Skip to content
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

Merged
merged 25 commits into from
Dec 23, 2024
Merged

Conversation

terencechain
Copy link
Member

@terencechain terencechain commented Dec 17, 2024

@terencechain terencechain requested review from prestonvanloon and a team as code owners December 17, 2024 22:36
@terencechain terencechain force-pushed the alpha10-spec-tests branch 3 times, most recently from 02dd398 to 8d74f95 Compare December 17, 2024 22:40
if effectiveBal*maxRandomByte >= maxEB*uint64(randomByte) {
cIndices = append(cIndices, cIndex)

if s.Version() >= version.Electra {
Copy link
Member Author

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

@@ -233,8 +233,14 @@ func verifyBlobCommitmentCount(body interfaces.ReadOnlyBeaconBlockBody) error {
if err != nil {
return err
}
if len(kzgs) > field_params.MaxBlobsPerBlock {
return fmt.Errorf("too many kzg commitments in block: %d", len(kzgs))
if body.Version() >= version.Electra {
Copy link
Member Author

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#4023
It's a place holder to make sure we can pass spec test, it'll be superseded by #14678

@@ -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())
Copy link
Member Author

@terencechain terencechain Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to: ethereum/consensus-specs#4040
Also updated spec test above

@@ -217,6 +217,7 @@ func TestSlashValidator_OK(t *testing.T) {
}

func TestSlashValidator_Electra(t *testing.T) {
helpers.ClearCache()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running TestSlashValidator_Electra by itself passes but running the entire package will fail because previous test uses cache. This wasn't an issue before but now becomes an issue because shuffling is different after Electra

@@ -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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to ethereum/consensus-specs#4020

@terencechain terencechain added the Ready For Review A pull request ready for code review label Dec 17, 2024
@terencechain terencechain force-pushed the alpha10-spec-tests branch 2 times, most recently from 533e5a7 to bca3668 Compare December 18, 2024 15:47
Comment on lines 153 to 154
randomByteSlice := bytesutil.PadTo(randomByte[offset:offset+2], 8)
randomValue := binary.LittleEndian.Uint64(randomByteSlice)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A matter of taste but I kinda read better this without the allocation

randomValue := uint64(randomByte[offset]) | uint64(randomByte[offset+1])<<8

// Use the preallocated seed buffer
binary.LittleEndian.PutUint64(seedBuffer[len(seed):], uint64(i/32))
randomByte := hashFunc(seedBuffer)[i%32]
if effectiveBal*fieldparams.MaxRandomValue >= cfg.MaxEffectiveBalance*uint64(randomByte) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be MaxRandomByte?

Suggested change
if effectiveBal*fieldparams.MaxRandomValue >= cfg.MaxEffectiveBalance*uint64(randomByte) {
if effectiveBal*maxRandomByte >= cfg.MaxEffectiveBalance*uint64(randomByte) {

CHANGELOG.md Outdated
@@ -82,6 +82,7 @@ Notable features:
- Save light client updates and bootstraps in DB.
- Added more comprehensive tests for `BlockToLightClientHeader`. [PR](https://github.com/prysmaticlabs/prysm/pull/14699)
- Added light client feature flag check to RPC handlers. [PR](https://github.com/prysmaticlabs/prysm/pull/14736)
- Add field param placeholder for Electra blob target and max to pass spec tests.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to the unreleased section

CHANGELOG.md Outdated
Comment on lines 130 to 132
- Enforce Compound prefix (0x02) for target when processing pending consolidation request.
- Limit consolidating by validator's effective balance.
- Use 16-bit random value for proposer and sync committee selection filter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this to the unreleased section

@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unexpected. Why is it changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to: ethereum/consensus-specs#4020
In latest spec, consolidation is only allowed if validator has 0x02

prestonvanloon
prestonvanloon previously approved these changes Dec 20, 2024
potuz
potuz previously approved these changes Dec 23, 2024
@terencechain terencechain dismissed stale reviews from potuz and prestonvanloon via 1145786 December 23, 2024 14:03
@terencechain terencechain added this pull request to the merge queue Dec 23, 2024
Merged via the queue into develop with commit 6ce6b86 Dec 23, 2024
15 checks passed
@terencechain terencechain deleted the alpha10-spec-tests branch December 23, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants