near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.34k stars 632 forks source link

Potential undercharging for delayed receipts #10295

Open bowenwang1996 opened 12 months ago

bowenwang1996 commented 12 months ago

Generally we don't account for the cost of reading a delayed receipt from the state. This causes a specific issue: when a shard is congested, refund receipts coming from other shards will be put into the delayed receipt queue. However, the gas cost of executing each of refund receipt is merely 223G gas, which is smaller than the cost of reading a delayed refund receipt (roughly 565Ggas assuming that such a receipt is roughly 300 bytes). This means that when there are a lot of delayed refund receipts in the queue (>1000) at once, there maybe a significant slowdown of execution simply because of the cost spent on reading the delayed refund receipts one by one.

There are a few ways we can address this issue:

bowenwang1996 commented 12 months ago

cc @marcelo-gonzalez who is investigating the slowdown in chunk processing time during congestion last week