feat(fuelvm-integration): reorg logic

pull/4861/head
Mantas M. 2 days ago
parent b649fa9dd5
commit 1e43076272
  1. 1
      rust/main/agents/relayer/src/relayer.rs
  2. 1
      rust/main/agents/validator/src/validator.rs
  3. 2
      rust/main/chains/hyperlane-fuel/abis/MerkleTreeHook.abi.json
  4. 7
      rust/main/chains/hyperlane-fuel/src/mailbox.rs
  5. 30
      rust/main/chains/hyperlane-fuel/src/merkle_tree_hook.rs
  6. 2
      rust/main/config/mainnet_config.json
  7. 2
      rust/main/config/testnet_config.json
  8. 17
      rust/main/hyperlane-base/src/settings/base.rs

@ -135,6 +135,7 @@ impl BaseAgent for Relayer {
.map(|origin| (origin.clone(), HyperlaneRocksDB::new(origin, db.clone())))
.collect::<HashMap<_, _>>();
settings.check_fuel_reorg();
let mailboxes = settings
.build_mailboxes(settings.destination_chains.iter(), &core_metrics)
.await?;

@ -76,6 +76,7 @@ impl BaseAgent for Validator {
// Intentionally using hyperlane_ethereum for the validator's signer
let (signer_instance, signer) = SingletonSigner::new(settings.validator.build().await?);
settings.check_fuel_reorg();
let core = settings.build_hyperlane_core(metrics.clone());
let checkpoint_syncer = settings
.checkpoint_syncer

@ -353,7 +353,7 @@
{
"name": "doc-comment",
"arguments": [
" Gets the stored count of the MerkleTree library."
" Gets the stored count of the MerkleTree."
]
},
{

@ -21,7 +21,6 @@ use std::{
fmt::{Debug, Formatter},
ops::RangeInclusive,
};
use tracing::{instrument, warn};
const GAS_ESTIMATE_MULTIPLIER: f64 = 1.3;
@ -78,11 +77,7 @@ impl Debug for FuelMailbox {
impl Mailbox for FuelMailbox {
#[instrument(level = "debug", err, ret, skip(self))]
#[allow(clippy::blocks_in_conditions)] // TODO: `rustc` 1.80.1 clippy issue
async fn count(&self, reorg_period: &ReorgPeriod) -> ChainResult<u32> {
assert!(
reorg_period.is_none(),
"Fuel does not support querying point-in-time"
);
async fn count(&self, _reorg_period: &ReorgPeriod) -> ChainResult<u32> {
self.contract
.methods()
.nonce()

@ -17,10 +17,7 @@ use hyperlane_core::{
};
use std::ops::RangeInclusive;
/// Smart contract level enforced finality
const ENFORCED_FINALITY: u8 = 1;
/// A reference to a AggregationIsm contract on some Fuel chain
/// A reference to a MerkleTreeHook contract on some Fuel chain
#[derive(Debug)]
pub struct FuelMerkleTreeHook {
contract: MerkleTreeHookContract<WalletUnlocked>,
@ -46,19 +43,6 @@ impl FuelMerkleTreeHook {
provider: fuel_provider,
})
}
/// Asserts the lag
/// The lag or re-org of FuelVM should be set to 1, as it is the soft finality
/// Also, since we cannot query point in time, the lag is built into the contract code
fn assert_lag(&self, reorg_period: &ReorgPeriod) {
assert!(
reorg_period
.as_blocks()
.is_ok_and(|reorg| reorg == ENFORCED_FINALITY as u32),
"FuelVM lag should always be {:?}",
ENFORCED_FINALITY
);
}
}
impl HyperlaneContract for FuelMerkleTreeHook {
@ -79,9 +63,7 @@ impl HyperlaneChain for FuelMerkleTreeHook {
#[async_trait]
impl MerkleTreeHook for FuelMerkleTreeHook {
async fn tree(&self, reorg_period: &ReorgPeriod) -> ChainResult<IncrementalMerkle> {
self.assert_lag(reorg_period);
async fn tree(&self, _reorg_period: &ReorgPeriod) -> ChainResult<IncrementalMerkle> {
self.contract
.methods()
.tree()
@ -97,9 +79,7 @@ impl MerkleTreeHook for FuelMerkleTreeHook {
})
}
async fn count(&self, reorg_period: &ReorgPeriod) -> ChainResult<u32> {
self.assert_lag(reorg_period);
async fn count(&self, _reorg_period: &ReorgPeriod) -> ChainResult<u32> {
self.contract
.methods()
.count()
@ -109,9 +89,7 @@ impl MerkleTreeHook for FuelMerkleTreeHook {
.map(|res| res.value)
}
async fn latest_checkpoint(&self, reorg_period: &ReorgPeriod) -> ChainResult<Checkpoint> {
self.assert_lag(reorg_period);
async fn latest_checkpoint(&self, _reorg_period: &ReorgPeriod) -> ChainResult<Checkpoint> {
self.contract
.methods()
.latest_checkpoint()

@ -2731,7 +2731,7 @@
"blocks": {
"confirmations": 1,
"estimateBlockTime": 1,
"reorgPeriod": 1
"reorgPeriod": 0
},
"chainId": 1717982311,
"deployer": {

@ -449,7 +449,7 @@
"blocks": {
"confirmations": 1,
"estimateBlockTime": 1,
"reorgPeriod": 1
"reorgPeriod": 0
},
"chainId": 1717982312,
"deployer": {

@ -3,10 +3,11 @@ use std::{collections::HashMap, fmt::Debug, hash::Hash, sync::Arc};
use eyre::{eyre, Context, Result};
use futures_util::future::try_join_all;
use hyperlane_core::{
HyperlaneChain, HyperlaneDomain, HyperlaneLogStore, HyperlaneProvider,
HyperlaneChain, HyperlaneDomain, HyperlaneDomainProtocol, HyperlaneLogStore, HyperlaneProvider,
HyperlaneSequenceAwareIndexerStoreReader, HyperlaneWatermarkedLogStore, InterchainGasPaymaster,
Mailbox, MerkleTreeHook, MultisigIsm, SequenceAwareIndexer, ValidatorAnnounce, H256,
};
use tracing::warn;
use crate::{
cursors::{CursorType, Indexable},
@ -81,6 +82,20 @@ impl Settings {
.ok_or_else(|| eyre!("No chain setup found for {domain}"))
}
/// Check and warn if reorg period is set for FuelVM domains.
pub fn check_fuel_reorg(&self) {
self.chains.values().into_iter().for_each(|conf| {
if conf.domain.domain_protocol() == HyperlaneDomainProtocol::Fuel {
if !conf.reorg_period.is_none() {
warn!(
"Reorg period is set for fuel domain {:?}. FuelVM chains are implemented with instant finality",
conf.domain
);
}
}
});
}
/// Try to get the domain for a given chain by name.
pub fn lookup_domain(&self, chain_name: &str) -> Result<HyperlaneDomain> {
self.chains

Loading…
Cancel
Save