Merge branch 'master' into blop-pool

This commit is contained in:
Paul Hauner
2019-03-29 17:49:33 +11:00
76 changed files with 4435 additions and 787 deletions

View File

@@ -37,6 +37,19 @@ impl BeaconBlockHeader {
pub fn canonical_root(&self) -> Hash256 {
Hash256::from_slice(&self.hash_tree_root()[..])
}
/// Given a `body`, consumes `self` and returns a complete `BeaconBlock`.
///
/// Spec v0.5.0
pub fn into_block(self, body: BeaconBlockBody) -> BeaconBlock {
BeaconBlock {
slot: self.slot,
previous_block_root: self.previous_block_root,
state_root: self.state_root,
body,
signature: self.signature,
}
}
}
#[cfg(test)]

View File

@@ -120,7 +120,7 @@ pub struct ChainSpec {
*
*/
pub boot_nodes: Vec<Multiaddr>,
pub network_id: u8,
pub chain_id: u8,
}
impl ChainSpec {
@@ -257,7 +257,7 @@ impl ChainSpec {
* Boot nodes
*/
boot_nodes: vec![],
network_id: 1, // foundation network id
chain_id: 1, // foundation chain id
}
}
@@ -274,7 +274,7 @@ impl ChainSpec {
Self {
boot_nodes,
network_id: 2, // lighthouse testnet network id
chain_id: 2, // lighthouse testnet chain id
..ChainSpec::few_validators()
}
}

View File

@@ -85,6 +85,6 @@ pub type AttesterMap = HashMap<(u64, u64), Vec<usize>>;
pub type ProposerMap = HashMap<u64, usize>;
pub use bls::{AggregatePublicKey, AggregateSignature, Keypair, PublicKey, SecretKey, Signature};
pub use libp2p::floodsub::{Topic, TopicBuilder};
pub use libp2p::floodsub::{Topic, TopicBuilder, TopicHash};
pub use libp2p::multiaddr;
pub use libp2p::Multiaddr;

View File

@@ -23,6 +23,7 @@ pub fn keypairs_path() -> PathBuf {
/// Builds a beacon state to be used for testing purposes.
///
/// This struct should **never be used for production purposes.**
#[derive(Clone)]
pub struct TestingBeaconStateBuilder {
state: BeaconState,
keypairs: Vec<Keypair>,
@@ -119,8 +120,10 @@ impl TestingBeaconStateBuilder {
})
.collect();
let genesis_time = 1553753928; // arbitrary
let mut state = BeaconState::genesis(
0,
genesis_time,
Eth1Data {
deposit_root: Hash256::zero(),
block_hash: Hash256::zero(),