Implement skip_randao_verification and blinded block rewards API (#3540)

## Issue Addressed

https://github.com/ethereum/beacon-APIs/pull/222

## Proposed Changes

Update Lighthouse's randao verification API to match the `beacon-APIs` spec. We implemented the API before spec stabilisation, and it changed slightly in the course of review.

Rather than a flag `verify_randao` taking a boolean value, the new API uses a `skip_randao_verification` flag which takes no argument. The new spec also requires the randao reveal to be present and equal to the point-at-infinity when `skip_randao_verification` is set.

I've also updated the `POST /lighthouse/analysis/block_rewards` API to take blinded blocks as input, as the execution payload is irrelevant and we may want to assess blocks produced by builders.

## Additional Info

This is technically a breaking change, but seeing as I suspect I'm the only one using these parameters/APIs, I think we're OK to include this in a patch release.
This commit is contained in:
Michael Sproul
2022-09-19 07:58:48 +00:00
parent ca42ef2e5a
commit f2ac0738d8
8 changed files with 116 additions and 145 deletions

View File

@@ -1233,17 +1233,17 @@ impl BeaconNodeHttpClient {
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<ForkVersionedResponse<BeaconBlock<T, Payload>>, Error> {
self.get_validator_blocks_with_verify_randao(slot, Some(randao_reveal), graffiti, None)
self.get_validator_blocks_modular(slot, randao_reveal, graffiti, SkipRandaoVerification::No)
.await
}
/// `GET v2/validator/blocks/{slot}`
pub async fn get_validator_blocks_with_verify_randao<T: EthSpec, Payload: ExecPayload<T>>(
pub async fn get_validator_blocks_modular<T: EthSpec, Payload: ExecPayload<T>>(
&self,
slot: Slot,
randao_reveal: Option<&SignatureBytes>,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
verify_randao: Option<bool>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<BeaconBlock<T, Payload>>, Error> {
let mut path = self.eth_path(V2)?;
@@ -1253,19 +1253,17 @@ impl BeaconNodeHttpClient {
.push("blocks")
.push(&slot.to_string());
if let Some(randao_reveal) = randao_reveal {
path.query_pairs_mut()
.append_pair("randao_reveal", &randao_reveal.to_string());
}
path.query_pairs_mut()
.append_pair("randao_reveal", &randao_reveal.to_string());
if let Some(graffiti) = graffiti {
path.query_pairs_mut()
.append_pair("graffiti", &graffiti.to_string());
}
if let Some(verify_randao) = verify_randao {
if skip_randao_verification == SkipRandaoVerification::Yes {
path.query_pairs_mut()
.append_pair("verify_randao", &verify_randao.to_string());
.append_pair("skip_randao_verification", "");
}
self.get(path).await
@@ -1278,25 +1276,22 @@ impl BeaconNodeHttpClient {
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<ForkVersionedResponse<BeaconBlock<T, Payload>>, Error> {
self.get_validator_blinded_blocks_with_verify_randao(
self.get_validator_blinded_blocks_modular(
slot,
Some(randao_reveal),
randao_reveal,
graffiti,
None,
SkipRandaoVerification::No,
)
.await
}
/// `GET v1/validator/blinded_blocks/{slot}`
pub async fn get_validator_blinded_blocks_with_verify_randao<
T: EthSpec,
Payload: ExecPayload<T>,
>(
pub async fn get_validator_blinded_blocks_modular<T: EthSpec, Payload: ExecPayload<T>>(
&self,
slot: Slot,
randao_reveal: Option<&SignatureBytes>,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
verify_randao: Option<bool>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<BeaconBlock<T, Payload>>, Error> {
let mut path = self.eth_path(V1)?;
@@ -1306,19 +1301,17 @@ impl BeaconNodeHttpClient {
.push("blinded_blocks")
.push(&slot.to_string());
if let Some(randao_reveal) = randao_reveal {
path.query_pairs_mut()
.append_pair("randao_reveal", &randao_reveal.to_string());
}
path.query_pairs_mut()
.append_pair("randao_reveal", &randao_reveal.to_string());
if let Some(graffiti) = graffiti {
path.query_pairs_mut()
.append_pair("graffiti", &graffiti.to_string());
}
if let Some(verify_randao) = verify_randao {
if skip_randao_verification == SkipRandaoVerification::Yes {
path.query_pairs_mut()
.append_pair("verify_randao", &verify_randao.to_string());
.append_key_only("skip_randao_verification");
}
self.get(path).await