Trie prunning async trigger#7800
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/supernova-async-exec #7800 +/- ##
==========================================================
Coverage 77.53% 77.54%
==========================================================
Files 882 882
Lines 123716 123789 +73
==========================================================
+ Hits 95919 95986 +67
- Misses 21439 21440 +1
- Partials 6358 6363 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces an async trigger for trie pruning (especially for header v3), wiring it through the async headers execution flow and updating the relevant interfaces/mocks/stubs accordingly.
Changes:
- Add
PruneTrieAsyncHeader(header data.HeaderHandler)to block processor interfaces and implement it in the base processor. - Stop triggering shard header v3 pruning from
shardProcessor.updateStateand trigger pruning fromasyncExecution/headersExecutor. - Add
process.GetHeaderWithNonce(...)helper to fetch headers by nonce for both shard and metachain paths.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| testscommon/processMocks/blockProcessorStub.go | Extend async-execution stub with PruneTrieAsyncHeader. |
| testscommon/blockProcessorStub.go | Extend test stub with PruneTrieAsyncHeader. |
| process/interface.go | Add PruneTrieAsyncHeader to main process.BlockProcessor interface. |
| process/common.go | Add GetHeaderWithNonce wrapper that dispatches to meta vs shard retrieval. |
| process/block/shardblock_test.go | Update pruning test to pass a header (not exec results slice). |
| process/block/shardblock.go | Remove sync v3 pruning from updateState; change v3 pruning API to accept a header. |
| process/block/metablock.go | Rename/simplify v3 pruning path and fetch previous meta header on-demand. |
| process/block/interface.go | Extend internal blockProcessor interface with pruneTrieHeaderV3(header). |
| process/block/export_test.go | Update exported test helper PruneTrieHeaderV3 signature; add test-only getters/setters for last pruned nonce. |
| process/block/baseProcess_test.go | Add unit tests for PruneTrieAsyncHeader. |
| process/block/baseProcess.go | Add async pruning logic with intermediate nonce handling + last-pruned nonce tracking. |
| process/asyncExecution/interface.go | Add PruneTrieAsyncHeader to async execution’s BlockProcessor interface. |
| process/asyncExecution/headersExecutor.go | Trigger async trie pruning after execution result is persisted/tracked. |
| integrationTests/mock/blockProcessorMock.go | Extend integration mock with PruneTrieAsyncHeader. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
process/block/baseProcess_test.go
Outdated
| header3 := &block.HeaderV3{ | ||
| Nonce: 10, | ||
| } | ||
| _ = header1.SetExecutionResultsHandlers(executionResultsHandlers) |
There was a problem hiding this comment.
In this test, execution results are set on header1 (nonce 8), but the method under test is called with header3 (nonce 10). This leaves header3 without execution results handlers, so PruneTrieAsyncHeader(header3) may not trigger pruning as expected and the assertions can become incorrect/flaky. Set the execution results handlers on header3 (or call pruning on the header you populated).
| _ = header1.SetExecutionResultsHandlers(executionResultsHandlers) | |
| _ = header3.SetExecutionResultsHandlers(executionResultsHandlers) |
process/block/shardblock.go
Outdated
| // TODO: analyse based on current header to be committed, not last committed header | ||
| prevHeaderHash := sp.getCurrentBlockHeader().GetPrevHash() | ||
| prevHeader, err := process.GetShardHeader(prevHeaderHash, sp.dataPool.Headers(), sp.marshalizer, sp.store) | ||
| if err != nil { |
There was a problem hiding this comment.
getPreviousExecutionResult() uses sp.getCurrentBlockHeader().GetPrevHash() to find the previous header. With the new async pruning flow (including pruning of intermediate nonces), pruneTrieHeaderV3() can be called for headers that are not the current committed header, so this will fetch the wrong previous header and compute incorrect previous root hashes for pruning. Pass the header being pruned (or its PrevHash) into getPreviousExecutionResult() and use header.GetPrevHash() instead.
process/block/baseProcess.go
Outdated
| } | ||
|
|
||
| // prune trie for the provided header | ||
| bp.blockProcessor.pruneTrieHeaderV3(header) | ||
| bp.lastPrunedHeaderNonce = header.GetNonce() |
There was a problem hiding this comment.
If pruning an intermediate nonce fails (e.g. header not found and the loop continues), lastPrunedHeaderNonce is still advanced to the provided header’s nonce at the end. This permanently skips the failed intermediate nonce(s) and they will never be retried in later calls, which can lead to missing trie pruning. Consider only advancing lastPrunedHeaderNonce up to the last successfully pruned nonce, or track/retry failures instead of skipping them permanently.
1714b93
| func TestBaseProcessor_PruneTrieAsyncHeader(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // header 1 |
There was a problem hiding this comment.
added long sequence of headers in tests, it's a long test, but it's easier to be analysed (or changed later on if needed) like this
…nager add Reset() for spm and ewl
clean ewl on failed consensus
3f8d81a
Reasoning behind the pull request
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?