-
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
Implement consensus spec v1.5.0-alpha.10 #14733
Changes from all commits
ee39207
491498e
45c4612
910f1ce
83cbd88
bc47d24
16473b9
511adcc
f553245
6448406
aee1467
ed695aa
96dadbd
fa39ce4
acc70e7
30a0a37
c9b8eef
f37f0c2
35da875
070eaa0
012b224
1a49d61
cea2442
73d78c9
1145786
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ func createValidatorsWithTotalActiveBalance(totalBal primitives.Gwei) []*eth.Val | |
vals := make([]*eth.Validator, num) | ||
for i := range vals { | ||
wd := make([]byte, 32) | ||
wd[0] = params.BeaconConfig().ETH1AddressWithdrawalPrefixByte | ||
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. This seems unexpected. Why is it changed? 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. Related to: ethereum/consensus-specs#4020 |
||
wd[0] = params.BeaconConfig().CompoundingWithdrawalPrefixByte | ||
wd[31] = byte(i) | ||
|
||
vals[i] = ð.Validator{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,8 +37,7 @@ import ( | |
// break | ||
// | ||
// # Calculate the consolidated balance | ||
// max_effective_balance = get_max_effective_balance(source_validator) | ||
// source_effective_balance = min(state.balances[pending_consolidation.source_index], max_effective_balance) | ||
// source_effective_balance = min(state.balances[pending_consolidation.source_index], source_validator.effective_balance) | ||
// | ||
// # Move active balance to target. Excess balance is withdrawable. | ||
// decrease_balance(state, pending_consolidation.source_index, source_effective_balance) | ||
|
@@ -78,7 +77,7 @@ func ProcessPendingConsolidations(ctx context.Context, st state.BeaconState) err | |
if err != nil { | ||
return err | ||
} | ||
b := min(validatorBalance, helpers.ValidatorMaxEffectiveBalance(sourceValidator)) | ||
b := min(validatorBalance, sourceValidator.EffectiveBalance()) | ||
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. This is related to: ethereum/consensus-specs#4040 |
||
|
||
if err := helpers.DecreaseBalance(st, pc.SourceIndex, b); err != nil { | ||
return err | ||
|
@@ -141,8 +140,8 @@ func ProcessPendingConsolidations(ctx context.Context, st state.BeaconState) err | |
// if not (has_correct_credential and is_correct_source_address): | ||
// return | ||
// | ||
// # Verify that target has execution withdrawal credentials | ||
// if not has_execution_withdrawal_credential(target_validator): | ||
// # Verify that target has compounding withdrawal credentials | ||
// if not has_compounding_withdrawal_credential(target_validator): | ||
// return | ||
// | ||
// # Verify the source and the target are active | ||
|
@@ -175,10 +174,6 @@ func ProcessPendingConsolidations(ctx context.Context, st state.BeaconState) err | |
// source_index=source_index, | ||
// target_index=target_index | ||
// )) | ||
// | ||
// # Churn any target excess active balance of target and raise its max | ||
// if has_eth1_withdrawal_credential(target_validator): | ||
// switch_to_compounding_validator(state, target_index) | ||
func ProcessConsolidationRequests(ctx context.Context, st state.BeaconState, reqs []*enginev1.ConsolidationRequest) error { | ||
if len(reqs) == 0 || st == nil { | ||
return nil | ||
|
@@ -253,7 +248,7 @@ func ProcessConsolidationRequests(ctx context.Context, st state.BeaconState, req | |
} | ||
|
||
// Target validator must have their withdrawal credentials set appropriately. | ||
if !helpers.HasExecutionWithdrawalCredentials(tgtV) { | ||
if !helpers.HasCompoundingWithdrawalCredential(tgtV) { | ||
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. This is related to ethereum/consensus-specs#4020 |
||
continue | ||
} | ||
|
||
|
@@ -298,13 +293,6 @@ func ProcessConsolidationRequests(ctx context.Context, st state.BeaconState, req | |
if err := st.AppendPendingConsolidation(ð.PendingConsolidation{SourceIndex: srcIdx, TargetIndex: tgtIdx}); err != nil { | ||
return fmt.Errorf("failed to append pending consolidation: %w", err) // This should never happen. | ||
} | ||
|
||
if helpers.HasETH1WithdrawalCredential(tgtV) { | ||
if err := SwitchToCompoundingValidator(st, tgtIdx); err != nil { | ||
log.WithError(err).Error("failed to switch to compounding validator") | ||
continue | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,7 @@ func TestSlashValidator_OK(t *testing.T) { | |
} | ||
|
||
func TestSlashValidator_Electra(t *testing.T) { | ||
helpers.ClearCache() | ||
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. Running |
||
validatorCount := 100 | ||
registry := make([]*ethpb.Validator, 0, validatorCount) | ||
balances := make([]uint64, 0, validatorCount) | ||
|
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 change is related to: ethereum/consensus-specs#4039
We defer fieldparams for
MaxRandomByte
as single source of truth