Skip to content

Commit

Permalink
[resharding] Check proof size limit while reading delayed receipts (#…
Browse files Browse the repository at this point in the history
…12721)

This PR builds on top of #12710 and
is related to issue #12701

After resharding, we copy the set of delayed receipts from parent to
both children. While handling delayed receipts in the new shard, we
iterated over all the delayed receipts and ignored/removed the ones that
did not belong to our shard.

Due to the implementation however, we bypassed checks to the state
witness size limit in the specific case of when the receipt did not
belong to our shard.

Now that we are doing the checks for the state witness size within the
trie recorder, it's much simper to go back and check the proof size
limit after reaching EVERY delayed receipt.
  • Loading branch information
shreyan-gupta authored Jan 13, 2025
1 parent 1dd1b0a commit 318dc05
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions runtime/runtime/src/congestion_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,13 +804,19 @@ impl<'a> DelayedReceiptQueueWrapper<'a> {
) -> Result<Option<ReceiptOrStateStoredReceipt>, RuntimeError> {
// While processing receipts, we need to keep track of the gas and bytes
// even for receipts that may be filtered out due to a resharding event
while let Some(receipt) = self.queue.pop_front(trie_update)? {
loop {
// Check proof size limit before each receipt is popped.
if trie_update.trie.check_proof_size_limit_exceed() {
break;
}
let Some(receipt) = self.queue.pop_front(trie_update)? else {
break;
};
let delayed_gas = receipt_congestion_gas(&receipt, &config)?;
let delayed_bytes = receipt_size(&receipt)? as u64;
self.removed_delayed_gas = safe_add_gas(self.removed_delayed_gas, delayed_gas)?;
self.removed_delayed_bytes = safe_add_gas(self.removed_delayed_bytes, delayed_bytes)?;

// TODO(resharding): The filter function check here is bypassing the limit check for state witness.
// Track gas and bytes for receipt above and return only receipt that belong to the shard.
if self.receipt_filter_fn(&receipt) {
return Ok(Some(receipt));
Expand Down

0 comments on commit 318dc05

Please sign in to comment.