Lenient duplicate checks on HTTP API for block publication (#5574)

* start splitting gossip verification

* WIP

* Gossip verify separate (#7)

* save

* save

* make ProvenancedBlock concrete

* delete into gossip verified block contents

* get rid of IntoBlobSidecar trait

* remove IntoGossipVerified trait

* get tests compiling

* don't check sidecar slashability in publish

* remove second publish closure

* drop blob bool. also prefer using message index over index of position in list

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Fix low-hanging tests

* Fix tests and clean up

* Clean up imports

* more cleanup

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Further refine behaviour and add tests

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Remove empty line

* Fix test (block is not fully imported just gossip verified)

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Update for unstable & use empty blob list

* Update comment

* Add test for duplicate block case

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Clarify unreachable case

* Fix another publish_block case

* Remove unreachable case in filter chain segment

* Revert unrelated blob optimisation

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Fix merge conflicts

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Fix some compilation issues. Impl is fucked though

* Support peerDAS

* Fix tests

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Fix conflict

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate

* Address review comments

* Merge remote-tracking branch 'origin/unstable' into gossip-verify-separate
This commit is contained in:
Michael Sproul
2024-09-24 14:52:44 +10:00
committed by GitHub
parent 1447eeb40b
commit 2792705331
21 changed files with 1071 additions and 516 deletions

View File

@@ -936,7 +936,10 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
let blob_slot = verified_blob.slot();
let blob_index = verified_blob.id().index;
let result = self.chain.process_gossip_blob(verified_blob).await;
let result = self
.chain
.process_gossip_blob(verified_blob, || Ok(()))
.await;
match &result {
Ok(AvailabilityProcessingStatus::Imported(block_root)) => {
@@ -963,7 +966,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
"block_root" => %block_root,
);
}
Err(BlockError::BlockIsAlreadyKnown(_)) => {
Err(BlockError::DuplicateFullyImported(_)) => {
debug!(
self.log,
"Ignoring gossip blob already imported";
@@ -1013,7 +1016,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
match self
.chain
.process_gossip_data_columns(vec![verified_data_column])
.process_gossip_data_columns(vec![verified_data_column], || Ok(()))
.await
{
Ok((availability, data_columns_to_publish)) => {
@@ -1050,7 +1053,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
}
}
}
Err(BlockError::BlockIsAlreadyKnown(_)) => {
Err(BlockError::DuplicateFullyImported(_)) => {
debug!(
self.log,
"Ignoring gossip column already imported";
@@ -1242,7 +1245,10 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
return None;
}
Err(BlockError::BlockIsAlreadyKnown(_)) => {
Err(
BlockError::DuplicateFullyImported(_)
| BlockError::DuplicateImportStatusUnknown(..),
) => {
debug!(
self.log,
"Gossip block is already known";

View File

@@ -294,7 +294,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
"slot" => %slot,
);
}
Err(BlockError::BlockIsAlreadyKnown(_)) => {
Err(BlockError::DuplicateFullyImported(_)) => {
debug!(
self.log,
"Blobs have already been imported";
@@ -355,7 +355,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
}
}
}
Err(BlockError::BlockIsAlreadyKnown(_)) => {
Err(BlockError::DuplicateFullyImported(_)) => {
debug!(
self.log,
"Custody columns have already been imported";
@@ -715,7 +715,8 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
peer_action: Some(PeerAction::LowToleranceError),
})
}
BlockError::BlockIsAlreadyKnown(_) => {
BlockError::DuplicateFullyImported(_)
| BlockError::DuplicateImportStatusUnknown(..) => {
// This can happen for many reasons. Head sync's can download multiples and parent
// lookups can download blocks before range sync
Ok(())

View File

@@ -517,7 +517,7 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
let action = match result {
BlockProcessingResult::Ok(AvailabilityProcessingStatus::Imported(_))
| BlockProcessingResult::Err(BlockError::BlockIsAlreadyKnown(_)) => {
| BlockProcessingResult::Err(BlockError::DuplicateFullyImported(..)) => {
// Successfully imported
request_state.on_processing_success()?;
Action::Continue
@@ -541,6 +541,16 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
Action::Retry
}
}
BlockProcessingResult::Err(BlockError::DuplicateImportStatusUnknown(..)) => {
// This is unreachable because RPC blocks do not undergo gossip verification, and
// this error can *only* come from gossip verification.
error!(
self.log,
"Single block lookup hit unreachable condition";
"block_root" => ?block_root
);
Action::Drop
}
BlockProcessingResult::Ignored => {
// Beacon processor signalled to ignore the block processing result.
// This implies that the cpu is overloaded. Drop the request.

View File

@@ -1471,7 +1471,7 @@ fn test_parent_lookup_happy_path() {
// Processing succeeds, now the rest of the chain should be sent for processing.
rig.parent_block_processed(
block_root,
BlockError::BlockIsAlreadyKnown(block_root).into(),
BlockError::DuplicateFullyImported(block_root).into(),
);
rig.expect_parent_chain_process();
rig.parent_chain_processed_success(block_root, &[]);
@@ -1839,7 +1839,7 @@ fn test_same_chain_race_condition() {
rig.log(&format!("Block {i} was removed and is already known"));
rig.parent_block_processed(
chain_hash,
BlockError::BlockIsAlreadyKnown(block.canonical_root()).into(),
BlockError::DuplicateFullyImported(block.canonical_root()).into(),
)
} else {
rig.log(&format!("Block {i} ParentUnknown"));

View File

@@ -629,8 +629,8 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
// cache nor in the request state of this lookup. Therefore, the block must either: (1) not
// be downloaded yet or (2) the block is already imported into the fork-choice.
// In case (1) the lookup must either successfully download the block or get dropped.
// In case (2) the block will be downloaded, processed, reach `BlockIsAlreadyKnown` and
// get dropped as completed.
// In case (2) the block will be downloaded, processed, reach `DuplicateFullyImported`
// and get dropped as completed.
return Ok(LookupRequestResult::Pending("waiting for block download"));
};
let expected_blobs = block.num_expected_blobs();