-
-
Notifications
You must be signed in to change notification settings - Fork 457
fix: align voluntary exit pruning with inclusion rules #9214
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
Open
solanaXpeter
wants to merge
3
commits into
ChainSafe:unstable
Choose a base branch
from
solanaXpeter:fix-voluntary-exit-prune-rules
base: unstable
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+91
−9
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
81 changes: 81 additions & 0 deletions
81
packages/beacon-node/test/unit/chain/opPools/opPool.test.ts
This file contains hidden or 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,81 @@ | ||
| import {describe, expect, it} from "vitest"; | ||
| import {createBeaconConfig, createChainForkConfig, defaultChainConfig} from "@lodestar/config"; | ||
| import {BeaconStateView, computeStartSlotAtEpoch} from "@lodestar/state-transition"; | ||
| import {phase0, ssz} from "@lodestar/types"; | ||
| import {OpPool} from "../../../../src/chain/opPools/opPool.js"; | ||
| import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js"; | ||
| import {generateState} from "../../../utils/state.js"; | ||
|
|
||
| const chainConfig = createChainForkConfig({ | ||
| ...defaultChainConfig, | ||
| ALTAIR_FORK_EPOCH: 1, | ||
| BELLATRIX_FORK_EPOCH: 2, | ||
| CAPELLA_FORK_EPOCH: 3, | ||
| DENEB_FORK_EPOCH: 4, | ||
| ELECTRA_FORK_EPOCH: 5, | ||
| }); | ||
|
|
||
| describe("OpPool voluntary exits", () => { | ||
| it("keeps previous-fork exits that are still includable before deneb", () => { | ||
| const headSlot = computeStartSlotAtEpoch(chainConfig.BELLATRIX_FORK_EPOCH); | ||
| const {pool, headBlock, headState} = createPoolContext(headSlot); | ||
|
|
||
| pool.insertVoluntaryExit(createVoluntaryExit(chainConfig.ALTAIR_FORK_EPOCH)); | ||
| pool.pruneAll(headBlock, headState); | ||
|
|
||
| expect(pool.getAllVoluntaryExits()).toHaveLength(1); | ||
| }); | ||
|
|
||
| it("prunes exits whose signatures are no longer includable before deneb", () => { | ||
| const headSlot = computeStartSlotAtEpoch(chainConfig.BELLATRIX_FORK_EPOCH); | ||
| const {pool, headBlock, headState} = createPoolContext(headSlot); | ||
|
|
||
| pool.insertVoluntaryExit(createVoluntaryExit(0)); | ||
| pool.pruneAll(headBlock, headState); | ||
|
|
||
| expect(pool.getAllVoluntaryExits()).toHaveLength(0); | ||
| }); | ||
|
|
||
| it("keeps capella exits after deneb because signatures remain perpetually valid", () => { | ||
| const headSlot = computeStartSlotAtEpoch(chainConfig.ELECTRA_FORK_EPOCH); | ||
| const {pool, headBlock, headState} = createPoolContext(headSlot); | ||
|
|
||
| pool.insertVoluntaryExit(createVoluntaryExit(chainConfig.CAPELLA_FORK_EPOCH)); | ||
| pool.pruneAll(headBlock, headState); | ||
|
|
||
| expect(pool.getAllVoluntaryExits()).toHaveLength(1); | ||
| }); | ||
|
|
||
| it("prunes pre-capella exits after deneb because their signature domain is no longer valid", () => { | ||
| const headSlot = computeStartSlotAtEpoch(chainConfig.ELECTRA_FORK_EPOCH); | ||
| const {pool, headBlock, headState} = createPoolContext(headSlot); | ||
|
|
||
| pool.insertVoluntaryExit(createVoluntaryExit(chainConfig.BELLATRIX_FORK_EPOCH)); | ||
| pool.pruneAll(headBlock, headState); | ||
|
|
||
| expect(pool.getAllVoluntaryExits()).toHaveLength(0); | ||
| }); | ||
| }); | ||
|
|
||
| function createPoolContext(headSlot: number) { | ||
| const state = generateState({slot: headSlot}, chainConfig); | ||
| const config = createBeaconConfig(chainConfig, state.genesisValidatorsRoot); | ||
| const headBlock = config.getForkTypes(headSlot).SignedBeaconBlock.defaultValue(); | ||
| headBlock.message.slot = headSlot; | ||
|
|
||
| return { | ||
| pool: new OpPool(config), | ||
| headBlock, | ||
| headState: new BeaconStateView(createCachedBeaconStateTest(state, config)), | ||
| }; | ||
| } | ||
|
|
||
| function createVoluntaryExit(epoch: number): phase0.SignedVoluntaryExit { | ||
| return { | ||
| ...ssz.phase0.SignedVoluntaryExit.defaultValue(), | ||
| message: { | ||
| validatorIndex: 0, | ||
| epoch, | ||
| }, | ||
| }; | ||
| } |
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.
Pruning now defers entirely to
isVoluntaryExitSignatureIncludable(), but that helper returnstruefor every exit oncestateFork >= deneb, so pre-Capella signatures can survive indefinitely until finalized. This conflicts with the actual signature domain rule (getDomainForVoluntaryExitinpackages/config/src/genesisConfig/index.tsfixes Deneb+ voluntary-exit verification to the Capella domain), meaning exits that were valid in Bellatrix/Capella gossip can become invalid at Deneb while still being kept and later selected for block production (which skips re-verifying exit signatures). On short-gap/custom fork schedules or during prolonged non-finality, this can lead to proposing blocks with invalid voluntary exits.Useful? React with 👍 / 👎.