Skip to content

Commit

Permalink
fix(congestion_control) - don't assume that gas is nonzero when buffe…
Browse files Browse the repository at this point in the history
…rs are not empty (#12708)

Previously the assert was:
```rust
assert_eq!(all_buffers_empty, self.own_congestion_info.buffered_receipts_gas() == 0);
```

But this is wrong. It could happen that buffers are not empty, but
`buffered_receipts_gas` is zero. Data receipts have zero gas, so having
only Data receipts in the outgoing buffer would trigger the assert.

Let's instead assert that gas is zero when there are no receipts, that
should always be true.
jancionear authored Jan 9, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a150221 commit f9e403b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion runtime/runtime/src/congestion_control.rs
Original file line number Diff line number Diff line change
@@ -277,7 +277,9 @@ impl ReceiptSinkV2 {
}

// Assert that empty buffers match zero buffered gas.
assert_eq!(all_buffers_empty, self.own_congestion_info.buffered_receipts_gas() == 0);
if all_buffers_empty {
assert_eq!(self.own_congestion_info.buffered_receipts_gas(), 0);
}

Ok(())
}

0 comments on commit f9e403b

Please sign in to comment.