Skip to content

Commit 671e7a0

Browse files
committed
feat (breaking): fine-grain mirroring control over authrpc
1 parent 474e433 commit 671e7a0

File tree

4 files changed

+65
-16
lines changed

4 files changed

+65
-16
lines changed

cmd/serve.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,44 @@ func CommandServe(cfg *config.Config) *cli.Command {
319319
Usage: "deduplicate repetitive fcu messages",
320320
},
321321

322+
&cli.BoolFlag{ // --authrpc-mirror-fcu-without-payload
323+
Category: strings.ToUpper(categoryAuthrpc),
324+
Destination: &cfg.Authrpc.MirrorFcuWithoutPayload,
325+
EnvVars: []string{envPrefix + strings.ToUpper(categoryAuthrpc) + "_MIRROR_FCU_WITHOUT_PAYLOAD"},
326+
Name: categoryAuthrpc + "-mirror-fcu-without-payload",
327+
Usage: "mirror engine_forkchoiceUpdated calls that do not carry execution payload",
328+
},
329+
330+
&cli.BoolFlag{ // --authrpc-mirror-fcu-with-payload
331+
Category: strings.ToUpper(categoryAuthrpc),
332+
Destination: &cfg.Authrpc.MirrorFcuWithPayload,
333+
EnvVars: []string{envPrefix + strings.ToUpper(categoryAuthrpc) + "_MIRROR_FCU_WITH_PAYLOAD"},
334+
Name: categoryAuthrpc + "-mirror-fcu-with-payload",
335+
Usage: "mirror engine_forkchoiceUpdated calls that carry execution payload",
336+
},
337+
322338
&cli.BoolFlag{ // --authrpc-mirror-get-payload
323339
Category: strings.ToUpper(categoryAuthrpc),
324340
Destination: &cfg.Authrpc.MirrorGetPayload,
325341
EnvVars: []string{envPrefix + strings.ToUpper(categoryAuthrpc) + "_MIRROR_GET_PAYLOAD"},
326342
Name: categoryAuthrpc + "-mirror-get-payload",
327-
Usage: "mirror getPayload calls as well",
343+
Usage: "mirror engine_getPayload calls",
344+
},
345+
346+
&cli.BoolFlag{ // --authrpc-mirror-new-payload
347+
Category: strings.ToUpper(categoryAuthrpc),
348+
Destination: &cfg.Authrpc.MirrorNewPayload,
349+
EnvVars: []string{envPrefix + strings.ToUpper(categoryAuthrpc) + "_MIRROR_NEW_PAYLOAD"},
350+
Name: categoryAuthrpc + "-mirror-new-payload",
351+
Usage: "mirror engine_newPayload calls",
352+
},
353+
354+
&cli.BoolFlag{ // --authrpc-mirror-set-max-da-size
355+
Category: strings.ToUpper(categoryAuthrpc),
356+
Destination: &cfg.Authrpc.MirrorSetMaxDASize,
357+
EnvVars: []string{envPrefix + strings.ToUpper(categoryAuthrpc) + "_MIRROR_SET_MAX_DA_SIZE"},
358+
Name: categoryAuthrpc + "-mirror-set-max-da-size",
359+
Usage: "mirror miner_setMaxDASize calls",
328360
},
329361
)
330362

config/authrpc.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ package config
33
type Authrpc struct {
44
*HttpProxy `yaml:"proxy"`
55

6-
DeduplicateFCUs bool `yaml:"deduplicate_fcus"`
7-
MirrorGetPayload bool `yaml:"mirror_get_payload"`
6+
DeduplicateFCUs bool `yaml:"deduplicate_fcus"`
7+
8+
MirrorFcuWithoutPayload bool `yaml:"mirror_fcu_without_payload"`
9+
MirrorFcuWithPayload bool `yaml:"mirror_fcu_with_payload"`
10+
MirrorGetPayload bool `yaml:"mirror_get_payload"`
11+
MirrorNewPayload bool `yaml:"mirror_new_payload"`
12+
MirrorSetMaxDASize bool `yaml:"mirror_set_max_da_size"`
813
}

proxy/authrpc.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ type Authrpc struct {
3232
}
3333

3434
type authrpcConfig struct {
35-
deduplicateFCUs bool
36-
mirrorGetPayload bool
35+
deduplicateFCUs bool
36+
mirrorFcuWithoutPayload bool
37+
mirrorFcuWithPayload bool
38+
mirrorGetPayload bool
39+
mirrorNewPayload bool
40+
mirrorSetMaxDASize bool
3741
}
3842

3943
func NewAuthrpc(
@@ -54,8 +58,12 @@ func NewAuthrpc(
5458
tickerSeenHeads: time.NewTicker(30 * time.Second),
5559

5660
cfg: &authrpcConfig{
57-
deduplicateFCUs: cfg.DeduplicateFCUs,
58-
mirrorGetPayload: cfg.MirrorGetPayload,
61+
deduplicateFCUs: cfg.DeduplicateFCUs,
62+
mirrorFcuWithoutPayload: cfg.MirrorFcuWithoutPayload,
63+
mirrorFcuWithPayload: cfg.MirrorFcuWithPayload,
64+
mirrorGetPayload: cfg.MirrorGetPayload,
65+
mirrorNewPayload: cfg.MirrorNewPayload,
66+
mirrorSetMaxDASize: cfg.MirrorSetMaxDASize,
5967
},
6068
}
6169
ap.proxy.triage = ap.triage
@@ -149,7 +157,7 @@ func (p *Authrpc) triage(ctx *fasthttp.RequestCtx) (
149157
JrpcMethod: call.GetMethod(),
150158
}, fasthttp.AcquireResponse()
151159

152-
case strings.HasPrefix(call.GetMethod(), "engine_getPayload"): // proxy with priority
160+
case strings.HasPrefix(call.GetMethod(), "engine_getPayload"):
153161
return &triaged.Request{
154162
Proxy: true,
155163
Prioritise: true,
@@ -158,19 +166,19 @@ func (p *Authrpc) triage(ctx *fasthttp.RequestCtx) (
158166
JrpcMethod: call.GetMethod(),
159167
}, fasthttp.AcquireResponse()
160168

161-
case strings.HasPrefix(call.GetMethod(), "engine_newPayload"): // proxy & mirror with priority
169+
case strings.HasPrefix(call.GetMethod(), "engine_newPayload"):
162170
return &triaged.Request{
163171
Proxy: true,
164172
Prioritise: true,
165-
Mirror: true,
173+
Mirror: p.cfg.mirrorNewPayload,
166174
JrpcID: call.GetID(),
167175
JrpcMethod: call.GetMethod(),
168176
}, fasthttp.AcquireResponse()
169177

170-
case strings.HasPrefix(call.GetMethod(), "miner_setMaxDASize"): // proxy & mirror
178+
case strings.HasPrefix(call.GetMethod(), "miner_setMaxDASize"):
171179
return &triaged.Request{
172180
Proxy: true,
173-
Mirror: true,
181+
Mirror: p.cfg.mirrorSetMaxDASize,
174182
JrpcID: call.GetID(),
175183
JrpcMethod: call.GetMethod(),
176184
}, fasthttp.AcquireResponse()
@@ -183,7 +191,7 @@ func (p *Authrpc) triage(ctx *fasthttp.RequestCtx) (
183191
)
184192
return &triaged.Request{
185193
Proxy: true,
186-
Mirror: true,
194+
Mirror: p.cfg.mirrorFcuWithoutPayload,
187195
JrpcID: call.GetID(),
188196
JrpcMethod: call.GetMethod(),
189197
}, fasthttp.AcquireResponse()
@@ -207,7 +215,7 @@ func (p *Authrpc) triage(ctx *fasthttp.RequestCtx) (
207215
return &triaged.Request{
208216
Proxy: true,
209217
Prioritise: true,
210-
Mirror: true,
218+
Mirror: p.cfg.mirrorFcuWithoutPayload,
211219
Deadline: blockTimestamp,
212220
JrpcID: call.GetID(),
213221
JrpcMethod: call.GetMethod() + "_withPayload",
@@ -225,7 +233,7 @@ func (p *Authrpc) triage(ctx *fasthttp.RequestCtx) (
225233
return &triaged.Request{
226234
Proxy: true,
227235
Prioritise: true,
228-
Mirror: true,
236+
Mirror: p.cfg.mirrorFcuWithPayload,
229237
JrpcID: call.GetID(),
230238
JrpcMethod: call.GetMethod() + "_withPayload",
231239
}, fasthttp.AcquireResponse()

readme.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ OPTIONS:
3232
--authrpc-max-client-connections-per-ip count maximum authrpc client tcp connections count per ip (0 means unlimited) (default: 0) [$BPROXY_AUTHRPC_MAX_CLIENT_CONNECTIONS_PER_IP]
3333
--authrpc-max-request-size megabytes maximum authrpc request payload size in megabytes (default: 15) [$BPROXY_AUTHRPC_MAX_REQUEST_SIZE]
3434
--authrpc-max-response-size megabytes maximum authrpc response payload size in megabytes (default: 160) [$BPROXY_AUTHRPC_MAX_RESPONSE_SIZE]
35-
--authrpc-mirror-get-payload mirror getPayload calls as well (default: false) [$BPROXY_AUTHRPC_MIRROR_GET_PAYLOAD]
35+
--authrpc-mirror-fcu-with-payload mirror engine_forkchoiceUpdated calls that carry execution payload (default: false) [$BPROXY_AUTHRPC_MIRROR_FCU_WITH_PAYLOAD]
36+
--authrpc-mirror-fcu-without-payload mirror engine_forkchoiceUpdated calls that do not carry execution payload (default: false) [$BPROXY_AUTHRPC_MIRROR_FCU_WITHOUT_PAYLOAD]
37+
--authrpc-mirror-get-payload mirror engine_getPayload calls (default: false) [$BPROXY_AUTHRPC_MIRROR_GET_PAYLOAD]
38+
--authrpc-mirror-new-payload mirror engine_newPayload calls (default: false) [$BPROXY_AUTHRPC_MIRROR_NEW_PAYLOAD]
39+
--authrpc-mirror-set-max-da-size mirror miner_setMaxDASize calls (default: false) [$BPROXY_AUTHRPC_MIRROR_SET_MAX_DA_SIZE]
3640
--authrpc-peer-tls-insecure-skip-verify do not verify authrpc peers' tls certificates (default: false) [$BPROXY_AUTHRPC_PEER_TLS_INSECURE_SKIP_VERIFY]
3741
--authrpc-peers urls [ --authrpc-peers urls ] list of authrpc peers urls to mirror the requests to [$BPROXY_AUTHRPC_PEERS]
3842
--authrpc-remove-backend-from-peers remove authrpc backend from peers (default: false) [$BPROXY_AUTHRPC_REMOVE_BACKEND_FROM_PEERS]

0 commit comments

Comments
 (0)