mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 12:30:08 +00:00
api: add skip_randao_verification for produceBlockV2 (#3837)
This commit is contained in:
parent
f7db50522b
commit
d6325b1ab5
@ -27,6 +27,9 @@ type
|
||||
## Skip verification of BLS signatures in block processing.
|
||||
## Predominantly intended for use in testing, e.g. to allow extra coverage.
|
||||
## Also useful to avoid unnecessary work when replaying known, good blocks.
|
||||
skipRandaoVerification ##\
|
||||
## Skip verification of the proposer's randao reveal in block processing, but do ensure
|
||||
## that they set the randao reveal to the point at infinity.
|
||||
skipStateRootValidation ##\
|
||||
## Skip verification of block state root.
|
||||
strictVerification ##\
|
||||
|
@ -90,6 +90,8 @@ const
|
||||
"Missing `randao_reveal` value"
|
||||
InvalidRandaoRevealValue* =
|
||||
"Invalid randao reveal value"
|
||||
InvalidSkipRandaoVerificationValue* =
|
||||
"Invalid skip_randao_verification value"
|
||||
InvalidGraffitiBytesValue* =
|
||||
"Invalid graffiti bytes value"
|
||||
InvalidEpochValueError* =
|
||||
|
@ -369,7 +369,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
# https://ethereum.github.io/beacon-APIs/#/Validator/produceBlockV2
|
||||
router.api(MethodGet, "/eth/v2/validator/blocks/{slot}") do (
|
||||
slot: Slot, randao_reveal: Option[ValidatorSig],
|
||||
graffiti: Option[GraffitiBytes]) -> RestApiResponse:
|
||||
graffiti: Option[GraffitiBytes], skip_randao_verification: Option[string]) -> RestApiResponse:
|
||||
let message =
|
||||
block:
|
||||
let qslot = block:
|
||||
@ -387,6 +387,15 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
return RestApiResponse.jsonError(Http400, InvalidSlotValueError,
|
||||
"Slot cannot be in the future")
|
||||
res
|
||||
let qskip_randao_verification =
|
||||
if skip_randao_verification.isNone():
|
||||
false
|
||||
else:
|
||||
let res = skip_randao_verification.get()
|
||||
if res.isErr() or res.get() != "":
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
InvalidSkipRandaoVerificationValue)
|
||||
true
|
||||
let qrandao =
|
||||
if randao_reveal.isNone():
|
||||
return RestApiResponse.jsonError(Http400, MissingRandaoRevealValue)
|
||||
@ -418,7 +427,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
if proposer.isNone():
|
||||
return RestApiResponse.jsonError(Http400, ProposerNotFoundError)
|
||||
let res = await makeBeaconBlockForHeadAndSlot(
|
||||
node, qrandao, proposer.get(), qgraffiti, qhead, qslot)
|
||||
node, qrandao, proposer.get(), qgraffiti, qhead, qslot, qskip_randao_verification)
|
||||
if res.isErr():
|
||||
return RestApiResponse.jsonError(Http400, res.error())
|
||||
res.get()
|
||||
|
@ -88,7 +88,10 @@ proc process_randao(
|
||||
let
|
||||
epoch = state.get_current_epoch()
|
||||
|
||||
if skipBlsValidation notin flags:
|
||||
if skipRandaoVerification in flags:
|
||||
if body.randao_reveal.toRaw != ValidatorSig.infinity.toRaw:
|
||||
return err("process_randao: expected point-at-infinity for skipRandaoVerification")
|
||||
elif skipBlsValidation notin flags:
|
||||
let proposer_pubkey = state.validators.item(proposer_index.get).pubkey
|
||||
|
||||
if not verify_epoch_signature(
|
||||
|
@ -446,6 +446,7 @@ proc makeBeaconBlockForHeadAndSlot*(
|
||||
node: BeaconNode, randao_reveal: ValidatorSig,
|
||||
validator_index: ValidatorIndex, graffiti: GraffitiBytes, head: BlockRef,
|
||||
slot: Slot,
|
||||
skip_randao_verification_bool: bool = false,
|
||||
execution_payload: Opt[ExecutionPayload] = Opt.none(ExecutionPayload),
|
||||
transactions_root: Opt[Eth2Digest] = Opt.none(Eth2Digest),
|
||||
execution_payload_root: Opt[Eth2Digest] = Opt.none(Eth2Digest)):
|
||||
@ -521,6 +522,7 @@ proc makeBeaconBlockForHeadAndSlot*(
|
||||
effectiveExecutionPayload,
|
||||
noRollback, # Temporary state - no need for rollback
|
||||
cache,
|
||||
verificationFlags = if skip_randao_verification_bool: {skipRandaoVerification} else: {},
|
||||
transactions_root =
|
||||
if transactions_root.isSome:
|
||||
Opt.some transactions_root.get
|
||||
|
Loading…
x
Reference in New Issue
Block a user