-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathrecipe_opstack.go
More file actions
210 lines (174 loc) · 6.3 KB
/
recipe_opstack.go
File metadata and controls
210 lines (174 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
package playground
import (
flag "github.com/spf13/pflag"
)
var _ Recipe = &OpRecipe{}
const defaultL2BuilderAddress = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
// OpRecipe is a recipe that deploys an OP stack
type OpRecipe struct {
// externalBuilder is the URL of the external builder to use. If enabled, the recipe deploys
// rollup-boost on the sequencer and uses this URL as the external builder.
externalBuilder string
// whether to enable the latest fork isthmus and when
enableLatestFork *uint64
// blockTime is the block time to use for the rollup
// (default is 2 seconds)
blockTime uint64
// batcherMaxChannelDuration is the maximum channel duration to use for the batcher
// (default is 2 seconds)
batcherMaxChannelDuration uint64
// whether to enable flashblocks in Rollup-boost. Note the internal builder **will not** be
// using flashblocks. This is meant to be used with an external builder for now.
flashblocks bool
// flashblocksBuilderURL is the URL of the builder that returns the flashblocks. This is meant to be used
// for external builders.
flashblocksBuilderURL string
// Indicates that flashblocks-rpc should use base image
baseOverlay bool
// whether to enable websocket proxy
enableWebsocketProxy bool
// whether to enable chain-monitor
enableChainMonitor bool
}
func (o *OpRecipe) Name() string {
return "opstack"
}
func (o *OpRecipe) Description() string {
return "Deploy an OP stack"
}
func (o *OpRecipe) Flags() *flag.FlagSet {
flags := flag.NewFlagSet("opstack", flag.ContinueOnError)
flags.StringVar(&o.externalBuilder, "external-builder", "", "External builder URL")
flags.Var(&nullableUint64Value{&o.enableLatestFork}, "enable-latest-fork", "Enable latest fork isthmus (nil or empty = disabled, otherwise enabled at specified block)")
flags.Uint64Var(&o.blockTime, "block-time", defaultOpBlockTimeSeconds, "Block time to use for the rollup")
flags.Uint64Var(&o.batcherMaxChannelDuration, "batcher-max-channel-duration", 2, "Maximum channel duration to use for the batcher")
flags.BoolVar(&o.flashblocks, "flashblocks", false, "Whether to enable flashblocks")
flags.BoolVar(&o.baseOverlay, "base-overlay", false, "Whether to use base implementation for flashblocks-rpc")
flags.StringVar(&o.flashblocksBuilderURL, "flashblocks-builder", "", "External URL of builder flashblocks stream")
flags.BoolVar(&o.enableWebsocketProxy, "enable-websocket-proxy", false, "Whether to enable websocket proxy")
flags.BoolVar(&o.enableChainMonitor, "chain-monitor", false, "Whether to enable chain-monitor")
return flags
}
func (o *OpRecipe) Artifacts() *ArtifactsBuilder {
builder := NewArtifactsBuilder()
builder.WithL2()
builder.ApplyLatestL2Fork(o.enableLatestFork)
builder.OpBlockTime(o.blockTime)
return builder
}
func (o *OpRecipe) Apply(svcManager *Manifest) {
svcManager.AddService(&RethEL{})
svcManager.AddService(&LighthouseBeaconNode{
ExecutionNode: "el",
})
svcManager.AddService(&LighthouseValidator{
BeaconNode: "beacon",
})
flashblocksBuilderURLRef := o.flashblocksBuilderURL
externalBuilderRef := o.externalBuilder
peers := []string{}
opGeth := &OpGeth{}
svcManager.AddService(opGeth)
svcManager.ctx.Bootnode = &BootnodeRef{
Service: "op-geth",
ID: opGeth.Enode.NodeID(),
}
if o.externalBuilder == "op-reth" {
// Add a new op-reth service and connect it to Rollup-boost
svcManager.AddService(&OpReth{})
externalBuilderRef = Connect("op-reth", "authrpc")
} else if o.externalBuilder == "op-rbuilder" {
svcManager.AddService(&OpRbuilder{
Flashblocks: o.flashblocks,
})
externalBuilderRef = Connect("op-rbuilder", "authrpc")
}
if o.flashblocks && o.externalBuilder == "op-rbuilder" {
// If flashblocks is enabled and using op-rbuilder, use it to deliver flashblocks
flashblocksBuilderURLRef = ConnectWs("op-rbuilder", "flashblocks")
}
if o.flashblocks {
peers = append(peers, "flashblocks-rpc")
}
// Only enable bproxy if flashblocks is enabled (since flashblocks-rpc is the only service that needs it)
if o.flashblocks {
svcManager.AddService(&BProxy{
TargetAuthrpc: externalBuilderRef,
Peers: peers,
Flashblocks: o.flashblocks,
FlashblocksBuilderURL: flashblocksBuilderURLRef,
})
}
// Only enable websocket-proxy if the flag is set
if o.enableWebsocketProxy {
svcManager.AddService(&WebsocketProxy{
Upstream: "rollup-boost",
})
}
elNode := "op-geth"
if o.externalBuilder != "" {
elNode = "rollup-boost"
// Use bproxy if flashblocks is enabled, otherwise use external builder directly
builderRef := externalBuilderRef
flashblocksBuilderRef := flashblocksBuilderURLRef
if o.flashblocks {
builderRef = Connect("bproxy", "authrpc")
flashblocksBuilderRef = ConnectWs("bproxy", "flashblocks")
}
svcManager.AddService(&RollupBoost{
ELNode: "op-geth",
Builder: builderRef,
Flashblocks: o.flashblocks,
FlashblocksBuilderURL: flashblocksBuilderRef,
})
}
if o.flashblocks {
// Determine which service to use for flashblocks websocket connection
flashblocksWSService := "rollup-boost"
useWebsocketProxy := false
if o.enableWebsocketProxy {
flashblocksWSService = "websocket-proxy"
useWebsocketProxy = true
}
svcManager.AddService(&FlashblocksRPC{
FlashblocksWSService: flashblocksWSService,
BaseOverlay: o.baseOverlay,
UseWebsocketProxy: useWebsocketProxy,
})
}
svcManager.AddService(&OpNode{
L1Node: "el",
L1Beacon: "beacon",
L2Node: elNode,
})
svcManager.AddService(&OpBatcher{
L1Node: "el",
L2Node: "op-geth",
RollupNode: "op-node",
MaxChannelDuration: o.batcherMaxChannelDuration,
})
if o.enableChainMonitor {
svcManager.AddService(&ChainMonitor{
L1RPC: "el",
L2BlockTime: o.blockTime,
L2BuilderAddress: defaultL2BuilderAddress,
L2RPC: "op-geth",
})
}
if svcManager.ctx.Contender.TargetChain == "" {
svcManager.ctx.Contender.TargetChain = "op-geth"
}
svcManager.RunContenderIfEnabled()
}
func (o *OpRecipe) Output(manifest *Manifest) map[string]interface{} {
/*
opGeth := manifest.MustGetService("op-geth").component.(*OpGeth)
if opGeth.Enode != "" {
// Only output if enode was set
return map[string]interface{}{
"op-geth-enode": opGeth.Enode,
}
}
*/
return map[string]interface{}{}
}