fix: merge issue

pull/3658/head
0xevolve 2 weeks ago
parent 5e2057a5b7
commit 34c6820cfd
  1. 3
      rust/main/chains/hyperlane-cosmos/src/validator_announce.rs
  2. 86
      rust/main/chains/hyperlane-starknet/src/indexer.rs
  3. 6
      rust/main/hyperlane-base/src/settings/chains.rs

@ -13,6 +13,7 @@ use crate::{
GetAnnounceStorageLocationsRequestInner,
},
signers::Signer,
types::tx_response_to_outcome,
ConnectionConf, CosmosProvider,
};
@ -107,7 +108,7 @@ impl ValidatorAnnounce for CosmosValidatorAnnounce {
.wasm_send(announce_request, None)
.await?;
Ok(response.try_into()?)
Ok(tx_response_to_outcome(response)?)
}
async fn announce_tokens_needed(&self, announcement: SignedType<Announcement>) -> Option<U256> {

@ -1,7 +1,7 @@
use async_trait::async_trait;
use hyperlane_core::{
ChainResult, ContractLocator, HyperlaneMessage, Indexed, Indexer, InterchainGasPayment,
LogMeta, MerkleTreeInsertion, SequenceAwareIndexer, H256, U256,
LogMeta, MerkleTreeInsertion, ReorgPeriod, SequenceAwareIndexer, H256, U256,
};
use starknet::core::types::{
BlockId, BlockTag, EventFilter, FieldElement, MaybePendingBlockWithTxHashes,
@ -45,7 +45,7 @@ impl<T: PartialEq> ParsedEvent<T> {
/// Starknet RPC Provider
pub struct StarknetMailboxIndexer {
contract: Arc<StarknetMailboxReader<AnyProvider>>,
reorg_period: u32,
reorg_period: ReorgPeriod,
}
impl StarknetMailboxIndexer {
@ -53,7 +53,7 @@ impl StarknetMailboxIndexer {
pub fn new(
conf: ConnectionConf,
locator: ContractLocator,
reorg_period: u32,
reorg_period: &ReorgPeriod,
) -> ChainResult<Self> {
let rpc_client =
AnyProvider::JsonRpcHttp(JsonRpcClient::new(HttpTransport::new(conf.url.clone())));
@ -64,7 +64,7 @@ impl StarknetMailboxIndexer {
Ok(Self {
contract: Arc::new(contract),
reorg_period,
reorg_period: reorg_period.clone(),
})
}
@ -100,16 +100,32 @@ impl StarknetMailboxIndexer {
#[instrument(level = "debug", err, ret, skip(self))]
async fn get_finalized_block_number(&self) -> ChainResult<u32> {
Ok(
self.contract
.provider
.block_number()
.await
.map_err(Into::<HyperlaneStarknetError>::into)?
.saturating_sub(self.reorg_period as u64)
.try_into()
.unwrap(), // TODO: check if safe
)
match self.reorg_period {
ReorgPeriod::None => Ok(
self.contract
.provider
.block_number()
.await
.map_err(Into::<HyperlaneStarknetError>::into)?
.try_into()
.unwrap(), // TODO: check if safe
),
ReorgPeriod::Blocks(reorg_period) => Ok(
self.contract
.provider
.block_number()
.await
.map_err(Into::<HyperlaneStarknetError>::into)?
.saturating_sub(reorg_period.get() as u64)
.try_into()
.unwrap(), // TODO: check if safe
),
ReorgPeriod::Tag(_) => {
Err(hyperlane_core::ChainCommunicationError::InvalidReorgPeriod(
self.reorg_period.clone(),
))
}
}
}
}
@ -263,7 +279,7 @@ impl SequenceAwareIndexer<H256> for StarknetMailboxIndexer {
/// Starknet RPC Provider
pub struct StarknetMerkleTreeHookIndexer {
contract: Arc<StarknetMerkleTreeHookReader<AnyProvider>>,
reorg_period: u32,
reorg_period: ReorgPeriod,
}
impl StarknetMerkleTreeHookIndexer {
@ -271,7 +287,7 @@ impl StarknetMerkleTreeHookIndexer {
pub fn new(
conf: ConnectionConf,
locator: ContractLocator,
reorg_period: u32,
reorg_period: &ReorgPeriod,
) -> ChainResult<Self> {
let rpc_client =
AnyProvider::JsonRpcHttp(JsonRpcClient::new(HttpTransport::new(conf.url.clone())));
@ -282,7 +298,7 @@ impl StarknetMerkleTreeHookIndexer {
Ok(Self {
contract: Arc::new(contract),
reorg_period,
reorg_period: reorg_period.clone(),
})
}
}
@ -347,16 +363,32 @@ impl Indexer<MerkleTreeInsertion> for StarknetMerkleTreeHookIndexer {
#[instrument(level = "debug", err, ret, skip(self))]
async fn get_finalized_block_number(&self) -> ChainResult<u32> {
Ok(
self.contract
.provider
.block_number()
.await
.map_err(Into::<HyperlaneStarknetError>::into)?
.saturating_sub(self.reorg_period as u64)
.try_into()
.unwrap(), // TODO: check if safe
)
match self.reorg_period {
ReorgPeriod::None => Ok(
self.contract
.provider
.block_number()
.await
.map_err(Into::<HyperlaneStarknetError>::into)?
.try_into()
.unwrap(), // TODO: check if safe
),
ReorgPeriod::Blocks(reorg_period) => Ok(
self.contract
.provider
.block_number()
.await
.map_err(Into::<HyperlaneStarknetError>::into)?
.saturating_sub(reorg_period.get() as u64)
.try_into()
.unwrap(), // TODO: check if safe
),
ReorgPeriod::Tag(_) => {
Err(hyperlane_core::ChainCommunicationError::InvalidReorgPeriod(
self.reorg_period.clone(),
))
}
}
}
}

@ -323,7 +323,7 @@ impl ChainConf {
let indexer = Box::new(h_starknet::StarknetMailboxIndexer::new(
conf.clone(),
locator,
self.reorg_period,
&self.reorg_period,
)?);
Ok(indexer as Box<dyn SequenceAwareIndexer<HyperlaneMessage>>)
}
@ -371,7 +371,7 @@ impl ChainConf {
let indexer = Box::new(h_starknet::StarknetMailboxIndexer::new(
conf.clone(),
locator,
self.reorg_period,
&self.reorg_period,
)?);
Ok(indexer as Box<dyn SequenceAwareIndexer<H256>>)
@ -517,7 +517,7 @@ impl ChainConf {
let indexer = Box::new(h_starknet::StarknetMerkleTreeHookIndexer::new(
conf.clone(),
locator,
self.reorg_period,
&self.reorg_period,
)?);
Ok(indexer as Box<dyn SequenceAwareIndexer<MerkleTreeInsertion>>)

Loading…
Cancel
Save