From dc92e0d33be2dfd8e684eb74f11bde2fe434968e Mon Sep 17 00:00:00 2001 From: tomg10 Date: Mon, 26 Aug 2024 13:55:48 +0200 Subject: [PATCH 1/4] missing Gateway migration changes Signed-off-by: tomg10 --- ...6115341_clear_incorrect_chain_ids.down.sql | 0 ...826115341_clear_incorrect_chain_ids.up.sql | 2 ++ core/lib/dal/src/eth_sender_dal.rs | 4 +-- core/node/eth_sender/src/eth_tx_aggregator.rs | 14 ++++++--- core/node/eth_sender/src/eth_tx_manager.rs | 28 +++++++++++------- .../src/l1_gas_price/gas_adjuster/mod.rs | 2 +- .../layers/eth_sender/aggregator.rs | 13 ++------- .../layers/eth_sender/manager.rs | 29 ++++++++++++------- 8 files changed, 53 insertions(+), 39 deletions(-) create mode 100644 core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.down.sql create mode 100644 core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql diff --git a/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.down.sql b/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.down.sql new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql b/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql new file mode 100644 index 000000000000..5b808605b1d5 --- /dev/null +++ b/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql @@ -0,0 +1,2 @@ +-- needed as we incorrectly set values of chain_id +ALTER TABLE eth_txs SET chain_id = NULL; diff --git a/core/lib/dal/src/eth_sender_dal.rs b/core/lib/dal/src/eth_sender_dal.rs index c76547422d8f..05dbac6fd52b 100644 --- a/core/lib/dal/src/eth_sender_dal.rs +++ b/core/lib/dal/src/eth_sender_dal.rs @@ -413,8 +413,8 @@ impl EthSenderDal<'_, '_> { WHERE id = $2 "#, - eth_tx_id as i32, - chain_id as i64, + chain_id as i32, + eth_tx_id as i64, ) .execute(self.storage.conn()) .await?; diff --git a/core/node/eth_sender/src/eth_tx_aggregator.rs b/core/node/eth_sender/src/eth_tx_aggregator.rs index 7d6a6b234742..7f304e2f72b7 100644 --- a/core/node/eth_sender/src/eth_tx_aggregator.rs +++ b/core/node/eth_sender/src/eth_tx_aggregator.rs @@ -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; } @@ -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 = diff --git a/core/node/eth_sender/src/eth_tx_manager.rs b/core/node/eth_sender/src/eth_tx_manager.rs index a97aed88a0a5..0d78ab71c62d 100644 --- a/core/node/eth_sender/src/eth_tx_manager.rs +++ b/core/node/eth_sender/src/eth_tx_manager.rs @@ -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, @@ -257,10 +262,10 @@ impl EthTxManager { } pub(crate) fn operator_address(&self, operator_type: OperatorType) -> Option
{ - 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, @@ -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); @@ -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 ); diff --git a/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs b/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs index 4ed9cf1330ea..e6842b92fdba 100644 --- a/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs +++ b/core/node/fee_model/src/l1_gas_price/gas_adjuster/mod.rs @@ -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"); diff --git a/core/node/node_framework/src/implementations/layers/eth_sender/aggregator.rs b/core/node/node_framework/src/implementations/layers/eth_sender/aggregator.rs index cfe701326bd6..310580aeb3a3 100644 --- a/core/node/node_framework/src/implementations/layers/eth_sender/aggregator.rs +++ b/core/node/node_framework/src/implementations/layers/eth_sender/aggregator.rs @@ -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}, }, @@ -55,7 +52,6 @@ pub struct Input { pub replica_pool: PoolResource, pub eth_client: Option, pub eth_client_blobs: Option, - pub eth_client_l2: Option, pub object_store: ObjectStoreResource, #[context(default)] pub circuit_breakers: CircuitBreakersResource, @@ -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; @@ -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, diff --git a/core/node/node_framework/src/implementations/layers/eth_sender/manager.rs b/core/node/node_framework/src/implementations/layers/eth_sender/manager.rs index d6989d8db72b..5462fa575f94 100644 --- a/core/node/node_framework/src/implementations/layers/eth_sender/manager.rs +++ b/core/node/node_framework/src/implementations/layers/eth_sender/manager.rs @@ -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}, }, @@ -48,7 +45,6 @@ pub struct Input { pub replica_pool: PoolResource, pub eth_client: BoundEthInterfaceResource, pub eth_client_blobs: Option, - pub l2_client: Option, pub gas_adjuster: GasAdjusterResource, #[context(default)] pub circuit_breakers: CircuitBreakersResource, @@ -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")?; @@ -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. From b7c546fab0f9df32d89f40083b900eb0daf5e832 Mon Sep 17 00:00:00 2001 From: tomg10 Date: Mon, 26 Aug 2024 13:58:14 +0200 Subject: [PATCH 2/4] fix Signed-off-by: tomg10 --- core/lib/dal/src/eth_sender_dal.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/dal/src/eth_sender_dal.rs b/core/lib/dal/src/eth_sender_dal.rs index 05dbac6fd52b..2266d6fb60f9 100644 --- a/core/lib/dal/src/eth_sender_dal.rs +++ b/core/lib/dal/src/eth_sender_dal.rs @@ -413,8 +413,8 @@ impl EthSenderDal<'_, '_> { WHERE id = $2 "#, - chain_id as i32, - eth_tx_id as i64, + chain_id as i64, + eth_tx_id as i32, ) .execute(self.storage.conn()) .await?; From 4aae4f823c3d5be6f2285b0a246cfba271f391e6 Mon Sep 17 00:00:00 2001 From: tomg10 Date: Mon, 26 Aug 2024 14:28:33 +0200 Subject: [PATCH 3/4] fix Signed-off-by: tomg10 --- .../migrations/20240826115341_clear_incorrect_chain_ids.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql b/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql index 5b808605b1d5..6e90944f069b 100644 --- a/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql +++ b/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql @@ -1,2 +1,2 @@ -- needed as we incorrectly set values of chain_id -ALTER TABLE eth_txs SET chain_id = NULL; +UPDATE eth_txs SET chain_id = NULL; From 2544e898598698c10c6c87e846475213069f19df Mon Sep 17 00:00:00 2001 From: tomg10 Date: Tue, 27 Aug 2024 11:41:35 +0200 Subject: [PATCH 4/4] remove migration fixing Signed-off-by: tomg10 --- .../20240826115341_clear_incorrect_chain_ids.down.sql | 0 .../migrations/20240826115341_clear_incorrect_chain_ids.up.sql | 2 -- 2 files changed, 2 deletions(-) delete mode 100644 core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.down.sql delete mode 100644 core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql diff --git a/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.down.sql b/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.down.sql deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql b/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql deleted file mode 100644 index 6e90944f069b..000000000000 --- a/core/lib/dal/migrations/20240826115341_clear_incorrect_chain_ids.up.sql +++ /dev/null @@ -1,2 +0,0 @@ --- needed as we incorrectly set values of chain_id -UPDATE eth_txs SET chain_id = NULL;