package
5.2.0
Repository: https://github.com/prysmaticlabs/prysm.git
Documentation: pkg.go.dev

# Functions

AddValidatorToRegistry updates the beacon state with validator information def add_validator_to_registry(state: BeaconState, pubkey: BLSPubkey, withdrawal_credentials: Bytes32, amount: uint64) -> None: index = get_index_for_new_validator(state) validator = get_validator_from_deposit(pubkey, withdrawal_credentials, amount) # [Modified in Electra:EIP7251] set_or_append_list(state.validators, index, validator) set_or_append_list(state.balances, index, amount) set_or_append_list(state.previous_epoch_participation, index, ParticipationFlags(0b0000_0000)) set_or_append_list(state.current_epoch_participation, index, ParticipationFlags(0b0000_0000)) set_or_append_list(state.inactivity_scores, index, uint64(0)).
ApplyDeposit adds the incoming deposit as a pending deposit on the state Spec pseudocode definition: def apply_deposit(state: BeaconState, pubkey: BLSPubkey, withdrawal_credentials: Bytes32, amount: uint64, signature: BLSSignature) -> None: validator_pubkeys = [v.pubkey for v in state.validators] if pubkey not in validator_pubkeys: # Verify the deposit signature (proof of possession) which is not checked by the deposit contract if is_valid_deposit_signature(pubkey, withdrawal_credentials, amount, signature): add_validator_to_registry(state, pubkey, withdrawal_credentials, Gwei(0)) # [Modified in Electra:EIP7251] # [New in Electra:EIP7251] state.pending_deposits.append(PendingDeposit( pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, amount=amount, signature=signature, slot=GENESIS_SLOT, # Use GENESIS_SLOT to distinguish from a pending deposit request )) else: # Increase balance by deposit amount # [Modified in Electra:EIP7251] state.pending_deposits.append(PendingDeposit( pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, amount=amount, signature=signature, slot=GENESIS_SLOT # Use GENESIS_SLOT to distinguish from a pending deposit request )).
ApplyPendingDeposit implements the spec definition below.
ComputeConsolidationEpochAndUpdateChurn fulfills the consensus spec definition below.
GetValidatorFromDeposit gets a new validator object with provided parameters def get_validator_from_deposit(pubkey: BLSPubkey, withdrawal_credentials: Bytes32, amount: uint64) -> Validator: validator = Validator( pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, effective_balance=Gwei(0), slashed=False, activation_eligibility_epoch=FAR_FUTURE_EPOCH, activation_epoch=FAR_FUTURE_EPOCH, exit_epoch=FAR_FUTURE_EPOCH, withdrawable_epoch=FAR_FUTURE_EPOCH, ) # [Modified in Electra:EIP7251] max_effective_balance = get_max_effective_balance(validator) validator.effective_balance = min(amount - amount % EFFECTIVE_BALANCE_INCREMENT, max_effective_balance) return validator.
IsValidDepositSignature returns whether deposit_data is valid def is_valid_deposit_signature(pubkey: BLSPubkey, withdrawal_credentials: Bytes32, amount: uint64, signature: BLSSignature) -> bool: deposit_message = DepositMessage( pubkey=pubkey, withdrawal_credentials=withdrawal_credentials, amount=amount, ) domain = compute_domain(DOMAIN_DEPOSIT) # Fork-agnostic domain since deposits are valid across forks signing_root = compute_signing_root(deposit_message, domain) return bls.Verify(pubkey, signing_root, signature).
IsValidSwitchToCompoundingRequest returns true if the given consolidation request is valid for switching to compounding.
ProcessConsolidationRequests implements the spec definition below.
ProcessDeposit takes in a deposit object and inserts it into the registry as a new validator or balance change.
ProcessDepositRequests is a function as part of electra to process execution layer deposits.
ProcessDeposits is one of the operations performed on each processed beacon block to verify queued validators from the Ethereum 1.0 Deposit Contract into the beacon chain.
ProcessEffectiveBalanceUpdates processes effective balance updates during epoch processing.
ProcessEpoch describes the per epoch operations that are performed on the beacon state.
ProcessPendingConsolidations implements the spec definition below.
ProcessPendingDeposits implements the spec definition below.
ProcessRegistryUpdates processes all validators eligible for the activation queue, all validators which should be ejected, and all validators which are eligible for activation from the queue.
ProcessWithdrawalRequests processes the validator withdrawals from the provided execution payload into the beacon state triggered by the execution layer.
QueueEntireBalanceAndResetValidator queues the entire balance and resets the validator.
QueueExcessActiveBalance queues validators with balances above the min activation balance and adds to pending deposit.
SwitchToCompoundingValidator Spec definition: def switch_to_compounding_validator(state: BeaconState, index: ValidatorIndex) -> None: validator = state.validators[index] validator.withdrawal_credentials = COMPOUNDING_WITHDRAWAL_PREFIX + validator.withdrawal_credentials[1:] queue_excess_active_balance(state, index).
UpgradeToElectra updates inputs a generic state to return the version Electra state.
VerifyBlockDepositLength Spec definition: # [Modified in Electra:EIP6110] # Disable former deposit mechanism once all prior deposits are processed eth1_deposit_index_limit = min(state.eth1_data.deposit_count, state.deposit_requests_start_index) if state.eth1_deposit_index < eth1_deposit_index_limit: assert len(body.deposits) == min(MAX_DEPOSITS, eth1_deposit_index_limit - state.eth1_deposit_index) else: assert len(body.deposits) == 0.

# Variables

Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.
Re-exports for methods that haven't changed in Electra.