Skip to content

Commit

Permalink
Merge branch 'main' into kunal/ica-v3-gas-router
Browse files Browse the repository at this point in the history
  • Loading branch information
aroralanuk authored Mar 25, 2024
2 parents e020ee8 + d535e66 commit 09938ed
Show file tree
Hide file tree
Showing 21 changed files with 473 additions and 416 deletions.
63 changes: 61 additions & 2 deletions rust/chains/hyperlane-ethereum/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ use std::time::Duration;
use ethers::{
abi::Detokenize,
prelude::{NameOrAddress, TransactionReceipt},
providers::ProviderError,
types::Eip1559TransactionRequest,
};
use ethers_contract::builders::ContractCall;
use ethers_core::types::BlockNumber;
use ethers_core::{
types::{BlockNumber, U256 as EthersU256},
utils::{
eip1559_default_estimator, EIP1559_FEE_ESTIMATION_PAST_BLOCKS,
EIP1559_FEE_ESTIMATION_REWARD_PERCENTILE,
},
};
use hyperlane_core::{utils::bytes_to_hex, ChainCommunicationError, ChainResult, H256, U256};
use tracing::{error, info};

Expand Down Expand Up @@ -84,10 +91,22 @@ where
.saturating_add(U256::from(GAS_ESTIMATE_BUFFER).into())
.into()
};
let Ok((max_fee, max_priority_fee)) = provider.estimate_eip1559_fees(None).await else {

let Ok((base_fee, max_fee, max_priority_fee)) = estimate_eip1559_fees(provider, None).await
else {
// Is not EIP 1559 chain
return Ok(tx.gas(gas_limit));
};

// If the base fee is zero, just treat the chain as a non-EIP-1559 chain.
// This is useful for BSC, where the base fee is zero, there's a minimum gas price
// generally enforced by nodes of 3 gwei, but EIP 1559 estimation suggests a priority
// fee lower than 3 gwei because of privileged transactions being included by block
// producers that have a lower priority fee.
if base_fee.is_zero() {
return Ok(tx.gas(gas_limit));
}

// Is EIP 1559 chain
let mut request = Eip1559TransactionRequest::new();
if let Some(from) = tx.tx.from() {
Expand All @@ -109,6 +128,46 @@ where
Ok(eip_1559_tx.gas(gas_limit))
}

type FeeEstimator = fn(EthersU256, Vec<Vec<EthersU256>>) -> (EthersU256, EthersU256);

/// Pretty much a copy of the logic in ethers-rs (https://github.com/hyperlane-xyz/ethers-rs/blob/c9ced035628da59376c369be035facda1648577a/ethers-providers/src/provider.rs#L478)
/// but returns the base fee as well as the max fee and max priority fee.
/// Gets a heuristic recommendation of max fee per gas and max priority fee per gas for
/// EIP-1559 compatible transactions.
async fn estimate_eip1559_fees<M>(
provider: Arc<M>,
estimator: Option<FeeEstimator>,
) -> ChainResult<(EthersU256, EthersU256, EthersU256)>
where
M: Middleware + 'static,
{
let base_fee_per_gas = provider
.get_block(BlockNumber::Latest)
.await
.map_err(ChainCommunicationError::from_other)?
.ok_or_else(|| ProviderError::CustomError("Latest block not found".into()))?
.base_fee_per_gas
.ok_or_else(|| ProviderError::CustomError("EIP-1559 not activated".into()))?;

let fee_history = provider
.fee_history(
EIP1559_FEE_ESTIMATION_PAST_BLOCKS,
BlockNumber::Latest,
&[EIP1559_FEE_ESTIMATION_REWARD_PERCENTILE],
)
.await
.map_err(ChainCommunicationError::from_other)?;

// use the provided fee estimator function, or fallback to the default implementation.
let (max_fee_per_gas, max_priority_fee_per_gas) = if let Some(es) = estimator {
es(base_fee_per_gas, fee_history.reward)
} else {
eip1559_default_estimator(base_fee_per_gas, fee_history.reward)
};

Ok((base_fee_per_gas, max_fee_per_gas, max_priority_fee_per_gas))
}

pub(crate) async fn call_with_lag<M, T>(
call: ethers::contract::builders::ContractCall<M, T>,
provider: &M,
Expand Down
154 changes: 77 additions & 77 deletions rust/config/mainnet3_config.json

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions rust/config/testnet4_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"http": "https://alfajores-forno.celo-testnet.org"
}
],
"merkleRootMultisigIsmFactory": "0xa9C7e306C0941896CA1fd528aA59089571D8D67E",
"messageIdMultisigIsmFactory": "0xC1b8c0e56D6a34940Ee2B86172450B54AFd633A7",
"aggregationIsmFactory": "0x4bE8AC22f506B1504C93C3A5b1579C5e7c550D9C",
"aggregationHookFactory": "0x71bB34Ee833467443628CEdFAA188B2387827Cee",
"staticMerkleRootMultisigIsmFactory": "0xa9C7e306C0941896CA1fd528aA59089571D8D67E",
"staticMessageIdMultisigIsmFactory": "0xC1b8c0e56D6a34940Ee2B86172450B54AFd633A7",
"staticAggregationIsmFactory": "0x4bE8AC22f506B1504C93C3A5b1579C5e7c550D9C",
"staticAggregationHookFactory": "0x71bB34Ee833467443628CEdFAA188B2387827Cee",
"proxyAdmin": "0x4eDBf5846D973c53AF478cf62aB5bC92807521e3",
"mailbox": "0xEf9F292fcEBC3848bF4bB92a96a04F9ECBb78E59",
"validatorAnnounce": "0x3726EE36a2A9e11a40d1ffD7D9A1A16e0154cDA0",
Expand All @@ -51,7 +51,7 @@
"fallbackRoutingHook": "0x3528B1aeF3a3d29E0eae90ad777A2b4A6a48aC3F",
"testRecipient": "0x6489d13AcAd3B8dce4c5B31f375DE4f9451E7b38",
"testTokenRecipient": "0x92dC0a76452a9D9358D2d2dEd8CddA209DF67c45",
"routingIsmFactory": "0x30d9A03762431F8A917a0C469E7A62Bf55092Ca6",
"domainRoutingIsmFactory": "0x30d9A03762431F8A917a0C469E7A62Bf55092Ca6",
"index": {
"from": 20231908
}
Expand Down Expand Up @@ -92,10 +92,10 @@
"transactionOverrides": {
"gasPrice": 80000000000
},
"merkleRootMultisigIsmFactory": "0x3E235B90197E1D6b5DB5ad5aD49f2c1ED6406382",
"messageIdMultisigIsmFactory": "0x0D96aF0c01c4bbbadaaF989Eb489c8783F35B763",
"aggregationIsmFactory": "0x40613dE82d672605Ab051C64079022Bb4F8bDE4f",
"aggregationHookFactory": "0xa1145B39F1c7Ef9aA593BC1DB1634b00CC020942",
"staticMerkleRootMultisigIsmFactory": "0x3E235B90197E1D6b5DB5ad5aD49f2c1ED6406382",
"staticMessageIdMultisigIsmFactory": "0x0D96aF0c01c4bbbadaaF989Eb489c8783F35B763",
"staticAggregationIsmFactory": "0x40613dE82d672605Ab051C64079022Bb4F8bDE4f",
"staticAggregationHookFactory": "0xa1145B39F1c7Ef9aA593BC1DB1634b00CC020942",
"proxyAdmin": "0xb12282d2E838Aa5f2A4F9Ee5f624a77b7199A078",
"storageGasOracle": "0x124EBCBC018A5D4Efe639f02ED86f95cdC3f6498",
"interchainGasPaymaster": "0x0dD20e410bdB95404f71c5a4e7Fa67B892A5f949",
Expand Down Expand Up @@ -144,10 +144,10 @@
}
}
],
"merkleRootMultisigIsmFactory": "0x93F50Ac4E5663DAAb03508008d592f6260964f62",
"messageIdMultisigIsmFactory": "0x90e1F9918F304645e4F6324E5C0EAc70138C84Ce",
"aggregationIsmFactory": "0xF588129ed84F219A1f0f921bE7Aa1B2176516858",
"aggregationHookFactory": "0x99554CC33cBCd6EDDd2f3fc9c7C9194Cb3b5df1E",
"staticMerkleRootMultisigIsmFactory": "0x93F50Ac4E5663DAAb03508008d592f6260964f62",
"staticMessageIdMultisigIsmFactory": "0x90e1F9918F304645e4F6324E5C0EAc70138C84Ce",
"staticAggregationIsmFactory": "0xF588129ed84F219A1f0f921bE7Aa1B2176516858",
"staticAggregationHookFactory": "0x99554CC33cBCd6EDDd2f3fc9c7C9194Cb3b5df1E",
"proxyAdmin": "0x378dA02f7dC3c23A8B5ecE32b8056CdF01e8d477",
"mailbox": "0x5b6CFf85442B851A8e6eaBd2A4E4507B5135B3B0",
"validatorAnnounce": "0x4f7179A691F8a684f56cF7Fed65171877d30739a",
Expand All @@ -159,7 +159,7 @@
"fallbackRoutingHook": "0xc684f7F50DB4b2563218512e021fBdd0BeD6b57E",
"testRecipient": "0x44a7e1d76fD8AfA244AdE7278336E3D5C658D398",
"testTokenRecipient": "0x9CC10c844B3Bbae2444E39991aB027C4A05D1F2e",
"routingIsmFactory": "0x683a81E0e1a238dcA7341e04c08d3bba6f0Cb74f",
"domainRoutingIsmFactory": "0x683a81E0e1a238dcA7341e04c08d3bba6f0Cb74f",
"index": {
"from": 26503317
}
Expand Down Expand Up @@ -202,10 +202,10 @@
"maxFeePerGas": 150000000000,
"maxPriorityFeePerGas": 40000000000
},
"merkleRootMultisigIsmFactory": "0xda0780ed3eE577EfE0B856E00f983bF231603307",
"messageIdMultisigIsmFactory": "0x23c2483ab814177bA79DCDCb5dFA1B105387AAB1",
"aggregationIsmFactory": "0x54b0d9AB6a99E9C9425D20fa4D9eE9dbf067e886",
"aggregationHookFactory": "0x54CA9De95B37365909364672D363D2ecFC4e1Af4",
"staticMerkleRootMultisigIsmFactory": "0xda0780ed3eE577EfE0B856E00f983bF231603307",
"staticMessageIdMultisigIsmFactory": "0x23c2483ab814177bA79DCDCb5dFA1B105387AAB1",
"staticAggregationIsmFactory": "0x54b0d9AB6a99E9C9425D20fa4D9eE9dbf067e886",
"staticAggregationHookFactory": "0x54CA9De95B37365909364672D363D2ecFC4e1Af4",
"merkleTreeHook": "0x9AF85731EDd41E2E50F81Ef8a0A69D2fB836EDf9",
"proxyAdmin": "0xa99aD6B1c10E92DB8d3510f1865A6d2Ab43EAd58",
"storageGasOracle": "0xBEd8Fd6d5c6cBd878479C25f4725C7c842a43821",
Expand All @@ -217,7 +217,7 @@
"fallbackRoutingHook": "0x31191BA83143b4745745389fEe64990c65F36829",
"testRecipient": "0xF45A4D54223DA32bf7b5D43a9a460Ef3C94C713B",
"testTokenRecipient": "0x57d098e6952B6C1c85Ce0B68C9Deada3dCf7D05A",
"routingIsmFactory": "0x832Ea28749C93C05E5AaF8207E4e61Bd56aE3877",
"domainRoutingIsmFactory": "0x832Ea28749C93C05E5AaF8207E4e61Bd56aE3877",
"index": {
"from": 40879305
}
Expand Down Expand Up @@ -257,11 +257,11 @@
"transactionOverrides": {
"gasPrice": 1000000
},
"merkleRootMultisigIsmFactory": "0x16B710b86CAd07E6F1C531861a16F5feC29dba37",
"messageIdMultisigIsmFactory": "0x44b764045BfDC68517e10e783E69B376cef196B2",
"aggregationIsmFactory": "0xC2E36cd6e32e194EE11f15D9273B64461A4D49A2",
"aggregationHookFactory": "0x6966b0E55883d49BFB24539356a2f8A673E02039",
"routingIsmFactory": "0x54148470292C24345fb828B003461a9444414517",
"staticMerkleRootMultisigIsmFactory": "0x16B710b86CAd07E6F1C531861a16F5feC29dba37",
"staticMessageIdMultisigIsmFactory": "0x44b764045BfDC68517e10e783E69B376cef196B2",
"staticAggregationIsmFactory": "0xC2E36cd6e32e194EE11f15D9273B64461A4D49A2",
"staticAggregationHookFactory": "0x6966b0E55883d49BFB24539356a2f8A673E02039",
"domainRoutingIsmFactory": "0x54148470292C24345fb828B003461a9444414517",
"mailbox": "0x33dB966328Ea213b0f76eF96CA368AB37779F065",
"proxyAdmin": "0x589C201a07c26b4725A4A829d772f24423da480B",
"validatorAnnounce": "0x20c44b1E3BeaDA1e9826CFd48BeEDABeE9871cE9",
Expand Down Expand Up @@ -307,10 +307,10 @@
"http": "https://sepolia-rpc.scroll.io"
}
],
"merkleRootMultisigIsmFactory": "0x275aCcCa81cAD931dC6fB6E49ED233Bc99Bed4A7",
"messageIdMultisigIsmFactory": "0xeb6f11189197223c656807a83B0DD374f9A6dF44",
"aggregationIsmFactory": "0x16B710b86CAd07E6F1C531861a16F5feC29dba37",
"aggregationHookFactory": "0x44b764045BfDC68517e10e783E69B376cef196B2",
"staticMerkleRootMultisigIsmFactory": "0x275aCcCa81cAD931dC6fB6E49ED233Bc99Bed4A7",
"staticMessageIdMultisigIsmFactory": "0xeb6f11189197223c656807a83B0DD374f9A6dF44",
"staticAggregationIsmFactory": "0x16B710b86CAd07E6F1C531861a16F5feC29dba37",
"staticAggregationHookFactory": "0x44b764045BfDC68517e10e783E69B376cef196B2",
"proxyAdmin": "0x598facE78a4302f11E3de0bee1894Da0b2Cb71F8",
"mailbox": "0x3C5154a193D6e2955650f9305c8d80c18C814A68",
"validatorAnnounce": "0x527768930D889662Fe7ACF64294871e86e4C2381",
Expand All @@ -322,7 +322,7 @@
"fallbackRoutingHook": "0xE1CCB130389f687bf745Dd6dc05E50da17d9ea96",
"testRecipient": "0xa3AB7E6cE24E6293bD5320A53329Ef2f4DE73fCA",
"testTokenRecipient": "0xc76E477437065093D353b7d56c81ff54D167B0Ab",
"routingIsmFactory": "0x17866ebE0e503784a9461d3e753dEeD0d3F61153",
"domainRoutingIsmFactory": "0x17866ebE0e503784a9461d3e753dEeD0d3F61153",
"index": {
"from": 1344054
}
Expand Down Expand Up @@ -363,10 +363,10 @@
"http": "https://rpc.sepolia.org"
}
],
"merkleRootMultisigIsmFactory": "0x0a71AcC99967829eE305a285750017C4916Ca269",
"messageIdMultisigIsmFactory": "0xFEb9585b2f948c1eD74034205a7439261a9d27DD",
"aggregationIsmFactory": "0xC83e12EF2627ACE445C298e6eC418684918a6002",
"aggregationHookFactory": "0x160C28C92cA453570aD7C031972b58d5Dd128F72",
"staticMerkleRootMultisigIsmFactory": "0x0a71AcC99967829eE305a285750017C4916Ca269",
"staticMessageIdMultisigIsmFactory": "0xFEb9585b2f948c1eD74034205a7439261a9d27DD",
"staticAggregationIsmFactory": "0xC83e12EF2627ACE445C298e6eC418684918a6002",
"staticAggregationHookFactory": "0x160C28C92cA453570aD7C031972b58d5Dd128F72",
"proxyAdmin": "0x97Bbc6bBaFa5Ce3b2FA966c121Af63bD09e940f8",
"storageGasOracle": "0x71775B071F77F1ce52Ece810ce084451a3045FFe",
"interchainGasPaymaster": "0x6f2756380FD49228ae25Aa7F2817993cB74Ecc56",
Expand All @@ -378,7 +378,7 @@
"fallbackRoutingHook": "0x17Dc724B7a2F09141C13b8AC33B396073785c2BC",
"testRecipient": "0xeDc1A3EDf87187085A3ABb7A9a65E1e7aE370C07",
"testTokenRecipient": "0x031AD9c560D37baC7d6Bd2d27A2443bAfd10101A",
"routingIsmFactory": "0x3F100cBBE5FD5466BdB4B3a15Ac226957e7965Ad",
"domainRoutingIsmFactory": "0x3F100cBBE5FD5466BdB4B3a15Ac226957e7965Ad",
"interchainSecurityModule": "0x958124472b14B7940Ed5317C44a2508791dB1d48",
"pausableHook": "0xa68022e53Fd28119D07C8336a8eC84A298Fd38Fd",
"index": {
Expand Down
8 changes: 4 additions & 4 deletions rust/hyperlane-base/src/settings/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ fn parse_custom_urls(
.end()
.map(|urls| {
urls.split(',')
.filter_map(|url| url.parse().take_err(err, || &chain.cwp + "customGrpcUrls"))
.filter_map(|url| url.parse().take_err(err, || &chain.cwp + key))
.collect_vec()
})
}
Expand All @@ -440,12 +440,12 @@ fn parse_base_and_override_urls(

if combined.is_empty() {
err.push(
&chain.cwp + "rpc_urls",
eyre!("Missing base rpc definitions for chain"),
&chain.cwp + base_key,
eyre!("Missing base {} definitions for chain", base_key),
);
err.push(
&chain.cwp + "custom_rpc_urls",
eyre!("Also missing rpc overrides for chain"),
eyre!("Also missing {} overrides for chain", base_key),
);
}
combined
Expand Down
4 changes: 3 additions & 1 deletion solidity/test/InterchainAccountRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,9 @@ contract InterchainAccountRouterTest is Test {
}

function testFuzz_sendValue(uint256 value) public {
vm.assume(value > 0 && value <= address(this).balance);
vm.assume(
value > 0 && value <= address(this).balance - gasPaymentQuote
);
payable(address(ica)).transfer(value);

bytes memory data = abi.encodeCall(this.receiveValue, (value));
Expand Down
8 changes: 4 additions & 4 deletions typescript/cli/examples/contract-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ anvil1:
multisigIsm: '0x9bDE63104EE030d9De419EEd6bA7D14b86D6fE3f'
testRecipient: '0x36FdA966CfffF8a9Cdc814f546db0e6378bFef35'
interchainAccountIsm: '0x5e8ee6840caa4f367aff1FF28aA36D5B1b836d35'
aggregationIsmFactory: '0xc864fa3B662613cA5051f41e157d0a997f9a5A87'
routingIsmFactory: '0x1fdfD1486b8339638C6b92f8a96D698D8182D2b1'
staticAggregationIsmFactory: '0xc864fa3B662613cA5051f41e157d0a997f9a5A87'
domainRoutingIsmFactory: '0x1fdfD1486b8339638C6b92f8a96D698D8182D2b1'
interchainQueryRouter: '0xA837e38C3F7D509DF3a7a0fCf65E3814DB6c2618'
interchainAccountRouter: '0x9521291A43ebA3aD3FD24d610F4b7F7543C8d761'
merkleRootMultisigIsmFactory: '0x82140b2ddAd4E4dd7e1D6757Fb5F9485c230B79d'
messageIdMultisigIsmFactory: '0x1079056da3EC7D55521F27e1E094015C0d39Cc65'
staticMerkleRootMultisigIsmFactory: '0x82140b2ddAd4E4dd7e1D6757Fb5F9485c230B79d'
staticMessageIdMultisigIsmFactory: '0x1079056da3EC7D55521F27e1E094015C0d39Cc65'
4 changes: 2 additions & 2 deletions typescript/cli/src/deploy/warp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async function runBuildConfigStep({
base.interchainSecurityModule ||
mergedContractAddrs[baseChainName]?.interchainSecurityModule ||
mergedContractAddrs[baseChainName]?.multisigIsm,
// ismFactory: mergedContractAddrs[baseChainName].routingIsmFactory, // TODO fix when updating from routingIsm
// ismFactory: mergedContractAddrs[baseChainName].domainRoutingIsmFactory, // TODO fix when updating from routingIsm
foreignDeployment: base.foreignDeployment,
name: baseMetadata.name,
symbol: baseMetadata.symbol,
Expand All @@ -172,7 +172,7 @@ async function runBuildConfigStep({
synthetic.interchainSecurityModule ||
mergedContractAddrs[sChainName]?.interchainSecurityModule ||
mergedContractAddrs[sChainName]?.multisigIsm,
// ismFactory: mergedContractAddrs[sChainName].routingIsmFactory, // TODO fix
// ismFactory: mergedContractAddrs[sChainName].domainRoutingIsmFactory, // TODO fix
foreignDeployment: synthetic.foreignDeployment,
};
}
Expand Down
6 changes: 1 addition & 5 deletions typescript/infra/config/aw-multisig.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@
]
},
"injective": {
"validators": [
"0xbfb8911b72cfb138c7ce517c57d9c691535dc517",
"0x6faa139c33a7e6f53cb101f6b2ae392298283ed2",
"0x0115e3a66820fb99da30d30e2ce52a453ba99d92"
]
"validators": ["0xbfb8911b72cfb138c7ce517c57d9c691535dc517"]
},
"mantapacific": {
"validators": [
Expand Down
2 changes: 1 addition & 1 deletion typescript/infra/config/environments/mainnet3/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const hyperlane: RootAgentConfig = {
docker: {
repo,
// Includes Cosmos block-by-block indexing.
tag: 'a72c3cf-20240314-173418',
tag: '39df4ca-20240321-100543',
},
gasPaymentEnforcement: [
// Temporary measure to ensure all inEVM warp route messages are delivered -
Expand Down
Loading

0 comments on commit 09938ed

Please sign in to comment.