Skip to content

Commit

Permalink
Merge branch 'main' into upgradable-warp-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ltyu authored Mar 26, 2024
2 parents b5b7d8d + 11f257e commit ce8c0a3
Show file tree
Hide file tree
Showing 65 changed files with 681 additions and 564 deletions.
6 changes: 6 additions & 0 deletions .changeset/two-kids-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@hyperlane-xyz/cli': minor
'@hyperlane-xyz/sdk': minor
---

Add Yield Routes to CLI
5 changes: 5 additions & 0 deletions .codespell/.codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
skip = .git,node_modules,yarn.lock,Cargo.lock,./typescript/helloworld
count =
quiet-level = 3
ignore-words = ./.codespell/ignore.txt
7 changes: 7 additions & 0 deletions .codespell/ignore.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
crate
receipient
received
receivedFrom
ser
readded
re-use
1 change: 1 addition & 0 deletions .codespell/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
codespell==2.2.6
35 changes: 35 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# A Github action that using codespell to check spelling.
# see .codespell/* for configs
# https://github.com/codespell-project/codespell

name: codespell

on:
# Triggers the workflow on push or pull request against main
push:
branches: [main]
pull_request:
branches: [main]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
codespell:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: pip cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Install prerequisites
run: sudo pip install -r ./.codespell/requirements.txt

- name: Spell check
run: codespell --config=./.codespell/.codespellrc
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This CoC applies to all members of the Hyperlane Network's community including,
3. Treat your fellow contributors with respect, fairness, and professionalism, especially in situations of high pressure.
4. Seek, offer, and accept objective critism of yours and others work, strive to acknowledge the contributions of others.
5. Be transparent and honest about your qualifications and any potential conflicts of interest. Transparency is a key tenant of the Hyperlane project and we expect it from all contributors.
6. Bring an open and curious mind, the Hyperlane project is designed to enable developers to express their curiousity, experiment, and build things we couldn't have imagined ourselves.
6. Bring an open and curious mind, the Hyperlane project is designed to enable developers to express their curiosity, experiment, and build things we couldn't have imagined ourselves.
7. Stay on track - Do your best to avoid off-topic discussion and make sure you are posting to the correct channel and repositories. Distractions are costly and it is far too easy for work to go off track.
8. Step down properly - Think of your fellow contributors when you step down from the project. Contributors of open-source projects come and go. It is crucial that when you leave the project or reduce your contribution significantly you do so in a way that minimizes disruption and keeps continuity in mind. Concretely this means telling your fellow contributors you are leaving and taking the proper steps to enable a smooth transition for other contributors to pick up where you left off.
9. Respect the privacy of others, and take extreme care to protect confidential data when you are exposed to it.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to Hyperlane

We'd love for you to contribue to Hyperlane! Here are the guidelines to follow when contributing:
We'd love for you to contribute to Hyperlane! Here are the guidelines to follow when contributing:

- [Code of Conduct](#coc)
- [Questions and Problems](#question)
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ comment:
component_management:
default_rules: # default rules that will be inherited by all components
statuses:
- type: project # in this case every component that doens't have a status defined will have a project type one
- type: project # in this case every component that does not have a status defined will have a project type one
target: auto
branches:
- "!main"
Expand Down
2 changes: 1 addition & 1 deletion rust/chains/hyperlane-cosmos/src/trait_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct ConnectionConf {
chain_id: String,
/// The human readable address prefix for the chains using bech32.
bech32_prefix: String,
/// Canoncial Assets Denom
/// Canonical Assets Denom
canonical_asset: String,
/// The gas price set by the cosmos-sdk validator. Note that this represents the
/// minimum price set by the validator.
Expand Down
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
2 changes: 1 addition & 1 deletion rust/chains/hyperlane-fuel/src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use hyperlane_core::H256;

/// Conversion from a fuel type to H256 primitive.
pub trait FuelIntoH256 {
/// Covert to an H256 primitive.
/// Convert to an H256 primitive.
fn into_h256(self) -> H256;
}

Expand Down
Loading

0 comments on commit ce8c0a3

Please sign in to comment.