Commit c6f6d68b authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

indexer: deduplicate l2geth and geth deps (#2859)

Remove some of the l2geth packages in place of
using geth packages directly. This begins to
remove l2geth as a dependency from the indexer,
as l2geth will become legacy code after the release
of bedrock.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent b3921408
---
'@eth-optimism/indexer': patch
---
Deduplicate some l2geth and geth utils
...@@ -7,12 +7,12 @@ LDFLAGSSTRING +=-X main.GitDate=$(GITDATE) ...@@ -7,12 +7,12 @@ LDFLAGSSTRING +=-X main.GitDate=$(GITDATE)
LDFLAGSSTRING +=-X main.GitVersion=$(GITVERSION) LDFLAGSSTRING +=-X main.GitVersion=$(GITVERSION)
LDFLAGS := -ldflags "$(LDFLAGSSTRING)" LDFLAGS := -ldflags "$(LDFLAGSSTRING)"
L1BRIDGE_ABI_ARTIFACT = ../../packages/contracts/artifacts/contracts/L1/messaging/L1StandardBridge.sol/L1StandardBridge.json L1BRIDGE_ABI_ARTIFACT = ../packages/contracts/artifacts/contracts/L1/messaging/L1StandardBridge.sol/L1StandardBridge.json
L2BRIDGE_ABI_ARTIFACT = ../../packages/contracts/artifacts/contracts/L2/messaging/L2StandardBridge.sol/L2StandardBridge.json L2BRIDGE_ABI_ARTIFACT = ../packages/contracts/artifacts/contracts/L2/messaging/L2StandardBridge.sol/L2StandardBridge.json
ERC20_ABI_ARTIFACT = ./contracts/ERC20.sol/ERC20.json ERC20_ABI_ARTIFACT = ./contracts/ERC20.sol/ERC20.json
SCC_ABI_ARTIFACT = ../../packages/contracts/artifacts/contracts/L1/rollup/StateCommitmentChain.sol/StateCommitmentChain.json SCC_ABI_ARTIFACT = ../packages/contracts/artifacts/contracts/L1/rollup/StateCommitmentChain.sol/StateCommitmentChain.json
indexer: indexer:
env GO111MODULE=on go build -v $(LDFLAGS) ./cmd/indexer env GO111MODULE=on go build -v $(LDFLAGS) ./cmd/indexer
...@@ -52,7 +52,7 @@ bindings-l2bridge: ...@@ -52,7 +52,7 @@ bindings-l2bridge:
cat $(L2BRIDGE_ABI_ARTIFACT) \ cat $(L2BRIDGE_ABI_ARTIFACT) \
| jq .abi \ | jq .abi \
| ../../l2geth/build/bin/abigen --pkg l2bridge \ | abigen --pkg l2bridge \
--abi - \ --abi - \
--out bindings/l2bridge/l2_standard_bridge.go \ --out bindings/l2bridge/l2_standard_bridge.go \
--type L2StandardBridge \ --type L2StandardBridge \
...@@ -84,7 +84,7 @@ bindings-l2erc20: ...@@ -84,7 +84,7 @@ bindings-l2erc20:
cat $(ERC20_ABI_ARTIFACT) \ cat $(ERC20_ABI_ARTIFACT) \
| jq .abi \ | jq .abi \
| ../../l2geth/build/bin/abigen --pkg l2erc20 \ | abigen --pkg l2erc20 \
--abi - \ --abi - \
--out bindings/l2erc20/l2erc20.go \ --out bindings/l2erc20/l2erc20.go \
--type L2ERC20 \ --type L2ERC20 \
......
This diff is collapsed.
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"strings" "strings"
l2common "github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
// NOTE: Only postgresql backend is supported at the moment. // NOTE: Only postgresql backend is supported at the moment.
...@@ -401,7 +400,7 @@ func (d *Database) GetDepositsByAddress(address common.Address, page PaginationP ...@@ -401,7 +400,7 @@ func (d *Database) GetDepositsByAddress(address common.Address, page PaginationP
// GetWithdrawalBatch returns the StateBatch corresponding to the given // GetWithdrawalBatch returns the StateBatch corresponding to the given
// withdrawal transaction hash. // withdrawal transaction hash.
func (d *Database) GetWithdrawalBatch(hash l2common.Hash) (*StateBatchJSON, error) { func (d *Database) GetWithdrawalBatch(hash common.Hash) (*StateBatchJSON, error) {
const selectWithdrawalBatchStatement = ` const selectWithdrawalBatchStatement = `
SELECT SELECT
state_batches.index, state_batches.root, state_batches.size, state_batches.prev_total, state_batches.extra_data, state_batches.block_hash, state_batches.index, state_batches.root, state_batches.size, state_batches.prev_total, state_batches.extra_data, state_batches.block_hash,
...@@ -459,7 +458,7 @@ func (d *Database) GetWithdrawalBatch(hash l2common.Hash) (*StateBatchJSON, erro ...@@ -459,7 +458,7 @@ func (d *Database) GetWithdrawalBatch(hash l2common.Hash) (*StateBatchJSON, erro
// GetWithdrawalsByAddress returns the list of Withdrawals indexed for the given // GetWithdrawalsByAddress returns the list of Withdrawals indexed for the given
// address paginated by the given params. // address paginated by the given params.
func (d *Database) GetWithdrawalsByAddress(address l2common.Address, page PaginationParam) (*PaginatedWithdrawals, error) { func (d *Database) GetWithdrawalsByAddress(address common.Address, page PaginationParam) (*PaginatedWithdrawals, error) {
const selectWithdrawalsStatement = ` const selectWithdrawalsStatement = `
SELECT SELECT
withdrawals.guid, withdrawals.from_address, withdrawals.to_address, withdrawals.guid, withdrawals.from_address, withdrawals.to_address,
...@@ -505,7 +504,7 @@ func (d *Database) GetWithdrawalsByAddress(address l2common.Address, page Pagina ...@@ -505,7 +504,7 @@ func (d *Database) GetWithdrawalsByAddress(address l2common.Address, page Pagina
} }
for i := range withdrawals { for i := range withdrawals {
batch, _ := d.GetWithdrawalBatch(l2common.HexToHash(withdrawals[i].TxHash)) batch, _ := d.GetWithdrawalBatch(common.HexToHash(withdrawals[i].TxHash))
withdrawals[i].Batch = batch withdrawals[i].Batch = batch
} }
...@@ -540,12 +539,12 @@ func (d *Database) GetWithdrawalsByAddress(address l2common.Address, page Pagina ...@@ -540,12 +539,12 @@ func (d *Database) GetWithdrawalsByAddress(address l2common.Address, page Pagina
} }
// GetHighestL1Block returns the highest known L1 block. // GetHighestL1Block returns the highest known L1 block.
func (d *Database) GetHighestL1Block() (*L1BlockLocator, error) { func (d *Database) GetHighestL1Block() (*BlockLocator, error) {
const selectHighestBlockStatement = ` const selectHighestBlockStatement = `
SELECT number, hash FROM l1_blocks ORDER BY number DESC LIMIT 1 SELECT number, hash FROM l1_blocks ORDER BY number DESC LIMIT 1
` `
var highestBlock *L1BlockLocator var highestBlock *BlockLocator
err := txn(d.db, func(tx *sql.Tx) error { err := txn(d.db, func(tx *sql.Tx) error {
row := tx.QueryRow(selectHighestBlockStatement) row := tx.QueryRow(selectHighestBlockStatement)
if row.Err() != nil { if row.Err() != nil {
...@@ -563,7 +562,7 @@ func (d *Database) GetHighestL1Block() (*L1BlockLocator, error) { ...@@ -563,7 +562,7 @@ func (d *Database) GetHighestL1Block() (*L1BlockLocator, error) {
return err return err
} }
highestBlock = &L1BlockLocator{ highestBlock = &BlockLocator{
Number: number, Number: number,
Hash: common.HexToHash(hash), Hash: common.HexToHash(hash),
} }
...@@ -578,12 +577,12 @@ func (d *Database) GetHighestL1Block() (*L1BlockLocator, error) { ...@@ -578,12 +577,12 @@ func (d *Database) GetHighestL1Block() (*L1BlockLocator, error) {
} }
// GetHighestL2Block returns the highest known L2 block. // GetHighestL2Block returns the highest known L2 block.
func (d *Database) GetHighestL2Block() (*L2BlockLocator, error) { func (d *Database) GetHighestL2Block() (*BlockLocator, error) {
const selectHighestBlockStatement = ` const selectHighestBlockStatement = `
SELECT number, hash FROM l2_blocks ORDER BY number DESC LIMIT 1 SELECT number, hash FROM l2_blocks ORDER BY number DESC LIMIT 1
` `
var highestBlock *L2BlockLocator var highestBlock *BlockLocator
err := txn(d.db, func(tx *sql.Tx) error { err := txn(d.db, func(tx *sql.Tx) error {
row := tx.QueryRow(selectHighestBlockStatement) row := tx.QueryRow(selectHighestBlockStatement)
if row.Err() != nil { if row.Err() != nil {
...@@ -601,9 +600,9 @@ func (d *Database) GetHighestL2Block() (*L2BlockLocator, error) { ...@@ -601,9 +600,9 @@ func (d *Database) GetHighestL2Block() (*L2BlockLocator, error) {
return err return err
} }
highestBlock = &L2BlockLocator{ highestBlock = &BlockLocator{
Number: number, Number: number,
Hash: l2common.HexToHash(hash), Hash: common.HexToHash(hash),
} }
return nil return nil
......
package db package db
import l2common "github.com/ethereum-optimism/optimism/l2geth/common" import "github.com/ethereum/go-ethereum/common"
// ETHL1Token is a placeholder token for differentiating ETH transactions from // ETHL1Token is a placeholder token for differentiating ETH transactions from
// ERC20 transactions on L1. // ERC20 transactions on L1.
...@@ -13,7 +13,7 @@ var ETHL1Token = &Token{ ...@@ -13,7 +13,7 @@ var ETHL1Token = &Token{
// ETHL2Address is a placeholder address for differentiating ETH transactions // ETHL2Address is a placeholder address for differentiating ETH transactions
// from ERC20 transactions on L2. // from ERC20 transactions on L2.
var ETHL2Address = l2common.HexToAddress("0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000") var ETHL2Address = common.HexToAddress("0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000")
// ETHL2Token is a placeholder token for differentiating ETH transactions from // ETHL2Token is a placeholder token for differentiating ETH transactions from
// ERC20 transactions on L2. // ERC20 transactions on L2.
......
package db package db
import ( import (
l2common "github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
) )
...@@ -21,8 +20,8 @@ func (b IndexedL1Block) String() string { ...@@ -21,8 +20,8 @@ func (b IndexedL1Block) String() string {
// IndexedL2Block contains the L2 block including the withdrawals in it. // IndexedL2Block contains the L2 block including the withdrawals in it.
type IndexedL2Block struct { type IndexedL2Block struct {
Hash l2common.Hash Hash common.Hash
ParentHash l2common.Hash ParentHash common.Hash
Number uint64 Number uint64
Timestamp uint64 Timestamp uint64
Withdrawals []Withdrawal Withdrawals []Withdrawal
......
package db package db
import ( import (
l2common "github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
) )
// L1BlockLocator contains the block locator for a L1 block. // BlockLocator contains the block number and hash. It can
type L1BlockLocator struct { // uniquely identify an Ethereum block
type BlockLocator struct {
Number uint64 `json:"number"` Number uint64 `json:"number"`
Hash common.Hash `json:"hash"` Hash common.Hash `json:"hash"`
} }
// L2BlockLocator contains the block locator for a L2 block.
type L2BlockLocator struct {
Number uint64 `json:"number"`
Hash l2common.Hash `json:"hash"`
}
...@@ -3,17 +3,17 @@ package db ...@@ -3,17 +3,17 @@ package db
import ( import (
"math/big" "math/big"
l2common "github.com/ethereum-optimism/optimism/l2geth/common" "github.com/ethereum/go-ethereum/common"
) )
// Withdrawal contains transaction data for withdrawals made via the L2 to L1 bridge. // Withdrawal contains transaction data for withdrawals made via the L2 to L1 bridge.
type Withdrawal struct { type Withdrawal struct {
GUID string GUID string
TxHash l2common.Hash TxHash common.Hash
L1Token l2common.Address L1Token common.Address
L2Token l2common.Address L2Token common.Address
FromAddress l2common.Address FromAddress common.Address
ToAddress l2common.Address ToAddress common.Address
Amount *big.Int Amount *big.Int
Data []byte Data []byte
LogIndex uint LogIndex uint
......
...@@ -12,8 +12,6 @@ import ( ...@@ -12,8 +12,6 @@ import (
"github.com/ethereum-optimism/optimism/indexer/services" "github.com/ethereum-optimism/optimism/indexer/services"
l2rpc "github.com/ethereum-optimism/optimism/l2geth/rpc"
"github.com/ethereum-optimism/optimism/indexer/metrics" "github.com/ethereum-optimism/optimism/indexer/metrics"
"github.com/ethereum-optimism/optimism/indexer/server" "github.com/ethereum-optimism/optimism/indexer/server"
"github.com/rs/cors" "github.com/rs/cors"
...@@ -21,7 +19,6 @@ import ( ...@@ -21,7 +19,6 @@ import (
database "github.com/ethereum-optimism/optimism/indexer/db" database "github.com/ethereum-optimism/optimism/indexer/db"
"github.com/ethereum-optimism/optimism/indexer/services/l1" "github.com/ethereum-optimism/optimism/indexer/services/l1"
"github.com/ethereum-optimism/optimism/indexer/services/l2" "github.com/ethereum-optimism/optimism/indexer/services/l2"
l2ethclient "github.com/ethereum-optimism/optimism/l2geth/ethclient"
"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"
...@@ -82,7 +79,7 @@ type Indexer struct { ...@@ -82,7 +79,7 @@ type Indexer struct {
ctx context.Context ctx context.Context
cfg Config cfg Config
l1Client *ethclient.Client l1Client *ethclient.Client
l2Client *l2ethclient.Client l2Client *ethclient.Client
l1IndexingService *l1.Service l1IndexingService *l1.Service
l2IndexingService *l2.Service l2IndexingService *l2.Service
...@@ -130,12 +127,12 @@ func NewIndexer(cfg Config, gitVersion string) (*Indexer, error) { ...@@ -130,12 +127,12 @@ func NewIndexer(cfg Config, gitVersion string) (*Indexer, error) {
// Connect to L1 and L2 providers. Perform these last since they are the // Connect to L1 and L2 providers. Perform these last since they are the
// most expensive. // most expensive.
l1Client, rawl1Client, err := dialL1EthClientWithTimeout(ctx, cfg.L1EthRpc) l1Client, rawl1Client, err := dialEthClientWithTimeout(ctx, cfg.L1EthRpc)
if err != nil { if err != nil {
return nil, err return nil, err
} }
l2Client, l2RPC, err := dialL2EthClientWithTimeout(ctx, cfg.L2EthRpc) l2Client, l2RPC, err := dialEthClientWithTimeout(ctx, cfg.L2EthRpc)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -271,7 +268,7 @@ func (b *Indexer) Stop() { ...@@ -271,7 +268,7 @@ func (b *Indexer) Stop() {
// dialL1EthClientWithTimeout attempts to dial the L1 provider using the // dialL1EthClientWithTimeout attempts to dial the L1 provider using the
// provided URL. If the dial doesn't complete within defaultDialTimeout seconds, // provided URL. If the dial doesn't complete within defaultDialTimeout seconds,
// this method will return an error. // this method will return an error.
func dialL1EthClientWithTimeout(ctx context.Context, url string) ( func dialEthClientWithTimeout(ctx context.Context, url string) (
*ethclient.Client, *rpc.Client, error) { *ethclient.Client, *rpc.Client, error) {
ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout) ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout)
...@@ -284,23 +281,6 @@ func dialL1EthClientWithTimeout(ctx context.Context, url string) ( ...@@ -284,23 +281,6 @@ func dialL1EthClientWithTimeout(ctx context.Context, url string) (
return ethclient.NewClient(c), c, nil return ethclient.NewClient(c), c, nil
} }
// dialL2EthClientWithTimeout attempts to dial the L2 provider using the
// provided URL. If the dial doesn't complete within defaultDialTimeout seconds,
// this method will return an error.
func dialL2EthClientWithTimeout(ctx context.Context, url string) (
*l2ethclient.Client, *l2rpc.Client, error) {
ctxt, cancel := context.WithTimeout(ctx, defaultDialTimeout)
defer cancel()
rpc, err := l2rpc.DialContext(ctxt, url)
if err != nil {
return nil, nil, err
}
return l2ethclient.NewClient(rpc), rpc, nil
}
// traceRateToFloat64 converts a time.Duration into a valid float64 for the // traceRateToFloat64 converts a time.Duration into a valid float64 for the
// Sentry client. The client only accepts values between 0.0 and 1.0, so this // Sentry client. The client only accepts values between 0.0 and 1.0, so this
// method clamps anything greater than 1 second to 1.0. // method clamps anything greater than 1 second to 1.0.
......
...@@ -6,7 +6,6 @@ import ( ...@@ -6,7 +6,6 @@ import (
"strconv" "strconv"
"time" "time"
l2common "github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
...@@ -160,7 +159,7 @@ func (m *Metrics) RecordDeposit(addr common.Address) { ...@@ -160,7 +159,7 @@ func (m *Metrics) RecordDeposit(addr common.Address) {
m.DepositsCount.WithLabelValues(sym).Inc() m.DepositsCount.WithLabelValues(sym).Inc()
} }
func (m *Metrics) RecordWithdrawal(addr l2common.Address) { func (m *Metrics) RecordWithdrawal(addr common.Address) {
sym := m.tokenAddrs[addr.String()] sym := m.tokenAddrs[addr.String()]
if sym == "" { if sym == "" {
sym = "UNKNOWN" sym = "UNKNOWN"
......
...@@ -95,8 +95,8 @@ type Service struct { ...@@ -95,8 +95,8 @@ type Service struct {
} }
type IndexerStatus struct { type IndexerStatus struct {
Synced float64 `json:"synced"` Synced float64 `json:"synced"`
Highest db.L1BlockLocator `json:"highest_block"` Highest db.BlockLocator `json:"highest_block"`
} }
func NewService(cfg ServiceConfig) (*Service, error) { func NewService(cfg ServiceConfig) (*Service, error) {
...@@ -203,7 +203,7 @@ func (s *Service) Loop(ctx context.Context) { ...@@ -203,7 +203,7 @@ func (s *Service) Loop(ctx context.Context) {
} }
func (s *Service) Update(newHeader *types.Header) error { func (s *Service) Update(newHeader *types.Header) error {
var lowest = db.L1BlockLocator{ var lowest = db.BlockLocator{
Number: s.cfg.StartBlockNumber, Number: s.cfg.StartBlockNumber,
Hash: common.HexToHash(s.cfg.StartBlockHash), Hash: common.HexToHash(s.cfg.StartBlockHash),
} }
......
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
"github.com/ethereum-optimism/optimism/indexer/bindings/l2bridge" "github.com/ethereum-optimism/optimism/indexer/bindings/l2bridge"
"github.com/ethereum-optimism/optimism/indexer/db" "github.com/ethereum-optimism/optimism/indexer/db"
"github.com/ethereum-optimism/optimism/l2geth/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum-optimism/optimism/l2geth/common" "github.com/ethereum/go-ethereum/common"
) )
type WithdrawalsMap map[common.Hash][]db.Withdrawal type WithdrawalsMap map[common.Hash][]db.Withdrawal
......
...@@ -5,7 +5,7 @@ import ( ...@@ -5,7 +5,7 @@ import (
"time" "time"
"github.com/ethereum-optimism/optimism/indexer/bindings/l2bridge" "github.com/ethereum-optimism/optimism/indexer/bindings/l2bridge"
"github.com/ethereum-optimism/optimism/l2geth/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
) )
// clientRetryInterval is the interval to wait between retrying client API // clientRetryInterval is the interval to wait between retrying client API
......
...@@ -6,8 +6,8 @@ import ( ...@@ -6,8 +6,8 @@ import (
"github.com/ethereum-optimism/optimism/indexer/bindings/l2bridge" "github.com/ethereum-optimism/optimism/indexer/bindings/l2bridge"
"github.com/ethereum-optimism/optimism/indexer/db" "github.com/ethereum-optimism/optimism/indexer/db"
"github.com/ethereum-optimism/optimism/l2geth/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum-optimism/optimism/l2geth/common" "github.com/ethereum/go-ethereum/common"
) )
type StandardBridge struct { type StandardBridge struct {
......
...@@ -7,11 +7,10 @@ import ( ...@@ -7,11 +7,10 @@ import (
"time" "time"
"github.com/ethereum-optimism/optimism/indexer/services/util" "github.com/ethereum-optimism/optimism/indexer/services/util"
"github.com/ethereum-optimism/optimism/l2geth/rpc"
"github.com/ethereum-optimism/optimism/l2geth/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum-optimism/optimism/l2geth/log" "github.com/ethereum/go-ethereum/log"
l2rpc "github.com/ethereum-optimism/optimism/l2geth/rpc" "github.com/ethereum/go-ethereum/rpc"
) )
const ( const (
...@@ -29,7 +28,7 @@ type ConfirmedHeaderSelector struct { ...@@ -29,7 +28,7 @@ type ConfirmedHeaderSelector struct {
cfg HeaderSelectorConfig cfg HeaderSelectorConfig
} }
func HeadersByRange(ctx context.Context, client *l2rpc.Client, startHeight uint64, count int) ([]*types.Header, error) { func HeadersByRange(ctx context.Context, client *rpc.Client, startHeight uint64, count int) ([]*types.Header, error) {
height := startHeight height := startHeight
batchElems := make([]rpc.BatchElem, count) batchElems := make([]rpc.BatchElem, count)
for i := 0; i < count; i++ { for i := 0; i < count; i++ {
...@@ -63,7 +62,7 @@ func (f *ConfirmedHeaderSelector) NewHead( ...@@ -63,7 +62,7 @@ func (f *ConfirmedHeaderSelector) NewHead(
ctx context.Context, ctx context.Context,
lowest uint64, lowest uint64,
header *types.Header, header *types.Header,
client *l2rpc.Client, client *rpc.Client,
) ([]*types.Header, error) { ) ([]*types.Header, error) {
number := header.Number.Uint64() number := header.Number.Uint64()
......
...@@ -3,12 +3,13 @@ package l2 ...@@ -3,12 +3,13 @@ package l2
import ( import (
"github.com/ethereum-optimism/optimism/indexer/bindings/l2erc20" "github.com/ethereum-optimism/optimism/indexer/bindings/l2erc20"
"github.com/ethereum-optimism/optimism/indexer/db" "github.com/ethereum-optimism/optimism/indexer/db"
"github.com/ethereum-optimism/optimism/l2geth/accounts/abi/bind"
l2common "github.com/ethereum-optimism/optimism/l2geth/common" "github.com/ethereum/go-ethereum/accounts/abi/bind"
l2ethclient "github.com/ethereum-optimism/optimism/l2geth/ethclient" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
) )
func QueryERC20(address l2common.Address, client *l2ethclient.Client) (*db.Token, error) { func QueryERC20(address common.Address, client *ethclient.Client) (*db.Token, error) {
contract, err := l2erc20.NewL2ERC20(address, client) contract, err := l2erc20.NewL2ERC20(address, client)
if err != nil { if err != nil {
return nil, err return nil, err
......
...@@ -10,17 +10,18 @@ import ( ...@@ -10,17 +10,18 @@ import (
"sync" "sync"
"time" "time"
l2rpc "github.com/ethereum-optimism/optimism/l2geth/rpc"
"github.com/ethereum-optimism/optimism/indexer/metrics" "github.com/ethereum-optimism/optimism/indexer/metrics"
"github.com/ethereum-optimism/optimism/indexer/server" "github.com/ethereum-optimism/optimism/indexer/server"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/ethereum-optimism/optimism/indexer/db" "github.com/ethereum-optimism/optimism/indexer/db"
"github.com/ethereum-optimism/optimism/indexer/services/l2/bridge" "github.com/ethereum-optimism/optimism/indexer/services/l2/bridge"
"github.com/ethereum-optimism/optimism/l2geth/common"
"github.com/ethereum-optimism/optimism/l2geth/core/types" "github.com/ethereum/go-ethereum/rpc"
l2ethclient "github.com/ethereum-optimism/optimism/l2geth/ethclient"
"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/go-ethereum/log"
"github.com/gorilla/mux" "github.com/gorilla/mux"
) )
...@@ -44,7 +45,7 @@ var clientRetryInterval = 5 * time.Second ...@@ -44,7 +45,7 @@ var clientRetryInterval = 5 * time.Second
// HeaderByNumberWithRetry retries the given func until it succeeds, waiting // HeaderByNumberWithRetry retries the given func until it succeeds, waiting
// for clientRetryInterval duration after every call. // for clientRetryInterval duration after every call.
func HeaderByNumberWithRetry(ctx context.Context, func HeaderByNumberWithRetry(ctx context.Context,
client *l2ethclient.Client) (*types.Header, error) { client *ethclient.Client) (*types.Header, error) {
for { for {
res, err := client.HeaderByNumber(ctx, nil) res, err := client.HeaderByNumber(ctx, nil)
switch err { switch err {
...@@ -60,8 +61,8 @@ func HeaderByNumberWithRetry(ctx context.Context, ...@@ -60,8 +61,8 @@ func HeaderByNumberWithRetry(ctx context.Context,
type ServiceConfig struct { type ServiceConfig struct {
Context context.Context Context context.Context
Metrics *metrics.Metrics Metrics *metrics.Metrics
L2RPC *l2rpc.Client L2RPC *rpc.Client
L2Client *l2ethclient.Client L2Client *ethclient.Client
ChainID *big.Int ChainID *big.Int
ConfDepth uint64 ConfDepth uint64
MaxHeaderBatchSize uint64 MaxHeaderBatchSize uint64
...@@ -85,8 +86,8 @@ type Service struct { ...@@ -85,8 +86,8 @@ type Service struct {
} }
type IndexerStatus struct { type IndexerStatus struct {
Synced float64 `json:"synced"` Synced float64 `json:"synced"`
Highest db.L2BlockLocator `json:"highest_block"` Highest db.BlockLocator `json:"highest_block"`
} }
func NewService(cfg ServiceConfig) (*Service, error) { func NewService(cfg ServiceConfig) (*Service, error) {
...@@ -181,7 +182,7 @@ func (s *Service) Loop(ctx context.Context) { ...@@ -181,7 +182,7 @@ func (s *Service) Loop(ctx context.Context) {
} }
func (s *Service) Update(newHeader *types.Header) error { func (s *Service) Update(newHeader *types.Header) error {
var lowest = db.L2BlockLocator{ var lowest = db.BlockLocator{
Number: s.cfg.StartBlockNumber, Number: s.cfg.StartBlockNumber,
Hash: common.HexToHash(s.cfg.StartBlockHash), Hash: common.HexToHash(s.cfg.StartBlockHash),
} }
......
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