Create the fork-choice crate.
- Adds the naive fork choice (longest chain) rule. - Adds basic documentation for the crate.
This commit is contained in:
parent
da1498fc45
commit
8109fad7bf
@ -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",
|
||||
|
@ -1,10 +1,11 @@
|
||||
[package]
|
||||
name = "naive_fork_choice"
|
||||
name = "fork_choice"
|
||||
version = "0.1.0"
|
||||
authors = ["Paul Hauner <paul@paulhauner.com>"]
|
||||
authors = ["Age Manning <Age@AgeManning.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
db = { path = "../../beacon_node/db" }
|
||||
ssz = { path = "../utils/ssz" }
|
||||
types = { path = "../types" }
|
||||
|
0
eth2/fork_choice/src/basic_lmd_ghost.rs
Normal file
0
eth2/fork_choice/src/basic_lmd_ghost.rs
Normal file
24
eth2/fork_choice/src/lib.rs
Normal file
24
eth2/fork_choice/src/lib.rs
Normal file
@ -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;
|
@ -14,7 +14,7 @@ pub enum ForkChoiceError {
|
||||
DBError(String),
|
||||
}
|
||||
|
||||
pub fn naive_fork_choice<T>(
|
||||
pub fn longest_chain<T>(
|
||||
head_block_hashes: &[Hash256],
|
||||
block_store: &Arc<BeaconBlockStore<T>>,
|
||||
) -> Result<Option<usize>, ForkChoiceError>
|
0
eth2/fork_choice/src/optimised_lmd_ghost.rs
Normal file
0
eth2/fork_choice/src/optimised_lmd_ghost.rs
Normal file
0
eth2/fork_choice/src/protolambda_lmd_ghost.rs
Normal file
0
eth2/fork_choice/src/protolambda_lmd_ghost.rs
Normal file
Loading…
Reference in New Issue
Block a user