55 "fmt"
66 "io"
77 "strconv"
8+ "strings"
89 "time"
910
1011 "github.com/ethereum/go-ethereum/common/hexutil"
@@ -100,13 +101,35 @@ func (o *OpRbuilder) Name() string {
100101
101102type FlashblocksRPC struct {
102103 FlashblocksWSService string
104+ BaseOverlay bool
105+ UseWebsocketProxy bool // Whether to add /ws path for websocket proxy
103106}
104107
105108func (f * FlashblocksRPC ) Run (service * Service , ctx * ExContext ) {
106- service .WithImage ("flashbots/flashblocks-rpc" ).
107- WithTag ("sha-7caffb9" ).
108- WithArgs (
109- "node" ,
109+ websocketURL := ConnectWs (f .FlashblocksWSService , "flashblocks" )
110+ if f .UseWebsocketProxy {
111+ websocketURL += "/ws"
112+ }
113+
114+ if f .BaseOverlay {
115+ // Base doesn't have built image, so we use mikawamp/base-reth-node
116+ service .WithImage ("docker.io/mikawamp/base-reth-node" ).
117+ WithTag ("latest" ).
118+ WithEntrypoint ("/app/base-reth-node" ).
119+ WithArgs (
120+ "node" ,
121+ "--websocket-url" , websocketURL ,
122+ )
123+ } else {
124+ service .WithImage ("flashbots/flashblocks-rpc" ).
125+ WithTag ("sha-7caffb9" ).
126+ WithArgs (
127+ "node" ,
128+ "--flashblocks.enabled" ,
129+ "--flashblocks.websocket-url" , websocketURL ,
130+ )
131+ }
132+ service .WithArgs (
110133 "--authrpc.port" , `{{Port "authrpc" 8551}}` ,
111134 "--authrpc.addr" , "0.0.0.0" ,
112135 "--authrpc.jwtsecret" , "/data/jwtsecret" ,
@@ -119,8 +142,6 @@ func (f *FlashblocksRPC) Run(service *Service, ctx *ExContext) {
119142 "--color" , "never" ,
120143 "--metrics" , `0.0.0.0:{{Port "metrics" 9090}}` ,
121144 "--port" , `{{Port "rpc" 30303}}` ,
122- "--flashblocks.enabled" ,
123- "--flashblocks.websocket-url" , ConnectWs (f .FlashblocksWSService , "flashblocks" ),
124145 ).
125146 WithArtifact ("/data/jwtsecret" , "jwtsecret" ).
126147 WithArtifact ("/data/l2-genesis.json" , "l2-genesis.json" ).
@@ -137,6 +158,73 @@ func (f *FlashblocksRPC) Name() string {
137158 return "flashblocks-rpc"
138159}
139160
161+ type BProxy struct {
162+ TargetAuthrpc string
163+ Peers []string
164+ Flashblocks bool
165+ FlashblocksBuilderURL string
166+ }
167+
168+ func (f * BProxy ) Run (service * Service , ctx * ExContext ) {
169+ peers := []string {}
170+ for _ , peer := range f .Peers {
171+ peers = append (peers , Connect (peer , "authrpc" ))
172+ }
173+ service .WithImage ("ghcr.io/flashbots/bproxy" ).
174+ WithTag ("v0.0.91" ).
175+ WithArgs (
176+ "serve" ,
177+ "--authrpc-backend" , f .TargetAuthrpc ,
178+ "--authrpc-backend-timeout" , "5s" ,
179+ "--authrpc-client-idle-connection-timeout" , "15m" ,
180+ "--authrpc-deduplicate-fcus" ,
181+ "--authrpc-enabled" ,
182+ "--authrpc-listen-address" , `0.0.0.0:{{Port "authrpc" 8651}}` ,
183+ "--authrpc-log-requests" ,
184+ "--authrpc-log-responses" ,
185+ "--authrpc-max-backend-connections-per-host" , "1" ,
186+ "--authrpc-max-request-size" , "150" ,
187+ "--authrpc-max-response-size" , "1150" ,
188+ "--authrpc-peers" , strings .Join (peers , "," ),
189+ "--authrpc-remove-backend-from-peers" ,
190+ "--authrpc-use-priority-queue" ,
191+ ).
192+ WithArtifact ("/data/jwtsecret" , "jwtsecret" )
193+
194+ if f .Flashblocks {
195+ service .WithArgs (
196+ "--flashblocks-backend" , f .FlashblocksBuilderURL ,
197+ "--flashblocks-enabled" ,
198+ "--flashblocks-listen-address" , `0.0.0.0:{{Port "flashblocks" 1114}}` ,
199+ "--flashblocks-log-messages" ,
200+ )
201+ }
202+
203+ }
204+
205+ func (f * BProxy ) Name () string {
206+ return "bproxy"
207+ }
208+
209+ type WebsocketProxy struct {
210+ Upstream string
211+ }
212+
213+ func (w * WebsocketProxy ) Run (service * Service , ctx * ExContext ) {
214+ service .WithImage ("docker.io/mikawamp/websocket-rpc" ).
215+ WithTag ("latest" ).
216+ WithArgs (
217+ "--listen-addr" , `0.0.0.0:{{Port "flashblocks" 1115}}` ,
218+ "--upstream-ws" , ConnectWs (w .Upstream , "flashblocks" ),
219+ "--enable-compression" ,
220+ "--client-ping-enabled" ,
221+ )
222+ }
223+
224+ func (w * WebsocketProxy ) Name () string {
225+ return "websocket-proxy"
226+ }
227+
140228type OpBatcher struct {
141229 L1Node string
142230 L2Node string
0 commit comments