Skip to content

Commit

Permalink
Adopt latest changes to request hash computation (#6718)
Browse files Browse the repository at this point in the history
* Adopt latest changes to request hash computation

The `requestType` of empty lists is no longer part of the requests hash.

- ethereum/EIPs#8989

* Avoid nested computeDigest scopes
  • Loading branch information
etan-status authored Nov 24, 2024
1 parent cd8de2f commit ddad30f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions beacon_chain/spec/helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -460,15 +460,16 @@ func computeRequestsHash(
WITHDRAWAL_REQUEST_TYPE = 0x01'u8 # EIP-7002
CONSOLIDATION_REQUEST_TYPE = 0x02'u8 # EIP-7251

template individualHash(requestType, requestList): Digest =
computeDigest:
h.update([requestType.byte])
for request in requestList:
h.update SSZ.encode(request)

let requestsHash = computeDigest:
template mixInRequests(requestType, requestList): untyped =
block:
let hash = computeDigest:
bind h
h.update([requestType.byte])
for request in requestList:
h.update SSZ.encode(request)
h.update(hash.data)
if requestList.len > 0:
h.update(individualHash(requestType, requestList).data)

static:
doAssert DEPOSIT_REQUEST_TYPE < WITHDRAWAL_REQUEST_TYPE
Expand Down

0 comments on commit ddad30f

Please sign in to comment.