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 <trkporter@ucdavis.edu>pull/1333/head^2
parent
bea8903982
commit
821a486082
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
@ -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, |
||||
} |
Loading…
Reference in new issue