mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 12:47:05 +00:00
merge unstable
This commit is contained in:
@@ -8,10 +8,11 @@ edition = { workspace = true }
|
||||
[dependencies]
|
||||
ethereum_ssz = { workspace = true }
|
||||
ethereum_ssz_derive = { workspace = true }
|
||||
logging = { workspace = true }
|
||||
metrics = { workspace = true }
|
||||
proto_array = { workspace = true }
|
||||
slog = { workspace = true }
|
||||
state_processing = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
types = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::metrics::{self, scrape_for_metrics};
|
||||
use crate::{ForkChoiceStore, InvalidationOperation};
|
||||
use logging::crit;
|
||||
use proto_array::{
|
||||
Block as ProtoBlock, DisallowedReOrgOffsets, ExecutionStatus, ProposerHeadError,
|
||||
ProposerHeadInfo, ProtoArrayForkChoice, ReOrgThreshold,
|
||||
};
|
||||
use slog::{crit, debug, warn, Logger};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use state_processing::{
|
||||
per_block_processing::errors::AttesterSlashingValidationError, per_epoch_processing,
|
||||
@@ -13,6 +13,7 @@ use std::cmp::Ordering;
|
||||
use std::collections::BTreeSet;
|
||||
use std::marker::PhantomData;
|
||||
use std::time::Duration;
|
||||
use tracing::{debug, warn};
|
||||
use types::{
|
||||
consts::bellatrix::INTERVALS_PER_SLOT, AbstractExecPayload, AttestationShufflingId,
|
||||
AttesterSlashingRef, BeaconBlockRef, BeaconState, BeaconStateError, ChainSpec, Checkpoint,
|
||||
@@ -1262,6 +1263,11 @@ where
|
||||
.is_finalized_checkpoint_or_descendant::<E>(block_root)
|
||||
}
|
||||
|
||||
pub fn is_descendant(&self, ancestor_root: Hash256, descendant_root: Hash256) -> bool {
|
||||
self.proto_array
|
||||
.is_descendant(ancestor_root, descendant_root)
|
||||
}
|
||||
|
||||
/// Returns `Ok(true)` if `block_root` has been imported optimistically or deemed invalid.
|
||||
///
|
||||
/// Returns `Ok(false)` if `block_root`'s execution payload has been elected as fully VALID, if
|
||||
@@ -1372,17 +1378,14 @@ where
|
||||
persisted: &PersistedForkChoice,
|
||||
reset_payload_statuses: ResetPayloadStatuses,
|
||||
spec: &ChainSpec,
|
||||
log: &Logger,
|
||||
) -> Result<ProtoArrayForkChoice, Error<T::Error>> {
|
||||
let mut proto_array = ProtoArrayForkChoice::from_bytes(&persisted.proto_array_bytes)
|
||||
.map_err(Error::InvalidProtoArrayBytes)?;
|
||||
let contains_invalid_payloads = proto_array.contains_invalid_payloads();
|
||||
|
||||
debug!(
|
||||
log,
|
||||
"Restoring fork choice from persisted";
|
||||
"reset_payload_statuses" => ?reset_payload_statuses,
|
||||
"contains_invalid_payloads" => contains_invalid_payloads,
|
||||
?reset_payload_statuses,
|
||||
contains_invalid_payloads, "Restoring fork choice from persisted"
|
||||
);
|
||||
|
||||
// Exit early if there are no "invalid" payloads, if requested.
|
||||
@@ -1401,18 +1404,14 @@ where
|
||||
// back to a proto-array which does not have the reset applied. This indicates a
|
||||
// significant error in Lighthouse and warrants detailed investigation.
|
||||
crit!(
|
||||
log,
|
||||
"Failed to reset payload statuses";
|
||||
"error" => e,
|
||||
"info" => "please report this error",
|
||||
error = ?e,
|
||||
info = "please report this error",
|
||||
"Failed to reset payload statuses"
|
||||
);
|
||||
ProtoArrayForkChoice::from_bytes(&persisted.proto_array_bytes)
|
||||
.map_err(Error::InvalidProtoArrayBytes)
|
||||
} else {
|
||||
debug!(
|
||||
log,
|
||||
"Successfully reset all payload statuses";
|
||||
);
|
||||
debug!("Successfully reset all payload statuses");
|
||||
Ok(proto_array)
|
||||
}
|
||||
}
|
||||
@@ -1424,10 +1423,9 @@ where
|
||||
reset_payload_statuses: ResetPayloadStatuses,
|
||||
fc_store: T,
|
||||
spec: &ChainSpec,
|
||||
log: &Logger,
|
||||
) -> Result<Self, Error<T::Error>> {
|
||||
let proto_array =
|
||||
Self::proto_array_from_persisted(&persisted, reset_payload_statuses, spec, log)?;
|
||||
Self::proto_array_from_persisted(&persisted, reset_payload_statuses, spec)?;
|
||||
|
||||
let current_slot = fc_store.get_current_slot();
|
||||
|
||||
@@ -1451,10 +1449,9 @@ where
|
||||
// an optimistic status so that we can have a head to start from.
|
||||
if let Err(e) = fork_choice.get_head(current_slot, spec) {
|
||||
warn!(
|
||||
log,
|
||||
"Could not find head on persisted FC";
|
||||
"info" => "resetting all payload statuses and retrying",
|
||||
"error" => ?e
|
||||
info = "resetting all payload statuses and retrying",
|
||||
error = ?e,
|
||||
"Could not find head on persisted FC"
|
||||
);
|
||||
// Although we may have already made this call whilst loading `proto_array`, try it
|
||||
// again since we may have mutated the `proto_array` during `get_head` and therefore may
|
||||
|
||||
@@ -25,6 +25,9 @@ pub type E = MainnetEthSpec;
|
||||
|
||||
pub const VALIDATOR_COUNT: usize = 64;
|
||||
|
||||
// When set to true, cache any states fetched from the db.
|
||||
pub const CACHE_STATE_IN_TESTS: bool = true;
|
||||
|
||||
/// Defines some delay between when an attestation is created and when it is mutated.
|
||||
pub enum MutationDelay {
|
||||
/// No delay between creation and mutation.
|
||||
@@ -373,7 +376,7 @@ impl ForkChoiceTest {
|
||||
let state = harness
|
||||
.chain
|
||||
.store
|
||||
.get_state(&state_root, None)
|
||||
.get_state(&state_root, None, CACHE_STATE_IN_TESTS)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
let balances = state
|
||||
|
||||
Reference in New Issue
Block a user