Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
8ec62d2
add missed_block metric
v4lproik Sep 13, 2023
bb545e1
init missed_block in constructor
v4lproik Sep 13, 2023
da53390
declare beaconproposercache in ValidatorMonitor
v4lproik Sep 13, 2023
710ff13
refacto proposer_shuffling_decision_root to use epoch instead of curr…
v4lproik Sep 13, 2023
a457a48
imple new proposer_shuffling_decision_root in callers
v4lproik Sep 13, 2023
ddd45a9
push missed_blocks
v4lproik Sep 13, 2023
f88f691
prune missed_blocks
v4lproik Sep 13, 2023
3845616
only add to hashmap if it's a monitored validator
v4lproik Sep 13, 2023
e13280d
remove current_epoch dup + typos
v4lproik Sep 14, 2023
2dbf8e7
extract in func
v4lproik Sep 14, 2023
9370ea8
add prom metrics
v4lproik Sep 14, 2023
751c88f
checkpoint is not only epoch but slot as well
v4lproik Sep 14, 2023
83da21b
add safeguard if we start a new chain at slot 0
v4lproik Sep 14, 2023
518648f
clean
v4lproik Sep 14, 2023
5026f0e
remove unnecessary negative value for a slot
v4lproik Sep 16, 2023
fe4958a
typo in comment
v4lproik Sep 16, 2023
84c1f8a
remove unused current_epoch
v4lproik Sep 16, 2023
3a3bf91
share beacon_proposer_cache between validator_monitor and beacon_chain
v4lproik Sep 16, 2023
4129d34
pass Hash256::zero()
v4lproik Sep 16, 2023
18970e5
debug objects
v4lproik Sep 16, 2023
724c161
fix loop: lag is at the head
v4lproik Sep 16, 2023
ac034fb
sed s/get_slot/get_epoch
v4lproik Sep 16, 2023
0d09546
fewer calls to cache.get_epoch
v4lproik Sep 17, 2023
8ec9288
fix typos
v4lproik Sep 17, 2023
a7ff5be
remove cache first call
v4lproik Sep 17, 2023
8d7a9f3
export TYPICAL_SLOTS_PER_EPOCH and use it in validator_monitor
v4lproik Sep 17, 2023
6bd4fb8
switch to gauge & loop over missed_blocks hashset
v4lproik Sep 17, 2023
d132dd6
fix subnet_service tests
v4lproik Sep 17, 2023
62a6ca8
remove unused var
v4lproik Sep 18, 2023
eb85595
clean + fix nits
v4lproik Sep 24, 2023
3dd8839
add beacon_proposer_cache + validator_monitor in builder
v4lproik Sep 24, 2023
e395c07
fix store_tests
v4lproik Sep 24, 2023
179b145
fix builder tests
v4lproik Sep 24, 2023
4151571
add tests
v4lproik Sep 24, 2023
4b1213f
add validator monitor set of tests
v4lproik Sep 24, 2023
c8cf973
clean tests
v4lproik Sep 24, 2023
265ae08
nits
v4lproik Sep 24, 2023
67923bb
optimise imports
v4lproik Sep 24, 2023
1c45e05
lint
v4lproik Sep 24, 2023
e1364bf
typo
v4lproik Sep 28, 2023
c92ab4a
added self.aggregatable
v4lproik Sep 28, 2023
e3fadcb
duplicate proposer_shuffling_decision_root
v4lproik Sep 28, 2023
b59d879
remove duplication in passing beacon_proposer_cache
v4lproik Sep 28, 2023
7b4bb21
remove duplication in passing beacon_proposer_cache
v4lproik Sep 28, 2023
37706b8
using indices
v4lproik Sep 28, 2023
ac46a0e
fmt
v4lproik Sep 28, 2023
704de81
implement missed blocks total
v4lproik Sep 28, 2023
dc19c4c
nits
v4lproik Oct 1, 2023
bfc8379
avoid heap allocation
v4lproik Oct 4, 2023
ed99d71
remove recursion limit
v4lproik Oct 4, 2023
18c6a73
fix lint
v4lproik Oct 4, 2023
c517e3d
Fix valdiator monitor builder pattern
paulhauner Oct 3, 2023
7ab3814
renaming metrics
v4lproik Oct 5, 2023
1660b36
renaming metrics in validator monitor
v4lproik Oct 5, 2023
3461c09
add log if there's a missing validator index
v4lproik Oct 5, 2023
724419c
consistent log
v4lproik Oct 5, 2023
2102655
fix loop
v4lproik Oct 5, 2023
54aa915
better loop
v4lproik Oct 7, 2023
bc3e396
move gauge to counter
v4lproik Oct 7, 2023
127c86a
fmt
v4lproik Oct 9, 2023
8c2d5f9
add error message
v4lproik Oct 9, 2023
3e1110d
lint
v4lproik Oct 9, 2023
4bd1b7c
fix prom metrics
v4lproik Oct 12, 2023
55add09
set gauge to 0 when non-finalized epochs
v4lproik Oct 12, 2023
648673d
better wording
v4lproik Oct 12, 2023
fae3ff1
remove hash256::zero in favour of block_root
v4lproik Oct 15, 2023
c1f0754
fix gauge total label
v4lproik Oct 15, 2023
109ed39
fix last missed block validator
v4lproik Oct 15, 2023
8672725
Add `MissedBlock` struct
paulhauner Nov 2, 2023
9840037
Fix comment
paulhauner Nov 2, 2023
0f27882
Refactor non-finalized block loop
paulhauner Nov 2, 2023
5e21607
Fix off-by-one
paulhauner Nov 2, 2023
73924cf
Avoid string allocation
paulhauner Nov 2, 2023
062e5d2
Fix compile error
paulhauner Nov 2, 2023
c8ce880
Remove non-finalized blocks metric
paulhauner Nov 2, 2023
6e9e108
Merge branch 'unstable' into add-missed-blocks-to-monitored-validators
v4lproik Nov 5, 2023
9771fb3
fix func clojure
v4lproik Nov 5, 2023
5aab7c3
remove unused variable
v4lproik Nov 5, 2023
0392b3f
remove unused DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD
v4lproik Nov 5, 2023
586c00f
remove unused DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD in builder
v4lproik Nov 5, 2023
4684aff
add validator index depending on the fork name
v4lproik Nov 6, 2023
5b1374e
typos
v4lproik Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ pub struct BeaconChain<T: BeaconChainTypes> {
/// A cache of eth1 deposit data at epoch boundaries for deposit finalization
pub eth1_finalization_cache: TimeoutRwLock<Eth1FinalizationCache>,
/// Caches the beacon block proposer shuffling for a given epoch and shuffling key root.
pub beacon_proposer_cache: Mutex<BeaconProposerCache>,
pub beacon_proposer_cache: Arc<Mutex<BeaconProposerCache>>,
/// Caches a map of `validator_index -> validator_pubkey`.
pub(crate) validator_pubkey_cache: TimeoutRwLock<ValidatorPubkeyCache<T>>,
/// A cache used when producing attestations.
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/beacon_proposer_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const CACHE_SIZE: usize = 16;
/// This value is fairly unimportant, it's used to avoid heap allocations. The result of it being
/// incorrect is non-substantial from a consensus perspective (and probably also from a
/// performance perspective).
const TYPICAL_SLOTS_PER_EPOCH: usize = 32;
pub const TYPICAL_SLOTS_PER_EPOCH: usize = 32;

/// For some given slot, this contains the proposer index (`index`) and the `fork` that should be
/// used to verify their signature.
Expand Down
50 changes: 19 additions & 31 deletions beacon_node/beacon_chain/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::beacon_chain::{CanonicalHead, BEACON_CHAIN_DB_KEY, ETH1_CACHE_DB_KEY, OP_POOL_DB_KEY};
use crate::beacon_proposer_cache::BeaconProposerCache;
use crate::data_availability_checker::DataAvailabilityChecker;
use crate::eth1_chain::{CachingEth1Backend, SszEth1};
use crate::eth1_finalization_cache::Eth1FinalizationCache;
Expand All @@ -10,7 +11,7 @@ use crate::persisted_beacon_chain::PersistedBeaconChain;
use crate::shuffling_cache::{BlockShufflingIds, ShufflingCache};
use crate::snapshot_cache::{SnapshotCache, DEFAULT_SNAPSHOT_CACHE_SIZE};
use crate::timeout_rw_lock::TimeoutRwLock;
use crate::validator_monitor::ValidatorMonitor;
use crate::validator_monitor::{ValidatorMonitor, ValidatorMonitorConfig};
use crate::validator_pubkey_cache::ValidatorPubkeyCache;
use crate::ChainConfig;
use crate::{
Expand All @@ -23,10 +24,10 @@ use fork_choice::{ForkChoice, ResetPayloadStatuses};
use futures::channel::mpsc::Sender;
use kzg::{Kzg, TrustedSetup};
use operation_pool::{OperationPool, PersistedOperationPool};
use parking_lot::RwLock;
use parking_lot::{Mutex, RwLock};
use proto_array::{DisallowedReOrgOffsets, ReOrgThreshold};
use slasher::Slasher;
use slog::{crit, debug, error, info, Logger};
use slog::{crit, debug, error, info, o, Logger};
use slot_clock::{SlotClock, TestingSlotClock};
use state_processing::per_slot_processing;
use std::marker::PhantomData;
Expand All @@ -35,8 +36,8 @@ use std::time::Duration;
use store::{Error as StoreError, HotColdDB, ItemStore, KeyValueStoreOp};
use task_executor::{ShutdownReason, TaskExecutor};
use types::{
BeaconBlock, BeaconState, ChainSpec, Checkpoint, Epoch, EthSpec, Graffiti, Hash256,
PublicKeyBytes, Signature, SignedBeaconBlock, Slot,
BeaconBlock, BeaconState, ChainSpec, Checkpoint, Epoch, EthSpec, Graffiti, Hash256, Signature,
SignedBeaconBlock, Slot,
};

/// An empty struct used to "witness" all the `BeaconChainTypes` traits. It has no user-facing
Expand Down Expand Up @@ -93,12 +94,12 @@ pub struct BeaconChainBuilder<T: BeaconChainTypes> {
log: Option<Logger>,
graffiti: Graffiti,
slasher: Option<Arc<Slasher<T::EthSpec>>>,
validator_monitor: Option<ValidatorMonitor<T::EthSpec>>,
// Pending I/O batch that is constructed during building and should be executed atomically
// alongside `PersistedBeaconChain` storage when `BeaconChainBuilder::build` is called.
pending_io_batch: Vec<KeyValueStoreOp>,
trusted_setup: Option<TrustedSetup>,
task_executor: Option<TaskExecutor>,
validator_monitor_config: Option<ValidatorMonitorConfig>,
}

impl<TSlotClock, TEth1Backend, TEthSpec, THotStore, TColdStore>
Expand Down Expand Up @@ -135,10 +136,10 @@ where
log: None,
graffiti: Graffiti::default(),
slasher: None,
validator_monitor: None,
pending_io_batch: vec![],
trusted_setup: None,
task_executor: None,
validator_monitor_config: None,
}
}

Expand Down Expand Up @@ -623,19 +624,8 @@ where
/// Register some validators for additional monitoring.
///
/// `validators` is a comma-separated string of 0x-formatted BLS pubkeys.
pub fn monitor_validators(
mut self,
auto_register: bool,
validators: Vec<PublicKeyBytes>,
individual_metrics_threshold: usize,
log: Logger,
) -> Self {
self.validator_monitor = Some(ValidatorMonitor::new(
validators,
auto_register,
individual_metrics_threshold,
log.clone(),
));
pub fn validator_monitor_config(mut self, config: ValidatorMonitorConfig) -> Self {
self.validator_monitor_config = Some(config);
self
}

Expand Down Expand Up @@ -671,11 +661,16 @@ where
let genesis_state_root = self
.genesis_state_root
.ok_or("Cannot build without a genesis state root")?;
let mut validator_monitor = self
.validator_monitor
.ok_or("Cannot build without a validator monitor")?;
let validator_monitor_config = self.validator_monitor_config.unwrap_or_default();
let head_tracker = Arc::new(self.head_tracker.unwrap_or_default());

let beacon_proposer_cache: Arc<Mutex<BeaconProposerCache>> = <_>::default();
let mut validator_monitor = ValidatorMonitor::new(
validator_monitor_config,
beacon_proposer_cache.clone(),
log.new(o!("service" => "val_mon")),
);

let current_slot = if slot_clock
.is_prior_to_genesis()
.ok_or("Unable to read slot clock")?
Expand Down Expand Up @@ -911,7 +906,7 @@ where
log.clone(),
)),
eth1_finalization_cache: TimeoutRwLock::new(Eth1FinalizationCache::new(log.clone())),
beacon_proposer_cache: <_>::default(),
beacon_proposer_cache,
block_times_cache: <_>::default(),
pre_finalization_block_cache: <_>::default(),
validator_pubkey_cache: TimeoutRwLock::new(validator_pubkey_cache),
Expand Down Expand Up @@ -1097,7 +1092,6 @@ fn descriptive_db_error(item: &str, error: &StoreError) -> String {
mod test {
use super::*;
use crate::test_utils::EphemeralHarnessType;
use crate::validator_monitor::DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD;
use ethereum_hashing::hash;
use genesis::{
generate_deterministic_keypairs, interop_genesis_state, DEFAULT_ETH1_BLOCK_HASH,
Expand Down Expand Up @@ -1155,12 +1149,6 @@ mod test {
.testing_slot_clock(Duration::from_secs(1))
.expect("should configure testing slot clock")
.shutdown_sender(shutdown_tx)
.monitor_validators(
true,
vec![],
DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD,
log.clone(),
)
.build()
.expect("should build");

Expand Down
5 changes: 5 additions & 0 deletions beacon_node/beacon_chain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,11 @@ lazy_static! {
"beacon_aggregated_attestation_subsets_total",
"Count of new aggregated attestations that are subsets of already known aggregates"
);
pub static ref VALIDATOR_MONITOR_MISSED_BLOCKS_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
"validator_monitor_missed_blocks_total",
"Number of non-finalized blocks missed",
&["validator"]
);

/*
* Kzg related metrics
Expand Down
18 changes: 15 additions & 3 deletions beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub use crate::{
beacon_chain::{BEACON_CHAIN_DB_KEY, ETH1_CACHE_DB_KEY, FORK_CHOICE_DB_KEY, OP_POOL_DB_KEY},
migrate::MigratorConfig,
sync_committee_verification::Error as SyncCommitteeError,
validator_monitor::DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD,
validator_monitor::{ValidatorMonitor, ValidatorMonitorConfig},
BeaconChainError, NotifyExecutionLayer, ProduceBlockVerification,
};
use crate::{
Expand Down Expand Up @@ -181,6 +181,7 @@ pub struct Builder<T: BeaconChainTypes> {
execution_layer: Option<ExecutionLayer<T::EthSpec>>,
mock_execution_layer: Option<MockExecutionLayer<T::EthSpec>>,
testing_slot_clock: Option<TestingSlotClock>,
validator_monitor_config: Option<ValidatorMonitorConfig>,
runtime: TestRuntime,
log: Logger,
}
Expand Down Expand Up @@ -316,6 +317,7 @@ where
execution_layer: None,
mock_execution_layer: None,
testing_slot_clock: None,
validator_monitor_config: None,
runtime,
log,
}
Expand Down Expand Up @@ -388,6 +390,14 @@ where
self
}

pub fn validator_monitor_config(
mut self,
validator_monitor_config: ValidatorMonitorConfig,
) -> Self {
self.validator_monitor_config = Some(validator_monitor_config);
self
}

/// Purposefully replace the `store_mutator`.
pub fn override_store_mutator(mut self, mutator: BoxedMutator<E, Hot, Cold>) -> Self {
assert!(self.store_mutator.is_some(), "store mutator not set");
Expand Down Expand Up @@ -494,11 +504,13 @@ where
let validator_keypairs = self
.validator_keypairs
.expect("cannot build without validator keypairs");
let chain_config = self.chain_config.unwrap_or_default();
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
.map_err(|e| format!("Unable to read trusted setup file: {}", e))
.unwrap();

let validator_monitor_config = self.validator_monitor_config.unwrap_or_default();

let chain_config = self.chain_config.unwrap_or_default();
let mut builder = BeaconChainBuilder::new(self.eth_spec_instance)
.logger(log.clone())
.custom_spec(spec)
Expand All @@ -518,7 +530,7 @@ where
log.clone(),
5,
)))
.monitor_validators(true, vec![], DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD, log)
.validator_monitor_config(validator_monitor_config)
.trusted_setup(trusted_setup);

builder = if let Some(mutator) = self.initial_mutator {
Expand Down
Loading