-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(book): Load Rollup Config Example (#224)
### Description Loading a rollup config example.
- Loading branch information
Showing
4 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Loading a Rollup Config from a Chain ID | ||
|
||
In this section, the code examples demonstrate loading the | ||
rollup config for the given L2 Chain ID. | ||
|
||
Let's load the Rollup Config for OP Mainnet which hash chain id 10. | ||
|
||
```rust | ||
use op_alloy_genesis::{OP_MAINNET_CONFIG, rollup_config_from_chain_id}; | ||
|
||
// The chain id for OP Mainnet | ||
let op_mainnet_id = 10; | ||
|
||
// Load a rollup config from the chain id. | ||
let op_mainnet_config = rollup_config_from_chain_id(op_mainnet_id).expect("infallible"); | ||
|
||
// The chain id should match the hardcoded chain id. | ||
assert_eq!(OP_MAINNET_CONFIG, op_mainnet_config); | ||
``` | ||
|
||
> ⚠️ Available Configs | ||
> | ||
> The `rollup_config_from_chain_id` method in `op-alloy-genesis` uses hardcoded | ||
> rollup configs. But, there are only a few of these hardcoded rollup configs in | ||
> `op-alloy-genesis`. This method and these configs are provided for `no_std` | ||
> environments where dynamic filesystem loading at runtime is not supported | ||
> in `no_std` environments. | ||
> | ||
> In a `std` environment, the [superchain][superchain] crate may be used which | ||
> dynamically provides all rollup configs from the [superchain-registry][registry] | ||
> for their respective chain ids. | ||
[superchain]: https://crates.io/crates/superchain | ||
[registry]: https://github.com/ethereum-optimism/superchain-registry |