Skip to content

refactor: payload envelope input -- pruneBelowParent#9326

Open
jeffoodchain wants to merge 3 commits intoChainSafe:unstablefrom
jeffoodchain:fix/prune-payload-envelope-input
Open

refactor: payload envelope input -- pruneBelowParent#9326
jeffoodchain wants to merge 3 commits intoChainSafe:unstablefrom
jeffoodchain:fix/prune-payload-envelope-input

Conversation

@jeffoodchain
Copy link
Copy Markdown

Motivation
According to #9318

Description

Change from iterating all the ancestor to only cache in seenPayloadEnvelopeInput/pruneBelowParent

Closes #9318

AI Assistance Disclosure

collaborate with claude code

- Updated the `pruneBelowParent` method to improve the deletion of payload inputs. Now, it checks if the cached FULL variant is an ancestor of the current parent block before evicting entries, ensuring only relevant inputs are removed. (according to issue ChainSafe#9318)
- Modified tests to reflect changes in the `pruneBelowParent` method, ensuring it correctly handles ancestor checks using `isDescendant`. Added a new test case to verify that non-ancestor entries on forks remain intact during pruning.
@jeffoodchain jeffoodchain requested a review from a team as a code owner May 5, 2026 05:24
@jeffoodchain jeffoodchain changed the title Fix/prune payload envelope input refactor: payload envelope input -- pruneBelowParent May 5, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the pruneBelowParent logic in SeenPayloadEnvelopeInput to use forkChoice.isDescendant for more precise pruning of ancestor blocks, ensuring that entries on other forks are preserved. Unit tests have been updated to reflect this change and include a new test case for fork handling. Feedback suggests using PayloadStatus.PENDING instead of PayloadStatus.FULL to improve robustness in identifying ancestors, particularly for the Gloas fork, and notes a typo in the source code comments.

Comment on lines +143 to +149
// Check if the cached FULL cariant is an ancestor of the current parent block
this.forkChoice.isDescendant(
input.blockRootHex,
PayloadStatus.FULL,
parentBlock.blockRoot,
parentBlock.payloadStatus
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The check for ancestor status should use PayloadStatus.PENDING instead of PayloadStatus.FULL. In the Gloas fork, every block root has a PENDING variant, but the FULL variant is only created once the execution payload is available. If a block in the cache is an ancestor but hasn't transitioned to FULL status in fork choice (e.g., if it was processed optimistically or if the node switched to a fork that doesn't require its payload), using PayloadStatus.FULL will cause isDescendant to return false, preventing the entry from being pruned until finalization. Using PayloadStatus.PENDING is more robust as it correctly identifies the block as an ancestor regardless of its payload status.

Also, there is a typo in the comment: "cariant" should be "variant".

        // Check if the cached block is an ancestor of the current parent block.
        // Using PENDING status for the ancestor is more robust as every Gloas block
        // has a PENDING variant, while the FULL variant may not exist yet or at all.
        this.forkChoice.isDescendant(
          input.blockRootHex,
          PayloadStatus.PENDING,
          parentBlock.blockRoot,
          parentBlock.payloadStatus
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Find better way to prune PayloadEnvelopeInput

1 participant