reduce compiler warnings

This commit is contained in:
jangko 2023-05-16 11:15:10 +07:00
parent ff0fc98fdf
commit 4e332868b7
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
9 changed files with 31 additions and 32 deletions

View File

@ -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)

View File

@ -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

View File

@ -1,5 +1,4 @@
import
chronicles,
chronos,
stint,
eth/common/eth_types,

View File

@ -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

View File

@ -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)

View File

@ -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.}

View File

@ -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,

View File

@ -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],

View File

@ -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].} =