From 7564b21aded16fe9016730087ab7558f084505a5 Mon Sep 17 00:00:00 2001 From: tersec Date: Tue, 9 May 2023 20:19:44 +0000 Subject: [PATCH] support only Nim 1.6+ (#606) --- .github/workflows/ci.yml | 4 ++-- eth.nimble | 12 +++--------- eth/common/eth_hash.nim | 7 ++----- eth/common/eth_types.nim | 9 +++------ eth/db/kvstore.nim | 10 +++------- eth/db/kvstore_sqlite3.nim | 8 ++------ eth/trie/hexary.nim | 3 --- tests/rlp/test_api_usage.nim | 4 ---- 8 files changed, 15 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e11343b..a80346a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: cpu: amd64 #- os: windows #cpu: i386 - branch: [version-1-2, version-1-4, version-1-6, devel] + branch: [version-1-6, devel] include: - target: os: linux @@ -43,7 +43,7 @@ jobs: name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})' runs-on: ${{ matrix.builder }} - continue-on-error: ${{ matrix.branch == 'version-1-6' || matrix.branch == 'devel' }} + continue-on-error: ${{ matrix.branch == 'devel' }} timeout-minutes: 60 steps: - name: Checkout diff --git a/eth.nimble b/eth.nimble index 6121262..0034181 100644 --- a/eth.nimble +++ b/eth.nimble @@ -4,7 +4,7 @@ description = "Ethereum Common library" license = "MIT" skipDirs = @["tests"] -requires "nim >= 1.2.0", +requires "nim >= 1.6.0", "nimcrypto", "stint", "secp256k1", @@ -18,17 +18,11 @@ requires "nim >= 1.2.0", "testutils", "unittest2" -let styleCheckStyle = - if (NimMajor, NimMinor) < (1, 6): - "hint" - else: - "error" - let commonParams = " --skipUserCfg:on" & " --verbosity:0 --hints:off" & - " --warning[ObservableStores]:off " & - " --styleCheck:usages --styleCheck:" & styleCheckStyle & + " --warning[ObservableStores]:off" & + " --styleCheck:usages --styleCheck:error" & " " & getEnv("NIMFLAGS") & " -d:chronosStrictException" & " -d:chronicles_log_level=TRACE" diff --git a/eth/common/eth_hash.nim b/eth/common/eth_hash.nim index f4fbb3f..eb0de80 100644 --- a/eth/common/eth_hash.nim +++ b/eth/common/eth_hash.nim @@ -1,13 +1,10 @@ -# Copyright (c) 2022 Status Research & Development GmbH +# Copyright (c) 2022-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} ## keccak256 is used across ethereum as the "default" hash function and this ## module provides a type and some helpers to produce such hashes diff --git a/eth/common/eth_types.nim b/eth/common/eth_types.nim index 38285d4..21d17ce 100644 --- a/eth/common/eth_types.nim +++ b/eth/common/eth_types.nim @@ -1,15 +1,12 @@ -# Copyright (c) 2022 Status Research & Development GmbH +# Copyright (c) 2022-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} -else: - {.push raises: [].} +{.push raises: [].} -## Core ethereum types and smalll helpers - keep focused as it gets imported +## Core ethereum types and small helpers - keep focused as it gets imported ## from many places import diff --git a/eth/db/kvstore.nim b/eth/db/kvstore.nim index 3b54d37..653fc4b 100644 --- a/eth/db/kvstore.nim +++ b/eth/db/kvstore.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2020 Status Research & Development GmbH +# Copyright (c) 2018-2023 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -8,12 +8,8 @@ ## Simple Key-Value store database interface that allows creating multiple ## tables within each store -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} - {.pragma: callback, gcsafe, raises: [Defect].} -else: - {.push raises: [].} - {.pragma: callback, gcsafe, raises: [].} +{.push raises: [].} +{.pragma: callback, gcsafe, raises: [].} import std/[tables, hashes, sets], diff --git a/eth/db/kvstore_sqlite3.nim b/eth/db/kvstore_sqlite3.nim index 6b13455..f240777 100644 --- a/eth/db/kvstore_sqlite3.nim +++ b/eth/db/kvstore_sqlite3.nim @@ -1,11 +1,7 @@ ## Implementation of KvStore based on sqlite3 -when (NimMajor, NimMinor) < (1, 4): - {.push raises: [Defect].} - {.pragma: callback, gcsafe, raises: [Defect].} -else: - {.push raises: [Defect].} - {.pragma: callback, gcsafe, raises: [].} +{.push raises: [Defect].} +{.pragma: callback, gcsafe, raises: [].} import std/[os, options, strformat, typetraits], diff --git a/eth/trie/hexary.nim b/eth/trie/hexary.nim index c262363..dcda646 100644 --- a/eth/trie/hexary.nim +++ b/eth/trie/hexary.nim @@ -32,9 +32,6 @@ proc expectHash(r: Rlp): seq[byte] = raise newException(RlpTypeMismatch, "RLP expected to be a Keccak hash value, but has an incorrect length") -when (NimMajor, NimMinor, NimPatch) < (1, 4, 0): - type AssertionDefect = AssertionError - type MissingNodeError* = ref object of AssertionDefect path*: NibblesSeq nodeHashBytes*: seq[byte] diff --git a/tests/rlp/test_api_usage.nim b/tests/rlp/test_api_usage.nim index e9578f2..0ca6ee0 100644 --- a/tests/rlp/test_api_usage.nim +++ b/tests/rlp/test_api_usage.nim @@ -35,10 +35,6 @@ proc test_blockBodyTranscode() = for n in 0 ..< min(trBlkSeq.len, trBlkSeq.len): check (n, trBlkSeq[n]) == (n, blkSeq[n]) - -when (NimMajor, NimMinor, NimPatch) < (1, 4, 0): - type AssertionDefect = AssertionError - suite "test api usage": test "empty bytes are not a proper RLP": var rlp = rlpFromBytes seq[byte](@[])