def test_get_genesis_block(): startup_state_root = b'\x10' * 32 genesis_slot = 10 genesis_block = get_genesis_block(startup_state_root, genesis_slot, BeaconBlock) assert genesis_block.slot == genesis_slot assert genesis_block.parent_root == ZERO_HASH32 assert genesis_block.state_root == startup_state_root assert genesis_block.randao_reveal == ZERO_HASH32 assert genesis_block.eth1_data == Eth1Data.create_empty_data() assert genesis_block.signature == EMPTY_SIGNATURE assert genesis_block.body.is_empty
def create_mock_genesis( num_validators: int, config: BeaconConfig, keymap: Dict[BLSPubkey, int], genesis_block_class: Type[BaseBeaconBlock], genesis_time: Timestamp = 0) -> Tuple[BeaconState, BaseBeaconBlock]: latest_eth1_data = Eth1Data.create_empty_data() assert num_validators <= len(keymap) pubkeys = list(keymap)[:num_validators] initial_validator_deposits = create_mock_initial_validator_deposits( num_validators=num_validators, config=config, pubkeys=pubkeys, keymap=keymap, ) state = get_initial_beacon_state( initial_validator_deposits=initial_validator_deposits, genesis_time=genesis_time, latest_eth1_data=latest_eth1_data, genesis_slot=config.GENESIS_SLOT, genesis_epoch=config.GENESIS_EPOCH, genesis_fork_version=config.GENESIS_FORK_VERSION, genesis_start_shard=config.GENESIS_START_SHARD, shard_count=config.SHARD_COUNT, seed_lookahead=config.SEED_LOOKAHEAD, latest_block_roots_length=config.LATEST_BLOCK_ROOTS_LENGTH, latest_index_roots_length=config.LATEST_INDEX_ROOTS_LENGTH, epoch_length=config.EPOCH_LENGTH, max_deposit_amount=config.MAX_DEPOSIT_AMOUNT, latest_penalized_exit_length=config.LATEST_PENALIZED_EXIT_LENGTH, latest_randao_mixes_length=config.LATEST_RANDAO_MIXES_LENGTH, entry_exit_delay=config.ENTRY_EXIT_DELAY, ) block = get_genesis_block( startup_state_root=state.root, genesis_slot=config.GENESIS_SLOT, block_class=genesis_block_class, ) assert len(state.validator_registry) == num_validators return state, block
def genesis_block(genesis_state, genesis_slot): return get_genesis_block( genesis_state.root, genesis_slot, SerenityBeaconBlock, )