From 630ad40a92798b89dd5c0b4702a0d81fb0861294 Mon Sep 17 00:00:00 2001 From: Daniel Savu <23065004+daniel-savu@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:29:29 +0100 Subject: [PATCH] wip --- .../src/rpc_clients/trait_builder.rs | 23 ++++++++++++------- rust/chains/hyperlane-ethereum/src/tx.rs | 3 +-- rust/ethers-prometheus/src/middleware/mod.rs | 13 ++++++++++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/rust/chains/hyperlane-ethereum/src/rpc_clients/trait_builder.rs b/rust/chains/hyperlane-ethereum/src/rpc_clients/trait_builder.rs index d522b40df..d5b327b70 100644 --- a/rust/chains/hyperlane-ethereum/src/rpc_clients/trait_builder.rs +++ b/rust/chains/hyperlane-ethereum/src/rpc_clients/trait_builder.rs @@ -218,12 +218,14 @@ pub trait BuildableWithProvider { // gas pricing issues. So we first wrap the provider in a gas escalator middleware. // - When txs reach the gas escalator, they will already have been signed by the signer middleware, // so they are ready to be retried + let signing_provider = wrap_with_signer(provider, signer.clone()).await; let gas_escalator_provider = - wrap_with_gas_escalator(provider, &conn.transaction_overrides); - let signing_provider = wrap_with_signer(gas_escalator_provider, signer) + wrap_with_gas_escalator(signing_provider, &conn.transaction_overrides); + let nonce_manager_provider = wrap_with_nonce_manager(gas_escalator_provider, signer) .await .map_err(ChainCommunicationError::from_other)?; - self.build_with_provider(signing_provider, conn, locator) + + self.build_with_provider(nonce_manager_provider, conn, locator) } else { self.build_with_provider(provider, conn, locator) } @@ -244,15 +246,20 @@ pub trait BuildableWithProvider { async fn wrap_with_signer( provider: M, signer: Signers, -) -> Result, Signers>, M::Error> { +) -> SignerMiddleware { + SignerMiddleware::new(provider, signer) +} + +async fn wrap_with_nonce_manager( + provider: M, + signer: Signers, +) -> Result, M::Error> { let provider_chain_id = provider.get_chainid().await?; let signer = ethers::signers::Signer::with_chain_id(signer, provider_chain_id.as_u64()); let address = ethers::prelude::Signer::address(&signer); - let provider = NonceManagerMiddleware::new(provider, address); - - let signing_provider = SignerMiddleware::new(provider, signer); - Ok(signing_provider) + let nonce_manager_provider = NonceManagerMiddleware::new(provider, address); + Ok(nonce_manager_provider) } fn build_polygon_gas_oracle(chain: ethers_core::types::Chain) -> ChainResult> { diff --git a/rust/chains/hyperlane-ethereum/src/tx.rs b/rust/chains/hyperlane-ethereum/src/tx.rs index 5ec0ebd38..f45a9ab0b 100644 --- a/rust/chains/hyperlane-ethereum/src/tx.rs +++ b/rust/chains/hyperlane-ethereum/src/tx.rs @@ -44,8 +44,7 @@ where .cloned() .unwrap_or_else(|| NameOrAddress::Address(Default::default())); - info!(?to, %data, "Dispatching transaction"); - // We can set the gas higher here! + info!(?to, %data, tx=?tx.tx, "Dispatching transaction"); let dispatch_fut = tx.send(); let dispatched = dispatch_fut .await? diff --git a/rust/ethers-prometheus/src/middleware/mod.rs b/rust/ethers-prometheus/src/middleware/mod.rs index 592e6a200..acb97dabb 100644 --- a/rust/ethers-prometheus/src/middleware/mod.rs +++ b/rust/ethers-prometheus/src/middleware/mod.rs @@ -227,7 +227,18 @@ impl Middleware for PrometheusMiddleware { ) -> Result, Self::Error> { let start = Instant::now(); let tx: TypedTransaction = tx.into(); - + // print tx type based on enum variants + match tx { + TypedTransaction::Legacy(_) => { + println!("~~~ sending Legacy transaction"); + } + TypedTransaction::Eip2930(_) => { + println!("~~~ sending EIP-2930 transaction"); + } + TypedTransaction::Eip1559(_) => { + println!("~~~ sending EIP-1559 transaction"); + } + } let chain = { let data = self.conf.read().await; chain_name(&data.chain).to_owned()