Sidecar inclusion proof (#4900)

* Refactor BlobSidecar to new type

* Fix some compile errors

* Gossip verification compiles

* Fix http api types take 1

* Fix another round of compile errors

* Beacon node crate compiles

* EF tests compile

* Remove all blob signing from VC

* fmt

* Tests compile

* Fix some tests

* Fix more http tests

* get compiling

* Fix gossip conditions and tests

* Add basic proof generation and verification

* remove unnecessary ssz decode

* add back build_sidecar

* remove default at fork for blobs

* fix beacon chain tests

* get relase tests compiling

* fix lints

* fix existing spec tests

* add new ef tests

* fix gossip duplicate rule

* lints

* add back sidecar signature check in gossip

* add finalized descendant check to blob sidecar gossip

* fix error conversion

* fix release tests

* sidecar inclusion self review cleanup

* Add proof verification and computation metrics

* Remove accidentally committed file

* Unify some block and blob errors; add slashing conditions for sidecars

* Address review comment

* Clean up re-org tests (#4957)

* Address more review comments

* Add Comments & Eliminate Unnecessary Clones

* update names

* Update beacon_node/beacon_chain/src/metrics.rs

Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>

* Update beacon_node/network/src/network_beacon_processor/tests.rs

Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>

* pr feedback

* fix test compile

* Sidecar Inclusion proof small refactor and updates (#4967)

* Update some comments, variables and small cosmetic fixes.

* Couple blobs and proofs into a tuple in `PayloadAndBlobs` for simplicity and safety.

* Update function comment.

* Update testing/ef_tests/src/cases/merkle_proof_validity.rs

Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>

* Rename the block and blob wrapper types used in the beacon API interfaces.

* make sure gossip invalid blobs are passed to the slasher (#4970)

* Add blob headers to slasher before adding to DA checker

* Replace Vec with HashSet in BlockQueue

* fmt

* Rename gindex -> index

* Simplify gossip condition

---------

Co-authored-by: realbigsean <seananderson33@gmail.com>
Co-authored-by: realbigsean <sean@sigmaprime.io>
Co-authored-by: Michael Sproul <michael@sigmaprime.io>
Co-authored-by: Mark Mackey <mark@sigmaprime.io>
Co-authored-by: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
Pawan Dhananjay
2023-12-05 08:19:59 -08:00
committed by GitHub
parent ec8edfb89a
commit 31044402ee
74 changed files with 1950 additions and 2270 deletions

View File

@@ -769,9 +769,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blocks<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn post_beacon_blocks<T: EthSpec>(
&self,
block_contents: &SignedBlockContents<T, Payload>,
block_contents: &PublishBlockRequest<T>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -789,9 +789,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blocks_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn post_beacon_blocks_ssz<T: EthSpec>(
&self,
block_contents: &SignedBlockContents<T, Payload>,
block_contents: &PublishBlockRequest<T>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -813,9 +813,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blinded_blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blinded_blocks<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn post_beacon_blinded_blocks<T: EthSpec>(
&self,
block: &SignedBlockContents<T, Payload>,
block: &SignedBlindedBeaconBlock<T>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -833,9 +833,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blinded_blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blinded_blocks_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn post_beacon_blinded_blocks_ssz<T: EthSpec>(
&self,
block: &SignedBlockContents<T, Payload>,
block: &SignedBlindedBeaconBlock<T>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -887,9 +887,9 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/blocks`
pub async fn post_beacon_blocks_v2<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn post_beacon_blocks_v2<T: EthSpec>(
&self,
block_contents: &SignedBlockContents<T, Payload>,
block_contents: &PublishBlockRequest<T>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version(
@@ -904,9 +904,9 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/blocks`
pub async fn post_beacon_blocks_v2_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn post_beacon_blocks_v2_ssz<T: EthSpec>(
&self,
block_contents: &SignedBlockContents<T, Payload>,
block_contents: &PublishBlockRequest<T>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version_and_ssz_body(
@@ -921,16 +921,16 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/blinded_blocks`
pub async fn post_beacon_blinded_blocks_v2<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn post_beacon_blinded_blocks_v2<T: EthSpec>(
&self,
block_contents: &SignedBlockContents<T, Payload>,
signed_block: &SignedBlindedBeaconBlock<T>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version(
self.post_beacon_blinded_blocks_v2_path(validation_level)?,
block_contents,
signed_block,
Some(self.timeouts.proposal),
block_contents.signed_block().message().body().fork_name(),
signed_block.message().body().fork_name(),
)
.await?;
@@ -940,14 +940,14 @@ impl BeaconNodeHttpClient {
/// `POST v2/beacon/blinded_blocks`
pub async fn post_beacon_blinded_blocks_v2_ssz<T: EthSpec>(
&self,
block_contents: &SignedBlindedBlockContents<T>,
signed_block: &SignedBlindedBeaconBlock<T>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version_and_ssz_body(
self.post_beacon_blinded_blocks_v2_path(validation_level)?,
block_contents.as_ssz_bytes(),
signed_block.as_ssz_bytes(),
Some(self.timeouts.proposal),
block_contents.signed_block().message().body().fork_name(),
signed_block.message().body().fork_name(),
)
.await?;
@@ -1700,38 +1700,33 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blocks/{slot}`
pub async fn get_validator_blocks<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blocks<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<ForkVersionedResponse<BlockContents<T, Payload>>, Error> {
) -> Result<ForkVersionedResponse<FullBlockContents<T>>, Error> {
self.get_validator_blocks_modular(slot, randao_reveal, graffiti, SkipRandaoVerification::No)
.await
}
/// `GET v2/validator/blocks/{slot}`
pub async fn get_validator_blocks_modular<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blocks_modular<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<BlockContents<T, Payload>>, Error> {
) -> Result<ForkVersionedResponse<FullBlockContents<T>>, Error> {
let path = self
.get_validator_blocks_path::<T, Payload>(
slot,
randao_reveal,
graffiti,
skip_randao_verification,
)
.get_validator_blocks_path::<T>(slot, randao_reveal, graffiti, skip_randao_verification)
.await?;
self.get(path).await
}
/// returns `GET v2/validator/blocks/{slot}` URL path
pub async fn get_validator_blocks_path<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blocks_path<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -1837,12 +1832,12 @@ impl BeaconNodeHttpClient {
if is_blinded_payload {
let blinded_payload = response
.json::<ForkVersionedResponse<BlockContents<T, BlindedPayload<T>>>>()
.json::<ForkVersionedResponse<BlindedBeaconBlock<T>>>()
.await?;
Ok(ForkVersionedBeaconBlockType::Blinded(blinded_payload))
} else {
let full_payload = response
.json::<ForkVersionedResponse<BlockContents<T, FullPayload<T>>>>()
.json::<ForkVersionedResponse<FullBlockContents<T>>>()
.await?;
Ok(ForkVersionedBeaconBlockType::Full(full_payload))
}
@@ -1901,13 +1896,13 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blocks_ssz<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<Option<Vec<u8>>, Error> {
self.get_validator_blocks_modular_ssz::<T, Payload>(
self.get_validator_blocks_modular_ssz::<T>(
slot,
randao_reveal,
graffiti,
@@ -1917,7 +1912,7 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_modular_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blocks_modular_ssz<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -1925,12 +1920,7 @@ impl BeaconNodeHttpClient {
skip_randao_verification: SkipRandaoVerification,
) -> Result<Option<Vec<u8>>, Error> {
let path = self
.get_validator_blocks_path::<T, Payload>(
slot,
randao_reveal,
graffiti,
skip_randao_verification,
)
.get_validator_blocks_path::<T>(slot, randao_reveal, graffiti, skip_randao_verification)
.await?;
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_validator_block_ssz)
@@ -1938,12 +1928,12 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blinded_blocks/{slot}`
pub async fn get_validator_blinded_blocks<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blinded_blocks<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<ForkVersionedResponse<BlockContents<T, Payload>>, Error> {
) -> Result<ForkVersionedResponse<BlindedBeaconBlock<T>>, Error> {
self.get_validator_blinded_blocks_modular(
slot,
randao_reveal,
@@ -1954,7 +1944,7 @@ impl BeaconNodeHttpClient {
}
/// returns `GET v1/validator/blinded_blocks/{slot}` URL path
pub async fn get_validator_blinded_blocks_path<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blinded_blocks_path<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -1986,18 +1976,15 @@ impl BeaconNodeHttpClient {
}
/// `GET v1/validator/blinded_blocks/{slot}`
pub async fn get_validator_blinded_blocks_modular<
T: EthSpec,
Payload: AbstractExecPayload<T>,
>(
pub async fn get_validator_blinded_blocks_modular<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<BlockContents<T, Payload>>, Error> {
) -> Result<ForkVersionedResponse<BlindedBeaconBlock<T>>, Error> {
let path = self
.get_validator_blinded_blocks_path::<T, Payload>(
.get_validator_blinded_blocks_path::<T>(
slot,
randao_reveal,
graffiti,
@@ -2009,13 +1996,13 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blinded_blocks/{slot}` in ssz format
pub async fn get_validator_blinded_blocks_ssz<T: EthSpec, Payload: AbstractExecPayload<T>>(
pub async fn get_validator_blinded_blocks_ssz<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<Option<Vec<u8>>, Error> {
self.get_validator_blinded_blocks_modular_ssz::<T, Payload>(
self.get_validator_blinded_blocks_modular_ssz::<T>(
slot,
randao_reveal,
graffiti,
@@ -2024,10 +2011,7 @@ impl BeaconNodeHttpClient {
.await
}
pub async fn get_validator_blinded_blocks_modular_ssz<
T: EthSpec,
Payload: AbstractExecPayload<T>,
>(
pub async fn get_validator_blinded_blocks_modular_ssz<T: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -2035,7 +2019,7 @@ impl BeaconNodeHttpClient {
skip_randao_verification: SkipRandaoVerification,
) -> Result<Option<Vec<u8>>, Error> {
let path = self
.get_validator_blinded_blocks_path::<T, Payload>(
.get_validator_blinded_blocks_path::<T>(
slot,
randao_reveal,
graffiti,