Skip to content
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

feat: Add zk gas per pubdata flag #845

Open
wants to merge 2 commits into
base: jrigada-pass-down-gas-values-for-script
Choose a base branch
from

Conversation

Jrigada
Copy link
Contributor

@Jrigada Jrigada commented Jan 17, 2025

What 💻

  • First thing updated with this PR
  • Second thing updated with this PR
  • Third thing updated with this PR

Why ✋

  • Reason why first thing was added to PR
  • Reason why second thing was added to PR
  • Reason why third thing was added to PR

Evidence 📷

Include screenshots, screen recordings, or console output here demonstrating that your changes work as intended

Documentation 📚

Please ensure the following before submitting your PR:

  • Check if these changes affect any documented features or workflows.
  • Update the book if these changes affect any documented features or workflows.

@Jrigada Jrigada requested a review from a team as a code owner January 17, 2025 17:10
@@ -133,6 +133,10 @@ pub struct ZkSyncArgs {
)]
#[serde(skip_serializing_if = "Option::is_none")]
pub suppressed_errors: Option<Vec<ZkSolcError>>,

/// Gas per pubdata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Gas per pubdata
/// Gas per pubdata to be set on transactions when broadcasting on scripts


/// Gas per pubdata
#[clap(long = "zk-gas-per-pubdata", value_name = "GAS_PER_PUBDATA")]
pub gas_per_pubdata: Option<u64>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not conceptually right to add this here as this is not a build option (same for paymaster_input as well). As those options are not for building they are for transactions. There's an analogous EVM set of opts that are in cli/src/opts/transactions.rs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also if we are just using for broadcast maybe it can just live in script args for now

@@ -143,7 +149,10 @@ pub async fn estimate_fee<P: ZksyncProvider<T>, T: Transport + Clone>(
let max_priority_fee = tx.max_priority_fee_per_gas().unwrap_or(fee.max_priority_fee_per_gas);
tx.set_max_fee_per_gas(max_fee);
tx.set_max_priority_fee_per_gas(max_priority_fee);
tx.set_gas_per_pubdata(fee.gas_per_pubdata_limit);
match tx.gas_per_pubdata() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe pass the option here directly as a function argument instead of setting before? If option is None then use the rpc result, else use the option value.

@@ -143,7 +149,10 @@ pub async fn estimate_fee<P: ZksyncProvider<T>, T: Transport + Clone>(
let max_priority_fee = tx.max_priority_fee_per_gas().unwrap_or(fee.max_priority_fee_per_gas);
tx.set_max_fee_per_gas(max_fee);
tx.set_max_priority_fee_per_gas(max_priority_fee);
tx.set_gas_per_pubdata(fee.gas_per_pubdata_limit);
match tx.gas_per_pubdata() {
Some(v) if !v.is_zero() => (),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the 0 check?

@@ -23,13 +23,20 @@ pub struct ZkEnv {
pub fair_l2_gas_price: u64,
/// fair pubdata price
pub fair_pubdata_price: u64,
/// gas per pubdata
pub gas_per_pubdata: Option<u64>,
Copy link
Contributor

@elfedy elfedy Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not belong to ZkEnv zk env simulates network params. This is a field set by the user specifying what price they should pay at max for gas_per_pubdata (If the network has a value that's higher, the tx gets reverted). If we need to keep in context, we should put this wherever paymaster_params are set as this is a value of the same nature (a param to add to transactions)

@@ -141,6 +141,11 @@ pub async fn send_transaction(
},
);
}

if let Some(gas_per_pubdata) = zk_tx_meta.gas_per_pubdata {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the only use we are giving this is overriding the value when broadcasting, we don't need to do this dance of adding the config value to the CheatcodeInspector then setting on ZkTransactionMetadata. We can just access this from right here by using self.script_config.config.zksync.gas_per_pubdata. The value of adding to ZkTransactionMetadata would be if we also used this when creating the broadcastable transactions/running the simulation, but until then probably not worth it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants