-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add meta and all-shards destination handling #3
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
Merged
AdoAdoAdo
merged 2 commits into
develop
from
add-treatment-destination-meta-and-allshards
Aug 13, 2026
Merged
Changes from all commits
Commits
Show all changes
2 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
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 |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| from typing import Any | ||
|
|
||
| from multiversx_cross_shard_analysis.constants import ALL_SHARDS_ID, META_SHARD_ID | ||
| from multiversx_cross_shard_analysis.issues import Issues | ||
|
|
||
|
|
||
| def mention(mtype: str, round_number: int, shard_id: int) -> tuple[str, dict[str, Any]]: | ||
| return (mtype, {"nonce": 0, "round": round_number, "epoch": 8, "shard_id": shard_id, "reserved": {}}) | ||
|
|
||
|
|
||
| def make_mb(receiver: int, mentioned: list[tuple[str, dict[str, Any]]], sender: int = 0, mb_type: int = 0) -> dict[ | ||
| str, Any]: | ||
| return { | ||
| "receiverShardID": receiver, | ||
| "senderShardID": sender, | ||
| "type": mb_type, | ||
| "txCount": 1, | ||
| "first_seen_epoch": 8, | ||
| "mentioned": mentioned, | ||
| } | ||
|
|
||
|
|
||
| # correct flow for a shard -> meta miniblock: the metablock proposes it for its own | ||
| # execution (labeled dest_shard) and commits the origin exec result (meta_origin) | ||
| # in the same round, then executes it in the next metablock | ||
| def meta_destined_correct_flow(mb_type: int = 0) -> dict[str, Any]: | ||
| return make_mb(META_SHARD_ID, [ | ||
| mention("origin_shard_proposed_headers_exec", 6379, 0), | ||
| mention("origin_shard_committed_headers_exec", 6379, 0), | ||
| mention("dest_shard_proposed_headers", 6380, META_SHARD_ID), | ||
| mention("meta_origin_shard_proposed_headers", 6380, META_SHARD_ID), | ||
| mention("dest_shard_committed_headers", 6380, META_SHARD_ID), | ||
| mention("meta_origin_shard_committed_headers", 6380, META_SHARD_ID), | ||
| mention("dest_shard_proposed_headers_exec", 6381, META_SHARD_ID), | ||
| mention("dest_shard_committed_headers_exec", 6381, META_SHARD_ID), | ||
| ], mb_type=mb_type) | ||
|
|
||
|
|
||
| def normal_cross_shard_correct_flow() -> dict[str, Any]: | ||
| return make_mb(1, [ | ||
| mention("origin_shard_proposed_headers_exec", 6379, 0), | ||
| mention("origin_shard_committed_headers_exec", 6379, 0), | ||
| mention("meta_origin_shard_proposed_headers", 6380, META_SHARD_ID), | ||
| mention("meta_origin_shard_committed_headers", 6380, META_SHARD_ID), | ||
| mention("dest_shard_proposed_headers", 6381, 1), | ||
| mention("dest_shard_committed_headers", 6381, 1), | ||
| mention("dest_shard_proposed_headers_exec", 6382, 1), | ||
| mention("dest_shard_committed_headers_exec", 6382, 1), | ||
| mention("meta_dest_shard_proposed_headers", 6383, META_SHARD_ID), | ||
| mention("meta_dest_shard_committed_headers", 6383, META_SHARD_ID), | ||
| ]) | ||
|
|
||
|
|
||
| class TestMissingOrDuplicateDestination: | ||
| issue = Issues.MISSING_OR_DUPLICATE_DESTINATION | ||
|
|
||
| def test_meta_destined_correct_flow_is_clean(self): | ||
| assert self.issue.check_missing_or_duplicate_destination(meta_destined_correct_flow()) is False | ||
|
|
||
| def test_meta_destined_scr_correct_flow_is_clean(self): | ||
| assert self.issue.check_missing_or_duplicate_destination(meta_destined_correct_flow(mb_type=90)) is False | ||
|
|
||
| def test_normal_cross_shard_correct_flow_is_clean(self): | ||
| assert self.issue.check_missing_or_duplicate_destination(normal_cross_shard_correct_flow()) is False | ||
|
|
||
| def test_missing_destination_detected(self): | ||
| mb = make_mb(1, [ | ||
| mention("origin_shard_proposed_headers_exec", 6379, 0), | ||
| mention("origin_shard_committed_headers_exec", 6379, 0), | ||
| mention("meta_origin_shard_committed_headers", 6380, META_SHARD_ID), | ||
| ]) | ||
| assert self.issue.check_missing_or_duplicate_destination(mb) is True | ||
|
|
||
| def test_duplicate_destination_detected(self): | ||
| mb = normal_cross_shard_correct_flow() | ||
| mb["mentioned"] += [ | ||
| mention("dest_shard_proposed_headers", 6383, 1), | ||
| mention("dest_shard_committed_headers", 6383, 1), | ||
| ] | ||
| assert self.issue.check_missing_or_duplicate_destination(mb) is True | ||
|
|
||
| def test_meta_destined_double_include_detected(self): | ||
| mb = meta_destined_correct_flow() | ||
| mb["mentioned"] += [ | ||
| mention("dest_shard_proposed_headers", 6382, META_SHARD_ID), | ||
| mention("dest_shard_committed_headers", 6382, META_SHARD_ID), | ||
| ] | ||
| assert self.issue.check_missing_or_duplicate_destination(mb) is True | ||
|
|
||
|
|
||
| class TestWrongProcessingOrder: | ||
| issue = Issues.WRONG_PROCESSING_ORDER | ||
|
|
||
| def test_meta_destined_correct_flow_is_clean(self): | ||
| assert self.issue.check_wrong_order(meta_destined_correct_flow()) is False | ||
|
|
||
| def test_normal_cross_shard_correct_flow_is_clean(self): | ||
| assert self.issue.check_wrong_order(normal_cross_shard_correct_flow()) is False | ||
|
|
||
| def test_dest_proposal_before_meta_origin_commit_detected(self): | ||
| mb = make_mb(1, [ | ||
| mention("origin_shard_committed_headers_exec", 6379, 0), | ||
| mention("dest_shard_proposed_headers", 6380, 1), | ||
| mention("meta_origin_shard_committed_headers", 6381, META_SHARD_ID), | ||
| mention("dest_shard_committed_headers_exec", 6382, 1), | ||
| ]) | ||
| assert self.issue.check_wrong_order(mb) is True | ||
|
|
||
| def test_meta_destined_exec_before_proposal_detected(self): | ||
| mb = make_mb(META_SHARD_ID, [ | ||
| mention("origin_shard_committed_headers_exec", 6379, 0), | ||
| mention("dest_shard_committed_headers_exec", 6380, META_SHARD_ID), | ||
| mention("dest_shard_committed_headers", 6381, META_SHARD_ID), | ||
| mention("meta_origin_shard_committed_headers", 6381, META_SHARD_ID), | ||
| ]) | ||
| assert self.issue.check_wrong_order(mb) is True | ||
|
|
||
| # epoch-start peer (validator info) miniblock, broadcast from meta to all shards; | ||
| # shards include it at their own pace, so meta notarizations interleave with | ||
| # other shards' inclusions | ||
| def test_broadcast_interleaved_destinations_is_clean(self): | ||
| mb = make_mb(ALL_SHARDS_ID, [ | ||
| mention("origin_shard_proposed_headers", 101, META_SHARD_ID), | ||
| mention("origin_shard_committed_headers", 101, META_SHARD_ID), | ||
| mention("dest_shard_proposed_headers", 102, 1), | ||
| mention("meta_dest_shard_proposed_headers", 103, META_SHARD_ID), | ||
| mention("meta_dest_shard_committed_headers", 103, META_SHARD_ID), | ||
| mention("dest_shard_committed_headers", 103, 1), | ||
| mention("dest_shard_proposed_headers", 103, 0), | ||
| mention("dest_shard_committed_headers", 103, 0), | ||
| mention("meta_dest_shard_proposed_headers", 104, META_SHARD_ID), | ||
| mention("meta_dest_shard_committed_headers", 104, META_SHARD_ID), | ||
| ], sender=META_SHARD_ID, mb_type=60) | ||
| assert self.issue.check_wrong_order(mb) is False | ||
|
|
||
| def test_broadcast_destination_before_origin_detected(self): | ||
| mb = make_mb(ALL_SHARDS_ID, [ | ||
| mention("dest_shard_proposed_headers", 100, 1), | ||
| mention("origin_shard_committed_headers", 101, META_SHARD_ID), | ||
| mention("dest_shard_committed_headers", 102, 1), | ||
| ], sender=META_SHARD_ID, mb_type=60) | ||
| assert self.issue.check_wrong_order(mb) is True |
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.
Uh oh!
There was an error while loading. Please reload this page.