mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-02 09:17:39 +00:00
Split BeaconState::genesis
into two functions
This allows us to build a genesis state without inducting all the validators. This will be a signigicant speed up for tests as we can avoid generating keypairs and checking proof-of-possessions.
This commit is contained in:
parent
d140563545
commit
f82c4268e2
@ -117,19 +117,18 @@ pub struct BeaconState {
|
||||
|
||||
impl BeaconState {
|
||||
/// Produce the first state of the Beacon Chain.
|
||||
pub fn genesis(
|
||||
pub fn genesis_without_validators(
|
||||
genesis_time: u64,
|
||||
initial_validator_deposits: Vec<Deposit>,
|
||||
latest_eth1_data: Eth1Data,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<BeaconState, Error> {
|
||||
debug!("Creating genesis state.");
|
||||
debug!("Creating genesis state (without validator processing).");
|
||||
let initial_crosslink = Crosslink {
|
||||
epoch: spec.genesis_epoch,
|
||||
shard_block_root: spec.zero_hash,
|
||||
};
|
||||
|
||||
let mut genesis_state = BeaconState {
|
||||
Ok(BeaconState {
|
||||
/*
|
||||
* Misc
|
||||
*/
|
||||
@ -188,7 +187,19 @@ impl BeaconState {
|
||||
*/
|
||||
cache_index_offset: 0,
|
||||
caches: vec![EpochCache::empty(); CACHED_EPOCHS],
|
||||
};
|
||||
})
|
||||
}
|
||||
/// Produce the first state of the Beacon Chain.
|
||||
pub fn genesis(
|
||||
genesis_time: u64,
|
||||
initial_validator_deposits: Vec<Deposit>,
|
||||
latest_eth1_data: Eth1Data,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<BeaconState, Error> {
|
||||
let mut genesis_state =
|
||||
BeaconState::genesis_without_validators(genesis_time, latest_eth1_data, spec)?;
|
||||
|
||||
trace!("Processing genesis deposits...");
|
||||
|
||||
let deposit_data = initial_validator_deposits
|
||||
.iter()
|
||||
|
Loading…
Reference in New Issue
Block a user