prevRandao -> Bytes32 (#740)

This one is a bit of a mess because it has different names and types
across specs :/
This commit is contained in:
Jacek Sieka 2024-10-02 13:00:10 +02:00 committed by GitHub
parent 70b7519f02
commit 5ce3c4557f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View File

@ -29,7 +29,9 @@ type
gasUsed*: GasInt
timestamp*: EthTime
extraData*: seq[byte]
mixHash*: Hash32
mixHash*: Bytes32
## AKA mix_digest in some specs - Hash32 in the eth API but Bytes32 in
## the execution API and spec!
nonce*: Bytes8
baseFeePerGas*: Opt[UInt256] # EIP-1559
withdrawalsRoot*: Opt[Hash32] # EIP-4895
@ -39,10 +41,10 @@ type
requestsRoot*: Opt[Hash32] # EIP-7685
# starting from EIP-4399, `mixDigest` field is called `prevRandao`
template prevRandao*(h: Header): Hash32 =
template prevRandao*(h: Header): Bytes32 =
h.mixHash
template `prevRandao=`*(h: Header, hash: Hash32) =
template `prevRandao=`*(h: Header, hash: Bytes32) =
h.mixHash = hash
template txRoot*(h: Header): Root = h.transactionsRoot

View File

@ -60,9 +60,9 @@ suite "BlockHashOrNumber":
suite "Block encodings":
test "EIP-4399 prevRandao field":
var blk: BlockHeader
blk.prevRandao = testHash
blk.prevRandao = Bytes32 testHash
let res = blk.prevRandao
check testHash == res
check Bytes32(testHash) == res
test "EIP-4788 parentBeaconBlockRoot field":
let header = BlockHeader(