-
Notifications
You must be signed in to change notification settings - Fork 226
Fix pending miniblocks meta #7794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ssd04
wants to merge
3
commits into
feat/supernova-async-exec
Choose a base branch
from
fix-pending-miniblocks-meta
base: feat/supernova-async-exec
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+96
−33
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,8 +67,11 @@ func createMockHeader( | |||||||
| func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
| pmb, _ := pendingMb.NewPendingMiniBlocks(&pool.HeadersPoolStub{}) | ||||||||
| t.Run("same sender and receiver shard, empty pendingMb", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
| pmb, _ := pendingMb.NewPendingMiniBlocks(&pool.HeadersPoolStub{}) | ||||||||
|
|
||||||||
| miniBlockHeaders := []block.MiniBlockHeader{ | ||||||||
| { | ||||||||
| Hash: []byte("mb header hash"), | ||||||||
|
|
@@ -92,6 +95,9 @@ func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | |||||||
| assert.Equal(t, 0, len(pendingMiniblocks)) | ||||||||
| }) | ||||||||
| t.Run("metachain receiver shard, empty pendingMb", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
| pmb, _ := pendingMb.NewPendingMiniBlocks(&pool.HeadersPoolStub{}) | ||||||||
| receivedShardId := core.MetachainShardId | ||||||||
| miniBlockHeaders := []block.MiniBlockHeader{ | ||||||||
| { | ||||||||
|
|
@@ -115,6 +121,9 @@ func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | |||||||
| assert.Equal(t, 0, len(pendingMiniblocks)) | ||||||||
| }) | ||||||||
| t.Run("metachain sender shard, empty pendingMb", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
| pmb, _ := pendingMb.NewPendingMiniBlocks(&pool.HeadersPoolStub{}) | ||||||||
| miniBlockHeaders := []block.MiniBlockHeader{ | ||||||||
| { | ||||||||
| Hash: []byte("mb header hash"), | ||||||||
|
|
@@ -137,6 +146,9 @@ func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | |||||||
| assert.Equal(t, 0, len(pendingMiniblocks)) | ||||||||
| }) | ||||||||
| t.Run("different sender and receiver shard, non empty pendingMb", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
| pmb, _ := pendingMb.NewPendingMiniBlocks(&pool.HeadersPoolStub{}) | ||||||||
| receivedShardId := uint32(1) | ||||||||
| miniBlockHeaders := []block.MiniBlockHeader{ | ||||||||
| { | ||||||||
|
|
@@ -159,7 +171,11 @@ func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | |||||||
| pendingMiniblocks := pmb.GetPendingMiniBlocks(receivedShardId) | ||||||||
| assert.Equal(t, 2, len(pendingMiniblocks)) | ||||||||
| }) | ||||||||
|
|
||||||||
| t.Run("different sender and receiver shard, delete already added, non empty pendingMb", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
| pmb, _ := pendingMb.NewPendingMiniBlocks(&pool.HeadersPoolStub{}) | ||||||||
| receivedShardId := uint32(1) | ||||||||
| miniBlockHeaders := []block.MiniBlockHeader{ | ||||||||
| { | ||||||||
|
|
@@ -187,8 +203,15 @@ func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | |||||||
| assert.Nil(t, err) | ||||||||
|
|
||||||||
| pendingMiniblocks := pmb.GetPendingMiniBlocks(receivedShardId) | ||||||||
| assert.Equal(t, 2, len(pendingMiniblocks)) | ||||||||
| assert.Equal(t, 4, len(pendingMiniblocks)) | ||||||||
|
|
||||||||
| err = pmb.AddProcessedHeader(header) | ||||||||
| assert.Nil(t, err) | ||||||||
|
|
||||||||
| pendingMiniblocks = pmb.GetPendingMiniBlocks(receivedShardId) | ||||||||
| assert.Equal(t, 2, len(pendingMiniblocks)) // removed duplicated mbs | ||||||||
| }) | ||||||||
|
|
||||||||
| t.Run("epoch start should reprocess everything", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
|
|
@@ -269,6 +292,7 @@ func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | |||||||
| assert.Equal(t, expectedMap, pendingMiniblocks.GetMapPendingMbShard()) | ||||||||
| assert.Equal(t, expectedBefore, pendingMiniblocks.GetBeforeRevertPendingMbShard()) | ||||||||
| }) | ||||||||
|
|
||||||||
| t.Run("MetaBlockV3 with shard data proposals", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
|
|
@@ -328,36 +352,85 @@ func TestPendingMiniBlockHeaders_AddProcessedHeader(t *testing.T) { | |||||||
|
|
||||||||
| // Only valid cross-shard miniblocks should be added | ||||||||
| pendingMiniblocks := pmbLocal.GetPendingMiniBlocks(1) | ||||||||
| assert.Equal(t, 0, len(pendingMiniblocks)) | ||||||||
| assert.Equal(t, 1, len(pendingMiniblocks)) // shard data mb header is included here | ||||||||
| assert.Equal(t, []byte("cross shard 0-1"), pendingMiniblocks[0]) | ||||||||
|
|
||||||||
| pendingMiniblocks = pmbLocal.GetPendingMiniBlocks(2) | ||||||||
| assert.Equal(t, 1, len(pendingMiniblocks)) | ||||||||
| assert.Equal(t, []byte("cross shard 0-2"), pendingMiniblocks[0]) | ||||||||
| assert.Equal(t, 0, len(pendingMiniblocks)) // do not consider proposed shard data info | ||||||||
|
|
||||||||
| // Invalid miniblocks should not be present | ||||||||
| pendingMiniblocks = pmbLocal.GetPendingMiniBlocks(core.MetachainShardId) | ||||||||
| assert.Nil(t, pendingMiniblocks) | ||||||||
| }) | ||||||||
| t.Run("MetaBlockV3 with missing header from pool should error", func(t *testing.T) { | ||||||||
|
|
||||||||
| t.Run("MetaBlockV3 with execution result miniblocks", func(t *testing.T) { | ||||||||
| t.Parallel() | ||||||||
|
|
||||||||
| dataPool := &pool.HeadersPoolStub{ | ||||||||
| GetHeaderByHashCalled: func(hash []byte) (data.HeaderHandler, error) { | ||||||||
| return nil, errExpected | ||||||||
| }, | ||||||||
| } | ||||||||
| pmbLocal, _ := pendingMb.NewPendingMiniBlocks(dataPool) | ||||||||
| pmbLocal, _ := pendingMb.NewPendingMiniBlocks(&pool.HeadersPoolStub{}) | ||||||||
|
|
||||||||
| header := &block.MetaBlockV3{ | ||||||||
| Nonce: 1, | ||||||||
| ShardInfo: []block.ShardData{ | ||||||||
| { | ||||||||
| ShardMiniBlockHeaders: []block.MiniBlockHeader{ | ||||||||
| { | ||||||||
| Hash: []byte("cross shard 0-1"), | ||||||||
| SenderShardID: 0, | ||||||||
| ReceiverShardID: 1, | ||||||||
| }, | ||||||||
| }, | ||||||||
| }, | ||||||||
| }, | ||||||||
| ShardInfoProposal: []block.ShardDataProposal{ | ||||||||
| { | ||||||||
| HeaderHash: []byte("proposed header"), | ||||||||
| }, | ||||||||
| }, | ||||||||
| ExecutionResults: []*block.MetaExecutionResult{ | ||||||||
| { | ||||||||
| ExecutionResult: &block.BaseMetaExecutionResult{}, | ||||||||
| MiniBlockHeaders: []block.MiniBlockHeader{ | ||||||||
| { | ||||||||
| Hash: []byte("same shard"), | ||||||||
| SenderShardID: 1, | ||||||||
| ReceiverShardID: 1, | ||||||||
| }, | ||||||||
| { | ||||||||
| Hash: []byte("shard to meta"), | ||||||||
| SenderShardID: 1, | ||||||||
| ReceiverShardID: core.MetachainShardId, | ||||||||
| }, | ||||||||
| { | ||||||||
| Hash: []byte("meta to all"), | ||||||||
| SenderShardID: core.MetachainShardId, | ||||||||
| ReceiverShardID: core.AllShardId, | ||||||||
| }, | ||||||||
| { | ||||||||
| Hash: []byte("cross shard 0-2"), | ||||||||
| SenderShardID: 0, | ||||||||
| ReceiverShardID: 2, | ||||||||
| }, | ||||||||
| }, | ||||||||
| }, | ||||||||
| }, | ||||||||
| } | ||||||||
|
|
||||||||
|
||||||||
| _ = errExpected |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getMiniBlocksHashesReadyForCrossShardExecutionnow propagates errors fromcommon.GetMiniBlockHeadersFromExecResult(new behavior vs. callingGetMiniBlockHeaderHandlers()directly). There should be a unit test exercising this error path (e.g., a v3 meta header whose execution result handler is nil or a wrong type) to ensureAddProcessedHeaderreturns the wrapped error as expected.