From fa4d5172244410c8e858c2ebe7277739763a0d27 Mon Sep 17 00:00:00 2001 From: perekopskiy Date: Fri, 13 Dec 2024 16:44:06 +0200 Subject: [PATCH] remove settlement_layer_url from api config; remove get_l1_processing_details --- core/bin/external_node/src/config/mod.rs | 1 - core/lib/config/src/configs/api.rs | 4 - core/lib/config/src/testonly.rs | 1 - core/lib/dal/src/eth_sender_dal.rs | 41 +------ core/lib/dal/src/models/storage_eth_tx.rs | 23 +--- core/lib/env_config/src/api.rs | 2 - core/lib/protobuf_config/src/api.rs | 2 - .../src/proto/config/api.proto | 1 - core/lib/types/src/api/mod.rs | 11 -- core/lib/types/src/eth_sender.rs | 7 -- core/lib/web3_decl/src/namespaces/zks.rs | 9 +- .../web3/backend_jsonrpsee/namespaces/zks.rs | 13 +-- .../api_server/src/web3/namespaces/zks.rs | 101 +----------------- core/node/api_server/src/web3/state.rs | 2 - .../commands/chain/migrate_from_gateway.rs | 2 - .../src/commands/chain/migrate_to_gateway.rs | 2 - 16 files changed, 9 insertions(+), 213 deletions(-) diff --git a/core/bin/external_node/src/config/mod.rs b/core/bin/external_node/src/config/mod.rs index a08fbc0f0814..db2c6eac9cf6 100644 --- a/core/bin/external_node/src/config/mod.rs +++ b/core/bin/external_node/src/config/mod.rs @@ -1461,7 +1461,6 @@ impl From<&ExternalNodeConfig> for InternalApiConfig { Self { l1_chain_id: config.required.l1_chain_id, l2_chain_id: config.required.l2_chain_id, - settlement_layer_url: None, max_tx_size: config.optional.max_tx_size_bytes, estimate_gas_scale_factor: config.optional.estimate_gas_scale_factor, estimate_gas_acceptable_overestimation: config diff --git a/core/lib/config/src/configs/api.rs b/core/lib/config/src/configs/api.rs index ce0bd7d8d63e..1321f25e7604 100644 --- a/core/lib/config/src/configs/api.rs +++ b/core/lib/config/src/configs/api.rs @@ -224,9 +224,6 @@ pub struct Web3JsonRpcConfig { /// (hundreds or thousands RPS). #[serde(default)] pub extended_api_tracing: bool, - - #[serde(default)] - pub settlement_layer_url: Option, } impl Web3JsonRpcConfig { @@ -267,7 +264,6 @@ impl Web3JsonRpcConfig { whitelisted_tokens_for_aa: vec![], api_namespaces: None, extended_api_tracing: false, - settlement_layer_url: None, } } diff --git a/core/lib/config/src/testonly.rs b/core/lib/config/src/testonly.rs index 687224af0f84..5dfcca9ce4e1 100644 --- a/core/lib/config/src/testonly.rs +++ b/core/lib/config/src/testonly.rs @@ -116,7 +116,6 @@ impl Distribution for EncodeDist { api_namespaces: self .sample_opt(|| self.sample_range(rng).map(|_| self.sample(rng)).collect()), extended_api_tracing: self.sample(rng), - settlement_layer_url: self.sample(rng), } } } diff --git a/core/lib/dal/src/eth_sender_dal.rs b/core/lib/dal/src/eth_sender_dal.rs index bbfe72fd782d..10f77718ba38 100644 --- a/core/lib/dal/src/eth_sender_dal.rs +++ b/core/lib/dal/src/eth_sender_dal.rs @@ -8,14 +8,13 @@ use zksync_db_connection::{ }; use zksync_types::{ aggregated_operations::AggregatedActionType, - eth_sender::{BatchSettlementInfo, EthTx, EthTxBlobSidecar, TxHistory, TxHistoryToSend}, + eth_sender::{EthTx, EthTxBlobSidecar, TxHistory, TxHistoryToSend}, Address, L1BatchNumber, SLChainId, H256, U256, }; use crate::{ models::storage_eth_tx::{ L1BatchEthSenderStats, StorageEthTx, StorageTxHistory, StorageTxHistoryToSend, - StoredBatchSettlementInfo, }, Core, }; @@ -796,44 +795,6 @@ impl EthSenderDal<'_, '_> { Ok(()) } - - pub async fn get_batch_finalization_info( - &mut self, - batch_number: L1BatchNumber, - ) -> DalResult> { - let mut info = sqlx::query_as!( - StoredBatchSettlementInfo, - r#" - SELECT - number AS batch_number, - eth_txs.chain_id AS settlement_layer_id, - eth_txs_history.tx_hash AS settlement_layer_tx_hash - FROM - l1_batches - JOIN eth_txs ON l1_batches.eth_execute_tx_id = eth_txs.id - JOIN eth_txs_history - ON ( - eth_txs.id = eth_txs_history.eth_tx_id - AND eth_txs_history.confirmed_at IS NOT NULL - ) - WHERE - l1_batches.number = $1 - "#, - i64::from(batch_number.0) - ) - .instrument("get_batch_finalization_info") - .with_arg("batch_number", &batch_number) - .fetch_all(self.storage) - .await?; - - assert!( - info.len() <= 1, - "Batch number must be unique in the database {:#?}", - info - ); - - Ok(info.pop().and_then(Into::into)) - } } /// These methods should only be used for tests. diff --git a/core/lib/dal/src/models/storage_eth_tx.rs b/core/lib/dal/src/models/storage_eth_tx.rs index 4d49baa98e29..b4a124c5d455 100644 --- a/core/lib/dal/src/models/storage_eth_tx.rs +++ b/core/lib/dal/src/models/storage_eth_tx.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use sqlx::types::chrono::NaiveDateTime; use zksync_types::{ aggregated_operations::AggregatedActionType, - eth_sender::{BatchSettlementInfo, EthTx, TxHistory, TxHistoryToSend}, + eth_sender::{EthTx, TxHistory, TxHistoryToSend}, Address, L1BatchNumber, Nonce, SLChainId, H256, }; @@ -126,24 +126,3 @@ impl From for TxHistoryToSend { } } } - -#[derive(Debug)] -pub struct StoredBatchSettlementInfo { - pub batch_number: i64, - pub settlement_layer_id: Option, - pub settlement_layer_tx_hash: Option, -} - -impl From for Option { - fn from(info: StoredBatchSettlementInfo) -> Option { - let settlement_layer_id = info.settlement_layer_id?; - let settlement_layer_tx_hash = info.settlement_layer_tx_hash?; - - Some(BatchSettlementInfo { - batch_number: info.batch_number as u32, - settlement_layer_id: SLChainId(settlement_layer_id as u64), - settlement_layer_tx_hash: H256::from_str(&settlement_layer_tx_hash) - .expect("Incorrect hash"), - }) - } -} diff --git a/core/lib/env_config/src/api.rs b/core/lib/env_config/src/api.rs index 0ea24ebf00d4..ecc2343d49f4 100644 --- a/core/lib/env_config/src/api.rs +++ b/core/lib/env_config/src/api.rs @@ -97,7 +97,6 @@ mod tests { ], api_namespaces: Some(vec!["debug".to_string()]), extended_api_tracing: true, - settlement_layer_url: Some("http://127.0.0.1:9011".into()), }, prometheus: PrometheusConfig { listener_port: 3312, @@ -144,7 +143,6 @@ mod tests { API_WEB3_JSON_RPC_WEBSOCKET_REQUESTS_PER_MINUTE_LIMIT=10 API_WEB3_JSON_RPC_MEMPOOL_CACHE_SIZE=10000 API_WEB3_JSON_RPC_MEMPOOL_CACHE_UPDATE_INTERVAL=50 - API_WEB3_JSON_RPC_SETTLEMENT_LAYER_URL="http://127.0.0.1:9011" API_CONTRACT_VERIFICATION_PORT="3070" API_CONTRACT_VERIFICATION_URL="http://127.0.0.1:3070" API_WEB3_JSON_RPC_MAX_RESPONSE_BODY_SIZE_MB=10 diff --git a/core/lib/protobuf_config/src/api.rs b/core/lib/protobuf_config/src/api.rs index 9cfa73c28ac3..3db80c6d691a 100644 --- a/core/lib/protobuf_config/src/api.rs +++ b/core/lib/protobuf_config/src/api.rs @@ -151,7 +151,6 @@ impl ProtoRepr for proto::Web3JsonRpc { .context("whitelisted_tokens_for_aa")?, extended_api_tracing: self.extended_api_tracing.unwrap_or_default(), api_namespaces, - settlement_layer_url: self.settlement_layer_url.clone(), }) } @@ -218,7 +217,6 @@ impl ProtoRepr for proto::Web3JsonRpc { .collect(), extended_api_tracing: Some(this.extended_api_tracing), api_namespaces: this.api_namespaces.clone().unwrap_or_default(), - settlement_layer_url: this.settlement_layer_url.clone(), } } } diff --git a/core/lib/protobuf_config/src/proto/config/api.proto b/core/lib/protobuf_config/src/proto/config/api.proto index c97c4f3fbe29..89ba0a6bcd2c 100644 --- a/core/lib/protobuf_config/src/proto/config/api.proto +++ b/core/lib/protobuf_config/src/proto/config/api.proto @@ -42,7 +42,6 @@ message Web3JsonRpc { optional bool extended_api_tracing = 33; // optional, default false optional bool estimate_gas_optimize_search = 34; // optional, default false optional uint32 latest_values_max_block_lag = 35; // optional - optional string settlement_layer_url = 36; // optional reserved 15; reserved "l1_to_l2_transactions_compatibility_mode"; reserved 11; reserved "request_timeout"; diff --git a/core/lib/types/src/api/mod.rs b/core/lib/types/src/api/mod.rs index 06669f4c01e8..4a45756823c2 100644 --- a/core/lib/types/src/api/mod.rs +++ b/core/lib/types/src/api/mod.rs @@ -898,17 +898,6 @@ pub struct L1BatchDetails { pub base: BlockDetailsBase, } -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct L1ProcessingDetails { - pub commit_tx_hash: Option, - pub committed_at: Option>, - pub prove_tx_hash: Option, - pub proven_at: Option>, - pub execute_tx_hash: Option, - pub executed_at: Option>, -} - #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct StorageProof { diff --git a/core/lib/types/src/eth_sender.rs b/core/lib/types/src/eth_sender.rs index 7dd46c44ca34..e8e12993054f 100644 --- a/core/lib/types/src/eth_sender.rs +++ b/core/lib/types/src/eth_sender.rs @@ -93,10 +93,3 @@ pub struct TxHistoryToSend { pub signed_raw_tx: Vec, pub nonce: Nonce, } - -#[derive(Clone, Debug, Serialize, Deserialize)] -pub struct BatchSettlementInfo { - pub batch_number: u32, - pub settlement_layer_id: SLChainId, - pub settlement_layer_tx_hash: H256, -} diff --git a/core/lib/web3_decl/src/namespaces/zks.rs b/core/lib/web3_decl/src/namespaces/zks.rs index 78dc8f3d65f4..07a7cc4ff1c2 100644 --- a/core/lib/web3_decl/src/namespaces/zks.rs +++ b/core/lib/web3_decl/src/namespaces/zks.rs @@ -6,8 +6,7 @@ use jsonrpsee::proc_macros::rpc; use zksync_types::{ api::{ state_override::StateOverride, BlockDetails, BridgeAddresses, L1BatchDetails, - L1ProcessingDetails, L2ToL1LogProof, Proof, ProtocolVersion, TransactionDetailedResult, - TransactionDetails, + L2ToL1LogProof, Proof, ProtocolVersion, TransactionDetailedResult, TransactionDetails, }, fee::Fee, fee_model::{FeeParams, PubdataIndependentBatchFeeModelInput}, @@ -112,12 +111,6 @@ pub trait ZksNamespace { async fn get_l1_batch_details(&self, batch: L1BatchNumber) -> RpcResult>; - #[method(name = "getL1ProcessingDetails")] - async fn get_l1_processing_details( - &self, - batch: L1BatchNumber, - ) -> RpcResult>; - #[method(name = "getBytecodeByHash")] async fn get_bytecode_by_hash(&self, hash: H256) -> RpcResult>>; diff --git a/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs b/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs index a4998fec4ad0..21f3f5ae49e1 100644 --- a/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs +++ b/core/node/api_server/src/web3/backend_jsonrpsee/namespaces/zks.rs @@ -4,8 +4,8 @@ use zksync_multivm::interface::VmEvent; use zksync_types::{ api::{ state_override::StateOverride, ApiStorageLog, BlockDetails, BridgeAddresses, - L1BatchDetails, L1ProcessingDetails, L2ToL1LogProof, Log, Proof, ProtocolVersion, - TransactionDetailedResult, TransactionDetails, + L1BatchDetails, L2ToL1LogProof, Log, Proof, ProtocolVersion, TransactionDetailedResult, + TransactionDetails, }, fee::Fee, fee_model::{FeeParams, PubdataIndependentBatchFeeModelInput}, @@ -148,15 +148,6 @@ impl ZksNamespaceServer for ZksNamespace { .map_err(|err| self.current_method().map_err(err)) } - async fn get_l1_processing_details( - &self, - batch_number: L1BatchNumber, - ) -> RpcResult> { - self.get_l1_processing_details_impl(batch_number) - .await - .map_err(|err| self.current_method().map_err(err)) - } - async fn get_bytecode_by_hash(&self, hash: H256) -> RpcResult>> { self.get_bytecode_by_hash_impl(hash) .await diff --git a/core/node/api_server/src/web3/namespaces/zks.rs b/core/node/api_server/src/web3/namespaces/zks.rs index 7cdc5f69127c..b272f7c443e9 100644 --- a/core/node/api_server/src/web3/namespaces/zks.rs +++ b/core/node/api_server/src/web3/namespaces/zks.rs @@ -11,8 +11,7 @@ use zksync_types::{ address_to_h256, api::{ state_override::StateOverride, BlockDetails, BridgeAddresses, GetLogsFilter, - L1BatchDetails, L1ProcessingDetails, L2ToL1LogProof, Proof, ProtocolVersion, StorageProof, - TransactionDetails, + L1BatchDetails, L2ToL1LogProof, Proof, ProtocolVersion, StorageProof, TransactionDetails, }, fee::Fee, fee_model::{FeeParams, PubdataIndependentBatchFeeModelInput}, @@ -24,14 +23,12 @@ use zksync_types::{ transaction_request::CallRequest, utils::storage_key_for_standard_token_balance, web3::Bytes, - AccountTreeId, L1BatchNumber, L2BlockNumber, L2ChainId, ProtocolVersionId, StorageKey, - Transaction, L1_MESSENGER_ADDRESS, L2_BASE_TOKEN_ADDRESS, - REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE, U256, U64, + AccountTreeId, L1BatchNumber, L2BlockNumber, ProtocolVersionId, StorageKey, Transaction, + L1_MESSENGER_ADDRESS, L2_BASE_TOKEN_ADDRESS, REQUIRED_L1_TO_L2_GAS_PER_PUBDATA_BYTE, U256, U64, }; use zksync_web3_decl::{ - client::{Client, L2}, error::{ClientRpcContext, Web3Error}, - namespaces::{EthNamespaceClient, ZksNamespaceClient}, + namespaces::ZksNamespaceClient, types::{Address, Token, H256}, }; @@ -563,96 +560,6 @@ impl ZksNamespace { .map_err(DalError::generalize)?) } - pub async fn get_l1_processing_details_impl( - &self, - batch_number: L1BatchNumber, - ) -> Result, Web3Error> { - let mut storage = self.state.acquire_connection().await?; - self.state - .start_info - .ensure_not_pruned(batch_number, &mut storage) - .await?; - - let batch_details = storage - .blocks_web3_dal() - .get_l1_batch_details(batch_number) - .await - .map_err(DalError::generalize)?; - - let Some(batch_details) = batch_details else { - return Ok(None); - }; - - let settlement_info = storage - .eth_sender_dal() - .get_batch_finalization_info(batch_number) - .await - .map_err(DalError::generalize)?; - - let Some(info) = settlement_info else { - return Ok(None); - }; - - // FIXME: this method should eventually also provide data about L1 commit and L1 prove. - - let (execute_tx_hash, executed_at) = - if info.settlement_layer_id.0 == self.state.api_config.l1_chain_id.0 { - ( - batch_details.base.execute_tx_hash, - batch_details.base.executed_at, - ) - } else { - // It is sl-based chain, we need to query the batch info from the SL - // Create a client for pinging the RPC. - let client: Client = Client::http( - self.state - .api_config - .settlement_layer_url - .clone() - .unwrap() - .parse() - .unwrap(), - )? - .for_network(L2::from(L2ChainId(self.state.api_config.l1_chain_id.0))) - .build(); - - let info = client - .get_transaction_receipt(info.settlement_layer_tx_hash) - .await - .expect("Failed to query the SL"); - let Some(info) = info else { - return Ok(None); - }; - let sl_l1_batch_number = info.l1_batch_number; - let Some(sl_l1_batch_number) = sl_l1_batch_number else { - return Ok(None); - }; - let batch_details = client - .get_l1_batch_details(L1BatchNumber(sl_l1_batch_number.as_u32())) - .await - .expect("Failed to query the SL2"); - let Some(batch_details) = batch_details else { - return Ok(None); - }; - - ( - batch_details.base.execute_tx_hash, - batch_details.base.executed_at, - ) - }; - - let details = L1ProcessingDetails { - commit_tx_hash: None, - committed_at: None, - prove_tx_hash: None, - proven_at: None, - execute_tx_hash, - executed_at, - }; - - Ok(Some(details)) - } - pub async fn get_bytecode_by_hash_impl( &self, hash: H256, diff --git a/core/node/api_server/src/web3/state.rs b/core/node/api_server/src/web3/state.rs index 2cece3bbf15f..bdefd79b6dd6 100644 --- a/core/node/api_server/src/web3/state.rs +++ b/core/node/api_server/src/web3/state.rs @@ -102,7 +102,6 @@ pub struct InternalApiConfig { /// Chain ID of the L1 network. Note, that it may be different from the chain id of the settlement layer. pub l1_chain_id: L1ChainId, pub l2_chain_id: L2ChainId, - pub settlement_layer_url: Option, pub max_tx_size: usize, pub estimate_gas_scale_factor: f64, pub estimate_gas_acceptable_overestimation: u32, @@ -132,7 +131,6 @@ impl InternalApiConfig { Self { l1_chain_id: genesis_config.l1_chain_id, l2_chain_id: genesis_config.l2_chain_id, - settlement_layer_url: web3_config.settlement_layer_url.clone(), max_tx_size: web3_config.max_tx_size, estimate_gas_scale_factor: web3_config.estimate_gas_scale_factor, estimate_gas_acceptable_overestimation: web3_config diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/migrate_from_gateway.rs b/zkstack_cli/crates/zkstack/src/commands/chain/migrate_from_gateway.rs index 24d635e8b043..bd3c88c7d478 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/migrate_from_gateway.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/migrate_from_gateway.rs @@ -192,7 +192,6 @@ pub async fn run(args: MigrateFromGatewayArgs, shell: &Shell) -> anyhow::Result< let mut general_config = chain_config.get_general_config().unwrap(); let eth_config = general_config.eth.as_mut().context("eth")?; - let api_config = general_config.api_config.as_mut().context("api config")?; eth_config .gas_adjuster @@ -224,7 +223,6 @@ pub async fn run(args: MigrateFromGatewayArgs, shell: &Shell) -> anyhow::Result< .as_mut() .expect("sender") .max_eth_tx_data_size = 120_000; - api_config.web3_json_rpc.settlement_layer_url = Some(l1_url); general_config.save_with_base_path(shell, chain_config.configs.clone())?; Ok(()) diff --git a/zkstack_cli/crates/zkstack/src/commands/chain/migrate_to_gateway.rs b/zkstack_cli/crates/zkstack/src/commands/chain/migrate_to_gateway.rs index e70523d37b43..5beedc894c56 100644 --- a/zkstack_cli/crates/zkstack/src/commands/chain/migrate_to_gateway.rs +++ b/zkstack_cli/crates/zkstack/src/commands/chain/migrate_to_gateway.rs @@ -382,7 +382,6 @@ pub async fn run(args: MigrateToGatewayArgs, shell: &Shell) -> anyhow::Result<() let mut general_config = chain_config.get_general_config().unwrap(); let eth_config = general_config.eth.as_mut().context("eth")?; - let api_config = general_config.api_config.as_mut().context("api config")?; eth_config .gas_adjuster @@ -414,7 +413,6 @@ pub async fn run(args: MigrateToGatewayArgs, shell: &Shell) -> anyhow::Result<() .as_mut() .expect("sender") .max_eth_tx_data_size = 550_000; - api_config.web3_json_rpc.settlement_layer_url = Some(gateway_url); general_config.save_with_base_path(shell, chain_config.configs.clone())?;