-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into inphi/chan-in-metrics
- Loading branch information
Showing
40 changed files
with
253 additions
and
88 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@eth-optimism/batch-submitter-service", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"private": true, | ||
"devDependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package driver | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"io" | ||
|
||
"github.com/ethereum-optimism/optimism/op-node/eth" | ||
"github.com/ethereum-optimism/optimism/op-node/metrics" | ||
"github.com/ethereum-optimism/optimism/op-node/rollup/derive" | ||
"github.com/ethereum-optimism/optimism/op-program/config" | ||
"github.com/ethereum/go-ethereum/log" | ||
) | ||
|
||
type Derivation interface { | ||
Step(ctx context.Context) error | ||
SafeL2Head() eth.L2BlockRef | ||
} | ||
|
||
type Driver struct { | ||
logger log.Logger | ||
pipeline Derivation | ||
} | ||
|
||
func NewDriver(logger log.Logger, cfg *config.Config, l1Source derive.L1Fetcher, l2Source derive.Engine) *Driver { | ||
pipeline := derive.NewDerivationPipeline(logger, cfg.Rollup, l1Source, l2Source, metrics.NoopMetrics) | ||
pipeline.Reset() | ||
return &Driver{ | ||
logger: logger, | ||
pipeline: pipeline, | ||
} | ||
} | ||
|
||
// Step runs the next step of the derivation pipeline. | ||
// Returns nil if there are further steps to be performed | ||
// Returns io.EOF if the derivation completed successfully | ||
// Returns a non-EOF error if the derivation failed | ||
func (d *Driver) Step(ctx context.Context) error { | ||
if err := d.pipeline.Step(ctx); errors.Is(err, io.EOF) { | ||
return io.EOF | ||
} else if errors.Is(err, derive.NotEnoughData) { | ||
d.logger.Debug("Data is lacking") | ||
return nil | ||
} else if err != nil { | ||
return fmt.Errorf("pipeline err: %w", err) | ||
} | ||
return nil | ||
} | ||
|
||
func (d *Driver) SafeHead() eth.L2BlockRef { | ||
return d.pipeline.SafeL2Head() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package driver | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
"io" | ||
"testing" | ||
|
||
"github.com/ethereum-optimism/optimism/op-node/eth" | ||
"github.com/ethereum-optimism/optimism/op-node/rollup/derive" | ||
"github.com/ethereum-optimism/optimism/op-node/testlog" | ||
"github.com/ethereum/go-ethereum/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDerivationComplete(t *testing.T) { | ||
driver := createDriver(t, fmt.Errorf("derivation complete: %w", io.EOF)) | ||
err := driver.Step(context.Background()) | ||
require.ErrorIs(t, err, io.EOF) | ||
} | ||
|
||
func TestTemporaryError(t *testing.T) { | ||
driver := createDriver(t, fmt.Errorf("whoopsie: %w", derive.ErrTemporary)) | ||
err := driver.Step(context.Background()) | ||
require.ErrorIs(t, err, derive.ErrTemporary) | ||
} | ||
|
||
func TestNotEnoughDataError(t *testing.T) { | ||
driver := createDriver(t, fmt.Errorf("idk: %w", derive.NotEnoughData)) | ||
err := driver.Step(context.Background()) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestGenericError(t *testing.T) { | ||
expected := errors.New("boom") | ||
driver := createDriver(t, expected) | ||
err := driver.Step(context.Background()) | ||
require.ErrorIs(t, err, expected) | ||
} | ||
|
||
func TestNoError(t *testing.T) { | ||
driver := createDriver(t, nil) | ||
err := driver.Step(context.Background()) | ||
require.NoError(t, err) | ||
} | ||
|
||
func createDriver(t *testing.T, derivationResult error) *Driver { | ||
derivation := &stubDerivation{nextErr: derivationResult} | ||
return &Driver{ | ||
logger: testlog.Logger(t, log.LvlDebug), | ||
pipeline: derivation, | ||
} | ||
} | ||
|
||
type stubDerivation struct { | ||
nextErr error | ||
} | ||
|
||
func (s stubDerivation) Step(ctx context.Context) error { | ||
return s.nextErr | ||
} | ||
|
||
func (s stubDerivation) SafeL2Head() eth.L2BlockRef { | ||
return eth.L2BlockRef{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.