From c22ce639e08f78b5fd12f2ba7f1e419e8849b1ca Mon Sep 17 00:00:00 2001 From: Alex Ostrovski Date: Thu, 9 May 2024 10:51:55 +0300 Subject: [PATCH] fix(eth-client): Fix call error detection (#1890) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What ❔ Fixes call error detection in `ensure_l1_batch_commit_data_generation_mode()`. ## Why ❔ Ethereum client is still broken fort the mainnet EN (where the L1 contracts are not updated yet). ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`. --- core/lib/zksync_core/src/utils/mod.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/lib/zksync_core/src/utils/mod.rs b/core/lib/zksync_core/src/utils/mod.rs index 2235792fce74..f2364dd1eff0 100644 --- a/core/lib/zksync_core/src/utils/mod.rs +++ b/core/lib/zksync_core/src/utils/mod.rs @@ -11,7 +11,7 @@ use async_trait::async_trait; use tokio::sync::watch; use zksync_config::configs::chain::L1BatchCommitDataGeneratorMode; use zksync_dal::{Connection, ConnectionPool, Core, CoreDal}; -use zksync_eth_client::{CallFunctionArgs, ContractError, Error as EthClientError, EthInterface}; +use zksync_eth_client::{CallFunctionArgs, ClientError, Error as EthClientError, EthInterface}; use zksync_types::{Address, L1BatchNumber, ProtocolVersionId}; /// Fallible and async predicate for binary search. @@ -192,8 +192,8 @@ pub async fn ensure_l1_batch_commit_data_generation_mode( // Getters contract does not support getPubdataPricingMode method. // This case is accepted for backwards compatibility with older contracts, but emits a // warning in case the wrong contract address was passed by the caller. - Err(EthClientError::Contract(ContractError::Function(_))) => { - tracing::warn!("Getters contract does not support getPubdataPricingMode method"); + Err(err @ EthClientError::EthereumGateway(ClientError::Call(_))) => { + tracing::warn!("Getters contract does not support getPubdataPricingMode method: {err}"); Ok(()) } Err(err) => anyhow::bail!(err), @@ -204,6 +204,7 @@ pub async fn ensure_l1_batch_commit_data_generation_mode( mod tests { use std::{mem, sync::Mutex}; + use jsonrpsee::types::ErrorObject; use zksync_eth_client::{clients::MockEthereum, ClientError}; use zksync_node_genesis::{insert_genesis_batch, GenesisParams}; use zksync_types::{ethabi, U256}; @@ -268,8 +269,8 @@ mod tests { } fn mock_ethereum_with_legacy_contract() -> MockEthereum { - let abi_err = ethabi::Error::InvalidName("getPubdataPricingMode".into()); - let err = EthClientError::Contract(ContractError::Function(abi_err)); + let call_err = ErrorObject::owned(3, "execution reverted: F", None::<()>); + let err = EthClientError::EthereumGateway(ClientError::Call(call_err)); mock_ethereum(ethabi::Token::Uint(U256::zero()), Some(err)) }