diff --git a/Cargo.toml b/Cargo.toml index b2efe55ad..4f453af4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = [ "eth2/attester", "eth2/block_producer", "eth2/genesis", - "eth2/naive_fork_choice", + "eth2/fork_choice", "eth2/types", "eth2/utils/bls", "eth2/utils/boolean-bitfield", diff --git a/eth2/naive_fork_choice/Cargo.toml b/eth2/fork_choice/Cargo.toml similarity index 68% rename from eth2/naive_fork_choice/Cargo.toml rename to eth2/fork_choice/Cargo.toml index 5b3a1b8d2..56ca7f3be 100644 --- a/eth2/naive_fork_choice/Cargo.toml +++ b/eth2/fork_choice/Cargo.toml @@ -1,10 +1,11 @@ [package] -name = "naive_fork_choice" +name = "fork_choice" version = "0.1.0" -authors = ["Paul Hauner "] +authors = ["Age Manning "] edition = "2018" [dependencies] db = { path = "../../beacon_node/db" } ssz = { path = "../utils/ssz" } types = { path = "../types" } + diff --git a/eth2/fork_choice/src/basic_lmd_ghost.rs b/eth2/fork_choice/src/basic_lmd_ghost.rs new file mode 100644 index 000000000..e69de29bb diff --git a/eth2/fork_choice/src/lib.rs b/eth2/fork_choice/src/lib.rs new file mode 100644 index 000000000..2af1cd525 --- /dev/null +++ b/eth2/fork_choice/src/lib.rs @@ -0,0 +1,24 @@ +//! This crate stores the various implementations of fork-choice rules that can be used for the +//! beacon blockchain. +//! +//! There are four implementations. One is the naive longest chain rule (primarily for testing +//! purposes). The other three are proposed implementations of the LMD-GHOST fork-choice rule with various forms of optimisation. +//! +//! The current implementations are: +//! - [`longest-chain`]: Simplistic longest-chain fork choice - primarily for testing, **not for +//! production**. +//! - [`basic_lmd_ghost`]: This is a simple and very inefficient implementation given in the ethereum 2.0 +//! specifications (https://github.com/ethereum/eth2.0-specs/blob/v0.1/specs/core/0_beacon-chain.md#get_block_root). +//! - [`optimised_lmd_ghost`]: This is an optimised version of the naive implementation as proposed +//! by Vitalik. The reference implementation can be found at: https://github.com/ethereum/research/blob/master/ghost/ghost.py +//! - [`protolambda_lmd_ghost`]: Another optimised version of LMD-GHOST designed by @protolambda. +//! The go implementation can be found here: https://github.com/protolambda/lmd-ghost. +//! +//! [`basic_lmd_ghost`]: struct.BasicLmdGhost.html +//! [`optimised_lmd_ghost`]: struct.OptimisedLmdGhost.html +//! [`protolambda_lmd_ghost`]: struct.ProtolambdaLmdGhost.html + +pub mod basic_lmd_ghost; +pub mod longest_chain; +pub mod optimised_lmd_ghost; +pub mod protolambda_lmd_ghost; diff --git a/eth2/naive_fork_choice/src/lib.rs b/eth2/fork_choice/src/longest_chain.rs similarity index 98% rename from eth2/naive_fork_choice/src/lib.rs rename to eth2/fork_choice/src/longest_chain.rs index 9a7578607..478bc8ac1 100644 --- a/eth2/naive_fork_choice/src/lib.rs +++ b/eth2/fork_choice/src/longest_chain.rs @@ -14,7 +14,7 @@ pub enum ForkChoiceError { DBError(String), } -pub fn naive_fork_choice( +pub fn longest_chain( head_block_hashes: &[Hash256], block_store: &Arc>, ) -> Result, ForkChoiceError> diff --git a/eth2/fork_choice/src/optimised_lmd_ghost.rs b/eth2/fork_choice/src/optimised_lmd_ghost.rs new file mode 100644 index 000000000..e69de29bb diff --git a/eth2/fork_choice/src/protolambda_lmd_ghost.rs b/eth2/fork_choice/src/protolambda_lmd_ghost.rs new file mode 100644 index 000000000..e69de29bb