Skip to content
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

fix(runtime) - Mitigate the receipt size limit bug #12633

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
20 changes: 19 additions & 1 deletion runtime/runtime/src/congestion_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,30 @@ impl ReceiptSinkV2 {
fn try_forward(
receipt: Receipt,
gas: u64,
size: u64,
mut size: u64,
shard: ShardId,
outgoing_limit: &mut HashMap<ShardId, OutgoingLimit>,
outgoing_receipts: &mut Vec<Receipt>,
apply_state: &ApplyState,
) -> Result<ReceiptForwarding, RuntimeError> {
// There is a bug which allows to create receipts that are above the size limit. Receipts
// above the size limit might not fit under the maximum outgoing size limit. Let's pretend
// that all receipts are at most `max_receipt_size` to avoid receipts getting stuck.
// See https://github.com/near/nearcore/issues/12606
let max_receipt_size = apply_state.config.wasm_config.limit_config.max_receipt_size;
if size > max_receipt_size {
if size > max_receipt_size {
Comment on lines +402 to +403
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this condition got duplicated

tracing::warn!(
target: "runtime",
"try_forward observed a receipt with size exceeding the size limit! receipt_id: {} size: {} size_limit: {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use structured logging - set the values as fields rather than in the formatted message

tracing::warn!(
  receipt_id=?..
  size,
  max_size,
  "try_forward observed a receipt with size exceeding the size limit"
);

receipt.receipt_id(),
size,
max_receipt_size,
);
size = max_receipt_size;
}
}

// Default case set to `Gas::MAX`: If no outgoing limit was defined for the receiving
// shard, this usually just means the feature is not enabled. Or, it
// could be a special case during resharding events. Or even a bug. In
Expand Down