Txpool context#7380
Conversation
…to txpool-context
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/supernova-async-exec #7380 +/- ##
=============================================================
- Coverage 77.40% 77.39% -0.01%
=============================================================
Files 868 868
Lines 117512 117549 +37
=============================================================
+ Hits 90956 90980 +24
- Misses 20577 20586 +9
- Partials 5979 5983 +4 ☔ 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 refactors transaction selection and block processing to properly track root hash changes through the OnExecutedBlock flow. The changes ensure that when blocks are executed, the transaction pool is notified with the correct root hash information, enabling better coordination between state changes and transaction selection.
Key changes:
- Refactored block processors to call OnExecutedBlock after block commitment
- Added RecreateTrieIfNeeded method to ensure correct state trie before transaction selection
- Updated selection session to use accountsProposal instead of accounts
- Enhanced error handling for ErrAccountNotFoundAtBlock in ephemeral provider
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| txcache/selectionTracker.go | Added logging for root hash tracking and returned errRootHashMismatch instead of just logging |
| state/accountsEphemeralProvider.go | Added handling for ErrAccountNotFoundAtBlock error type |
| process/block/shardblock.go | Refactored to call OnExecutedBlock and RecreateTrieIfNeeded |
| process/block/metablock.go | Added OnExecutedBlock call and RecreateTrieIfNeeded |
| process/block/baseProcess.go | Added OnExecutedBlock and RecreateTrieIfNeeded methods |
| process/block/preprocess/transactions.go | Changed to use accountsProposal for selection session |
| process/coordinator/process_test.go | Updated mocks to include RecreateTrieIfNeededCalled and RootHashCalled |
| Multiple test files | Updated test mocks to return nil instead of hardcoded root hash values |
| integrationTests/*.go | Added SetRootHashOfGenesisBlocks and OnExecutedBlock initialization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| require.NoError(t, err) | ||
|
|
||
| err = bp.RecreateTrieIfNeeded() | ||
| require.Equal(t, expectedError, err) |
There was a problem hiding this comment.
Variable name mismatch: the test is checking for expectedError but the mock returns expectedErr. This assertion will always fail. Change expectedError to expectedErr to match the variable defined on line 4095.
| require.Equal(t, expectedError, err) | |
| require.Equal(t, expectedErr, err) |
| "latestRootHash", st.latestRootHash, | ||
| "session rootHash", rootHash, | ||
| ) | ||
| return nil, errRootHashMismatch |
There was a problem hiding this comment.
[question]
Is this backwards compatible? Or is this just new code for supernova?
There was a problem hiding this comment.
should also apply on legacy, as the onExecuted is done there as well.
If it is not done everywhere, should be added, and if added in all needed places, then it should be backwards compatible
There was a problem hiding this comment.
this has to be checked
There was a problem hiding this comment.
you can also remove the todo, as now I think the correct information is passed, and the error is returned
| "latestRootHash", st.latestRootHash, | ||
| "session rootHash", rootHash, | ||
| ) | ||
| return nil, errRootHashMismatch |
There was a problem hiding this comment.
should also apply on legacy, as the onExecuted is done there as well.
If it is not done everywhere, should be added, and if added in all needed places, then it should be backwards compatible
| accountsAdapter := &stateMock.AccountsStub{ | ||
| RootHashCalled: func() ([]byte, error) { | ||
| return []byte("rootHash"), nil | ||
| return nil, nil |
There was a problem hiding this comment.
So both mocks will return nil and the checks are valid, right?
[question[
If so, woulnd't it make sens to make the selection tracker mock return the same hash?
|
|
||
| session, err := NewSelectionSession(ArgsSelectionSession{ | ||
| AccountsAdapter: txs.accounts, | ||
| AccountsAdapter: txs.accountsProposal, |
There was a problem hiding this comment.
Got it, thanks for clarification
Reasoning behind the pull request
NOTE: the mismatch on the OnProposedBlock is not solved in this PR.
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?