From fb0494e7399b62d7120a8c0b06a854a9a52b8eec Mon Sep 17 00:00:00 2001 From: andri lim Date: Thu, 13 Jun 2024 20:25:59 +0700 Subject: [PATCH] Bump nim-eth for revert GasInt back to int64 (#6347) * Bump nim-eth for revert GasInt back to int64 * Fix libnimbus_lc --- beacon_chain/libnimbus_lc/libnimbus_lc.nim | 11 ++++++----- beacon_chain/spec/helpers.nim | 6 +++--- tests/testblockutil.nim | 6 ++++-- vendor/nim-eth | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/beacon_chain/libnimbus_lc/libnimbus_lc.nim b/beacon_chain/libnimbus_lc/libnimbus_lc.nim index c3aa4eac9e..cb0c7876b1 100644 --- a/beacon_chain/libnimbus_lc/libnimbus_lc.nim +++ b/beacon_chain/libnimbus_lc/libnimbus_lc.nim @@ -9,6 +9,7 @@ import std/[json, sequtils, times], + stew/saturation_arith, eth/common/[eth_types_rlp, transaction], eth/keys, eth/p2p/discoveryv5/random2, @@ -1257,8 +1258,8 @@ proc ETHExecutionBlockHeaderCreateFromJson( logsBloom: distinctBase(data.logsBloom), difficulty: data.difficulty, number: distinctBase(data.number), - gasLimit: distinctBase(data.gasLimit), - gasUsed: distinctBase(data.gasUsed), + gasLimit: GasInt.saturate distinctBase(data.gasLimit), + gasUsed: GasInt.saturate distinctBase(data.gasUsed), timestamp: EthTime(distinctBase(data.timestamp)), extraData: distinctBase(data.extraData), mixHash: data.mixHash.asEth2Digest, @@ -1613,9 +1614,9 @@ proc ETHTransactionsCreateFromJson( chainId: distinctBase(tx.chainId).u256, `from`: ExecutionAddress(data: fromAddress), nonce: tx.nonce, - maxPriorityFeePerGas: tx.maxPriorityFeePerGas, - maxFeePerGas: tx.maxFeePerGas, - gas: tx.gasLimit, + maxPriorityFeePerGas: tx.maxPriorityFeePerGas.uint64, + maxFeePerGas: tx.maxFeePerGas.uint64, + gas: tx.gasLimit.uint64, destinationType: destinationType, to: ExecutionAddress(data: toAddress), value: tx.value, diff --git a/beacon_chain/spec/helpers.nim b/beacon_chain/spec/helpers.nim index ee376329d8..f0d2d00916 100644 --- a/beacon_chain/spec/helpers.nim +++ b/beacon_chain/spec/helpers.nim @@ -513,9 +513,9 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader = logsBloom : payload.logs_bloom.data, difficulty : default(DifficultyInt), number : payload.block_number, - gasLimit : cast[GasInt](payload.gas_limit), - gasUsed : cast[GasInt](payload.gas_used), - timestamp : EthTime(int64.saturate payload.timestamp), + gasLimit : GasInt.saturate(payload.gas_limit), + gasUsed : GasInt.saturate(payload.gas_used), + timestamp : EthTime(payload.timestamp), extraData : payload.extra_data.asSeq, mixHash : payload.prev_randao, # EIP-4399 `mixHash` -> `prevRandao` nonce : default(BlockNonce), diff --git a/tests/testblockutil.nim b/tests/testblockutil.nim index e3a1dba835..7820fb5574 100644 --- a/tests/testblockutil.nim +++ b/tests/testblockutil.nim @@ -118,6 +118,8 @@ proc build_empty_merge_execution_payload(state: bellatrix.BeaconState): bellatrix.ExecutionPayloadForSigning(executionPayload: payload, blockValue: Wei.zero) +from stew/saturating_arith import saturate + proc build_empty_execution_payload( state: bellatrix.BeaconState, feeRecipient: Eth1Address): bellatrix.ExecutionPayloadForSigning = @@ -127,8 +129,8 @@ proc build_empty_execution_payload( latest = state.latest_execution_payload_header timestamp = compute_timestamp_at_slot(state, state.slot) randao_mix = get_randao_mix(state, get_current_epoch(state)) - base_fee = calcEip1599BaseFee(latest.gas_limit, - latest.gas_used, + base_fee = calcEip1599BaseFee(GasInt.saturate latest.gas_limit, + GasInt.saturate latest.gas_used, latest.base_fee_per_gas) var payload = bellatrix.ExecutionPayloadForSigning( diff --git a/vendor/nim-eth b/vendor/nim-eth index 9b6497ed8a..f169068df6 160000 --- a/vendor/nim-eth +++ b/vendor/nim-eth @@ -1 +1 @@ -Subproject commit 9b6497ed8a05ba25ee47142f3fc1f61742b51a6c +Subproject commit f169068df6c11a2aeba27584c60e354e19c42e94