Commit 62b2ef93 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #3367 from ethereum-optimism/rollup-client-move

op-node,op-proposer: move rollup client bindings
parents 69487027 d61365aa
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/ethereum-optimism/optimism/op-node/sources"
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"
...@@ -25,7 +26,6 @@ import ( ...@@ -25,7 +26,6 @@ import (
"github.com/ethereum-optimism/optimism/op-batcher/sequencer" "github.com/ethereum-optimism/optimism/op-batcher/sequencer"
"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-proposer/rollupclient"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr" "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"
...@@ -491,7 +491,7 @@ func dialEthClientWithTimeout(ctx context.Context, url string) ( ...@@ -491,7 +491,7 @@ func dialEthClientWithTimeout(ctx context.Context, url string) (
// dialRollupClientWithTimeout attempts to dial the RPC provider using the provided // dialRollupClientWithTimeout attempts to dial the RPC provider using the provided
// URL. If the dial doesn't complete within defaultDialTimeout seconds, this // URL. If the dial doesn't complete within defaultDialTimeout seconds, this
// method will return an error. // method will return an error.
func dialRollupClientWithTimeout(ctx context.Context, url string) (*rollupclient.RollupClient, error) { func dialRollupClientWithTimeout(ctx context.Context, url string) (*sources.RollupClient, error) {
ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout) ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout)
defer cancel() defer cancel()
...@@ -500,7 +500,7 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*rollupclient ...@@ -500,7 +500,7 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*rollupclient
return nil, err return nil, err
} }
return rollupclient.NewRollupClient(client), nil return sources.NewRollupClient(client), 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
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"math/big" "math/big"
"time" "time"
"github.com/ethereum-optimism/optimism/op-proposer/rollupclient" "github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
...@@ -22,7 +22,7 @@ type Config struct { ...@@ -22,7 +22,7 @@ type Config struct {
// API to hit for batch data // API to hit for batch data
L2Client *ethclient.Client L2Client *ethclient.Client
RollupNode *rollupclient.RollupClient RollupNode *sources.RollupClient
// Limit the size of txs // Limit the size of txs
MinL1TxSize uint64 MinL1TxSize uint64
......
...@@ -18,9 +18,9 @@ import ( ...@@ -18,9 +18,9 @@ import (
"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/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-node/testlog" "github.com/ethereum-optimism/optimism/op-node/testlog"
"github.com/ethereum-optimism/optimism/op-node/withdrawals" "github.com/ethereum-optimism/optimism/op-node/withdrawals"
"github.com/ethereum-optimism/optimism/op-proposer/rollupclient"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
...@@ -168,7 +168,7 @@ func TestL2OutputSubmitter(t *testing.T) { ...@@ -168,7 +168,7 @@ func TestL2OutputSubmitter(t *testing.T) {
rollupRPCClient, err := rpc.DialContext(context.Background(), cfg.Nodes["sequencer"].RPC.HttpEndpoint()) rollupRPCClient, err := rpc.DialContext(context.Background(), cfg.Nodes["sequencer"].RPC.HttpEndpoint())
require.Nil(t, err) require.Nil(t, err)
rollupClient := rollupclient.NewRollupClient(rollupRPCClient) rollupClient := sources.NewRollupClient(rollupRPCClient)
// OutputOracle is already deployed // OutputOracle is already deployed
l2OutputOracle, err := bindings.NewL2OutputOracleCaller(sys.L2OOContractAddr, l1Client) l2OutputOracle, err := bindings.NewL2OutputOracleCaller(sys.L2OOContractAddr, l1Client)
...@@ -330,7 +330,7 @@ func TestSystemE2E(t *testing.T) { ...@@ -330,7 +330,7 @@ func TestSystemE2E(t *testing.T) {
rollupRPCClient, err := rpc.DialContext(context.Background(), cfg.Nodes["sequencer"].RPC.HttpEndpoint()) rollupRPCClient, err := rpc.DialContext(context.Background(), cfg.Nodes["sequencer"].RPC.HttpEndpoint())
require.Nil(t, err) require.Nil(t, err)
rollupClient := rollupclient.NewRollupClient(rollupRPCClient) rollupClient := sources.NewRollupClient(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)
......
package eth
// SyncStatus is a snapshot of the driver.
// Values may be zeroed if not yet initialized.
type SyncStatus struct {
// CurrentL1 is the block that the derivation process is currently at,
// this may not be fully derived into L2 data yet.
// If the node is synced, this matches the HeadL1, minus the verifier confirmation distance.
CurrentL1 L1BlockRef `json:"current_l1"`
// HeadL1 is the perceived head of the L1 chain, no confirmation distance.
// The head is not guaranteed to build on the other L1 sync status fields,
// as the node may be in progress of resetting to adapt to a L1 reorg.
HeadL1 L1BlockRef `json:"head_l1"`
SafeL1 L1BlockRef `json:"safe_l1"`
FinalizedL1 L1BlockRef `json:"finalized_l1"`
// UnsafeL2 is the absolute tip of the L2 chain,
// pointing to block data that has not been submitted to L1 yet.
// The sequencer is building this, and verifiers may also be ahead of the
// SafeL2 block if they sync blocks via p2p or other offchain sources.
UnsafeL2 L2BlockRef `json:"unsafe_l2"`
// SafeL2 points to the L2 block that was derived from the L1 chain.
// This point may still reorg if the L1 chain reorgs.
SafeL2 L2BlockRef `json:"safe_l2"`
// FinalizedL2 points to the L2 block that was derived fully from
// finalized L1 information, thus irreversible.
FinalizedL2 L2BlockRef `json:"finalized_l2"`
}
...@@ -8,7 +8,6 @@ import ( ...@@ -8,7 +8,6 @@ import (
"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/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"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"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -23,7 +22,7 @@ type l2EthClient interface { ...@@ -23,7 +22,7 @@ type l2EthClient interface {
} }
type driverClient interface { type driverClient interface {
SyncStatus(ctx context.Context) (*driver.SyncStatus, error) SyncStatus(ctx context.Context) (*eth.SyncStatus, error)
ResetDerivationPipeline(context.Context) error ResetDerivationPipeline(context.Context) error
} }
...@@ -97,7 +96,7 @@ func (n *nodeAPI) OutputAtBlock(ctx context.Context, number rpc.BlockNumber) ([] ...@@ -97,7 +96,7 @@ func (n *nodeAPI) OutputAtBlock(ctx context.Context, number rpc.BlockNumber) ([]
return []eth.Bytes32{l2OutputRootVersion, l2OutputRoot}, nil return []eth.Bytes32{l2OutputRootVersion, l2OutputRoot}, nil
} }
func (n *nodeAPI) SyncStatus(ctx context.Context) (*driver.SyncStatus, error) { func (n *nodeAPI) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) {
recordDur := n.m.RecordRPCServerRequest("optimism_syncStatus") recordDur := n.m.RecordRPCServerRequest("optimism_syncStatus")
defer recordDur() defer recordDur()
return n.dr.SyncStatus(ctx) return n.dr.SyncStatus(ctx)
......
...@@ -7,7 +7,6 @@ import ( ...@@ -7,7 +7,6 @@ import (
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum-optimism/optimism/op-node/testutils" "github.com/ethereum-optimism/optimism/op-node/testutils"
"github.com/ethereum-optimism/optimism/op-node/metrics" "github.com/ethereum-optimism/optimism/op-node/metrics"
...@@ -149,7 +148,7 @@ func TestSyncStatus(t *testing.T) { ...@@ -149,7 +148,7 @@ func TestSyncStatus(t *testing.T) {
l2Client := &testutils.MockL2Client{} l2Client := &testutils.MockL2Client{}
drClient := &mockDriverClient{} drClient := &mockDriverClient{}
rng := rand.New(rand.NewSource(1234)) rng := rand.New(rand.NewSource(1234))
status := driver.SyncStatus{ status := eth.SyncStatus{
CurrentL1: testutils.RandomBlockRef(rng), CurrentL1: testutils.RandomBlockRef(rng),
HeadL1: testutils.RandomBlockRef(rng), HeadL1: testutils.RandomBlockRef(rng),
UnsafeL2: testutils.RandomL2BlockRef(rng), UnsafeL2: testutils.RandomL2BlockRef(rng),
...@@ -173,7 +172,7 @@ func TestSyncStatus(t *testing.T) { ...@@ -173,7 +172,7 @@ func TestSyncStatus(t *testing.T) {
client, err := dialRPCClientWithBackoff(context.Background(), log, "http://"+server.Addr().String()) client, err := dialRPCClientWithBackoff(context.Background(), log, "http://"+server.Addr().String())
assert.NoError(t, err) assert.NoError(t, err)
var out *driver.SyncStatus var out *eth.SyncStatus
err = client.CallContext(context.Background(), &out, "optimism_syncStatus") err = client.CallContext(context.Background(), &out, "optimism_syncStatus")
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, &status, out) assert.Equal(t, &status, out)
...@@ -183,8 +182,8 @@ type mockDriverClient struct { ...@@ -183,8 +182,8 @@ type mockDriverClient struct {
mock.Mock mock.Mock
} }
func (c *mockDriverClient) SyncStatus(ctx context.Context) (*driver.SyncStatus, error) { func (c *mockDriverClient) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) {
return c.Mock.MethodCalled("SyncStatus").Get(0).(*driver.SyncStatus), nil return c.Mock.MethodCalled("SyncStatus").Get(0).(*eth.SyncStatus), nil
} }
func (c *mockDriverClient) ResetDerivationPipeline(ctx context.Context) error { func (c *mockDriverClient) ResetDerivationPipeline(ctx context.Context) error {
......
...@@ -106,7 +106,7 @@ func (d *Driver) ResetDerivationPipeline(ctx context.Context) error { ...@@ -106,7 +106,7 @@ func (d *Driver) ResetDerivationPipeline(ctx context.Context) error {
return d.s.ResetDerivationPipeline(ctx) return d.s.ResetDerivationPipeline(ctx)
} }
func (d *Driver) SyncStatus(ctx context.Context) (*SyncStatus, error) { func (d *Driver) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) {
return d.s.SyncStatus(ctx) return d.s.SyncStatus(ctx)
} }
......
...@@ -16,31 +16,8 @@ import ( ...@@ -16,31 +16,8 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
) )
// SyncStatus is a snapshot of the driver. // Deprecated: use eth.SyncStatus instead.
// Values may be zeroed if not yet initialized. type SyncStatus = eth.SyncStatus
type SyncStatus struct {
// CurrentL1 is the block that the derivation process is currently at,
// this may not be fully derived into L2 data yet.
// If the node is synced, this matches the HeadL1, minus the verifier confirmation distance.
CurrentL1 eth.L1BlockRef `json:"current_l1"`
// HeadL1 is the perceived head of the L1 chain, no confirmation distance.
// The head is not guaranteed to build on the other L1 sync status fields,
// as the node may be in progress of resetting to adapt to a L1 reorg.
HeadL1 eth.L1BlockRef `json:"head_l1"`
SafeL1 eth.L1BlockRef `json:"safe_l1"`
FinalizedL1 eth.L1BlockRef `json:"finalized_l1"`
// UnsafeL2 is the absolute tip of the L2 chain,
// pointing to block data that has not been submitted to L1 yet.
// The sequencer is building this, and verifiers may also be ahead of the
// SafeL2 block if they sync blocks via p2p or other offchain sources.
UnsafeL2 eth.L2BlockRef `json:"unsafe_l2"`
// SafeL2 points to the L2 block that was derived from the L1 chain.
// This point may still reorg if the L1 chain reorgs.
SafeL2 eth.L2BlockRef `json:"safe_l2"`
// FinalizedL2 points to the L2 block that was derived fully from
// finalized L1 information, thus irreversible.
FinalizedL2 eth.L2BlockRef `json:"finalized_l2"`
}
type state struct { type state struct {
// Latest recorded head, safe block and finalized block of the L1 Chain, independent of derivation work // Latest recorded head, safe block and finalized block of the L1 Chain, independent of derivation work
...@@ -56,7 +33,7 @@ type state struct { ...@@ -56,7 +33,7 @@ type state struct {
idleDerivation bool idleDerivation bool
// Requests for sync status. Synchronized with event loop to avoid reading an inconsistent sync status. // Requests for sync status. Synchronized with event loop to avoid reading an inconsistent sync status.
syncStatusReq chan chan SyncStatus syncStatusReq chan chan eth.SyncStatus
// Upon receiving a channel in this channel, the derivation pipeline is forced to be reset. // Upon receiving a channel in this channel, the derivation pipeline is forced to be reset.
// It tells the caller that the reset occurred by closing the passed in channel. // It tells the caller that the reset occurred by closing the passed in channel.
...@@ -101,7 +78,7 @@ func NewState(driverCfg *Config, log log.Logger, snapshotLog log.Logger, config ...@@ -101,7 +78,7 @@ func NewState(driverCfg *Config, log log.Logger, snapshotLog log.Logger, config
return &state{ return &state{
derivation: derivationPipeline, derivation: derivationPipeline,
idleDerivation: false, idleDerivation: false,
syncStatusReq: make(chan chan SyncStatus, 10), syncStatusReq: make(chan chan eth.SyncStatus, 10),
forceReset: make(chan chan struct{}, 10), forceReset: make(chan chan struct{}, 10),
Config: config, Config: config,
DriverConfig: driverCfg, DriverConfig: driverCfg,
...@@ -472,7 +449,7 @@ func (s *state) eventLoop() { ...@@ -472,7 +449,7 @@ func (s *state) eventLoop() {
reqStep() // continue with the next step if we can reqStep() // continue with the next step if we can
} }
case respCh := <-s.syncStatusReq: case respCh := <-s.syncStatusReq:
respCh <- SyncStatus{ respCh <- eth.SyncStatus{
CurrentL1: s.derivation.Progress().Origin, CurrentL1: s.derivation.Progress().Origin,
HeadL1: s.l1Head, HeadL1: s.l1Head,
SafeL1: s.l1Safe, SafeL1: s.l1Safe,
...@@ -510,8 +487,8 @@ func (s *state) ResetDerivationPipeline(ctx context.Context) error { ...@@ -510,8 +487,8 @@ func (s *state) ResetDerivationPipeline(ctx context.Context) error {
} }
} }
func (s *state) SyncStatus(ctx context.Context) (*SyncStatus, error) { func (s *state) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) {
respCh := make(chan SyncStatus) respCh := make(chan eth.SyncStatus)
select { select {
case <-ctx.Done(): case <-ctx.Done():
return nil, ctx.Err() return nil, ctx.Err()
......
package sources
import (
"context"
"math/big"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
)
type RollupClient struct {
rpc *rpc.Client
}
func NewRollupClient(rpc *rpc.Client) *RollupClient {
return &RollupClient{rpc}
}
func (r *RollupClient) OutputAtBlock(ctx context.Context, blockNum *big.Int) ([]eth.Bytes32, error) {
var output []eth.Bytes32
err := r.rpc.CallContext(ctx, &output, "optimism_outputAtBlock", hexutil.EncodeBig(blockNum))
return output, err
}
func (r *RollupClient) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) {
var output *eth.SyncStatus
err := r.rpc.CallContext(ctx, &output, "optimism_syncStatus")
return output, err
}
func (r *RollupClient) RollupConfig(ctx context.Context) (*rollup.Config, error) {
var output *rollup.Config
err := r.rpc.CallContext(ctx, &output, "optimism_rollupConfig")
return output, err
}
func (r *RollupClient) Version(ctx context.Context) (string, error) {
var output string
err := r.rpc.CallContext(ctx, &output, "optimism_version")
return output, err
}
...@@ -7,9 +7,10 @@ import ( ...@@ -7,9 +7,10 @@ import (
"math/big" "math/big"
"strings" "strings"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum-optimism/optimism/op-bindings/bindings" "github.com/ethereum-optimism/optimism/op-bindings/bindings"
"github.com/ethereum-optimism/optimism/op-node/eth" "github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-proposer/rollupclient"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -27,7 +28,7 @@ type Config struct { ...@@ -27,7 +28,7 @@ type Config struct {
Name string Name string
L1Client *ethclient.Client L1Client *ethclient.Client
L2Client *ethclient.Client L2Client *ethclient.Client
RollupClient *rollupclient.RollupClient RollupClient *sources.RollupClient
L2OOAddr common.Address L2OOAddr common.Address
ChainID *big.Int ChainID *big.Int
PrivKey *ecdsa.PrivateKey PrivKey *ecdsa.PrivateKey
......
...@@ -12,6 +12,8 @@ import ( ...@@ -12,6 +12,8 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/ethereum-optimism/optimism/op-node/sources"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
oplog "github.com/ethereum-optimism/optimism/op-service/log" oplog "github.com/ethereum-optimism/optimism/op-service/log"
...@@ -20,7 +22,6 @@ import ( ...@@ -20,7 +22,6 @@ import (
oprpc "github.com/ethereum-optimism/optimism/op-service/rpc" oprpc "github.com/ethereum-optimism/optimism/op-service/rpc"
"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/rollupclient"
"github.com/ethereum-optimism/optimism/op-proposer/txmgr" "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"
...@@ -247,7 +248,7 @@ func dialEthClientWithTimeout(ctx context.Context, url string) ( ...@@ -247,7 +248,7 @@ func dialEthClientWithTimeout(ctx context.Context, url string) (
// dialRollupClientWithTimeout attempts to dial the RPC provider using the provided // dialRollupClientWithTimeout attempts to dial the RPC provider using the provided
// URL. If the dial doesn't complete within defaultDialTimeout seconds, this // URL. If the dial doesn't complete within defaultDialTimeout seconds, this
// method will return an error. // method will return an error.
func dialRollupClientWithTimeout(ctx context.Context, url string) (*rollupclient.RollupClient, error) { func dialRollupClientWithTimeout(ctx context.Context, url string) (*sources.RollupClient, error) {
ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout) ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout)
defer cancel() defer cancel()
...@@ -256,7 +257,7 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*rollupclient ...@@ -256,7 +257,7 @@ func dialRollupClientWithTimeout(ctx context.Context, url string) (*rollupclient
return nil, err return nil, err
} }
return rollupclient.NewRollupClient(client), nil return sources.NewRollupClient(client), 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 package rollupclient
import ( import (
"context" "github.com/ethereum-optimism/optimism/op-node/sources"
"math/big"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/driver"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
) )
type RollupClient struct { // Deprecated: use sources.RollupClient instead
rpc *rpc.Client type RollupClient = sources.RollupClient
}
func NewRollupClient(rpc *rpc.Client) *RollupClient {
return &RollupClient{rpc}
}
func (r *RollupClient) OutputAtBlock(ctx context.Context, blockNum *big.Int) ([]eth.Bytes32, error) {
var output []eth.Bytes32
err := r.rpc.CallContext(ctx, &output, "optimism_outputAtBlock", hexutil.EncodeBig(blockNum))
return output, err
}
func (r *RollupClient) SyncStatus(ctx context.Context) (*driver.SyncStatus, error) {
var output *driver.SyncStatus
err := r.rpc.CallContext(ctx, &output, "optimism_syncStatus")
return output, err
}
func (r *RollupClient) RollupConfig(ctx context.Context) (*rollup.Config, error) {
var output *rollup.Config
err := r.rpc.CallContext(ctx, &output, "optimism_rollupConfig")
return output, err
}
func (r *RollupClient) Version(ctx context.Context) (string, error) { // Deprecated: use sources.NewRollupClient instead
var output string func NewRollupClient(rpc *rpc.Client) *sources.RollupClient {
err := r.rpc.CallContext(ctx, &output, "optimism_version") return sources.NewRollupClient(rpc)
return output, err
} }
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