Tidy up and add some logs
This commit is contained in:
parent
e1239a1ecc
commit
c1b3d1b63e
@ -39,7 +39,6 @@ impl AttestationAggregator {
|
|||||||
free_attestation: &FreeAttestation,
|
free_attestation: &FreeAttestation,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) -> Result<ProcessOutcome, ProcessError> {
|
) -> Result<ProcessOutcome, ProcessError> {
|
||||||
// let validator_index = free_attestation.validator_index as usize;
|
|
||||||
let (slot, shard, committee_index) = state.attestation_slot_and_shard_for_validator(
|
let (slot, shard, committee_index) = state.attestation_slot_and_shard_for_validator(
|
||||||
free_attestation.validator_index as usize,
|
free_attestation.validator_index as usize,
|
||||||
spec,
|
spec,
|
||||||
|
@ -40,7 +40,10 @@ macro_rules! safe_sub_assign {
|
|||||||
|
|
||||||
impl BeaconState {
|
impl BeaconState {
|
||||||
pub fn per_epoch_processing(&mut self, spec: &ChainSpec) -> Result<(), Error> {
|
pub fn per_epoch_processing(&mut self, spec: &ChainSpec) -> Result<(), Error> {
|
||||||
debug!("Starting per-epoch processing...");
|
debug!(
|
||||||
|
"Starting per-epoch processing on epoch {}...",
|
||||||
|
self.current_epoch(spec)
|
||||||
|
);
|
||||||
/*
|
/*
|
||||||
* All Validators
|
* All Validators
|
||||||
*/
|
*/
|
||||||
@ -60,6 +63,11 @@ impl BeaconState {
|
|||||||
.filter(|a| a.data.slot / spec.epoch_length == self.current_epoch(spec))
|
.filter(|a| a.data.slot / spec.epoch_length == self.current_epoch(spec))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Current epoch attestations: {}",
|
||||||
|
current_epoch_attestations.len()
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validators attesting during the current epoch.
|
* Validators attesting during the current epoch.
|
||||||
*/
|
*/
|
||||||
@ -90,6 +98,11 @@ impl BeaconState {
|
|||||||
let current_epoch_boundary_attesting_balance =
|
let current_epoch_boundary_attesting_balance =
|
||||||
self.get_effective_balances(¤t_epoch_boundary_attester_indices[..], spec);
|
self.get_effective_balances(¤t_epoch_boundary_attester_indices[..], spec);
|
||||||
|
|
||||||
|
debug!(
|
||||||
|
"Current epoch boundary attesters: {}",
|
||||||
|
current_epoch_boundary_attester_indices.len()
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validators attesting during the previous epoch
|
* Validators attesting during the previous epoch
|
||||||
*/
|
*/
|
||||||
@ -106,7 +119,10 @@ impl BeaconState {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
debug!("previous epoch attestations: {}", previous_epoch_attestations.len());
|
debug!(
|
||||||
|
"previous epoch attestations: {}",
|
||||||
|
previous_epoch_attestations.len()
|
||||||
|
);
|
||||||
|
|
||||||
let previous_epoch_attester_indices =
|
let previous_epoch_attester_indices =
|
||||||
self.get_attestation_participants_union(&previous_epoch_attestations[..], spec)?;
|
self.get_attestation_participants_union(&previous_epoch_attestations[..], spec)?;
|
||||||
@ -209,6 +225,7 @@ impl BeaconState {
|
|||||||
// TODO: check saturating_sub is correct.
|
// TODO: check saturating_sub is correct.
|
||||||
self.justification_bitfield |= 2;
|
self.justification_bitfield |= 2;
|
||||||
self.justified_slot = self.slot.saturating_sub(2 * spec.epoch_length);
|
self.justified_slot = self.slot.saturating_sub(2 * spec.epoch_length);
|
||||||
|
debug!(">= 2/3 voted for previous epoch boundary");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If >= 2/3 of validators voted for the current epoch boundary
|
// If >= 2/3 of validators voted for the current epoch boundary
|
||||||
@ -216,6 +233,7 @@ impl BeaconState {
|
|||||||
// TODO: check saturating_sub is correct.
|
// TODO: check saturating_sub is correct.
|
||||||
self.justification_bitfield |= 1;
|
self.justification_bitfield |= 1;
|
||||||
self.justified_slot = self.slot.saturating_sub(1 * spec.epoch_length);
|
self.justified_slot = self.slot.saturating_sub(1 * spec.epoch_length);
|
||||||
|
debug!(">= 2/3 voted for current epoch boundary");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.previous_justified_slot == self.slot.saturating_sub(2 * spec.epoch_length))
|
if (self.previous_justified_slot == self.slot.saturating_sub(2 * spec.epoch_length))
|
||||||
@ -310,7 +328,7 @@ impl BeaconState {
|
|||||||
let previous_epoch_attester_indices_hashset: HashSet<usize> =
|
let previous_epoch_attester_indices_hashset: HashSet<usize> =
|
||||||
HashSet::from_iter(previous_epoch_attester_indices.iter().map(|i| *i));
|
HashSet::from_iter(previous_epoch_attester_indices.iter().map(|i| *i));
|
||||||
|
|
||||||
debug!("previous epoch justified attesters: {}, previous epoch boundary attesters: {}, previous epoch head attesters: {}, previous epoch attesters: {}", previous_epoch_justified_attester_indices.len(), previous_epoch_boundary_attester_indices.len(), previous_epoch_head_attestations.len(), previous_epoch_attester_indices.len());
|
debug!("previous epoch justified attesters: {}, previous epoch boundary attesters: {}, previous epoch head attesters: {}, previous epoch attesters: {}", previous_epoch_justified_attester_indices.len(), previous_epoch_boundary_attester_indices.len(), previous_epoch_head_attester_indices.len(), previous_epoch_attester_indices.len());
|
||||||
|
|
||||||
debug!("{} epochs since finality.", epochs_since_finality);
|
debug!("{} epochs since finality.", epochs_since_finality);
|
||||||
|
|
||||||
@ -396,7 +414,7 @@ impl BeaconState {
|
|||||||
/*
|
/*
|
||||||
* Attestation inclusion
|
* Attestation inclusion
|
||||||
*/
|
*/
|
||||||
for index in previous_epoch_attester_indices_hashset {
|
for &index in &previous_epoch_attester_indices_hashset {
|
||||||
let inclusion_slot =
|
let inclusion_slot =
|
||||||
self.inclusion_slot(&previous_epoch_attestations[..], index, spec)?;
|
self.inclusion_slot(&previous_epoch_attestations[..], index, spec)?;
|
||||||
let proposer_index = self
|
let proposer_index = self
|
||||||
@ -409,7 +427,10 @@ impl BeaconState {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("Processed validator attestation inclusdion rewards.");
|
debug!(
|
||||||
|
"Previous epoch attesters: {}.",
|
||||||
|
previous_epoch_attester_indices_hashset.len()
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Crosslinks
|
* Crosslinks
|
||||||
@ -513,6 +534,8 @@ impl BeaconState {
|
|||||||
.cloned()
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
debug!("Epoch transition complete.");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user