Revert "Adopt latest changes to requests hash computation" (#2892)

* Revert "Adopt latest changes to requests hash computation (#2862)"

This reverts commit 1721435b3c.

* Fix test vector requestHash

---------

Co-authored-by: jangko <jangko128@gmail.com>
This commit is contained in:
tersec 2024-11-29 09:13:08 +00:00 committed by GitHub
parent 6142183d2c
commit b2a4373cc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 8 additions and 957 deletions

View File

@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2021-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))

View File

@ -16,7 +16,6 @@ import
eth/common/[hashes, accounts, headers, addresses],
../db/[ledger, core_db],
../constants,
../utils/utils,
./chain_config
# ------------------------------------------------------------------------------
@ -79,10 +78,6 @@ proc toGenesisHeader*(
result.excessBlobGas = Opt.some g.excessBlobGas.get(0'u64)
result.parentBeaconBlockRoot = Opt.some g.parentBeaconBlockRoot.get(default(Hash32))
if fork >= Prague:
const EmptyRequestsHash = calcRequestsHash()
result.requestsHash = Opt.some(EmptyRequestsHash)
proc toGenesisHeader*(
genesis: Genesis;
fork: HardFork;

View File

@ -40,8 +40,7 @@ func calcRequestsHash*(requests: varargs[seq[byte]]): Hash32 =
var ctx: sha256
ctx.init()
for i, data in requests:
if data.len > 0:
ctx.update(calcHash(i.byte, data).data)
ctx.update(calcHash(i.byte, data).data)
ctx.finish(result.data)
ctx.clear()

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@
"payload": {
"baseFeePerGas": "0x7",
"blobGasUsed": "0x40000",
"blockHash": "0x2ad74d1c5c12bcdedbdc821ae5d18f44e732b4096b6496a23bd9483d202003c5",
"blockHash": "0x187307d7dc9beb87af2a1d8340e9f17a3bbe4738963daeaf6d8e13b27b2d6a7f",
"blockNumber": "0x94b2",
"excessBlobGas": "0x0",
"extraData": "0xd883010e0c846765746888676f312e32332e32856c696e7578",

View File

@ -12,8 +12,7 @@ import
std/[os],
unittest2,
../nimbus/config,
../nimbus/common/common,
../nimbus/utils/utils
../nimbus/common/common
const
baseDir = [".", "tests", ".."/"tests", $DirSep] # path containg repo
@ -133,21 +132,6 @@ proc customGenesisTest() =
check com.genesisHeader.blockHash == genesisHash
check com.chainId == 17000.ChainId
test "Prague genesis":
# pre Prague
var cg: NetworkParams
check loadNetworkParams("mekong.json".findFilePath, cg)
var com = CommonRef.new(newCoreDbRef DefaultDbMemory, params = cg)
check com.genesisHeader.requestsHash.isNone
# post prague
const EmptyRequestsHash = hash32"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
check loadNetworkParams("prague.json".findFilePath, cg)
com = CommonRef.new(newCoreDbRef DefaultDbMemory, params = cg)
check com.genesisHeader.requestsHash.isSome
check com.genesisHeader.requestsHash.get == EmptyRequestsHash
check calcRequestsHash(default(seq[byte]), default(seq[byte]), default(seq[byte])) == EmptyRequestsHash
proc genesisMain*() =
genesisTest()
customGenesisTest()

View File

@ -18,7 +18,7 @@
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requestsHash": "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f",
"requests": [
"0x",
"0x",

View File

@ -34,7 +34,7 @@
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requestsHash": "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f",
"requests": [
"0x",
"0x",

View File

@ -34,7 +34,7 @@
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0xf34c7b46f404c6c6f91b540c098b6dfe3f59b7e50ad155807c8c7d2221e52241",
"requestsHash": "0xa5c19ed76c01fe25a67b7ef8c227caa34951e8c7e74168408b5be0861dac686d",
"requests": [
"0x81521c60874daf5b425c21e44caf045c4d475e8b33a557a28cee3c46ef9cf9bd95b4c75a0bb629981b40d0102452dd4c020000000000000000000000332e43696a505ef45b9319973785f837ce5267b9000065cd1d0000008c8f2647f342d2c3e8fd07c6b3b9b16383ac11c4be6a6962c7fc18a789daee5fac20ee0bbe4a10383759aaffacacb72b0d67f998730cdf4995fe73afe434dfce2803b343606f67fc4995597c0af9e0fe9ed00006e5889bec29171f670e7d9be20000000000000000",
"0x",

View File

@ -60,7 +60,7 @@
"gasUsed": "0x15fa9",
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requestsHash": "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f",
"requests": [
"0x",
"0x",