Commit e9628932 authored by protolambda's avatar protolambda

op-node: make rollup node RPC testable in op-e2e

parent 9e0151d5
...@@ -16,18 +16,16 @@ import ( ...@@ -16,18 +16,16 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/ethereum-optimism/optimism/op-batcher/sequencer"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/sources" "github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr"
oplog "github.com/ethereum-optimism/optimism/op-service/log" oplog "github.com/ethereum-optimism/optimism/op-service/log"
opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics" opmetrics "github.com/ethereum-optimism/optimism/op-service/metrics"
oppprof "github.com/ethereum-optimism/optimism/op-service/pprof" oppprof "github.com/ethereum-optimism/optimism/op-service/pprof"
oprpc "github.com/ethereum-optimism/optimism/op-service/rpc" oprpc "github.com/ethereum-optimism/optimism/op-service/rpc"
hdwallet "github.com/miguelmota/go-ethereum-hdwallet"
"github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-batcher/sequencer"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
...@@ -36,6 +34,8 @@ import ( ...@@ -36,6 +34,8 @@ import (
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
hdwallet "github.com/miguelmota/go-ethereum-hdwallet"
"github.com/urfave/cli"
) )
const ( const (
...@@ -495,12 +495,12 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*sources.Roll ...@@ -495,12 +495,12 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*sources.Roll
ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout) ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout)
defer cancel() defer cancel()
client, err := rpc.DialContext(ctxt, url) rpcCl, err := rpc.DialContext(ctxt, url)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return sources.NewRollupClient(client), nil return sources.NewRollupClient(client.NewBaseRPCClient(rpcCl)), nil
} }
// parseAddress parses an ETH address from a hex string. This method will fail if // parseAddress parses an ETH address from a hex string. This method will fail if
......
...@@ -4,6 +4,10 @@ import ( ...@@ -4,6 +4,10 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
...@@ -15,9 +19,6 @@ import ( ...@@ -15,9 +19,6 @@ import (
"github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/p2p"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/testutils"
) )
// L1CanonSrc is used to sync L1 from another node. // L1CanonSrc is used to sync L1 from another node.
...@@ -170,6 +171,12 @@ func (s *L1Replica) RPCClient() client.RPC { ...@@ -170,6 +171,12 @@ func (s *L1Replica) RPCClient() client.RPC {
} }
} }
func (s *L1Replica) L1Client(t Testing, cfg *rollup.Config) *sources.L1Client {
l1F, err := sources.NewL1Client(s.RPCClient(), s.log, nil, sources.L1ClientDefaultConfig(cfg, false))
require.NoError(t, err)
return l1F
}
// ActL1FinalizeNext finalizes the next block, which must be marked as safe before doing so (see ActL1SafeNext). // ActL1FinalizeNext finalizes the next block, which must be marked as safe before doing so (see ActL1SafeNext).
func (s *L1Replica) ActL1FinalizeNext(t Testing) { func (s *L1Replica) ActL1FinalizeNext(t Testing) {
safe := s.l1Chain.CurrentSafeBlock() safe := s.l1Chain.CurrentSafeBlock()
......
...@@ -4,6 +4,8 @@ import ( ...@@ -4,6 +4,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/beacon" "github.com/ethereum/go-ethereum/core/beacon"
...@@ -21,6 +23,7 @@ import ( ...@@ -21,6 +23,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/client" "github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/testutils" "github.com/ethereum-optimism/optimism/op-node/testutils"
) )
...@@ -130,6 +133,12 @@ func (e *L2Engine) RPCClient() client.RPC { ...@@ -130,6 +133,12 @@ func (e *L2Engine) RPCClient() client.RPC {
} }
} }
func (e *L2Engine) EngineClient(t Testing, cfg *rollup.Config) *sources.EngineClient {
l2Cl, err := sources.NewEngineClient(e.RPCClient(), e.log, nil, sources.EngineClientDefaultConfig(cfg))
require.NoError(t, err)
return l2Cl
}
// ActL2RPCFail makes the next L2 RPC request fail // ActL2RPCFail makes the next L2 RPC request fail
func (e *L2Engine) ActL2RPCFail(t Testing) { func (e *L2Engine) ActL2RPCFail(t Testing) {
if e.failL2RPC != nil { // already set to fail? if e.failL2RPC != nil { // already set to fail?
......
...@@ -22,7 +22,7 @@ type L2Sequencer struct { ...@@ -22,7 +22,7 @@ type L2Sequencer struct {
failL2GossipUnsafeBlock error // mock error failL2GossipUnsafeBlock error // mock error
} }
func NewL2Sequencer(log log.Logger, l1 derive.L1Fetcher, eng derive.Engine, cfg *rollup.Config, seqConfDepth uint64) *L2Sequencer { func NewL2Sequencer(log log.Logger, l1 derive.L1Fetcher, eng L2API, cfg *rollup.Config, seqConfDepth uint64) *L2Sequencer {
ver := NewL2Verifier(log, l1, eng, cfg) ver := NewL2Verifier(log, l1, eng, cfg)
return &L2Sequencer{ return &L2Sequencer{
L2Verifier: *ver, L2Verifier: *ver,
......
package actions package actions
import ( import (
"context"
"errors" "errors"
"io" "io"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver" "github.com/ethereum-optimism/optimism/op-node/client"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/node"
"github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/testutils" "github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
gnode "github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/require"
) )
// L2Verifier is an actor that functions like a rollup node, // L2Verifier is an actor that functions like a rollup node,
...@@ -32,13 +37,25 @@ type L2Verifier struct { ...@@ -32,13 +37,25 @@ type L2Verifier struct {
l2Building bool l2Building bool
rollupCfg *rollup.Config rollupCfg *rollup.Config
rpc *rpc.Server
failRPC error // mock error
}
type L2API interface {
derive.Engine
InfoByRpcNumber(ctx context.Context, num rpc.BlockNumber) (eth.BlockInfo, error)
// GetProof returns a proof of the account, it may return a nil result without error if the address was not found.
GetProof(ctx context.Context, address common.Address, blockTag string) (*eth.AccountResult, error)
} }
func NewL2Verifier(log log.Logger, l1 derive.L1Fetcher, eng derive.Engine, cfg *rollup.Config) *L2Verifier { func NewL2Verifier(log log.Logger, l1 derive.L1Fetcher, eng L2API, cfg *rollup.Config) *L2Verifier {
metrics := &testutils.TestDerivationMetrics{} metrics := &testutils.TestDerivationMetrics{}
pipeline := derive.NewDerivationPipeline(log, cfg, l1, eng, metrics) pipeline := derive.NewDerivationPipeline(log, cfg, l1, eng, metrics)
pipeline.Reset() pipeline.Reset()
return &L2Verifier{
rollupNode := &L2Verifier{
log: log, log: log,
eng: eng, eng: eng,
derivation: pipeline, derivation: pipeline,
...@@ -47,7 +64,44 @@ func NewL2Verifier(log log.Logger, l1 derive.L1Fetcher, eng derive.Engine, cfg * ...@@ -47,7 +64,44 @@ func NewL2Verifier(log log.Logger, l1 derive.L1Fetcher, eng derive.Engine, cfg *
l2PipelineIdle: true, l2PipelineIdle: true,
l2Building: false, l2Building: false,
rollupCfg: cfg, rollupCfg: cfg,
rpc: rpc.NewServer(),
}
// setup RPC server for rollup node, hooked to the actor as backend
m := &testutils.TestRPCMetrics{}
backend := &l2VerifierBackend{verifier: rollupNode}
apis := []rpc.API{
{
Namespace: "optimism",
Service: node.NewNodeAPI(cfg, eng, backend, log, m),
Public: true,
Authenticated: false,
},
{
Namespace: "admin",
Version: "",
Service: node.NewAdminAPI(backend, m),
Public: true, // TODO: this field is deprecated. Do we even need this anymore?
Authenticated: false,
},
}
if err := gnode.RegisterApis(apis, nil, rollupNode.rpc); err != nil {
panic(err)
} }
return rollupNode
}
type l2VerifierBackend struct {
verifier *L2Verifier
}
func (s *l2VerifierBackend) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) {
return s.verifier.SyncStatus(), nil
}
func (s *l2VerifierBackend) ResetDerivationPipeline(ctx context.Context) error {
s.verifier.derivation.Reset()
return nil
} }
func (s *L2Verifier) SyncStatus() *eth.SyncStatus { func (s *L2Verifier) SyncStatus() *eth.SyncStatus {
...@@ -62,6 +116,31 @@ func (s *L2Verifier) SyncStatus() *eth.SyncStatus { ...@@ -62,6 +116,31 @@ func (s *L2Verifier) SyncStatus() *eth.SyncStatus {
} }
} }
func (s *L2Verifier) RollupClient() *sources.RollupClient {
return sources.NewRollupClient(s.RPCClient())
}
func (s *L2Verifier) RPCClient() client.RPC {
cl := rpc.DialInProc(s.rpc)
return testutils.RPCErrFaker{
RPC: client.NewBaseRPCClient(cl),
ErrFn: func() error {
err := s.failRPC
s.failRPC = nil // reset back, only error once.
return err
},
}
}
// ActRPCFail makes the next L2 RPC request fail
func (s *L2Verifier) ActRPCFail(t Testing) {
if s.failRPC != nil { // already set to fail?
t.InvalidAction("already set a mock rpc error")
return
}
s.failRPC = errors.New("mock RPC error")
}
func (s *L2Verifier) ActL1HeadSignal(t Testing) { func (s *L2Verifier) ActL1HeadSignal(t Testing) {
head, err := s.l1.L1BlockRefByLabel(t.Ctx(), eth.Unsafe) head, err := s.l1.L1BlockRefByLabel(t.Ctx(), eth.Unsafe)
require.NoError(t, err) require.NoError(t, err)
......
...@@ -3,27 +3,26 @@ package actions ...@@ -3,27 +3,26 @@ package actions
import ( import (
"testing" "testing"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/testlog"
) )
func setupVerifierTest(t Testing, sd *e2eutils.SetupData, log log.Logger) (*L1Miner, *L2Engine, *L2Verifier) { func setupVerifier(t Testing, sd *e2eutils.SetupData, log log.Logger, l1F derive.L1Fetcher) (*L2Engine, *L2Verifier) {
jwtPath := e2eutils.WriteDefaultJWT(t) jwtPath := e2eutils.WriteDefaultJWT(t)
miner := NewL1Miner(log, sd.L1Cfg)
l1F, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false))
require.NoError(t, err)
engine := NewL2Engine(log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath) engine := NewL2Engine(log, sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath)
l2Cl, err := sources.NewEngineClient(engine.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) engCl := engine.EngineClient(t, sd.RollupCfg)
require.NoError(t, err) verifier := NewL2Verifier(log, l1F, engCl, sd.RollupCfg)
return engine, verifier
}
verifier := NewL2Verifier(log, l1F, l2Cl, sd.RollupCfg) func setupVerifierOnlyTest(t Testing, sd *e2eutils.SetupData, log log.Logger) (*L1Miner, *L2Engine, *L2Verifier) {
miner := NewL1Miner(log, sd.L1Cfg)
l1Cl := miner.L1Client(t, sd.RollupCfg)
engine, verifier := setupVerifier(t, sd, log, l1Cl)
return miner, engine, verifier return miner, engine, verifier
} }
...@@ -37,7 +36,7 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) { ...@@ -37,7 +36,7 @@ func TestL2Verifier_SequenceWindow(gt *testing.T) {
dp := e2eutils.MakeDeployParams(t, p) dp := e2eutils.MakeDeployParams(t, p)
sd := e2eutils.Setup(t, dp, defaultAlloc) sd := e2eutils.Setup(t, dp, defaultAlloc)
log := testlog.Logger(t, log.LvlDebug) log := testlog.Logger(t, log.LvlDebug)
miner, engine, verifier := setupVerifierTest(t, sd, log) miner, engine, verifier := setupVerifierOnlyTest(t, sd, log)
miner.ActL1SetFeeRecipient(common.Address{'A'}) miner.ActL1SetFeeRecipient(common.Address{'A'})
// Make two sequence windows worth of empty L1 blocks. After we pass the first sequence window, the L2 chain should get blocks // Make two sequence windows worth of empty L1 blocks. After we pass the first sequence window, the L2 chain should get blocks
......
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/bindings" "github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-bindings/predeploys" "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum-optimism/optimism/op-node/sources" "github.com/ethereum-optimism/optimism/op-node/sources"
...@@ -57,7 +58,7 @@ func TestL2OutputSubmitter(t *testing.T) { ...@@ -57,7 +58,7 @@ func TestL2OutputSubmitter(t *testing.T) {
rollupRPCClient, err := rpc.DialContext(context.Background(), sys.RollupNodes["sequencer"].HTTPEndpoint()) rollupRPCClient, err := rpc.DialContext(context.Background(), sys.RollupNodes["sequencer"].HTTPEndpoint())
require.Nil(t, err) require.Nil(t, err)
rollupClient := sources.NewRollupClient(rollupRPCClient) rollupClient := sources.NewRollupClient(client.NewBaseRPCClient(rollupRPCClient))
// OutputOracle is already deployed // OutputOracle is already deployed
l2OutputOracle, err := bindings.NewL2OutputOracleCaller(predeploys.DevL2OutputOracleAddr, l1Client) l2OutputOracle, err := bindings.NewL2OutputOracleCaller(predeploys.DevL2OutputOracleAddr, l1Client)
...@@ -212,7 +213,7 @@ func TestSystemE2E(t *testing.T) { ...@@ -212,7 +213,7 @@ func TestSystemE2E(t *testing.T) {
rollupRPCClient, err := rpc.DialContext(context.Background(), sys.RollupNodes["sequencer"].HTTPEndpoint()) rollupRPCClient, err := rpc.DialContext(context.Background(), sys.RollupNodes["sequencer"].HTTPEndpoint())
require.Nil(t, err) require.Nil(t, err)
rollupClient := sources.NewRollupClient(rollupRPCClient) rollupClient := sources.NewRollupClient(client.NewBaseRPCClient(rollupRPCClient))
// basic check that sync status works // basic check that sync status works
seqStatus, err := rollupClient.SyncStatus(context.Background()) seqStatus, err := rollupClient.SyncStatus(context.Background())
require.Nil(t, err) require.Nil(t, err)
......
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"github.com/ethereum-optimism/optimism/op-bindings/predeploys" "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/version" "github.com/ethereum-optimism/optimism/op-node/version"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
...@@ -26,12 +25,17 @@ type driverClient interface { ...@@ -26,12 +25,17 @@ type driverClient interface {
ResetDerivationPipeline(context.Context) error ResetDerivationPipeline(context.Context) error
} }
type rpcMetrics interface {
// RecordRPCServerRequest returns a function that records the duration of serving the given RPC method
RecordRPCServerRequest(method string) func()
}
type adminAPI struct { type adminAPI struct {
dr driverClient dr driverClient
m *metrics.Metrics m rpcMetrics
} }
func newAdminAPI(dr driverClient, m *metrics.Metrics) *adminAPI { func NewAdminAPI(dr driverClient, m rpcMetrics) *adminAPI {
return &adminAPI{ return &adminAPI{
dr: dr, dr: dr,
m: m, m: m,
...@@ -49,10 +53,10 @@ type nodeAPI struct { ...@@ -49,10 +53,10 @@ type nodeAPI struct {
client l2EthClient client l2EthClient
dr driverClient dr driverClient
log log.Logger log log.Logger
m *metrics.Metrics m rpcMetrics
} }
func newNodeAPI(config *rollup.Config, l2Client l2EthClient, dr driverClient, log log.Logger, m *metrics.Metrics) *nodeAPI { func NewNodeAPI(config *rollup.Config, l2Client l2EthClient, dr driverClient, log log.Logger, m rpcMetrics) *nodeAPI {
return &nodeAPI{ return &nodeAPI{
config: config, config: config,
client: l2Client, client: l2Client,
......
...@@ -171,7 +171,7 @@ func (n *OpNode) initRPCServer(ctx context.Context, cfg *Config) error { ...@@ -171,7 +171,7 @@ func (n *OpNode) initRPCServer(ctx context.Context, cfg *Config) error {
n.server.EnableP2P(p2p.NewP2PAPIBackend(n.p2pNode, n.log, n.metrics)) n.server.EnableP2P(p2p.NewP2PAPIBackend(n.p2pNode, n.log, n.metrics))
} }
if cfg.RPC.EnableAdmin { if cfg.RPC.EnableAdmin {
n.server.EnableAdminAPI(newAdminAPI(n.l2Driver, n.metrics)) n.server.EnableAdminAPI(NewAdminAPI(n.l2Driver, n.metrics))
} }
n.log.Info("Starting JSON-RPC server") n.log.Info("Starting JSON-RPC server")
if err := n.server.Start(); err != nil { if err := n.server.Start(); err != nil {
......
...@@ -29,7 +29,7 @@ type rpcServer struct { ...@@ -29,7 +29,7 @@ type rpcServer struct {
} }
func newRPCServer(ctx context.Context, rpcCfg *RPCConfig, rollupCfg *rollup.Config, l2Client l2EthClient, dr driverClient, log log.Logger, appVersion string, m *metrics.Metrics) (*rpcServer, error) { func newRPCServer(ctx context.Context, rpcCfg *RPCConfig, rollupCfg *rollup.Config, l2Client l2EthClient, dr driverClient, log log.Logger, appVersion string, m *metrics.Metrics) (*rpcServer, error) {
api := newNodeAPI(rollupCfg, l2Client, dr, log.New("rpc", "node"), m) api := NewNodeAPI(rollupCfg, l2Client, dr, log.New("rpc", "node"), m)
// TODO: extend RPC config with options for WS, IPC and HTTP RPC connections // TODO: extend RPC config with options for WS, IPC and HTTP RPC connections
endpoint := net.JoinHostPort(rpcCfg.ListenAddr, strconv.Itoa(rpcCfg.ListenPort)) endpoint := net.JoinHostPort(rpcCfg.ListenAddr, strconv.Itoa(rpcCfg.ListenPort))
r := &rpcServer{ r := &rpcServer{
......
...@@ -4,17 +4,17 @@ import ( ...@@ -4,17 +4,17 @@ import (
"context" "context"
"math/big" "math/big"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
) )
type RollupClient struct { type RollupClient struct {
rpc *rpc.Client rpc client.RPC
} }
func NewRollupClient(rpc *rpc.Client) *RollupClient { func NewRollupClient(rpc client.RPC) *RollupClient {
return &RollupClient{rpc} return &RollupClient{rpc}
} }
......
...@@ -34,3 +34,9 @@ func (t *TestDerivationMetrics) RecordUnsafePayloadsBuffer(length uint64, memSiz ...@@ -34,3 +34,9 @@ func (t *TestDerivationMetrics) RecordUnsafePayloadsBuffer(length uint64, memSiz
t.FnRecordUnsafePayloads(length, memSize, next) t.FnRecordUnsafePayloads(length, memSize, next)
} }
} }
type TestRPCMetrics struct{}
func (n *TestRPCMetrics) RecordRPCServerRequest(method string) func() {
return func() {}
}
...@@ -12,9 +12,7 @@ import ( ...@@ -12,9 +12,7 @@ import (
"syscall" "syscall"
"time" "time"
hdwallet "github.com/miguelmota/go-ethereum-hdwallet" "github.com/ethereum-optimism/optimism/op-node/client"
"github.com/urfave/cli"
"github.com/ethereum-optimism/optimism/op-node/sources" "github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-proposer/drivers/l2output" "github.com/ethereum-optimism/optimism/op-proposer/drivers/l2output"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr" "github.com/ethereum-optimism/optimism/op-proposer/txmgr"
...@@ -28,6 +26,8 @@ import ( ...@@ -28,6 +26,8 @@ import (
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
hdwallet "github.com/miguelmota/go-ethereum-hdwallet"
"github.com/urfave/cli"
) )
const ( const (
...@@ -250,12 +250,12 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*sources.Roll ...@@ -250,12 +250,12 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*sources.Roll
ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout) ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout)
defer cancel() defer cancel()
client, err := rpc.DialContext(ctxt, url) rpcCl, err := rpc.DialContext(ctxt, url)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return sources.NewRollupClient(client), nil return sources.NewRollupClient(client.NewBaseRPCClient(rpcCl)), nil
} }
// parseAddress parses an ETH address from a hex string. This method will fail if // parseAddress parses an ETH address from a hex string. This method will fail if
......
package rollupclient
import (
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum/go-ethereum/rpc"
)
// Deprecated: use sources.RollupClient instead
type RollupClient = sources.RollupClient
// Deprecated: use sources.NewRollupClient instead
func NewRollupClient(rpc *rpc.Client) *sources.RollupClient {
return sources.NewRollupClient(rpc)
}
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