Avoid nested computeDigest scopes

This commit is contained in:
Etan Kissling 2024-11-22 00:06:03 +01:00
parent 34faa72988
commit 0660dc9711
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
1 changed files with 7 additions and 6 deletions

View File

@ -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 =
if requestList.len > 0:
let hash = computeDigest:
bind h
h.update([requestType.byte])
for request in requestList:
h.update SSZ.encode(request)
h.update(hash.data)
h.update(individualHash(requestType, requestList).data)
static:
doAssert DEPOSIT_REQUEST_TYPE < WITHDRAWAL_REQUEST_TYPE