Skip to content

Commit

Permalink
remove debugging lines, fix chache initialization slot
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed May 9, 2022
1 parent e67f07d commit 1854a23
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 29 deletions.
48 changes: 29 additions & 19 deletions consensus/proto_array/src/proto_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,28 +867,38 @@ impl ProtoArray {
correct_justified && correct_finalized
};

if let (Some(unrealized_justified_checkpoint), Some(unrealized_finalized_checkpoint), Some(justified_checkpoint), Some(finalized_checkpoint)) = (
node.unrealized_justified_checkpoint,
node.unrealized_finalized_checkpoint,
node.justified_checkpoint,
node.finalized_checkpoint,
) {
if justified_checkpoint.epoch < self.justified_checkpoint.epoch && finalized_checkpoint.epoch < self.finalized_checkpoint.epoch {
checkpoint_match_predicate(unrealized_justified_checkpoint, unrealized_finalized_checkpoint, )
} else if justified_checkpoint.epoch < self.justified_checkpoint.epoch {
checkpoint_match_predicate(unrealized_justified_checkpoint, finalized_checkpoint, )
} else if finalized_checkpoint.epoch < self.finalized_checkpoint.epoch {
checkpoint_match_predicate(justified_checkpoint, unrealized_finalized_checkpoint, )
} else {
checkpoint_match_predicate(justified_checkpoint, finalized_checkpoint)
}
} else if let (Some(justified_checkpoint), Some(finalized_checkpoint)) =
(node.justified_checkpoint, node.finalized_checkpoint)
if let (
Some(unrealized_justified_checkpoint),
Some(unrealized_finalized_checkpoint),
Some(justified_checkpoint),
Some(finalized_checkpoint),
) = (
node.unrealized_justified_checkpoint,
node.unrealized_finalized_checkpoint,
node.justified_checkpoint,
node.finalized_checkpoint,
) {
if justified_checkpoint.epoch < self.justified_checkpoint.epoch
&& finalized_checkpoint.epoch < self.finalized_checkpoint.epoch
{
checkpoint_match_predicate(justified_checkpoint, finalized_checkpoint)
checkpoint_match_predicate(
unrealized_justified_checkpoint,
unrealized_finalized_checkpoint,
)
} else if justified_checkpoint.epoch < self.justified_checkpoint.epoch {
checkpoint_match_predicate(unrealized_justified_checkpoint, finalized_checkpoint)
} else if finalized_checkpoint.epoch < self.finalized_checkpoint.epoch {
checkpoint_match_predicate(justified_checkpoint, unrealized_finalized_checkpoint)
} else {
false
checkpoint_match_predicate(justified_checkpoint, finalized_checkpoint)
}
} else if let (Some(justified_checkpoint), Some(finalized_checkpoint)) =
(node.justified_checkpoint, node.finalized_checkpoint)
{
checkpoint_match_predicate(justified_checkpoint, finalized_checkpoint)
} else {
false
}
}

/// Return a reverse iterator over the nodes which comprise the chain ending at `block_root`.
Expand Down
7 changes: 6 additions & 1 deletion consensus/types/src/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,9 +1368,14 @@ impl<T: EthSpec> BeaconState<T> {
&mut self,
spec: &ChainSpec,
) -> Result<PreviousParticipationCache, BeaconStateError> {
let next_slot_epoch = self
.slot()
.saturating_add(Slot::new(1))
.epoch(T::slots_per_epoch());

// Check cache if it was initialized in the states current epoch.
if let Some(cache) = self.previous_epoch_participation_cache() {
if cache.initialized_epoch() == self.current_epoch() {
if cache.initialized_epoch() == next_slot_epoch {
return Ok(cache.clone());
}
}
Expand Down
5 changes: 2 additions & 3 deletions lcli/src/parse_ssz.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::fs;
use clap::ArgMatches;
use clap_utils::parse_required;
use serde::Serialize;
use snap::raw::Decoder;
use ssz::Decode;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::str::FromStr;
use snap::raw::Decoder;
use types::*;

enum OutputFormat {
Expand Down Expand Up @@ -44,7 +44,6 @@ pub fn run_parse_ssz<T: EthSpec>(matches: &ArgMatches) -> Result<(), String> {
bytes
};


info!("Using {} spec", T::spec_name());
info!("Type: {:?}", type_str);

Expand Down
1 change: 0 additions & 1 deletion testing/ef_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
ef_tests = []
milagro = ["bls/milagro"]
fake_crypto = ["bls/fake_crypto"]
write_ssz_files = ["beacon_chain/write_ssz_files"]

[dependencies]
bls = { path = "../../crypto/bls", default-features = false }
Expand Down
4 changes: 0 additions & 4 deletions testing/ef_tests/src/cases/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ impl<E: EthSpec> Case for ForkChoiceTest<E> {
return Err(Error::SkippedKnownFailure);
};

if _case_index != 1 {
return Err(Error::SkippedKnownFailure);
}

for step in &self.steps {
match step {
Step::Tick { tick } => tester.set_tick(*tick),
Expand Down
2 changes: 1 addition & 1 deletion testing/ef_tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fn fork_choice_get_head() {
#[test]
fn fork_choice_on_block() {
ForkChoiceHandler::<MinimalEthSpec>::new("on_block").run();
// ForkChoiceHandler::<MainnetEthSpec>::new("on_block").run();
ForkChoiceHandler::<MainnetEthSpec>::new("on_block").run();
}

#[test]
Expand Down

0 comments on commit 1854a23

Please sign in to comment.