Commit 6bd72f00 authored by protolambda's avatar protolambda Committed by GitHub

op-batcher: apply code-review suggestions

Co-authored-by: default avatarSebastian Stammler <seb@oplabs.co>
parent 8f7f94d5
...@@ -110,10 +110,6 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string, ...@@ -110,10 +110,6 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
if err := bs.initRPCServer(cfg); err != nil { if err := bs.initRPCServer(cfg); err != nil {
return fmt.Errorf("failed to start RPC server: %w", err) return fmt.Errorf("failed to start RPC server: %w", err)
} }
// Validate the setup
if err := bs.Check(); err != nil {
return fmt.Errorf("failed post-initialization check: %w", err)
}
bs.Metrics.RecordInfo(bs.Version) bs.Metrics.RecordInfo(bs.Version)
bs.Metrics.RecordUp() bs.Metrics.RecordUp()
...@@ -260,12 +256,6 @@ func (bs *BatcherService) initRPCServer(cfg *CLIConfig) error { ...@@ -260,12 +256,6 @@ func (bs *BatcherService) initRPCServer(cfg *CLIConfig) error {
return nil return nil
} }
// Check ensures that the [BatcherService] is valid
func (bs *BatcherService) Check() error {
return nil
}
// Start runs once upon start of the batcher lifecycle, // Start runs once upon start of the batcher lifecycle,
// and starts batch-submission work if the batcher is configured to start submit data on startup. // and starts batch-submission work if the batcher is configured to start submit data on startup.
func (bs *BatcherService) Start(_ context.Context) error { func (bs *BatcherService) Start(_ context.Context) error {
......
...@@ -93,7 +93,7 @@ func testVerifyL2OutputRootEmptyBlock(t *testing.T, detached bool) { ...@@ -93,7 +93,7 @@ func testVerifyL2OutputRootEmptyBlock(t *testing.T, detached bool) {
l2OutputRoot := agreedL2Output.OutputRoot l2OutputRoot := agreedL2Output.OutputRoot
t.Log("=====Stopping batch submitter=====") t.Log("=====Stopping batch submitter=====")
err = sys.BatchSubmitter.Driver().StopBatchSubmitting(context.Background()) err = sys.BatchSubmitter.Driver().StopBatchSubmitting(ctx)
require.NoError(t, err, "could not stop batch submitter") require.NoError(t, err, "could not stop batch submitter")
// Wait for the sequencer to catch up with the current L1 head so we know all submitted batches are processed // Wait for the sequencer to catch up with the current L1 head so we know all submitted batches are processed
......
...@@ -39,8 +39,10 @@ func (lf *LoopFn) work() { ...@@ -39,8 +39,10 @@ func (lf *LoopFn) work() {
return return
case <-lf.ticker.Ch(): case <-lf.ticker.Ch():
ctx, cancel := context.WithCancel(lf.ctx) ctx, cancel := context.WithCancel(lf.ctx)
lf.fn(ctx) func() {
cancel() defer cancel()
lf.fn(ctx)
}()
} }
} }
} }
......
...@@ -23,5 +23,10 @@ func TestLoopFn(t *testing.T) { ...@@ -23,5 +23,10 @@ func TestLoopFn(t *testing.T) {
<-calls <-calls
cl.AdvanceTime(time.Second * 10) cl.AdvanceTime(time.Second * 10)
<-calls <-calls
select {
case <-calls:
t.Fatal("more calls than expected")
default:
}
require.ErrorIs(t, loopFn.Close(), testErr) require.ErrorIs(t, loopFn.Close(), testErr)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment