mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-04 18:14:30 +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 {
|
impl BeaconState {
|
||||||
/// Produce the first state of the Beacon Chain.
|
/// Produce the first state of the Beacon Chain.
|
||||||
pub fn genesis(
|
pub fn genesis_without_validators(
|
||||||
genesis_time: u64,
|
genesis_time: u64,
|
||||||
initial_validator_deposits: Vec<Deposit>,
|
|
||||||
latest_eth1_data: Eth1Data,
|
latest_eth1_data: Eth1Data,
|
||||||
spec: &ChainSpec,
|
spec: &ChainSpec,
|
||||||
) -> Result<BeaconState, Error> {
|
) -> Result<BeaconState, Error> {
|
||||||
debug!("Creating genesis state.");
|
debug!("Creating genesis state (without validator processing).");
|
||||||
let initial_crosslink = Crosslink {
|
let initial_crosslink = Crosslink {
|
||||||
epoch: spec.genesis_epoch,
|
epoch: spec.genesis_epoch,
|
||||||
shard_block_root: spec.zero_hash,
|
shard_block_root: spec.zero_hash,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut genesis_state = BeaconState {
|
Ok(BeaconState {
|
||||||
/*
|
/*
|
||||||
* Misc
|
* Misc
|
||||||
*/
|
*/
|
||||||
@ -188,7 +187,19 @@ impl BeaconState {
|
|||||||
*/
|
*/
|
||||||
cache_index_offset: 0,
|
cache_index_offset: 0,
|
||||||
caches: vec![EpochCache::empty(); CACHED_EPOCHS],
|
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
|
let deposit_data = initial_validator_deposits
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user