Skip to content
Merged
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
40 changes: 20 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["crates/*"]
resolver = "2"

[workspace.package]
version = "0.14.4"
version = "0.16.0-rc.1"
edition = "2024"
rust-version = "1.88"
authors = ["init4"]
Expand Down Expand Up @@ -34,33 +34,33 @@ debug = false
incremental = false

[workspace.dependencies]
signet-blobber = { version = "0.14", path = "crates/blobber" }
signet-block-processor = { version = "0.14", path = "crates/block-processor" }
signet-db = { version = "0.14", path = "crates/db" }
signet-genesis = { version = "0.14", path = "crates/genesis" }
signet-node = { version = "0.14", path = "crates/node" }
signet-node-config = { version = "0.14", path = "crates/node-config" }
signet-node-tests = { version = "0.14", path = "crates/node-tests" }
signet-node-types = { version = "0.14", path = "crates/node-types" }
signet-rpc = { version = "0.14", path = "crates/rpc" }
signet-blobber = { version = "0.16.0-rc.1", path = "crates/blobber" }
signet-block-processor = { version = "0.16.0-rc.1", path = "crates/block-processor" }
signet-db = { version = "0.16.0-rc.1", path = "crates/db" }
signet-genesis = { version = "0.16.0-rc.1", path = "crates/genesis" }
signet-node = { version = "0.16.0-rc.1", path = "crates/node" }
signet-node-config = { version = "0.16.0-rc.1", path = "crates/node-config" }
signet-node-tests = { version = "0.16.0-rc.1", path = "crates/node-tests" }
signet-node-types = { version = "0.16.0-rc.1", path = "crates/node-types" }
signet-rpc = { version = "0.16.0-rc.1", path = "crates/rpc" }

init4-bin-base = { version = "0.17.0", features = ["alloy"] }

signet-bundle = "0.14"
signet-constants = "0.14"
signet-evm = "0.14"
signet-extract = "0.14"
signet-test-utils = "0.14"
signet-tx-cache = "0.14"
signet-types = "0.14"
signet-zenith = "0.14"
signet-journal = "0.14"
signet-bundle = "0.16.0-rc.1"
signet-constants = "0.16.0-rc.1"
signet-evm = "0.16.0-rc.1"
signet-extract = "0.16.0-rc.1"
signet-test-utils = "0.16.0-rc.1"
signet-tx-cache = "0.16.0-rc.1"
signet-types = "0.16.0-rc.1"
signet-zenith = "0.16.0-rc.1"
signet-journal = "0.16.0-rc.1"

# ajj
ajj = { version = "0.3.4" }

# trevm
trevm = { version = "0.31.0", features = ["full_env_cfg"] }
trevm = { version = "0.31.2", features = ["full_env_cfg"] }
revm-inspectors = "0.32.0" # should be 1 more than trevm version, usually

# Alloy periphery crates
Expand Down
16 changes: 11 additions & 5 deletions crates/genesis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ Genesis configuration and utilities for the Signet Node.

This library contains the following:

- `GenesisSpec` - An enum representing different genesis specifications (Mainnet,
Pecorino, Test, or custom file paths), which can be used to load genesis data.
- `NetworkGenesis` - A struct containing both rollup and host genesis configurations.
- `GenesisSpec` - An enum representing different genesis specifications
(Mainnet, Parmigiana, Pecorino, Test, or custom file paths), which can be
used to load genesis data.
- `NetworkGenesis` - A struct containing both rollup and host genesis
configurations.
- `PARMIGIANA_GENESIS` / `PARMIGIANA_HOST_GENESIS` - The Parmigiana genesis
data.
- `PECORINO_GENESIS` / `PECORINO_HOST_GENESIS` - The Pecorino genesis data.
- `TEST_GENESIS` / `TEST_HOST_GENESIS` - Local test genesis for testing purposes.
- `TEST_GENESIS` / `TEST_HOST_GENESIS` - Local test genesis for testing
purposes.
- `GenesisError` - Errors that can occur when loading or parsing genesis data.

## Example

```
# use signet_genesis::GenesisSpec;
# use signet_constants::KnownChains;
# fn _main() -> Result<(), Box<dyn std::error::Error>> {
let genesis = GenesisSpec::Pecorino.load_genesis()?;
let genesis = GenesisSpec::Known(KnownChains::Parmigiana).load_genesis()?;
// Access rollup (L2/Signet) genesis
let rollup = &genesis.rollup;
// Access host (L1/Ethereum) genesis
Expand Down
76 changes: 50 additions & 26 deletions crates/genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ pub static MAINNET_HOST_GENESIS: LazyLock<Genesis> = LazyLock::new(|| {
serde_json::from_str(MAINNET_HOST_GENESIS_JSON).expect("Failed to parse mainnet host genesis")
});

/// Genesis for the Parmigiana testnet.
pub static PARMIGIANA_GENESIS: LazyLock<Genesis> = LazyLock::new(|| {
serde_json::from_str(include_str!("./parmigiana.genesis.json"))
.expect("Failed to parse parmigiana genesis")
});

/// Genesis for the Parmigiana host testnet.
pub static PARMIGIANA_HOST_GENESIS: LazyLock<Genesis> = LazyLock::new(|| {
serde_json::from_str(include_str!("./parmigiana.host.genesis.json"))
.expect("Failed to parse parmigiana host genesis")
});

/// Genesis for the Pecorino testnet.
pub static PECORINO_GENESIS: LazyLock<Genesis> = LazyLock::new(|| {
serde_json::from_str(PECORINO_GENESIS_JSON).expect("Failed to parse pecorino genesis")
Expand Down Expand Up @@ -90,9 +102,9 @@ pub enum GenesisError {
#[derive(Debug, Clone)]
pub struct NetworkGenesis {
/// The rollup genesis configuration.
pub rollup: Genesis,
pub rollup: Cow<'static, Genesis>,
/// The host genesis configuration.
pub host: Genesis,
pub host: Cow<'static, Genesis>,
}

/// Raw genesis JSON strings for a network.
Expand All @@ -108,12 +120,8 @@ pub struct RawNetworkGenesis {
#[derive(Debug, Clone, serde::Deserialize)]
#[serde(untagged)]
pub enum GenesisSpec {
/// Signet mainnet.
Mainnet,
/// Pecorino testnet.
Pecorino,
/// Local testnet.
Test,
/// Known chain genesis configurations.
Known(#[serde(deserialize_with = "known_from_str")] KnownChains),
/// Custom paths to genesis files.
Custom {
/// Path to the rollup genesis file.
Expand All @@ -123,21 +131,34 @@ pub enum GenesisSpec {
},
}

fn known_from_str<'de, D>(deserializer: D) -> std::result::Result<KnownChains, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <String as serde::Deserialize>::deserialize(deserializer)?;
KnownChains::from_str(&s).map_err(serde::de::Error::custom)
}

impl GenesisSpec {
/// Load the raw genesis JSON strings from the specified source.
///
/// Returns both rollup and host genesis JSON strings.
pub fn load_raw_genesis(&self) -> Result<RawNetworkGenesis> {
match self {
GenesisSpec::Mainnet => Ok(RawNetworkGenesis {
GenesisSpec::Known(KnownChains::Mainnet) => Ok(RawNetworkGenesis {
rollup: Cow::Borrowed(MAINNET_GENESIS_JSON),
host: Cow::Borrowed(MAINNET_HOST_GENESIS_JSON),
}),
GenesisSpec::Pecorino => Ok(RawNetworkGenesis {
GenesisSpec::Known(KnownChains::Parmigiana) => Ok(RawNetworkGenesis {
rollup: Cow::Borrowed(include_str!("./parmigiana.genesis.json")),
host: Cow::Borrowed(include_str!("./parmigiana.host.genesis.json")),
}),
#[allow(deprecated)]
GenesisSpec::Known(KnownChains::Pecorino) => Ok(RawNetworkGenesis {
rollup: Cow::Borrowed(PECORINO_GENESIS_JSON),
host: Cow::Borrowed(PECORINO_HOST_GENESIS_JSON),
}),
GenesisSpec::Test => Ok(RawNetworkGenesis {
GenesisSpec::Known(KnownChains::Test) => Ok(RawNetworkGenesis {
rollup: Cow::Borrowed(TEST_GENESIS_JSON),
host: Cow::Borrowed(TEST_HOST_GENESIS_JSON),
}),
Expand All @@ -153,21 +174,27 @@ impl GenesisSpec {
/// Returns both rollup and host genesis configurations.
pub fn load_genesis(&self) -> Result<NetworkGenesis> {
match self {
GenesisSpec::Mainnet => Ok(NetworkGenesis {
rollup: MAINNET_GENESIS.clone(),
host: MAINNET_HOST_GENESIS.clone(),
GenesisSpec::Known(KnownChains::Mainnet) => Ok(NetworkGenesis {
rollup: Cow::Borrowed(&*MAINNET_GENESIS),
host: Cow::Borrowed(&*MAINNET_HOST_GENESIS),
}),
GenesisSpec::Known(KnownChains::Parmigiana) => Ok(NetworkGenesis {
rollup: Cow::Borrowed(&*PARMIGIANA_GENESIS),
host: Cow::Borrowed(&*PARMIGIANA_HOST_GENESIS),
}),
GenesisSpec::Pecorino => Ok(NetworkGenesis {
rollup: PECORINO_GENESIS.clone(),
host: PECORINO_HOST_GENESIS.clone(),
#[allow(deprecated)]
GenesisSpec::Known(KnownChains::Pecorino) => Ok(NetworkGenesis {
rollup: Cow::Borrowed(&*PECORINO_GENESIS),
host: Cow::Borrowed(&*PECORINO_HOST_GENESIS),
}),
GenesisSpec::Known(KnownChains::Test) => Ok(NetworkGenesis {
rollup: Cow::Borrowed(&*TEST_GENESIS),
host: Cow::Borrowed(&*TEST_HOST_GENESIS),
}),
GenesisSpec::Test => {
Ok(NetworkGenesis { rollup: TEST_GENESIS.clone(), host: TEST_HOST_GENESIS.clone() })
}
GenesisSpec::Custom { .. } => self.load_raw_genesis().and_then(|genesis| {
Ok(NetworkGenesis {
rollup: serde_json::from_str(&genesis.rollup)?,
host: serde_json::from_str(&genesis.host)?,
rollup: Cow::Owned(serde_json::from_str(&genesis.rollup)?),
host: Cow::Owned(serde_json::from_str(&genesis.host)?),
})
}),
}
Expand Down Expand Up @@ -240,9 +267,6 @@ impl FromEnv for GenesisSpec {

impl From<KnownChains> for GenesisSpec {
fn from(known: KnownChains) -> Self {
match known {
KnownChains::Pecorino => GenesisSpec::Pecorino,
KnownChains::Test => GenesisSpec::Test,
}
Self::Known(known)
}
}
145 changes: 145 additions & 0 deletions crates/genesis/src/parmigiana.genesis.json

Large diffs are not rendered by default.

Loading