diff --git a/nimbus/common/common.nim b/nimbus/common/common.nim index ee51f7022..9fbb8c91b 100644 --- a/nimbus/common/common.nim +++ b/nimbus/common/common.nim @@ -92,7 +92,7 @@ type proc hardForkTransition*( com: CommonRef, forkDeterminer: ForkDeterminationInfo) - {.gcsafe, raises: [CatchableError].} + {.gcsafe, raises: [].} func cliquePeriod*(com: CommonRef): int @@ -253,7 +253,7 @@ func toHardFork*( proc hardForkTransition( com: CommonRef, forkDeterminer: ForkDeterminationInfo) - {.gcsafe, raises: [CatchableError].} = + {.gcsafe, raises: [].} = ## When consensus type already transitioned to POS, ## the storage can choose not to store TD anymore, ## at that time, TD is no longer needed to find a fork @@ -268,7 +268,7 @@ proc hardForkTransition*( number: BlockNumber, td: Option[DifficultyInt], time: Option[EthTime]) - {.gcsafe, raises: [CatchableError].} = + {.gcsafe, raises: [].} = com.hardForkTransition(ForkDeterminationInfo( blockNumber: number, time: time, td: td)) @@ -277,12 +277,12 @@ proc hardForkTransition*( parentHash: Hash256, number: BlockNumber, time: Option[EthTime]) - {.gcsafe, raises: [CatchableError].} = + {.gcsafe, raises: [].} = com.hardForkTransition(number, getTdIfNecessary(com, parentHash), time) proc hardForkTransition*( com: CommonRef, header: BlockHeader) - {.gcsafe, raises: [CatchableError].} = + {.gcsafe, raises: [].} = com.hardForkTransition( header.parentHash, header.blockNumber, some(header.timestamp)) @@ -357,7 +357,7 @@ proc initializeEmptyDb*(com: CommonRef) doAssert(canonicalHeadHashKey().toOpenArray in trieDB) proc syncReqNewHead*(com: CommonRef; header: BlockHeader) - {.gcsafe, raises: [CatchableError].} = + {.gcsafe, raises: [].} = ## Used by RPC to update the beacon head for snap sync if not com.syncReqNewHead.isNil: com.syncReqNewHead(header) diff --git a/nimbus/core/executor/process_transaction.nim b/nimbus/core/executor/process_transaction.nim index 85f600136..aa91e9a7f 100644 --- a/nimbus/core/executor/process_transaction.nim +++ b/nimbus/core/executor/process_transaction.nim @@ -38,7 +38,7 @@ proc commitOrRollbackDependingOnGasUsed( vmState: BaseVMState, accTx: SavePoint, header: BlockHeader, tx: Transaction, gasBurned: GasInt, priorityFee: GasInt): - Result[GasInt, void] {.raises: [RlpError].} = + Result[GasInt, void] {.raises: [].} = # Make sure that the tx does not exceed the maximum cumulative limit as # set in the block header. Again, the eip-1559 reference does not mention # an early stop. It would rather detect differing values for the block diff --git a/nimbus/evm/async/operations.nim b/nimbus/evm/async/operations.nim index b4c87215f..e8a4fe034 100644 --- a/nimbus/evm/async/operations.nim +++ b/nimbus/evm/async/operations.nim @@ -1,5 +1,4 @@ import - chronicles, chronos, stint, eth/common/eth_types, diff --git a/nimbus/evm/interpreter/gas_costs.nim b/nimbus/evm/interpreter/gas_costs.nim index 60e2248a8..065b30793 100644 --- a/nimbus/evm/interpreter/gas_costs.nim +++ b/nimbus/evm/interpreter/gas_costs.nim @@ -327,13 +327,13 @@ template gasCosts(fork: EVMFork, prefix, ResultGasCostsName: untyped) = SSTORE_RESET_GAS = FeeSchedule[GasSreset] const - NoopGas = SLOAD_GAS # if the value doesn't change. - DirtyGas = SLOAD_GAS # if a dirty value is changed. - InitGas = FeeSchedule[GasSset] # from clean zero to non-zero - InitRefund = FeeSchedule[GasSset] - SLOAD_GAS # resetting to the original zero value - CleanGas = SSTORE_RESET_GAS # from clean non-zero to something else - CleanRefund = SSTORE_RESET_GAS - SLOAD_GAS # resetting to the original non-zero value - ClearRefund = FeeSchedule[RefundsClear]# clearing an originally existing storage slot + NoopGas {.used.} = SLOAD_GAS # if the value doesn't change. + DirtyGas {.used.} = SLOAD_GAS # if a dirty value is changed. + InitGas {.used.} = FeeSchedule[GasSset] # from clean zero to non-zero + InitRefund {.used.} = FeeSchedule[GasSset] - SLOAD_GAS # resetting to the original zero value + CleanGas {.used.} = SSTORE_RESET_GAS # from clean non-zero to something else + CleanRefund {.used.} = SSTORE_RESET_GAS - SLOAD_GAS # resetting to the original non-zero value + ClearRefund {.used.} = FeeSchedule[RefundsClear]# clearing an originally existing storage slot when fork < FkConstantinople or fork == FkPetersburg: let isStorageEmpty = gasParams.s_currentValue.isZero diff --git a/nimbus/evm/interpreter/op_handlers/oph_arithmetic.nim b/nimbus/evm/interpreter/op_handlers/oph_arithmetic.nim index 8dd48652e..b0b723493 100644 --- a/nimbus/evm/interpreter/op_handlers/oph_arithmetic.nim +++ b/nimbus/evm/interpreter/op_handlers/oph_arithmetic.nim @@ -54,7 +54,7 @@ const ## 0x04, Division let (lhs, rhs) = k.cpt.stack.popInt(2) k.cpt.stack.push: - if rhs == 0: + if rhs.isZero: # EVM special casing of div by 0 zero(UInt256) else: @@ -66,7 +66,7 @@ const let (lhs, rhs) = k.cpt.stack.popInt(2) var r: UInt256 - if rhs != 0: + if rhs.isZero.not: var a = lhs var b = rhs var signA, signB: bool @@ -81,7 +81,7 @@ const ## 0x06, Modulo let (lhs, rhs) = k.cpt.stack.popInt(2) k.cpt.stack.push: - if rhs == 0: + if rhs.isZero: zero(UInt256) else: lhs mod rhs @@ -92,7 +92,7 @@ const let (lhs, rhs) = k.cpt.stack.popInt(2) var r: UInt256 - if rhs != 0: + if rhs.isZero.not: var sign: bool var v = lhs var m = rhs @@ -109,7 +109,7 @@ const let (lhs, rhs, modulus) = k.cpt.stack.popInt(3) k.cpt.stack.push: - if modulus == 0: + if modulus.isZero: zero(UInt256) else: addmod(lhs, rhs, modulus) @@ -121,7 +121,7 @@ const let (lhs, rhs, modulus) = k.cpt.stack.popInt(3) k.cpt.stack.push: - if modulus == 0: + if modulus.isZero: zero(UInt256) else: mulmod(lhs, rhs, modulus) diff --git a/nimbus/evm/modexp.nim b/nimbus/evm/modexp.nim index a06d2e1ef..7d4118812 100644 --- a/nimbus/evm/modexp.nim +++ b/nimbus/evm/modexp.nim @@ -7,7 +7,7 @@ const vendorPath = currentSourcePath.rsplit({DirSep, AltSep}, 3)[0] & "/vendor" srcPath = vendorPath & "/libtommath" -{.passc: "-IMP_32BIT"} +{.passc: "-DMP_32BIT"} {.compile: srcPath & "/mp_radix_size.c"} {.compile: srcPath & "/mp_to_radix.c"} {.compile: srcPath & "/mp_init_u64.c"} @@ -124,9 +124,9 @@ type const MP_OKAY = 0.mp_err - MP_LT = -1 - MP_EQ = 0 - MP_GT = 1 + MP_LT* = -1 + MP_EQ* = 0 + MP_GT* = 1 template getPtr(z: untyped): untyped = when (NimMajor, NimMinor) > (1,6): @@ -158,9 +158,9 @@ proc mp_to_ubin(a: mp_int, buf: ptr byte, maxlen: csize_t, written: var csize_t) # Y = G**X (mod P) proc mp_exptmod(G, X, P, Y: mp_int): mp_err {.mp_abi.} -proc mp_get_i32(a: mp_int): int32 {.mp_abi.} -proc mp_get_u32(a: mp_int): uint32 = - cast[uint32](mp_get_i32(a)) +#proc mp_get_i32(a: mp_int): int32 {.mp_abi.} +#proc mp_get_u32(a: mp_int): uint32 = +# cast[uint32](mp_get_i32(a)) # proc mp_init_u64(a: mp_int, b: uint64): mp_err {.mp_abi.} # proc mp_set_u64(a: mp_int, b: uint64) {.mp_abi.} diff --git a/nimbus/evm/precompiles.nim b/nimbus/evm/precompiles.nim index 34647fbbb..b36cce53e 100644 --- a/nimbus/evm/precompiles.nim +++ b/nimbus/evm/precompiles.nim @@ -9,7 +9,7 @@ # according to those terms. import - std/[math, macros], + std/[macros], "."/[types, blake2b_f, blscurve], ./interpreter/[gas_meter, gas_costs, utils/utils_numeric], ../errors, eth/[common, keys], chronicles, diff --git a/nimbus/transaction/call_common.nim b/nimbus/transaction/call_common.nim index f872fda96..433bd1c29 100644 --- a/nimbus/transaction/call_common.nim +++ b/nimbus/transaction/call_common.nim @@ -9,7 +9,7 @@ {.push raises: [].} import - eth/common/eth_types, stint, options, stew/ranges/ptr_arith, + eth/common/eth_types, stint, options, stew/ptrops, chronos, ".."/[vm_types, vm_state, vm_computation, vm_state_transactions], ".."/[vm_internals, vm_precompiles, vm_gas_costs], diff --git a/stateless/witness_from_tree.nim b/stateless/witness_from_tree.nim index 61c1b488c..4ea02b420 100644 --- a/stateless/witness_from_tree.nim +++ b/stateless/witness_from_tree.nim @@ -89,10 +89,10 @@ proc writeUVarint(wb: var WitnessBuilder, x: UInt256) # we don't truncate to byte here, int will be faster var b = value.truncate(int) and 0x7F # low order 7 bits of value value = value shr 7 - if value != 0: # more bytes to come + if value.isZero.not: # more bytes to come b = b or 0x80 # set high order bit of b wb.writeByte(b) - if value == 0: break + if value.isZero: break proc writeNibbles(wb: var WitnessBuilder; n: NibblesSeq, withLen: bool = true) {.gcsafe, raises: [IOError].} =