mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-04 05:14:33 +00:00
Drop skip too large condition for liveness safety (#6014)
* Drop skip too large condition for liveness safety
This commit is contained in:
@@ -114,7 +114,7 @@ use std::collections::HashSet;
|
|||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::Duration;
|
||||||
use store::iter::{BlockRootsIterator, ParentRootBlockIterator, StateRootsIterator};
|
use store::iter::{BlockRootsIterator, ParentRootBlockIterator, StateRootsIterator};
|
||||||
use store::{
|
use store::{
|
||||||
DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore, KeyValueStoreOp, StoreItem, StoreOp,
|
DatabaseBlock, Error as DBError, HotColdDB, KeyValueStore, KeyValueStoreOp, StoreItem, StoreOp,
|
||||||
@@ -1410,10 +1410,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
let start_slot = head_state.slot();
|
|
||||||
let task_start = Instant::now();
|
|
||||||
let max_task_runtime = Duration::from_secs(self.spec.seconds_per_slot);
|
|
||||||
|
|
||||||
let head_state_slot = head_state.slot();
|
let head_state_slot = head_state.slot();
|
||||||
let mut state = head_state;
|
let mut state = head_state;
|
||||||
|
|
||||||
@@ -1423,18 +1419,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
while state.slot() < slot {
|
while state.slot() < slot {
|
||||||
// Do not allow and forward state skip that takes longer than the maximum task duration.
|
|
||||||
//
|
|
||||||
// This is a protection against nodes doing too much work when they're not synced
|
|
||||||
// to a chain.
|
|
||||||
if task_start + max_task_runtime < Instant::now() {
|
|
||||||
return Err(Error::StateSkipTooLarge {
|
|
||||||
start_slot,
|
|
||||||
requested_slot: slot,
|
|
||||||
max_task_runtime,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: supplying some `state_root` when it is known would be a cheap and easy
|
// Note: supplying some `state_root` when it is known would be a cheap and easy
|
||||||
// optimization.
|
// optimization.
|
||||||
match per_slot_processing(&mut state, skip_state_root, &self.spec) {
|
match per_slot_processing(&mut state, skip_state_root, &self.spec) {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ use state_processing::{
|
|||||||
state_advance::Error as StateAdvanceError,
|
state_advance::Error as StateAdvanceError,
|
||||||
BlockProcessingError, BlockReplayError, EpochProcessingError, SlotProcessingError,
|
BlockProcessingError, BlockReplayError, EpochProcessingError, SlotProcessingError,
|
||||||
};
|
};
|
||||||
use std::time::Duration;
|
|
||||||
use task_executor::ShutdownReason;
|
use task_executor::ShutdownReason;
|
||||||
use tokio::task::JoinError;
|
use tokio::task::JoinError;
|
||||||
use types::milhouse::Error as MilhouseError;
|
use types::milhouse::Error as MilhouseError;
|
||||||
@@ -77,11 +76,6 @@ pub enum BeaconChainError {
|
|||||||
ProposerSlashingValidationError(ProposerSlashingValidationError),
|
ProposerSlashingValidationError(ProposerSlashingValidationError),
|
||||||
AttesterSlashingValidationError(AttesterSlashingValidationError),
|
AttesterSlashingValidationError(AttesterSlashingValidationError),
|
||||||
BlsExecutionChangeValidationError(BlsExecutionChangeValidationError),
|
BlsExecutionChangeValidationError(BlsExecutionChangeValidationError),
|
||||||
StateSkipTooLarge {
|
|
||||||
start_slot: Slot,
|
|
||||||
requested_slot: Slot,
|
|
||||||
max_task_runtime: Duration,
|
|
||||||
},
|
|
||||||
MissingFinalizedStateRoot(Slot),
|
MissingFinalizedStateRoot(Slot),
|
||||||
/// Returned when an internal check fails, indicating corrupt data.
|
/// Returned when an internal check fails, indicating corrupt data.
|
||||||
InvariantViolated(String),
|
InvariantViolated(String),
|
||||||
|
|||||||
Reference in New Issue
Block a user