diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index b5ed74e192..8b0e879aa7 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -39,7 +39,7 @@ use types::*; // Must be 32-bytes or panic. // // |-------must be this long------| -pub const GRAFFITI: &str = "sigp/lighthouse-0.0.0-prerelease"; +pub const GRAFFITI: &str = "sigp/lighthouse-0.1.0-prerelease"; /// If true, everytime a block is processed the pre-state, post-state and block are written to SSZ /// files in the temp directory. @@ -47,6 +47,9 @@ pub const GRAFFITI: &str = "sigp/lighthouse-0.0.0-prerelease"; /// Only useful for testing. const WRITE_BLOCK_PROCESSING_SSZ: bool = cfg!(feature = "write_ssz_files"); +/// Maximum block slot number. Block with slots bigger than this constant will NOT be processed. +const MAXIMUM_BLOCK_SLOT_NUMBER: u64 = 4_294_967_296; // 2^32 + #[derive(Debug, PartialEq)] pub enum BlockProcessingOutcome { /// Block was valid and imported into the block graph. @@ -69,6 +72,8 @@ pub enum BlockProcessingOutcome { }, /// Block is already known, no need to re-import. BlockIsAlreadyKnown, + /// The block slot exceeds the MAXIMUM_BLOCK_SLOT_NUMBER. + BlockSlotLimitReached, /// The block could not be applied to the state, it is invalid. PerBlockProcessingError(BlockProcessingError), } @@ -1174,6 +1179,10 @@ impl BeaconChain { return Ok(BlockProcessingOutcome::GenesisBlock); } + if block.slot >= MAXIMUM_BLOCK_SLOT_NUMBER { + return Ok(BlockProcessingOutcome::BlockSlotLimitReached); + } + if block.slot <= finalized_slot { return Ok(BlockProcessingOutcome::WouldRevertFinalizedSlot { block_slot: block.slot,