Skip to content

Commit

Permalink
Remove settlement_mode from gas adjuster
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Mar 5, 2025
1 parent b965a84 commit 23f33d7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 74 deletions.
17 changes: 10 additions & 7 deletions core/bin/block_reverter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use zksync_dal::{ConnectionPool, Core};
use zksync_env_config::{object_store::SnapshotsObjectStoreConfig, FromEnv};
use zksync_object_store::ObjectStoreFactory;
use zksync_protobuf_config::proto;
use zksync_types::{Address, L1BatchNumber};
use zksync_types::{settlement::SettlementMode, Address, L1BatchNumber};

#[derive(Debug, Parser)]
#[command(author = "Matter Labs", version, about = "Block revert utility", long_about = None)]
Expand Down Expand Up @@ -202,7 +202,6 @@ async fn main() -> anyhow::Result<()> {

let gas_adjuster = eth_sender.gas_adjuster.context("gas_adjuster")?;
let default_priority_fee_per_gas = gas_adjuster.default_priority_fee_per_gas;
let settlement_mode = gas_adjuster.settlement_mode;

let database_secrets = match &secrets_config {
Some(secrets_config) => secrets_config
Expand Down Expand Up @@ -236,12 +235,16 @@ async fn main() -> anyhow::Result<()> {

let contracts = SettlementLayerContracts::new(&contracts, None);

let sl_rpc_url = if settlement_mode.is_gateway() {
l1_secrets
.gateway_rpc_url
.context("Gateway URL not found")?
// TODO think more about it
let (sl_rpc_url, settlement_mode) = if opts.gateway_chain_path.is_some() {
(
l1_secrets
.gateway_rpc_url
.context("Gateway URL not found")?,
SettlementMode::Gateway,
)
} else {
l1_secrets.l1_rpc_url
(l1_secrets.l1_rpc_url, SettlementMode::SettlesToL1)
};

let sl_diamond_proxy = contracts
Expand Down
7 changes: 1 addition & 6 deletions core/lib/config/src/configs/eth_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::time::Duration;

use anyhow::Context as _;
use serde::Deserialize;
use zksync_basic_types::{pubdata_da::PubdataSendingMode, settlement::SettlementMode, H256};
use zksync_basic_types::{pubdata_da::PubdataSendingMode, H256};
use zksync_crypto_primitives::K256PrivateKey;

use crate::EthWatchConfig;
Expand Down Expand Up @@ -57,7 +57,6 @@ impl EthConfig {
num_samples_for_blob_base_fee_estimate: 10,
internal_pubdata_pricing_multiplier: 1.0,
max_blob_base_fee: None,
settlement_mode: Default::default(),
}),
watcher: Some(EthWatchConfig {
confirmations_for_eth_event: None,
Expand Down Expand Up @@ -206,10 +205,6 @@ pub struct GasAdjusterConfig {
pub internal_pubdata_pricing_multiplier: f64,
/// Max blob base fee that is allowed to be used.
pub max_blob_base_fee: Option<u64>,
/// Whether the gas adjuster should require that the L2 node is used as a settlement layer.
/// It offers a runtime check for correctly provided values.
#[serde(default)]
pub settlement_mode: SettlementMode,
}

impl GasAdjusterConfig {
Expand Down
2 changes: 0 additions & 2 deletions core/lib/config/src/testonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,6 @@ impl Distribution<configs::eth_sender::GasAdjusterConfig> for EncodeDist {
num_samples_for_blob_base_fee_estimate: self.sample(rng),
internal_pubdata_pricing_multiplier: self.sample(rng),
max_blob_base_fee: self.sample(rng),
// TODO(EVM-676): generate it randomly once this value is used
settlement_mode: Default::default(),
}
}
}
Expand Down
28 changes: 2 additions & 26 deletions core/lib/protobuf_config/src/eth.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Context as _;
use zksync_config::configs::{self};
use zksync_protobuf::{required, ProtoRepr};
use zksync_types::{pubdata_da::PubdataSendingMode, settlement::SettlementMode};
use zksync_types::pubdata_da::PubdataSendingMode;

use crate::{proto::eth as proto, read_optional_repr};

Expand Down Expand Up @@ -45,24 +45,6 @@ impl proto::PubdataSendingMode {
}
}

impl proto::SettlementMode {
fn new(x: &SettlementMode) -> Self {
use SettlementMode as From;
match x {
From::SettlesToL1 => Self::SettlesToL1,
From::Gateway => Self::Gateway,
}
}

fn parse(&self) -> SettlementMode {
use SettlementMode as To;
match self {
Self::SettlesToL1 => To::SettlesToL1,
Self::Gateway => To::Gateway,
}
}
}

impl ProtoRepr for proto::Eth {
type Type = configs::eth_sender::EthConfig;

Expand Down Expand Up @@ -191,12 +173,6 @@ impl ProtoRepr for proto::GasAdjuster {
)
.context("internal_pubdata_pricing_multiplier")?,
max_blob_base_fee: self.max_blob_base_fee,
settlement_mode: self
.settlement_mode
.map(proto::SettlementMode::try_from)
.transpose()?
.map(|x| x.parse())
.unwrap_or_default(),
})
}

Expand All @@ -218,7 +194,7 @@ impl ProtoRepr for proto::GasAdjuster {
),
internal_pubdata_pricing_multiplier: Some(this.internal_pubdata_pricing_multiplier),
max_blob_base_fee: this.max_blob_base_fee,
settlement_mode: Some(proto::SettlementMode::new(&this.settlement_mode).into()),
settlement_mode: None,
}
}
}
Expand Down
53 changes: 20 additions & 33 deletions core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,22 @@ mod tests;

#[derive(Debug)]
pub struct GasAdjusterClient {
gateway_mode: bool,
inner: Box<dyn EthFeeInterface>,
}

impl GasAdjusterClient {
pub fn from_l1(inner: Box<DynClient<L1>>) -> Self {
Self {
inner: Box::new(inner.for_component("gas_adjuster")),
gateway_mode: false,
}
}

pub fn from_l2(inner: Box<DynClient<L2>>) -> Self {
impl From<Box<DynClient<L1>>> for GasAdjusterClient {
fn from(inner: Box<DynClient<L1>>) -> Self {
Self {
inner: Box::new(inner.for_component("gas_adjuster")),
gateway_mode: true,
}
}
}

impl From<Box<DynClient<L1>>> for GasAdjusterClient {
fn from(inner: Box<DynClient<L1>>) -> Self {
Self::from_l1(inner)
}
}

impl From<Box<DynClient<L2>>> for GasAdjusterClient {
fn from(inner: Box<DynClient<L2>>) -> Self {
Self::from_l2(inner)
Self {
inner: Box::new(inner.for_component("gas_adjuster")),
}
}
}

Expand Down Expand Up @@ -84,21 +71,21 @@ impl GasAdjuster {
commitment_mode: L1BatchCommitmentMode,
) -> anyhow::Result<Self> {
// A runtime check to ensure consistent config.
if config.settlement_mode.is_gateway() {
anyhow::ensure!(client.gateway_mode, "Must be L2 client in L2 mode");

anyhow::ensure!(
matches!(pubdata_sending_mode, PubdataSendingMode::RelayedL2Calldata | PubdataSendingMode::Custom),
"Only relayed L2 calldata or Custom is available for L2 mode, got: {pubdata_sending_mode:?}"
);
} else {
anyhow::ensure!(!client.gateway_mode, "Must be L1 client in L1 mode");

anyhow::ensure!(
!matches!(pubdata_sending_mode, PubdataSendingMode::RelayedL2Calldata),
"Relayed L2 calldata is only available in L2 mode"
);
}
// if config.settlement_mode.is_gateway() {
// anyhow::ensure!(client.gateway_mode, "Must be L2 client in L2 mode");
//
// anyhow::ensure!(
// matches!(pubdata_sending_mode, PubdataSendingMode::RelayedL2Calldata | PubdataSendingMode::Custom),
// "Only relayed L2 calldata or Custom is available for L2 mode, got: {pubdata_sending_mode:?}"
// );
// } else {
// anyhow::ensure!(!client.gateway_mode, "Must be L1 client in L1 mode");
//
// anyhow::ensure!(
// !matches!(pubdata_sending_mode, PubdataSendingMode::RelayedL2Calldata),
// "Relayed L2 calldata is only available in L2 mode"
// );
// }

// Subtracting 1 from the "latest" block number to prevent errors in case
// the info about the latest block is not yet present on the node.
Expand Down

0 comments on commit 23f33d7

Please sign in to comment.