execution/engine withdrawals amount in uint64 gwei (#4509)
This commit is contained in:
parent
68e08c6f15
commit
eb02415f00
|
@ -245,8 +245,6 @@ func asEth2Digest*(x: BlockHash): Eth2Digest =
|
||||||
template asBlockHash*(x: Eth2Digest): BlockHash =
|
template asBlockHash*(x: Eth2Digest): BlockHash =
|
||||||
BlockHash(x.data)
|
BlockHash(x.data)
|
||||||
|
|
||||||
const weiInGwei = 1_000_000_000.u256
|
|
||||||
|
|
||||||
from ../spec/datatypes/capella import ExecutionPayload, Withdrawal
|
from ../spec/datatypes/capella import ExecutionPayload, Withdrawal
|
||||||
|
|
||||||
func asConsensusWithdrawal(w: WithdrawalV1): capella.Withdrawal =
|
func asConsensusWithdrawal(w: WithdrawalV1): capella.Withdrawal =
|
||||||
|
@ -254,16 +252,14 @@ func asConsensusWithdrawal(w: WithdrawalV1): capella.Withdrawal =
|
||||||
index: w.index.uint64,
|
index: w.index.uint64,
|
||||||
validator_index: w.validatorIndex.uint64,
|
validator_index: w.validatorIndex.uint64,
|
||||||
address: ExecutionAddress(data: w.address.distinctBase),
|
address: ExecutionAddress(data: w.address.distinctBase),
|
||||||
|
amount: w.amount.uint64)
|
||||||
# TODO spec doesn't mention non-even-multiples, also overflow
|
|
||||||
amount: (w.amount.u256 div weiInGwei).truncate(uint64))
|
|
||||||
|
|
||||||
func asEngineWithdrawal(w: capella.Withdrawal): WithdrawalV1 =
|
func asEngineWithdrawal(w: capella.Withdrawal): WithdrawalV1 =
|
||||||
WithdrawalV1(
|
WithdrawalV1(
|
||||||
index: Quantity(w.index),
|
index: Quantity(w.index),
|
||||||
validatorIndex: Quantity(w.validator_index),
|
validatorIndex: Quantity(w.validator_index),
|
||||||
address: Address(w.address.data),
|
address: Address(w.address.data),
|
||||||
amount: w.amount.u256 * weiInGwei)
|
amount: Quantity(w.amount))
|
||||||
|
|
||||||
func asConsensusExecutionPayload*(rpcExecutionPayload: ExecutionPayloadV1):
|
func asConsensusExecutionPayload*(rpcExecutionPayload: ExecutionPayloadV1):
|
||||||
bellatrix.ExecutionPayload =
|
bellatrix.ExecutionPayload =
|
||||||
|
|
|
@ -391,16 +391,13 @@ proc computeTransactionsTrieRoot*(
|
||||||
doAssert false, "HexaryTrie.put failed: " & $exc.msg
|
doAssert false, "HexaryTrie.put failed: " & $exc.msg
|
||||||
tr.rootHash()
|
tr.rootHash()
|
||||||
|
|
||||||
func gweiToWei*(gwei: Gwei): UInt256 =
|
|
||||||
gwei.u256 * 1_000_000_000.u256
|
|
||||||
|
|
||||||
func toExecutionWithdrawal*(
|
func toExecutionWithdrawal*(
|
||||||
withdrawal: capella.Withdrawal): ExecutionWithdrawal =
|
withdrawal: capella.Withdrawal): ExecutionWithdrawal =
|
||||||
ExecutionWithdrawal(
|
ExecutionWithdrawal(
|
||||||
index: withdrawal.index,
|
index: withdrawal.index,
|
||||||
validatorIndex: withdrawal.validator_index,
|
validatorIndex: withdrawal.validator_index,
|
||||||
address: EthAddress withdrawal.address.data,
|
address: EthAddress withdrawal.address.data,
|
||||||
amount: gweiToWei withdrawal.amount)
|
amount: withdrawal.amount)
|
||||||
|
|
||||||
# https://eips.ethereum.org/EIPS/eip-4895
|
# https://eips.ethereum.org/EIPS/eip-4895
|
||||||
proc computeWithdrawalsTrieRoot*(
|
proc computeWithdrawalsTrieRoot*(
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8f0ae55353b95f888dce8a32bf810e58f7091b96
|
Subproject commit 68f4c53828cec749e398864bcc6b0097c8d66c31
|
|
@ -1 +1 @@
|
||||||
Subproject commit 33586798eae94f2c5bc543089b426769809549e1
|
Subproject commit b5188b0679aa36ae54ea083bcd68349ef1b344e7
|
Loading…
Reference in New Issue