#chain #registry #superchain #config #read #definition #id

no-std maili-registry

A registry of superchain configs

3 releases

new 0.1.2 Jan 9, 2025
0.1.1 Jan 9, 2025
0.1.0 Jan 8, 2025

#23 in Magic Beans

Download history 181/week @ 2025-01-03

181 downloads per month
Used in maili

MIT/Apache

2MB
9K SLoC

Go 8K SLoC // 0.2% comments Rust 444 SLoC Shell 84 SLoC // 0.2% comments Just 57 SLoC // 0.3% comments

maili-registry

CI maili-registry MIT License Apache License Book

maili-registry is a no_std crate that exports rust type definitions for chains in the superchain-registry. Since it reads static files to read configurations for various chains into instantiated objects, the maili-registry crate requires serde as a dependency. To use the maili-registry crate, add the crate as a dependency to a Cargo.toml.

maili-registry = "0.1.0"

maili-registry declares lazy evaluated statics that expose ChainConfigs, RollupConfigs, and Chain objects for all chains with static definitions in the superchain registry. The way this works is the golang side of the superchain registry contains an "internal code generation" script that has been modified to output configuration files to the crates/registry directory in the etc folder that are read by the maili-registry rust crate. These static config files contain an up-to-date list of all superchain configurations with their chain configs. It is expected that if the commit hash of the superchain-registry pulled in as a git submodule has breaking changes, the tests in this crate (maili-registry) will break and updates will need to be made.

There are three core statics exposed by the maili-registry.

  • CHAINS: A list of chain objects containing the superchain metadata for this chain.
  • OPCHAINS: A map from chain id to ChainConfig.
  • ROLLUP_CONFIGS: A map from chain id to RollupConfig.

maili-registry exports the complete list of chains within the superchain, as well as each chain's RollupConfigs and ChainConfigs.

Usage

Add the following to your Cargo.toml.

[dependencies]
maili-registry = "0.1.0"

To make maili-registry no_std, toggle default-features off like so.

[dependencies]
maili-registry = { version = "0.1.0", default-features = false }

Below demonstrates getting the RollupConfig for OP Mainnet (Chain ID 10).

use maili_registry::ROLLUP_CONFIGS;

let op_chain_id = 10;
let op_rollup_config = ROLLUP_CONFIGS.get(&op_chain_id);
println!("OP Mainnet Rollup Config: {:?}", op_rollup_config);

A mapping from chain id to ChainConfig is also available.

use maili_registry::OPCHAINS;

let op_chain_id = 10;
let op_chain_config = OPCHAINS.get(&op_chain_id);
println!("OP Mainnet Chain Config: {:?}", op_chain_config);

Feature Flags

  • std: Uses the standard library to pull in environment variables.

Credits

superchain-registry contributors for building and maintaining superchain types.

alloy and op-alloy for creating and maintaining high quality Ethereum and Optimism types in rust.

Dependencies

~15MB
~337K SLoC