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

eip-7251: process consolidations #13983

Merged
merged 7 commits into from
May 15, 2024

Conversation

@prestonvanloon prestonvanloon force-pushed the eip-7251-process-consolidations branch 4 times, most recently from de6f522 to 22039e2 Compare May 11, 2024 15:03
@prestonvanloon prestonvanloon force-pushed the eip-7251-process-consolidations branch 8 times, most recently from ee3ad6e to 5f53644 Compare May 13, 2024 18:21
@prestonvanloon prestonvanloon marked this pull request as ready for review May 13, 2024 18:22
@prestonvanloon prestonvanloon requested a review from a team as a code owner May 13, 2024 18:22
@prestonvanloon prestonvanloon force-pushed the eip-7251-process-consolidations branch 2 times, most recently from de0c18f to fefdf12 Compare May 14, 2024 06:51
@prestonvanloon
Copy link
Member Author

This is failing minimal spectests. I was skipping all spectests for consolidations as I thought they were deleted in v1.5.0-alpha.2, but I've learned that only mainnet spectests were missing for consolidations. When unskipping minimal spectests, they are failing for the following reason:

==================== Test output for //testing/spectest/minimal/electra/operations:go_default_test:
--- FAIL: TestMinimal_Electra_Operations_Consolidation (0.01s)
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/basic_consolidation_in_current_consolidation_epoch (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/basic_consolidation_in_new_consolidation_epoch (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/basic_consolidation_with_compounding_credential (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/basic_consolidation_with_insufficient_preexisting_churn (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/basic_consolidation_with_preexisting_churn (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/consolidation_balance_larger_than_churn_limit (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/consolidation_balance_through_two_churn_epochs (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed
    --- FAIL: TestMinimal_Electra_Operations_Consolidation/consolidation_churn_limit_balance (0.00s)
        assertions.go:144: helpers.go:62 Unexpected error: consolidation signature verification failed

I'll work on fixing this, but the rest of the PR is still ready for review.

@prestonvanloon prestonvanloon force-pushed the eip-7251-process-consolidations branch 2 times, most recently from f0641a9 to d5dd5e7 Compare May 14, 2024 07:55
@prestonvanloon
Copy link
Member Author

Fixed! Good bug catch by spectest, I was using the wrong fork version for computing the domain.

beacon-chain/core/electra/consolidations.go Outdated Show resolved Hide resolved
}
}

return st, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably needs a broader design discussion and is outside of the scope of this PR, but what's the reason for returning the state here when the function doesn't make a copy of the passed in state? When I see a signature such as func F(state) state, I expect that I should only use the returned state because it will differ from the passed in state when the function returns. On the contrary, SwitchToCompoundingValidator doesn't return the state, so I expect the argument to be mutated inside the function.

It would be nice if we were consistent here.

P.S. The comment even says This method makes mutating calls to the beacon state

Copy link
Member Author

Choose a reason for hiding this comment

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

There is even an argument that this method should be a receiver on the state.

if err := st.ProcessPendingConsolidations(ctx, pendingConsolidations); err != nil {
  return fmt.Errorf("failed to process pending consolidations: %w", err)
}

I agree that this signature smells as is so I will change it as part of this PR such that it will not return the resulting state.

Copy link
Member Author

Choose a reason for hiding this comment

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

One thing to note @rkapka, all of the other state transition functions return (state.BeaconState, error) so these methods will be the exception actually. It's not a big deal, we can also refactor the other methods not to return the state since it mutates it in place.

beacon-chain/core/electra/consolidations.go Outdated Show resolved Hide resolved
beacon-chain/core/electra/consolidations.go Outdated Show resolved Hide resolved
beacon-chain/core/electra/consolidations.go Outdated Show resolved Hide resolved
beacon-chain/core/electra/consolidations_test.go Outdated Show resolved Hide resolved
beacon-chain/core/electra/consolidations_test.go Outdated Show resolved Hide resolved
@prestonvanloon prestonvanloon force-pushed the eip-7251-process-consolidations branch 2 times, most recently from 6bab1fb to 1f2f82f Compare May 14, 2024 14:30
Fix failing spectest //testing/spectest/minimal/electra/operations:go_default_test
@prestonvanloon prestonvanloon force-pushed the eip-7251-process-consolidations branch from 1f2f82f to 0711d91 Compare May 15, 2024 08:16
@prestonvanloon prestonvanloon added the Electra electra hardfork label May 15, 2024
@prestonvanloon prestonvanloon force-pushed the eip-7251-process-consolidations branch from 0711d91 to 8141096 Compare May 15, 2024 13:38
@prestonvanloon prestonvanloon added this pull request to the merge queue May 15, 2024
Merged via the queue into develop with commit fcbe194 May 15, 2024
16 of 17 checks passed
@prestonvanloon prestonvanloon deleted the eip-7251-process-consolidations branch May 15, 2024 14:03
ErnestK pushed a commit to ErnestK/prysm that referenced this pull request May 19, 2024
* eip-7251: process_pending_consolidations and process_consolidations

* Consolidate unit tests + spectests

Fix failing spectest //testing/spectest/minimal/electra/operations:go_default_test

* Unskip consolidation processing for minimal spectests

* PR feedback

* Update beacon-chain/core/electra/consolidations_test.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Update beacon-chain/core/electra/consolidations_test.go

Co-authored-by: Radosław Kapka <rkapka@wp.pl>

* Move consolidation limit check outside of the loop

---------

Co-authored-by: Radosław Kapka <rkapka@wp.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Electra electra hardfork
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants