Skip to content

fix: cast mktx does not set gas_per_pubdata from estimate and skips gas limit multiplier #1277

@tomimor

Description

@tomimor

Description

cast mktx (crates/cast/src/cmd/mktx/zksync.rs) calls ZksyncProvider::estimate_fee directly instead of foundry_zksync_core::estimate_fee. This causes two gaps:

  1. gas_per_pubdata not set from estimate — when the user does not pass --zk-gas-per-pubdata, gas_per_pubdata is never populated from the RPC estimate response (fee.gas_per_pubdata_limit). All other commands (cast send, forge create, script broadcast) fall back to the estimate value via foundry_zksync_core::estimate_fee.

  2. No gas limit multipliercast mktx uses the raw fee.gas_limit instead of applying the 130% safety multiplier that foundry_zksync_core::estimate_fee applies.

Note: when the user does pass --zk-gas-per-pubdata, the value is correctly set in build_zk_tx and is not overwritten, so the CLI flag works in that case.

Current code

let fee = ZksyncProvider::estimate_fee(&zk_provider, tx.clone()).await?;
tx.set_max_fee_per_gas(fee.max_fee_per_gas);
tx.set_max_priority_fee_per_gas(fee.max_priority_fee_per_gas);
tx.set_gas_limit(fee.gas_limit);

Suggested fix

Replace the manual fee handling with the shared helper:

foundry_zksync_core::estimate_fee(&mut tx, &zk_provider, 130, zk_tx.gas_per_pubdata).await?;

Related

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions