mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +00:00
Add BeaconBlock genesis
This commit is contained in:
38
beacon_chain/genesis/src/beacon_block.rs
Normal file
38
beacon_chain/genesis/src/beacon_block.rs
Normal file
@@ -0,0 +1,38 @@
|
||||
use bls::Signature;
|
||||
use spec::ChainSpec;
|
||||
use types::{BeaconBlock, BeaconBlockBody};
|
||||
|
||||
/// Generate a genesis BeaconBlock.
|
||||
pub fn genesis_beacon_block(spec: &ChainSpec) -> BeaconBlock {
|
||||
BeaconBlock {
|
||||
slot: spec.initial_slot_number,
|
||||
parent_root: spec.zero_hash,
|
||||
state_root: spec.zero_hash,
|
||||
randao_reveal: spec.zero_hash,
|
||||
candidate_pow_receipt_root: spec.zero_hash,
|
||||
signature: Signature::default(),
|
||||
body: BeaconBlockBody {
|
||||
proposer_slashings: vec![],
|
||||
casper_slashings: vec![],
|
||||
attestations: vec![],
|
||||
deposits: vec![],
|
||||
exits: vec![],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// TODO: enhance these tests.
|
||||
// https://github.com/sigp/lighthouse/issues/117
|
||||
|
||||
#[test]
|
||||
fn test_genesis() {
|
||||
let spec = ChainSpec::foundation();
|
||||
|
||||
// This only checks that the function runs without panic.
|
||||
genesis_beacon_block(&spec);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ extern crate validator_induction;
|
||||
extern crate validator_shuffling;
|
||||
|
||||
mod beacon_state;
|
||||
mod beacon_block;
|
||||
|
||||
pub use beacon_state::{genesis_beacon_state, Error as GenesisError};
|
||||
|
||||
pub use crate::beacon_block::genesis_beacon_block;
|
||||
pub use crate::beacon_state::{genesis_beacon_state, Error as GenesisError};
|
||||
|
||||
Reference in New Issue
Block a user