Skip to content

Commit

Permalink
Adopt latest changes to requests hash computation
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Nov 22, 2024
1 parent 7b2b59a commit 213c6d3
Show file tree
Hide file tree
Showing 8 changed files with 955 additions and 6 deletions.
2 changes: 1 addition & 1 deletion nimbus/common/chain_config_hash.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2021-2024 Status Research & Development GmbH
# Copyright (c) 2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand Down
5 changes: 5 additions & 0 deletions nimbus/common/genesis.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import
eth/common/[hashes, accounts, headers, addresses],
../db/[ledger, core_db],
../constants,
../utils/utils,
./chain_config

# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -78,6 +79,10 @@ 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;
Expand Down
3 changes: 2 additions & 1 deletion nimbus/utils/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func calcRequestsHash*(requests: varargs[seq[byte]]): Hash32 =
var ctx: sha256
ctx.init()
for i, data in requests:
ctx.update(calcHash(i.byte, data).data)
if data.len > 0:
ctx.update(calcHash(i.byte, data).data)
ctx.finish(result.data)
ctx.clear()

Expand Down
Loading

0 comments on commit 213c6d3

Please sign in to comment.