Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
serichoi65 committed Feb 12, 2025
1 parent 701f4f0 commit 84426bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
6 changes: 2 additions & 4 deletions pkg/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ func (idx *Indexer) ParseInterestingTransactionsAndLogs(ctx context.Context, fet
return parsedTransactions, nil
}

// or should this be in transactionLogs.go?
// why do we need ctx context.Context and do we need it here?
func (idx *Indexer) IndexContractUpgrade(fetchedBlock *fetcher.FetchedBlock, upgradedLog *storage.TransactionLog) {
blockNumber := fetchedBlock.Block.Number.Value()
func (idx *Indexer) IndexContractUpgrade(ctx context.Context, blockNumber uint64, upgradedLog *storage.TransactionLog) error {
// the new address that the contract points to
newProxiedAddress := ""

Expand Down Expand Up @@ -202,6 +199,7 @@ func (idx *Indexer) IndexContractUpgrade(fetchedBlock *fetcher.FetchedBlock, upg
return
}
idx.Logger.Sugar().Infow("Upgraded proxy contract", zap.String("contractAddress", upgradedLog.Address), zap.String("proxyContractAddress", newProxiedAddress))
return nil
}

func (idx *Indexer) IndexFetchedBlock(fetchedBlock *fetcher.FetchedBlock) (*storage.Block, bool, error) {
Expand Down
24 changes: 4 additions & 20 deletions pkg/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func (p *Pipeline) RunForFetchedBlock(ctx context.Context, block *fetcher.Fetche
// With only interesting transactions/logs parsed, insert them into the database
indexedTransactions := make([]*storage.Transaction, 0)
indexedTransactionLogs := make([]*storage.TransactionLog, 0)
contractUpgradedLogs := make([]*storage.TransactionLog, 0)
blockFetchTime = time.Now()
for _, pt := range parsedTransactions {
transactionTime := time.Now()
Expand Down Expand Up @@ -162,13 +161,6 @@ func (p *Pipeline) RunForFetchedBlock(ctx context.Context, block *fetcher.Fetche
zap.String("transactionHash", indexedTransaction.TransactionHash),
zap.Uint64("logIndex", log.LogIndex),
)
// block-lake/internal/indexer/indexer.go
// find contract upgraded logs here?
if log.EventName == "Upgraded" {
contractUpgradedLogs = append(contractUpgradedLogs, log)
// or maybe don't make it into a list and upgrade here directly
// idx.IndexContractUpgrade(blockNumber, log, reindexContract)
}

if err := p.stateManager.HandleLogStateChange(indexedLog); err != nil {
p.Logger.Sugar().Errorw("Failed to handle log state change",
Expand All @@ -189,6 +181,10 @@ func (p *Pipeline) RunForFetchedBlock(ctx context.Context, block *fetcher.Fetche
)
return err
}

if log.EventName == "Upgraded" {
p.Indexer.IndexContractUpgrade(ctx, blockNumber, log)
}
}
p.Logger.Sugar().Debugw("Handled log state changes",
zap.Uint64("blockNumber", blockNumber),
Expand All @@ -200,18 +196,6 @@ func (p *Pipeline) RunForFetchedBlock(ctx context.Context, block *fetcher.Fetche
zap.Uint64("blockNumber", blockNumber),
zap.Int64("indexTime", time.Since(blockFetchTime).Milliseconds()),
)

if len(contractUpgradedLogs) > 0 {
p.Logger.Sugar().Debugw("Found contract upgrade logs",
zap.Uint64("blockNumber", blockNumber),
zap.String("transactionHash", indexedTransaction.TransactionHash),
zap.Uint64("count", len(contractUpgradedLogs)),
)
if err := p.Indexer.IndexContractUpgrades(block.Block.Number.Value()); err != nil {
p.Logger.Sugar().Errorw("Failed to index contract upgrades", zap.Uint64("blockNumber", block.Block.Number.Value()), zap.Error(err))
return err
}
}

if block.Block.Number.Value()%3600 == 0 {
p.Logger.Sugar().Infow("Indexing OperatorRestakedStrategies", zap.Uint64("blockNumber", block.Block.Number.Value()))
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ type BatchTransaction struct {
BytecodeHash string
}

// do i need to add type here?

type OperatorRestakedStrategies struct {
AvsDirectoryAddress string
BlockNumber uint64
Expand Down

0 comments on commit 84426bb

Please sign in to comment.