Skip to content

Commit

Permalink
feat(book): Genesis - System Config (#211)
Browse files Browse the repository at this point in the history
### Description

Adds docs for the `SystemConfig` and structures the book out a bit.
  • Loading branch information
refcell authored Nov 1, 2024
1 parent 1f5686d commit b16e785
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 3 deletions.
9 changes: 8 additions & 1 deletion book/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Summary

- [Introduction](./intro.md)
- [Glossary](./glossary.md)
- [Getting Started](./starting/installation.md)
- [Building](./building/README.md)
- [Genesis](./building/genesis/README.md)
- [Rollup Config](./building/genesis/rollup-config.md)
- [System Config](./building/genesis/system-config.md)
- [Examples](./examples/README.md)
- [Contributing](./CONTRIBUTING.md)
- [Licensing](./LICENSE.md)
- [Glossary](./glossary.md)
3 changes: 3 additions & 0 deletions book/src/building/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Building

This section offers in-depth documentation into the various `op-alloy` crates.
38 changes: 38 additions & 0 deletions book/src/building/genesis/rollup-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Rollup Configs

Rollup configurations are a consensus construct used to configure an Optimism Consensus client.
When an OP Stack chain is deployed into production or consensus nodes are configured to sync the chain,
certain consensus parameters can be configured. These parameters are defined in the [OP Stack specs][config].

Consensus parameters are consumed by OP Stack software through the `RollupConfig` type defined in the
[`op-alloy-genesis`][genesis] crate.

## `RollupConfig` Type

The [`RollupConfig`][rc] type is defined in [`op-alloy-genesis`][genesis].

A predefined rollup config can be loaded from a given L2 chain id using
the [`rollup_config_from_chain_id`][rcid] method. An example is shown below.

```rust
use op_alloy_genesis::{OP_MAINNET_CONFIG, rollup_config_from_chain_id};

let op_mainnet_config = rollup_config_from_chain_id(10).expect("infallible");
assert_eq!(OP_MAINNET_CONFIG, op_mainnet_config);
```

The `OP_MAINNET_CONFIG` is one of the predefined rollup configs exported by
the [`op-alloy-genesis`][genesis] crate. Other predefined configs include
the following.

- `OP_MAINNET_CONFIG`
- `OP_SEPOLIA_CONFIG`
- `BASE_MAINNET_CONFIG`
- `BASE_SEPOLIA_CONFIG`

<!-- Links -->

[rcid]: https://docs.rs/op-alloy-genesis/latest/op_alloy_genesis/rollup/fn.rollup_config_from_chain_id.html
[rc]: https://docs.rs/op-alloy-genesis/latest/op_alloy_genesis/rollup/struct.RollupConfig.html
[genesis]: https://crates.io/crates/op-alloy-genesis
[config]: https://specs.optimism.io/protocol/configurability.html
32 changes: 32 additions & 0 deletions book/src/building/genesis/system-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# System Config

The system configuration is a set of configurable chain parameters
defined in a contract on L1. These parameters can be changed through
the system config contract, emitting events that are picked up by
the [rollup node derivation process][derivation]. To dive deeper
into the System Config, visit the [OP Stack Specifications][specs].

## `SystemConfig` Type

The [`SystemConfig`][sc] type is defined in [`op-alloy-genesis`][genesis].

Parameters defined in the [`SystemConfig`][sc] are expected to be updated
through L1 receipts, using the [`update_with_receipts`][update] method.

## Holocene Updates

The [Holocene Hardfork][holocene] introduced an update to the [`SystemConfig`][sc]
type, adding EIP-1559 parameters to the config.

The [`SystemConfig`][sc] type in [`op-alloy-genesis`][genesis] provides a method
called [`eip_1559_params`][eip] that returns the EIP-1559 parameters encoded as
a [`B64`][b64].

[holocene]: https://specs.optimism.io/protocol/holocene/overview.html
[b64]: https://docs.rs/alloy-primitives/latest/alloy_primitives/aliases/type.B64.html
[eip]: https://docs.rs/op-alloy-genesis/latest/op_alloy_genesis/system/struct.SystemConfig.html#method.eip_1559_params
[update]: https://docs.rs/op-alloy-genesis/latest/op_alloy_genesis/system/struct.SystemConfig.html#method.update_with_receipts
[sc]: https://docs.rs/op-alloy-genesis/latest/op_alloy_genesis/system/struct.SystemConfig.html
[specs]: https://specs.optimism.io/protocol/system-config.html#system-config
[derivation]: https://specs.optimism.io/protocol/derivation.html
[genesis]: https://crates.io/crates/op-alloy-genesis
5 changes: 5 additions & 0 deletions book/src/examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Examples

Examples for working with `op-alloy-*` crates.

TODO: document `op-alloy` crate use and using it with re-exports.
4 changes: 2 additions & 2 deletions book/src/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ performance types, traits, and middleware from [alloy][alloy].

To get started with op-alloy, add op-alloy crates as a dependency and take your first steps.

### [Building with op-alloy](./building/rollup-configs.md)
### [Building with op-alloy](./building/README.md)

A walkthrough of building with op-alloy.

### [Examples](./examples/genesis/loading-a-rollup-config.md)
### [Examples](./examples/README.md)

This section will give you practical examples of how Alloy can be used in your codebase.

Expand Down

0 comments on commit b16e785

Please sign in to comment.