mirror of https://github.com/status-im/nim-eth.git
EIP-4399 preparation
From EIP-4399 spec: Renaming The mixHash field SHOULD further be renamed to random. ...
This commit is contained in:
parent
eb6fd2a7b6
commit
cf95b688e6
|
@ -74,6 +74,9 @@ task test_db, "Run db tests":
|
|||
task test_utp, "Run utp tests":
|
||||
runTest("tests/utp/all_utp_tests")
|
||||
|
||||
task test_common, "Run common tests":
|
||||
runTest("tests/common/test_eth_types")
|
||||
|
||||
task test, "Run all tests":
|
||||
for filename in [
|
||||
"test_bloom",
|
||||
|
@ -87,6 +90,7 @@ task test, "Run all tests":
|
|||
test_trie_task()
|
||||
test_db_task()
|
||||
test_utp_task()
|
||||
test_common_task()
|
||||
|
||||
task test_discv5_full, "Run discovery v5 and its dependencies tests":
|
||||
test_keys_task()
|
||||
|
|
|
@ -244,6 +244,14 @@ 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 =
|
||||
h.mixDigest
|
||||
|
||||
template `random=`*(h: BlockHeader | BlockHeaderRef, hash: Hash256) =
|
||||
h.mixDigest = hash
|
||||
|
||||
func toBlockNonce*(n: uint64): BlockNonce =
|
||||
n.toBytesBE()
|
||||
|
||||
|
|
|
@ -49,3 +49,10 @@ suite "BlockHashOrNumber":
|
|||
|
||||
Json.roundtripTest BlockHashOrNumber(isHash: false, number: 1209231231),
|
||||
"\"1209231231\""
|
||||
|
||||
test "EIP-4399 random field":
|
||||
let hash = Hash256.fromHex "0x7a64245f7f95164f6176d90bd4903dbdd3e5433d555dd1385e81787f9672c588"
|
||||
var blk: BlockHeader
|
||||
blk.random = hash
|
||||
let res = blk.random
|
||||
check hash == res
|
||||
|
|
Loading…
Reference in New Issue