Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration-tests/tests/l1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async fn l1_deposit() -> anyhow::Result<()> {
.await?;
let l1_deposit_request = bridgehub
.request_l2_transaction_direct(
// TODO: after v31 we can mint only the tx_base_cost
amount + tx_base_cost,
alice,
amount,
Expand Down
16 changes: 11 additions & 5 deletions lib/rpc/src/eth_call_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use zksync_os_storage_api::ViewState;
use zksync_os_storage_api::{
RepositoryError, StateError, state_override_view::OverriddenStateView,
};
use zksync_os_types::ZksyncOsEncode;
use zksync_os_types::{ExecutionVersion, ZksyncOsEncode};
use zksync_os_types::{
L1_TX_MINIMAL_GAS_LIMIT, L1Envelope, L1PriorityTxType, L1Tx, L1TxType, L2Envelope,
REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE, SYSTEM_TX_TYPE_ID, UpgradeTxType, ZkEnvelope,
Expand Down Expand Up @@ -555,7 +555,7 @@ impl<RpcStorage: ReadRpcStorage> EthCallHandler<RpcStorage> {
if optimistic_gas_limit < highest_gas_limit {
// Set the transaction's gas limit to the calculated optimistic gas limit.
let mut optimistic_tx = tx.clone();
set_gas_limit(&mut optimistic_tx, optimistic_gas_limit);
set_gas_limit(&mut optimistic_tx, optimistic_gas_limit, &block_context);

// Re-execute the transaction with the new gas limit and update the result and
// environment.
Expand Down Expand Up @@ -600,7 +600,7 @@ impl<RpcStorage: ReadRpcStorage> EthCallHandler<RpcStorage> {
};

let mut mid_tx = tx.clone();
set_gas_limit(&mut mid_tx, mid_gas_limit);
set_gas_limit(&mut mid_tx, mid_gas_limit, &block_context);
tracing::trace!(
gas_limit = mid_tx.gas_limit(),
"trying to simulate transaction"
Expand Down Expand Up @@ -648,7 +648,7 @@ impl<RpcStorage: ReadRpcStorage> EthCallHandler<RpcStorage> {
}
}

fn set_gas_limit(tx: &mut ZkTransaction, gas_limit: u64) {
fn set_gas_limit(tx: &mut ZkTransaction, gas_limit: u64, block_context: &BlockContext) {
match tx.inner.inner_mut() {
ZkEnvelope::System(_) => {
unreachable!("system transactions don't have explicit gas limit");
Expand All @@ -661,7 +661,13 @@ fn set_gas_limit(tx: &mut ZkTransaction, gas_limit: u64) {
ZkEnvelope::L1(envelope) => {
let tx = &mut envelope.inner;
tx.gas_limit = gas_limit;
tx.to_mint = tx.value + U256::from(tx.max_fee_per_gas) * U256::from(gas_limit);
let to_mint = if block_context.execution_version >= ExecutionVersion::V6 as u32 {
// After V31, L1 transactions only need to mint the fee
U256::from(tx.max_fee_per_gas) * U256::from(gas_limit)
} else {
tx.value + U256::from(tx.max_fee_per_gas) * U256::from(gas_limit)
};
tx.to_mint = to_mint;
}
ZkEnvelope::Upgrade(envelope) => envelope.inner.gas_limit = gas_limit,
}
Expand Down
Loading