Skip to content

refcell/montana

Repository files navigation

logo

An experimental, performant suite of Base stack components. Built in Rust.

Crates.io MSRV CI License Chain: Base

What's Montana?UsageDemoPerformanceFootprintContributingProvenanceLicense

Caution

Montana is under active development and is not ready for production use.

Important

Based on our contrived benchmarks, Montana achieves up to 9x faster decompression and 7.7x faster Brotli compression compared to the OP Stack. See Performance for details.

What's Montana?

Montana is an experimental, high-performance implementation of a minimal L2 stack written entirely in Rust. It provides a complete L2 stack comprising both sequencer and validator node implementations, each with distinct execution and consensus layers. The execution layer processes blocks using op-revm, providing state transitions for Base stack chains through block fetching, transaction execution, and state management via an in-memory database with RPC fallback. The consensus layer manages the data availability layer through a trait-abstracted compression pipeline supporting Brotli, Zstd, and Zlib compression algorithms.

Montana includes a local simulation harness that orchestrates anvil instances for both L1 and L2 chains, enabling full end-to-end testing of the batch submission and derivation pipeline without external infrastructure. The sequencer batches L2 blocks and submits them to L1 via EIP-4844 blobs or legacy calldata, while the validator derives batches from L1, decompresses them, and re-executes blocks to reconstruct the canonical chain state. The architecture is fully modular with trait-abstracted sources and sinks, allowing batch data to flow through local files, anvil chains, or production L1 endpoints.

For detailed documentation on the consensus pipeline architecture, see the pipeline crate README.

Usage

Simulate the entire L2 stack locally using anvil instances for both L1 and L2 chains. See a demo video of this command running below.

just harness-fast

Tip

See the Justfile for other useful commands, including just ci to run all CI checks locally.

Demo

montana.mov

Note

The demo runs just harness-fast which is aliased to run the montana binary.

This demo shows an L2 anvil chain that a sequencer takes transactions from and batch submits them to an anvil L1 chain. A validator then derives these batches and then re-executes them, resulting in the canonical finalized L2 chain.

Performance

Batch Submission → Derivation Round Trip

Full pipeline benchmarks measured across 1,000 batches on local anvil infrastructure:

Operation p50 p95 p99
Batch Submission (L2 → L1) 12ms 18ms 24ms
Derivation (L1 → L2) 8ms 14ms 19ms
Full Round Trip 21ms 34ms 45ms

Block Execution

Measured using op-revm across 10,000 Base mainnet blocks:

Operation p50 p95 p99
Block Execution 1.2ms 3.8ms 7.1ms
State Commitment 0.4ms 0.9ms 1.6ms

Compression

Benchmarked with 31 Base mainnet blocks (5,766 transactions, 1.67 MB raw):

Algorithm Compressed Size
Brotli 16.7%
Zstd 17.9%
Zlib 25.7%

Brotli achieves the best compression at 83.3% reduction, making it the default for batch submission.

OP Stack Comparison

Montana benchmarked against equivalent OP Stack (Go) operations:

Operation Montana OP Stack Speedup
Brotli Compress 10KB 6.7µs 51.4µs 7.7x
Brotli Decompress 10KB 5.9µs 26.0µs 4.4x
Zstd Decompress 10KB 544ns 5.1µs 9.3x
Full Pipeline 100 blocks 138µs 654µs 4.7x

Tip

Run the benchmarks yourself with just bench-compare. See the benchmarks documentation for methodology and complete results.

Footprint

Lines of code comparison with the OP Stack (op-reth, op-batcher, op-node):

Service Montana OP Stack Reduction
Execution Node 3,263 17,619 81.5%
Batch Submitter 7,063 9,163 22.9%
Derivation Pipeline 1,675 38,575 95.7%
Total 12,001 65,357 81.6%

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Provenance

@danyalprout and @refcell built this in a week during a Base Hackathon.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

An experimental, performant suite of Base stack components. Built in Rust.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages