Skip to content

Commit

Permalink
fix module naming
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Oct 30, 2024
1 parent 67d091d commit 8e9a1a9
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 41 deletions.
8 changes: 4 additions & 4 deletions cmd/debugger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"context"
"fmt"
ethereum2 "github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"github.com/Layr-Labs/go-sidecar/pkg/clients/etherscan"
"github.com/Layr-Labs/go-sidecar/pkg/contractCaller"
"github.com/Layr-Labs/go-sidecar/pkg/contractManager"
Expand Down Expand Up @@ -42,7 +42,7 @@ func main() {
}

etherscanClient := etherscan.NewEtherscanClient(cfg, l)
client := ethereum2.NewClient(cfg.EthereumRpcConfig.BaseUrl, l)
client := ethereum.NewClient(cfg.EthereumRpcConfig.BaseUrl, l)

pgConfig := postgres.PostgresConfigFromDbConfig(&cfg.DatabaseConfig)
pgConfig.CreateDbIfNotExists = true
Expand Down Expand Up @@ -121,7 +121,7 @@ func main() {
}

transactionHash := "0xf6775c38af1d2802bcbc2b7c8959c0d5b48c63a14bfeda0261ba29d76c68c423"
transaction := &ethereum2.EthereumTransaction{}
transaction := &ethereum.EthereumTransaction{}

for _, tx := range block.Block.Transactions {
if tx.Hash.Value() == transactionHash {
Expand All @@ -132,7 +132,7 @@ func main() {

logIndex := 4
receipt := block.TxReceipts[transaction.Hash.Value()]
var interestingLog *ethereum2.EthereumEventLog
var interestingLog *ethereum.EthereumEventLog

for _, log := range receipt.Logs {
if log.LogIndex.Value() == uint64(logIndex) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/contractManager/contractManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package contractManager
import (
"context"
"fmt"
ethereum2 "github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"github.com/Layr-Labs/go-sidecar/pkg/clients/etherscan"
"github.com/Layr-Labs/go-sidecar/pkg/contractStore"
"github.com/Layr-Labs/go-sidecar/pkg/utils"
Expand All @@ -16,15 +16,15 @@ import (
type ContractManager struct {
ContractStore contractStore.ContractStore
EtherscanClient *etherscan.EtherscanClient
EthereumClient *ethereum2.Client
EthereumClient *ethereum.Client
Statsd *statsd.Client
Logger *zap.Logger
}

func NewContractManager(
cs contractStore.ContractStore,
ec *etherscan.EtherscanClient,
e *ethereum2.Client,
e *ethereum.Client,
s *statsd.Client,
l *zap.Logger,
) *ContractManager {
Expand Down Expand Up @@ -69,7 +69,7 @@ func (cm *ContractManager) FindOrCreateContractWithProxy(
return nil, err
}

storageValue, err := cm.EthereumClient.GetStorageAt(context.Background(), contractAddress, ethereum2.EIP1967_STORAGE_SLOT, "latest")
storageValue, err := cm.EthereumClient.GetStorageAt(context.Background(), contractAddress, ethereum.EIP1967_STORAGE_SLOT, "latest")
if err != nil {
cm.Logger.Sugar().Errorw("Failed to get storage value", zap.Error(err), zap.String("contractAddress", contractAddress))
} else {
Expand Down Expand Up @@ -97,7 +97,7 @@ func (cm *ContractManager) CreateContract(
zap.String("contractAddress", contractAddress),
)
} else {
bytecodeHash = ethereum2.HashBytecode(bytecode)
bytecodeHash = ethereum.HashBytecode(bytecode)
cm.Logger.Sugar().Debugw("Fetched contract bytecode",
zap.String("contractAddress", contractAddress),
zap.String("bytecodeHash", bytecodeHash),
Expand Down
22 changes: 11 additions & 11 deletions pkg/fetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package fetcher

import (
"context"
ethereum2 "github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"slices"
"sync"

Expand All @@ -12,12 +12,12 @@ import (
)

type Fetcher struct {
EthClient *ethereum2.Client
EthClient *ethereum.Client
Logger *zap.Logger
Config *config.Config
}

func NewFetcher(ethClient *ethereum2.Client, cfg *config.Config, l *zap.Logger) *Fetcher {
func NewFetcher(ethClient *ethereum.Client, cfg *config.Config, l *zap.Logger) *Fetcher {
return &Fetcher{
EthClient: ethClient,
Logger: l,
Expand All @@ -26,9 +26,9 @@ func NewFetcher(ethClient *ethereum2.Client, cfg *config.Config, l *zap.Logger)
}

type FetchedBlock struct {
Block *ethereum2.EthereumBlock
Block *ethereum.EthereumBlock
// map[transactionHash] => transactionReceipt
TxReceipts map[string]*ethereum2.EthereumTransactionReceipt
TxReceipts map[string]*ethereum.EthereumTransactionReceipt
// map[contractAddress] => stored value
ContractStorage map[string]string
}
Expand All @@ -40,11 +40,11 @@ func (f *Fetcher) FetchBlock(ctx context.Context, blockNumber uint64) (*FetchedB
return nil, err
}

txReceiptRequests := make([]*ethereum2.RPCRequest, 0)
txReceiptRequests := make([]*ethereum.RPCRequest, 0)
f.Logger.Sugar().Debugf("Fetching '%d' transactions from block '%d'", len(block.Transactions), blockNumber)

for i, tx := range block.Transactions {
txReceiptRequests = append(txReceiptRequests, ethereum2.GetTransactionReceiptRequest(tx.Hash.Value(), uint(i)))
txReceiptRequests = append(txReceiptRequests, ethereum.GetTransactionReceiptRequest(tx.Hash.Value(), uint(i)))
}

f.Logger.Sugar().Debugw("Fetching transaction receipts",
Expand All @@ -58,9 +58,9 @@ func (f *Fetcher) FetchBlock(ctx context.Context, blockNumber uint64) (*FetchedB
return nil, err
}

receipts := make(map[string]*ethereum2.EthereumTransactionReceipt)
receipts := make(map[string]*ethereum.EthereumTransactionReceipt)
for _, response := range receiptResponses {
r, err := ethereum2.RPCMethod_getTransactionReceipt.ResponseParser(response.Result)
r, err := ethereum.RPCMethod_getTransactionReceipt.ResponseParser(response.Result)
if err != nil {
f.Logger.Sugar().Errorw("failed to parse transaction receipt",
zap.Error(err),
Expand Down Expand Up @@ -133,7 +133,7 @@ func (f *Fetcher) FetchBlock(ctx context.Context, blockNumber uint64) (*FetchedB
for _, receipt := range receipts {
if receipt.ContractAddress != "" {
if cb, ok := contractBytecodeMap[receipt.ContractAddress.Value()]; ok {
receipt.ContractBytecode = ethereum2.EthereumHexString(cb)
receipt.ContractBytecode = ethereum.EthereumHexString(cb)
}
}
}
Expand All @@ -158,5 +158,5 @@ func (f *Fetcher) GetContractStorageSlot(ctx context.Context, contractAddress st
stringBlock = hexutil.EncodeUint64(blockNumber)
}

return f.EthClient.GetStorageAt(ctx, contractAddress, ethereum2.EIP1967_STORAGE_SLOT, stringBlock)
return f.EthClient.GetStorageAt(ctx, contractAddress, ethereum.EIP1967_STORAGE_SLOT, stringBlock)
}
34 changes: 17 additions & 17 deletions pkg/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package indexer
import (
"context"
"fmt"
ethereum2 "github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"github.com/Layr-Labs/go-sidecar/pkg/clients/ethereum"
"github.com/Layr-Labs/go-sidecar/pkg/clients/etherscan"
"github.com/Layr-Labs/go-sidecar/pkg/contractCaller"
"github.com/Layr-Labs/go-sidecar/pkg/contractManager"
Expand All @@ -19,15 +19,15 @@ import (
)

type Indexer struct {
Logger *zap.Logger
MetadataStore storage.BlockStore
ContractStore contractStore.ContractStore
Logger *zap.Logger
MetadataStore storage.BlockStore
ContractStore contractStore.ContractStore
ContractManager *contractManager.ContractManager
EtherscanClient *etherscan.EtherscanClient
Fetcher *fetcher.Fetcher
EthereumClient *ethereum2.Client
Config *config.Config
ContractCaller contractCaller.IContractCaller
EthereumClient *ethereum.Client
Config *config.Config
ContractCaller contractCaller.IContractCaller
}

type IndexErrorType int
Expand All @@ -41,8 +41,8 @@ const (
)

type IndexError struct {
Type IndexErrorType
Err error
Type IndexErrorType
Err error
BlockNumber uint64
TransactionHash string
LogIndex int
Expand Down Expand Up @@ -87,7 +87,7 @@ func NewIndexer(
cs contractStore.ContractStore,
es *etherscan.EtherscanClient,
cm *contractManager.ContractManager,
e *ethereum2.Client,
e *ethereum.Client,
f *fetcher.Fetcher,
cc contractCaller.IContractCaller,
l *zap.Logger,
Expand Down Expand Up @@ -240,7 +240,7 @@ func (idx *Indexer) IsInterestingAddress(addr string) bool {
return slices.Contains(idx.Config.GetInterestingAddressForConfigEnv(), addr)
}

func (idx *Indexer) IsInterestingTransaction(txn *ethereum2.EthereumTransaction, receipt *ethereum2.EthereumTransactionReceipt) bool {
func (idx *Indexer) IsInterestingTransaction(txn *ethereum.EthereumTransaction, receipt *ethereum.EthereumTransactionReceipt) bool {
address := txn.To.Value()
contractAddress := receipt.ContractAddress.Value()

Expand All @@ -254,8 +254,8 @@ func (idx *Indexer) IsInterestingTransaction(txn *ethereum2.EthereumTransaction,
func (idx *Indexer) FilterInterestingTransactions(
block *storage.Block,
fetchedBlock *fetcher.FetchedBlock,
) []*ethereum2.EthereumTransaction {
interestingTransactions := make([]*ethereum2.EthereumTransaction, 0)
) []*ethereum.EthereumTransaction {
interestingTransactions := make([]*ethereum.EthereumTransaction, 0)
for _, tx := range fetchedBlock.Block.Transactions {
txReceipt, ok := fetchedBlock.TxReceipts[tx.Hash.Value()]
if !ok {
Expand Down Expand Up @@ -289,8 +289,8 @@ func (idx *Indexer) FilterInterestingTransactions(

func (idx *Indexer) IndexTransaction(
block *storage.Block,
tx *ethereum2.EthereumTransaction,
receipt *ethereum2.EthereumTransactionReceipt,
tx *ethereum.EthereumTransaction,
receipt *ethereum.EthereumTransactionReceipt,
) (*storage.Transaction, error) {
return idx.MetadataStore.InsertBlockTransaction(
block.Number,
Expand All @@ -304,8 +304,8 @@ func (idx *Indexer) IndexTransaction(
}

func (idx *Indexer) FindAndHandleContractCreationForTransactions(
transactions []*ethereum2.EthereumTransaction,
receipts map[string]*ethereum2.EthereumTransactionReceipt,
transactions []*ethereum.EthereumTransaction,
receipts map[string]*ethereum.EthereumTransactionReceipt,
contractStorage map[string]string,
blockNumber uint64,
) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/pipeline/pipeline_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/Layr-Labs/go-sidecar/pkg/indexer"
"github.com/Layr-Labs/go-sidecar/pkg/postgres"
"github.com/Layr-Labs/go-sidecar/pkg/storage"
postgres2 "github.com/Layr-Labs/go-sidecar/pkg/storage/postgres"
pgStorage "github.com/Layr-Labs/go-sidecar/pkg/storage/postgres"
"log"
"testing"

Expand Down Expand Up @@ -82,7 +82,7 @@ func setup() (

cm := contractManager.NewContractManager(contractStore, etherscanClient, client, sdc, l)

mds := postgres2.NewPostgresBlockStore(grm, l, cfg)
mds := pgStorage.NewPostgresBlockStore(grm, l, cfg)

sm := stateManager.NewEigenStateManager(l, grm)

Expand Down
4 changes: 2 additions & 2 deletions pkg/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package postgres

import (
"github.com/Layr-Labs/go-sidecar/internal/config"
logger2 "github.com/Layr-Labs/go-sidecar/internal/logger"
"github.com/Layr-Labs/go-sidecar/internal/logger"
"github.com/Layr-Labs/go-sidecar/internal/tests"
"github.com/Layr-Labs/go-sidecar/pkg/postgres/migrations"
"testing"
Expand All @@ -18,7 +18,7 @@ func Test_Postgres(t *testing.T) {
}
cfg.DatabaseConfig.DbName = testDbName

l, _ := logger2.NewLogger(&logger2.LoggerConfig{Debug: true})
l, _ := logger.NewLogger(&logger.LoggerConfig{Debug: true})

pgConfig := PostgresConfigFromDbConfig(&cfg.DatabaseConfig)
pgConfig.CreateDbIfNotExists = true
Expand Down

0 comments on commit 8e9a1a9

Please sign in to comment.