Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions crates/constants/src/chains/mainnet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//! Constants for the Mainnet.

use crate::{
HostConstants, HostTokens, HostUsdRecord, RollupConstants, RollupTokens, SignetConstants,
SignetEnvironmentConstants, SignetSystemConstants, UsdRecords,
};
use alloy::primitives::{address, Address};
use std::borrow::Cow;

/// Name for the host chain.
pub const HOST_NAME: &str = "Mainnet";
/// Chain ID for the Mainnet host chain.
pub const HOST_CHAIN_ID: u64 = 1;
/// Deployment height of the rollup on Mainnet host chain.
pub const DEPLOY_HEIGHT: u64 = 23734244;
/// `Zenith` contract address for the Mainnet host chain.
pub const HOST_ZENITH: Address = address!("0xBCe84D45d7be8859bcBd838d4a7b3448B55E6869");
/// `Orders` contract address for the Mainnet host chain.
pub const HOST_ORDERS: Address = address!("0x96f44ddc3Bc8892371305531F1a6d8ca2331fE6C");
/// `Passage` contract address for the Mainnet host chain.
pub const HOST_PASSAGE: Address = address!("0x02a64d6e2c30d2B07ddBD177b24D9D0f6439CcbD");
/// `Transactor` contract address for the Mainnet host chain.
pub const HOST_TRANSACTOR: Address = address!("0xC4388A6f4917B8D392B19b43F9c46FEC1B890f45");

/// USDC token for the Mainnet host chain (empty placeholder).
pub const HOST_USDC: Address = address!("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
/// USDT token for the Mainnet host chain (empty placeholder).
pub const HOST_USDT: Address = address!("0xdAC17F958D2ee523a2206206994597C13D831ec7");
/// WBTC token for the Mainnet host chain (empty placeholder).
pub const HOST_WBTC: Address = address!("0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599");
/// WETH token for the Mainnet host chain (empty placeholder).
pub const HOST_WETH: Address = address!("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2");

/// USDC token record for the Mainnet host chain (placeholder name/decimals).
pub const HOST_USDC_RECORD: HostUsdRecord = HostUsdRecord::new(HOST_USDC, Cow::Borrowed("USDC"), 6);
/// USDT token record for the Mainnet host chain (placeholder name/decimals).
pub const HOST_USDT_RECORD: HostUsdRecord = HostUsdRecord::new(HOST_USDT, Cow::Borrowed("USDT"), 6);
/// Host USD records for the Mainnet host chain (empty list by default).
pub const HOST_USD_RECORDS: UsdRecords = UsdRecords::new();
/// Host system tokens for Mainnet (placeholders).
pub const HOST_TOKENS: HostTokens = HostTokens::new(HOST_USD_RECORDS, HOST_WBTC, HOST_WETH);

/// Host system constants for Mainnet.
pub const HOST: HostConstants = crate::HostConstants::new(
HOST_CHAIN_ID,
DEPLOY_HEIGHT,
HOST_ZENITH,
HOST_ORDERS,
HOST_PASSAGE,
HOST_TRANSACTOR,
HOST_TOKENS,
);

/// Name for the network.
pub const RU_NAME: &str = "Signet";
/// Chain ID for the Mainnet RU chain.
pub const RU_CHAIN_ID: u64 = 519;

/// WETH token for the Mainnet RU chain (placeholder).
pub const RU_WETH: Address = address!("0x0000000000000000007369676e65742d77657468");
/// WBTC token for the Mainnet RU chain (placeholder).
pub const RU_WBTC: Address = address!("0x0000000000000000007369676e65742d77627463");
/// `Orders` contract address for the Mainnet RU chain (placeholder).
pub const RU_ORDERS: Address = address!("0x000000000000007369676e65742d6f7264657273");
/// `Passage` contract address for the Mainnet RU chain (placeholder).
pub const RU_PASSAGE: Address = address!("0x0000000000007369676e65742d70617373616765");
/// The WETH9-based wrapped native USD token contract (placeholder).
pub const WRAPPED: Address = address!("0x0000000000000000007369676e65742D77757364");
/// RU pre-approved system tokens for Mainnet (placeholders).
pub const RU_TOKENS: RollupTokens = RollupTokens::new(RU_WBTC, RU_WETH);

/// Base fee recipient address for the Mainnet RU chain (placeholder).
pub const BASE_FEE_RECIPIENT: Address = address!("0x86Fa9c9fb93C5F6022276db84bf2A05b5a72283E");

/// RU system constants for Mainnet.
pub const ROLLUP: RollupConstants =
crate::RollupConstants::new(RU_CHAIN_ID, RU_ORDERS, RU_PASSAGE, BASE_FEE_RECIPIENT, RU_TOKENS);

/// Signet system constants for Mainnet.
pub const MAINNET_SYS: SignetSystemConstants = crate::SignetSystemConstants::new(HOST, ROLLUP);

/// Signet environment constants for Mainnet.
pub const MAINNET_ENV: SignetEnvironmentConstants = SignetEnvironmentConstants::new(
Cow::Borrowed(HOST_NAME),
Cow::Borrowed(RU_NAME),
Cow::Borrowed(TX_CACHE_URL),
);

/// Signet constants for Mainnet.
pub const MAINNET: SignetConstants = SignetConstants::new(MAINNET_SYS, MAINNET_ENV);

/// The URL of the Transaction Cache endpoint (empty for mainnet placeholder).
pub const TX_CACHE_URL: &str = "TODO";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing missing is the tx cache url cc @rswanson

4 changes: 3 additions & 1 deletion crates/constants/src/chains/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod test_utils;
pub mod mainnet;

pub mod pecorino;

pub mod test_utils;
4 changes: 2 additions & 2 deletions crates/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#![cfg_attr(docsrs, feature(doc_cfg))]

mod chains;
pub use chains::test_utils;

pub use chains::mainnet;
pub use chains::pecorino;
pub use chains::test_utils;

mod types;
pub use types::{
Expand Down
7 changes: 5 additions & 2 deletions crates/constants/src/types/chains.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::str::FromStr;

/// The list of known chains as a string.
const KNOWN_CHAINS: &str = "pecorino, test";
const KNOWN_CHAINS: &str = "mainnet, pecorino, test";

/// Error type for parsing struct from a chain name.
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
Expand All @@ -14,6 +14,8 @@ pub enum ParseChainError {
/// Known chains for the Signet system.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum KnownChains {
/// Mainnet chain.
Mainnet,
/// Pecorino chain.
Pecorino,
/// Test chain.
Expand All @@ -26,8 +28,9 @@ impl FromStr for KnownChains {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let s = s.trim().to_lowercase();
match s.as_str() {
"test" => Ok(Self::Test),
"mainnet" => Ok(Self::Mainnet),
"pecorino" => Ok(Self::Pecorino),
"test" => Ok(Self::Test),
_ => Err(ParseChainError::ChainNotSupported(s)),
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/constants/src/types/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ impl SignetEnvironmentConstants {
Self { host_name, rollup_name, transaction_cache }
}

/// Get the hard-coded Mainnet environment constants.
pub const fn mainnet() -> Self {
crate::chains::mainnet::MAINNET_ENV
}

/// Get the hard-coded Pecorino environment constants.
pub const fn pecorino() -> Self {
crate::chains::pecorino::PECORINO_ENV
Expand Down Expand Up @@ -53,6 +58,7 @@ impl TryFrom<KnownChains> for SignetEnvironmentConstants {

fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
match chain {
KnownChains::Mainnet => Ok(Self::mainnet()),
KnownChains::Pecorino => Ok(Self::pecorino()),
KnownChains::Test => Ok(Self::test()),
}
Expand Down
6 changes: 6 additions & 0 deletions crates/constants/src/types/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ impl HostConstants {
Self { chain_id, deploy_height, zenith, orders, passage, transactor, tokens }
}

/// Get the hard-coded Mainnet host constants.
pub const fn mainnet() -> Self {
crate::chains::mainnet::HOST
}

/// Get the hard-coded Pecorino host constants.
pub const fn pecorino() -> Self {
crate::chains::pecorino::HOST
Expand Down Expand Up @@ -146,6 +151,7 @@ impl FromStr for HostConstants {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let chain: KnownChains = s.parse()?;
match chain {
KnownChains::Mainnet => Ok(Self::mainnet()),
KnownChains::Pecorino => Ok(Self::pecorino()),
KnownChains::Test => Ok(Self::test()),
}
Expand Down
12 changes: 12 additions & 0 deletions crates/constants/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ impl SignetSystemConstants {
Self { host, rollup }
}

/// Get the hard-coded Mainnet constants.
pub const fn mainnet() -> Self {
crate::chains::mainnet::MAINNET_SYS
}

/// Get the hard-coded Pecorino constants.
pub const fn pecorino() -> Self {
crate::chains::pecorino::PECORINO_SYS
Expand Down Expand Up @@ -225,6 +230,7 @@ impl TryFrom<KnownChains> for SignetSystemConstants {

fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
match chain {
KnownChains::Mainnet => Ok(Self::mainnet()),
KnownChains::Pecorino => Ok(Self::pecorino()),
KnownChains::Test => Ok(Self::test()),
}
Expand Down Expand Up @@ -257,6 +263,11 @@ impl SignetConstants {
Self { system, environment }
}

/// Get the hard-coded Mainnet rollup constants.
pub const fn mainnet() -> Self {
crate::chains::mainnet::MAINNET
}

/// Get the hard-coded Pecorino rollup constants.
pub const fn pecorino() -> Self {
crate::chains::pecorino::PECORINO
Expand Down Expand Up @@ -293,6 +304,7 @@ impl TryFrom<KnownChains> for SignetConstants {

fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
match chain {
KnownChains::Mainnet => Ok(Self::mainnet()),
KnownChains::Pecorino => Ok(Self::pecorino()),
KnownChains::Test => Ok(Self::test()),
}
Expand Down
6 changes: 6 additions & 0 deletions crates/constants/src/types/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ impl RollupConstants {
Self { chain_id, orders, passage, base_fee_recipient, tokens }
}

/// Get the hard-coded Mainnet rollup constants.
pub const fn mainnet() -> Self {
crate::chains::mainnet::ROLLUP
}

/// Get the hard-coded Pecorino rollup constants.
pub const fn pecorino() -> Self {
crate::chains::pecorino::ROLLUP
Expand Down Expand Up @@ -111,6 +116,7 @@ impl TryFrom<KnownChains> for RollupConstants {

fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
match chain {
KnownChains::Mainnet => Ok(Self::mainnet()),
KnownChains::Pecorino => Ok(Self::pecorino()),
KnownChains::Test => Ok(Self::test()),
}
Expand Down
5 changes: 5 additions & 0 deletions crates/test-utils/src/specs/host_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ impl HostBlockSpec {
}
}

pub const fn mainnet() -> Self {
Self::new(SignetSystemConstants::mainnet())
}

/// Make a new block spec with Pecorino constants.
pub const fn pecorino() -> Self {
Self::new(SignetSystemConstants::pecorino())
Expand Down Expand Up @@ -416,6 +420,7 @@ impl TryFrom<KnownChains> for HostBlockSpec {

fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
match chain {
KnownChains::Mainnet => Ok(Self::mainnet()),
KnownChains::Pecorino => Ok(Self::pecorino()),
KnownChains::Test => Ok(Self::test()),
}
Expand Down
6 changes: 6 additions & 0 deletions crates/test-utils/src/specs/ru_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ impl RuBlockSpec {
Self { constants, tx: vec![], gas_limit: None, reward_address: None }
}

/// Create a new empty RU block spec with the Mainnet constants.
pub const fn mainnet() -> Self {
Self::new(SignetSystemConstants::mainnet())
}

/// Create a new empty RU block spec with the Pecorino constants.
pub const fn pecorino() -> Self {
Self::new(SignetSystemConstants::pecorino())
Expand Down Expand Up @@ -148,6 +153,7 @@ impl TryFrom<KnownChains> for RuBlockSpec {

fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
match chain {
KnownChains::Mainnet => Ok(Self::mainnet()),
KnownChains::Pecorino => Ok(Self::pecorino()),
KnownChains::Test => Ok(Self::test()),
}
Expand Down
Loading