From 622e6489d8e8e98a2f1b40205ab6b0dd9cc99523 Mon Sep 17 00:00:00 2001 From: jangko Date: Sun, 27 Feb 2022 11:40:15 +0700 Subject: [PATCH] EIP-4399 changes: random -> prevRandao --- eth/common/eth_types.nim | 7 +++---- tests/common/test_eth_types.nim | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/eth/common/eth_types.nim b/eth/common/eth_types.nim index c1cf39b..7e771a4 100644 --- a/eth/common/eth_types.nim +++ b/eth/common/eth_types.nim @@ -244,12 +244,11 @@ func baseFee*(h: BlockHeader | BlockHeaderRef): UInt256 = template `baseFee=`*(h: BlockHeader | BlockHeaderRef, data: UInt256) = h.fee = some(data) -# starting from EIP-4399, `mixHash`/`mixDigest` field will be alled `random` -# https://github.com/ethereum/EIPs/blob/bd156daf2afa38aa95bc2137d3121ff536e50645/EIPS/eip-4399.md -template random*(h: BlockHeader | BlockHeaderRef): Hash256 = +# starting from EIP-4399, `mixHash`/`mixDigest` field will be alled `prevRandao` +template prevRandao*(h: BlockHeader | BlockHeaderRef): Hash256 = h.mixDigest -template `random=`*(h: BlockHeader | BlockHeaderRef, hash: Hash256) = +template `prevRandao=`*(h: BlockHeader | BlockHeaderRef, hash: Hash256) = h.mixDigest = hash func toBlockNonce*(n: uint64): BlockNonce = diff --git a/tests/common/test_eth_types.nim b/tests/common/test_eth_types.nim index fa6b43b..a4fb66c 100644 --- a/tests/common/test_eth_types.nim +++ b/tests/common/test_eth_types.nim @@ -50,9 +50,9 @@ suite "BlockHashOrNumber": Json.roundtripTest BlockHashOrNumber(isHash: false, number: 1209231231), "\"1209231231\"" - test "EIP-4399 random field": + test "EIP-4399 prevRandao field": let hash = Hash256.fromHex "0x7a64245f7f95164f6176d90bd4903dbdd3e5433d555dd1385e81787f9672c588" var blk: BlockHeader - blk.random = hash - let res = blk.random + blk.prevRandao = hash + let res = blk.prevRandao check hash == res