Skip to content

Commit b15b7d7

Browse files
committed
Remove legacy max-skip-slots checks (#4403)
## Proposed Changes Remove `max-skip-slots` checks when processing blocks. This was legacy code which was previously used in the Medalla testnet to sync to the correct fork. With the addition of checkpoint sync which allows us to sync to any arbitrary fork, this is no longer a necessary feature, so it has been removed for simplicity. ## Additional Notes The CLI flag and checks for attestation processing have been retained as it still may have uses in DoS protection.
1 parent 2bb62b7 commit b15b7d7

File tree

4 files changed

+2
-39
lines changed

4 files changed

+2
-39
lines changed

beacon_node/beacon_chain/src/block_verification.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ pub enum BlockError<T: EthSpec> {
141141
/// It's unclear if this block is valid, but it cannot be processed without already knowing
142142
/// its parent.
143143
ParentUnknown(Arc<SignedBeaconBlock<T>>),
144-
/// The block skips too many slots and is a DoS risk.
145-
TooManySkippedSlots { parent_slot: Slot, block_slot: Slot },
146144
/// The block slot is greater than the present slot.
147145
///
148146
/// ## Peer scoring
@@ -786,9 +784,6 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
786784
parent_block.root
787785
};
788786

789-
// Reject any block that exceeds our limit on skipped slots.
790-
check_block_skip_slots(chain, parent_block.slot, block.message())?;
791-
792787
// We assign to a variable instead of using `if let Some` directly to ensure we drop the
793788
// write lock before trying to acquire it again in the `else` clause.
794789
let proposer_opt = chain
@@ -942,9 +937,6 @@ impl<T: BeaconChainTypes> SignatureVerifiedBlock<T> {
942937

943938
let (mut parent, block) = load_parent(block_root, block, chain)?;
944939

945-
// Reject any block that exceeds our limit on skipped slots.
946-
check_block_skip_slots(chain, parent.beacon_block.slot(), block.message())?;
947-
948940
let state = cheap_state_advance_to_obtain_committees(
949941
&mut parent.pre_state,
950942
parent.beacon_state_root,
@@ -1135,9 +1127,6 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
11351127
return Err(BlockError::ParentUnknown(block));
11361128
}
11371129

1138-
// Reject any block that exceeds our limit on skipped slots.
1139-
check_block_skip_slots(chain, parent.beacon_block.slot(), block.message())?;
1140-
11411130
/*
11421131
* Perform cursory checks to see if the block is even worth processing.
11431132
*/
@@ -1492,30 +1481,6 @@ impl<T: BeaconChainTypes> ExecutionPendingBlock<T> {
14921481
}
14931482
}
14941483

1495-
/// Check that the count of skip slots between the block and its parent does not exceed our maximum
1496-
/// value.
1497-
///
1498-
/// Whilst this is not part of the specification, we include this to help prevent us from DoS
1499-
/// attacks. In times of dire network circumstance, the user can configure the
1500-
/// `import_max_skip_slots` value.
1501-
fn check_block_skip_slots<T: BeaconChainTypes>(
1502-
chain: &BeaconChain<T>,
1503-
parent_slot: Slot,
1504-
block: BeaconBlockRef<'_, T::EthSpec>,
1505-
) -> Result<(), BlockError<T::EthSpec>> {
1506-
// Reject any block that exceeds our limit on skipped slots.
1507-
if let Some(max_skip_slots) = chain.config.import_max_skip_slots {
1508-
if block.slot() > parent_slot + max_skip_slots {
1509-
return Err(BlockError::TooManySkippedSlots {
1510-
parent_slot,
1511-
block_slot: block.slot(),
1512-
});
1513-
}
1514-
}
1515-
1516-
Ok(())
1517-
}
1518-
15191484
/// Returns `Ok(())` if the block's slot is greater than the anchor block's slot (if any).
15201485
fn check_block_against_anchor_slot<T: BeaconChainTypes>(
15211486
block: BeaconBlockRef<'_, T::EthSpec>,

beacon_node/beacon_chain/src/chain_config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ pub const FORK_CHOICE_LOOKAHEAD_FACTOR: u32 = 24;
1717

1818
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
1919
pub struct ChainConfig {
20-
/// Maximum number of slots to skip when importing a consensus message (e.g., block,
21-
/// attestation, etc).
20+
/// Maximum number of slots to skip when importing an attestation.
2221
///
2322
/// If `None`, there is no limit.
2423
pub import_max_skip_slots: Option<u64>,

beacon_node/network/src/beacon_processor/worker/gossip_methods.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,6 @@ impl<T: BeaconChainTypes> Worker<T> {
835835
| Err(e @ BlockError::NonLinearParentRoots)
836836
| Err(e @ BlockError::BlockIsNotLaterThanParent { .. })
837837
| Err(e @ BlockError::InvalidSignature)
838-
| Err(e @ BlockError::TooManySkippedSlots { .. })
839838
| Err(e @ BlockError::WeakSubjectivityConflict)
840839
| Err(e @ BlockError::InconsistentFork(_))
841840
| Err(e @ BlockError::ExecutionPayloadError(_))

beacon_node/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
685685
Arg::with_name("max-skip-slots")
686686
.long("max-skip-slots")
687687
.help(
688-
"Refuse to skip more than this many slots when processing a block or attestation. \
688+
"Refuse to skip more than this many slots when processing an attestation. \
689689
This prevents nodes on minority forks from wasting our time and disk space, \
690690
but could also cause unnecessary consensus failures, so is disabled by default."
691691
)

0 commit comments

Comments
 (0)