Skip to content

Commit

Permalink
Bump nim-eth for revert GasInt back to int64 (#6347)
Browse files Browse the repository at this point in the history
* Bump nim-eth for revert GasInt back to int64

* Fix libnimbus_lc
  • Loading branch information
jangko authored Jun 13, 2024
1 parent 20af24e commit fb0494e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
11 changes: 6 additions & 5 deletions beacon_chain/libnimbus_lc/libnimbus_lc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import
std/[json, sequtils, times],
stew/saturation_arith,
eth/common/[eth_types_rlp, transaction],
eth/keys,
eth/p2p/discoveryv5/random2,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions beacon_chain/spec/helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions tests/testblockutil.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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(
Expand Down

0 comments on commit fb0494e

Please sign in to comment.