mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
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:
@@ -1,50 +1,42 @@
|
||||
use beacon_chain::BlockProductionError;
|
||||
use eth2::types::{BeaconBlockAndBlobSidecars, BlindedBeaconBlockAndBlobSidecars, BlockContents};
|
||||
use types::{AbstractExecPayload, BeaconBlock, EthSpec, ForkName, SidecarList};
|
||||
use beacon_chain::{BeaconBlockResponse, BeaconBlockResponseWrapper, BlockProductionError};
|
||||
use eth2::types::{BlockContents, FullBlockContents, ProduceBlockV3Response};
|
||||
use types::{EthSpec, ForkName};
|
||||
type Error = warp::reject::Rejection;
|
||||
|
||||
pub fn build_block_contents<E: EthSpec, Payload: AbstractExecPayload<E>>(
|
||||
pub fn build_block_contents<E: EthSpec>(
|
||||
fork_name: ForkName,
|
||||
block: BeaconBlock<E, Payload>,
|
||||
maybe_blobs: Option<SidecarList<E, <Payload as AbstractExecPayload<E>>::Sidecar>>,
|
||||
) -> Result<BlockContents<E, Payload>, Error> {
|
||||
match Payload::block_type() {
|
||||
types::BlockType::Blinded => match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
|
||||
Ok(BlockContents::Block(block))
|
||||
}
|
||||
block_response: BeaconBlockResponseWrapper<E>,
|
||||
) -> Result<ProduceBlockV3Response<E>, Error> {
|
||||
match block_response {
|
||||
BeaconBlockResponseWrapper::Blinded(block) => {
|
||||
Ok(ProduceBlockV3Response::Blinded(block.block))
|
||||
}
|
||||
BeaconBlockResponseWrapper::Full(block) => match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => Ok(
|
||||
ProduceBlockV3Response::Full(FullBlockContents::Block(block.block)),
|
||||
),
|
||||
ForkName::Deneb => {
|
||||
if let Some(blinded_blob_sidecars) = maybe_blobs {
|
||||
let block_and_blobs = BlindedBeaconBlockAndBlobSidecars {
|
||||
blinded_block: block,
|
||||
blinded_blob_sidecars,
|
||||
};
|
||||
let BeaconBlockResponse {
|
||||
block,
|
||||
state: _,
|
||||
blob_items,
|
||||
execution_payload_value: _,
|
||||
consensus_block_value: _,
|
||||
} = block;
|
||||
|
||||
Ok(BlockContents::BlindedBlockAndBlobSidecars(block_and_blobs))
|
||||
} else {
|
||||
Err(warp_utils::reject::block_production_error(
|
||||
let Some((kzg_proofs, blobs)) = blob_items else {
|
||||
return Err(warp_utils::reject::block_production_error(
|
||||
BlockProductionError::MissingBlobs,
|
||||
))
|
||||
}
|
||||
}
|
||||
},
|
||||
types::BlockType::Full => match fork_name {
|
||||
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
|
||||
Ok(BlockContents::Block(block))
|
||||
}
|
||||
ForkName::Deneb => {
|
||||
if let Some(blob_sidecars) = maybe_blobs {
|
||||
let block_and_blobs = BeaconBlockAndBlobSidecars {
|
||||
));
|
||||
};
|
||||
|
||||
Ok(ProduceBlockV3Response::Full(
|
||||
FullBlockContents::BlockContents(BlockContents {
|
||||
block,
|
||||
blob_sidecars,
|
||||
};
|
||||
|
||||
Ok(BlockContents::BlockAndBlobSidecars(block_and_blobs))
|
||||
} else {
|
||||
Err(warp_utils::reject::block_production_error(
|
||||
BlockProductionError::MissingBlobs,
|
||||
))
|
||||
}
|
||||
kzg_proofs,
|
||||
blobs,
|
||||
}),
|
||||
))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user