Supernova meta processing#7354
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/supernova-async-exec #7354 +/- ##
=============================================================
+ Coverage 77.30% 77.35% +0.04%
=============================================================
Files 867 868 +1
Lines 116906 117321 +415
=============================================================
+ Hits 90379 90758 +379
- Misses 20565 20591 +26
- Partials 5962 5972 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| "hash", currentBlockHash) | ||
| bp.revertGasForCrossShardDstMeMiniBlocks(currMiniBlocksAdded, pendingMiniBlocks) | ||
|
|
||
| return false, pendingMiniBlocks, nil |
There was a problem hiding this comment.
just a note, this might be misleading, as the returned pendingMiniBlocks are not pending anymore, as they were reverted.
There was a problem hiding this comment.
although the comment from metablockProposal.go clarifies this a bit
There was a problem hiding this comment.
refactored this part
|
|
||
| // RevertIncomingMiniBlocks reverts the gas consumption for the given incoming mini blocks | ||
| func (gc *gasConsumption) RevertIncomingMiniBlocks(miniBlockHashes [][]byte) { | ||
| // TODO: implement this |
There was a problem hiding this comment.
will remove todo once it is merged.
| if !ok { | ||
| continue | ||
| } | ||
| mp.addHeader(shardHdrInfo.Hash, shardHdrInfo.Header, shardHdrInfo.UsedInBlock) |
There was a problem hiding this comment.
pass the entire structure?
There was a problem hiding this comment.
addHeader was not refactored in this PR
| func (mp *metaProcessor) createProposalMiniBlocks(haveTime func() bool) error { | ||
| if !haveTime() { | ||
| log.Debug("metaProcessor.createProposalMiniBlocks", "error", process.ErrTimeIsOut) | ||
| return nil |
There was a problem hiding this comment.
return nil here = create a proposal with empty body?
| shardHeaders []data.HeaderHandler, | ||
| shardHeaderHashes [][]byte, | ||
| ) ([]data.ShardDataHandler, error) { | ||
| if !metaHeader.IsHeaderV3() { |
There was a problem hiding this comment.
check header for nil
| shardHeaders []data.ShardHeaderHandler, | ||
| shardHeaderHashes [][]byte, | ||
| ) ([]data.ShardDataHandler, error) { | ||
| if metaHeader.IsHeaderV3() { |
There was a problem hiding this comment.
check header for nil
| return nil, process.ErrWrongTypeAssertion | ||
| } | ||
|
|
||
| execResultHandler.GetMiniBlockHeadersHandlers() |
| execResultHandler data.ExecutionResultHandler, | ||
| ) []block.MiniBlockHeader { | ||
| mbHeaderHandlers := execResultHandler.GetMiniBlockHeadersHandlers() | ||
| shardMiniBlockHeaders := make([]block.MiniBlockHeader, 0) |
There was a problem hiding this comment.
| shardMiniBlockHeaders := make([]block.MiniBlockHeader, 0) | |
| shardMiniBlockHeaders := make([]block.MiniBlockHeader, 0, len(mbHeaderHandlers)) |
# Conflicts: # process/block/pendingMb/pendingMiniBlocks.go
…ersx/mx-chain-go into shard-data-proposal-integration # Conflicts: # go.mod # go.sum
Shard data proposal integration
…create-shardinfo-testing
# Conflicts: # go.sum
| return &CrossShardIncomingMbsCreationResult{ | ||
| HeaderFinished: false, | ||
| PendingMiniBlocks: pendingMiniBlocks, | ||
| AddedMiniBlocks: currMiniBlocksAdded, | ||
| }, nil | ||
| } | ||
|
|
||
| return &CrossShardIncomingMbsCreationResult{ | ||
| HeaderFinished: true, | ||
| PendingMiniBlocks: pendingMiniBlocks, | ||
| AddedMiniBlocks: currMiniBlocksAdded, | ||
| }, nil |
There was a problem hiding this comment.
| return &CrossShardIncomingMbsCreationResult{ | |
| HeaderFinished: false, | |
| PendingMiniBlocks: pendingMiniBlocks, | |
| AddedMiniBlocks: currMiniBlocksAdded, | |
| }, nil | |
| } | |
| return &CrossShardIncomingMbsCreationResult{ | |
| HeaderFinished: true, | |
| PendingMiniBlocks: pendingMiniBlocks, | |
| AddedMiniBlocks: currMiniBlocksAdded, | |
| }, nil | |
| } | |
| return &CrossShardIncomingMbsCreationResult{ | |
| HeaderFinished: hdrFinished, | |
| PendingMiniBlocks: pendingMiniBlocks, | |
| AddedMiniBlocks: currMiniBlocksAdded, | |
| }, nil |
return hdrFinished directly?
| func (mp *metaProcessor) getLastCrossNotarizedShardHdrs() (map[uint32]data.HeaderHandler, error) { | ||
| lastCrossNotarizedHeader := make(map[uint32]data.HeaderHandler, mp.shardCoordinator.NumberOfShards()) | ||
| func (mp *metaProcessor) getLastCrossNotarizedShardHdrsAndAddToCurrentBlock() (map[uint32]data.HeaderHandler, error) { | ||
| lastCrossNotarizedHeader, err := mp.getLastCrossNotarizedShardHdrs() |
There was a problem hiding this comment.
rename to ...Headers? same below
| func (mp *metaProcessor) createShardInfo(metaHdr data.MetaHeaderHandler) ([]data.ShardDataHandler, error) { | ||
| var shardInfo []data.ShardDataHandler | ||
| if mp.epochStartTrigger.IsEpochStart() { | ||
| if metaHdr.IsStartOfEpochBlock() { |
There was a problem hiding this comment.
we don't need to check by epochStartTrigger.IsEpochStart() on legacy?
There was a problem hiding this comment.
adding of epoch start data should have already happened on the condition of epochStartTrigger.IsEpochStart() earlier (on block creation), so at this point the conditions should be equivalent for legacy.
| return nil, process.ErrWrongTypeAssertion | ||
| } | ||
|
|
||
| header, err := sic.headersPool.GetHeaderByHash(execResultHandler.GetHeaderHash()) |
There was a problem hiding this comment.
i'm thinking if it might help to use GetHeader func (from process common which search in pool and then in storage) it should be in the pool but if there is an edge case
There was a problem hiding this comment.
that would mean giving the component access also to the storage service. I would leave it like this for now, the header should be in the pool. We can see first how the testing goes and decide later if if is really needed.
| shardHeader, ok := header.(data.ShardHeaderHandler) | ||
| if !ok { | ||
| return nil, process.ErrWrongTypeAssertion | ||
| } | ||
|
|
There was a problem hiding this comment.
add IsHeaderV3 check? as for meta header proposal
| return nil, err | ||
| } | ||
|
|
||
| err = mp.addExecutionResultsOnHeader(metaHeader) |
There was a problem hiding this comment.
do we add execution results on header on CreateNewHeaderProposal? shoudn't be set on CreateBlockProposal?
There was a problem hiding this comment.
this was required on the metachain with the proposal flow, as otherwise we would not know that the epoch change should be done (we do the epoch change now when we notarize the execution results from an epoch change proposal, rather than relying on the epoch change trigger component).
This was done in order to have minimal changes to the trigger, considering that the detection of the epoch change conditions are now not in sync with the execution of an epoch change, and the commit of the epoch change.
| return nil, nil | ||
| } | ||
|
|
||
| func (mp *metaProcessor) hasStartOfEpochExecutionResults(metaHeader data.MetaHeaderHandler) (bool, error) { |
There was a problem hiding this comment.
| func (mp *metaProcessor) hasStartOfEpochExecutionResults(metaHeader data.MetaHeaderHandler) (bool, error) { | |
| func hasStartOfEpochExecutionResults(metaHeader data.MetaHeaderHandler) (bool, error) { |
*optional: i might refactor a bit and use this also in epoch start bootstrap in another PR
There was a problem hiding this comment.
yes, this could be moved and refactored, I would do this on another PR, there is an ongoing work of adding unit tests for this in a separate PR.
| } | ||
|
|
There was a problem hiding this comment.
on legacy there was also go mp.requestShardHeadersIfNeeded(hdrsAddedForShard, lastShardHdr) we don't need it anymore?
There was a problem hiding this comment.
yes, I think we need something similar, but requesting both headers and proofs, and not based on the finality as the headers are already final once they have a proof.
This should be done on another PR.
| defer s.mut.Unlock() | ||
|
|
||
| if check.IfNil(metaBlock) || len(metaBlockHash) == 0 { | ||
| if check.IfNil(header) || len(headerHash) == 0 { |
There was a problem hiding this comment.
not related to this pr: can be done before mutex lock
| // TODO: pendingMiniBlocksHandler should be updated | ||
| shardData.NumPendingMiniBlocks = uint32(len(sic.pendingMiniBlocksHandler.GetPendingMiniBlocks(header.GetShardID()))) |
There was a problem hiding this comment.
done, coming in another PR
MX-17245 Adding unit tests for shardinfo
…chain-go into supernova-meta-processing
| func (mp *metaProcessor) getLastCrossNotarizedShardHdrs() (map[uint32]data.HeaderHandler, error) { | ||
| lastCrossNotarizedHeader := make(map[uint32]data.HeaderHandler, mp.shardCoordinator.NumberOfShards()) | ||
| func (mp *metaProcessor) getLastCrossNotarizedShardHdrsAndAddToCurrentBlock() (map[uint32]data.HeaderHandler, error) { | ||
| lastCrossNotarizedHeader, err := mp.getLastCrossNotarizedShardHeaders() |
There was a problem hiding this comment.
here i was referring to the variable name, it confused me at first, but not directly related to this PR, it can remain as it is
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?