diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6a7fc9..6c5a806 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ jobs: max-parallel: 20 matrix: test_lang: [c] - branch: [version-1-6] + branch: [version-1-6, version-2-0, devel] target: - os: linux cpu: amd64 diff --git a/.gitignore b/.gitignore index 22fd483..cac9c51 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build/ *.dylib *.a *.exe +nimble.paths diff --git a/config.nims b/config.nims new file mode 100644 index 0000000..7c9db32 --- /dev/null +++ b/config.nims @@ -0,0 +1,4 @@ +# begin Nimble config (version 1) +when fileExists("nimble.paths"): + include "nimble.paths" +# end Nimble config diff --git a/src/mining.nim b/src/mining.nim index 131423d..71ca080 100644 --- a/src/mining.nim +++ b/src/mining.nim @@ -1,8 +1,8 @@ -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Distributed under the Apache v2 License (license terms are at http://www.apache.org/licenses/LICENSE-2.0). -import ./proof_of_work, ./private/conversion -import endians, random, math, nimcrypto +import ./proof_of_work +import random, math, nimcrypto proc mulCarry(a, b: uint64): tuple[carry, unit: uint64] = ## Multiplication in extended precision diff --git a/src/proof_of_work.nim b/src/proof_of_work.nim index baddb12..e3c0b9b 100644 --- a/src/proof_of_work.nim +++ b/src/proof_of_work.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Distributed under the Apache v2 License (license terms are at http://www.apache.org/licenses/LICENSE-2.0). import math, endians, @@ -13,11 +13,11 @@ export toHex, hexToByteArrayBE, hexToSeqBytesBE, toByteArrayBE # debug functions const REVISION* = 23 # Based on spec revision 23 WORD_BYTES = 4 # bytes in word - in Nim we use 64 bits words # TODO check that - DATASET_BYTES_INIT* = 2'u64^30 # bytes in dataset at genesis - DATASET_BYTES_GROWTH* = 2'u64^23 # dataset growth per epoch - CACHE_BYTES_INIT* = 2'u64^24 # bytes in cache at genesis - CACHE_BYTES_GROWTH* = 2'u64^17 # cache growth per epoch - CACHE_MULTIPLIER = 1024 # Size of the DAG relative to the cache + DATASET_BYTES_INIT* = 2'u64^30 # bytes in dataset at genesis + DATASET_BYTES_GROWTH* = 2'u64^23 # dataset growth per epoch + CACHE_BYTES_INIT* = 2'u64^24 # bytes in cache at genesis + CACHE_BYTES_GROWTH* = 2'u64^17 # cache growth per epoch + CACHE_MULTIPLIER* = 1024 # Size of the DAG relative to the cache EPOCH_LENGTH* = 30000 # blocks per epoch MIX_BYTES* = 128 # width of mix HASH_BYTES* = 64 # hash length in bytes @@ -31,7 +31,7 @@ const proc get_cache_size*(block_number: uint64): uint64 {.noSideEffect.}= result = CACHE_BYTES_INIT + CACHE_BYTES_GROWTH * (block_number div EPOCH_LENGTH) result -= HASH_BYTES - while (let dm = divmod(result, HASH_BYTES); + while (let dm = intmath.divmod(result, HASH_BYTES); dm.rem == 0 and not dm.quot.isPrime): # In a static lang, checking that the result of a division is prime # means checking that remainder == 0 and quotient is prime @@ -40,7 +40,7 @@ proc get_cache_size*(block_number: uint64): uint64 {.noSideEffect.}= proc get_data_size*(block_number: uint64): uint64 {.noSideEffect.}= result = DATASET_BYTES_INIT + DATASET_BYTES_GROWTH * (block_number div EPOCH_LENGTH) result -= MIX_BYTES - while (let dm = divmod(result, MIX_BYTES); + while (let dm = intmath.divmod(result, MIX_BYTES); dm.rem == 0 and not dm.quot.isPrime): result -= 2 * MIX_BYTES diff --git a/tests/all_tests.nim b/tests/all_tests.nim index f63cc3b..631e692 100644 --- a/tests/all_tests.nim +++ b/tests/all_tests.nim @@ -1,6 +1,8 @@ -# Copyright (c) 2018 Status Research & Development GmbH +# Copyright (c) 2018-2024 Status Research & Development GmbH # Distributed under the Apache v2 License (license terms are at http://www.apache.org/licenses/LICENSE-2.0). +{. warning[UnusedImport]:off .} + import ./test_internal_multiprecision_arithmetic, ./test_proof_of_work diff --git a/tests/test_internal_multiprecision_arithmetic.nim b/tests/test_internal_multiprecision_arithmetic.nim index 2ac2386..65bb30d 100644 --- a/tests/test_internal_multiprecision_arithmetic.nim +++ b/tests/test_internal_multiprecision_arithmetic.nim @@ -3,7 +3,7 @@ include ../src/mining -import unittest, random +import unittest suite "[Internal] Testing multi-precision arithmetic": test "Multi-Precision multiplication gives the proper unit (modulo 2^64)":