mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Custody persist fix (#7661)
N/A Persist the epoch -> cgc values. This is to ensure that `ValidatorRegistrations::latest_validator_custody_requirement` always returns a `Some` value post restart assuming the `epoch_validator_custody_requirements` map has been updated in the previous runs.
This commit is contained in:
@@ -163,7 +163,13 @@ impl CustodyContext {
|
||||
validator_custody_count: AtomicU64::new(ssz_context.validator_custody_at_head),
|
||||
current_is_supernode: is_supernode,
|
||||
persisted_is_supernode: ssz_context.persisted_is_supernode,
|
||||
validator_registrations: Default::default(),
|
||||
validator_registrations: RwLock::new(ValidatorRegistrations {
|
||||
validators: Default::default(),
|
||||
epoch_validator_custody_requirements: ssz_context
|
||||
.epoch_validator_custody_requirements
|
||||
.into_iter()
|
||||
.collect(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,8 +269,9 @@ pub struct CustodyCountChanged {
|
||||
/// The custody information that gets persisted across runs.
|
||||
#[derive(Debug, Encode, Decode, Clone)]
|
||||
pub struct CustodyContextSsz {
|
||||
validator_custody_at_head: u64,
|
||||
persisted_is_supernode: bool,
|
||||
pub validator_custody_at_head: u64,
|
||||
pub persisted_is_supernode: bool,
|
||||
pub epoch_validator_custody_requirements: Vec<(Epoch, u64)>,
|
||||
}
|
||||
|
||||
impl From<&CustodyContext> for CustodyContextSsz {
|
||||
@@ -272,6 +279,13 @@ impl From<&CustodyContext> for CustodyContextSsz {
|
||||
CustodyContextSsz {
|
||||
validator_custody_at_head: context.validator_custody_count.load(Ordering::Relaxed),
|
||||
persisted_is_supernode: context.persisted_is_supernode,
|
||||
epoch_validator_custody_requirements: context
|
||||
.validator_registrations
|
||||
.read()
|
||||
.epoch_validator_custody_requirements
|
||||
.iter()
|
||||
.map(|(epoch, count)| (*epoch, *count))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user