Skip to content

Commit

Permalink
fix: merge upstream v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoieh committed Dec 8, 2023
1 parent 2af9192 commit 2bcb794
Show file tree
Hide file tree
Showing 46 changed files with 515 additions and 164 deletions.
16 changes: 15 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ go 1.21

require (
github.com/BurntSushi/toml v1.3.2
github.com/aws/aws-sdk-go-v2 v1.24.0
github.com/aws/aws-sdk-go-v2/config v1.18.45
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.25.4
github.com/btcsuite/btcd v0.23.3
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0
Expand Down Expand Up @@ -53,6 +56,16 @@ require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/allegro/bigcache v1.2.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.43 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.15.2 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 // indirect
github.com/aws/smithy-go v1.19.0 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.7.0 // indirect
Expand Down Expand Up @@ -111,6 +124,7 @@ require (
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/huin/goupnp v1.3.0 // indirect
github.com/influxdata/influxdb-client-go/v2 v2.4.0 // indirect
github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c // indirect
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
Expand Down Expand Up @@ -164,7 +178,6 @@ require (
github.com/onsi/ginkgo/v2 v2.13.0 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/panjf2000/ants/v2 v2.7.3 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down Expand Up @@ -209,6 +222,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect
)

// TODO replace to bnb-chain/op-geth
replace github.com/ethereum/go-ethereum v1.13.1 => github.com/ethereum-optimism/op-geth v1.101304.0-rc.2.0.20231030225546-cd491fa3b588

//replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain
Expand Down
103 changes: 35 additions & 68 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion op-aws-sdk/key_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli"
"github.com/urfave/cli/v2"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions op-batcher/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.19.9-alpine3.16 as builder
FROM --platform=$BUILDPLATFORM golang:1.21.5-alpine3.18 as builder

ARG VERSION=v0.0.0

Expand All @@ -24,7 +24,7 @@ ARG TARGETOS TARGETARCH

RUN make op-batcher VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH

FROM alpine:3.16
FROM alpine:3.18

COPY --from=builder /app/op-batcher/bin/op-batcher /usr/local/bin

Expand Down
4 changes: 4 additions & 0 deletions op-batcher/batcher/batch_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/urfave/cli/v2"

opaws "github.com/ethereum-optimism/optimism/op-aws-sdk"
"github.com/ethereum-optimism/optimism/op-batcher/flags"
opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
Expand All @@ -16,6 +17,9 @@ import (
// This method returns a cliapp.LifecycleAction, to create an op-service CLI-lifecycle-managed batch-submitter with.
func Main(version string) cliapp.LifecycleAction {
return func(cliCtx *cli.Context, closeApp context.CancelCauseFunc) (cliapp.Lifecycle, error) {
if err := opaws.KeyManager(context.Background(), cliCtx, opaws.OP_BATCHER_SIGN_KEY); err != nil {
return nil, err
}
if err := flags.CheckRequired(cliCtx); err != nil {
return nil, err
}
Expand Down
9 changes: 0 additions & 9 deletions op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
Expand Down Expand Up @@ -325,9 +321,7 @@ func (l *BatchSubmitter) publishTxToL1(ctx context.Context, queue *txmgr.Queue[t
l.recordL1Tip(l1tip)

// Collect next transaction data
l.publishReceiveMu.Lock()
txdata, err := l.state.TxData(l1tip.ID())
l.publishReceiveMu.Unlock()
if err == io.EOF {
l.Log.Trace("no transaction data available")
return err
Expand Down Expand Up @@ -361,9 +355,6 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txDat
}

func (l *BatchSubmitter) handleReceipt(r txmgr.TxReceipt[txData]) {
l.publishReceiveMu.Lock()
defer l.publishReceiveMu.Unlock()

// Record TX Status
if r.Err != nil {
l.Log.Warn("unable to publish tx", "err", r.Err, "data_size", r.ID.Len())
Expand Down
5 changes: 3 additions & 2 deletions op-batcher/batcher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/ethereum-optimism/optimism/op-batcher/rpc"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
"github.com/ethereum-optimism/optimism/op-service/client"
"github.com/ethereum-optimism/optimism/op-service/dial"
"github.com/ethereum-optimism/optimism/op-service/httputil"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
Expand All @@ -38,7 +39,7 @@ type BatcherConfig struct {
type BatcherService struct {
Log log.Logger
Metrics metrics.Metricer
L1Client *ethclient.Client
L1Client client.IFallbackClient
L2Client *ethclient.Client
RollupNode *sources.RollupClient
TxManager txmgr.TxManager
Expand Down Expand Up @@ -117,7 +118,7 @@ func (bs *BatcherService) initFromCLIConfig(ctx context.Context, version string,
}

func (bs *BatcherService) initRPCClients(ctx context.Context, cfg *CLIConfig) error {
l1Client, err := dial.DialEthClientWithTimeout(ctx, dial.DefaultDialTimeout, bs.Log, cfg.L1EthRpc)
l1Client, err := dial.DialEthClientWithTimeoutAndFallback(ctx, cfg.L1EthRpc, dial.DefaultDialTimeout, bs.Log, dial.BatcherFallbackThreshold, bs.Metrics)
if err != nil {
return fmt.Errorf("failed to dial L1 RPC: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion op-batcher/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
oplog "github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics/doc"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion op-batcher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
// Required flags
L1EthRpcFlag = &cli.StringFlag{
Name: "l1-eth-rpc",
Usage: "HTTP provider URL for L1",
Usage: "HTTP provider URL for L1. Multiple alternative addresses are supported, separated by commas, and the first address is used by default",
EnvVars: prefixEnvVars("L1_ETH_RPC"),
}
L2EthRpcFlag = &cli.StringFlag{
Expand Down
5 changes: 3 additions & 2 deletions op-batcher/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/prometheus/client_golang/prometheus"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
Expand All @@ -29,7 +30,7 @@ type Metricer interface {

opmetrics.RPCMetricer

StartBalanceMetrics(l log.Logger, client *ethclient.Client, account common.Address) io.Closer
StartBalanceMetrics(l log.Logger, client ethereum.ChainStateReader, account common.Address) io.Closer

RecordLatestL1Block(l1ref eth.L1BlockRef)
RecordL2BlocksLoaded(l2ref eth.L2BlockRef)
Expand Down Expand Up @@ -193,7 +194,7 @@ func (m *Metrics) Document() []opmetrics.DocumentedMetric {
return m.factory.Document()
}

func (m *Metrics) StartBalanceMetrics(l log.Logger, client *ethclient.Client, account common.Address) io.Closer {
func (m *Metrics) StartBalanceMetrics(l log.Logger, client ethereum.ChainStateReader, account common.Address) io.Closer {
return opmetrics.LaunchBalanceMetrics(l, m.registry, m.ns, client, account)
}

Expand Down
6 changes: 4 additions & 2 deletions op-batcher/metrics/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package metrics
import (
"io"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"

"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
Expand Down Expand Up @@ -42,6 +42,8 @@ func (*noopMetrics) RecordChannelTimedOut(derive.ChannelID) {}
func (*noopMetrics) RecordBatchTxSubmitted() {}
func (*noopMetrics) RecordBatchTxSuccess() {}
func (*noopMetrics) RecordBatchTxFailed() {}
func (*noopMetrics) StartBalanceMetrics(log.Logger, *ethclient.Client, common.Address) io.Closer {
func (*noopMetrics) StartBalanceMetrics(log.Logger, ethereum.ChainStateReader, common.Address) io.Closer {
return nil
}
func (m *noopMetrics) RecordL1UrlSwitchEvt(url string) {
}
18 changes: 9 additions & 9 deletions op-e2e/actions/fallback_client_test.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package actions

import (
"math/big"
"testing"
"time"

"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/testlog"
service_client "github.com/ethereum-optimism/optimism/op-service/client"
"github.com/ethereum-optimism/optimism/op-service/client"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/sources"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/stretchr/testify/require"
"math/big"
"testing"
"time"
)

func setupFallbackClientTest(t Testing, sd *e2eutils.SetupData, log log.Logger, l1Url string) (*L1Miner, *L1Replica, *L1Replica, *L2Engine, *L2Sequencer, *sources.FallbackClient) {
Expand All @@ -23,7 +23,7 @@ func setupFallbackClientTest(t Testing, sd *e2eutils.SetupData, log log.Logger,
miner := NewL1MinerWithPort(t, log, sd.L1Cfg, 8545)
l1_2 := NewL1ReplicaWithPort(t, log, sd.L1Cfg, 8546)
l1_3 := NewL1ReplicaWithPort(t, log, sd.L1Cfg, 8547)
isMultiUrl, urlList := service_client.MultiUrlParse(l1Url)
isMultiUrl, urlList := client.MultiUrlParse(l1Url)
require.True(t, isMultiUrl)
opts := []client.RPCOption{
client.WithHttpPollInterval(0),
Expand Down
28 changes: 24 additions & 4 deletions op-node/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
ARG OP_STACK_GO_BUILDER=us-docker.pkg.dev/oplabs-tools-artifacts/images/op-stack-go:latest
FROM $OP_STACK_GO_BUILDER as builder
# See "make golang-docker" and /ops/docker/op-stack-go
FROM --platform=$BUILDPLATFORM golang:1.21.5-alpine3.18 as builder

ARG VERSION=v0.0.0

RUN apk add --no-cache make gcc musl-dev linux-headers git jq bash

# build op-node with the shared go.mod & go.sum files
COPY ./op-node /app/op-node
COPY ./op-chain-ops /app/op-chain-ops
COPY ./op-service /app/op-service
COPY ./op-bindings /app/op-bindings
COPY ./op-aws-sdk /app/op-aws-sdk
COPY ./go.mod /app/go.mod
COPY ./go.sum /app/go.sum
COPY ./.git /app/.git

WORKDIR /app/op-node

RUN go mod download

ARG TARGETOS TARGETARCH

RUN make op-node VERSION="$VERSION" GOOS=$TARGETOS GOARCH=$TARGETARCH

FROM alpine:3.18

COPY --from=builder /usr/local/bin/op-node /usr/local/bin/op-node
COPY --from=builder /app/op-node/bin/op-node /usr/local/bin

CMD ["op-node"]
Loading

0 comments on commit 2bcb794

Please sign in to comment.