Skip to content

Txpool context#7380

Merged
AdoAdoAdo merged 35 commits into
feat/supernova-async-execfrom
txpool-context
Nov 7, 2025
Merged

Txpool context#7380
AdoAdoAdo merged 35 commits into
feat/supernova-async-execfrom
txpool-context

Conversation

@danielradu10

@danielradu10 danielradu10 commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Reasoning behind the pull request

  • At the moment, when we derive the virtual selection session, there is always a mismatch between the latest root hash, saved on the OnExecuted flow, and the root hash from the accounts proposal. This PR solves this issue.
    NOTE: the mismatch on the OnProposedBlock is not solved in this PR.

Proposed changes

  • propagate the error for roothash mismatch from the selection tracker
  • added a log in the updateRootHashNoLock from the selection tracker for the cases when the latest root hash is not updated
  • called the RecreateTrieIfNeeded on the createMiniBlocks flow from both shardProcessor and metaProcessor.
  • called the OnExecutedBlock on the CommitBlock flow from both shardProcessor and metaProcessor.
  • (in the integration tests) removed the mocked root hashes from the creation of genesis blocks
  • (in the integration tests) called the OnExecutedBlock with the right root hash at the right moment (i.e. after the accounts adapter is modified)
  • (in the integration tests) other fixes (setting the right root hash for each genesis block, setting the current blockchain header with the correct header etc)
  • fixed unit tests, integration tests

Testing procedure

  • integration tests, unit tests

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

Base automatically changed from prepare-for-legacy-sync to feat/supernova-async-exec October 30, 2025 09:23
@AdoAdoAdo AdoAdoAdo mentioned this pull request Oct 31, 2025
@codecov

codecov Bot commented Nov 4, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.08696% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.39%. Comparing base (00c3e00) to head (007e1fe).
⚠️ Report is 37 commits behind head on feat/supernova-async-exec.

Files with missing lines Patch % Lines
node/chainSimulator/chainSimulator.go 0.00% 4 Missing ⚠️
process/block/metablock.go 33.33% 2 Missing and 2 partials ⚠️
process/block/shardblock.go 60.00% 1 Missing and 1 partial ⚠️
txcache/selectionTracker.go 90.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielradu10 danielradu10 marked this pull request as ready for review November 5, 2025 11:48
@danielradu10 danielradu10 self-assigned this Nov 5, 2025
@AdoAdoAdo AdoAdoAdo requested a review from Copilot November 5, 2025 12:09

Copilot AI left a comment

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.

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.

Comment thread process/block/baseProcess_test.go Outdated
require.NoError(t, err)

err = bp.RecreateTrieIfNeeded()
require.Equal(t, expectedError, err)

Copilot AI Nov 5, 2025

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
require.Equal(t, expectedError, err)
require.Equal(t, expectedErr, err)

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

@mariusmihaic mariusmihaic self-requested a review November 5, 2025 13:13
Comment thread integrationTests/testInitializer.go
Comment thread integrationTests/testInitializer.go Outdated
Comment thread integrationTests/testInitializer.go Outdated
Comment thread integrationTests/multiShard/smartContract/scCallingSC_test.go
Comment thread integrationTests/testProcessorNode.go Outdated
Comment thread process/block/shardblock.go Outdated
Comment thread process/block/baseProcess_test.go
Comment thread process/block/baseProcess_test.go Outdated
Comment thread state/accountsEphemeralProvider.go Outdated
"latestRootHash", st.latestRootHash,
"session rootHash", rootHash,
)
return nil, errRootHashMismatch

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.

[question]
Is this backwards compatible? Or is this just new code for supernova?

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.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this has to be checked

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed TODO

Comment thread txcache/selectionTracker.go Outdated

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.

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

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.

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

Comment thread integrationTests/vm/staking/baseTestMetaProcessor.go Outdated
accountsAdapter := &stateMock.AccountsStub{
RootHashCalled: func() ([]byte, error) {
return []byte("rootHash"), nil
return nil, nil

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.

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,

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.

Got it, thanks for clarification

Comment thread state/accountsEphemeralProvider.go Outdated
Comment thread txcache/selectionTracker.go
@AdoAdoAdo AdoAdoAdo merged commit 19c13e3 into feat/supernova-async-exec Nov 7, 2025
10 of 11 checks passed
@AdoAdoAdo AdoAdoAdo deleted the txpool-context branch November 7, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants