From f13f23e21bae1a2b1cfd2ebba8d48ea0c25a23b5 Mon Sep 17 00:00:00 2001 From: henridf Date: Tue, 11 Jul 2023 21:35:55 +0200 Subject: [PATCH] Complete Deneb bn side for /eth/v2/validator/blocks/{slot} (#5146) * Complete Deneb bn side for /eth/v2/validator/blocks/{slot} * Address review feedback * More review feedback * Tighten up when condition * Update beacon_chain/rpc/rest_validator_api.nim Co-authored-by: tersec --------- Co-authored-by: tersec --- beacon_chain/rpc/rest_validator_api.nim | 52 +++++++++++++++++-------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/beacon_chain/rpc/rest_validator_api.nim b/beacon_chain/rpc/rest_validator_api.nim index 1dd775d01..498589d09 100644 --- a/beacon_chain/rpc/rest_validator_api.nim +++ b/beacon_chain/rpc/rest_validator_api.nim @@ -395,14 +395,6 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) = let res = case node.dag.cfg.consensusForkAtEpoch(qslot.epoch) of ConsensusFork.Deneb: - # TODO - # We should return a block with sidecars here - # https://github.com/ethereum/beacon-APIs/pull/302/files - # The code paths leading to makeBeaconBlockForHeadAndSlot are already - # partially refactored to make it possible to return the blobs from - # the call, but the signature of the call needs to be changed furhter - # to access the blobs here. - discard $denebImplementationMissing await makeBeaconBlockForHeadAndSlot( deneb.ExecutionPayloadForSigning, node, qrandao, proposer, qgraffiti, qhead, qslot) @@ -418,17 +410,43 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) = return RestApiResponse.jsonError(Http400, InvalidSlotValueError) if res.isErr(): return RestApiResponse.jsonError(Http400, res.error()) - res.get.blck + res.get return - if contentType == sszMediaType: - let headers = [("eth-consensus-version", message.kind.toString())] - withBlck(message): + withBlck(message.blck): + let data = + when blck is deneb.BeaconBlock: + let bundle = message.blobsBundleOpt.get() + let blockRoot = hash_tree_root(blck) + var sidecars = newSeqOfCap[BlobSidecar](bundle.blobs.len) + for i in 0..