-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Electra core transition operations #14001
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d53af19
adding electra operations
james-prysm 8b7c706
Merge branch 'develop' into electra-core-transition
james-prysm 4af60eb
Merge branch 'develop' into electra-core-transition
james-prysm 8724745
enabling spec tests
james-prysm 44ed1b7
adding electra process epoch
james-prysm b5e316d
skipping spec tests for now
james-prysm 20753ef
Update testing/spectest/minimal/electra/fork_transition/BUILD.bazel
james-prysm 9613d3b
fixing naming
james-prysm 6f74697
gaz
james-prysm 4705382
fixing more bazel build stuff
james-prysm 00ba32f
Merge branch 'develop' into electra-core-transition
james-prysm ab71bef
Merge branch 'develop' into electra-core-transition
james-prysm 53196e9
Merge branch 'develop' into electra-core-transition
james-prysm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package electra | ||
|
||
import "github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
|
||
// ProcessEffectiveBalanceUpdates processes effective balance updates during epoch processing. | ||
// | ||
// Spec pseudocode definition: | ||
// | ||
// def process_effective_balance_updates(state: BeaconState) -> None: | ||
// # Update effective balances with hysteresis | ||
// for index, validator in enumerate(state.validators): | ||
// balance = state.balances[index] | ||
// HYSTERESIS_INCREMENT = uint64(EFFECTIVE_BALANCE_INCREMENT // HYSTERESIS_QUOTIENT) | ||
// DOWNWARD_THRESHOLD = HYSTERESIS_INCREMENT * HYSTERESIS_DOWNWARD_MULTIPLIER | ||
// UPWARD_THRESHOLD = HYSTERESIS_INCREMENT * HYSTERESIS_UPWARD_MULTIPLIER | ||
// EFFECTIVE_BALANCE_LIMIT = ( | ||
// MAX_EFFECTIVE_BALANCE_EIP7251 if has_compounding_withdrawal_credential(validator) | ||
// else MIN_ACTIVATION_BALANCE | ||
// ) | ||
// | ||
// if ( | ||
// balance + DOWNWARD_THRESHOLD < validator.effective_balance | ||
// or validator.effective_balance + UPWARD_THRESHOLD < balance | ||
// ): | ||
// validator.effective_balance = min(balance - balance % EFFECTIVE_BALANCE_INCREMENT, EFFECTIVE_BALANCE_LIMIT) | ||
func ProcessEffectiveBalanceUpdates(state state.BeaconState) error { | ||
// TODO: replace with real implementation | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package electra | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
) | ||
|
||
// ProcessRegistryUpdates rotates validators in and out of active pool. | ||
// the amount to rotate is determined churn limit. | ||
// | ||
// Spec pseudocode definition: | ||
// | ||
// def process_registry_updates(state: BeaconState) -> None: | ||
// # Process activation eligibility and ejections | ||
// for index, validator in enumerate(state.validators): | ||
// if is_eligible_for_activation_queue(validator): | ||
// validator.activation_eligibility_epoch = get_current_epoch(state) + 1 | ||
// | ||
// if ( | ||
// is_active_validator(validator, get_current_epoch(state)) | ||
// and validator.effective_balance <= EJECTION_BALANCE | ||
// ): | ||
// initiate_validator_exit(state, ValidatorIndex(index)) | ||
// | ||
// # Activate all eligible validators | ||
// activation_epoch = compute_activation_exit_epoch(get_current_epoch(state)) | ||
// for validator in state.validators: | ||
// if is_eligible_for_activation(state, validator): | ||
// validator.activation_epoch = activation_epoch | ||
func ProcessRegistryUpdates(ctx context.Context, state state.BeaconState) (state.BeaconState, error) { | ||
// TODO: replace with real implementation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coming in #14005 |
||
return state, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package electra | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
enginev1 "github.com/prysmaticlabs/prysm/v5/proto/engine/v1" | ||
) | ||
|
||
// ProcessExecutionLayerWithdrawRequests processes the validator withdrawals from the provided execution payload | ||
// into the beacon state triggered by the execution layer. | ||
// | ||
// Spec pseudocode definition: | ||
// | ||
// def process_execution_layer_withdrawal_request( | ||
// | ||
// state: BeaconState, | ||
// execution_layer_withdrawal_request: ExecutionLayerWithdrawalRequest | ||
// | ||
// ) -> None: | ||
// amount = execution_layer_withdrawal_request.amount | ||
// is_full_exit_request = amount == FULL_EXIT_REQUEST_AMOUNT | ||
// | ||
// # If partial withdrawal queue is full, only full exits are processed | ||
// if len(state.pending_partial_withdrawals) == PENDING_PARTIAL_WITHDRAWALS_LIMIT and not is_full_exit_request: | ||
// return | ||
// | ||
// validator_pubkeys = [v.pubkey for v in state.validators] | ||
// # Verify pubkey exists | ||
// request_pubkey = execution_layer_withdrawal_request.validator_pubkey | ||
// if request_pubkey not in validator_pubkeys: | ||
// return | ||
// index = ValidatorIndex(validator_pubkeys.index(request_pubkey)) | ||
// validator = state.validators[index] | ||
// | ||
// # Verify withdrawal credentials | ||
// has_correct_credential = has_execution_withdrawal_credential(validator) | ||
// is_correct_source_address = ( | ||
// validator.withdrawal_credentials[12:] == execution_layer_withdrawal_request.source_address | ||
// ) | ||
// if not (has_correct_credential and is_correct_source_address): | ||
// return | ||
// # Verify the validator is active | ||
// if not is_active_validator(validator, get_current_epoch(state)): | ||
// return | ||
// # Verify exit has not been initiated | ||
// if validator.exit_epoch != FAR_FUTURE_EPOCH: | ||
// return | ||
// # Verify the validator has been active long enough | ||
// if get_current_epoch(state) < validator.activation_epoch + SHARD_COMMITTEE_PERIOD: | ||
// return | ||
// | ||
// pending_balance_to_withdraw = get_pending_balance_to_withdraw(state, index) | ||
// | ||
// if is_full_exit_request: | ||
// # Only exit validator if it has no pending withdrawals in the queue | ||
// if pending_balance_to_withdraw == 0: | ||
// initiate_validator_exit(state, index) | ||
// return | ||
// | ||
// has_sufficient_effective_balance = validator.effective_balance >= MIN_ACTIVATION_BALANCE | ||
// has_excess_balance = state.balances[index] > MIN_ACTIVATION_BALANCE + pending_balance_to_withdraw | ||
// | ||
// # Only allow partial withdrawals with compounding withdrawal credentials | ||
// if has_compounding_withdrawal_credential(validator) and has_sufficient_effective_balance and has_excess_balance: | ||
// to_withdraw = min( | ||
// state.balances[index] - MIN_ACTIVATION_BALANCE - pending_balance_to_withdraw, | ||
// amount | ||
// ) | ||
// exit_queue_epoch = compute_exit_epoch_and_update_churn(state, to_withdraw) | ||
// withdrawable_epoch = Epoch(exit_queue_epoch + MIN_VALIDATOR_WITHDRAWABILITY_DELAY) | ||
// state.pending_partial_withdrawals.append(PendingPartialWithdrawal( | ||
// index=index, | ||
// amount=to_withdraw, | ||
// withdrawable_epoch=withdrawable_epoch, | ||
// )) | ||
func ProcessExecutionLayerWithdrawRequests(ctx context.Context, st state.BeaconState, wrs []*enginev1.ExecutionLayerWithdrawalRequest) (state.BeaconState, error) { | ||
//TODO: replace with real implementation | ||
return st, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming in #14003