-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(api): Improve estimation for gas_per_pubdata_limit #3475
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
Conversation
slowli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dumb question: Do I understand correctly that the changed logic influences zks_estimateFee output only? (There are 2 other uses of gas estimation, eth_estimateGas and zks_estimateL1ToL2Gas, but they both seem to output only Fee.gas_limit.) If so, gas_per_pubdata_limit is overwritten before estimation to a hard-coded value (50,000); is this fine?
zksync-era/core/node/api_server/src/web3/namespaces/zks.rs
Lines 81 to 84 in c156e79
| tx.common_data.fee.max_priority_fee_per_gas = 0u64.into(); | |
| tx.common_data.fee.gas_per_pubdata_limit = U256::from(DEFAULT_L2_TX_GAS_PER_PUBDATA_BYTE); | |
| self.estimate_fee(tx.into(), block_args, state_override) | |
| .await |
It sort of contradicts "we should not exceed the limit that was provided by the user in the initial request", since the value provided by the user is ignored.
Yes.
Huh, that's both fine and not fine. I would expect |
|
@perekopskiy @slowli do we want to merge this PR, or do you think a bigger rework is mandatory? |
|
I think this PR is fine to merge (AFAIU, it shouldn't break anything), but I won't pretend I'm an expert on the domain, so it's difficult for me to estimate how complete this fix is. |
🤖 I have created a release *beep* *boop* --- ## [26.3.0](core-v26.2.1...core-v26.3.0) (2025-02-12) ### Features * **contract-verifier:** Do not allow verification requests for verified contracts ([#3578](#3578)) ([6a1f1b8](6a1f1b8)) * **contract-verifier:** Partial matching & automatic verification ([#3527](#3527)) ([bf9fe85](bf9fe85)) * **contract-verifier:** Support missing options for EVM in API ([#3592](#3592)) ([309fdf4](309fdf4)) * **en:** better EN default req entities limit, improved documentation for API limits ([#3546](#3546)) ([e7eb716](e7eb716)) * make `zksync_types` thinner ([#3574](#3574)) ([e7f93e4](e7f93e4)) * new da_dispatcher metrics ([#3464](#3464)) ([75a7c08](75a7c08)) * update FFLONK protocol version ([#3572](#3572)) ([a352852](a352852)) * **vm:** Allow caching signature verification ([#3505](#3505)) ([7bb5ed3](7bb5ed3)) * **vm:** Support missed storage invocation limit in fast VM ([#3548](#3548)) ([ef67694](ef67694)) ### Bug Fixes * Add debug information to object store retries ([#3576](#3576)) ([036315c](036315c)) * allow configuring NoDA client via ENV ([#3599](#3599)) ([a72ab63](a72ab63)) * **api:** Change `contractAddress` assignment for transaction receipts ([#3452](#3452)) ([4179711](4179711)) * **api:** Improve estimation for gas_per_pubdata_limit ([#3475](#3475)) ([bda1b25](bda1b25)) * Avail gas relay decoding issues ([#3547](#3547)) ([a171433](a171433)) * **ci:** commenting out getFilterChanges test until fix is ready ([#3582](#3582)) ([99c3905](99c3905)) * Support newer versions of foundry-zksync ([#3556](#3556)) ([d39fb6d](d39fb6d)) * **vm:** Fix VM divergences related to validation ([#3567](#3567)) ([170d194](170d194)) ### Performance Improvements * **db:** Remove `events.tx_initiator_address` writes and index ([#3559](#3559)) ([298abd2](298abd2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: zksync-era-bot <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [26.3.0](core-v26.2.1...core-v26.3.0) (2025-02-12) ### Features * **contract-verifier:** Do not allow verification requests for verified contracts ([#3578](#3578)) ([6a1f1b8](6a1f1b8)) * **contract-verifier:** Partial matching & automatic verification ([#3527](#3527)) ([b94d1ad](b94d1ad)) * **contract-verifier:** Support missing options for EVM in API ([#3592](#3592)) ([309fdf4](309fdf4)) * **en:** better EN default req entities limit, improved documentation for API limits ([#3546](#3546)) ([e7eb716](e7eb716)) * make `zksync_types` thinner ([#3574](#3574)) ([292e731](292e731)) * new da_dispatcher metrics ([#3464](#3464)) ([75a7c08](75a7c08)) * update FFLONK protocol version ([#3572](#3572)) ([a352852](a352852)) * **vm:** Allow caching signature verification ([#3505](#3505)) ([7bb5ed3](7bb5ed3)) * **vm:** Support missed storage invocation limit in fast VM ([#3548](#3548)) ([ef67694](ef67694)) ### Bug Fixes * Add debug information to object store retries ([#3576](#3576)) ([036315c](036315c)) * allow configuring NoDA client via ENV ([#3599](#3599)) ([a72ab63](a72ab63)) * **api:** Change `contractAddress` assignment for transaction receipts ([#3452](#3452)) ([4179711](4179711)) * **api:** Improve estimation for gas_per_pubdata_limit ([#3475](#3475)) ([bda1b25](bda1b25)) * Avail gas relay decoding issues ([#3547](#3547)) ([a171433](a171433)) * **ci:** commenting out getFilterChanges test until fix is ready ([#3582](#3582)) ([99c3905](99c3905)) * Support newer versions of foundry-zksync ([#3556](#3556)) ([d39fb6d](d39fb6d)) * **vm:** Fix VM divergences related to validation ([#3567](#3567)) ([170d194](170d194)) ### Performance Improvements * **db:** Remove `events.tx_initiator_address` writes and index ([#3559](#3559)) ([298abd2](298abd2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: zksync-era-bot <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [26.3.0](matter-labs/zksync-era@core-v26.2.1...core-v26.3.0) (2025-02-12) ### Features * **contract-verifier:** Do not allow verification requests for verified contracts ([#3578](matter-labs/zksync-era#3578)) ([6a1f1b8](matter-labs/zksync-era@6a1f1b8)) * **contract-verifier:** Partial matching & automatic verification ([#3527](matter-labs/zksync-era#3527)) ([a0b7ca1](matter-labs/zksync-era@a0b7ca1)) * **contract-verifier:** Support missing options for EVM in API ([#3592](matter-labs/zksync-era#3592)) ([309fdf4](matter-labs/zksync-era@309fdf4)) * **en:** better EN default req entities limit, improved documentation for API limits ([#3546](matter-labs/zksync-era#3546)) ([e7eb716](matter-labs/zksync-era@e7eb716)) * make `zksync_types` thinner ([#3574](matter-labs/zksync-era#3574)) ([fc84832](matter-labs/zksync-era@fc84832)) * new da_dispatcher metrics ([#3464](matter-labs/zksync-era#3464)) ([75a7c08](matter-labs/zksync-era@75a7c08)) * update FFLONK protocol version ([#3572](matter-labs/zksync-era#3572)) ([a352852](matter-labs/zksync-era@a352852)) * **vm:** Allow caching signature verification ([#3505](matter-labs/zksync-era#3505)) ([7bb5ed3](matter-labs/zksync-era@7bb5ed3)) * **vm:** Support missed storage invocation limit in fast VM ([#3548](matter-labs/zksync-era#3548)) ([ef67694](matter-labs/zksync-era@ef67694)) ### Bug Fixes * Add debug information to object store retries ([#3576](matter-labs/zksync-era#3576)) ([036315c](matter-labs/zksync-era@036315c)) * allow configuring NoDA client via ENV ([#3599](matter-labs/zksync-era#3599)) ([a72ab63](matter-labs/zksync-era@a72ab63)) * **api:** Change `contractAddress` assignment for transaction receipts ([#3452](matter-labs/zksync-era#3452)) ([4179711](matter-labs/zksync-era@4179711)) * **api:** Improve estimation for gas_per_pubdata_limit ([#3475](matter-labs/zksync-era#3475)) ([bda1b25](matter-labs/zksync-era@bda1b25)) * Avail gas relay decoding issues ([#3547](matter-labs/zksync-era#3547)) ([a171433](matter-labs/zksync-era@a171433)) * **ci:** commenting out getFilterChanges test until fix is ready ([#3582](matter-labs/zksync-era#3582)) ([99c3905](matter-labs/zksync-era@99c3905)) * Support newer versions of foundry-zksync ([#3556](matter-labs/zksync-era#3556)) ([d39fb6d](matter-labs/zksync-era@d39fb6d)) * **vm:** Fix VM divergences related to validation ([#3567](matter-labs/zksync-era#3567)) ([170d194](matter-labs/zksync-era@170d194)) ### Performance Improvements * **db:** Remove `events.tx_initiator_address` writes and index ([#3559](matter-labs/zksync-era#3559)) ([298abd2](matter-labs/zksync-era@298abd2)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: zksync-era-bot <[email protected]>
Fixes the
gas_per_pubdata_limitfield calculation. Right now, we provide the value we get from deriving the existing batch input, which is most likely lower than limit provided in fee estimation request.Given that we scale the overall fee, it should be safe to scale the limit as well, as long as we don't go beyond the limit supplied in the tx.
Providing the limit as-is without scaling can be very flaky: transaction risks to be left in the mempool over minor
gas_per_pubdatachanges.