Era

ZKsync
FoundryLayer 2
500,000 USDC
View results
Submission Details
Severity: low
Valid

During an L1Transaction preparation in `Bootloader.yul` all the gas that's used in `l1TxPreparation` is not accounted for and some of it is not paid at the end of the execution

Vulnerabity Details

The function Bootloader.yul::l1TxPreparation returns a value gasUsedOnPreparation which is used to calculate the gas used during the entire transaction that is later paid by the sender of the transaction at the end of the execution.

The gasUsedOnPreparation value is got from subtracting of the gasBeforePreparation and the final remaining gas after all the preparation opereations are done. But the issue is that this gas value gasBeforePreparation is captured after some operation which also consumes gas is excuted making the gas used in this operation not to be accounted for in the gasUsedOnPreparation value hence won't be paid for.

setPubdataInfo(gasPerPubdata, basePubdataSpent)
//@audit gas when sending pubdata not captured
let gasBeforePreparation := gas()
debugLog("gasBeforePreparation", gasBeforePreparation)

As you can see before capturing gasBeforePreparation, the function first calls setPubdataInfo fuction which makes an external call to the system context contract of setting pubDataInfo. This consumes some gas though it may be small but this gas is not accounted for.

let success := call( gas(),SYSTEM_CONTEXT_ADDR(), 0, 0, 68, 0, 0)

All other functions that call setPubdataInfo like l2TxValidation account for all the gas used except for l1TxPreparation.

This gas maybe small but as more l1 transactions get executed, it will accumulate to a big value lost in operater fees.

Imapct

Less gas than one that should be paid is paid at the end of the transaction execution.

Recommendation

Consider capturing gasBeforePreparation before calling setPubdataInfo:

-- setPubdataInfo(gasPerPubdata, basePubdataSpent)
let gasBeforePreparation := gas()
debugLog("gasBeforePreparation", gasBeforePreparation)
++ setPubdataInfo(gasPerPubdata, basePubdataSpent)
Updates

Lead Judging Commences

inallhonesty Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

all the gas that's used in Bootloader.yul::`l1TxPreparation` is not accounted for and some of it is not paid at the end of the execution

Appeal created

0xlookman Submitter
5 months ago
inallhonesty Lead Judge
5 months ago
inallhonesty Lead Judge 5 months ago
Submission Judgement Published
Validated
Assigned finding tags:

all the gas that's used in Bootloader.yul::`l1TxPreparation` is not accounted for and some of it is not paid at the end of the execution

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.