{"id":46486281,"url":"https://github.com/flashbots/rblib","last_synced_at":"2026-03-06T09:31:01.997Z","repository":{"id":318709894,"uuid":"1002798980","full_name":"flashbots/rblib","owner":"flashbots","description":"Modular SDK for building payload builders.","archived":false,"fork":false,"pushed_at":"2026-02-20T06:37:42.000Z","size":1512,"stargazers_count":75,"open_issues_count":11,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-02-20T11:07:35.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flashbots.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-16T06:55:53.000Z","updated_at":"2026-02-20T06:37:42.000Z","dependencies_parsed_at":"2025-10-10T09:08:10.232Z","dependency_job_id":"5420cccb-460e-42af-bef1-a2fd421a81f8","html_url":"https://github.com/flashbots/rblib","commit_stats":null,"previous_names":["flashbots/rblib"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/flashbots/rblib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Frblib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Frblib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Frblib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Frblib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flashbots","download_url":"https://codeload.github.com/flashbots/rblib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flashbots%2Frblib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30168966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-06T09:30:57.036Z","updated_at":"2026-03-06T09:31:01.979Z","avatar_url":"https://github.com/flashbots.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rblib — A Modular Rust SDK for Ethereum Block Building\n\n[![Sanity Check](https://github.com/flashbots/rblib/actions/workflows/sanity.yaml/badge.svg)](https://github.com/flashbots/rblib/actions/workflows/sanity.yaml)\n\n\n\u003e [\\!WARNING]\n\u003e This library is **alpha software** under active development. Breaking changes are expected, APIs are not yet stable, and no official support is provided. Early adopters are encouraged to open issues for bugs and feedback to help shape the project's direction.\n\n![](./assets/rblib_chip.png)\n\n\n**rblib** is a high-performance, modular Rust SDK for constructing Ethereum-compatible block builders. Built on top of the [Reth](https://github.com/paradigmxyz/reth) execution engine, it provides robust, platform-agnostic primitives and declarative workflows designed for both L1 and L2 applications.\n\n-----\n\n## Core Philosophy\n\n`rblib` is designed for sophisticated engineering teams who require granular control and composability in their block-building logic. Our philosophy centers on three key principles:\n\n  * **Modularity:** Core components are decoupled. Use the low-level Payload API for fine-grained control, or compose high-level Pipelines for declarative workflows.\n  * **Performance:** By leveraging Reth and a zero-copy design for payload state, `rblib` is built for high-throughput, latency-sensitive environments.\n  * **Extensibility:** A clean `Platform` trait abstraction allows for seamless extension to support custom EVM-based chains (L2s, app-chains) without forking the core logic.\n\n-----\n\n## Key Features\n\n  * **Composable Payload API:** A flexible, low-level API for constructing and inspecting block payloads via immutable `Checkpoint` transformations.\n  * **Declarative Pipelines API:** A high-level, composable system for defining block-building workflows (e.g., ordering, revert protection) as reusable `Step`s.\n  * **Platform-Agnostic Design:** Out-of-the-box support for `Ethereum` and `Optimism`, with a clear interface for adding new platforms.\n  * **Integrated Testing Framework:** A rich test suite with utilities for multi-platform testing, local Reth nodes, and isolated component tests.\n\n-----\n\n## Getting Started\n\nAdd `rblib` to your project's dependencies:\n\n```bash\ncargo add rblib\n```\n\n-----\n\n## Core Concepts\n\n`rblib` is split into two primary APIs that can be used independently or together.\n\n### 1\\. The Payload API\n\nLocated in `rblib::payload` (see `src/payload`), this API provides the foundational primitives for block construction. It enables exploring many different payload variations efficiently.\n\n#### Checkpoints\n\nA `Checkpoint\u003cP\u003e` is an immutable snapshot of a payload's state after a mutation (e.g., applying a transaction or bundle). Checkpoints are cheap to clone and fork, making it trivial to explore alternative block constructions from a common state. Each checkpoint retains the history of its parent, allowing it to act as a `DatabaseRef` for the chain state at that specific point. Common algorithms for inspecting checkpoints are available in `src/payload/ext/checkpoint.rs`.\n\n**Example: Building and Forking a Payload**\n\n```rust\nuse rblib::{*, test_utils::*};\n\nlet ctx = BlockContext::\u003cEthereum\u003e::mocked();\n\n// Create a linear history\nlet checkpoint1 = ctx.apply(tx1)?;\nlet checkpoint2 = checkpoint1.apply(tx2)?;\n\n// Fork from an earlier state to explore an alternative\nlet checkpoint3_alt = checkpoint1.apply(tx3)?;\n\n// Compare the outcomes of the two different forks\nlet gas_main = checkpoint2.cumulative_gas_used();\nlet gas_alt = checkpoint3_alt.cumulative_gas_used();\nlet balance_main = checkpoint2.balance_of(coinbase_addr);\nlet balance_alt = checkpoint3_alt.balance_of(coinbase_addr);\n```\n\n#### Spans\n\nA `Span\u003cP\u003e` is a view over a linear sequence of checkpoints, useful for analyzing or manipulating a specific portion of a payload's history.\n\n```rust\nuse rblib::payload::*;\n\nlet full_history = checkpoint.history();\nlet total_gas = full_history.gas_used();\n\n// Analyze a sub-section of the payload\nlet sub_span = full_history.skip(2).take(4);\nlet sub_gas = sub_span.gas_used();\n```\n\n### 2\\. The Pipelines API\n\nLocated in `rblib::pipelines` (see `src/pipelines/`), this API uses the Payload API to create declarative, reusable block-building workflows. It is particularly powerful for L2s, where standardized logic can be composed and customized.\n\nPipelines are built from **Steps** (`src/pipelines/step.rs`) and control-flow components (`src/pipelines/mod.rs`). A rich library of common, reusable steps is provided in `src/pipelines/steps/`.\n\n**Example: A Minimal Builder Pipeline**\n\nThis example defines a pipeline that loops over a set of ordering and protection steps before finalizing the block.\n\n```rust\nuse rblib::*;\n\nfn main() {\n    // Define a reusable pipeline workflow\n    let pipeline = Pipeline::\u003cEthereum\u003e::default()\n        .with_epilogue(BuilderEpilogue)\n        .with_pipeline(\n            Loop,\n            (\n                AppendOneOrder::default(),\n                PriorityFeeOrdering,\n                TotalProfitOrdering,\n                RevertProtection,\n            ),\n        );\n\n    // Integrate with a Reth node\n    Cli::parse_args()\n        .run(|builder, _| async move {\n            let handle = builder\n                .with_types::\u003cEthereumNode\u003e()\n                .with_components(\n                    EthereumNode::components()\n                        .payload(pipeline.into_service()))\n                .with_add_ons(EthereumAddOns::default())\n                .launch()\n                .await?;\n\n            handle.wait_for_node_exit().await\n        })\n        .unwrap();\n}\n```\n\n-----\n\n## Platform Abstraction\n\nChain-specific logic (e.g., transaction types, block validation rules) is abstracted via the `Platform` trait (`src/platform/mod.rs`). This allows the core building logic to remain generic while providing concrete implementations for `Ethereum` and `Optimism`.\n\nTo support a custom chain, implement the `Platform` trait. See `examples/custom-platform.rs` for a practical example.\n\n-----\n\n## Examples and Integration\n\n`Pipeline::into_service()` is the primary entry point for converting a pipeline into a Reth-compatible `PayloadServiceBuilder`. For complete integration examples, see the `examples/` directory and the reference builder implementation in `bin/flashblocks/src/main.rs`.\n\n-----\n\n## Development \u0026 Testing\n\nThe project includes a comprehensive testing infrastructure to ensure reliability.\n\n  * **Run all tests:**\n    ```bash\n    cargo test\n    ```\n  * **Run a specific test with verbose logging:**\n    ```bash\n    TEST_TRACE=on cargo test smoke::all_transactions_included_ethereum\n    ```\n- **Multi-Platform Testing**: Use `#[rblib_test(Ethereum, Optimism, YourCustomPlatform)]` to run tests across platforms.\n- **Local Test Nodes**: `LocalNode\u003cP, C\u003e` (`src/test_utils/node.rs`) provides full Reth nodes for integration testing.\n- **Step Testing**: `OneStep\u003cP\u003e` (`src/test_utils/step.rs`) enables isolated step testing.\n- **Funded Accounts**: Use `FundedAccounts::by_address()` or `.with_random_funded_signer()` for test transactions.\n- **Mocks**: Mocking utilities are available for types like `BlockContext` and `PayloadAttributes`.\n\n\n-----\n\n## Contributing\n\nContributions are welcome. Please feel free to open an issue to discuss a bug, feature request, or design question. Pull requests should be focused and include relevant tests.\n\n## License\n\nThis project is licensed under the [MIT License](/LICENSE).\n\n-----\n\nMade with ☀️ by the ⚡🤖 collective.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashbots%2Frblib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflashbots%2Frblib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflashbots%2Frblib/lists"}