def get_block_root(latest_block_roots: Sequence[Hash32], current_slot: SlotNumber, slot: SlotNumber) -> Hash32: """ Returns the block root at a recent ``slot``. """ slot_relative_position = SlotNumber(current_slot - len(latest_block_roots)) return _get_element_from_recent_list( latest_block_roots, slot, slot_relative_position, )
def get_pending_validator(cls, pubkey: BLSPubkey, withdrawal_credentials: Hash32, randao_commitment: Hash32, latest_status_change_slot: SlotNumber, custody_commitment: Hash32) -> 'ValidatorRecord': """ Return a new pending ``ValidatorRecord`` with the given fields. """ return cls( pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, randao_commitment=randao_commitment, randao_layers=0, status=ValidatorStatusCode.PENDING_ACTIVATION, latest_status_change_slot=latest_status_change_slot, exit_count=0, custody_commitment=custody_commitment, latest_custody_reseed_slot=SlotNumber(0), penultimate_custody_reseed_slot=SlotNumber(0), )
def create_pending_validator( cls, pubkey: BLSPubkey, withdrawal_credentials: Hash32, randao_commitment: Hash32, custody_commitment: Hash32) -> 'ValidatorRecord': """ Return a new pending ``ValidatorRecord`` with the given fields. """ return cls( pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, randao_commitment=randao_commitment, randao_layers=0, activation_slot=FAR_FUTURE_SLOT, exit_slot=FAR_FUTURE_SLOT, withdrawal_slot=FAR_FUTURE_SLOT, penalized_slot=FAR_FUTURE_SLOT, exit_count=0, status_flags=0, custody_commitment=custody_commitment, latest_custody_reseed_slot=SlotNumber(0), penultimate_custody_reseed_slot=SlotNumber(0), )
def _get_shard_committees_at_slot( state_slot: SlotNumber, shard_committees_at_slots: Sequence[Sequence[ShardCommittee]], slot: SlotNumber, epoch_length: int) -> Iterable[ShardCommittee]: if len(shard_committees_at_slots) != epoch_length * 2: raise ValueError( "Length of shard_committees_at_slots != epoch_length * 2" "\texpected: %s, found: %s" % (epoch_length * 2, len(shard_committees_at_slots))) slot_relative_position = SlotNumber(state_slot - epoch_length) yield from _get_element_from_recent_list( shard_committees_at_slots, slot, slot_relative_position, )
from eth.beacon.typing import ( BLSSignature, SlotNumber, ) # # shuffle function # # The size of 3 bytes in integer # sample_range = 2 ** (3 * 8) = 2 ** 24 = 16777216 # sample_range = 16777216 # Entropy is consumed from the seed in 3-byte (24 bit) chunks. RAND_BYTES = 3 # The highest possible result of the RNG. RAND_MAX = 2**(RAND_BYTES * 8) - 1 EMPTY_SIGNATURE = BLSSignature((0, 0)) GWEI_PER_ETH = 10**9 FAR_FUTURE_SLOT = SlotNumber(2**64 - 1)
TARGET_COMMITTEE_SIZE=2**7, # (= 128) validators EJECTION_BALANCE=Ether(2**4), # (= 16) ETH MAX_BALANCE_CHURN_QUOTIENT=2**5, # (= 32) BEACON_CHAIN_SHARD_NUMBER=ShardNumber(2**64 - 1), MAX_CASPER_VOTES=2**10, # (= 1,024) votes LATEST_BLOCK_ROOTS_LENGTH=2**13, # (= 8,192) block roots LATEST_RANDAO_MIXES_LENGTH=2**13, # (= 8,192) randao mixes LATEST_PENALIZED_EXIT_LENGTH=2**13, # (= 8,192) randao mixes # Deposit contract DEPOSIT_CONTRACT_ADDRESS=ZERO_ADDRESS, # TBD DEPOSIT_CONTRACT_TREE_DEPTH=2**5, # (= 32) MIN_DEPOSIT=Ether(2**0), # (= 1) ETH MAX_DEPOSIT=Ether(2**5), # (= 32) ETH # Initial values GENESIS_FORK_VERSION=0, GENESIS_SLOT=SlotNumber(0), BLS_WITHDRAWAL_PREFIX_BYTE=b'\x00', # Time parameters SLOT_DURATION=Second(6), # seconds MIN_ATTESTATION_INCLUSION_DELAY=2**2, # (= 4) slots EPOCH_LENGTH=2**6, # (= 64) slots SEED_LOOKAHEAD=2**6, # (= 64) slots ENTRY_EXIT_DELAY=2**8, # (= 256) slots POW_RECEIPT_ROOT_VOTING_PERIOD=2**10, # (= 1,024) slots MIN_VALIDATOR_WITHDRAWAL_TIME=2**14, # (= 16,384) slots # Reward and penalty quotients BASE_REWARD_QUOTIENT=2**10, # (= 1,024) WHISTLEBLOWER_REWARD_QUOTIENT=2**9, # (= 512) INCLUDER_REWARD_QUOTIENT=2**3, # (= 8) INACTIVITY_PENALTY_QUOTIENT=2**24, # (= 16,777,216) # Max operations per block
TARGET_COMMITTEE_SIZE=2**7, # (= 128) validators EJECTION_BALANCE=Ether(2**4), # (= 16) ETH MAX_BALANCE_CHURN_QUOTIENT=2**5, # (= 32) BEACON_CHAIN_SHARD_NUMBER=ShardNumber(2**64 - 1), BLS_WITHDRAWAL_PREFIX_BYTE=b'\x00', MAX_CASPER_VOTES=2**10, # (= 1,024) votes LATEST_BLOCK_ROOTS_LENGTH=2**13, # (= 8,192) block roots LATEST_RANDAO_MIXES_LENGTH=2**13, # (= 8,192) randao mixes # Deposit contract DEPOSIT_CONTRACT_ADDRESS=ZERO_ADDRESS, # TBD DEPOSIT_CONTRACT_TREE_DEPTH=2**5, # (= 32) MIN_DEPOSIT=Ether(2**0), # (= 1) ETH MAX_DEPOSIT=Ether(2**5), # (= 32) ETH # Initial values INITIAL_FORK_VERSION=0, INITIAL_SLOT_NUMBER=SlotNumber(0), # Time parameters SLOT_DURATION=Second(6), # seconds MIN_ATTESTATION_INCLUSION_DELAY=2**2, # (= 4) slots EPOCH_LENGTH=2**6, # (= 64) slots POW_RECEIPT_ROOT_VOTING_PERIOD=2**10, # (= 1,024) slots SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD=2**17, # (= 131,072) slots COLLECTIVE_PENALTY_CALCULATION_PERIOD=2**20, # (= 1,048,576) slots ZERO_BALANCE_VALIDATOR_TTL=2**22, # (= 4,194,304) slots # Reward and penalty quotients BASE_REWARD_QUOTIENT=2**10, # (= 1,024) WHISTLEBLOWER_REWARD_QUOTIENT=2**9, # (= 512) INCLUDER_REWARD_QUOTIENT=2**3, # (= 8) INACTIVITY_PENALTY_QUOTIENT=2**24, # (= 16,777,216) # Max operations per block MAX_PROPOSER_SLASHINGS=2**4, # (= 16)