Skip to content

Commit

Permalink
Use hardfork dates when getting migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Feb 4, 2025
1 parent 2f72e74 commit 4719df7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
9 changes: 7 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ func (c *Config) GetRewardsSqlForkDates() (ForkMap, error) {
Date: "2025-01-09",
},
RewardsFork_Mississippi: Fork{
Date: "2025-02-04",
Date: "2025-02-04",
BlockNumber: 3287006,
},
}, nil
case Chain_Holesky:
Expand All @@ -336,7 +337,8 @@ func (c *Config) GetRewardsSqlForkDates() (ForkMap, error) {
Date: "2025-01-09",
},
RewardsFork_Mississippi: Fork{
Date: "2025-02-10",
Date: "2025-02-10",
BlockNumber: 3323306,
},
}, nil
case Chain_Mainnet:
Expand All @@ -358,6 +360,9 @@ func (c *Config) GetRewardsSqlForkDates() (ForkMap, error) {
},
RewardsFork_Mississippi: Fork{
Date: "2025-03-27",
// mississippi fork on mainnet doesnt have a fork date since we didnt need to backfill
// any data for it like we did for preprod and holesky
BlockNumber: 0,
},
}, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func (sm *StateMigration) GetMigrationName() string {
}

func (sm *StateMigration) MigrateState(currentBlockNumber uint64) ([][]byte, error) {
// This migration only applies to preprod and holesky. Mainnet will be released with all
// of these features (slashing, rewards v2.1) at once rather than iteratively like we did
// with preprod and holesky
if sm.globalConfig.Chain == config.Chain_Mainnet {
sm.logger.Sugar().Infof("No migration needed for mainnet")
return nil, nil
Expand Down
27 changes: 10 additions & 17 deletions pkg/eigenState/stateMigrator/stateMigrator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package stateMigrator

import (
"fmt"
"github.com/Layr-Labs/sidecar/internal/config"
_02502031222_operatorSets "github.com/Layr-Labs/sidecar/pkg/eigenState/stateMigrator/stateMigrations/202502031222_operatorSets"
"github.com/Layr-Labs/sidecar/pkg/eigenState/stateMigrator/types"
Expand Down Expand Up @@ -29,23 +28,17 @@ func NewStateMigrator(grm *gorm.DB, cfg *config.Config, l *zap.Logger) *StateMig
// getMigrations returns a map of block numbers to migrations that should be run at that block number
// taking the chain into account
func (sm *StateMigrator) getMigrations() (map[uint64][]types.IStateMigration, error) {
switch sm.globalConfig.Chain {
case config.Chain_Preprod:
return map[uint64][]types.IStateMigration{
3286029: {
_02502031222_operatorSets.NewStateMigration(sm.db, sm.logger, sm.globalConfig),
},
}, nil
case config.Chain_Holesky:
return map[uint64][]types.IStateMigration{
3286029: {
_02502031222_operatorSets.NewStateMigration(sm.db, sm.logger, sm.globalConfig),
},
}, nil
case config.Chain_Mainnet:
return map[uint64][]types.IStateMigration{}, nil
forks, err := sm.globalConfig.GetRewardsSqlForkDates()
if err != nil {
return nil, err
}
return nil, fmt.Errorf("no migrations found for chain %s", sm.globalConfig.Chain)

return map[uint64][]types.IStateMigration{
// Mississippi hard fork. Applies to preprod and holesky to materialize EigenState models for operator sets
forks[config.RewardsFork_Mississippi].BlockNumber: {
_02502031222_operatorSets.NewStateMigration(sm.db, sm.logger, sm.globalConfig),
},
}, nil
}

// GetMigrationsForBlock returns a list of migrations that should be run at the given block number
Expand Down

0 comments on commit 4719df7

Please sign in to comment.