diff --git a/beacon_chain/rpc/rest_validator_api.nim b/beacon_chain/rpc/rest_validator_api.nim index cd864e5e9..593738e77 100644 --- a/beacon_chain/rpc/rest_validator_api.nim +++ b/beacon_chain/rpc/rest_validator_api.nim @@ -423,7 +423,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) = raiseAssert "preferredContentType() returns invalid content type" # https://ethereum.github.io/beacon-APIs/#/Validator/produceBlindedBlock - # https://github.com/ethereum/beacon-APIs/blob/v2.4.0/apis/validator/blinded_block.yaml + # https://github.com/ethereum/beacon-APIs/blob/c097f1a62c9a12c30e8175a39f205f92d3b931a9/apis/validator/blinded_block.yaml router.api(MethodGet, "/eth/v1/validator/blinded_blocks/{slot}") do ( slot: Slot, randao_reveal: Option[ValidatorSig], graffiti: Option[GraffitiBytes], diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index 3ae68c6cf..8f048185e 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -661,9 +661,12 @@ proc constructSignableBlindedBlock[T: deneb_mev.SignedBlindedBeaconBlock]( blindedBlock -func constructPlainBlindedBlock[ - T: capella_mev.BlindedBeaconBlock, EPH: capella.ExecutionPayloadHeader]( - blck: ForkyBeaconBlock, executionPayloadHeader: EPH): T = +func constructPlainBlindedBlock[T: capella_mev.BlindedBeaconBlock]( + blck: ForkyBeaconBlock, + executionPayloadHeader: capella.ExecutionPayloadHeader): T = + # https://github.com/nim-lang/Nim/issues/23020 workaround + static: doAssert T is capella_mev.BlindedBeaconBlock + const blckFields = getFieldNames(typeof(blck)) blckBodyFields = getFieldNames(typeof(blck.body)) @@ -677,6 +680,25 @@ func constructPlainBlindedBlock[ blindedBlock +func constructPlainBlindedBlock[T: deneb_mev.BlindedBeaconBlock]( + blck: ForkyBeaconBlock, + executionPayloadHeader: deneb_mev.BlindedExecutionPayloadAndBlobsBundle): T = + # https://github.com/nim-lang/Nim/issues/23020 workaround + static: doAssert T is deneb_mev.BlindedBeaconBlock + + const + blckFields = getFieldNames(typeof(blck)) + blckBodyFields = getFieldNames(typeof(blck.body)) + + var blindedBlock: T + + # https://github.com/ethereum/builder-specs/blob/v0.3.0/specs/bellatrix/validator.md#block-proposal + copyFields(blindedBlock, blck, blckFields) + copyFields(blindedBlock.body, blck.body, blckBodyFields) + assign(blindedBlock.body.execution_payload_header, executionPayloadHeader.execution_payload_header) + + blindedBlock + proc blindedBlockCheckSlashingAndSign[ T: capella_mev.SignedBlindedBeaconBlock | @@ -938,10 +960,10 @@ proc makeBlindedBeaconBlockForHeadAndSlot*[BBB: ForkyBlindedBeaconBlock]( withBlck(forkedBlck): when consensusFork >= ConsensusFork.Capella: when ((consensusFork == ConsensusFork.Deneb and - EPH is deneb.ExecutionPayloadHeader) or + EPH is deneb_mev.BlindedExecutionPayloadAndBlobsBundle) or (consensusFork == ConsensusFork.Capella and EPH is capella.ExecutionPayloadHeader)): - return ok (constructPlainBlindedBlock[BBB, EPH]( + return ok (constructPlainBlindedBlock[BBB]( forkyBlck, executionPayloadHeader), bidValue) else: return err("makeBlindedBeaconBlockForHeadAndSlot: mismatched block/payload types")