Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ impl GasPaymentPolicy for GasPaymentPolicyMinimum {
/// This is different from not requiring message senders to make any payment at all to
/// the configured IGP to get relayed. To relay regardless of the existence of a payment,
/// the `None` IGP policy should be used.

async fn message_meets_gas_payment_requirement(
&self,
_message: &HyperlaneMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl GasPaymentPolicy for GasPaymentPolicyOnChainFeeQuoting {
/// OnChainFeeQuoting requires the user to pay a specified fraction of the
/// estimated gas. Like the Minimum policy, OnChainFeeQuoting requires a
/// payment to exist on the IGP specified in the config.

async fn message_meets_gas_payment_requirement(
&self,
_message: &HyperlaneMessage,
Expand Down
2 changes: 1 addition & 1 deletion rust/main/agents/relayer/src/msg/metadata/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl IsmCachePolicyClassifier {
}
IsmCacheSelector::AppContext {
context: selector_app_context,
} => app_context.map_or(false, |app_context| app_context == selector_app_context),
} => app_context == Some(selector_app_context),
};

if matches_module
Expand Down
2 changes: 1 addition & 1 deletion rust/main/agents/relayer/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Server {

let expose_environment_variable_endpoint =
env::var("HYPERLANE_RELAYER_ENVIRONMENT_VARIABLE_ENDPOINT_ENABLED")
.map_or(false, |v| v == "true");
.is_ok_and(|v| v == "true");
if expose_environment_variable_endpoint {
router = router.merge(EnvironmentVariableApi::new().router());
}
Expand Down
2 changes: 1 addition & 1 deletion rust/main/agents/relayer/src/settings/matching_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'de> Visitor<'de> for FilterVisitor<H256> {
}
}

impl<'de> Visitor<'de> for FilterVisitor<RegexWrapper> {
impl Visitor<'_> for FilterVisitor<RegexWrapper> {
type Value = RegexWrapper;

fn expecting(&self, fmt: &mut Formatter) -> fmt::Result {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ impl CosmosAddress {
/// - digest: H256 digest (hex representation of address)
/// - prefix: Bech32 prefix
/// - byte_count: Number of bytes to truncate the digest to. Cosmos addresses can sometimes
/// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate
/// length.
/// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate length.
pub fn from_h256(digest: H256, prefix: &str, byte_count: usize) -> ChainResult<Self> {
// This is the hex-encoded version of the address
let untruncated_bytes = digest.as_bytes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ impl GrpcProvider {
.map(CosmosGrpcClient::new)
.map_err(Into::<HyperlaneCosmosError>::into)
})
.collect::<Result<Vec<CosmosGrpcClient>, _>>()
.map_err(HyperlaneCosmosError::from)?;
.collect::<Result<Vec<CosmosGrpcClient>, _>>()?;

let fallback = FallbackProvider::new(clients);
Ok(Self { fallback })
Expand Down
3 changes: 1 addition & 2 deletions rust/main/chains/hyperlane-cosmos/src/libs/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ impl CosmosAddress {
/// - digest: H256 digest (hex representation of address)
/// - prefix: Bech32 prefix
/// - byte_count: Number of bytes to truncate the digest to. Cosmos addresses can sometimes
/// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate
/// length.
/// be less than 32 bytes, so this helps to serialize it in bech32 with the appropriate length.
pub fn from_h256(digest: H256, prefix: &str, byte_count: usize) -> ChainResult<Self> {
// This is the hex-encoded version of the address
let untruncated_bytes = digest.as_bytes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ pub fn decode_revert_reason(return_data: &Bytes) -> Option<String> {

// Manually decode the ABI-encoded string
// Equivalent to ethers.js: ethers.utils.defaultAbiCoder.decode(['string'], data)
match <String as AbiDecode>::decode(data) {
Ok(reason) => Some(reason),
Err(_) => None,
}
<String as AbiDecode>::decode(data).ok()
} else {
None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const METHOD_SEND_RAW_TRANSACTION: &str = "eth_sendRawTransaction";
/// Wrapper of `FallbackProvider` for use in `hyperlane-ethereum`
/// The wrapper uses two distinct strategies to place requests to chains:
/// 1. multicast - the request will be sent to all the providers simultaneously and the first
/// successful response will be used.
/// successful response will be used.
///
/// 2. fallback - the request will be sent to each provider one by one according to their
/// priority and the priority will be updated depending on success/failure.
/// priority and the priority will be updated depending on success/failure.
///
/// Multicast strategy is used to submit transactions into the chain, namely with RPC method
/// `eth_sendRawTransaction` while fallback strategy is used for all the other RPC methods.
Expand Down Expand Up @@ -235,7 +236,7 @@ where
&'a self,
method: &'a str,
params: &'a Value,
) -> FuturesUnordered<impl Future<Output = Result<Value, HttpClientError>> + Sized + '_> {
) -> FuturesUnordered<impl Future<Output = Result<Value, HttpClientError>> + Sized + 'a> {
let unordered = FuturesUnordered::new();
self.inner
.providers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pub fn is_interchain_payment_instruction(instruction_data: &[u8]) -> bool {
/// * `program_id` - Identifier of program for which we are searching transactions for.
/// * `pda_pubkey` - Identifier for PDA the relevant transaction should operate upon.
/// * `is_specified_instruction` - Function which returns `true` for instruction which should be
/// included into the relevant transaction.
/// included into the relevant transaction.
fn search_transactions(
transactions: Vec<EncodedTransactionWithStatusMeta>,
program_id: &Pubkey,
Expand Down
4 changes: 2 additions & 2 deletions rust/main/chains/hyperlane-starknet/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ impl SequenceAwareIndexer<MerkleTreeInsertion> for StarknetMerkleTreeHookIndexer
}
}

/// TODO: This is a placeholder for the Interchain Gas Paymaster indexer.
/// Interchain Gas Paymaster
// TODO: This is a placeholder for the Interchain Gas Paymaster indexer.
// Interchain Gas Paymaster

/// A reference to a InterchainGasPaymasterIndexer contract on some Starknet chain
#[derive(Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion rust/main/chains/hyperlane-starknet/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub fn to_packed_bytes(bytes: &[u8]) -> Vec<u128> {
// Create a new byte vector with the necessary padding
let mut padded_bytes = Vec::with_capacity(total_len);
padded_bytes.extend_from_slice(bytes);
padded_bytes.extend(std::iter::repeat(0).take(padding));
padded_bytes.extend(std::iter::repeat_n(0, padding));

let mut result = Vec::with_capacity(total_len / 16);
for chunk in padded_bytes.chunks_exact(16) {
Expand Down
2 changes: 1 addition & 1 deletion rust/main/hyperlane-base/src/db/rocks/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub struct PrefixIterator<'a, V> {
_phantom: PhantomData<*const V>,
}

impl<'a, V> Iterator for PrefixIterator<'a, V>
impl<V> Iterator for PrefixIterator<'_, V>
where
V: Encode + Decode,
{
Expand Down
2 changes: 1 addition & 1 deletion rust/main/hyperlane-base/src/server/base_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Server {
///
/// routes:
/// - metrics - serving OpenMetrics format reports on `/metrics`
/// (this is compatible with Prometheus, which ought to be configured to scrape this endpoint)
/// (this is compatible with Prometheus, which ought to be configured to scrape this endpoint)
/// - custom_routes - additional routes to be served by the server as per the specific agent
pub fn run_with_custom_router(self: Arc<Self>, router: Router) -> JoinHandle<()> {
let port = self.listen_port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ impl<'e, T> ParseChain<'e, T> {
}
}

impl<'e, T: Default> ParseChain<'e, T> {
impl<T: Default> ParseChain<'_, T> {
pub fn unwrap_or_default(self) -> T {
self.0.unwrap_or_default()
}
Expand Down
2 changes: 1 addition & 1 deletion rust/main/hyperlane-base/src/types/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl MultisigCheckpointSyncer {
}

#[cfg(test)]
pub mod test {
mod test {
use std::str::FromStr;

use aws_config::Region;
Expand Down
4 changes: 2 additions & 2 deletions rust/main/hyperlane-core/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct ContractLocator<'a> {
}

#[cfg(feature = "strum")]
impl<'a> std::fmt::Display for ContractLocator<'a> {
impl std::fmt::Display for ContractLocator<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<'de> Deserialize<'de> for ReorgPeriod {

struct ReorgPeriodVisitor;

impl<'de> de::Visitor<'de> for ReorgPeriodVisitor {
impl de::Visitor<'_> for ReorgPeriodVisitor {
type Value = ReorgPeriod;

fn expecting(&self, f: &mut Formatter) -> std::fmt::Result {
Expand Down
1 change: 0 additions & 1 deletion rust/main/hyperlane-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#![warn(missing_docs)]
#![deny(unsafe_code)]
#![allow(unknown_lints)] // TODO: `rustc` 1.80.1 clippy issue
#![forbid(where_clauses_object_safety)]
#![deny(clippy::unwrap_used, clippy::panic)]

extern crate core;
Expand Down
2 changes: 1 addition & 1 deletion rust/main/hyperlane-core/src/rpc_clients/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ pub mod test {
}

#[tokio::test]
pub async fn test_deprioritization_by_failed_count() {
async fn test_deprioritization_by_failed_count() {
let provider1 = ProviderMock::new(None);
let provider2 = ProviderMock::new(None);
let provider3 = ProviderMock::new(None);
Expand Down
1 change: 1 addition & 0 deletions rust/main/hyperlane-core/src/traits/pending_operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ impl PartialEq for QueueOperation {

impl Eq for QueueOperation {}

#[allow(clippy::unnecessary_map_or)] // can't use `.is_ok_and` because it still unstables in `sbf`
impl Ord for QueueOperation {
fn cmp(&self, other: &Self) -> Ordering {
use Ordering::*;
Expand Down
2 changes: 2 additions & 0 deletions rust/main/hyperlane-core/src/types/primitive_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![allow(clippy::assign_op_pattern)]
#![allow(clippy::reversed_empty_ranges)]
#![allow(clippy::manual_div_ceil)]

use std::{
ops::{Div, Mul},
Expand Down Expand Up @@ -45,6 +46,7 @@ construct_uint! {
mod fixed_hashes {
// we can't change how they made the macro, so ignore the lint
#![allow(clippy::non_canonical_clone_impl)]
#![allow(unexpected_cfgs)]

use borsh::{BorshDeserialize, BorshSerialize};
use fixed_hash::construct_fixed_hash;
Expand Down
5 changes: 3 additions & 2 deletions rust/main/hyperlane-core/src/types/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl fmt::Display for FromHexError {
/// Decode given (both 0x-prefixed or not) hex string into a vector of bytes.
///
/// Returns an error if non-hex characters are present.
#[allow(clippy::manual_div_ceil)] // can't use `.div_ceil` because it still unstables in `sbf`
pub fn from_hex(v: &str) -> Result<Vec<u8>, FromHexError> {
let (v, stripped) = v.strip_prefix("0x").map_or((v, false), |v| (v, true));

Expand Down Expand Up @@ -196,7 +197,7 @@ pub enum ExpectedLen<'a> {
Between(usize, &'a mut [u8]),
}

impl<'a> fmt::Display for ExpectedLen<'a> {
impl fmt::Display for ExpectedLen<'_> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
ExpectedLen::Exact(ref v) => write!(fmt, "{} bytes", v.len()),
Expand Down Expand Up @@ -271,7 +272,7 @@ where
len: ExpectedLen<'a>,
}

impl<'a, 'b> de::Visitor<'b> for Visitor<'a> {
impl<'b> de::Visitor<'b> for Visitor<'_> {
type Value = usize;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
1 change: 0 additions & 1 deletion rust/main/hyperlane-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![forbid(unsafe_code)]
#![cfg_attr(test, warn(missing_docs))]
#![allow(unknown_lints)] // TODO: `rustc` 1.80.1 clippy issue
#![forbid(where_clauses_object_safety)]

/// Mock contracts
pub mod mocks;
93 changes: 51 additions & 42 deletions rust/main/hyperlane-test/src/mocks/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,71 @@ use mockall::*;

use hyperlane_core::{accumulator::incremental::IncrementalMerkle, *};

mock! {
pub MailboxContract {
// Mailbox
pub fn _address(&self) -> H256 {}
pub use mock_mailbox_contract::MockMailboxContract;

pub fn _domain(&self) -> &HyperlaneDomain {}
mod mock_mailbox_contract {

pub fn _provider(&self) -> Box<dyn HyperlaneProvider> {}
#![allow(missing_docs)]
use super::*;

pub fn _domain_hash(&self) -> H256 {}
mock! {
pub MailboxContract {
// Mailbox
pub fn _address(&self) -> H256 {}

pub fn _raw_message_by_id(
&self,
leaf: H256,
) -> ChainResult<Option<RawHyperlaneMessage>> {}
pub fn _domain(&self) -> &HyperlaneDomain {}

pub fn _id_by_nonce(
&self,
nonce: usize,
) -> ChainResult<Option<H256>> {}
pub fn _provider(&self) -> Box<dyn HyperlaneProvider> {}

pub fn _tree(&self, reorg_period: &ReorgPeriod) -> ChainResult<IncrementalMerkle> {}
pub fn _domain_hash(&self) -> H256 {}

pub fn _count(&self, reorg_period: &ReorgPeriod) -> ChainResult<u32> {}
pub fn _raw_message_by_id(
&self,
leaf: H256,
) -> ChainResult<Option<RawHyperlaneMessage>> {}

pub fn _latest_checkpoint(&self, reorg_period: &ReorgPeriod) -> ChainResult<Checkpoint> {}
pub fn _id_by_nonce(
&self,
nonce: usize,
) -> ChainResult<Option<H256>> {}

pub fn _default_ism(&self) -> ChainResult<H256> {}
pub fn _recipient_ism(&self, recipient: H256) -> ChainResult<H256> {}
pub fn _tree(&self, reorg_period: &ReorgPeriod) -> ChainResult<IncrementalMerkle> {}

pub fn _delivered(&self, id: H256) -> ChainResult<bool> {}
pub fn _count(&self, reorg_period: &ReorgPeriod) -> ChainResult<u32> {}

pub fn process(
&self,
message: &HyperlaneMessage,
metadata: &[u8],
tx_gas_limit: Option<U256>,
) -> ChainResult<TxOutcome> {}
pub fn _latest_checkpoint(&self, reorg_period: &ReorgPeriod) -> ChainResult<Checkpoint> {}

pub fn process_estimate_costs(
&self,
message: &HyperlaneMessage,
metadata: &[u8],
) -> ChainResult<TxCostEstimate> {}
pub fn _default_ism(&self) -> ChainResult<H256> {}
pub fn _recipient_ism(&self, recipient: H256) -> ChainResult<H256> {}

pub fn process_calldata(
&self,
message: &HyperlaneMessage,
metadata: &[u8],
) -> Vec<u8> {}
pub fn _delivered(&self, id: H256) -> ChainResult<bool> {}

pub fn process_batch<'a>(
&self,
ops: Vec<&'a QueueOperation>,
) -> ChainResult<BatchResult> {}
pub fn process(
&self,
message: &HyperlaneMessage,
metadata: &[u8],
tx_gas_limit: Option<U256>,
) -> ChainResult<TxOutcome> {}

pub fn supports_batching(&self) -> bool {
pub fn process_estimate_costs(
&self,
message: &HyperlaneMessage,
metadata: &[u8],
) -> ChainResult<TxCostEstimate> {}

pub fn process_calldata(
&self,
message: &HyperlaneMessage,
metadata: &[u8],
) -> Vec<u8> {}

pub fn process_batch<'a>(
&self,
ops: Vec<&'a QueueOperation>,
) -> ChainResult<BatchResult> {}

pub fn supports_batching(&self) -> bool {
}
}
}
}
Expand Down Expand Up @@ -145,6 +153,7 @@ impl HyperlaneContract for MockMailboxContract {
}

impl MockMailboxContract {
/// Create a new mock mailbox contract with a default ISM
pub fn new_with_default_ism(default_ism: H256) -> Self {
let mut mock = Self::new();
mock.expect__default_ism()
Expand Down
1 change: 1 addition & 0 deletions rust/main/hyperlane-test/src/mocks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Mock mailbox contract
pub mod mailbox;
/// Mock validator announce contract
pub mod validator_announce;

pub use mailbox::MockMailboxContract;
Expand Down
2 changes: 1 addition & 1 deletion rust/main/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.81.0"
channel = "1.86.0"
profile = "default"
Loading
Loading