Skip to content

Commit 5fc925d

Browse files
committed
Use correct L1 client for verifying origin in streamer
1 parent c097caa commit 5fc925d

File tree

10 files changed

+45
-2
lines changed

10 files changed

+45
-2
lines changed

espresso/cli.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
TestingBatcherPrivateKeyFlagName = espressoFlags("testing-batcher-private-key")
3636
OriginHeight = espressoFlags("origin-height")
3737
NamespaceFlagName = espressoFlags("namespace")
38+
RollupL1UrlFlagName = espressoFlags("rollup-l1-url")
3839
)
3940

4041
func CLIFlags(envPrefix string, category string) []cli.Flag {
@@ -96,6 +97,12 @@ func CLIFlags(envPrefix string, category string) []cli.Flag {
9697
EnvVars: espressoEnvs(envPrefix, "NAMESPACE"),
9798
Category: category,
9899
},
100+
&cli.StringFlag{
101+
Name: RollupL1UrlFlagName,
102+
Usage: "RPC URL of L1 backing the Rollup we're streaming for",
103+
EnvVars: espressoEnvs(envPrefix, "ROLLUP_L1_URL"),
104+
Category: category,
105+
},
99106
}
100107
}
101108

@@ -106,6 +113,7 @@ type CLIConfig struct {
106113
QueryServiceURLs []string
107114
LightClientAddr common.Address
108115
L1URL string
116+
RollupL1URL string
109117
TestingBatcherPrivateKey *ecdsa.PrivateKey
110118
Namespace uint64
111119
OriginHeight uint64
@@ -123,6 +131,9 @@ func (c CLIConfig) Check() error {
123131
if c.L1URL == "" {
124132
return fmt.Errorf("L1 URL is required when Espresso is enabled")
125133
}
134+
if c.RollupL1URL == "" {
135+
return fmt.Errorf("rollup L1 URL is required when Espresso is enabled")
136+
}
126137
if c.Namespace == 0 {
127138
return fmt.Errorf("namespace is required when Espresso is enabled")
128139
}
@@ -136,6 +147,7 @@ func ReadCLIConfig(c *cli.Context) CLIConfig {
136147
PollInterval: c.Duration(PollIntervalFlagName),
137148
UseFetchAPI: c.Bool(UseFetchApiFlagName),
138149
L1URL: c.String(L1UrlFlagName),
150+
RollupL1URL: c.String(RollupL1UrlFlagName),
139151
Namespace: c.Uint64(NamespaceFlagName),
140152
OriginHeight: c.Uint64(OriginHeight),
141153
}
@@ -169,6 +181,11 @@ func BatchStreamerFromCLIConfig[B Batch](
169181
return nil, fmt.Errorf("failed to dial L1 RPC: %w", err)
170182
}
171183

184+
RollupL1Client, err := ethclient.Dial(cfg.RollupL1URL)
185+
if err != nil {
186+
return nil, fmt.Errorf("failed to dial Rollup L1 RPC: %w", err)
187+
}
188+
172189
espressoClient, err := espressoClient.NewMultipleNodesClient(cfg.QueryServiceURLs)
173190
if err != nil {
174191
return nil, fmt.Errorf("failed to create Espresso client: %w", err)
@@ -182,6 +199,7 @@ func BatchStreamerFromCLIConfig[B Batch](
182199
streamer := NewEspressoStreamer(
183200
cfg.Namespace,
184201
NewAdaptL1BlockRefClient(l1Client),
202+
NewAdaptL1BlockRefClient(RollupL1Client),
185203
espressoClient,
186204
espressoLightClient,
187205
log,

espresso/environment/2_espresso_liveness_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ func TestE2eDevnetWithEspressoDegradedLivenessViaCaffNode(t *testing.T) {
262262
streamer := espresso.NewEspressoStreamer(
263263
system.RollupConfig.L2ChainID.Uint64(),
264264
espresso.NewAdaptL1BlockRefClient(l1Client),
265+
espresso.NewAdaptL1BlockRefClient(l1Client),
265266
espressoClient.NewClient(server.URL),
266267
lightClient,
267268
l,

espresso/environment/enclave_helpers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ func LaunchBatcherInEnclave() E2eDevnetLauncherOption {
9696
appendArg(&args, flags.L1EthRpcFlag.Name, l1Rpc)
9797
appendArg(&args, txmgr.L1RPCFlagName, l1Rpc)
9898
appendArg(&args, espresso.L1UrlFlagName, l1Rpc)
99+
appendArg(&args, espresso.RollupL1UrlFlagName, l1Rpc)
99100
l2EthRpc := sys.EthInstances[e2esys.RoleSeq].UserRPC().(endpoint.HttpRPC).HttpRPC()
100101
appendArg(&args, flags.L2EthRpcFlag.Name, l2EthRpc)
101102
rollupRpc := sys.RollupNodes[e2esys.RoleSeq].UserRPC().(endpoint.HttpRPC).HttpRPC()

espresso/environment/espresso_caff_node.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func LaunchCaffNode(t *testing.T, system *e2esys.System, espressoDevNode Espress
118118
// To create a valid multiple nodes client, we need to provide at least 2 URLs.
119119
QueryServiceURLs: []string{u.String(), u.String()},
120120
L1URL: system.L1.UserRPC().RPC(),
121+
RollupL1URL: system.L1.UserRPC().RPC(),
121122
LightClientAddr: common.HexToAddress(ESPRESSO_LIGHT_CLIENT_ADDRESS),
122123
}
123124

espresso/streamer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type BatchStreamer[B Batch] struct {
7474
Namespace uint64
7575

7676
L1Client L1Client
77+
RollupL1Client L1Client
7778
EspressoClient EspressoClient
7879
EspressoLightClient LightClientCallerInterface
7980
Log log.Logger
@@ -112,6 +113,7 @@ var _ EspressoStreamer[Batch] = (*BatchStreamer[Batch])(nil)
112113
func NewEspressoStreamer[B Batch](
113114
namespace uint64,
114115
l1Client L1Client,
116+
rollupL1Client L1Client,
115117
espressoClient EspressoClient,
116118
lightClient LightClientCallerInterface,
117119
log log.Logger,
@@ -121,6 +123,7 @@ func NewEspressoStreamer[B Batch](
121123
) *BatchStreamer[B] {
122124
return &BatchStreamer[B]{
123125
L1Client: l1Client,
126+
RollupL1Client: rollupL1Client,
124127
EspressoClient: espressoClient,
125128
EspressoLightClient: lightClient,
126129
Log: log,
@@ -193,7 +196,7 @@ func (s *BatchStreamer[B]) CheckBatch(ctx context.Context, batch B) (BatchValidi
193196
return BatchUndecided, 0
194197
}
195198

196-
l1headerHash, err := s.L1Client.HeaderHashByNumber(ctx, new(big.Int).SetUint64(origin.Number))
199+
l1headerHash, err := s.RollupL1Client.HeaderHashByNumber(ctx, new(big.Int).SetUint64(origin.Number))
197200
if err != nil {
198201
// Signal to resync to be able to fetch the L1 header.
199202
s.Log.Warn("Failed to fetch the L1 header, pending resync", "error", err)

espresso/streamer_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func TestNewEspressoStreamer(t *testing.T) {
3535
_ = espresso.NewEspressoStreamer(
3636
1,
3737
nil,
38+
nil,
3839
nil, nil, nil, derive.CreateEspressoBatchUnmarshaler(common.Address{}),
3940
50*time.Millisecond,
4041
0,
@@ -356,6 +357,7 @@ func setupStreamerTesting(namespace uint64, batcherAddress common.Address) (*Moc
356357
state,
357358
state,
358359
state,
360+
state,
359361
logger,
360362
derive.CreateEspressoBatchUnmarshaler(batcherAddress),
361363
50*time.Millisecond,

op-batcher/batcher/service.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,14 @@ func (bs *BatcherService) initEspresso(cfg *CLIConfig) error {
541541
return nil
542542
}
543543

544+
if cfg.Espresso.RollupL1URL == "" {
545+
cfg.Espresso.RollupL1URL = cfg.L1EthRpc
546+
}
547+
548+
if cfg.Espresso.RollupL1URL != cfg.L1EthRpc {
549+
log.Warn("Espresso Rollup L1 URL differs from batcher's L1EthRpc")
550+
}
551+
544552
if cfg.Espresso.L1URL == "" {
545553
log.Warn("Espresso L1 URL not provided, using batcher's L1EthRpc")
546554
cfg.Espresso.L1URL = cfg.L1EthRpc

op-batcher/enclave-entrypoint.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# to directly pass commandline arguments when starting EIF images)
77

88
# We will need to start a proxy for each of those urls
9-
URL_ARG_RE='^(--altda\.da-server|--espresso\.urls|--espresso.\l1-url|--l1-eth-rpc|--l2-eth-rpc|--rollup-rpc|--signer\.endpoint)(=|$)'
9+
URL_ARG_RE='^(--altda\.da-server|--espresso\.urls|--espresso.\l1-url|--espresso.rollup-l1-url|--l1-eth-rpc|--l2-eth-rpc|--rollup-rpc|--signer\.endpoint)(=|$)'
1010

1111
# Re-populate the arguments passed through the environment
1212
if [ -n "$ENCLAVE_BATCHER_ARGS" ]; then

op-e2e/system/e2esys/setup.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System,
10241024
Enabled: (cfg.AllocType == config.AllocTypeEspressoWithEnclave) || (cfg.AllocType == config.AllocTypeEspressoWithoutEnclave),
10251025
PollInterval: 250 * time.Millisecond,
10261026
L1URL: sys.EthInstances[RoleL1].UserRPC().RPC(),
1027+
RollupL1URL: sys.EthInstances[RoleL1].UserRPC().RPC(),
10271028
TestingBatcherPrivateKey: testingBatcherPk,
10281029
}
10291030

op-node/service.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ func NewConfig(ctx *cli.Context, log log.Logger) (*config.Config, error) {
6969

7070
l1Endpoint := NewL1EndpointConfig(ctx)
7171

72+
if rollupConfig.CaffNodeConfig.RollupL1URL == "" {
73+
rollupConfig.CaffNodeConfig.RollupL1URL = l1Endpoint.L1NodeAddr
74+
}
75+
76+
if l1Endpoint.L1NodeAddr != rollupConfig.CaffNodeConfig.RollupL1URL {
77+
log.Warn("Espresso streamer rollup L1 URL does not match L1 node address of caff node", "rollupL1URL", rollupConfig.CaffNodeConfig.RollupL1URL, "l1NodeAddr", l1Endpoint.L1NodeAddr)
78+
}
79+
7280
l2Endpoint, err := NewL2EndpointConfig(ctx, log)
7381
if err != nil {
7482
return nil, fmt.Errorf("failed to load l2 endpoints info: %w", err)

0 commit comments

Comments
 (0)