From 821a486082f9703b5e94bdd18ac85244ba75ff60 Mon Sep 17 00:00:00 2001 From: Asa Oines Date: Tue, 29 Nov 2022 09:02:06 -0500 Subject: [PATCH] Update domain IDs to match chain IDs (#1313) * Rename abacus->hyperlane in agents * Rename in typescript * Update domain IDs to match chain IDs * Rename abacus->hyperlane in dockerfile * Update test consts to match shape * Fix domain id tests * Reset test_config.json * Rm old migrations * Change scraper migrations * rm auroratestnet Co-authored-by: Trevor Porter --- .../m20220805_000001_create_table_domain.rs | 337 ------------------ ...0001_create_type_enum_checkpoint_update.rs | 34 -- .../m20220805_000002_create_table_block.rs | 88 ----- ...20220805_000003_create_table_checkpoint.rs | 91 ----- .../m20220805_000003_create_table_cursor.rs | 60 ---- ...0220805_000003_create_table_transaction.rs | 132 ------- ...5_000004_create_table_checkpoint_update.rs | 91 ----- ...0220805_000004_create_table_gas_payment.rs | 88 ----- .../m20220805_000004_create_table_message.rs | 143 -------- ...5_000005_create_table_delivered_message.rs | 108 ------ ...20805_000005_create_table_message_state.rs | 96 ----- .../m20221122_000001_create_table_domain.rs | 32 +- rust/hyperlane-core/src/chain.rs | 51 +-- typescript/sdk/src/consts/chainMetadata.ts | 28 +- 14 files changed, 40 insertions(+), 1339 deletions(-) delete mode 100644 rust/agents/scraper/migration/src/m20220805_000001_create_table_domain.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000001_create_type_enum_checkpoint_update.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000002_create_table_block.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000003_create_table_checkpoint.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000003_create_table_cursor.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000003_create_table_transaction.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000004_create_table_checkpoint_update.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000004_create_table_gas_payment.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000004_create_table_message.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000005_create_table_delivered_message.rs delete mode 100644 rust/agents/scraper/migration/src/m20220805_000005_create_table_message_state.rs diff --git a/rust/agents/scraper/migration/src/m20220805_000001_create_table_domain.rs b/rust/agents/scraper/migration/src/m20220805_000001_create_table_domain.rs deleted file mode 100644 index 376483fd2..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000001_create_table_domain.rs +++ /dev/null @@ -1,337 +0,0 @@ -use std::time; -use std::time::UNIX_EPOCH; - -use sea_orm::prelude::DateTime; -use sea_orm_migration::prelude::*; - -/// List of domain data we want to initialize the database with. -/// -/// This needs to be immutable because once we create the tables, we need to -/// make additional migrations to make changes, otherwise we have to rollback -/// everything to apply the new version of this migration again. Admittedly we -/// will reset the database every so often so it isn't as big of a deal, but I -/// want to try and support not having to do that. -/// -/// This is why it does not use the domain id lookup tools in the library which -/// are subject to change as we deprecate and add new ones. -const DOMAINS: &[RawDomain] = &[ - RawDomain { - name: "alfajores", - token: "CELO", - domain: 1000, - chain_id: 44787, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "arbitrum", - token: "ETH", - domain: 6386274, - chain_id: 42161, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "arbitrumgoerli", - token: "ETH", - domain: 421613, - chain_id: 421613, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "arbitrumrinkeby", - token: "ETH", - domain: 0x61722d72, - chain_id: 421611, - is_test_net: true, - is_deprecated: true, - }, - RawDomain { - name: "auroratestnet", - token: "ETH", - domain: 0x61752d74, - chain_id: 1313161555, - is_test_net: true, - is_deprecated: true, - }, - RawDomain { - name: "avalanche", - token: "AVAX", - domain: 0x61766178, - chain_id: 43114, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "bsc", - token: "BNB", - domain: 6452067, - chain_id: 56, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "bsctestnet", - token: "tBNB", - domain: 0x62732d74, - chain_id: 97, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "celo", - token: "CELO", - domain: 0x63656c6f, - chain_id: 42220, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "ethereum", - token: "ETH", - domain: 0x657468, - chain_id: 1, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "fuji", - token: "AVAX", - domain: 43113, - chain_id: 43113, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "goerli", - token: "ETH", - domain: 5, - chain_id: 5, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "kovan", - token: "ETH", - domain: 3000, - chain_id: 42, - is_test_net: true, - is_deprecated: true, - }, - RawDomain { - name: "moonbasealpha", - token: "DEV", - domain: 0x6d6f2d61, - chain_id: 1287, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "moonbeam", - token: "GLMR", - domain: 0x6d6f2d6d, - chain_id: 1284, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "mumbai", - token: "MATIC", - domain: 80001, - chain_id: 80001, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "optimism", - token: "ETH", - domain: 28528, - chain_id: 10, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "optimismgoerli", - token: "ETH", - domain: 420, - chain_id: 420, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "optimismkovan", - token: "ETH", - domain: 0x6f702d6b, - chain_id: 69, - is_test_net: true, - is_deprecated: true, - }, - RawDomain { - name: "polygon", - token: "MATIC", - domain: 0x706f6c79, - chain_id: 137, - is_test_net: false, - is_deprecated: false, - }, - RawDomain { - name: "test1", - token: "ETH", - domain: 13371, - chain_id: 0, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "test2", - token: "ETH", - domain: 13372, - chain_id: 0, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "test3", - token: "ETH", - domain: 13373, - chain_id: 0, - is_test_net: true, - is_deprecated: false, - }, - RawDomain { - name: "zksync2testnet", - token: "ETH", - domain: 280, - chain_id: 280, - is_test_net: true, - is_deprecated: false, - }, -]; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(Domain::Table) - .if_not_exists() - .col( - ColumnDef::new(Domain::Id) - .unsigned() - .not_null() - .primary_key(), - ) - .col( - ColumnDef::new(Domain::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col(ColumnDef::new(Domain::TimeUpdated).timestamp().not_null()) - .col(ColumnDef::new(Domain::Name).text().not_null()) - .col(ColumnDef::new(Domain::NativeToken).text().not_null()) - .col(ColumnDef::new(Domain::ChainId).big_unsigned().unique_key()) - .col(ColumnDef::new(Domain::IsTestNet).boolean().not_null()) - .col(ColumnDef::new(Domain::IsDeprecated).boolean().not_null()) - .to_owned(), - ) - .await?; - - use sea_orm_migration::sea_orm::ActiveValue::{NotSet, Set}; - use sea_orm_migration::sea_orm::EntityTrait; - - let db = manager.get_connection(); - for domain in DOMAINS { - let now = { - let sys = time::SystemTime::now(); - let dur = sys.duration_since(UNIX_EPOCH).unwrap(); - DateTime::from_timestamp(dur.as_secs() as i64, dur.subsec_nanos()) - }; - - EntityTrait::insert(domain::ActiveModel { - id: Set(domain.domain), - time_created: Set(now), - time_updated: Set(now), - name: Set(domain.name.to_owned()), - native_token: Set(domain.token.to_owned()), - chain_id: if domain.chain_id == 0 { - // this is to support testnets and maybe in the future chains without chain ids. - NotSet - } else { - Set(domain.chain_id) - }, - is_test_net: Set(domain.is_test_net), - is_deprecated: Set(domain.is_deprecated), - }) - .exec(db) - .await?; - } - - Ok(()) - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Domain::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum Domain { - Table, - /// Hyperlane domain ID - Id, - /// Time of record creation - TimeCreated, - /// Time of the last record update - TimeUpdated, - /// Human readable name of the domain - Name, - /// Symbol for the native token - NativeToken, - /// For EVM compatible chains, the official EVM chain ID - ChainId, - /// Whether this is a test network - IsTestNet, - /// Whether this domain has been decommissioned from active use. - IsDeprecated, -} - -mod domain { - use sea_orm_migration::sea_orm::entity::prelude::*; - - #[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel)] - #[sea_orm(table_name = "domain")] - pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - id: u32, - time_created: DateTime, - time_updated: DateTime, - name: String, - native_token: String, - chain_id: u64, - is_test_net: bool, - is_deprecated: bool, - } - - #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] - pub enum Relation {} - - impl ActiveModelBehavior for ActiveModel {} -} - -struct RawDomain { - name: &'static str, - token: &'static str, - domain: u32, - chain_id: u64, - is_test_net: bool, - is_deprecated: bool, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000001_create_type_enum_checkpoint_update.rs b/rust/agents/scraper/migration/src/m20220805_000001_create_type_enum_checkpoint_update.rs deleted file mode 100644 index 735cd1c50..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000001_create_type_enum_checkpoint_update.rs +++ /dev/null @@ -1,34 +0,0 @@ -use sea_orm_migration::prelude::*; -use sea_orm_migration::sea_orm::strum::{EnumIter, IntoEnumIterator as _}; - -use crate::extension::postgres::Type; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_type( - Type::create() - .as_enum(CheckpointUpdateType::Table) - .values(CheckpointUpdateType::iter().skip(1)) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_type(Type::drop().name(CheckpointUpdateType::Table).to_owned()) - .await - } -} - -#[derive(EnumIter, Iden)] -pub enum CheckpointUpdateType { - Table, - Premature, - Fraudulent, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000002_create_table_block.rs b/rust/agents/scraper/migration/src/m20220805_000002_create_table_block.rs deleted file mode 100644 index 710866cd7..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000002_create_table_block.rs +++ /dev/null @@ -1,88 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::l20220805_types::*; -use crate::m20220805_000001_create_table_domain::Domain; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(Block::Table) - .if_not_exists() - .col( - ColumnDef::new(Block::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(Block::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col(ColumnDef::new(Block::Domain).unsigned().not_null()) - .col( - ColumnDef::new_with_type(Block::Hash, Hash) - .unique_key() - .not_null(), - ) - .col(ColumnDef::new(Block::Height).big_unsigned().not_null()) - .col(ColumnDef::new(Block::Timestamp).timestamp().not_null()) - .foreign_key( - ForeignKey::create() - .from_col(Block::Domain) - .to(Domain::Table, Domain::Id), - ) - .index( - Index::create() - .col(Block::Domain) - .col(Block::Height) - .unique(), - ) - .to_owned(), - ) - .await?; - - manager - .create_index( - Index::create() - .table(Block::Table) - .name("block_hash_idx") - .col(Block::Hash) - .index_type(IndexType::Hash) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Block::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum Block { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// Domain id the block is on - Domain, - /// Block hash - Hash, - /// Block height - Height, - /// Time the block was created at - Timestamp, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000003_create_table_checkpoint.rs b/rust/agents/scraper/migration/src/m20220805_000003_create_table_checkpoint.rs deleted file mode 100644 index d5258f3f1..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000003_create_table_checkpoint.rs +++ /dev/null @@ -1,91 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::l20220805_types::*; -use crate::m20220805_000001_create_table_domain::Domain; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(Checkpoint::Table) - .if_not_exists() - .col( - ColumnDef::new(Checkpoint::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(Checkpoint::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col(ColumnDef::new(Checkpoint::Timestamp).timestamp().not_null()) - .col(ColumnDef::new(Checkpoint::Signature).binary().not_null()) - .col(ColumnDef::new_with_type(Checkpoint::Validator, Address).not_null()) - .col(ColumnDef::new_with_type(Checkpoint::Root, Hash).not_null()) - .col(ColumnDef::new(Checkpoint::Index).unsigned().not_null()) - .col( - ColumnDef::new(Checkpoint::OriginDomain) - .unsigned() - .not_null(), - ) - .col(ColumnDef::new_with_type(Checkpoint::OutboxAddress, Address).not_null()) - .foreign_key( - ForeignKey::create() - .from_col(Checkpoint::OriginDomain) - .to(Domain::Table, Domain::Id), - ) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Checkpoint::Table) - .name("checkpoint_outbox_domain_index_idx") - .col(Checkpoint::OutboxAddress) - .col(Checkpoint::OriginDomain) - .col(Checkpoint::Index) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Checkpoint::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum Checkpoint { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// Time the checkpoint was made - Timestamp, - /// Validator's signature that this is a valid checkpoint - Signature, - /// Address of the validator - Validator, - /// Merkle tree root hash - Root, - /// Highest leaf index this checkpoint includes - Index, - /// Domain of the origin chain this checkpoint was made for. - OriginDomain, - /// Address of the outbox this checkpoint was made for - OutboxAddress, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000003_create_table_cursor.rs b/rust/agents/scraper/migration/src/m20220805_000003_create_table_cursor.rs deleted file mode 100644 index d1a8d8639..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000003_create_table_cursor.rs +++ /dev/null @@ -1,60 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::m20220805_000001_create_table_domain::Domain; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(Cursor::Table) - .if_not_exists() - .col( - ColumnDef::new(Cursor::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col(ColumnDef::new(Cursor::Domain).unsigned().not_null()) - .col( - ColumnDef::new(Cursor::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col(ColumnDef::new(Cursor::Height).big_unsigned().not_null()) - .foreign_key( - ForeignKey::create() - .from_col(Cursor::Domain) - .to(Domain::Table, Domain::Id), - ) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Cursor::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum Cursor { - Table, - /// Unique database ID - Id, - /// Hyperlane domain ID the cursor is for - Domain, - /// Time when the record was created - TimeCreated, - /// Height of the last block read for finality - Height, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000003_create_table_transaction.rs b/rust/agents/scraper/migration/src/m20220805_000003_create_table_transaction.rs deleted file mode 100644 index 77020d27f..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000003_create_table_transaction.rs +++ /dev/null @@ -1,132 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::l20220805_types::*; -use crate::m20220805_000002_create_table_block::Block; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(Transaction::Table) - .if_not_exists() - .col( - ColumnDef::new(Transaction::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(Transaction::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col( - ColumnDef::new_with_type(Transaction::Hash, Hash) - .not_null() - .unique_key(), - ) - .col( - ColumnDef::new(Transaction::BlockId) - .big_integer() - .not_null(), - ) - .col(ColumnDef::new(Transaction::GasLimit).double().not_null()) - .col(ColumnDef::new(Transaction::MaxPriorityFeePerGas).double()) - .col(ColumnDef::new(Transaction::MaxFeePerGas).double()) - .col(ColumnDef::new(Transaction::GasPrice).double()) - .col(ColumnDef::new(Transaction::EffectiveGasPrice).double()) - .col(ColumnDef::new(Transaction::Nonce).big_unsigned().not_null()) - .col(ColumnDef::new_with_type(Transaction::Sender, Address).not_null()) - .col(&mut ColumnDef::new_with_type( - Transaction::Recipient, - Address, - )) - .col(ColumnDef::new(Transaction::GasUsed).double().not_null()) - .col( - ColumnDef::new(Transaction::CumulativeGasUsed) - .double() - .not_null(), - ) - .foreign_key( - ForeignKey::create() - .from_col(Transaction::BlockId) - .to(Block::Table, Block::Id), - ) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Transaction::Table) - .name("transaction_hash_idx") - .col(Transaction::Hash) - .index_type(IndexType::Hash) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Transaction::Table) - .name("transaction_sender_idx") - .col(Transaction::Sender) - .index_type(IndexType::Hash) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Transaction::Table) - .name("transaction_block_idx") - .col(Transaction::BlockId) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Transaction::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum Transaction { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// The transaction hash - Hash, - /// Block this transaction was included in - BlockId, - /// Amount of gas which was allocated for running the transaction - GasLimit, - MaxPriorityFeePerGas, - MaxFeePerGas, - /// Price paid for gas on this txn. Null for type 2 txns. - GasPrice, - EffectiveGasPrice, - /// Nonce of this transaction by the sneder - Nonce, - /// Transaction signer - Sender, - /// Recipient or contract - Recipient, - /// Amount of gas used by this transaction - GasUsed, - /// Cumulative gas used within the block after this was executed - CumulativeGasUsed, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000004_create_table_checkpoint_update.rs b/rust/agents/scraper/migration/src/m20220805_000004_create_table_checkpoint_update.rs deleted file mode 100644 index 6d63c6e20..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000004_create_table_checkpoint_update.rs +++ /dev/null @@ -1,91 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::m20220805_000001_create_type_enum_checkpoint_update::CheckpointUpdateType; -use crate::m20220805_000003_create_table_checkpoint::Checkpoint; -use crate::m20220805_000003_create_table_transaction::Transaction; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(CheckpointUpdate::Table) - .if_not_exists() - .col( - ColumnDef::new(CheckpointUpdate::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(CheckpointUpdate::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col( - ColumnDef::new(CheckpointUpdate::CheckpointId) - .big_integer() - .not_null(), - ) - .col( - ColumnDef::new(CheckpointUpdate::UpdateType) - .custom(CheckpointUpdateType::Table) - .not_null(), - ) - .col( - ColumnDef::new(CheckpointUpdate::TxId) - .big_integer() - .not_null(), - ) - .foreign_key( - ForeignKey::create() - .from_col(CheckpointUpdate::CheckpointId) - .to(Checkpoint::Table, Checkpoint::Id), - ) - .foreign_key( - ForeignKey::create() - .from_col(CheckpointUpdate::TxId) - .to(Transaction::Table, Transaction::Id), - ) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .name("checkpoint_update_checkpoint_idx") - .table(CheckpointUpdate::Table) - .col(CheckpointUpdate::CheckpointId) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(CheckpointUpdate::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum CheckpointUpdate { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// Checkpoint this is an update for. - CheckpointId, - /// What this update is. - UpdateType, - /// Transaction the update was made in. - TxId, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000004_create_table_gas_payment.rs b/rust/agents/scraper/migration/src/m20220805_000004_create_table_gas_payment.rs deleted file mode 100644 index 141bcc5f5..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000004_create_table_gas_payment.rs +++ /dev/null @@ -1,88 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::l20220805_types::*; -use crate::m20220805_000001_create_table_domain::Domain; -use crate::m20220805_000003_create_table_transaction::Transaction; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(GasPayment::Table) - .if_not_exists() - .col( - ColumnDef::new(GasPayment::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(GasPayment::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col(ColumnDef::new(GasPayment::Domain).unsigned().not_null()) - .col(ColumnDef::new(GasPayment::LeafIndex).unsigned().not_null()) - .col(ColumnDef::new_with_type(GasPayment::OutboxAddress, Address).not_null()) - .col(ColumnDef::new_with_type(GasPayment::Amount, CryptoCurrency).not_null()) - .col(ColumnDef::new(GasPayment::TxId).big_integer().not_null()) - .foreign_key( - ForeignKey::create() - .from_col(GasPayment::TxId) - .to(Transaction::Table, Transaction::Id), - ) - .foreign_key( - ForeignKey::create() - .from_col(GasPayment::Domain) - .to(Domain::Table, Domain::Id), - ) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(GasPayment::Table) - .name("gas_payment_domain_outbox_leaf_idx") - .col(GasPayment::Domain) - .col(GasPayment::OutboxAddress) - .col(GasPayment::LeafIndex) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(GasPayment::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum GasPayment { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// Domain ID of the chain the payment was made on; technically duplicating - /// Tx -> Block -> Domain but this will be used a lot for lookups. - Domain, - /// Message leaf index the payment was for - LeafIndex, - /// Address of the outbox contract - OutboxAddress, - /// How much was paid - Amount, - /// Transaction the payment was made in - TxId, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000004_create_table_message.rs b/rust/agents/scraper/migration/src/m20220805_000004_create_table_message.rs deleted file mode 100644 index c83c4668c..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000004_create_table_message.rs +++ /dev/null @@ -1,143 +0,0 @@ -use crate::l20220805_types::*; -use crate::m20220805_000001_create_table_domain::Domain; -use crate::m20220805_000003_create_table_transaction::Transaction; -use sea_orm_migration::prelude::*; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(Message::Table) - .if_not_exists() - .col( - ColumnDef::new(Message::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(Message::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col( - ColumnDef::new_with_type(Message::Hash, Hash) - .not_null() - .unique_key(), - ) - .col(ColumnDef::new(Message::Origin).unsigned().not_null()) - .col(ColumnDef::new(Message::Destination).unsigned().not_null()) - .col(ColumnDef::new(Message::LeafIndex).unsigned().not_null()) - .col(ColumnDef::new_with_type(Message::Sender, Address).not_null()) - .col(ColumnDef::new_with_type(Message::Recipient, Address).not_null()) - .col(ColumnDef::new(Message::MsgBody).binary()) - .col(ColumnDef::new_with_type(Message::OutboxAddress, Address).not_null()) - .col(ColumnDef::new(Message::Timestamp).timestamp().not_null()) - .col(ColumnDef::new(Message::OriginTxId).big_integer().not_null()) - .foreign_key( - ForeignKey::create() - .from_col(Message::Origin) - .to(Domain::Table, Domain::Id), - ) - .foreign_key( - ForeignKey::create() - .from_col(Message::OriginTxId) - .to(Transaction::Table, Transaction::Id), - ) - .index( - Index::create() - .unique() - .col(Message::OutboxAddress) - .col(Message::Origin) - .col(Message::LeafIndex), - ) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Message::Table) - .name("msg_tx_timestamp") - .col(Message::Timestamp) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Message::Table) - .name("message_tx_idx") - .col(Message::OriginTxId) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Message::Table) - .name("message_sender_idx") - .col(Message::Sender) - .index_type(IndexType::Hash) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(Message::Table) - .name("message_recipient_idx") - .col(Message::Recipient) - .index_type(IndexType::Hash) - .to_owned(), - ) - .await?; - - Ok(()) - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(Message::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum Message { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// Message hash - Hash, - /// Domain ID of the origin chain - Origin, - /// Domain ID of the destination chain - Destination, - /// Leaf index of this message in the merkle tree of the outbox - LeafIndex, - /// Address of the message sender on the origin chain (not necessarily the - /// transaction signer) - Sender, - /// Address of the message recipient on the destination chain. - Recipient, - /// Binary blob included in the message. - MsgBody, - /// Address of the outbox contract - OutboxAddress, - /// timestamp on block that includes the origin transaction (saves a double - /// join) - Timestamp, - /// Transaction this message was dispatched in on the origin chain. - OriginTxId, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000005_create_table_delivered_message.rs b/rust/agents/scraper/migration/src/m20220805_000005_create_table_delivered_message.rs deleted file mode 100644 index c11a7135f..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000005_create_table_delivered_message.rs +++ /dev/null @@ -1,108 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::l20220805_types::*; -use crate::m20220805_000001_create_table_domain::Domain; -use crate::m20220805_000003_create_table_transaction::Transaction; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(DeliveredMessage::Table) - .if_not_exists() - .col( - ColumnDef::new(DeliveredMessage::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(DeliveredMessage::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col( - ColumnDef::new_with_type(DeliveredMessage::Hash, Hash) - .not_null() - .unique_key(), - ) - .col( - ColumnDef::new(DeliveredMessage::Domain) - .unsigned() - .not_null(), - ) - .col( - ColumnDef::new_with_type(DeliveredMessage::InboxAddress, Address) - .not_null(), - ) - .col( - ColumnDef::new(DeliveredMessage::TxId) - .big_integer() - .not_null(), - ) - .foreign_key( - ForeignKey::create() - .from_col(DeliveredMessage::Domain) - .to(Domain::Table, Domain::Id), - ) - .foreign_key( - ForeignKey::create() - .from_col(DeliveredMessage::TxId) - .to(Transaction::Table, Transaction::Id), - ) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(DeliveredMessage::Table) - .name("delivered_message_tx_idx") - .col(DeliveredMessage::TxId) - .to_owned(), - ) - .await?; - manager - .create_index( - Index::create() - .table(DeliveredMessage::Table) - .name("delivered_message_hash_idx") - .col(DeliveredMessage::Hash) - .index_type(IndexType::Hash) - .to_owned(), - ) - .await?; - Ok(()) - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(DeliveredMessage::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum DeliveredMessage { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// Hash of the message which was delivered - Hash, - /// Domain the message was received on - Domain, - /// Address of the inbox contract the message was received by - InboxAddress, - /// Transaction the delivery was included in - TxId, -} diff --git a/rust/agents/scraper/migration/src/m20220805_000005_create_table_message_state.rs b/rust/agents/scraper/migration/src/m20220805_000005_create_table_message_state.rs deleted file mode 100644 index 6b84418d3..000000000 --- a/rust/agents/scraper/migration/src/m20220805_000005_create_table_message_state.rs +++ /dev/null @@ -1,96 +0,0 @@ -use sea_orm_migration::prelude::*; - -use crate::l20220805_types::*; -use crate::m20220805_000004_create_table_message::Message; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(MessageState::Table) - .if_not_exists() - .col( - ColumnDef::new(MessageState::Id) - .big_integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col( - ColumnDef::new(MessageState::TimeCreated) - .timestamp() - .not_null() - .default("NOW()"), - ) - .col(ColumnDef::new(MessageState::MsgId).big_integer().not_null()) - .col( - ColumnDef::new(MessageState::BlockHeight) - .big_unsigned() - .not_null(), - ) - .col( - ColumnDef::new(MessageState::BlockTimestamp) - .timestamp() - .not_null(), - ) - .col( - ColumnDef::new(MessageState::Processable) - .boolean() - .not_null(), - ) - .col(&mut ColumnDef::new_with_type( - MessageState::EstimatedGasCost, - CryptoCurrency, - )) - .col(ColumnDef::new(MessageState::ErrorMsg).text()) - .foreign_key( - ForeignKey::create() - .from_col(MessageState::MsgId) - .to(Message::Table, Message::Id), - ) - .index( - Index::create() - .col(MessageState::MsgId) - .col(MessageState::BlockHeight) - .unique(), - ) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(MessageState::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -pub enum MessageState { - Table, - /// Unique database ID - Id, - /// Time of record creation - TimeCreated, - /// Message this state was calculated for - MsgId, - /// Height of the block this state was calculated with - BlockHeight, - /// Timestamp of the block this was calculated for - BlockTimestamp, - /// Whether or not gas estimation on handle succeeds - Processable, - /// How much gas we expect it would cost to deliver the message; null if we - /// could not estimate - EstimatedGasCost, - /// Error message when running estimateGas if there was an error; null if - /// there was no error - ErrorMsg, -} diff --git a/rust/agents/scraper/migration/src/m20221122_000001_create_table_domain.rs b/rust/agents/scraper/migration/src/m20221122_000001_create_table_domain.rs index 376483fd2..13e343425 100644 --- a/rust/agents/scraper/migration/src/m20221122_000001_create_table_domain.rs +++ b/rust/agents/scraper/migration/src/m20221122_000001_create_table_domain.rs @@ -18,7 +18,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "alfajores", token: "CELO", - domain: 1000, + domain: 44787, chain_id: 44787, is_test_net: true, is_deprecated: false, @@ -26,7 +26,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "arbitrum", token: "ETH", - domain: 6386274, + domain: 42161, chain_id: 42161, is_test_net: false, is_deprecated: false, @@ -42,23 +42,15 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "arbitrumrinkeby", token: "ETH", - domain: 0x61722d72, + domain: 421611, chain_id: 421611, is_test_net: true, is_deprecated: true, }, - RawDomain { - name: "auroratestnet", - token: "ETH", - domain: 0x61752d74, - chain_id: 1313161555, - is_test_net: true, - is_deprecated: true, - }, RawDomain { name: "avalanche", token: "AVAX", - domain: 0x61766178, + domain: 43114, chain_id: 43114, is_test_net: false, is_deprecated: false, @@ -66,7 +58,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "bsc", token: "BNB", - domain: 6452067, + domain: 56, chain_id: 56, is_test_net: false, is_deprecated: false, @@ -74,7 +66,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "bsctestnet", token: "tBNB", - domain: 0x62732d74, + domain: 97, chain_id: 97, is_test_net: true, is_deprecated: false, @@ -82,7 +74,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "celo", token: "CELO", - domain: 0x63656c6f, + domain: 42220, chain_id: 42220, is_test_net: false, is_deprecated: false, @@ -122,7 +114,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "moonbasealpha", token: "DEV", - domain: 0x6d6f2d61, + domain: 1287, chain_id: 1287, is_test_net: true, is_deprecated: false, @@ -130,7 +122,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "moonbeam", token: "GLMR", - domain: 0x6d6f2d6d, + domain: 1284, chain_id: 1284, is_test_net: false, is_deprecated: false, @@ -146,7 +138,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "optimism", token: "ETH", - domain: 28528, + domain: 10, chain_id: 10, is_test_net: false, is_deprecated: false, @@ -162,7 +154,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "optimismkovan", token: "ETH", - domain: 0x6f702d6b, + domain: 69, chain_id: 69, is_test_net: true, is_deprecated: true, @@ -170,7 +162,7 @@ const DOMAINS: &[RawDomain] = &[ RawDomain { name: "polygon", token: "MATIC", - domain: 0x706f6c79, + domain: 137, chain_id: 137, is_test_net: false, is_deprecated: false, diff --git a/rust/hyperlane-core/src/chain.rs b/rust/hyperlane-core/src/chain.rs index 5f6e72f2b..2bdc7dc63 100644 --- a/rust/hyperlane-core/src/chain.rs +++ b/rust/hyperlane-core/src/chain.rs @@ -58,51 +58,34 @@ impl From<&'_ Address> for ethers::types::H160 { #[derive(FromPrimitive, EnumString, strum::Display, EnumIter, PartialEq, Eq, Debug)] #[strum(serialize_all = "lowercase")] pub enum HyperlaneDomain { - /// Ethereum mainnet domain ID, decimal ID 6648936 - Ethereum = 0x657468, - /// Ethereum testnet Goerli domain ID + Ethereum = 1, Goerli = 5, - /// Ethereum testnet Kovan domain ID Kovan = 3000, - /// Polygon mainnet domain ID, decimal ID 1886350457 - Polygon = 0x706f6c79, - /// Polygon testnet Mumbai domain ID + Polygon = 137, Mumbai = 80001, - /// Avalanche mainnet domain ID, decimal ID 1635148152 - Avalanche = 0x61766178, - /// Avalanche testnet Fuji domain ID + Avalanche = 43114, Fuji = 43113, - /// Arbitrum mainnet domain ID, decimal ID 6386274 - Arbitrum = 0x617262, - /// Arbitrum testnet ArbitrumRinkeby domain ID, decimal ID 1634872690 - ArbitrumRinkeby = 0x61722d72, + Arbitrum = 42161, + ArbitrumRinkeby = 421611, ArbitrumGoerli = 421613, - /// Optimism mainnet domain ID, decimal ID 28528 - Optimism = 0x6f70, - /// Optimism testnet OptimismKovan domain ID, decimal ID 1869622635 - OptimismKovan = 0x6f702d6b, + Optimism = 10, + OptimismKovan = 69, OptimismGoerli = 420, - /// BSC mainnet domain ID, decimal ID 6452067 #[strum(serialize = "bsc")] - BinanceSmartChain = 0x627363, - /// BSC testnet, decimal ID 1651715444 + BinanceSmartChain = 56, #[strum(serialize = "bsctestnet")] - BinanceSmartChainTestnet = 0x62732d74, + BinanceSmartChainTestnet = 97, - /// Celo domain ID, decimal ID 1667591279 - Celo = 0x63656c6f, - /// Celo testnet Alfajores domain ID - Alfajores = 1000, + Celo = 42220, + Alfajores = 44787, - /// Moonbeam testnet MoonbaseAlpha domain ID, decimal ID 1836002657 - MoonbaseAlpha = 0x6d6f2d61, - /// Moonbeam domain ID, decimal ID 1836002669 - Moonbeam = 0x6d6f2d6d, + MoonbaseAlpha = 1287, + Moonbeam = 1284, Zksync2Testnet = 280, @@ -332,23 +315,23 @@ mod tests { #[test] fn domain_ids() { assert_eq!( - HyperlaneDomain::try_from(0x657468u32).unwrap(), + HyperlaneDomain::try_from(1).unwrap(), HyperlaneDomain::Ethereum, ); - assert_eq!(u32::from(HyperlaneDomain::Ethereum), 0x657468u32,); + assert_eq!(u32::from(HyperlaneDomain::Ethereum), 1); } #[test] fn test_name_from_domain_id() { - assert_eq!(name_from_domain_id(0x657468u32), Some("ethereum".into()),); + assert_eq!(name_from_domain_id(1), Some("ethereum".into()),); assert_eq!(name_from_domain_id(0xf00u32), None,); } #[test] fn test_domain_id_from_name() { - assert_eq!(domain_id_from_name("ethereum"), Some(0x657468u32),); + assert_eq!(domain_id_from_name("ethereum"), Some(1),); assert_eq!(domain_id_from_name("foo"), None,); } diff --git a/typescript/sdk/src/consts/chainMetadata.ts b/typescript/sdk/src/consts/chainMetadata.ts index c9b530e11..9a2b731b0 100644 --- a/typescript/sdk/src/consts/chainMetadata.ts +++ b/typescript/sdk/src/consts/chainMetadata.ts @@ -31,20 +31,20 @@ export interface RpcPagination { * Mainnets */ export const celo: ChainMetadata = { - id: 0x63656c6f, // b'celo' interpreted as an int + id: 42220, finalityBlocks: 0, gnosisSafeTransactionServiceUrl: 'https://transaction-service.gnosis-safe-staging.celo-networks-dev.org', }; export const ethereum: ChainMetadata = { - id: 0x657468, // b'eth' interpreted as an int + id: 1, finalityBlocks: 20, gnosisSafeTransactionServiceUrl: 'https://safe-transaction.gnosis.io', }; export const arbitrum: ChainMetadata = { - id: 0x617262, // b'arb' interpreted as an int + id: 42161, finalityBlocks: 0, gasCurrencyCoinGeckoId: 'ethereum', // ETH is used for gas gnosisSafeTransactionServiceUrl: @@ -52,7 +52,7 @@ export const arbitrum: ChainMetadata = { }; export const optimism: ChainMetadata = { - id: 0x6f70, // b'op' interpreted as an int + id: 10, finalityBlocks: 0, gasCurrencyCoinGeckoId: 'ethereum', // ETH is used for gas gnosisSafeTransactionServiceUrl: @@ -60,14 +60,14 @@ export const optimism: ChainMetadata = { }; export const bsc: ChainMetadata = { - id: 0x627363, // b'bsc' interpreted as an int + id: 56, finalityBlocks: 15, gasCurrencyCoinGeckoId: 'binancecoin', gnosisSafeTransactionServiceUrl: 'https://safe-transaction.bsc.gnosis.io/', }; export const avalanche: ChainMetadata = { - id: 0x61766178, // b'avax' interpreted as an int + id: 43114, finalityBlocks: 3, paginate: { // Needs to be low to avoid RPC timeouts @@ -80,7 +80,7 @@ export const avalanche: ChainMetadata = { }; export const polygon: ChainMetadata = { - id: 0x706f6c79, // b'poly' interpreted as an int + id: 137, finalityBlocks: 256, paginate: { // Needs to be low to avoid RPC timeouts @@ -96,7 +96,7 @@ export const polygon: ChainMetadata = { * Testnets */ export const alfajores: ChainMetadata = { - id: 1000, + id: 44787, finalityBlocks: 0, }; @@ -151,22 +151,17 @@ const testChains = { }; export const bsctestnet: ChainMetadata = { - id: 0x62732d74, // b'bs-t' interpreted as an int + id: 97, finalityBlocks: 9, }; -export const auroratestnet: ChainMetadata = { - id: 0x61752d74, // b'au-t' interpreted as an int - finalityBlocks: 1, -}; - export const moonbasealpha: ChainMetadata = { - id: 0x6d6f2d61, // b'mo-a' interpreted as an int + id: 1287, finalityBlocks: 1, }; export const moonbeam: ChainMetadata = { - id: 0x6d6f2d6d, // b'mo-a' interpreted as an int + id: 1284, finalityBlocks: 1, }; @@ -183,7 +178,6 @@ export const chainMetadata = { goerli, mumbai, bsctestnet, - auroratestnet, moonbasealpha, moonbeam, optimismgoerli,