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:
co-authored by
Jimmy Chen
realbigsean
realbigsean
Michael Sproul
Mark Mackey
parent
ec8edfb89a
commit
31044402ee
@@ -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,
|
||||
}),
|
||||
))
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ use bytes::Bytes;
|
||||
use directory::DEFAULT_ROOT_DIR;
|
||||
use eth2::types::{
|
||||
self as api_types, BroadcastValidation, EndpointVersion, ForkChoice, ForkChoiceNode,
|
||||
SignedBlindedBlockContents, SignedBlockContents, ValidatorId, ValidatorStatus,
|
||||
PublishBlockRequest, ValidatorId, ValidatorStatus,
|
||||
};
|
||||
use lighthouse_network::{types::SyncState, EnrExt, NetworkGlobals, PeerId, PubsubMessage};
|
||||
use lighthouse_version::version_with_platform;
|
||||
@@ -76,9 +76,9 @@ use tokio_stream::{
|
||||
};
|
||||
use types::{
|
||||
Attestation, AttestationData, AttestationShufflingId, AttesterSlashing, BeaconStateError,
|
||||
BlindedPayload, CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName,
|
||||
ForkVersionedResponse, Hash256, ProposerPreparationData, ProposerSlashing, RelativeEpoch,
|
||||
SignedAggregateAndProof, SignedBlsToExecutionChange, SignedContributionAndProof,
|
||||
CommitteeCache, ConfigAndPreset, Epoch, EthSpec, ForkName, ForkVersionedResponse, Hash256,
|
||||
ProposerPreparationData, ProposerSlashing, RelativeEpoch, SignedAggregateAndProof,
|
||||
SignedBlindedBeaconBlock, SignedBlsToExecutionChange, SignedContributionAndProof,
|
||||
SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncCommitteeMessage,
|
||||
SyncContributionData,
|
||||
};
|
||||
@@ -1306,7 +1306,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(network_tx_filter.clone())
|
||||
.and(log_filter.clone())
|
||||
.then(
|
||||
move |block_contents: SignedBlockContents<T::EthSpec>,
|
||||
move |block_contents: PublishBlockRequest<T::EthSpec>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
@@ -1342,7 +1342,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
log: Logger| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P0, async move {
|
||||
let block_contents = SignedBlockContents::<T::EthSpec>::from_ssz_bytes(
|
||||
let block_contents = PublishBlockRequest::<T::EthSpec>::from_ssz_bytes(
|
||||
&block_bytes,
|
||||
&chain.spec,
|
||||
)
|
||||
@@ -1375,7 +1375,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(log_filter.clone())
|
||||
.then(
|
||||
move |validation_level: api_types::BroadcastValidationQuery,
|
||||
block_contents: SignedBlockContents<T::EthSpec>,
|
||||
block_contents: PublishBlockRequest<T::EthSpec>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
@@ -1413,7 +1413,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
log: Logger| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P0, async move {
|
||||
let block_contents = SignedBlockContents::<T::EthSpec>::from_ssz_bytes(
|
||||
let block_contents = PublishBlockRequest::<T::EthSpec>::from_ssz_bytes(
|
||||
&block_bytes,
|
||||
&chain.spec,
|
||||
)
|
||||
@@ -1449,7 +1449,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(network_tx_filter.clone())
|
||||
.and(log_filter.clone())
|
||||
.then(
|
||||
move |block_contents: SignedBlindedBlockContents<T::EthSpec>,
|
||||
move |block_contents: SignedBlindedBeaconBlock<T::EthSpec>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
@@ -1485,14 +1485,13 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
log: Logger| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P0, async move {
|
||||
let block =
|
||||
SignedBlockContents::<T::EthSpec, BlindedPayload<_>>::from_ssz_bytes(
|
||||
&block_bytes,
|
||||
&chain.spec,
|
||||
)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_bad_request(format!("invalid SSZ: {e:?}"))
|
||||
})?;
|
||||
let block = SignedBlindedBeaconBlock::<T::EthSpec>::from_ssz_bytes(
|
||||
&block_bytes,
|
||||
&chain.spec,
|
||||
)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_bad_request(format!("invalid SSZ: {e:?}"))
|
||||
})?;
|
||||
publish_blocks::publish_blinded_block(
|
||||
block,
|
||||
chain,
|
||||
@@ -1518,14 +1517,14 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.and(log_filter.clone())
|
||||
.then(
|
||||
move |validation_level: api_types::BroadcastValidationQuery,
|
||||
block_contents: SignedBlindedBlockContents<T::EthSpec>,
|
||||
blinded_block: SignedBlindedBeaconBlock<T::EthSpec>,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
log: Logger| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P0, async move {
|
||||
publish_blocks::publish_blinded_block(
|
||||
block_contents,
|
||||
blinded_block,
|
||||
chain,
|
||||
&network_tx,
|
||||
log,
|
||||
@@ -1555,14 +1554,13 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
network_tx: UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
log: Logger| {
|
||||
task_spawner.spawn_async_with_rejection(Priority::P0, async move {
|
||||
let block =
|
||||
SignedBlockContents::<T::EthSpec, BlindedPayload<_>>::from_ssz_bytes(
|
||||
&block_bytes,
|
||||
&chain.spec,
|
||||
)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_bad_request(format!("invalid SSZ: {e:?}"))
|
||||
})?;
|
||||
let block = SignedBlindedBeaconBlock::<T::EthSpec>::from_ssz_bytes(
|
||||
&block_bytes,
|
||||
&chain.spec,
|
||||
)
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_bad_request(format!("invalid SSZ: {e:?}"))
|
||||
})?;
|
||||
publish_blocks::publish_blinded_block(
|
||||
block,
|
||||
chain,
|
||||
|
||||
@@ -3,8 +3,7 @@ use std::sync::Arc;
|
||||
use types::{payload::BlockProductionVersion, *};
|
||||
|
||||
use beacon_chain::{
|
||||
BeaconBlockResponse, BeaconBlockResponseType, BeaconChain, BeaconChainTypes,
|
||||
ProduceBlockVerification,
|
||||
BeaconBlockResponseWrapper, BeaconChain, BeaconChainTypes, ProduceBlockVerification,
|
||||
};
|
||||
use eth2::types::{self as api_types, EndpointVersion, SkipRandaoVerification};
|
||||
use ssz::Encode;
|
||||
@@ -69,35 +68,23 @@ pub async fn produce_block_v3<T: BeaconChainTypes>(
|
||||
warp_utils::reject::custom_bad_request(format!("failed to fetch a block: {:?}", e))
|
||||
})?;
|
||||
|
||||
match block_response_type {
|
||||
BeaconBlockResponseType::Full(block_response) => {
|
||||
build_response_v3(chain, block_response, endpoint_version, accept_header)
|
||||
}
|
||||
BeaconBlockResponseType::Blinded(block_response) => {
|
||||
build_response_v3(chain, block_response, endpoint_version, accept_header)
|
||||
}
|
||||
}
|
||||
build_response_v3(chain, block_response_type, endpoint_version, accept_header)
|
||||
}
|
||||
|
||||
pub fn build_response_v3<T: BeaconChainTypes, E: EthSpec, Payload: AbstractExecPayload<E>>(
|
||||
pub fn build_response_v3<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
block_response: BeaconBlockResponse<E, Payload>,
|
||||
block_response: BeaconBlockResponseWrapper<T::EthSpec>,
|
||||
endpoint_version: EndpointVersion,
|
||||
accept_header: Option<api_types::Accept>,
|
||||
) -> Result<Response<Body>, warp::Rejection> {
|
||||
let fork_name = block_response
|
||||
.block
|
||||
.to_ref()
|
||||
.fork_name(&chain.spec)
|
||||
.map_err(inconsistent_fork_rejection)?;
|
||||
let execution_payload_value = block_response.execution_payload_value();
|
||||
let consensus_block_value = block_response.consensus_block_value();
|
||||
let execution_payload_blinded = block_response.is_blinded();
|
||||
|
||||
let block_contents = build_block_contents::build_block_contents(
|
||||
fork_name,
|
||||
block_response.block,
|
||||
block_response.maybe_side_car,
|
||||
)?;
|
||||
|
||||
let execution_payload_blinded = Payload::block_type() == BlockType::Blinded;
|
||||
let block_contents = build_block_contents::build_block_contents(fork_name, block_response)?;
|
||||
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
@@ -107,9 +94,9 @@ pub fn build_response_v3<T: BeaconChainTypes, E: EthSpec, Payload: AbstractExecP
|
||||
.map(|res: Response<Body>| add_consensus_version_header(res, fork_name))
|
||||
.map(|res| add_execution_payload_blinded_header(res, execution_payload_blinded))
|
||||
.map(|res: Response<Body>| {
|
||||
add_execution_payload_value_header(res, block_response.execution_payload_value)
|
||||
add_execution_payload_value_header(res, execution_payload_value)
|
||||
})
|
||||
.map(|res| add_consensus_block_value_header(res, block_response.consensus_block_value))
|
||||
.map(|res| add_consensus_block_value_header(res, consensus_block_value))
|
||||
.map_err(|e| -> warp::Rejection {
|
||||
warp_utils::reject::custom_server_error(format!("failed to create response: {}", e))
|
||||
}),
|
||||
@@ -117,10 +104,8 @@ pub fn build_response_v3<T: BeaconChainTypes, E: EthSpec, Payload: AbstractExecP
|
||||
.map(|response| warp::reply::json(&response).into_response())
|
||||
.map(|res| add_consensus_version_header(res, fork_name))
|
||||
.map(|res| add_execution_payload_blinded_header(res, execution_payload_blinded))
|
||||
.map(|res| {
|
||||
add_execution_payload_value_header(res, block_response.execution_payload_value)
|
||||
})
|
||||
.map(|res| add_consensus_block_value_header(res, block_response.consensus_block_value)),
|
||||
.map(|res| add_execution_payload_value_header(res, execution_payload_value))
|
||||
.map(|res| add_consensus_block_value_header(res, consensus_block_value)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,14 +135,7 @@ pub async fn produce_blinded_block_v2<T: BeaconChainTypes>(
|
||||
.await
|
||||
.map_err(warp_utils::reject::block_production_error)?;
|
||||
|
||||
match block_response_type {
|
||||
BeaconBlockResponseType::Full(block_response) => {
|
||||
build_response_v2(chain, block_response, endpoint_version, accept_header)
|
||||
}
|
||||
BeaconBlockResponseType::Blinded(block_response) => {
|
||||
build_response_v2(chain, block_response, endpoint_version, accept_header)
|
||||
}
|
||||
}
|
||||
build_response_v2(chain, block_response_type, endpoint_version, accept_header)
|
||||
}
|
||||
|
||||
pub async fn produce_block_v2<T: BeaconChainTypes>(
|
||||
@@ -187,33 +165,20 @@ pub async fn produce_block_v2<T: BeaconChainTypes>(
|
||||
.await
|
||||
.map_err(warp_utils::reject::block_production_error)?;
|
||||
|
||||
match block_response_type {
|
||||
BeaconBlockResponseType::Full(block_response) => {
|
||||
build_response_v2(chain, block_response, endpoint_version, accept_header)
|
||||
}
|
||||
BeaconBlockResponseType::Blinded(block_response) => {
|
||||
build_response_v2(chain, block_response, endpoint_version, accept_header)
|
||||
}
|
||||
}
|
||||
build_response_v2(chain, block_response_type, endpoint_version, accept_header)
|
||||
}
|
||||
|
||||
pub fn build_response_v2<T: BeaconChainTypes, E: EthSpec, Payload: AbstractExecPayload<E>>(
|
||||
pub fn build_response_v2<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
block_response: BeaconBlockResponse<E, Payload>,
|
||||
block_response: BeaconBlockResponseWrapper<T::EthSpec>,
|
||||
endpoint_version: EndpointVersion,
|
||||
accept_header: Option<api_types::Accept>,
|
||||
) -> Result<Response<Body>, warp::Rejection> {
|
||||
let fork_name = block_response
|
||||
.block
|
||||
.to_ref()
|
||||
.fork_name(&chain.spec)
|
||||
.map_err(inconsistent_fork_rejection)?;
|
||||
|
||||
let block_contents = build_block_contents::build_block_contents(
|
||||
fork_name,
|
||||
block_response.block,
|
||||
block_response.maybe_side_car,
|
||||
)?;
|
||||
let block_contents = build_block_contents::build_block_contents(fork_name, block_response)?;
|
||||
|
||||
match accept_header {
|
||||
Some(api_types::Accept::Ssz) => Response::builder()
|
||||
|
||||
@@ -6,8 +6,8 @@ use beacon_chain::{
|
||||
AvailabilityProcessingStatus, BeaconChain, BeaconChainError, BeaconChainTypes, BlockError,
|
||||
IntoGossipVerifiedBlockContents, NotifyExecutionLayer,
|
||||
};
|
||||
use eth2::types::{BroadcastValidation, ErrorMessage};
|
||||
use eth2::types::{FullPayloadContents, SignedBlockContents};
|
||||
use eth2::types::{into_full_block_and_blobs, BroadcastValidation, ErrorMessage};
|
||||
use eth2::types::{FullPayloadContents, PublishBlockRequest};
|
||||
use execution_layer::ProvenancedPayload;
|
||||
use lighthouse_network::PubsubMessage;
|
||||
use network::NetworkMessage;
|
||||
@@ -19,8 +19,9 @@ use std::time::Duration;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
AbstractExecPayload, BeaconBlockRef, BlindedPayload, EthSpec, ExecPayload, ExecutionBlockHash,
|
||||
ForkName, FullPayload, FullPayloadMerge, Hash256, SignedBeaconBlock, SignedBlobSidecarList,
|
||||
AbstractExecPayload, BeaconBlockRef, BlobSidecarList, EthSpec, ExecPayload, ExecutionBlockHash,
|
||||
ForkName, FullPayload, FullPayloadMerge, Hash256, SignedBeaconBlock, SignedBlindedBeaconBlock,
|
||||
VariableList,
|
||||
};
|
||||
use warp::http::StatusCode;
|
||||
use warp::{reply::Response, Rejection, Reply};
|
||||
@@ -65,7 +66,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
|
||||
|
||||
/* actually publish a block */
|
||||
let publish_block = move |block: Arc<SignedBeaconBlock<T::EthSpec>>,
|
||||
blobs_opt: Option<SignedBlobSidecarList<T::EthSpec>>,
|
||||
blobs_opt: Option<BlobSidecarList<T::EthSpec>>,
|
||||
sender,
|
||||
log,
|
||||
seen_timestamp| {
|
||||
@@ -86,8 +87,8 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
|
||||
}
|
||||
SignedBeaconBlock::Deneb(_) => {
|
||||
let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block.clone())];
|
||||
if let Some(signed_blobs) = blobs_opt {
|
||||
for (blob_index, blob) in signed_blobs.into_iter().enumerate() {
|
||||
if let Some(blob_sidecars) = blobs_opt {
|
||||
for (blob_index, blob) in blob_sidecars.into_iter().enumerate() {
|
||||
pubsub_messages.push(PubsubMessage::BlobSidecar(Box::new((
|
||||
blob_index as u64,
|
||||
blob,
|
||||
@@ -108,10 +109,6 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
|
||||
let sender_clone = network_tx.clone();
|
||||
let log_clone = log.clone();
|
||||
|
||||
// We can clone this because the blobs are `Arc`'d in `BlockContents`, but the block is not,
|
||||
// so we avoid cloning the block at this point.
|
||||
let blobs_opt = block_contents.inner_blobs();
|
||||
|
||||
/* if we can form a `GossipVerifiedBlock`, we've passed our basic gossip checks */
|
||||
let (gossip_verified_block, gossip_verified_blobs) =
|
||||
match block_contents.into_gossip_verified_block(&chain) {
|
||||
@@ -142,6 +139,13 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
|
||||
// Clone here, so we can take advantage of the `Arc`. The block in `BlockContents` is not,
|
||||
// `Arc`'d but blobs are.
|
||||
let block = gossip_verified_block.block.block_cloned();
|
||||
let blobs_opt = gossip_verified_blobs.as_ref().map(|gossip_verified_blobs| {
|
||||
let blobs = gossip_verified_blobs
|
||||
.into_iter()
|
||||
.map(|b| b.clone_blob())
|
||||
.collect::<Vec<_>>();
|
||||
VariableList::from(blobs)
|
||||
});
|
||||
|
||||
let block_root = block_root.unwrap_or(gossip_verified_block.block_root);
|
||||
|
||||
@@ -292,16 +296,16 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
|
||||
/// Handles a request from the HTTP API for blinded blocks. This converts blinded blocks into full
|
||||
/// blocks before publishing.
|
||||
pub async fn publish_blinded_block<T: BeaconChainTypes>(
|
||||
block_contents: SignedBlockContents<T::EthSpec, BlindedPayload<T::EthSpec>>,
|
||||
blinded_block: SignedBlindedBeaconBlock<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
network_tx: &UnboundedSender<NetworkMessage<T::EthSpec>>,
|
||||
log: Logger,
|
||||
validation_level: BroadcastValidation,
|
||||
duplicate_status_code: StatusCode,
|
||||
) -> Result<Response, Rejection> {
|
||||
let block_root = block_contents.signed_block().canonical_root();
|
||||
let full_block: ProvenancedBlock<T, SignedBlockContents<T::EthSpec>> =
|
||||
reconstruct_block(chain.clone(), block_root, block_contents, log.clone()).await?;
|
||||
let block_root = blinded_block.canonical_root();
|
||||
let full_block: ProvenancedBlock<T, PublishBlockRequest<T::EthSpec>> =
|
||||
reconstruct_block(chain.clone(), block_root, blinded_block, log.clone()).await?;
|
||||
publish_block::<T, _>(
|
||||
Some(block_root),
|
||||
full_block,
|
||||
@@ -320,10 +324,9 @@ pub async fn publish_blinded_block<T: BeaconChainTypes>(
|
||||
pub async fn reconstruct_block<T: BeaconChainTypes>(
|
||||
chain: Arc<BeaconChain<T>>,
|
||||
block_root: Hash256,
|
||||
block_contents: SignedBlockContents<T::EthSpec, BlindedPayload<T::EthSpec>>,
|
||||
block: SignedBlindedBeaconBlock<T::EthSpec>,
|
||||
log: Logger,
|
||||
) -> Result<ProvenancedBlock<T, SignedBlockContents<T::EthSpec>>, Rejection> {
|
||||
let block = block_contents.signed_block();
|
||||
) -> Result<ProvenancedBlock<T, PublishBlockRequest<T::EthSpec>>, Rejection> {
|
||||
let full_payload_opt = if let Ok(payload_header) = block.message().body().execution_payload() {
|
||||
let el = chain.execution_layer.as_ref().ok_or_else(|| {
|
||||
warp_utils::reject::custom_server_error("Missing execution layer".to_string())
|
||||
@@ -365,7 +368,7 @@ pub async fn reconstruct_block<T: BeaconChainTypes>(
|
||||
);
|
||||
|
||||
let full_payload = el
|
||||
.propose_blinded_beacon_block(block_root, &block_contents)
|
||||
.propose_blinded_beacon_block(block_root, &block)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!(
|
||||
@@ -385,15 +388,15 @@ pub async fn reconstruct_block<T: BeaconChainTypes>(
|
||||
match full_payload_opt {
|
||||
// A block without a payload is pre-merge and we consider it locally
|
||||
// built.
|
||||
None => block_contents
|
||||
.try_into_full_block_and_blobs(None)
|
||||
.map(ProvenancedBlock::local),
|
||||
Some(ProvenancedPayload::Local(full_payload_contents)) => block_contents
|
||||
.try_into_full_block_and_blobs(Some(full_payload_contents))
|
||||
.map(ProvenancedBlock::local),
|
||||
Some(ProvenancedPayload::Builder(full_payload_contents)) => block_contents
|
||||
.try_into_full_block_and_blobs(Some(full_payload_contents))
|
||||
.map(ProvenancedBlock::builder),
|
||||
None => into_full_block_and_blobs(block, None).map(ProvenancedBlock::local),
|
||||
Some(ProvenancedPayload::Local(full_payload_contents)) => {
|
||||
into_full_block_and_blobs(block, Some(full_payload_contents))
|
||||
.map(ProvenancedBlock::local)
|
||||
}
|
||||
Some(ProvenancedPayload::Builder(full_payload_contents)) => {
|
||||
into_full_block_and_blobs(block, Some(full_payload_contents))
|
||||
.map(ProvenancedBlock::builder)
|
||||
}
|
||||
}
|
||||
.map_err(|e| {
|
||||
warp_utils::reject::custom_server_error(format!("Unable to add payload to block: {e:?}"))
|
||||
|
||||
@@ -2,18 +2,12 @@ use beacon_chain::{
|
||||
test_utils::{AttestationStrategy, BlockStrategy},
|
||||
GossipVerifiedBlock, IntoGossipVerifiedBlockContents,
|
||||
};
|
||||
use eth2::types::{
|
||||
BroadcastValidation, SignedBeaconBlock, SignedBlindedBeaconBlock, SignedBlockContents,
|
||||
SignedBlockContentsTuple,
|
||||
};
|
||||
use eth2::types::{BroadcastValidation, PublishBlockRequest, SignedBeaconBlock};
|
||||
use http_api::test_utils::InteractiveTester;
|
||||
use http_api::{publish_blinded_block, publish_block, reconstruct_block, ProvenancedBlock};
|
||||
use std::sync::Arc;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
BlindedBlobSidecar, BlindedPayload, BlobSidecar, FullPayload, Hash256, MainnetEthSpec,
|
||||
SignedSidecarList, Slot,
|
||||
};
|
||||
use types::{Hash256, MainnetEthSpec, Slot};
|
||||
use warp::Rejection;
|
||||
use warp_utils::reject::CustomBadRequest;
|
||||
|
||||
@@ -80,7 +74,7 @@ pub async fn gossip_invalid() {
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(&SignedBlockContents::new(block, blobs), validation_level)
|
||||
.post_beacon_blocks_v2(&PublishBlockRequest::new(block, blobs), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -131,7 +125,7 @@ pub async fn gossip_partial_pass() {
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(&SignedBlockContents::new(block, blobs), validation_level)
|
||||
.post_beacon_blocks_v2(&PublishBlockRequest::new(block, blobs), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -174,7 +168,7 @@ pub async fn gossip_full_pass() {
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(
|
||||
&SignedBlockContents::new(block.clone(), blobs),
|
||||
&PublishBlockRequest::new(block.clone(), blobs),
|
||||
validation_level,
|
||||
)
|
||||
.await;
|
||||
@@ -266,7 +260,7 @@ pub async fn consensus_invalid() {
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(&SignedBlockContents::new(block, blobs), validation_level)
|
||||
.post_beacon_blocks_v2(&PublishBlockRequest::new(block, blobs), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -315,7 +309,7 @@ pub async fn consensus_gossip() {
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(&SignedBlockContents::new(block, blobs), validation_level)
|
||||
.post_beacon_blocks_v2(&PublishBlockRequest::new(block, blobs), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -358,10 +352,8 @@ pub async fn consensus_partial_pass_only_consensus() {
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
let state_a = tester.harness.get_current_state();
|
||||
let ((block_a, _), state_after_a): ((SignedBeaconBlock<E>, _), _) =
|
||||
tester.harness.make_block(state_a.clone(), slot_b).await;
|
||||
let ((block_b, blobs_b), state_after_b): ((SignedBeaconBlock<E>, _), _) =
|
||||
tester.harness.make_block(state_a, slot_b).await;
|
||||
let ((block_a, _), state_after_a) = tester.harness.make_block(state_a.clone(), slot_b).await;
|
||||
let ((block_b, blobs_b), state_after_b) = tester.harness.make_block(state_a, slot_b).await;
|
||||
let block_b_root = block_b.canonical_root();
|
||||
|
||||
/* check for `make_block` curios */
|
||||
@@ -369,7 +361,7 @@ pub async fn consensus_partial_pass_only_consensus() {
|
||||
assert_eq!(block_b.state_root(), state_after_b.tree_hash_root());
|
||||
assert_ne!(block_a.state_root(), block_b.state_root());
|
||||
|
||||
let gossip_block_contents_b = SignedBlockContents::new(block_b, blobs_b)
|
||||
let gossip_block_contents_b = PublishBlockRequest::new(block_b, blobs_b)
|
||||
.into_gossip_verified_block(&tester.harness.chain);
|
||||
assert!(gossip_block_contents_b.is_ok());
|
||||
let gossip_block_a = GossipVerifiedBlock::new(block_a.clone().into(), &tester.harness.chain);
|
||||
@@ -430,7 +422,7 @@ pub async fn consensus_full_pass() {
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(
|
||||
&SignedBlockContents::new(block.clone(), blobs),
|
||||
&PublishBlockRequest::new(block.clone(), blobs),
|
||||
validation_level,
|
||||
)
|
||||
.await;
|
||||
@@ -481,7 +473,7 @@ pub async fn equivocation_invalid() {
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(&SignedBlockContents::new(block, blobs), validation_level)
|
||||
.post_beacon_blocks_v2(&PublishBlockRequest::new(block, blobs), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -538,7 +530,7 @@ pub async fn equivocation_consensus_early_equivocation() {
|
||||
assert!(tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(
|
||||
&SignedBlockContents::new(block_a.clone(), blobs_a),
|
||||
&PublishBlockRequest::new(block_a.clone(), blobs_a),
|
||||
validation_level
|
||||
)
|
||||
.await
|
||||
@@ -552,7 +544,7 @@ pub async fn equivocation_consensus_early_equivocation() {
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(
|
||||
&SignedBlockContents::new(block_b.clone(), blobs_b),
|
||||
&PublishBlockRequest::new(block_b.clone(), blobs_b),
|
||||
validation_level,
|
||||
)
|
||||
.await;
|
||||
@@ -603,7 +595,7 @@ pub async fn equivocation_gossip() {
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(&SignedBlockContents::new(block, blobs), validation_level)
|
||||
.post_beacon_blocks_v2(&PublishBlockRequest::new(block, blobs), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -661,10 +653,10 @@ pub async fn equivocation_consensus_late_equivocation() {
|
||||
assert_eq!(block_b.state_root(), state_after_b.tree_hash_root());
|
||||
assert_ne!(block_a.state_root(), block_b.state_root());
|
||||
|
||||
let gossip_block_contents_b = SignedBlockContents::new(block_b, blobs_b)
|
||||
let gossip_block_contents_b = PublishBlockRequest::new(block_b, blobs_b)
|
||||
.into_gossip_verified_block(&tester.harness.chain);
|
||||
assert!(gossip_block_contents_b.is_ok());
|
||||
let gossip_block_contents_a = SignedBlockContents::new(block_a, blobs_a)
|
||||
let gossip_block_contents_a = PublishBlockRequest::new(block_a, blobs_a)
|
||||
.into_gossip_verified_block(&tester.harness.chain);
|
||||
assert!(gossip_block_contents_a.is_err());
|
||||
|
||||
@@ -728,7 +720,7 @@ pub async fn equivocation_full_pass() {
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(
|
||||
&SignedBlockContents::new(block.clone(), blobs),
|
||||
&PublishBlockRequest::new(block.clone(), blobs),
|
||||
validation_level,
|
||||
)
|
||||
.await;
|
||||
@@ -776,11 +768,9 @@ pub async fn blinded_gossip_invalid() {
|
||||
})
|
||||
.await;
|
||||
|
||||
let blinded_block_contents = into_signed_blinded_block_contents(block_contents_tuple);
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_tuple.0.clone_as_blinded(), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -829,11 +819,9 @@ pub async fn blinded_gossip_partial_pass() {
|
||||
})
|
||||
.await;
|
||||
|
||||
let blinded_block_contents = into_signed_blinded_block_contents(block_contents_tuple);
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_tuple.0.clone_as_blinded(), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -870,18 +858,17 @@ pub async fn blinded_gossip_full_pass() {
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
let state_a = tester.harness.get_current_state();
|
||||
let (block_contents_tuple, _) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
let block_contents = block_contents_tuple.into();
|
||||
let (blinded_block, _) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block, validation_level)
|
||||
.await;
|
||||
|
||||
assert!(response.is_ok());
|
||||
assert!(tester
|
||||
.harness
|
||||
.chain
|
||||
.block_is_known_to_fork_choice(&block_contents.signed_block().canonical_root()));
|
||||
.block_is_known_to_fork_choice(&blinded_block.canonical_root()));
|
||||
}
|
||||
|
||||
// This test checks that a block that is valid from both a gossip and consensus perspective is accepted when using `broadcast_validation=gossip`.
|
||||
@@ -912,19 +899,18 @@ pub async fn blinded_gossip_full_pass_ssz() {
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
let state_a = tester.harness.get_current_state();
|
||||
let (block_contents_tuple, _) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
let block_contents = block_contents_tuple.into();
|
||||
let (blinded_block, _) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2_ssz(&block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2_ssz(&blinded_block, validation_level)
|
||||
.await;
|
||||
|
||||
assert!(response.is_ok());
|
||||
assert!(tester
|
||||
.harness
|
||||
.chain
|
||||
.block_is_known_to_fork_choice(&block_contents.signed_block().canonical_root()));
|
||||
.block_is_known_to_fork_choice(&blinded_block.canonical_root()));
|
||||
}
|
||||
|
||||
/// This test checks that a block that is **invalid** from a gossip perspective gets rejected when using `broadcast_validation=consensus`.
|
||||
@@ -963,11 +949,9 @@ pub async fn blinded_consensus_invalid() {
|
||||
})
|
||||
.await;
|
||||
|
||||
let blinded_block_contents = into_signed_blinded_block_contents(block_contents_tuple);
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_tuple.0.clone_as_blinded(), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -1014,11 +998,9 @@ pub async fn blinded_consensus_gossip() {
|
||||
.make_block_with_modifier(state_a, slot_b, |b| *b.state_root_mut() = Hash256::zero())
|
||||
.await;
|
||||
|
||||
let blinded_block_contents = into_signed_blinded_block_contents(block_contents_tuple);
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_tuple.0.clone_as_blinded(), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -1060,19 +1042,18 @@ pub async fn blinded_consensus_full_pass() {
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
let state_a = tester.harness.get_current_state();
|
||||
let (block_contents_tuple, _) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
let (blinded_block, _) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
|
||||
let block_contents = block_contents_tuple.into();
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block, validation_level)
|
||||
.await;
|
||||
|
||||
assert!(response.is_ok());
|
||||
assert!(tester
|
||||
.harness
|
||||
.chain
|
||||
.block_is_known_to_fork_choice(&block_contents.signed_block().canonical_root()));
|
||||
.block_is_known_to_fork_choice(&blinded_block.canonical_root()));
|
||||
}
|
||||
|
||||
/// This test checks that a block that is **invalid** from a gossip perspective gets rejected when using `broadcast_validation=consensus_and_equivocation`.
|
||||
@@ -1112,11 +1093,9 @@ pub async fn blinded_equivocation_invalid() {
|
||||
})
|
||||
.await;
|
||||
|
||||
let blinded_block_contents = into_signed_blinded_block_contents(block_contents_tuple);
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_tuple.0.clone_as_blinded(), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -1159,18 +1138,13 @@ pub async fn blinded_equivocation_consensus_early_equivocation() {
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
let state_a = tester.harness.get_current_state();
|
||||
let (block_contents_tuple_a, state_after_a) = tester
|
||||
let (block_a, state_after_a) = tester
|
||||
.harness
|
||||
.make_blinded_block(state_a.clone(), slot_b)
|
||||
.await;
|
||||
let (block_contents_tuple_b, state_after_b) =
|
||||
tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
let (block_b, state_after_b) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
|
||||
/* check for `make_blinded_block` curios */
|
||||
let block_contents_a: SignedBlockContents<E, BlindedPayload<E>> = block_contents_tuple_a.into();
|
||||
let block_contents_b: SignedBlockContents<E, BlindedPayload<E>> = block_contents_tuple_b.into();
|
||||
let block_a = block_contents_a.signed_block();
|
||||
let block_b = block_contents_b.signed_block();
|
||||
assert_eq!(block_a.state_root(), state_after_a.tree_hash_root());
|
||||
assert_eq!(block_b.state_root(), state_after_b.tree_hash_root());
|
||||
assert_ne!(block_a.state_root(), block_b.state_root());
|
||||
@@ -1178,7 +1152,7 @@ pub async fn blinded_equivocation_consensus_early_equivocation() {
|
||||
/* submit `block_a` as valid */
|
||||
assert!(tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_a, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_a, validation_level)
|
||||
.await
|
||||
.is_ok());
|
||||
assert!(tester
|
||||
@@ -1189,7 +1163,7 @@ pub async fn blinded_equivocation_consensus_early_equivocation() {
|
||||
/* submit `block_b` which should induce equivocation */
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_b, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_b, validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -1236,11 +1210,9 @@ pub async fn blinded_equivocation_gossip() {
|
||||
.make_block_with_modifier(state_a, slot_b, |b| *b.state_root_mut() = Hash256::zero())
|
||||
.await;
|
||||
|
||||
let blinded_block_contents = into_signed_blinded_block_contents(block_contents_tuple);
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blinded_blocks_v2(&blinded_block_contents, validation_level)
|
||||
.post_beacon_blinded_blocks_v2(&block_contents_tuple.0.clone_as_blinded(), validation_level)
|
||||
.await;
|
||||
assert!(response.is_err());
|
||||
|
||||
@@ -1286,12 +1258,11 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
let state_a = tester.harness.get_current_state();
|
||||
let ((block_a, blobs_a), state_after_a): ((SignedBlindedBeaconBlock<E>, _), _) = tester
|
||||
let (block_a, state_after_a) = tester
|
||||
.harness
|
||||
.make_blinded_block(state_a.clone(), slot_b)
|
||||
.await;
|
||||
let ((block_b, blobs_b), state_after_b): ((SignedBlindedBeaconBlock<E>, _), _) =
|
||||
tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
let (block_b, state_after_b) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
|
||||
/* check for `make_blinded_block` curios */
|
||||
assert_eq!(block_a.state_root(), state_after_a.tree_hash_root());
|
||||
@@ -1301,7 +1272,7 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
|
||||
let unblinded_block_a = reconstruct_block(
|
||||
tester.harness.chain.clone(),
|
||||
block_a.canonical_root(),
|
||||
SignedBlockContents::new(block_a, blobs_a),
|
||||
block_a,
|
||||
test_logger.clone(),
|
||||
)
|
||||
.await
|
||||
@@ -1309,7 +1280,7 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
|
||||
let unblinded_block_b = reconstruct_block(
|
||||
tester.harness.chain.clone(),
|
||||
block_b.canonical_root(),
|
||||
SignedBlockContents::new(block_b.clone(), blobs_b.clone()),
|
||||
block_b.clone(),
|
||||
test_logger.clone(),
|
||||
)
|
||||
.await
|
||||
@@ -1338,7 +1309,7 @@ pub async fn blinded_equivocation_consensus_late_equivocation() {
|
||||
let channel = tokio::sync::mpsc::unbounded_channel();
|
||||
|
||||
let publication_result = publish_blinded_block(
|
||||
SignedBlockContents::new(block_b, blobs_b),
|
||||
block_b,
|
||||
tester.harness.chain,
|
||||
&channel.0,
|
||||
test_logger,
|
||||
@@ -1383,15 +1354,11 @@ pub async fn blinded_equivocation_full_pass() {
|
||||
let slot_b = slot_a + 1;
|
||||
|
||||
let state_a = tester.harness.get_current_state();
|
||||
let ((block, blobs), _): ((SignedBlindedBeaconBlock<E>, _), _) =
|
||||
tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
let (block, _) = tester.harness.make_blinded_block(state_a, slot_b).await;
|
||||
|
||||
let response: Result<(), eth2::Error> = tester
|
||||
.client
|
||||
.post_beacon_blocks_v2(
|
||||
&SignedBlockContents::new(block.clone(), blobs),
|
||||
validation_level,
|
||||
)
|
||||
.post_beacon_blinded_blocks_v2(&block, validation_level)
|
||||
.await;
|
||||
|
||||
assert!(response.is_ok());
|
||||
@@ -1400,20 +1367,3 @@ pub async fn blinded_equivocation_full_pass() {
|
||||
.chain
|
||||
.block_is_known_to_fork_choice(&block.canonical_root()));
|
||||
}
|
||||
|
||||
fn into_signed_blinded_block_contents(
|
||||
block_contents_tuple: SignedBlockContentsTuple<E, FullPayload<E>>,
|
||||
) -> SignedBlockContents<E, BlindedPayload<E>> {
|
||||
let (block, maybe_blobs) = block_contents_tuple;
|
||||
SignedBlockContents::new(block.into(), maybe_blobs.map(into_blinded_blob_sidecars))
|
||||
}
|
||||
|
||||
fn into_blinded_blob_sidecars(
|
||||
blobs: SignedSidecarList<E, BlobSidecar<E>>,
|
||||
) -> SignedSidecarList<E, BlindedBlobSidecar> {
|
||||
blobs
|
||||
.into_iter()
|
||||
.map(|blob| blob.into())
|
||||
.collect::<Vec<_>>()
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
Address, Epoch, EthSpec, ExecPayload, ExecutionBlockHash, ForkName, FullPayload,
|
||||
MainnetEthSpec, MinimalEthSpec, ProposerPreparationData, Slot,
|
||||
Address, Epoch, EthSpec, ExecPayload, ExecutionBlockHash, ForkName, MainnetEthSpec,
|
||||
MinimalEthSpec, ProposerPreparationData, Slot,
|
||||
};
|
||||
|
||||
use eth2::types::ForkVersionedBeaconBlockType::{Blinded, Full};
|
||||
@@ -641,13 +641,9 @@ pub async fn proposer_boost_re_org_test(
|
||||
assert_eq!(block_c.parent_root(), block_b_root);
|
||||
}
|
||||
|
||||
// Sign blobs.
|
||||
let block_c_signed_blobs =
|
||||
block_c_blobs.map(|blobs| harness.sign_blobs(blobs, &state_b, proposer_index));
|
||||
|
||||
// Applying block C should cause it to become head regardless (re-org or continuation).
|
||||
let block_root_c = harness
|
||||
.process_block_result((block_c.clone(), block_c_signed_blobs))
|
||||
.process_block_result((block_c.clone(), block_c_blobs))
|
||||
.await
|
||||
.unwrap()
|
||||
.into();
|
||||
@@ -828,7 +824,7 @@ pub async fn fork_choice_before_proposal() {
|
||||
.into();
|
||||
let block_d = tester
|
||||
.client
|
||||
.get_validator_blocks::<E, FullPayload<E>>(slot_d, &randao_reveal, None)
|
||||
.get_validator_blocks::<E>(slot_d, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
|
||||
@@ -64,8 +64,8 @@ struct ApiTester {
|
||||
harness: Arc<BeaconChainHarness<EphemeralHarnessType<E>>>,
|
||||
chain: Arc<BeaconChain<EphemeralHarnessType<E>>>,
|
||||
client: BeaconNodeHttpClient,
|
||||
next_block: SignedBlockContents<E>,
|
||||
reorg_block: SignedBlockContents<E>,
|
||||
next_block: PublishBlockRequest<E>,
|
||||
reorg_block: PublishBlockRequest<E>,
|
||||
attestations: Vec<Attestation<E>>,
|
||||
contribution_and_proofs: Vec<SignedContributionAndProof<E>>,
|
||||
attester_slashing: AttesterSlashing<E>,
|
||||
@@ -173,13 +173,13 @@ impl ApiTester {
|
||||
let (next_block, _next_state) = harness
|
||||
.make_block(head.beacon_state.clone(), harness.chain.slot().unwrap())
|
||||
.await;
|
||||
let next_block = SignedBlockContents::from(next_block);
|
||||
let next_block = PublishBlockRequest::from(next_block);
|
||||
|
||||
// `make_block` adds random graffiti, so this will produce an alternate block
|
||||
let (reorg_block, _reorg_state) = harness
|
||||
.make_block(head.beacon_state.clone(), harness.chain.slot().unwrap() + 1)
|
||||
.await;
|
||||
let reorg_block = SignedBlockContents::from(reorg_block);
|
||||
let reorg_block = PublishBlockRequest::from(reorg_block);
|
||||
|
||||
let head_state_root = head.beacon_state_root();
|
||||
let attestations = harness
|
||||
@@ -314,13 +314,13 @@ impl ApiTester {
|
||||
let (next_block, _next_state) = harness
|
||||
.make_block(head.beacon_state.clone(), harness.chain.slot().unwrap())
|
||||
.await;
|
||||
let next_block = SignedBlockContents::from(next_block);
|
||||
let next_block = PublishBlockRequest::from(next_block);
|
||||
|
||||
// `make_block` adds random graffiti, so this will produce an alternate block
|
||||
let (reorg_block, _reorg_state) = harness
|
||||
.make_block(head.beacon_state.clone(), harness.chain.slot().unwrap())
|
||||
.await;
|
||||
let reorg_block = SignedBlockContents::from(reorg_block);
|
||||
let reorg_block = PublishBlockRequest::from(reorg_block);
|
||||
|
||||
let head_state_root = head.beacon_state_root();
|
||||
let attestations = harness
|
||||
@@ -1301,7 +1301,7 @@ impl ApiTester {
|
||||
|
||||
assert!(self
|
||||
.client
|
||||
.post_beacon_blocks(&SignedBlockContents::from(block))
|
||||
.post_beacon_blocks(&PublishBlockRequest::from(block))
|
||||
.await
|
||||
.is_err());
|
||||
|
||||
@@ -1328,7 +1328,7 @@ impl ApiTester {
|
||||
|
||||
assert!(self
|
||||
.client
|
||||
.post_beacon_blocks_ssz(&SignedBlockContents::from(block))
|
||||
.post_beacon_blocks_ssz(&PublishBlockRequest::from(block))
|
||||
.await
|
||||
.is_err());
|
||||
|
||||
@@ -1357,7 +1357,8 @@ impl ApiTester {
|
||||
.await
|
||||
.is_ok());
|
||||
|
||||
let blinded_block_contents = block_contents.clone_as_blinded();
|
||||
// Blinded deneb block contents is just the blinded block
|
||||
let blinded_block_contents = block_contents.signed_block().clone_as_blinded();
|
||||
|
||||
// Test all the POST methods in sequence, they should all behave the same.
|
||||
let responses = vec![
|
||||
@@ -2567,7 +2568,7 @@ impl ApiTester {
|
||||
|
||||
let block = self
|
||||
.client
|
||||
.get_validator_blocks::<E, FullPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
@@ -2576,7 +2577,7 @@ impl ApiTester {
|
||||
|
||||
let signed_block = block.sign(&sk, &fork, genesis_validators_root, &self.chain.spec);
|
||||
let signed_block_contents =
|
||||
SignedBlockContents::try_from(signed_block.clone()).unwrap();
|
||||
PublishBlockRequest::try_from(signed_block.clone()).unwrap();
|
||||
|
||||
self.client
|
||||
.post_beacon_blocks(&signed_block_contents)
|
||||
@@ -2631,13 +2632,13 @@ impl ApiTester {
|
||||
|
||||
let block_bytes = self
|
||||
.client
|
||||
.get_validator_blocks_ssz::<E, FullPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blocks_ssz::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.expect("block bytes");
|
||||
|
||||
let block_contents =
|
||||
BlockContents::<E, FullPayload<E>>::from_ssz_bytes(&block_bytes, &self.chain.spec)
|
||||
FullBlockContents::<E>::from_ssz_bytes(&block_bytes, &self.chain.spec)
|
||||
.expect("block contents bytes can be decoded");
|
||||
|
||||
let signed_block_contents =
|
||||
@@ -2704,28 +2705,26 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
if is_blinded_payload {
|
||||
let block_contents = <BlockContents<E, BlindedPayload<E>>>::from_ssz_bytes(
|
||||
let blinded_block = <BlindedBeaconBlock<E>>::from_ssz_bytes(
|
||||
&fork_version_response_bytes.unwrap(),
|
||||
&self.chain.spec,
|
||||
)
|
||||
.expect("block contents bytes can be decoded");
|
||||
|
||||
let signed_block_contents =
|
||||
block_contents.sign(&sk, &fork, genesis_validators_root, &self.chain.spec);
|
||||
let signed_blinded_block =
|
||||
blinded_block.sign(&sk, &fork, genesis_validators_root, &self.chain.spec);
|
||||
|
||||
self.client
|
||||
.post_beacon_blocks_ssz(&signed_block_contents)
|
||||
.post_beacon_blinded_blocks_ssz(&signed_blinded_block)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// This converts the generic `Payload` to a concrete type for comparison.
|
||||
let signed_block = signed_block_contents.deconstruct().0;
|
||||
let head_block = SignedBeaconBlock::from(signed_block.clone());
|
||||
assert_eq!(head_block, signed_block);
|
||||
let head_block = self.chain.head_beacon_block().clone_as_blinded();
|
||||
assert_eq!(head_block, signed_blinded_block);
|
||||
|
||||
self.chain.slot_clock.set_slot(slot.as_u64() + 1);
|
||||
} else {
|
||||
let block_contents = <BlockContents<E, FullPayload<E>>>::from_ssz_bytes(
|
||||
let block_contents = <FullBlockContents<E>>::from_ssz_bytes(
|
||||
&fork_version_response_bytes.unwrap(),
|
||||
&self.chain.spec,
|
||||
)
|
||||
@@ -2757,7 +2756,7 @@ impl ApiTester {
|
||||
|
||||
let block = self
|
||||
.client
|
||||
.get_validator_blocks_modular::<E, FullPayload<E>>(
|
||||
.get_validator_blocks_modular::<E>(
|
||||
slot,
|
||||
&Signature::infinity().unwrap().into(),
|
||||
None,
|
||||
@@ -2815,13 +2814,13 @@ impl ApiTester {
|
||||
|
||||
// Check failure with no `skip_randao_verification` passed.
|
||||
self.client
|
||||
.get_validator_blocks::<E, FullPayload<E>>(slot, &bad_randao_reveal, None)
|
||||
.get_validator_blocks::<E>(slot, &bad_randao_reveal, None)
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
// Check failure with `skip_randao_verification` (requires infinity sig).
|
||||
self.client
|
||||
.get_validator_blocks_modular::<E, FullPayload<E>>(
|
||||
.get_validator_blocks_modular::<E>(
|
||||
slot,
|
||||
&bad_randao_reveal,
|
||||
None,
|
||||
@@ -2836,7 +2835,7 @@ impl ApiTester {
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_blinded_block_production<Payload: AbstractExecPayload<E>>(&self) {
|
||||
pub async fn test_blinded_block_production(&self) {
|
||||
let fork = self.chain.canonical_head.cached_head().head_fork();
|
||||
let genesis_validators_root = self.chain.genesis_validators_root;
|
||||
|
||||
@@ -2876,29 +2875,33 @@ impl ApiTester {
|
||||
|
||||
let block = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, Payload>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
|
||||
let signed_block_contents =
|
||||
block.sign(&sk, &fork, genesis_validators_root, &self.chain.spec);
|
||||
let signed_block = block.sign(&sk, &fork, genesis_validators_root, &self.chain.spec);
|
||||
|
||||
self.client
|
||||
.post_beacon_blinded_blocks(&signed_block_contents)
|
||||
.post_beacon_blinded_blocks(&signed_block)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// This converts the generic `Payload` to a concrete type for comparison.
|
||||
let signed_block = signed_block_contents.deconstruct().0;
|
||||
let head_block = SignedBeaconBlock::from(signed_block.clone());
|
||||
assert_eq!(head_block, signed_block);
|
||||
let head_block = self
|
||||
.client
|
||||
.get_beacon_blocks(CoreBlockId::Head)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.data;
|
||||
|
||||
assert_eq!(head_block.clone_as_blinded(), signed_block);
|
||||
|
||||
self.chain.slot_clock.set_slot(slot.as_u64() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn test_blinded_block_production_ssz<Payload: AbstractExecPayload<E>>(&self) {
|
||||
pub async fn test_blinded_block_production_ssz(&self) {
|
||||
let fork = self.chain.canonical_head.cached_head().head_fork();
|
||||
let genesis_validators_root = self.chain.genesis_validators_root;
|
||||
|
||||
@@ -2938,43 +2941,47 @@ impl ApiTester {
|
||||
|
||||
let block_contents_bytes = self
|
||||
.client
|
||||
.get_validator_blinded_blocks_ssz::<E, Payload>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks_ssz::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.expect("block bytes");
|
||||
|
||||
let block_contents = BlockContents::<E, Payload>::from_ssz_bytes(
|
||||
&block_contents_bytes,
|
||||
&self.chain.spec,
|
||||
)
|
||||
.expect("block contents bytes can be decoded");
|
||||
let block_contents =
|
||||
FullBlockContents::<E>::from_ssz_bytes(&block_contents_bytes, &self.chain.spec)
|
||||
.expect("block contents bytes can be decoded");
|
||||
|
||||
let signed_block_contents =
|
||||
block_contents.sign(&sk, &fork, genesis_validators_root, &self.chain.spec);
|
||||
|
||||
self.client
|
||||
.post_beacon_blinded_blocks_ssz(&signed_block_contents)
|
||||
.post_beacon_blinded_blocks_ssz(
|
||||
&signed_block_contents.signed_block().clone_as_blinded(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// This converts the generic `Payload` to a concrete type for comparison.
|
||||
let signed_block = signed_block_contents.deconstruct().0;
|
||||
let head_block = SignedBeaconBlock::from(signed_block.clone());
|
||||
assert_eq!(head_block, signed_block);
|
||||
let head_block = self
|
||||
.client
|
||||
.get_beacon_blocks(CoreBlockId::Head)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.data;
|
||||
|
||||
let signed_block = signed_block_contents.signed_block();
|
||||
assert_eq!(&head_block, signed_block);
|
||||
|
||||
self.chain.slot_clock.set_slot(slot.as_u64() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn test_blinded_block_production_no_verify_randao<Payload: AbstractExecPayload<E>>(
|
||||
self,
|
||||
) -> Self {
|
||||
pub async fn test_blinded_block_production_no_verify_randao(self) -> Self {
|
||||
for _ in 0..E::slots_per_epoch() {
|
||||
let slot = self.chain.slot().unwrap();
|
||||
|
||||
let block_contents = self
|
||||
let blinded_block = self
|
||||
.client
|
||||
.get_validator_blinded_blocks_modular::<E, Payload>(
|
||||
.get_validator_blinded_blocks_modular::<E>(
|
||||
slot,
|
||||
&Signature::infinity().unwrap().into(),
|
||||
None,
|
||||
@@ -2983,18 +2990,14 @@ impl ApiTester {
|
||||
.await
|
||||
.unwrap()
|
||||
.data;
|
||||
assert_eq!(block_contents.block().slot(), slot);
|
||||
assert_eq!(blinded_block.slot(), slot);
|
||||
self.chain.slot_clock.set_slot(slot.as_u64() + 1);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
pub async fn test_blinded_block_production_verify_randao_invalid<
|
||||
Payload: AbstractExecPayload<E>,
|
||||
>(
|
||||
self,
|
||||
) -> Self {
|
||||
pub async fn test_blinded_block_production_verify_randao_invalid(self) -> Self {
|
||||
let fork = self.chain.canonical_head.cached_head().head_fork();
|
||||
let genesis_validators_root = self.chain.genesis_validators_root;
|
||||
|
||||
@@ -3034,13 +3037,13 @@ impl ApiTester {
|
||||
|
||||
// Check failure with full randao verification enabled.
|
||||
self.client
|
||||
.get_validator_blinded_blocks::<E, Payload>(slot, &bad_randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &bad_randao_reveal, None)
|
||||
.await
|
||||
.unwrap_err();
|
||||
|
||||
// Check failure with `skip_randao_verification` (requires infinity sig).
|
||||
self.client
|
||||
.get_validator_blinded_blocks_modular::<E, Payload>(
|
||||
.get_validator_blinded_blocks_modular::<E>(
|
||||
slot,
|
||||
&bad_randao_reveal,
|
||||
None,
|
||||
@@ -3520,13 +3523,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
let payload: BlindedPayload<E> = match payload_type {
|
||||
Blinded(payload) => payload
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
.into(),
|
||||
Blinded(payload) => payload.data.body().execution_payload().unwrap().into(),
|
||||
Full(_) => panic!("Expecting a blinded payload"),
|
||||
};
|
||||
|
||||
@@ -3545,11 +3542,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -3586,11 +3582,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -3630,13 +3625,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
let payload: BlindedPayload<E> = match payload_type {
|
||||
Blinded(payload) => payload
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
.into(),
|
||||
Blinded(payload) => payload.data.body().execution_payload().unwrap().into(),
|
||||
Full(_) => panic!("Expecting a blinded payload"),
|
||||
};
|
||||
|
||||
@@ -3665,11 +3654,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -3711,13 +3699,7 @@ impl ApiTester {
|
||||
.unwrap();
|
||||
|
||||
let payload: BlindedPayload<E> = match payload_type {
|
||||
Blinded(payload) => payload
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
.into(),
|
||||
Blinded(payload) => payload.data.body().execution_payload().unwrap().into(),
|
||||
Full(_) => panic!("Expecting a blinded payload"),
|
||||
};
|
||||
|
||||
@@ -3752,11 +3734,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -3845,11 +3826,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -3936,11 +3916,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4026,11 +4005,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4102,11 +4080,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4162,11 +4139,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4235,11 +4211,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(next_slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4265,11 +4240,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(next_slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4370,11 +4344,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(next_slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4410,11 +4383,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(next_slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(next_slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4524,11 +4496,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4608,11 +4579,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4673,11 +4643,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4738,11 +4707,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4803,11 +4771,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4867,11 +4834,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -4907,16 +4873,11 @@ impl ApiTester {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let block_contents = match payload_type {
|
||||
let _block_contents = match payload_type {
|
||||
Blinded(payload) => payload.data,
|
||||
Full(_) => panic!("Expecting a blinded payload"),
|
||||
};
|
||||
|
||||
let (_, maybe_sidecars) = block_contents.deconstruct();
|
||||
|
||||
// Response should contain blob sidecars
|
||||
assert!(maybe_sidecars.is_some());
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
@@ -4940,11 +4901,10 @@ impl ApiTester {
|
||||
|
||||
let payload: BlindedPayload<E> = self
|
||||
.client
|
||||
.get_validator_blinded_blocks::<E, BlindedPayload<E>>(slot, &randao_reveal, None)
|
||||
.get_validator_blinded_blocks::<E>(slot, &randao_reveal, None)
|
||||
.await
|
||||
.unwrap()
|
||||
.data
|
||||
.block()
|
||||
.body()
|
||||
.execution_payload()
|
||||
.unwrap()
|
||||
@@ -5892,17 +5852,14 @@ async fn block_production_v3_ssz_with_skip_slots() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn blinded_block_production_full_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_blinded_block_production::<FullPayload<_>>()
|
||||
.await;
|
||||
ApiTester::new().await.test_blinded_block_production().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn blinded_block_production_ssz_full_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_blinded_block_production_ssz::<FullPayload<_>>()
|
||||
.test_blinded_block_production_ssz()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -5911,7 +5868,7 @@ async fn blinded_block_production_with_skip_slots_full_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_blinded_block_production::<FullPayload<_>>()
|
||||
.test_blinded_block_production()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -5920,7 +5877,7 @@ async fn blinded_block_production_ssz_with_skip_slots_full_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_blinded_block_production_ssz::<FullPayload<_>>()
|
||||
.test_blinded_block_production_ssz()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -5928,7 +5885,7 @@ async fn blinded_block_production_ssz_with_skip_slots_full_payload_premerge() {
|
||||
async fn blinded_block_production_no_verify_randao_full_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_blinded_block_production_no_verify_randao::<FullPayload<_>>()
|
||||
.test_blinded_block_production_no_verify_randao()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -5936,16 +5893,13 @@ async fn blinded_block_production_no_verify_randao_full_payload_premerge() {
|
||||
async fn blinded_block_production_verify_randao_invalid_full_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_blinded_block_production_verify_randao_invalid::<FullPayload<_>>()
|
||||
.test_blinded_block_production_verify_randao_invalid()
|
||||
.await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn blinded_block_production_blinded_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_blinded_block_production::<BlindedPayload<_>>()
|
||||
.await;
|
||||
ApiTester::new().await.test_blinded_block_production().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
@@ -5953,7 +5907,7 @@ async fn blinded_block_production_with_skip_slots_blinded_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.skip_slots(E::slots_per_epoch() * 2)
|
||||
.test_blinded_block_production::<BlindedPayload<_>>()
|
||||
.test_blinded_block_production()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -5961,7 +5915,7 @@ async fn blinded_block_production_with_skip_slots_blinded_payload_premerge() {
|
||||
async fn blinded_block_production_no_verify_randao_blinded_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_blinded_block_production_no_verify_randao::<BlindedPayload<_>>()
|
||||
.test_blinded_block_production_no_verify_randao()
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -5969,7 +5923,7 @@ async fn blinded_block_production_no_verify_randao_blinded_payload_premerge() {
|
||||
async fn blinded_block_production_verify_randao_invalid_blinded_payload_premerge() {
|
||||
ApiTester::new()
|
||||
.await
|
||||
.test_blinded_block_production_verify_randao_invalid::<BlindedPayload<_>>()
|
||||
.test_blinded_block_production_verify_randao_invalid()
|
||||
.await;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user