Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge queue: embarking unstable (5ce1619) and [#5451 + #5456 + #5440 + #5426] together #5459

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2651,7 +2651,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// If the block is relevant, add it to the filtered chain segment.
Ok(_) => filtered_chain_segment.push((block_root, block)),
// If the block is already known, simply ignore this block.
Err(BlockError::BlockIsAlreadyKnown) => continue,
Err(BlockError::BlockIsAlreadyKnown(_)) => continue,
// If the block is the genesis block, simply ignore this block.
Err(BlockError::GenesisBlock) => continue,
// If the block is is for a finalized slot, simply ignore this block.
Expand Down Expand Up @@ -2879,7 +2879,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.fork_choice_read_lock()
.contains_block(&block_root)
{
return Err(BlockError::BlockIsAlreadyKnown);
return Err(BlockError::BlockIsAlreadyKnown(blob.block_root()));
}

if let Some(event_handler) = self.event_handler.as_ref() {
Expand Down Expand Up @@ -2911,7 +2911,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.fork_choice_read_lock()
.contains_block(&block_root)
{
return Err(BlockError::BlockIsAlreadyKnown);
return Err(BlockError::BlockIsAlreadyKnown(block_root));
}

if let Some(event_handler) = self.event_handler.as_ref() {
Expand Down
8 changes: 4 additions & 4 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub enum BlockError<T: EthSpec> {
/// ## Peer scoring
///
/// The block is valid and we have already imported a block with this hash.
BlockIsAlreadyKnown,
BlockIsAlreadyKnown(Hash256),
/// The block slot exceeds the MAXIMUM_BLOCK_SLOT_NUMBER.
///
/// ## Peer scoring
Expand Down Expand Up @@ -832,7 +832,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
// already know this block.
let fork_choice_read_lock = chain.canonical_head.fork_choice_read_lock();
if fork_choice_read_lock.contains_block(&block_root) {
return Err(BlockError::BlockIsAlreadyKnown);
return Err(BlockError::BlockIsAlreadyKnown(block_root));
}

// Do not process a block that doesn't descend from the finalized root.
Expand Down Expand Up @@ -966,7 +966,7 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
SeenBlock::Slashable => {
return Err(BlockError::Slashable);
}
SeenBlock::Duplicate => return Err(BlockError::BlockIsAlreadyKnown),
SeenBlock::Duplicate => return Err(BlockError::BlockIsAlreadyKnown(block_root)),
SeenBlock::UniqueNonSlashable => {}
};

Expand Down Expand Up @@ -1784,7 +1784,7 @@ pub fn check_block_relevancy<T: BeaconChainTypes>(
.fork_choice_read_lock()
.contains_block(&block_root)
{
return Err(BlockError::BlockIsAlreadyKnown);
return Err(BlockError::BlockIsAlreadyKnown(block_root));
}

Ok(block_root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ pub trait AvailabilityView<E: EthSpec> {
/// 1. The blob entry at the index is empty and no block exists, or
/// 2. The block exists and its commitment matches the blob's commitment.
fn merge_single_blob(&mut self, index: usize, blob: Self::BlobType) {
let commitment = *blob.get_commitment();
if let Some(cached_block) = self.get_cached_block() {
let block_commitment_opt = cached_block.get_commitments().get(index).copied();
if let Some(block_commitment) = block_commitment_opt {
if block_commitment == commitment {
if block_commitment == *blob.get_commitment() {
self.insert_blob_at_index(index, blob)
}
}
Expand Down
3 changes: 0 additions & 3 deletions beacon_node/beacon_chain/src/execution_payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,9 +560,6 @@ where
parent_beacon_block_root,
);

// Note: the suggested_fee_recipient is stored in the `execution_layer`, it will add this parameter.
//
// This future is not executed here, it's up to the caller to await it.
let block_contents = execution_layer
.get_payload(
parent_hash,
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/beacon_chain/tests/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ async fn block_gossip_verification() {
assert!(
matches!(
unwrap_err(harness.chain.verify_block_for_gossip(Arc::new(block.clone())).await),
BlockError::BlockIsAlreadyKnown,
BlockError::BlockIsAlreadyKnown(_),
),
"should register any valid signature against the proposer, even if the block failed later verification"
);
Expand Down Expand Up @@ -1115,7 +1115,7 @@ async fn block_gossip_verification() {
.verify_block_for_gossip(block.clone())
.await
.expect_err("should error when processing known block"),
BlockError::BlockIsAlreadyKnown
BlockError::BlockIsAlreadyKnown(_)
),
"the second proposal by this validator should be rejected"
);
Expand Down
8 changes: 4 additions & 4 deletions beacon_node/http_api/src/publish_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
| SignedBeaconBlock::Altair(_)
| SignedBeaconBlock::Merge(_)
| SignedBeaconBlock::Capella(_) => {
crate::publish_pubsub_message(&sender, PubsubMessage::BeaconBlock(block.clone()))
crate::publish_pubsub_message(&sender, PubsubMessage::BeaconBlock(block))
.map_err(|_| BlockError::BeaconChainError(BeaconChainError::UnableToPublish))?;
}
SignedBeaconBlock::Deneb(_) => {
let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block.clone())];
let mut pubsub_messages = vec![PubsubMessage::BeaconBlock(block)];
if let Some(blob_sidecars) = blobs_opt {
for (blob_index, blob) in blob_sidecars.into_iter().enumerate() {
pubsub_messages.push(PubsubMessage::BlobSidecar(Box::new((
Expand All @@ -113,7 +113,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
let (gossip_verified_block, gossip_verified_blobs) =
match block_contents.into_gossip_verified_block(&chain) {
Ok(b) => b,
Err(BlockContentsError::BlockError(BlockError::BlockIsAlreadyKnown))
Err(BlockContentsError::BlockError(BlockError::BlockIsAlreadyKnown(_)))
| Err(BlockContentsError::BlobError(
beacon_chain::blob_verification::GossipBlobError::RepeatBlob { .. },
)) => {
Expand All @@ -133,7 +133,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlockConten
log,
"Not publishing block - not gossip verified";
"slot" => slot,
"error" => ?e
"error" => %e
);
return Err(warp_utils::reject::custom_bad_request(e.to_string()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
return None;
}
Err(BlockError::BlockIsAlreadyKnown) => {
Err(BlockError::BlockIsAlreadyKnown(_)) => {
debug!(
self.log,
"Gossip block is already known";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
"slot" => %slot,
);
}
Err(BlockError::BlockIsAlreadyKnown) => {
Err(BlockError::BlockIsAlreadyKnown(_)) => {
debug!(
self.log,
"Blobs have already been imported";
Expand Down Expand Up @@ -639,7 +639,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
peer_action: Some(PeerAction::LowToleranceError),
})
}
BlockError::BlockIsAlreadyKnown => {
BlockError::BlockIsAlreadyKnown(_) => {
// This can happen for many reasons. Head sync's can download multiples and parent
// lookups can download blocks before range sync
Ok(())
Expand Down
12 changes: 6 additions & 6 deletions beacon_node/network/src/sync/block_lookups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
let root = lookup.block_root();
trace!(self.log, "Single block processing failed"; "block" => %root, "error" => %e);
match e {
BlockError::BlockIsAlreadyKnown => {
BlockError::BlockIsAlreadyKnown(_) => {
// No error here
return Ok(None);
}
Expand Down Expand Up @@ -898,17 +898,17 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
match &result {
BlockProcessingResult::Ok(status) => match status {
AvailabilityProcessingStatus::Imported(block_root) => {
trace!(self.log, "Parent block processing succeeded"; &parent_lookup, "block_root" => ?block_root)
debug!(self.log, "Parent block processing succeeded"; &parent_lookup, "block_root" => ?block_root)
}
AvailabilityProcessingStatus::MissingComponents(_, block_root) => {
trace!(self.log, "Parent missing parts, triggering single block lookup "; &parent_lookup,"block_root" => ?block_root)
debug!(self.log, "Parent missing parts, triggering single block lookup "; &parent_lookup,"block_root" => ?block_root)
}
},
BlockProcessingResult::Err(e) => {
trace!(self.log, "Parent block processing failed"; &parent_lookup, "error" => %e)
debug!(self.log, "Parent block processing failed"; &parent_lookup, "error" => %e)
}
BlockProcessingResult::Ignored => {
trace!(
debug!(
self.log,
"Parent block processing job was ignored";
"action" => "re-requesting block",
Expand Down Expand Up @@ -954,7 +954,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
self.request_parent(parent_lookup, cx);
}
BlockProcessingResult::Ok(AvailabilityProcessingStatus::Imported(_))
| BlockProcessingResult::Err(BlockError::BlockIsAlreadyKnown { .. }) => {
| BlockProcessingResult::Err(BlockError::BlockIsAlreadyKnown(_)) => {
// Check if the beacon processor is available
let Some(beacon_processor) = cx.beacon_processor_if_enabled() else {
return trace!(
Expand Down
12 changes: 10 additions & 2 deletions beacon_node/network/src/sync/block_lookups/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ fn test_parent_lookup_happy_path() {
rig.expect_empty_network();

// Processing succeeds, now the rest of the chain should be sent for processing.
bl.parent_block_processed(chain_hash, BlockError::BlockIsAlreadyKnown.into(), &mut cx);
bl.parent_block_processed(
chain_hash,
BlockError::BlockIsAlreadyKnown(block_root).into(),
&mut cx,
);
rig.expect_parent_chain_process();
let process_result = BatchProcessResult::Success {
was_non_empty: true,
Expand Down Expand Up @@ -1117,7 +1121,11 @@ fn test_same_chain_race_condition() {
// the processing result
if i + 2 == depth {
// one block was removed
bl.parent_block_processed(chain_hash, BlockError::BlockIsAlreadyKnown.into(), &mut cx)
bl.parent_block_processed(
chain_hash,
BlockError::BlockIsAlreadyKnown(block.canonical_root()).into(),
&mut cx,
)
} else {
bl.parent_block_processed(
chain_hash,
Expand Down
4 changes: 2 additions & 2 deletions scripts/local_testnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ To view the beacon, validator client and geth logs:

```bash
tail -f ~/.lighthouse/local-testnet/testnet/beacon_node_1.log
taif -f ~/.lighthouse/local-testnet/testnet/validator_node_1.log
tail -f ~/.lighthouse/local-testnet/testnet/validator_node_1.log
tail -f ~/.lighthouse/local-testnet/testnet/geth_1.log
```

Expand Down Expand Up @@ -198,4 +198,4 @@ Update the genesis time to now using:

Some addresses in the local testnet are seeded with testnet ETH, allowing users to carry out transactions. To send a transaction, we first add the address to a wallet, such as [Metamask](https://metamask.io/). The private keys for the addresses are listed [here](https://github.com/sigp/lighthouse/blob/441fc1691b69f9edc4bbdc6665f3efab16265c9b/testing/execution_engine_integration/src/execution_engine.rs#L13-L14).

Next, we add the local testnet to Metamask, a brief guide can be found [here](https://support.metamask.io/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC). If you start the local testnet with default settings, the network RPC is: http://localhost:6001 and the `Chain ID` is `4242`, as defined in [`vars.env`](https://github.com/sigp/lighthouse/blob/441fc1691b69f9edc4bbdc6665f3efab16265c9b/scripts/local_testnet/vars.env#L42). Once the network and account are added, you should see that the account contains testnet ETH which allow us to carry out transactions.
Next, we add the local testnet to Metamask, a brief guide can be found [here](https://support.metamask.io/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC). If you start the local testnet with default settings, the network RPC is: http://localhost:6001 and the `Chain ID` is `4242`, as defined in [`vars.env`](https://github.com/sigp/lighthouse/blob/441fc1691b69f9edc4bbdc6665f3efab16265c9b/scripts/local_testnet/vars.env#L42). Once the network and account are added, you should see that the account contains testnet ETH which allow us to carry out transactions.