Skip to content

Commit 477a842

Browse files
authored
feat: add chain-monitor (#225)
Add new `--chain-monitor` flag for opstack recipe to bootstrap https://github.com/flashbots/chain-monitor Using `0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266` as builder signer for op-rbuilder
1 parent 467132c commit 477a842

File tree

3 files changed

+76
-7
lines changed

3 files changed

+76
-7
lines changed

playground/catalog.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ func init() {
2525
register(&BProxy{})
2626
register(&WebsocketProxy{})
2727
register(&BuilderHub{})
28+
register(&ChainMonitor{})
2829
}

playground/components.go

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func (r *RollupBoost) Apply(manifest *Manifest) {
2828
service := manifest.NewService("rollup-boost").
2929
WithImage("docker.io/flashbots/rollup-boost").
3030
WithTag("v0.7.5").
31+
DependsOnHealthy(r.ELNode).
3132
WithArgs(
3233
"--rpc-host", "0.0.0.0",
3334
"--rpc-port", `{{Port "authrpc" 8551}}`,
@@ -74,10 +75,18 @@ func (o *OpRbuilder) Apply(manifest *Manifest) {
7475
"--metrics", `0.0.0.0:{{Port "metrics" 9090}}`,
7576
"--port", `{{Port "rpc" 30303}}`,
7677
"--builder.enable-revert-protection",
78+
"--rollup.builder-secret-key", "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
7779
).
7880
WithArtifact("/data/jwtsecret", "jwtsecret").
7981
WithArtifact("/data/l2-genesis.json", "l2-genesis.json").
80-
WithVolume("data", "/data_op_reth")
82+
WithVolume("data", "/data_op_reth").
83+
WithReady(ReadyCheck{
84+
QueryURL: "http://localhost:8545",
85+
Interval: 1 * time.Second,
86+
Timeout: 10 * time.Second,
87+
Retries: 20,
88+
StartPeriod: 1 * time.Second,
89+
})
8190

8291
if manifest.ctx.Bootnode != nil {
8392
service.WithArgs("--trusted-peers", manifest.ctx.Bootnode.Connect())
@@ -211,6 +220,29 @@ func (w *WebsocketProxy) Apply(manifest *Manifest) {
211220
)
212221
}
213222

223+
type ChainMonitor struct {
224+
L1RPC string
225+
L2BlockTime uint64
226+
L2BuilderAddress string
227+
L2RPC string
228+
}
229+
230+
func (c *ChainMonitor) Apply(manifest *Manifest) {
231+
manifest.NewService("chain-monitor").
232+
WithPort("metrics", 8080).
233+
WithImage("ghcr.io/flashbots/chain-monitor").
234+
WithTag("v0.0.54").
235+
DependsOnHealthy(c.L1RPC).
236+
DependsOnHealthy(c.L2RPC).
237+
WithArgs(
238+
"serve",
239+
"--l1-rpc", Connect(c.L1RPC, "http"),
240+
"--l2-block-time", fmt.Sprintf("%ds", c.L2BlockTime),
241+
"--l2-monitor-builder-address", c.L2BuilderAddress,
242+
"--l2-rpc", Connect(c.L2RPC, "http"),
243+
)
244+
}
245+
214246
type OpBatcher struct {
215247
L1Node string
216248
L2Node string
@@ -257,6 +289,9 @@ func (o *OpNode) Apply(manifest *Manifest) {
257289
"--l1.http-poll-interval", "6s",
258290
"--l2", Connect(o.L2Node, "authrpc"),
259291
"--l2.jwt-secret", "/data/jwtsecret",
292+
"--metrics.enabled",
293+
"--metrics.addr", "0.0.0.0",
294+
"--metrics.port", `{{Port "metrics" 7300}}`,
260295
"--sequencer.enabled",
261296
"--sequencer.l1-confs", "0",
262297
"--verifier.l1-confs", "0",
@@ -269,9 +304,6 @@ func (o *OpNode) Apply(manifest *Manifest) {
269304
"--p2p.listen.udp", `{{PortUDP "p2p" 9003}}`,
270305
"--p2p.scoring.peers", "light",
271306
"--p2p.ban.peers", "true",
272-
"--metrics.enabled",
273-
"--metrics.addr", "0.0.0.0",
274-
"--metrics.port", `{{Port "metrics" 7300}}`,
275307
"--pprof.enabled",
276308
"--rpc.enable-admin",
277309
"--safedb.path", "/data_db",
@@ -355,7 +387,14 @@ func (o *OpGeth) Apply(manifest *Manifest) {
355387
WithReadyFn(opGethReadyFn).
356388
WithArtifact("/data/l2-genesis.json", "l2-genesis.json").
357389
WithArtifact("/data/jwtsecret", "jwtsecret").
358-
WithArtifact("/data/p2p_key.txt", o.Enode.Artifact)
390+
WithArtifact("/data/p2p_key.txt", o.Enode.Artifact).
391+
WithReady(ReadyCheck{
392+
QueryURL: "http://localhost:8545",
393+
Interval: 1 * time.Second,
394+
Timeout: 10 * time.Second,
395+
Retries: 20,
396+
StartPeriod: 1 * time.Second,
397+
})
359398
}
360399

361400
func opGethReadyFn(ctx context.Context, instance *instance) error {
@@ -451,7 +490,14 @@ func (r *RethEL) Apply(manifest *Manifest) {
451490
}).
452491
WithArtifact("/data/genesis.json", "genesis.json").
453492
WithArtifact("/data/jwtsecret", "jwtsecret").
454-
WithVolume("data", "/data_reth")
493+
WithVolume("data", "/data_reth").
494+
WithReady(ReadyCheck{
495+
QueryURL: "http://localhost:8545",
496+
Interval: 1 * time.Second,
497+
Timeout: 10 * time.Second,
498+
Retries: 20,
499+
StartPeriod: 1 * time.Second,
500+
})
455501

456502
if r.UseNativeReth {
457503
// we need to use this otherwise the db cannot be binded
@@ -639,7 +685,14 @@ func (o *OpReth) Apply(manifest *Manifest) {
639685
}).
640686
WithArtifact("/data/jwtsecret", "jwtsecret").
641687
WithArtifact("/data/l2-genesis.json", "l2-genesis.json").
642-
WithVolume("data", "/data_op_reth")
688+
WithVolume("data", "/data_op_reth").
689+
WithReady(ReadyCheck{
690+
QueryURL: "http://localhost:8545",
691+
Interval: 1 * time.Second,
692+
Timeout: 10 * time.Second,
693+
Retries: 20,
694+
StartPeriod: 1 * time.Second,
695+
})
643696
}
644697

645698
type MevBoost struct {

playground/recipe_opstack.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66

77
var _ Recipe = &OpRecipe{}
88

9+
const defaultL2BuilderAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
10+
911
// OpRecipe is a recipe that deploys an OP stack
1012
type OpRecipe struct {
1113
// externalBuilder is the URL of the external builder to use. If enabled, the recipe deploys
@@ -36,6 +38,9 @@ type OpRecipe struct {
3638

3739
// whether to enable websocket proxy
3840
enableWebsocketProxy bool
41+
42+
// whether to enable chain-monitor
43+
enableChainMonitor bool
3944
}
4045

4146
func (o *OpRecipe) Name() string {
@@ -56,6 +61,7 @@ func (o *OpRecipe) Flags() *flag.FlagSet {
5661
flags.BoolVar(&o.baseOverlay, "base-overlay", false, "Whether to use base implementation for flashblocks-rpc")
5762
flags.StringVar(&o.flashblocksBuilderURL, "flashblocks-builder", "", "External URL of builder flashblocks stream")
5863
flags.BoolVar(&o.enableWebsocketProxy, "enable-websocket-proxy", false, "Whether to enable websocket proxy")
64+
flags.BoolVar(&o.enableChainMonitor, "chain-monitor", false, "Whether to enable chain-monitor")
5965
return flags
6066
}
6167

@@ -174,6 +180,15 @@ func (o *OpRecipe) Apply(svcManager *Manifest) {
174180
MaxChannelDuration: o.batcherMaxChannelDuration,
175181
})
176182

183+
if o.enableChainMonitor {
184+
svcManager.AddService(&ChainMonitor{
185+
L1RPC: "el",
186+
L2BlockTime: o.blockTime,
187+
L2BuilderAddress: defaultL2BuilderAddress,
188+
L2RPC: "op-geth",
189+
})
190+
}
191+
177192
if svcManager.ctx.Contender.TargetChain == "" {
178193
svcManager.ctx.Contender.TargetChain = "op-geth"
179194
}

0 commit comments

Comments
 (0)