Skip to content

Commit

Permalink
Merge pull request #4542 from ethereum-optimism/jg/cleanup_file_struc…
Browse files Browse the repository at this point in the history
…ture

op-batcher/op-proposer: New package structure
  • Loading branch information
mergify[bot] committed Dec 20, 2022
2 parents 943e155 + 836c84e commit 69200bd
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_batcher
package batcher

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_batcher
package batcher

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/config.go → op-batcher/batcher/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_batcher
package batcher

import (
"time"
Expand Down
7 changes: 3 additions & 4 deletions op-batcher/driver.go → op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_batcher
package batcher

import (
"context"
Expand All @@ -12,7 +12,6 @@ import (
"time"

hdwallet "github.com/ethereum-optimism/go-ethereum-hdwallet"
"github.com/ethereum-optimism/optimism/op-batcher/sequencer"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr"
"github.com/ethereum/go-ethereum/accounts"
Expand All @@ -27,7 +26,7 @@ import (
type BatchSubmitter struct {
txMgr *TransactionManager
addr common.Address
cfg sequencer.Config
cfg DriverConfig
wg sync.WaitGroup
done chan struct{}
log log.Logger
Expand Down Expand Up @@ -141,7 +140,7 @@ func NewBatchSubmitterWithSigner(cfg Config, addr common.Address, signer SignerF
SafeAbortNonceTooLowCount: cfg.SafeAbortNonceTooLowCount,
}

batcherCfg := sequencer.Config{
batcherCfg := DriverConfig{
Log: l,
Name: "Batch Submitter",
L1Client: l1Client,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package sequencer
package batcher

import (
"math/big"
Expand All @@ -11,7 +11,7 @@ import (
"github.com/ethereum/go-ethereum/log"
)

type Config struct {
type DriverConfig struct {
Log log.Logger
Name string

Expand Down
2 changes: 1 addition & 1 deletion op-batcher/txmgr.go → op-batcher/batcher/txmgr.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_batcher
package batcher

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/utils.go → op-batcher/batcher/utils.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_batcher
package batcher

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/urfave/cli"

batcher "github.com/ethereum-optimism/optimism/op-batcher"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum/go-ethereum/log"
Expand Down
6 changes: 3 additions & 3 deletions op-e2e/actions/l2_proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-proposer/drivers/l2output"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
)

Expand All @@ -24,15 +24,15 @@ type ProposerCfg struct {
type L2Proposer struct {
log log.Logger
l1 *ethclient.Client
driver *l2output.Driver
driver *proposer.Driver
address common.Address
lastTx common.Hash
}

func NewL2Proposer(t Testing, log log.Logger, cfg *ProposerCfg, l1 *ethclient.Client, rollupCl *sources.RollupClient) *L2Proposer {
chainID, err := l1.ChainID(t.Ctx())
require.NoError(t, err)
dr, err := l2output.NewDriver(l2output.Config{
dr, err := proposer.NewDriver(proposer.DriverConfig{
Log: log,
Name: "proposer",
L1Client: l1,
Expand Down
4 changes: 4 additions & 0 deletions op-e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module github.com/ethereum-optimism/optimism/op-e2e

go 1.18

replace github.com/ethereum-optimism/optimism/op-batcher v0.10.4 => ./../op-batcher

replace github.com/ethereum-optimism/optimism/op-proposer v0.10.4 => ./../op-proposer

require (
github.com/docker/docker v20.10.21+incompatible
github.com/docker/go-connections v0.4.0
Expand Down
4 changes: 0 additions & 4 deletions op-e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,12 @@ github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468 h1:7KgjBYDji5AKi42eRYI+n8Gs+ZJVilSASL3WBu82c3M=
github.com/ethereum-optimism/op-geth v0.0.0-20221216190603-60b51d600468/go.mod h1:p0Yox74PhYlq1HvijrCBCD9A3cI7rXco7hT6KrQr+rY=
github.com/ethereum-optimism/optimism/op-batcher v0.10.4 h1:qLCdvVMgVja2AGbkKKG7xNW8nm+3C5rz4xagQ3Cg0sw=
github.com/ethereum-optimism/optimism/op-batcher v0.10.4/go.mod h1:a19oViWrL7dy1pPSIa2Dgsv8o97HOzVtKx+m2J5qQqY=
github.com/ethereum-optimism/optimism/op-bindings v0.10.4 h1:CFn4+t0FUrBG5DmkKyYrLbGmzHWLdLv8QdUnlklvozc=
github.com/ethereum-optimism/optimism/op-bindings v0.10.4/go.mod h1:philKV8erP02ggjk2mRIdvJd2ZjMzpmqu0+zwwzKmNw=
github.com/ethereum-optimism/optimism/op-chain-ops v0.10.4 h1:10/BrNfcobBNuaIQQAUcDblzLCtNeGMhGvqHdzhENKk=
github.com/ethereum-optimism/optimism/op-chain-ops v0.10.4/go.mod h1:AIajN/ydQj57npQeqP0hcax3lhjix5brpEgw0KpvI/A=
github.com/ethereum-optimism/optimism/op-node v0.10.4 h1:ZXqfrFKgb6W4ZLbkfO9NlgaQ1djBCCPzNGbd6TgehVI=
github.com/ethereum-optimism/optimism/op-node v0.10.4/go.mod h1:avOLjMLxzB5QB7HmiLlpNkyS93QVHdr0AttRdfYGX3Y=
github.com/ethereum-optimism/optimism/op-proposer v0.10.4 h1:X81vdig8CeiDrhPjQjCOc/eDBlOLcakppy+F4Sngk0E=
github.com/ethereum-optimism/optimism/op-proposer v0.10.4/go.mod h1:2WlzvnX23uOfgMsTF2UKKLb0PT9AqQOIm6OgtWTn1TQ=
github.com/ethereum-optimism/optimism/op-service v0.10.4 h1:WKqNyOBkdJ0ZdlGiDPROZMaWfYxpsYjA5Anb0Bkl5m4=
github.com/ethereum-optimism/optimism/op-service v0.10.4/go.mod h1:7INvNCJGwVgNT4gz9Yupx7PAEJeu+F/JtHKv1fOr+9Q=
github.com/fjl/memsize v0.0.1 h1:+zhkb+dhUgx0/e+M8sF0QqiouvMQUiKR+QYvdxIOKcQ=
Expand Down
4 changes: 2 additions & 2 deletions op-e2e/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"testing"
"time"

bss "github.com/ethereum-optimism/optimism/op-batcher"
l2os "github.com/ethereum-optimism/optimism/op-proposer"
bss "github.com/ethereum-optimism/optimism/op-batcher/batcher"
l2os "github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog "github.com/ethereum-optimism/optimism/op-service/log"

"github.com/docker/docker/api/types"
Expand Down
4 changes: 2 additions & 2 deletions op-e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"

bss "github.com/ethereum-optimism/optimism/op-batcher"
bss "github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
Expand All @@ -33,7 +33,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/testlog"
l2os "github.com/ethereum-optimism/optimism/op-proposer"
l2os "github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
)

Expand Down
5 changes: 2 additions & 3 deletions op-proposer/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/urfave/cli"

proposer "github.com/ethereum-optimism/optimism/op-proposer"
"github.com/ethereum-optimism/optimism/op-proposer/flags"
"github.com/ethereum-optimism/optimism/op-proposer/proposer"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum/go-ethereum/log"
)
Expand All @@ -26,8 +26,7 @@ func main() {
app.Version = fmt.Sprintf("%s-%s-%s", Version, GitCommit, GitDate)
app.Name = "op-proposer"
app.Usage = "L2Output Submitter"
app.Description = "Service for generating and submitting L2 Output " +
"checkpoints to the L2OutputOracle contract"
app.Description = "Service for generating and submitting L2 Output checkpoints to the L2OutputOracle contract"

app.Action = proposer.Main(Version)
err := app.Run(os.Args)
Expand Down
2 changes: 1 addition & 1 deletion op-proposer/config.go → op-proposer/proposer/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_proposer
package proposer

import (
"time"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package l2output
package proposer

import (
"context"
Expand All @@ -22,7 +22,7 @@ import (
var bigOne = big.NewInt(1)
var supportedL2OutputVersion = eth.Bytes32{}

type Config struct {
type DriverConfig struct {
Log log.Logger
Name string

Expand All @@ -48,14 +48,14 @@ type Config struct {
}

type Driver struct {
cfg Config
cfg DriverConfig
l2ooContract *bindings.L2OutputOracle
rawL2ooContract *bind.BoundContract
walletAddr common.Address
l log.Logger
}

func NewDriver(cfg Config) (*Driver, error) {
func NewDriver(cfg DriverConfig) (*Driver, error) {
l2ooContract, err := bindings.NewL2OutputOracle(cfg.L2OOAddr, cfg.L1Client)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package drivers
package proposer

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_proposer
package proposer

import (
"context"
Expand All @@ -25,7 +25,6 @@ import (

"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-proposer/drivers/l2output"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
oplog "github.com/ethereum-optimism/optimism/op-service/log"
Expand Down Expand Up @@ -210,7 +209,7 @@ func NewL2OutputSubmitterWithSigner(
SafeAbortNonceTooLowCount: cfg.SafeAbortNonceTooLowCount,
}

l2OutputDriver, err := l2output.NewDriver(l2output.Config{
l2OutputDriver, err := NewDriver(DriverConfig{
Log: l,
Name: "L2Output Submitter",
L1Client: l1Client,
Expand Down
8 changes: 4 additions & 4 deletions op-proposer/service.go → op-proposer/proposer/service.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package op_proposer
package proposer

import (
"context"
Expand All @@ -13,9 +13,9 @@ import (
"github.com/ethereum/go-ethereum/log"
)

// Driver is an interface for creating and submitting transactions for a
// DriverInterface is an interface for creating and submitting transactions for a
// specific contract.
type Driver interface {
type DriverInterface interface {
// Name is an identifier used to prefix logs for a particular service.
Name() string

Expand Down Expand Up @@ -53,7 +53,7 @@ type Driver interface {
type ServiceConfig struct {
Log log.Logger
Context context.Context
Driver Driver
Driver DriverInterface
PollInterval time.Duration
L1Client *ethclient.Client
TxManagerConfig txmgr.Config
Expand Down

0 comments on commit 69200bd

Please sign in to comment.