mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-20 10:18:35 +00:00
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 <tersec@users.noreply.github.com> --------- Co-authored-by: tersec <tersec@users.noreply.github.com>
This commit is contained in:
parent
a2adbf809f
commit
f13f23e21b
@ -395,14 +395,6 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
let res =
|
let res =
|
||||||
case node.dag.cfg.consensusForkAtEpoch(qslot.epoch)
|
case node.dag.cfg.consensusForkAtEpoch(qslot.epoch)
|
||||||
of ConsensusFork.Deneb:
|
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(
|
await makeBeaconBlockForHeadAndSlot(
|
||||||
deneb.ExecutionPayloadForSigning,
|
deneb.ExecutionPayloadForSigning,
|
||||||
node, qrandao, proposer, qgraffiti, qhead, qslot)
|
node, qrandao, proposer, qgraffiti, qhead, qslot)
|
||||||
@ -418,15 +410,41 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
return RestApiResponse.jsonError(Http400, InvalidSlotValueError)
|
return RestApiResponse.jsonError(Http400, InvalidSlotValueError)
|
||||||
if res.isErr():
|
if res.isErr():
|
||||||
return RestApiResponse.jsonError(Http400, res.error())
|
return RestApiResponse.jsonError(Http400, res.error())
|
||||||
res.get.blck
|
res.get
|
||||||
return
|
return
|
||||||
|
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..<bundle.blobs.len:
|
||||||
|
let sidecar = deneb.BlobSidecar(
|
||||||
|
block_root: blockRoot,
|
||||||
|
index: BlobIndex(i),
|
||||||
|
slot: blck.slot,
|
||||||
|
block_parent_root: blck.parent_root,
|
||||||
|
proposer_index: blck.proposer_index,
|
||||||
|
blob: bundle.blobs[i],
|
||||||
|
kzg_commitment: bundle.kzgs[i],
|
||||||
|
kzg_proof: bundle.proofs[i]
|
||||||
|
)
|
||||||
|
sidecars.add(sidecar)
|
||||||
|
|
||||||
|
DenebBlockContents(
|
||||||
|
`block`: blck,
|
||||||
|
blob_sidecars: List[BlobSidecar,
|
||||||
|
Limit MAX_BLOBS_PER_BLOCK].init(sidecars))
|
||||||
|
elif blck is phase0.BeaconBlock or blck is altair.BeaconBlock or
|
||||||
|
blck is bellatrix.BeaconBlock or blck is capella.BeaconBlock:
|
||||||
|
blck
|
||||||
|
else:
|
||||||
|
static: raiseAssert "produceBlockV2 received unexpected version"
|
||||||
if contentType == sszMediaType:
|
if contentType == sszMediaType:
|
||||||
let headers = [("eth-consensus-version", message.kind.toString())]
|
let headers = [("eth-consensus-version", message.blck.kind.toString())]
|
||||||
withBlck(message):
|
|
||||||
RestApiResponse.sszResponse(blck, headers)
|
RestApiResponse.sszResponse(blck, headers)
|
||||||
elif contentType == jsonMediaType:
|
elif contentType == jsonMediaType:
|
||||||
withBlck(message):
|
RestApiResponse.jsonResponseWVersion(blck, message.blck.kind)
|
||||||
RestApiResponse.jsonResponseWVersion(blck, message.kind)
|
|
||||||
else:
|
else:
|
||||||
raiseAssert "preferredContentType() returns invalid content type"
|
raiseAssert "preferredContentType() returns invalid content type"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user