execution/engine withdrawals amount in uint64 gwei (#4509)

This commit is contained in:
tersec 2023-01-14 17:26:57 +00:00 committed by GitHub
parent 68e08c6f15
commit eb02415f00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 12 deletions

View File

@ -245,8 +245,6 @@ func asEth2Digest*(x: BlockHash): Eth2Digest =
template asBlockHash*(x: Eth2Digest): BlockHash =
BlockHash(x.data)
const weiInGwei = 1_000_000_000.u256
from ../spec/datatypes/capella import ExecutionPayload, Withdrawal
func asConsensusWithdrawal(w: WithdrawalV1): capella.Withdrawal =
@ -254,16 +252,14 @@ func asConsensusWithdrawal(w: WithdrawalV1): capella.Withdrawal =
index: w.index.uint64,
validator_index: w.validatorIndex.uint64,
address: ExecutionAddress(data: w.address.distinctBase),
# TODO spec doesn't mention non-even-multiples, also overflow
amount: (w.amount.u256 div weiInGwei).truncate(uint64))
amount: w.amount.uint64)
func asEngineWithdrawal(w: capella.Withdrawal): WithdrawalV1 =
WithdrawalV1(
index: Quantity(w.index),
validatorIndex: Quantity(w.validator_index),
address: Address(w.address.data),
amount: w.amount.u256 * weiInGwei)
amount: Quantity(w.amount))
func asConsensusExecutionPayload*(rpcExecutionPayload: ExecutionPayloadV1):
bellatrix.ExecutionPayload =

View File

@ -391,16 +391,13 @@ proc computeTransactionsTrieRoot*(
doAssert false, "HexaryTrie.put failed: " & $exc.msg
tr.rootHash()
func gweiToWei*(gwei: Gwei): UInt256 =
gwei.u256 * 1_000_000_000.u256
func toExecutionWithdrawal*(
withdrawal: capella.Withdrawal): ExecutionWithdrawal =
ExecutionWithdrawal(
index: withdrawal.index,
validatorIndex: withdrawal.validator_index,
address: EthAddress withdrawal.address.data,
amount: gweiToWei withdrawal.amount)
amount: withdrawal.amount)
# https://eips.ethereum.org/EIPS/eip-4895
proc computeWithdrawalsTrieRoot*(

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 8f0ae55353b95f888dce8a32bf810e58f7091b96
Subproject commit 68f4c53828cec749e398864bcc6b0097c8d66c31

2
vendor/nim-web3 vendored

@ -1 +1 @@
Subproject commit 33586798eae94f2c5bc543089b426769809549e1
Subproject commit b5188b0679aa36ae54ea083bcd68349ef1b344e7