Skip to content

Commit b6e4f95

Browse files
authored
Merge pull request #19 from dmarzzz/update-readme
add banner asset, update readme, add code of conduct
2 parents 9e9b93a + 690f9e7 commit b6e4f95

File tree

3 files changed

+220
-77
lines changed

3 files changed

+220
-77
lines changed

CODE_OF_CONDUCT.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
10+
identity and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the overall
26+
community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or advances of
31+
any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email address,
35+
without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement writing an
63+
email to leo@flashbots.net or contacting elopio#8526 in
64+
[Discord](https://discord.com/invite/7hvTycdNcK).
65+
All complaints will be reviewed and investigated promptly and fairly.
66+
67+
All community leaders are obligated to respect the privacy and security of the
68+
reporter of any incident.
69+
70+
## Enforcement Guidelines
71+
72+
Community leaders will follow these Community Impact Guidelines in determining
73+
the consequences for any action they deem in violation of this Code of Conduct:
74+
75+
### 1. Correction
76+
77+
**Community Impact**: Use of inappropriate language or other behavior deemed
78+
unprofessional or unwelcome in the community.
79+
80+
**Consequence**: A private, written warning from community leaders, providing
81+
clarity around the nature of the violation and an explanation of why the
82+
behavior was inappropriate. A public apology may be requested.
83+
84+
### 2. Warning
85+
86+
**Community Impact**: A violation through a single incident or series of
87+
actions.
88+
89+
**Consequence**: A warning with consequences for continued behavior. No
90+
interaction with the people involved, including unsolicited interaction with
91+
those enforcing the Code of Conduct, for a specified period of time. This
92+
includes avoiding interactions in community spaces as well as external channels
93+
like social media. Violating these terms may lead to a temporary or permanent
94+
ban.
95+
96+
### 3. Temporary Ban
97+
98+
**Community Impact**: A serious violation of community standards, including
99+
sustained inappropriate behavior.
100+
101+
**Consequence**: A temporary ban from any sort of interaction or public
102+
communication with the community for a specified period of time. No public or
103+
private interaction with the people involved, including unsolicited interaction
104+
with those enforcing the Code of Conduct, is allowed during this period.
105+
Violating these terms may lead to a permanent ban.
106+
107+
### 4. Permanent Ban
108+
109+
**Community Impact**: Demonstrating a pattern of violation of community
110+
standards, including sustained inappropriate behavior, harassment of an
111+
individual, or aggression toward or disparagement of classes of individuals.
112+
113+
**Consequence**: A permanent ban from any sort of public interaction within the
114+
community.
115+
116+
## Attribution
117+
118+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119+
version 2.1, available at
120+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
121+
122+
Community Impact Guidelines were inspired by
123+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124+
125+
For answers to common questions about this code of conduct, see the FAQ at
126+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
127+
[https://www.contributor-covenant.org/translations][translations].
128+
129+
[homepage]: https://www.contributor-covenant.org
130+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
131+
[Mozilla CoC]: https://github.com/mozilla/diversity
132+
[FAQ]: https://www.contributor-covenant.org/faq
133+
[translations]: https://www.contributor-covenant.org/translations

README.md

Lines changed: 87 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,110 @@
1-
# rblib — Rust SDK for Ethereum Block Builders
2-
3-
> [!WARNING]
4-
> This library is early alpha software under active and rapid development. Breaking changes are expected, APIs may shift, and stability is not guaranteed. No official support is provided at this stage; however, early adopters are encouraged to open issues for bugs, feedback, or feature requests. Your input will help shape the roadmap.
1+
# rblib — A Modular Rust SDK for Ethereum Block Building
52

63
[![Sanity Check](https://github.com/flashbots/rblib/actions/workflows/sanity.yaml/badge.svg)](https://github.com/flashbots/rblib/actions/workflows/sanity.yaml)
74

85

6+
> [\!WARNING]
7+
> 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.
8+
9+
![](./assets/rblib_chip.png)
10+
11+
12+
**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.
913

10-
**rblib** is a Rust SDK for building Ethereum-compatible block builders using the [Reth](https://github.com/paradigmxyz/reth) execution engine. It provides two independent, platform-agnostic APIs:
14+
-----
1115

12-
- **Payload API** — Flexible primitives for constructing and inspecting block payloads.
13-
- **Pipelines API** — Declarative workflows for block building, suitable for both L1 and L2 scenarios.
16+
## Core Philosophy
1417

15-
Out-of-the-box support is provided for both `Ethereum` and `Optimism` platforms via the `Platform` trait.
18+
`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:
1619

17-
---
20+
* **Modularity:** Core components are decoupled. Use the low-level Payload API for fine-grained control, or compose high-level Pipelines for declarative workflows.
21+
* **Performance:** By leveraging Reth and a zero-copy design for payload state, `rblib` is built for high-throughput, latency-sensitive environments.
22+
* **Extensibility:** A clean `Platform` trait abstraction allows for seamless extension to support custom EVM-based chains (L2s, app-chains) without forking the core logic.
1823

19-
## Payload Building API
24+
-----
2025

21-
Located in `src/payload`, this API offers a composable interface for building block payloads through a series of checkpoints. It can be used standalone, without the pipeline system.
26+
## Key Features
2227

23-
### Checkpoints
28+
* **Composable Payload API:** A flexible, low-level API for constructing and inspecting block payloads via immutable `Checkpoint` transformations.
29+
* **Declarative Pipelines API:** A high-level, composable system for defining block-building workflows (e.g., ordering, revert protection) as reusable `Step`s.
30+
* **Platform-Agnostic Design:** Out-of-the-box support for `Ethereum` and `Optimism`, with a clear interface for adding new platforms.
31+
* **Integrated Testing Framework:** A rich test suite with utilities for multi-platform testing, local Reth nodes, and isolated component tests.
2432

25-
A `Checkpoint<P>` is an atomic unit of payload mutation—think of it as a state transformation (e.g., applying a transaction or bundle). Checkpoints are cheap to copy, discard, and fork, making it easy to explore alternative payload constructions.
33+
-----
2634

27-
Each checkpoint:
35+
## Getting Started
36+
37+
Add `rblib` to your project's dependencies:
38+
39+
```bash
40+
cargo add rblib
41+
```
2842

29-
- Tracks its entire history back to the block’s initial state.
30-
- Implements `DatabaseRef`, acting as a chain state provider rooted at the parent block plus all mutations in its history.
43+
-----
3144

32-
Common algorithms for building and inspecting checkpoints are available in `src/payload/ext/checkpoint.rs`.
45+
## Core Concepts
3346

34-
#### Example: Building and Forking Payloads
47+
`rblib` is split into two primary APIs that can be used independently or together.
48+
49+
### 1\. The Payload API
50+
51+
Located in `rblib::payload` (see `src/payload`), this API provides the foundational primitives for block construction. It enables exploring many different payload variations efficiently.
52+
53+
#### Checkpoints
54+
55+
A `Checkpoint<P>` 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`.
56+
57+
**Example: Building and Forking a Payload**
3558

3659
```rust
3760
use rblib::{*, test_utils::*};
3861

3962
let ctx = BlockContext::<Ethereum>::mocked();
4063

64+
// Create a linear history
4165
let checkpoint1 = ctx.apply(tx1)?;
4266
let checkpoint2 = checkpoint1.apply(tx2)?;
4367

44-
// Fork the state to explore alternatives
68+
// Fork from an earlier state to explore an alternative
4569
let checkpoint3_alt = checkpoint1.apply(tx3)?;
4670

47-
// Compare alternative payloads
48-
let gas1 = checkpoint2.cumulative_gas_used();
49-
let gas2 = checkpoint3_alt.cumulative_gas_used();
50-
51-
let balance1 = checkpoint2.balance_of(coinbase_addr);
52-
let balance2 = checkpoint3_alt.balance_of(coinbase_addr);
71+
// Compare the outcomes of the two different forks
72+
let gas_main = checkpoint2.cumulative_gas_used();
73+
let gas_alt = checkpoint3_alt.cumulative_gas_used();
74+
let balance_main = checkpoint2.balance_of(coinbase_addr);
75+
let balance_alt = checkpoint3_alt.balance_of(coinbase_addr);
5376
```
5477

55-
### Spans
78+
#### Spans
5679

57-
A `Span<P>` represents a linear sequence of checkpointsuseful for analyzing or manipulating parts of a payload.
80+
A `Span<P>` is a view over a linear sequence of checkpoints, useful for analyzing or manipulating a specific portion of a payload's history.
5881

5982
```rust
6083
use rblib::payload::*;
6184

62-
let all_history = checkpoint.history();
63-
let all_gas = all_history.gas_used();
85+
let full_history = checkpoint.history();
86+
let total_gas = full_history.gas_used();
6487

65-
let sub_span = all_history.skip(2).take(4);
88+
// Analyze a sub-section of the payload
89+
let sub_span = full_history.skip(2).take(4);
6690
let sub_gas = sub_span.gas_used();
6791
```
6892

69-
### Platform Agnostic
70-
71-
The Payload API works with any type implementing the `Platform` trait.
93+
### 2\. The Pipelines API
7294

73-
---
95+
Located 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.
7496

75-
## Pipelines API
97+
Pipelines 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/`.
7698

77-
Located in `src/pipelines/`, this API builds on the Payload API to provide a declarative, composable workflow for block building. It’s especially useful for L2 builders, where common logic can be reused and customized.
99+
**Example: A Minimal Builder Pipeline**
78100

79-
### Example: Minimal Builder Pipeline
101+
This example defines a pipeline that loops over a set of ordering and protection steps before finalizing the block.
80102

81103
```rust
82104
use rblib::*;
83105

84106
fn main() {
107+
// Define a reusable pipeline workflow
85108
let pipeline = Pipeline::<Ethereum>::default()
86109
.with_epilogue(BuilderEpilogue)
87110
.with_pipeline(
@@ -94,6 +117,7 @@ fn main() {
94117
),
95118
);
96119

120+
// Integrate with a Reth node
97121
Cli::parse_args()
98122
.run(|builder, _| async move {
99123
let handle = builder
@@ -111,65 +135,51 @@ fn main() {
111135
}
112136
```
113137

114-
### Pipeline Pattern
138+
-----
115139

116-
- **Steps** (`src/pipelines/step.rs`): Each `Step<P>` implements methods like `step()`, `before_job()`, and `after_job()`. Common steps include transaction ordering, revert protection, and more.
117-
- **Pipelines** (`src/pipelines/mod.rs`): Compose steps and control-flow components using a builder pattern (`.with_step()`, `.with_prologue()`, `.with_epilogue()`).
118-
- **Common Steps Library** (`src/pipelines/steps/`): A collection of well-tested reusable payload building steps commonly used in most block builders.
140+
## Platform Abstraction
119141

120-
---
142+
Chain-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`.
121143

122-
## Platform Abstraction Layer
144+
To support a custom chain, implement the `Platform` trait. See `examples/custom-platform.rs` for a practical example.
123145

124-
Chain-specific logic is separated via the `Platform` trait (`src/platform/mod.rs`). You can customize platforms for different EVMs, block structures, or transaction types. See `examples/custom-platform.rs` for extending Optimism with custom bundles.
146+
-----
125147

126-
Default implementations for `Ethereum` and `Optimism` are included.
148+
## Examples and Integration
127149

128-
---
150+
`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`.
129151

130-
## Testing Infrastructure
152+
-----
131153

154+
## Development & Testing
155+
156+
The project includes a comprehensive testing infrastructure to ensure reliability.
157+
158+
* **Run all tests:**
159+
```bash
160+
cargo test
161+
```
162+
* **Run a specific test with verbose logging:**
163+
```bash
164+
TEST_TRACE=on cargo test smoke::all_transactions_included_ethereum
165+
```
132166
- **Multi-Platform Testing**: Use `#[rblib_test(Ethereum, Optimism, YourCustomPlatform)]` to run tests across platforms.
133167
- **Local Test Nodes**: `LocalNode<P, C>` (`src/test_utils/node.rs`) provides full Reth nodes for integration testing.
134168
- **Step Testing**: `OneStep<P>` (`src/test_utils/step.rs`) enables isolated step testing.
135169
- **Funded Accounts**: Use `FundedAccounts::by_address()` or `.with_random_funded_signer()` for test transactions.
136170
- **Mocks**: Mocking utilities are available for types like `BlockContext` and `PayloadAttributes`.
137171
138-
---
139-
140-
## Development Commands
141-
142-
Run all tests:
143-
144-
```bash
145-
cargo test
146-
```
147-
148-
Debug a specific test with logs:
149-
150-
```bash
151-
TEST_TRACE=on cargo test smoke::all_transactions_included_ethereum
152-
```
153-
154-
---
155-
156-
## Integration with Reth
157-
158-
- `Pipeline::into_service()` converts pipelines to `PayloadServiceBuilder`.
159-
- Platform-specific `build_payload()` methods use Reth’s native builders.
160-
161-
See `examples/` and `bin/flashblocks/src/main.rs` for integration examples.
162172
163-
---
173+
-----
164174
165175
## Contributing
166176
167-
Contributions, issues, and feature requests are welcome. Please see the codebase and examples for guidance on extending platforms, steps, or pipelines.
177+
Contributions 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.
168178
169-
## License
179+
## License
170180
171-
The code in this project is free software under the [MIT License](/LICENSE).
181+
This project is licensed under the [MIT License](/LICENSE).
172182
173-
---
183+
-----
174184
175-
Made with ☀️ by the ⚡🤖 collective.
185+
Made with ☀️ by the ⚡🤖 collective.

assets/rblib_chip.png

552 KB
Loading

0 commit comments

Comments
 (0)