Add and update logs

This commit is contained in:
Paul Hauner
2019-02-16 15:08:33 +11:00
parent 3b92b69028
commit b0513b1ec1
6 changed files with 59 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
use log::debug;
use log::{debug, trace};
use std::collections::HashMap;
use types::{beacon_state::BeaconStateError, BeaconState, ChainSpec, Epoch, Slot};
@@ -42,7 +42,7 @@ impl CachedBeaconState {
let mut attestation_duties: Vec<AttestationDutyMap> = Vec::with_capacity(3);
if CACHE_PREVIOUS {
debug!("CachedBeaconState::from_beacon_state: building previous epoch cache.");
debug!("from_beacon_state: building previous epoch cache.");
let cache = build_epoch_cache(&state, previous_epoch, &spec)?;
committees.push(cache.committees);
attestation_duties.push(cache.attestation_duty_map);
@@ -51,7 +51,7 @@ impl CachedBeaconState {
attestation_duties.push(HashMap::new());
}
if CACHE_CURRENT {
debug!("CachedBeaconState::from_beacon_state: building current epoch cache.");
debug!("from_beacon_state: building current epoch cache.");
let cache = build_epoch_cache(&state, current_epoch, &spec)?;
committees.push(cache.committees);
attestation_duties.push(cache.attestation_duty_map);
@@ -60,7 +60,7 @@ impl CachedBeaconState {
attestation_duties.push(HashMap::new());
}
if CACHE_NEXT {
debug!("CachedBeaconState::from_beacon_state: building next epoch cache.");
debug!("from_beacon_state: building next epoch cache.");
let cache = build_epoch_cache(&state, next_epoch, &spec)?;
committees.push(cache.committees);
attestation_duties.push(cache.attestation_duty_map);
@@ -81,6 +81,7 @@ impl CachedBeaconState {
}
fn slot_to_cache_index(&self, slot: Slot) -> Option<usize> {
trace!("slot_to_cache_index: cache lookup");
match slot.epoch(self.spec.epoch_length) {
epoch if (epoch == self.previous_epoch) & CACHE_PREVIOUS => Some(0),
epoch if (epoch == self.current_epoch) & CACHE_CURRENT => Some(1),

View File

@@ -128,7 +128,18 @@ impl BeaconChainHarness {
pub fn increment_beacon_chain_slot(&mut self) -> Slot {
let slot = self.beacon_chain.present_slot() + 1;
debug!("Incrementing BeaconChain slot to {}.", slot);
let nth_slot = slot
- slot
.epoch(self.spec.epoch_length)
.start_slot(self.spec.epoch_length);
let nth_epoch = slot.epoch(self.spec.epoch_length) - self.spec.genesis_epoch;
debug!(
"Advancing BeaconChain to slot {}, epoch {} (epoch height: {}, slot {} in epoch.).",
slot,
slot.epoch(self.spec.epoch_length),
nth_epoch,
nth_slot
);
self.beacon_chain.slot_clock.set_slot(slot.as_u64());
self.beacon_chain.advance_state(slot).unwrap();

View File

@@ -33,7 +33,7 @@ fn it_can_produce_past_first_epoch_boundary() {
for i in 0..blocks {
harness.advance_chain_with_block();
debug!("Produced block {}/{}.", i, blocks);
debug!("Produced block {}/{}.", i + 1, blocks);
}
let dump = harness.chain_dump().expect("Chain dump failed.");