From 1187874168bb183673a65b569d4c4a1619d56e6b Mon Sep 17 00:00:00 2001 From: Danil Nemirovsky <4614623+ameten@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:00:49 +0000 Subject: [PATCH] Make variable names more precise --- .../hyperlane-sealevel/src/interchain_gas.rs | 4 +- .../chains/hyperlane-sealevel/src/mailbox.rs | 41 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs b/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs index ad81d7f444..3c2cbd1c16 100644 --- a/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs +++ b/rust/main/chains/hyperlane-sealevel/src/interchain_gas.rs @@ -120,14 +120,14 @@ impl SealevelInterchainGasPaymasterIndexer { ) -> ChainResult { let discriminator = hyperlane_sealevel_igp::accounts::GAS_PAYMENT_DISCRIMINATOR; let sequence_number_bytes = sequence_number.to_le_bytes(); - let length = 32; // the length of the `unique_gas_payment_pubkey` field + let unique_gas_payment_pubkey_length = 32; // the length of the `unique_gas_payment_pubkey` field let accounts = search_accounts_by_discriminator( &self.rpc_client, &self.igp.program_id, discriminator, &sequence_number_bytes, UNIQUE_GAS_PAYMENT_PUBKEY_OFFSET, - length, + unique_gas_payment_pubkey_length, ) .await?; diff --git a/rust/main/chains/hyperlane-sealevel/src/mailbox.rs b/rust/main/chains/hyperlane-sealevel/src/mailbox.rs index 0df14627f5..45e4461279 100644 --- a/rust/main/chains/hyperlane-sealevel/src/mailbox.rs +++ b/rust/main/chains/hyperlane-sealevel/src/mailbox.rs @@ -4,21 +4,13 @@ use std::{collections::HashMap, num::NonZeroU64, ops::RangeInclusive, str::FromS use async_trait::async_trait; use borsh::{BorshDeserialize, BorshSerialize}; -use hyperlane_core::{ - accumulator::incremental::IncrementalMerkle, BatchItem, ChainCommunicationError, - ChainCommunicationError::ContractError, ChainResult, Checkpoint, ContractLocator, Decode as _, - Encode as _, FixedPointNumber, HyperlaneAbi, HyperlaneChain, HyperlaneContract, - HyperlaneDomain, HyperlaneMessage, HyperlaneProvider, Indexed, Indexer, KnownHyperlaneDomain, - LogMeta, Mailbox, MerkleTreeHook, ReorgPeriod, SequenceAwareIndexer, TxCostEstimate, TxOutcome, - H256, H512, U256, -}; use hyperlane_sealevel_interchain_security_module_interface::{ InterchainSecurityModuleInstruction, VerifyInstruction, }; use hyperlane_sealevel_mailbox::{ accounts::{ DispatchedMessageAccount, InboxAccount, OutboxAccount, ProcessedMessage, - ProcessedMessageAccount, + ProcessedMessageAccount, DISPATCHED_MESSAGE_DISCRIMINATOR, PROCESSED_MESSAGE_DISCRIMINATOR, }, instruction, instruction::InboxProcess, @@ -58,6 +50,15 @@ use solana_transaction_status::{ }; use tracing::{debug, info, instrument, warn}; +use hyperlane_core::{ + accumulator::incremental::IncrementalMerkle, BatchItem, ChainCommunicationError, + ChainCommunicationError::ContractError, ChainResult, Checkpoint, ContractLocator, Decode as _, + Encode as _, FixedPointNumber, HyperlaneAbi, HyperlaneChain, HyperlaneContract, + HyperlaneDomain, HyperlaneMessage, HyperlaneProvider, Indexed, Indexer, KnownHyperlaneDomain, + LogMeta, Mailbox, MerkleTreeHook, ReorgPeriod, SequenceAwareIndexer, TxCostEstimate, TxOutcome, + H256, H512, U256, +}; + use crate::account::{search_accounts_by_discriminator, search_and_validate_account}; use crate::error::HyperlaneSealevelError; use crate::transaction::search_dispatched_message_transactions; @@ -664,17 +665,16 @@ impl SealevelMailboxIndexer { &self, nonce: u32, ) -> ChainResult<(Indexed, LogMeta)> { - let discriminator = hyperlane_sealevel_mailbox::accounts::DISPATCHED_MESSAGE_DISCRIMINATOR; let nonce_bytes = nonce.to_le_bytes(); - let offset = 1 + 8 + 4 + 8; // the offset to get the `unique_message_pubkey` field - let length = 32; // the length of the `unique_message_pubkey` field + let unique_dispatched_message_pubkey_offset = 1 + 8 + 4 + 8; // the offset to get the `unique_message_pubkey` field + let unique_dispatch_message_pubkey_length = 32; // the length of the `unique_message_pubkey` field let accounts = search_accounts_by_discriminator( self.rpc(), &self.program_id, - &discriminator, + &DISPATCHED_MESSAGE_DISCRIMINATOR, &nonce_bytes, - offset, - length, + unique_dispatched_message_pubkey_offset, + unique_dispatch_message_pubkey_length, ) .await?; @@ -752,17 +752,16 @@ impl SealevelMailboxIndexer { &self, nonce: u32, ) -> ChainResult<(Indexed, LogMeta)> { - let discriminator = hyperlane_sealevel_mailbox::accounts::PROCESSED_MESSAGE_DISCRIMINATOR; let nonce_bytes = nonce.to_le_bytes(); - let offset = 1 + 8 + 8; // the offset to get the `message_id` field - let length = 32; + let delivered_message_id_offset = 1 + 8 + 8; // the offset to get the `message_id` field + let delivered_message_id_length = 32; let accounts = search_accounts_by_discriminator( self.rpc(), &self.program_id, - &discriminator, + &PROCESSED_MESSAGE_DISCRIMINATOR, &nonce_bytes, - offset, - length, + delivered_message_id_offset, + delivered_message_id_length, ) .await?;