-
Notifications
You must be signed in to change notification settings - Fork 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
EIP-6110: Supply validator deposits on chain #13944
Conversation
if uint64(len(body.Deposits())) != maxDeposits { | ||
return nil, fmt.Errorf("incorrect outstanding deposits in block body, wanted: %d, got: %d", | ||
maxDeposits, len(body.Deposits())) | ||
if len(body.Deposits()) != 0 { |
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.
double check as this is changing existing logic or if I need to handle it in a fork specific way
don't forget about this,
|
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
@@ -10,6 +10,7 @@ go_library( | |||
"effective_balance_updates.go", | |||
"registry_updates.go", | |||
"transition.go", | |||
"transition_no_verify.sig.go", |
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.
This filename doesn't make sense for what you've added. It should be called operations.go, in my opinion.
If you want to keep it with this pattern please use underscores for the name and avoid a .sig.go
suffix
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.
another good catch was definitely not intentional...
// for_ops(body.execution_payload.withdrawal_requests, process_execution_layer_withdrawal_request) | ||
// for_ops(body.execution_payload.deposit_requests, process_deposit_requests) # [New in Electra:EIP6110] | ||
// for_ops(body.consolidations, process_consolidation) # [New in Electra:EIP7251] | ||
func Operations( |
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.
func Operations( | |
func ProcessOperations( |
This name is more appropriate imo
return nil, errors.Wrap(err, "could not process deposit receipts") | ||
} | ||
|
||
// TODO: Process consolidations from execution header. |
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.
I'll have this ready for review today 💪
// 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) | ||
// set_or_append_list(state.validators, index, validator) | ||
// set_or_append_list(state.balances, index, 0) # [Modified in Electra:EIP7251] | ||
// 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)) | ||
// state.pending_balance_deposits.append(PendingBalanceDeposit(index=index, amount=amount)) # [New in Electra:EIP7251] | ||
func AddValidatorToRegistry(beaconState state.BeaconState, pubKey []byte, withdrawalCredentials []byte, amount uint64) error { | ||
val := GetValidatorFromDeposit(pubKey, withdrawalCredentials) | ||
if err := beaconState.AppendValidator(val); err != nil { | ||
return err | ||
} | ||
index, ok := beaconState.ValidatorIndexByPubkey(bytesutil.ToBytes48(pubKey)) | ||
if !ok { | ||
return errors.New("could not find validator in registry") | ||
} | ||
if err := beaconState.AppendBalance(0); err != nil { | ||
return err | ||
} | ||
if err := beaconState.AppendPendingBalanceDeposit(index, amount); err != nil { | ||
return err | ||
} | ||
if err := beaconState.AppendInactivityScore(0); err != nil { | ||
return err | ||
} | ||
if err := beaconState.AppendPreviousParticipationBits(0); err != nil { | ||
return err | ||
} | ||
return beaconState.AppendCurrentParticipationBits(0) | ||
} |
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.
Shouldn't this go in the validator file?
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.
I can move it, i think it's only used in deposits though
// effective_balance=0, # [Modified in Electra:EIP7251] | ||
// | ||
// ) | ||
func GetValidatorFromDeposit(pubKey []byte, withdrawalCredentials []byte) *ethpb.Validator { |
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.
func GetValidatorFromDeposit(pubKey []byte, withdrawalCredentials []byte) *ethpb.Validator { | |
func ValidatorFromDeposit(pubKey []byte, withdrawalCredentials []byte) *ethpb.Validator { |
Please use idiomatic go, avoid Get prefix
What type of PR is this?
Feature
What does this PR do? Why is it needed?
implements eip6110 as defined in https://eips.ethereum.org/EIPS/eip-6110
TODO
adds spec testsspec tests need to be updated in future PR for devnet1Which issues(s) does this PR fix?
Other notes for review
related PR: #13943