diff --git a/op-batcher/batcher/service.go b/op-batcher/batcher/service.go index 70a3becf2f7e..9da6f969d50f 100644 --- a/op-batcher/batcher/service.go +++ b/op-batcher/batcher/service.go @@ -52,7 +52,7 @@ type BatcherService struct { L1Client client.Client EndpointProvider dial.L2EndpointProvider - TxManager txmgr.TxManager + TxManager txmgr.TxManager PlasmaDA *plasma.DAClient BatcherConfig @@ -143,7 +143,7 @@ func (bs *BatcherService) initRPCClients(ctx context.Context, cfg *CLIConfig) er ethUrls := strings.Split(cfg.L2EthRpc, ",") endpointProvider, err = dial.NewActiveL2EndpointProvider(ctx, ethUrls, rollupUrls, cfg.ActiveSequencerCheckDuration, dial.DefaultDialTimeout, bs.Log) } else { - endpointProvider, err = dial.NewStaticL2EndpointProvider(ctx, bs.Log, cfg.L2EthRpc, cfg.RollupRpc) + endpointProvider, err = dial.NewStaticL2EndpointProvider(ctx, bs.Log, cfg.L2EthRpc, cfg.RollupRpc, bs.Metrics) } if err != nil { return fmt.Errorf("failed to build L2 endpoint provider: %w", err) diff --git a/op-batcher/metrics/metrics.go b/op-batcher/metrics/metrics.go index 8e669f9824c4..e1ae77ad854a 100644 --- a/op-batcher/metrics/metrics.go +++ b/op-batcher/metrics/metrics.go @@ -5,14 +5,15 @@ import ( "github.com/prometheus/client_golang/prometheus" - "github.com/ethereum-optimism/optimism/op-node/rollup/derive" - "github.com/ethereum-optimism/optimism/op-service/eth" - opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics" - txmetrics "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" + "github.com/ethereum-optimism/optimism/op-service/eth" + opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics" + txmetrics "github.com/ethereum-optimism/optimism/op-service/txmgr/metrics" ) const Namespace = "op_batcher" diff --git a/op-e2e/actions/l1_miner.go b/op-e2e/actions/l1_miner.go index adbaee77da90..66c365669387 100644 --- a/op-e2e/actions/l1_miner.go +++ b/op-e2e/actions/l1_miner.go @@ -51,6 +51,13 @@ func NewL1Miner(t Testing, log log.Logger, genesis *core.Genesis) *L1Miner { } } +func NewL1MinerWithPort(t Testing, log log.Logger, genesis *core.Genesis, port int) *L1Miner { + rep := NewL1ReplicaWithPort(t, log, genesis, port) + return &L1Miner{ + L1Replica: *rep, + } +} + func (s *L1Miner) BlobStore() derive.L1BlobsFetcher { return s.blobStore } diff --git a/op-proposer/metrics/metrics.go b/op-proposer/metrics/metrics.go index e7dbeb5a05fd..1b91192f39ba 100644 --- a/op-proposer/metrics/metrics.go +++ b/op-proposer/metrics/metrics.go @@ -29,9 +29,7 @@ type Metricer interface { // Record Tx metrics txmetrics.TxMetricer - 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 RecordL2BlocksProposed(l2ref eth.L2BlockRef) } @@ -86,7 +84,7 @@ func (m *Metrics) Registry() *prometheus.Registry { return m.registry } -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) } diff --git a/op-proposer/metrics/noop.go b/op-proposer/metrics/noop.go index f04a198791cc..06b7daad65b9 100644 --- a/op-proposer/metrics/noop.go +++ b/op-proposer/metrics/noop.go @@ -3,8 +3,8 @@ package metrics import ( "io" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum-optimism/optimism/op-service/eth" @@ -15,7 +15,6 @@ import ( type noopMetrics struct { opmetrics.NoopRefMetrics txmetrics.NoopTxMetrics - opmetrics.NoopRPCMetrics } var NoopMetrics Metricer = new(noopMetrics) @@ -25,7 +24,7 @@ func (*noopMetrics) RecordUp() {} func (*noopMetrics) RecordL2BlocksProposed(l2ref eth.L2BlockRef) {} -func (*noopMetrics) StartBalanceMetrics(log.Logger, *ethclient.Client, common.Address) io.Closer { +func (*noopMetrics) StartBalanceMetrics(log.Logger, ethereum.ChainStateReader, common.Address) io.Closer { return nil } diff --git a/op-proposer/proposer/l2_output_submitter.go b/op-proposer/proposer/l2_output_submitter.go index a98e96e63031..dc560cb11ebc 100644 --- a/op-proposer/proposer/l2_output_submitter.go +++ b/op-proposer/proposer/l2_output_submitter.go @@ -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-proposer/flags" opservice "github.com/ethereum-optimism/optimism/op-service" "github.com/ethereum-optimism/optimism/op-service/cliapp" @@ -16,6 +17,10 @@ import ( // This method returns a cliapp.LifecycleAction, to create an op-service CLI-lifecycle-managed L2Output-submitter func Main(version string) cliapp.LifecycleAction { return func(cliCtx *cli.Context, _ context.CancelCauseFunc) (cliapp.Lifecycle, error) { + if err := opaws.KeyManager(context.Background(), ctx, opaws.OP_PROPOSER_SIGN_KEY); err != nil { + return nil, err + } + if err := flags.CheckRequired(cliCtx); err != nil { return nil, err } diff --git a/op-proposer/proposer/service.go b/op-proposer/proposer/service.go index f50d4975a3af..1045353e464b 100644 --- a/op-proposer/proposer/service.go +++ b/op-proposer/proposer/service.go @@ -22,7 +22,6 @@ import ( "github.com/ethereum-optimism/optimism/op-service/txmgr" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" ) @@ -74,10 +73,6 @@ type ProposerService struct { // The service components are fully started, except for the driver, // which will not be submitting state (if it was configured to) until the Start part of the lifecycle. func ProposerServiceFromCLIConfig(ctx context.Context, version string, cfg *CLIConfig, log log.Logger) (*ProposerService, error) { - if err := opaws.KeyManager(context.Background(), ctx, opaws.OP_PROPOSER_SIGN_KEY); err != nil { - return err - } - var ps ProposerService if err := ps.initFromCLIConfig(ctx, version, cfg, log); err != nil { return nil, errors.Join(err, ps.Stop(ctx)) // try to clean up our failed initialization attempt diff --git a/op-service/dial/static_l2_provider.go b/op-service/dial/static_l2_provider.go index 8d51f062b9af..c6fbb64845df 100644 --- a/op-service/dial/static_l2_provider.go +++ b/op-service/dial/static_l2_provider.go @@ -3,7 +3,8 @@ package dial import ( "context" - "github.com/ethereum/go-ethereum/ethclient" + "github.com/ethereum-optimism/optimism/op-service/client" + "github.com/ethereum-optimism/optimism/op-service/metrics" "github.com/ethereum/go-ethereum/log" ) @@ -20,10 +21,10 @@ type L2EndpointProvider interface { // It is meant for scenarios where a single, unchanging (L2 rollup node, L2 execution node) pair is used type StaticL2EndpointProvider struct { StaticL2RollupProvider - ethClient *ethclient.Client + ethClient client.Client } -func NewStaticL2EndpointProvider(ctx context.Context, log log.Logger, ethClientUrl string, rollupClientUrl string) (*StaticL2EndpointProvider, error) { +func NewStaticL2EndpointProvider(ctx context.Context, log log.Logger, ethClientUrl string, rollupClientUrl string, metrics metrics.RPCMetricer) (*StaticL2EndpointProvider, error) { ethClient, err := DialEthClientWithTimeout(ctx, DefaultDialTimeout, log, ethClientUrl) if err != nil { return nil, err @@ -34,7 +35,7 @@ func NewStaticL2EndpointProvider(ctx context.Context, log log.Logger, ethClientU } return &StaticL2EndpointProvider{ StaticL2RollupProvider: *rollupProvider, - ethClient: ethClient, + ethClient: client.NewInstrumentedClient(ethClient, metrics), }, nil } diff --git a/op-service/sources/receipts_test.go b/op-service/sources/receipts_test.go index 088a3d9b22cb..235e51bb9042 100644 --- a/op-service/sources/receipts_test.go +++ b/op-service/sources/receipts_test.go @@ -164,7 +164,7 @@ func (tc *ReceiptsTestCase) Run(t *testing.T) { testCfg.MethodResetDuration = 0 } logger := testlog.Logger(t, log.LevelError) - ethCl, err := NewEthClient(client.NewBaseRPCClient(cl), logger, nil, testCfg) + ethCl, err := NewEthClient(client.NewBaseRPCClient(cl), logger, nil, testCfg, true) require.NoError(t, err) defer ethCl.Close() diff --git a/op-service/txmgr/txmgr.go b/op-service/txmgr/txmgr.go index 0763b33b52de..b60ba4e21fed 100644 --- a/op-service/txmgr/txmgr.go +++ b/op-service/txmgr/txmgr.go @@ -263,7 +263,7 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (* // If the gas limit is set, we can use that as the gas if gasLimit == 0 { // Calculate the intrinsic gas for the transaction - gas, err := m.backend.EstimateGas(ctx, bsc.ToLegacyCallMsg(ethereum.CallMsg{ + gas, err := m.backend.EstimateGas(ctx, ethereum.CallMsg{ From: m.cfg.From, To: candidate.To, GasTipCap: gasTipCap,