Skip to content

Commit

Permalink
things are running;
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Sep 8, 2024
1 parent 1c51888 commit 1ee7fc2
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ block-lake/preprod-values.yaml
./block-lake/preprod-values.yaml
/scripts/runLocal
*.db*
sqlite
4 changes: 3 additions & 1 deletion cmd/sidecar/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ func main() {
}

migrator := migrations.NewSqliteMigrator(grm, l)
migrator.MigrateAll()
if err = migrator.MigrateAll(); err != nil {
log.Fatalf("Failed to migrate: %v", err)
}

contractStore := sqliteContractStore.NewSqliteContractStore(grm, l, cfg)
if err := contractStore.InitializeCoreContracts(); err != nil {
log.Fatalf("Failed to initialize core contracts: %v", err)
}

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

Expand Down
13 changes: 0 additions & 13 deletions ideas.md

This file was deleted.

2 changes: 1 addition & 1 deletion internal/eigenState/eigenstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func Test_EigenStateManager(t *testing.T) {
err = esm.InitProcessingForBlock(200)
assert.Nil(t, err)

root, err := esm.GenerateStateRoot(200)
root, err := esm.GenerateStateRoot(200, "0x123")
assert.Nil(t, err)
assert.True(t, len(root) > 0)
})
Expand Down
3 changes: 2 additions & 1 deletion internal/eigenState/stateManager/stateManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ func (e *EigenStateManager) CommitFinalState(blockNumber uint64) error {
return nil
}

func (e *EigenStateManager) GenerateStateRoot(blockNumber uint64) (types.StateRoot, error) {
func (e *EigenStateManager) GenerateStateRoot(blockNumber uint64, blockHash string) (types.StateRoot, error) {
sortedIndexes := e.GetSortedModelIndexes()
roots := [][]byte{
[]byte(fmt.Sprintf("%d", blockNumber)),
[]byte(blockHash),
}

for _, state := range sortedIndexes {
Expand Down
13 changes: 7 additions & 6 deletions internal/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func (p *Pipeline) RunForBlock(ctx context.Context, blockNumber uint64) error {
p.Logger.Sugar().Errorw("Failed to init processing for block", zap.Uint64("blockNumber", blockNumber), zap.Error(err))
return err
}
p.Logger.Sugar().Infow("Initialized processing for block", zap.Uint64("blockNumber", blockNumber))

// Parse all transactions and logs for the block.
// - If a transaction is not calling to a contract, it is ignored
Expand Down Expand Up @@ -142,20 +143,20 @@ func (p *Pipeline) RunForBlock(ctx context.Context, blockNumber uint64) error {
}
}

// Handle contract creation for transactions
interestingTransactions := p.Indexer.FilterInterestingTransactions(indexedBlock, block)
if len(interestingTransactions) == 0 {
p.Logger.Sugar().Debugw("No interesting transactions found, no need to create any new contracts", zap.Uint64("blockNumber", blockNumber))
return nil
if len(interestingTransactions) > 0 {
// If we have interesting transactions, check for contract creations.
// Really though this probably should never get reached since we only care about interesting transactions
// which are hard coded and any implementations of proxies would get get processed above as part of the upgrade check
p.Indexer.FindAndHandleContractCreationForTransactions(interestingTransactions, block.TxReceipts, block.ContractStorage, blockNumber)
}
p.Indexer.FindAndHandleContractCreationForTransactions(interestingTransactions, block.TxReceipts, block.ContractStorage, blockNumber)

if err := p.stateManager.CommitFinalState(blockNumber); err != nil {
p.Logger.Sugar().Errorw("Failed to commit final state", zap.Uint64("blockNumber", blockNumber), zap.Error(err))
return err
}

stateRoot, err := p.stateManager.GenerateStateRoot(blockNumber)
stateRoot, err := p.stateManager.GenerateStateRoot(blockNumber, block.Block.Hash.Value())
if err != nil {
p.Logger.Sugar().Errorw("Failed to generate state root", zap.Uint64("blockNumber", blockNumber), zap.Error(err))
return err
Expand Down
1 change: 1 addition & 0 deletions internal/sqlite/migrations/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (m *SqliteMigrator) MigrateAll() error {
&_202409080918_staterootTable.SqliteMigration{},
}

m.Logger.Sugar().Info("Running migrations")
for _, migration := range migrations {
err := m.Migrate(migration)
if err != nil {
Expand Down

0 comments on commit 1ee7fc2

Please sign in to comment.