Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hyperlane-xyz/hyperlane-monorepo in…
Browse files Browse the repository at this point in the history
…to xeno/update-warp-remote-router-schema
  • Loading branch information
xeno097 committed Dec 4, 2024
2 parents 3ab922f + 323f0f1 commit fe5fde4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
8 changes: 5 additions & 3 deletions rust/main/agents/scraper/src/db/payment.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use eyre::{eyre, Result};
use itertools::Itertools;
use sea_orm::{prelude::*, ActiveValue::*, Insert, QuerySelect};
use tracing::{debug, instrument, trace};
use tracing::{debug, instrument};

use hyperlane_core::{address_to_bytes, h256_to_bytes, InterchainGasPayment, LogMeta, H256};
use migration::OnConflict;
Expand All @@ -12,6 +12,7 @@ use crate::db::ScraperDb;

use super::generated::gas_payment;

#[derive(Debug)]
pub struct StorablePayment<'a> {
pub payment: &'a InterchainGasPayment,
pub sequence: Option<i64>,
Expand All @@ -26,13 +27,14 @@ impl ScraperDb {
&self,
domain: u32,
interchain_gas_paymaster: &H256,
payments: impl Iterator<Item = StorablePayment<'_>>,
payments: &[StorablePayment<'_>],
) -> Result<u64> {
let latest_id_before = self.latest_payment_id(domain).await?;
let interchain_gas_paymaster = address_to_bytes(interchain_gas_paymaster);

// we have a race condition where a message may not have been scraped yet even
let models = payments
.iter()
.map(|storable| gas_payment::ActiveModel {
id: NotSet,
time_created: Set(date_time::now()),
Expand All @@ -49,7 +51,7 @@ impl ScraperDb {
})
.collect_vec();

trace!(?models, "Writing gas payments to database");
debug!(?models, "Writing gas payments to database");

if models.is_empty() {
debug!("Wrote zero new gas payments to database");
Expand Down
14 changes: 12 additions & 2 deletions rust/main/agents/scraper/src/store/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use std::collections::HashMap;

use async_trait::async_trait;
use eyre::Result;
use itertools::Itertools;
use tracing::debug;

use hyperlane_core::{HyperlaneLogStore, Indexed, InterchainGasPayment, LogMeta, H512};

Expand Down Expand Up @@ -42,14 +44,22 @@ impl HyperlaneLogStore<InterchainGasPayment> for HyperlaneDbStore {
sequence,
meta,
txn_id,
});
})
.collect_vec();

debug!(
domain = self.domain.id(),
interchain_gas_paymaster_address = ?self.interchain_gas_paymaster_address,
?storable,
"storable payments",
);

let stored = self
.db
.store_payments(
self.domain.id(),
&self.interchain_gas_paymaster_address,
storable,
&storable,
)
.await?;
Ok(stored as u32)
Expand Down
13 changes: 1 addition & 12 deletions typescript/cli/src/commands/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,30 +184,19 @@ export const read: CommandModuleWithContext<{
type: 'string',
description: 'Mailbox address used to derive the core config',
},
interchainAccountRouter: {
type: 'string',
description: 'InterchainAccountRouter address used to derive its config',
},
config: outputFileCommandOption(
DEFAULT_CORE_DEPLOYMENT_CONFIG_PATH,
false,
'The path to output a Core Config JSON or YAML file.',
),
},
handler: async ({
context,
chain,
mailbox,
config: configFilePath,
interchainAccountRouter,
}) => {
handler: async ({ context, chain, mailbox, config: configFilePath }) => {
logCommandHeader('Hyperlane Core Read');

const coreConfig = await executeCoreRead({
context,
chain,
mailbox,
interchainAccountRouter,
});

writeYamlOrJson(configFilePath, coreConfig, 'yaml');
Expand Down
11 changes: 4 additions & 7 deletions typescript/cli/src/read/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ export async function executeCoreRead({
context,
chain,
mailbox,
interchainAccountRouter,
}: {
context: CommandContext;
chain: ChainName;
mailbox?: Address;
interchainAccountRouter?: Address;
}): Promise<CoreConfig> {
const addresses = await context.registry.getChainAddresses(chain);
if (!mailbox) {
Expand All @@ -25,13 +23,12 @@ export async function executeCoreRead({
);
}

if (!interchainAccountRouter) {
interchainAccountRouter = addresses?.interchainAccountRouter;
}

const evmCoreReader = new EvmCoreReader(context.multiProvider, chain);
try {
return evmCoreReader.deriveCoreConfig({ mailbox, interchainAccountRouter });
return evmCoreReader.deriveCoreConfig({
mailbox,
interchainAccountRouter: addresses?.interchainAccountRouter,
});
} catch (e: any) {
errorRed(
`❌ Failed to read core config for mailbox ${mailbox} on ${chain}:`,
Expand Down

0 comments on commit fe5fde4

Please sign in to comment.