[General] Why does L1L2 tx require >2x gas limit overhead to succeed on L2? #991
-
Team or ProjectCaldera ZK chainGenLayer EnvironmentTestnet L2 block number20520 - 20524 Provide a brief description of the functionality you're trying to implement and the issue you are running into.Here are three L1L2 transactions:
All three txs have the same calldata and are expected to use 342k gas, but unless gas limit is specified with high enough (~2.1x) buffer, tx will fail on L2. Questions:
Repo Link (Optional)No response Additional Details
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry for the late reply, investigating this required a fairly deep dive into ZKsync protocol.
Several things that need to be mentioned here:
Now, let's focus on your 700k gas transaction and use it as an example. From my experiments it generates 468 bytes of pubdata (not sure if there is an easy way to obtain this information but I can elaborate on how I figured that out if you want). Empirically (fancy word for saying I tried a bunch of numbers), I found out that to make it pass you need to provide 20k extra gas making the total 720k. Bootloader then refunds roughly Hope this helps and I am happpy to get into details on why 800 (a seemingly magic number) was chosen but don't want to bloat this answer further than it already is.
The constant is hardcoded in protocol and is not currently configurable. This is especially unfortunate for validiums which have low fair gas per pubdata by design but are stuck with 800 that was chosen with rollups in mind. I relayed this to protocol developers as an area for potential improvement but don't have any specific outcome yet. I will post an update if something changes though. Also, it is unclear from your message if you are aware of this or not but I'll mention just in case: L1->L2 transactions should be estimated through |
Beta Was this translation helpful? Give feedback.
@albertlai431
Sorry for the late reply, investigating this required a fairly deep dive into ZKsync protocol.
Several things that need to be mentioned here:
REQUIRED_L2_GAS_PRICE_PER_PUBDATA=800
is 160x higher than current fair pubdata price of5
.