chore: Revert "feat(hyp-ethereum): gas escalator middleware (#3852)" (#4098)

This reverts commit c3c002a8fe.

### Description

The gas escalator took up to 28gb of memory, and even though it was only
ever released on RC, it must have taken up too many cluster resources,
ending up starving the `hyperlane` relayer. Reverting for now until we
have a better idea

### Drive-by changes

<!--
Are there any minor or drive-by changes also included?
-->

### Related issues

<!--
- Fixes #[issue number here]
-->

### Backward compatibility

<!--
Are these changes backward compatible? Are there any infrastructure
implications, e.g. changes that would prohibit deploying older commits
using this infra tooling?

Yes/No
-->

### Testing

<!--
What kind of testing have these changes undergone?

None/Manual/Unit Tests
-->
pull/4101/head
Daniel Savu 5 months ago committed by GitHub
parent 8c8f39abfe
commit a5e5f70610
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 22
      rust/Cargo.lock
  2. 10
      rust/Cargo.toml
  3. 47
      rust/chains/hyperlane-ethereum/src/rpc_clients/trait_builder.rs
  4. 3
      rust/chains/hyperlane-ethereum/src/tx.rs
  5. 1
      rust/ethers-prometheus/src/middleware/mod.rs
  6. 7
      rust/utils/run-locally/src/invariants.rs

22
rust/Cargo.lock generated

@ -2725,7 +2725,7 @@ dependencies = [
[[package]]
name = "ethers"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"ethers-addressbook",
"ethers-contract",
@ -2739,7 +2739,7 @@ dependencies = [
[[package]]
name = "ethers-addressbook"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"ethers-core",
"once_cell",
@ -2750,7 +2750,7 @@ dependencies = [
[[package]]
name = "ethers-contract"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"ethers-contract-abigen",
"ethers-contract-derive",
@ -2768,7 +2768,7 @@ dependencies = [
[[package]]
name = "ethers-contract-abigen"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"Inflector",
"cfg-if",
@ -2792,7 +2792,7 @@ dependencies = [
[[package]]
name = "ethers-contract-derive"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"ethers-contract-abigen",
"ethers-core",
@ -2806,7 +2806,7 @@ dependencies = [
[[package]]
name = "ethers-core"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"arrayvec",
"bytes",
@ -2836,7 +2836,7 @@ dependencies = [
[[package]]
name = "ethers-etherscan"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"ethers-core",
"getrandom 0.2.12",
@ -2852,7 +2852,7 @@ dependencies = [
[[package]]
name = "ethers-middleware"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"async-trait",
"auto_impl 0.5.0",
@ -2900,7 +2900,7 @@ dependencies = [
[[package]]
name = "ethers-providers"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"async-trait",
"auto_impl 1.1.0",
@ -2936,7 +2936,7 @@ dependencies = [
[[package]]
name = "ethers-signers"
version = "1.0.2"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-06-27-2#df3510cdfdd18ee6e6e9b0d7bad61f405c8abc49"
source = "git+https://github.com/hyperlane-xyz/ethers-rs?tag=2024-04-25#361b69b9561e11eb3cf8000a51de1985e2571785"
dependencies = [
"async-trait",
"coins-bip32",
@ -4086,7 +4086,7 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"socket2 0.4.10",
"socket2 0.5.5",
"tokio",
"tower-service",
"tracing",

@ -197,27 +197,27 @@ cosmwasm-schema = "1.2.7"
[workspace.dependencies.ethers]
features = []
git = "https://github.com/hyperlane-xyz/ethers-rs"
tag = "2024-06-27-2"
tag = "2024-04-25"
[workspace.dependencies.ethers-contract]
features = ["legacy"]
git = "https://github.com/hyperlane-xyz/ethers-rs"
tag = "2024-06-27-2"
tag = "2024-04-25"
[workspace.dependencies.ethers-core]
features = []
git = "https://github.com/hyperlane-xyz/ethers-rs"
tag = "2024-06-27-2"
tag = "2024-04-25"
[workspace.dependencies.ethers-providers]
features = []
git = "https://github.com/hyperlane-xyz/ethers-rs"
tag = "2024-06-27-2"
tag = "2024-04-25"
[workspace.dependencies.ethers-signers]
features = ["aws"]
git = "https://github.com/hyperlane-xyz/ethers-rs"
tag = "2024-06-27-2"
tag = "2024-04-25"
[patch.crates-io.curve25519-dalek]
branch = "v3.2.2-relax-zeroize"

@ -3,7 +3,6 @@ use std::sync::Arc;
use std::time::Duration;
use async_trait::async_trait;
use ethers::middleware::gas_escalator::{Frequency, GasEscalatorMiddleware, GeometricGasPrice};
use ethers::middleware::gas_oracle::{
GasCategory, GasOracle, GasOracleMiddleware, Polygon, ProviderOracle,
};
@ -11,8 +10,6 @@ use ethers::prelude::{
Http, JsonRpcClient, Middleware, NonceManagerMiddleware, Provider, Quorum, QuorumProvider,
SignerMiddleware, WeightedProvider, Ws, WsClientError,
};
use ethers::types::Address;
use ethers_signers::Signer;
use hyperlane_core::rpc_clients::FallbackProvider;
use reqwest::{Client, Url};
use thiserror::Error;
@ -213,19 +210,10 @@ pub trait BuildableWithProvider {
M: Middleware + 'static,
{
Ok(if let Some(signer) = signer {
// The signing provider is used for sending txs, which may end up stuck in the mempool due to
// gas pricing issues. We first wrap the provider in a signer middleware, to sign any new txs sent by the gas escalator middleware.
// We keep nonce manager as the outermost middleware, so that every new tx with a higher gas price reuses the same nonce.
let signing_provider = wrap_with_signer(provider, signer.clone())
let signing_provider = wrap_with_signer(provider, signer)
.await
.map_err(ChainCommunicationError::from_other)?;
let gas_escalator_provider = wrap_with_gas_escalator(signing_provider);
let nonce_manager_provider =
wrap_with_nonce_manager(gas_escalator_provider, signer.address())
.await
.map_err(ChainCommunicationError::from_other)?;
self.build_with_provider(nonce_manager_provider, conn, locator)
self.build_with_provider(signing_provider, conn, locator)
} else {
self.build_with_provider(provider, conn, locator)
}
@ -246,19 +234,15 @@ pub trait BuildableWithProvider {
async fn wrap_with_signer<M: Middleware>(
provider: M,
signer: Signers,
) -> Result<SignerMiddleware<M, Signers>, M::Error> {
) -> Result<SignerMiddleware<NonceManagerMiddleware<M>, Signers>, M::Error> {
let provider_chain_id = provider.get_chainid().await?;
let signer = ethers::signers::Signer::with_chain_id(signer, provider_chain_id.as_u64());
Ok(SignerMiddleware::new(provider, signer))
}
let address = ethers::prelude::Signer::address(&signer);
let provider = NonceManagerMiddleware::new(provider, address);
async fn wrap_with_nonce_manager<M: Middleware>(
provider: M,
signer_address: Address,
) -> Result<NonceManagerMiddleware<M>, M::Error> {
let nonce_manager_provider = NonceManagerMiddleware::new(provider, signer_address);
Ok(nonce_manager_provider)
let signing_provider = SignerMiddleware::new(provider, signer);
Ok(signing_provider)
}
fn build_polygon_gas_oracle(chain: ethers_core::types::Chain) -> ChainResult<Box<dyn GasOracle>> {
@ -290,20 +274,3 @@ where
};
Ok(GasOracleMiddleware::new(provider, gas_oracle))
}
fn wrap_with_gas_escalator<M>(provider: M) -> GasEscalatorMiddleware<M>
where
M: Middleware + 'static,
{
// Increase the gas price by 12.5% every 60 seconds
// (These are the default values from ethers doc comments)
const COEFFICIENT: f64 = 1.125;
const EVERY_SECS: u64 = 60u64;
// 550 gwei is the limit we also use for polygon, so we reuse for consistency
const MAX_GAS_PRICE: u128 = 550 * 10u128.pow(9);
let escalator = GeometricGasPrice::new(COEFFICIENT, EVERY_SECS, MAX_GAS_PRICE.into());
// Check the status of sent txs every eth block or so. The alternative is to subscribe to new blocks and check then,
// which adds unnecessary load on the provider.
const FREQUENCY: Frequency = Frequency::Duration(Duration::from_secs(12).as_millis() as _);
GasEscalatorMiddleware::new(provider, escalator, FREQUENCY)
}

@ -44,7 +44,8 @@ where
.cloned()
.unwrap_or_else(|| NameOrAddress::Address(Default::default()));
info!(?to, %data, tx=?tx.tx, "Dispatching transaction");
info!(?to, %data, "Dispatching transaction");
// We can set the gas higher here!
let dispatch_fut = tx.send();
let dispatched = dispatch_fut
.await?

@ -227,6 +227,7 @@ impl<M: Middleware> Middleware for PrometheusMiddleware<M> {
) -> Result<PendingTransaction<'_, Self::Provider>, Self::Error> {
let start = Instant::now();
let tx: TypedTransaction = tx.into();
let chain = {
let data = self.conf.read().await;
chain_name(&data.chain).to_owned()

@ -80,12 +80,9 @@ pub fn termination_invariants_met(
// EDIT: Having had a quick look, it seems like there are some legitimate reverts happening in the confirm step
// (`Transaction attempting to process message either reverted or was reorged`)
// in which case more gas expenditure logs than messages are expected.
let gas_expenditure_log_count = log_counts.get(GAS_EXPENDITURE_LOG_MESSAGE).unwrap();
assert!(
gas_expenditure_log_count >= &total_messages_expected,
"Didn't record gas payment for all delivered messages. Got {} gas payment logs, expected at least {}",
gas_expenditure_log_count,
total_messages_expected
log_counts.get(GAS_EXPENDITURE_LOG_MESSAGE).unwrap() >= &total_messages_expected,
"Didn't record gas payment for all delivered messages"
);
// These tests check that we fixed https://github.com/hyperlane-xyz/hyperlane-monorepo/issues/3915, where some logs would not show up
assert!(

Loading…
Cancel
Save