Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed Jul 26, 2023
1 parent df84f17 commit a4aabc5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ pub enum BlockProductionError {
blob_block_hash: ExecutionBlockHash,
payload_block_hash: ExecutionBlockHash,
},
NoBlobsCached,
FailedToReadFinalizedBlock(store::Error),
MissingFinalizedBlock(Hash256),
BlockTooLarge(usize),
ShuttingDown,
MissingBlobs,
MissingSyncAggregate,
MissingExecutionPayload,
MissingKzgCommitment(String),
Expand Down
7 changes: 6 additions & 1 deletion beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ use state_processing::{
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::marker::PhantomData;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
Expand Down Expand Up @@ -828,7 +829,11 @@ where
.into_iter()
.map(|blob_sidecar| {
let blinded_sidecar: BlindedBlobSidecar = blob_sidecar.message.into();
SignedSidecar::new(Arc::new(blinded_sidecar), blob_sidecar.signature)
SignedSidecar {
message: Arc::new(blinded_sidecar),
signature: blob_sidecar.signature,
_phantom: PhantomData,
}
})
.collect(),
)
Expand Down
1 change: 0 additions & 1 deletion beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,6 @@ impl<T: EthSpec> ExecutionLayer<T> {
}
};

// TODO(jimmy): cache blobs bundle
let payload_response = async {
debug!(
self.log(),
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/http_api/src/build_block_contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn build_block_contents<T: BeaconChainTypes>(
Ok(BlockContents::BlockAndBlobSidecars(block_and_blobs))
} else {
Err(warp_utils::reject::block_production_error(
BlockProductionError::NoBlobsCached,
BlockProductionError::MissingBlobs,
))
}
}
Expand All @@ -54,7 +54,7 @@ pub fn build_blinded_block_contents<T: BeaconChainTypes>(
Ok(BlockContents::BlindedBlockAndBlobSidecars(block_and_blobs))
} else {
Err(warp_utils::reject::block_production_error(
BlockProductionError::NoBlobsCached,
BlockProductionError::MissingBlobs,
))
}
}
Expand Down
7 changes: 0 additions & 7 deletions beacon_node/http_api/src/publish_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ pub async fn reconstruct_block<T: BeaconChainTypes>(
.into();
ProvenancedPayload::Local(payload)
// If we already have an execution payload with this transactions root cached, use it.
// TODO(jimmy) get cached blobs
} else if let Some(cached_payload) =
el.get_payload_by_root(&payload_header.tree_hash_root())
{
Expand Down Expand Up @@ -365,20 +364,14 @@ pub async fn reconstruct_block<T: BeaconChainTypes>(
// A block without a payload is pre-merge and we consider it locally
// built.
None => block
// .deconstruct()
// .0
.try_into_full_block(None)
.map(SignedBlockContents::Block)
.map(ProvenancedBlock::local),
Some(ProvenancedPayload::Local(full_payload)) => block
// .deconstruct()
// .0
.try_into_full_block(Some(full_payload))
.map(SignedBlockContents::Block)
.map(ProvenancedBlock::local),
Some(ProvenancedPayload::Builder(full_payload)) => block
// .deconstruct()
// .0
.try_into_full_block(Some(full_payload))
.map(SignedBlockContents::Block)
.map(ProvenancedBlock::builder),
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/network/src/network_beacon_processor/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use std::time::Duration;
use tokio::sync::mpsc;
use types::blob_sidecar::FixedBlobSidecarList;
use types::{
Attestation, AttesterSlashing, BlobSidecar, Epoch, Hash256, MainnetEthSpec, ProposerSlashing,
SignedAggregateAndProof, SignedBeaconBlock, SignedSidecarList, SignedVoluntaryExit, Slot,
Attestation, AttesterSlashing, Epoch, Hash256, MainnetEthSpec, ProposerSlashing,
SignedAggregateAndProof, SignedBeaconBlock, SignedBlobSidecarList, SignedVoluntaryExit, Slot,
SubnetId,
};

Expand All @@ -52,7 +52,7 @@ const STANDARD_TIMEOUT: Duration = Duration::from_secs(10);
struct TestRig {
chain: Arc<BeaconChain<T>>,
next_block: Arc<SignedBeaconBlock<E>>,
next_blobs: Option<SignedSidecarList<E, BlobSidecar<E>>>,
next_blobs: Option<SignedBlobSidecarList<E>>,
attestations: Vec<(Attestation<E>, SubnetId)>,
next_block_attestations: Vec<(Attestation<E>, SubnetId)>,
next_block_aggregate_attestations: Vec<SignedAggregateAndProof<E>>,
Expand Down
11 changes: 0 additions & 11 deletions consensus/types/src/signed_blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,13 @@ pub struct SignedSidecar<T: EthSpec, S: Sidecar<T>> {
pub _phantom: PhantomData<T>,
}

impl<T: EthSpec, S: Sidecar<T>> SignedSidecar<T, S> {
pub fn new(message: Arc<S>, signature: Signature) -> SignedSidecar<T, S> {
Self {
message,
signature,
_phantom: Default::default(),
}
}
}

/// List of Signed Sidecars that implements `Sidecar`.
pub type SignedSidecarList<T, Sidecar> =
VariableList<SignedSidecar<T, Sidecar>, <T as EthSpec>::MaxBlobsPerBlock>;
pub type SignedBlobSidecarList<T> = SignedSidecarList<T, BlobSidecar<T>>;

pub type SignedBlobSidecar<T> = SignedSidecar<T, BlobSidecar<T>>;

// TODO(jimmy): impl on SignedSidecar instead?
impl<T: EthSpec> SignedBlobSidecar<T> {
/// Verify `self.signature`.
///
Expand Down
6 changes: 5 additions & 1 deletion validator_client/src/validator_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,11 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {

metrics::inc_counter_vec(&metrics::SIGNED_BLOBS_TOTAL, &[metrics::SUCCESS]);

signed_blob_sidecars.push(SignedSidecar::new(blob_sidecar, signature));
signed_blob_sidecars.push(SignedSidecar {
message: blob_sidecar,
signature,
_phantom: PhantomData,
});
}

Ok(VariableList::from(signed_blob_sidecars))
Expand Down

0 comments on commit a4aabc5

Please sign in to comment.