mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Add OptimizedLMDGhost fork choice rule and tests
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
extern crate beacon_chain;
|
||||
extern crate bls;
|
||||
extern crate db;
|
||||
//extern crate env_logger; // for debugging
|
||||
// extern crate env_logger; // for debugging
|
||||
extern crate fork_choice;
|
||||
extern crate hex;
|
||||
extern crate log;
|
||||
@@ -15,8 +15,8 @@ pub use beacon_chain::BeaconChain;
|
||||
use bls::Signature;
|
||||
use db::stores::{BeaconBlockStore, BeaconStateStore};
|
||||
use db::MemoryDB;
|
||||
//use env_logger::{Builder, Env};
|
||||
use fork_choice::{BitwiseLMDGhost, ForkChoice, ForkChoiceAlgorithm, LongestChain, SlowLMDGhost};
|
||||
// use env_logger::{Builder, Env};
|
||||
use fork_choice::{BitwiseLMDGhost, OptimizedLMDGhost, ForkChoice, ForkChoiceAlgorithm, LongestChain, SlowLMDGhost};
|
||||
use ssz::ssz_encode;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
@@ -27,6 +27,18 @@ use yaml_rust::yaml;
|
||||
|
||||
// Note: We Assume the block Id's are hex-encoded.
|
||||
|
||||
#[test]
|
||||
fn test_optimized_lmd_ghost() {
|
||||
// set up logging
|
||||
// Builder::from_env(Env::default().default_filter_or("trace")).init();
|
||||
|
||||
test_yaml_vectors(
|
||||
ForkChoiceAlgorithm::OptimizedLMDGhost,
|
||||
"tests/lmd_ghost_test_vectors.yaml",
|
||||
100,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bitwise_lmd_ghost() {
|
||||
// set up logging
|
||||
@@ -212,6 +224,10 @@ fn setup_inital_state(
|
||||
|
||||
// the fork choice instantiation
|
||||
let fork_choice: Box<ForkChoice> = match fork_choice_algo {
|
||||
ForkChoiceAlgorithm::OptimizedLMDGhost => Box::new(OptimizedLMDGhost::new(
|
||||
block_store.clone(),
|
||||
state_store.clone(),
|
||||
)),
|
||||
ForkChoiceAlgorithm::BitwiseLMDGhost => Box::new(BitwiseLMDGhost::new(
|
||||
block_store.clone(),
|
||||
state_store.clone(),
|
||||
|
||||
Reference in New Issue
Block a user