def from_genesis( cls, base_db: AtomicDatabaseAPI, genesis_state: BeaconState, genesis_block: BaseBeaconBlock, genesis_config: Eth2GenesisConfig, ) -> "BaseBeaconChain": """ Initialize the ``BeaconChain`` from a genesis state and block. """ sm_class = cls.get_state_machine_class_for_block_slot( genesis_block.slot) if type(genesis_block) != sm_class.block_class: raise BlockClassError( "Given genesis block class: {}, StateMachine.block_class: {}". format(type(genesis_block), sm_class.block_class)) chaindb = cls.get_chaindb_class()(db=base_db, genesis_config=genesis_config) chaindb.persist_state(genesis_state) genesis_scoring_class = sm_class.get_fork_choice_scoring_class() genesis_score_class = genesis_scoring_class.get_score_class() genesis_score = genesis_score_class.from_genesis( genesis_state, genesis_block) genesis_scoring = ConstantScoring(genesis_score) chaindb.persist_block(genesis_block, genesis_block.__class__, genesis_scoring) return cls(base_db, genesis_config)
def from_genesis(cls, base_db: BaseAtomicDB, genesis_state: BeaconState, genesis_block: BaseBeaconBlock) -> 'BaseBeaconChain': """ Initialize the ``BeaconChain`` from a genesis state. """ sm_class = cls.get_state_machine_class_for_block_slot( genesis_block.slot) if type(genesis_block) != sm_class.block_class: raise BlockClassError( "Given genesis block class: {}, StateMachine.block_class: {}". format(type(genesis_block), sm_class.block_class)) chaindb = cls.get_chaindb_class()(db=base_db) chaindb.persist_state(genesis_state) return cls._from_genesis_block(base_db, genesis_block)
def from_genesis( cls, base_db: AtomicDatabaseAPI, genesis_state: BeaconState, genesis_block: BaseBeaconBlock, genesis_config: Eth2GenesisConfig, ) -> "BaseBeaconChain": """ Initialize the ``BeaconChain`` from a genesis state. """ sm_class = cls.get_state_machine_class_for_block_slot( genesis_block.slot) if type(genesis_block) != sm_class.block_class: raise BlockClassError( "Given genesis block class: {}, StateMachine.block_class: {}". format(type(genesis_block), sm_class.block_class)) chaindb = cls.get_chaindb_class()(db=base_db, genesis_config=genesis_config) chaindb.persist_state(genesis_state) attestation_pool = AttestationPool() return cls._from_genesis_block(base_db, attestation_pool, genesis_block, genesis_config)