Skip to content

Commit

Permalink
fix(eth-sender): missing Gateway migration changes (#2732)
Browse files Browse the repository at this point in the history
Signed-off-by: tomg10 <lemures64@gmail.com>
  • Loading branch information
tomg10 authored Aug 27, 2024
1 parent 64b2ff8 commit a4170e9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 38 deletions.
2 changes: 1 addition & 1 deletion core/lib/dal/src/eth_sender_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ impl EthSenderDal<'_, '_> {
WHERE
id = $2
"#,
eth_tx_id as i32,
chain_id as i64,
eth_tx_id as i32,
)
.execute(self.storage.conn())
.await?;
Expand Down
14 changes: 10 additions & 4 deletions core/node/eth_sender/src/eth_tx_aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,14 @@ impl EthTxAggregator {
);
return Ok(());
}
let is_gateway = self.settlement_mode.is_gateway();
let tx = self
.save_eth_tx(storage, &agg_op, contracts_are_pre_shared_bridge, false)
.save_eth_tx(
storage,
&agg_op,
contracts_are_pre_shared_bridge,
is_gateway,
)
.await?;
Self::report_eth_tx_saving(storage, &agg_op, &tx).await;
}
Expand Down Expand Up @@ -556,9 +562,9 @@ impl EthTxAggregator {
// We may be using a custom sender for commit transactions, so use this
// var whatever it actually is: a `None` for single-addr operator or `Some`
// for multi-addr operator in 4844 mode.
let sender_addr = match op_type {
AggregatedActionType::Commit => self.custom_commit_sender_addr,
_ => None,
let sender_addr = match (op_type, is_gateway) {
(AggregatedActionType::Commit, false) => self.custom_commit_sender_addr,
(_, _) => None,
};
let nonce = self.get_next_nonce(&mut transaction, sender_addr).await?;
let encoded_aggregated_op =
Expand Down
28 changes: 17 additions & 11 deletions core/node/eth_sender/src/eth_tx_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ impl EthTxManager {
gas_adjuster,
max_acceptable_priority_fee_in_gwei: config.max_acceptable_priority_fee_in_gwei,
};
let l1_interface = Box::new(RealL1Interface {
ethereum_gateway,
ethereum_gateway_blobs,
l2_gateway,
wait_confirmations: config.wait_confirmations,
});
tracing::info!(
"Started eth_tx_manager supporting {:?} operators",
l1_interface.supported_operator_types()
);
Self {
l1_interface: Box::new(RealL1Interface {
ethereum_gateway,
ethereum_gateway_blobs,
l2_gateway,
wait_confirmations: config.wait_confirmations,
}),
l1_interface,
config,
fees_oracle: Box::new(fees_oracle),
pool,
Expand Down Expand Up @@ -257,10 +262,10 @@ impl EthTxManager {
}

pub(crate) fn operator_address(&self, operator_type: OperatorType) -> Option<Address> {
if operator_type == OperatorType::NonBlob {
None
} else {
if operator_type == OperatorType::Blob {
self.l1_interface.get_blobs_operator_account()
} else {
None
}
}
// Monitors the in-flight transactions, marks mined ones as confirmed,
Expand Down Expand Up @@ -519,9 +524,10 @@ impl EthTxManager {
tracing::info!("Stop signal received, eth_tx_manager is shutting down");
break;
}
let operator_to_track = self.l1_interface.supported_operator_types()[0];
let l1_block_numbers = self
.l1_interface
.get_l1_block_numbers(OperatorType::Blob)
.get_l1_block_numbers(operator_to_track)
.await?;
METRICS.track_block_numbers(&l1_block_numbers);

Expand Down Expand Up @@ -643,7 +649,7 @@ impl EthTxManager {
.get_l1_block_numbers(operator_type)
.await
.unwrap();
tracing::info!(
tracing::debug!(
"Loop iteration at block {} for {operator_type:?} operator",
l1_block_numbers.latest
);
Expand Down
2 changes: 1 addition & 1 deletion core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl GasAdjuster {

anyhow::ensure!(
matches!(pubdata_sending_mode, PubdataSendingMode::RelayedL2Calldata),
"Only relayed L2 calldata is available for L2 mode"
"Only relayed L2 calldata is available for L2 mode, got: {pubdata_sending_mode:?}"
);
} else {
anyhow::ensure!(!client.gateway_mode, "Must be L1 client in L1 mode");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ use zksync_types::{commitment::L1BatchCommitmentMode, settlement::SettlementMode
use crate::{
implementations::resources::{
circuit_breakers::CircuitBreakersResource,
eth_interface::{
BoundEthInterfaceForBlobsResource, BoundEthInterfaceForL2Resource,
BoundEthInterfaceResource,
},
eth_interface::{BoundEthInterfaceForBlobsResource, BoundEthInterfaceResource},
object_store::ObjectStoreResource,
pools::{MasterPool, PoolResource, ReplicaPool},
},
Expand Down Expand Up @@ -55,7 +52,6 @@ pub struct Input {
pub replica_pool: PoolResource<ReplicaPool>,
pub eth_client: Option<BoundEthInterfaceResource>,
pub eth_client_blobs: Option<BoundEthInterfaceForBlobsResource>,
pub eth_client_l2: Option<BoundEthInterfaceForL2Resource>,
pub object_store: ObjectStoreResource,
#[context(default)]
pub circuit_breakers: CircuitBreakersResource,
Expand Down Expand Up @@ -100,11 +96,6 @@ impl WiringLayer for EthTxAggregatorLayer {
let master_pool = input.master_pool.get().await.unwrap();
let replica_pool = input.replica_pool.get().await.unwrap();

let eth_client = if self.settlement_mode.is_gateway() {
input.eth_client_l2.context("l2_client must be provided")?.0
} else {
input.eth_client.context("l1_client must be provided")?.0
};
let eth_client_blobs = input.eth_client_blobs.map(|c| c.0);
let object_store = input.object_store.0;

Expand All @@ -125,7 +116,7 @@ impl WiringLayer for EthTxAggregatorLayer {
master_pool.clone(),
config.clone(),
aggregator,
eth_client.clone(),
input.eth_client.unwrap().0,
self.contracts_config.validator_timelock_addr,
self.contracts_config.l1_multicall3_addr,
self.contracts_config.diamond_proxy_addr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use zksync_eth_sender::EthTxManager;
use crate::{
implementations::resources::{
circuit_breakers::CircuitBreakersResource,
eth_interface::{
BoundEthInterfaceForBlobsResource, BoundEthInterfaceForL2Resource,
BoundEthInterfaceResource,
},
eth_interface::{BoundEthInterfaceForBlobsResource, BoundEthInterfaceResource},
gas_adjuster::GasAdjusterResource,
pools::{MasterPool, PoolResource, ReplicaPool},
},
Expand Down Expand Up @@ -48,7 +45,6 @@ pub struct Input {
pub replica_pool: PoolResource<ReplicaPool>,
pub eth_client: BoundEthInterfaceResource,
pub eth_client_blobs: Option<BoundEthInterfaceForBlobsResource>,
pub l2_client: Option<BoundEthInterfaceForL2Resource>,
pub gas_adjuster: GasAdjusterResource,
#[context(default)]
pub circuit_breakers: CircuitBreakersResource,
Expand Down Expand Up @@ -81,9 +77,10 @@ impl WiringLayer for EthTxManagerLayer {
let master_pool = input.master_pool.get().await.unwrap();
let replica_pool = input.replica_pool.get().await.unwrap();

let eth_client = input.eth_client.0;
let settlement_mode = self.eth_sender_config.gas_adjuster.unwrap().settlement_mode;
let eth_client = input.eth_client.0.clone();
let eth_client_blobs = input.eth_client_blobs.map(|c| c.0);
let l2_client = input.l2_client.map(|c| c.0);
let l2_client = input.eth_client.0;

let config = self.eth_sender_config.sender.context("sender")?;

Expand All @@ -93,9 +90,21 @@ impl WiringLayer for EthTxManagerLayer {
master_pool,
config,
gas_adjuster,
Some(eth_client),
eth_client_blobs,
l2_client,
if !settlement_mode.is_gateway() {
Some(eth_client)
} else {
None
},
if !settlement_mode.is_gateway() {
eth_client_blobs
} else {
None
},
if settlement_mode.is_gateway() {
Some(l2_client)
} else {
None
},
);

// Insert circuit breaker.
Expand Down

0 comments on commit a4170e9

Please sign in to comment.