Skip to content

Commit 870e880

Browse files
authored
Add flashblocks (#170)
* Add flashblocks * Finish * Update docs * Fix
1 parent 7a02ffb commit 870e880

File tree

5 files changed

+110
-3
lines changed

5 files changed

+110
-3
lines changed

examples/op-stack-flashblocks.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Op Stack Rollup Boost with Flashblocks
2+
3+
This example shows how to deploy an Op Stack with rollup-boost using Flashblocks for pre-confirmations.
4+
5+
## What is Flashblocks?
6+
7+
Flashblocks is a feature in rollup-boost that enables pre-confirmations by proposing incremental sections of blocks. This allows for faster transaction confirmations and improved user experience on L2 networks.
8+
9+
## Quick Start
10+
11+
Deploy the Op Stack with rollup-boost and Flashblocks enabled:
12+
13+
```bash
14+
$ go run main.go cook opstack --external-builder op-rbuilder --flashblocks
15+
```
16+
17+
This will deploy an Op Stack chain with:
18+
19+
- A complete L1 setup (CL/EL)
20+
- A complete L2 sequencer (op-geth/op-node/op-batcher)
21+
- Rollup-boost with Flashblocks enabled for pre-confirmations
22+
- Op-rbuilder as the external block builder with Flashblocks support
23+
24+
The `--flashblocks` flag enables the Flashblocks feature, allowing the system to provide pre-confirmations for faster transaction processing.

playground/artifacts.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ func Connect(service, port string) string {
411411
return ConnectRaw(service, port, "http", "")
412412
}
413413

414+
func ConnectWs(service, port string) string {
415+
return ConnectRaw(service, port, "ws", "")
416+
}
417+
414418
type output struct {
415419
dst string
416420

playground/catalog.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func init() {
2121
register(&BuilderHubPostgres{})
2222
register(&BuilderHubMockProxy{})
2323
register(&nullService{})
24+
register(&OpRbuilder{})
2425
}
2526

2627
func FindComponent(name string) ServiceGen {

playground/components.go

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,80 @@ var defaultJWTToken = "04592280e1778419b7aa954d43871cb2cfb2ebda754fb735e8adeb293
1313
type RollupBoost struct {
1414
ELNode string
1515
Builder string
16+
17+
Flashblocks bool
18+
FlashblocksBuilderURL string
1619
}
1720

1821
func (r *RollupBoost) Run(service *Service, ctx *ExContext) {
1922
service.
2023
WithImage("docker.io/flashbots/rollup-boost").
21-
WithTag("0.4rc1").
24+
WithTag("0.7.0").
2225
WithArgs(
26+
"--rpc-host", "0.0.0.0",
2327
"--rpc-port", `{{Port "authrpc" 8551}}`,
2428
"--l2-jwt-path", "/data/jwtsecret",
2529
"--l2-url", Connect(r.ELNode, "authrpc"),
2630
"--builder-jwt-path", "/data/jwtsecret",
2731
"--builder-url", r.Builder,
2832
).WithArtifact("/data/jwtsecret", "jwtsecret")
33+
34+
if r.Flashblocks {
35+
service.WithArgs(
36+
"--flashblocks",
37+
"--flashblocks-host", "0.0.0.0",
38+
"--flashblocks-port", `{{Port "flashblocks" 1112}}`,
39+
)
40+
}
41+
if r.FlashblocksBuilderURL != "" {
42+
service.WithArgs(
43+
"--flashblocks-builder-url", r.FlashblocksBuilderURL,
44+
)
45+
}
2946
}
3047

3148
func (r *RollupBoost) Name() string {
3249
return "rollup-boost"
3350
}
3451

52+
type OpRbuilder struct {
53+
Flashblocks bool
54+
}
55+
56+
func (o *OpRbuilder) Run(service *Service, ctx *ExContext) {
57+
service.WithImage("ghcr.io/flashbots/op-rbuilder").
58+
WithTag("sha-4f1931b").
59+
WithArgs(
60+
"node",
61+
"--authrpc.port", `{{Port "authrpc" 8551}}`,
62+
"--authrpc.addr", "0.0.0.0",
63+
"--authrpc.jwtsecret", "/data/jwtsecret",
64+
"--http",
65+
"--http.addr", "0.0.0.0",
66+
"--http.port", `{{Port "http" 8545}}`,
67+
"--chain", "/data/l2-genesis.json",
68+
"--datadir", "/data_op_reth",
69+
"--disable-discovery",
70+
"--color", "never",
71+
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
72+
"--port", `{{Port "rpc" 30303}}`).
73+
WithArtifact("/data/jwtsecret", "jwtsecret").
74+
WithArtifact("/data/l2-genesis.json", "l2-genesis.json").
75+
WithVolume("data", "/data_op_reth")
76+
77+
if o.Flashblocks {
78+
service.WithArgs(
79+
"--flashblocks.enabled",
80+
"--flashblocks.addr", "0.0.0.0",
81+
"--flashblocks.port", `{{Port "flashblocks" 1112}}`,
82+
)
83+
}
84+
}
85+
86+
func (o *OpRbuilder) Name() string {
87+
return "op-rbuilder"
88+
}
89+
3590
type OpBatcher struct {
3691
L1Node string
3792
L2Node string

playground/recipe_opstack.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ type OpRecipe struct {
2222
// batcherMaxChannelDuration is the maximum channel duration to use for the batcher
2323
// (default is 2 seconds)
2424
batcherMaxChannelDuration uint64
25+
26+
// whether to enable flashblocks in Rollup-boost. Note the internal builder **will not** be
27+
// using flashblocks. This is meant to be used with an external builder for now.
28+
flashblocks bool
29+
30+
// flashblocksBuilderURL is the URL of the builder that returns the flashblocks. This is meant to be used
31+
// for external builders.
32+
flashblocksBuilderURL string
2533
}
2634

2735
func (o *OpRecipe) Name() string {
@@ -38,6 +46,7 @@ func (o *OpRecipe) Flags() *flag.FlagSet {
3846
flags.Var(&nullableUint64Value{&o.enableLatestFork}, "enable-latest-fork", "Enable latest fork isthmus (nil or empty = disabled, otherwise enabled at specified block)")
3947
flags.Uint64Var(&o.blockTime, "block-time", defaultOpBlockTimeSeconds, "Block time to use for the rollup")
4048
flags.Uint64Var(&o.batcherMaxChannelDuration, "batcher-max-channel-duration", 2, "Maximum channel duration to use for the batcher")
49+
flags.BoolVar(&o.flashblocks, "flashblocks", false, "Whether to enable flashblocks")
4150
return flags
4251
}
4352

@@ -58,21 +67,35 @@ func (o *OpRecipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest {
5867
BeaconNode: "beacon",
5968
})
6069

70+
flashblocksBuilderURLRef := o.flashblocksBuilderURL
6171
externalBuilderRef := o.externalBuilder
72+
6273
if o.externalBuilder == "op-reth" {
6374
// Add a new op-reth service and connect it to Rollup-boost
6475
svcManager.AddService("op-reth", &OpReth{})
6576

6677
externalBuilderRef = Connect("op-reth", "authrpc")
78+
} else if o.externalBuilder == "op-rbuilder" {
79+
svcManager.AddService("op-rbuilder", &OpRbuilder{
80+
Flashblocks: o.flashblocks,
81+
})
82+
externalBuilderRef = Connect("op-rbuilder", "authrpc")
83+
}
84+
85+
if o.flashblocks && o.externalBuilder == "op-rbuilder" {
86+
// If flashblocks is enabled and using op-rbuilder, use it to deliver flashblocks
87+
flashblocksBuilderURLRef = ConnectWs("op-rbuilder", "flashblocks")
6788
}
6889

6990
elNode := "op-geth"
7091
if o.externalBuilder != "" {
7192
elNode = "rollup-boost"
7293

7394
svcManager.AddService("rollup-boost", &RollupBoost{
74-
ELNode: "op-geth",
75-
Builder: externalBuilderRef,
95+
ELNode: "op-geth",
96+
Builder: externalBuilderRef,
97+
Flashblocks: o.flashblocks,
98+
FlashblocksBuilderURL: flashblocksBuilderURLRef,
7699
})
77100
}
78101
svcManager.AddService("op-node", &OpNode{

0 commit comments

Comments
 (0)