-
Notifications
You must be signed in to change notification settings - Fork 666
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[resharding] Handle resharding of delayed receipts (#12513)
This PR is the core of delayed receipt handling for resharding V3. ## Writeup from NEP The delayed receipts queue contains all incoming receipts that could not be executed as part of a block due to resource constraints like compute cost, gas limits etc. The entries in the delayed receipt queue can belong to any of the accounts as part of the shard. During a resharding event, we ideally need to split the delayed receipts across both the child shards according to the associated account_id with the receipt. The singleton trie key DelayedReceiptIndices holds the start_index and end_index associated with the delayed receipt entries for the shard. The trie key DelayedReceipt { index } contains the actual delayed receipt associated with some account_id. These are processed in a fifo queue order during chunk execution. Note that the delayed receipt trie keys do not have the account_id prefix. In ReshardingV2, we followed the trivial solution of iterating through all the delayed receipt queue entries and assigning them to the appropriate child shard, however due to constraints on the state witness size limits and instant resharding, this approach is no longer feasible for ReshardingV3. For ReshardingV3, we decided to handle the resharding by duplicating the entries of the delayed receipt queue across both the child shards. This is great from the perspective of state witness size and instant resharding as we only need to access the delayed receipt queue root entry in the trie, however it breaks the assumption that all delayed receipts in a shard belong to the accounts within that shard. To resolve this, with the new protocol version, we changed the implementation of runtime to discard executing delayed receipts that don't belong to the account_id on that shard. Note that no delayed receipts are lost during resharding as all receipts get executed exactly once based on which of the child shards does the associated account_id belong to. Source NEP [receipt handling section](near/NEPs#578). ## Changes in this PR - We change the implementation of `DelayedReceiptQueueWrapper` to add a new filter function that filters out all delayed receipts that do not belong to the current shard. - `peek_iter` functions is updated appropriately to filter out delayed receipts as well to ensure compatibility with pipelining. - Main loop in `process_delayed_receipts` as updated from "while processing_state.delayed_receipts.len() > 0" to something like "loop while Some(delayed_receipt) in queue" as we no longer have a precise count of the number of delayed receipts to process. ## Next steps - Change memtrie split function to include delayed receipts in child shards - Testloop test.
- Loading branch information
1 parent
137ab8c
commit 6eeabc3
Showing
8 changed files
with
164 additions
and
90 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
Oops, something went wrong.