Skip to content

Fixes api block#7797

Open
miiu96 wants to merge 10 commits intofeat/supernova-async-execfrom
fix-api-block-receipts
Open

Fixes api block#7797
miiu96 wants to merge 10 commits intofeat/supernova-async-execfrom
fix-api-block-receipts

Conversation

@miiu96
Copy link
Contributor

@miiu96 miiu96 commented Mar 20, 2026

Reasoning behind the pull request

  • Fixes API block
  • Fixes GetBulkFromEpoch from fullHistoryPrunningStorer

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?

@miiu96 miiu96 self-assigned this Mar 20, 2026
@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.53%. Comparing base (8eab550) to head (37ff483).

Files with missing lines Patch % Lines
node/external/blockAPI/baseBlock.go 83.33% 1 Missing and 1 partial ⚠️
node/external/blockAPI/check.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##           feat/supernova-async-exec    #7797      +/-   ##
=============================================================
- Coverage                      77.54%   77.53%   -0.01%     
=============================================================
  Files                            882      882              
  Lines                         123683   123646      -37     
=============================================================
- Hits                           95908    95870      -38     
- Misses                         21429    21434       +5     
+ Partials                        6346     6342       -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.

@ssd04 ssd04 self-requested a review March 20, 2026 13:10
Comment on lines -240 to -242
NumTxs: numOfTxs,
NotarizedBlocks: notarizedBlocks,
MiniBlocks: miniblocks,
Copy link
Contributor

Choose a reason for hiding this comment

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

add activation flag check for this? or maybe better keep it as before, with propored miniblocks and num of txs?

Comment on lines -232 to -233
NumTxs: numOfTxs,
MiniBlocks: miniblocks,
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

Copy link
Contributor

Copilot AI left a comment

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 updates the block API receipts-loading flow to correctly handle protocol differences (incl. Supernova round activation) by threading round/receipts-hash context through the API block processors and receipts repository.

Changes:

  • Extends LoadReceipts to accept an explicit receiptsHash and updates all call sites/tests accordingly.
  • Adds EnableRoundsHandler plumbing into the block API processor args and processors; uses it to select the correct storage unit for receipts.
  • Refactors shard/meta API block conversion to delegate miniblock/tx counting logic to shared helpers and adds an integration-style simulator test for receipts.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
testscommon/receiptsRepositoryStub.go Updates stub to match new LoadReceipts(receiptsHash, header, headerHash) signature.
process/receipts/receiptsRepository.go Updates repository LoadReceipts signature and storage-key selection input.
process/receipts/receiptsRepository_test.go Adjusts tests to pass receiptsHash explicitly.
node/external/blockAPI/interface.go Updates internal blockAPI receipts repository interface signature.
node/external/blockAPI/blockArgs.go Adds EnableRoundHandler arg (rounds handler) for block API processor construction.
node/external/blockAPI/check.go Validates non-nil rounds handler in args.
node/external/blockAPI/baseBlock.go Uses rounds flag to choose receipts storer unit; passes explicit receipts hash to receipts repo for intrashard miniblocks.
node/external/blockAPI/baseBlock_test.go Updates tests to the new receipts-loading API and handler plumbing.
node/external/blockAPI/shardBlock.go Refactors conversion to use helper methods; updates intrashard receipts miniblock loading signature.
node/external/blockAPI/metaBlock.go Same as shardBlock: refactor + updated intrashard receipts miniblock loading signature.
node/external/blockAPI/apiBlockFactory_test.go Updates block API processor args to include rounds handler.
node/chainSimulator/chainSimulator_test.go Adds a simulator test asserting receipts are exposed correctly across Supernova activation.
factory/interface.go Updates public ReceiptsRepository interface signature.
factory/api/apiResolverFactory.go Wires EnableRoundsHandler() into block API processor args.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


allMbs := append(mbsBeforeExecutionAndCleanup, mbsAfterExecution...)
intraMb, err := bap.getIntrashardMiniblocksFromReceiptsStorage(blockHeader, headerHash, options)
receiptsHash := executionResultHandler.GetReceiptsHash()
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

In async execution, receiptsHash := executionResultHandler.GetReceiptsHash() can be nil/empty (e.g. if the field is missing in older execution results / default-initialized). Passing that through to LoadReceipts makes decideStorageKey choose an empty key instead of falling back to the header hash for the empty-receipts case, which can prevent intrashard miniblocks from being loaded. Consider falling back to blockHeader.GetReceiptsHash() (or to bap.emptyReceiptsHash) when len(receiptsHash)==0 before calling getIntrashardMiniblocksFromReceiptsStorage.

Suggested change
receiptsHash := executionResultHandler.GetReceiptsHash()
receiptsHash := executionResultHandler.GetReceiptsHash()
if len(receiptsHash) == 0 {
// Fallback to the block header receipts hash for older/default async results
receiptsHash = blockHeader.GetReceiptsHash()
}
if len(receiptsHash) == 0 {
// If still empty, use the predefined empty receipts hash
receiptsHash = bap.emptyReceiptsHash
}

Copilot uses AI. Check for mistakes.
AccountsRepository state.AccountsRepository
ScheduledTxsExecutionHandler process.ScheduledTxsExecutionHandler
EnableEpochsHandler common.EnableEpochsHandler
EnableRoundHandler common.EnableRoundsHandler
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

ArgAPIBlockProcessor introduces an exported field named EnableRoundHandler, but the type and the rest of the codebase use EnableRoundsHandler (plural). This inconsistency is easy to trip over and makes the API args less discoverable; consider renaming the field to EnableRoundsHandler and updating call sites accordingly.

Suggested change
EnableRoundHandler common.EnableRoundsHandler
EnableRoundsHandler common.EnableRoundsHandler

Copilot uses AI. Check for mistakes.
chainSimulatorCommon.CheckGenerateTransactions(t, chainSimulator)
}

func TestSimilator_MoveBalanceCheckReceipt(t *testing.T) {
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The test name TestSimilator_MoveBalanceCheckReceipt is misspelled (Similator). Since Go test selection relies on Test... names, consider correcting it to TestSimulator_MoveBalanceCheckReceipt for consistency and easier discovery.

Suggested change
func TestSimilator_MoveBalanceCheckReceipt(t *testing.T) {
func TestSimulator_MoveBalanceCheckReceipt(t *testing.T) {

Copilot uses AI. Check for mistakes.
require.Equal(te, value, mb.Receipts[0].Value.String())
}
}
require.True(t, called)
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

Inside checkReceipts, assertions mostly use the te parameter, but the final assertion uses the outer t (require.True(t, called)). This can report failures on the wrong *testing.T (especially if this helper is reused in subtests). Use te consistently for all assertions in this helper.

Suggested change
require.True(t, called)
require.True(te, called)

Copilot uses AI. Check for mistakes.
chainSimulatorCommon.CheckGenerateTransactions(t, chainSimulator)
}

func TestSimilator_MoveBalanceCheckReceipt(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Simulator instead of Similator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

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.

4 participants