mirror of https://github.com/status-im/nim-eth.git
EIP-4399 changes: random -> prevRandao
This commit is contained in:
parent
63add129b8
commit
622e6489d8
|
@ -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 =
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue