Skip to content

Commit 3d12a91

Browse files
committed
eip-7685 compatible
1 parent a5910ca commit 3d12a91

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

nrpc/nrpc.nim

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
209209
# Make the forkchoiceUpdated call based, after loading attributes based on the consensus fork
210210
let fcuResponse = await rpcClient.forkchoiceUpdated(state, payloadAttributes)
211211
debug "forkchoiceUpdated", state = state, response = fcuResponse
212-
info "forkchoiceUpdated Request sent", response = fcuResponse.payloadStatus.status
212+
if fcuResponse.payloadStatus.status != PayloadExecutionStatus.valid:
213+
error "Forkchoice not validated", status = fcuResponse.payloadStatus.status
214+
quit(QuitFailure)
215+
else:
216+
info "forkchoiceUpdated Request sent",
217+
response = fcuResponse.payloadStatus.status
213218

214219
while running and currentBlockNumber < headBlck.header.number:
215220
var isAvailable = false
@@ -250,19 +255,24 @@ proc syncToEngineApi(conf: NRpcConf) {.async.} =
250255
versionedHashes = versioned_hashes
251256
elif consensusFork == ConsensusFork.Electra or
252257
consensusFork == ConsensusFork.Fulu:
253-
# Calculate the versioned hashes from the kzg commitments
254-
let versioned_hashes = mapIt(
255-
forkyBlck.message.body.blob_kzg_commitments,
256-
engine_api.VersionedHash(kzg_commitment_to_versioned_hash(it)),
257-
)
258-
# Execution Requests for Electra
259-
let execution_requests =
260-
@[
261-
SSZ.encode(forkyBlck.message.body.execution_requests.deposits),
262-
SSZ.encode(forkyBlck.message.body.execution_requests.withdrawals),
263-
SSZ.encode(forkyBlck.message.body.execution_requests.consolidations),
264-
]
265-
# TODO: Update to `newPayload()` once nim-web3 is updated
258+
let
259+
# Calculate the versioned hashes from the kzg commitments
260+
versioned_hashes = mapIt(
261+
forkyBlck.message.body.blob_kzg_commitments,
262+
engine_api.VersionedHash(kzg_commitment_to_versioned_hash(it)),
263+
)
264+
# Execution Requests for Electra
265+
execution_requests = block:
266+
var requests: seq[seq[byte]]
267+
for request_type, request_data in [
268+
SSZ.encode(forkyBlck.message.body.execution_requests.deposits),
269+
SSZ.encode(forkyBlck.message.body.execution_requests.withdrawals),
270+
SSZ.encode(forkyBlck.message.body.execution_requests.consolidations),
271+
]:
272+
if request_data.len > 0:
273+
requests.add @[request_type.byte] & request_data
274+
requests
275+
266276
payloadResponse = await rpcClient.engine_newPayloadV4(
267277
payload,
268278
versioned_hashes,

0 commit comments

Comments
 (0)