From 952e46014c64cd462301b7ab6123443874b9b009 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Thu, 9 Jan 2025 10:27:48 -0600 Subject: [PATCH] feat: add leaf format forking logic for ODRewardSubmissions set block height for fork --- internal/config/config.go | 86 ++++++++++---- .../operatorAVSSplits/operatorAVSSplits.go | 43 ++++++- .../operatorDirectedRewardSubmissions.go | 107 +++++++++++++++--- .../operatorPISplits/operatorPISplits.go | 41 ++++++- .../up.go | 40 ------- pkg/postgres/migrations/migrator.go | 2 - pkg/rewards/2_goldStakerRewardAmounts.go | 16 +-- pkg/rewards/5_goldRfaeStakers.go | 10 +- pkg/rewards/8_goldOperatorODRewardAmounts.go | 4 +- pkg/rewards/9_goldStakerODRewardAmounts.go | 4 +- pkg/rewards/rewards.go | 2 +- pkg/rewards/rewardsV2_test.go | 2 +- pkg/rewards/rewards_test.go | 2 +- .../1_stakerStrategyPayouts.go | 4 +- pkg/rewards/stakerOperators/stakerOperator.go | 2 +- 15 files changed, 250 insertions(+), 115 deletions(-) delete mode 100644 pkg/postgres/migrations/202501061613_reindexTestnetForStaterootChange/up.go diff --git a/internal/config/config.go b/internal/config/config.go index d4cde4c5..0b8249d2 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -3,6 +3,7 @@ package config import ( "errors" "fmt" + "slices" "strconv" "strings" "time" @@ -28,15 +29,18 @@ const ( Chain_Holesky Chain = "holesky" Chain_Preprod Chain = "preprod" - Fork_Nile ForkName = "nile" - Fork_Amazon ForkName = "amazon" - Fork_Panama ForkName = "panama" - Fork_Arno ForkName = "arno" - Fork_Trinity ForkName = "trinity" - ENV_PREFIX = "SIDECAR" ) +// Rewards forks named after rivers +const ( + RewardsFork_Nile ForkName = "nile" + RewardsFork_Amazon ForkName = "amazon" + RewardsFork_Panama ForkName = "panama" + RewardsFork_Arno ForkName = "arno" + RewardsFork_Trinity ForkName = "trinity" +) + func normalizeFlagName(name string) string { return strings.ReplaceAll(name, "-", "_") } @@ -188,6 +192,10 @@ type ContractAddresses struct { AvsDirectory string } +func (c *Config) ChainIsOneOf(chains ...Chain) bool { + return slices.Contains(chains, c.Chain) +} + func (c *Config) GetContractsMapForChain() *ContractAddresses { if c.Chain == Chain_Preprod { return &ContractAddresses{ @@ -249,34 +257,62 @@ func (c *Config) GetGenesisBlockNumber() uint64 { type ForkMap map[ForkName]string -func (c *Config) GetForkDates() (ForkMap, error) { +func (c *Config) GetRewardsSqlForkDates() (ForkMap, error) { switch c.Chain { case Chain_Preprod: return ForkMap{ - Fork_Amazon: "1970-01-01", // Amazon hard fork was never on preprod as we backfilled - Fork_Nile: "2024-08-14", // Last calculation end timestamp was 8-13: https://holesky.etherscan.io/tx/0xb5a6855e88c79312b7c0e1c9f59ae9890b97f157ea27e69e4f0fadada4712b64#eventlog - Fork_Panama: "2024-10-01", - Fork_Arno: "2024-12-13", - Fork_Trinity: "2025-01-09", + RewardsFork_Amazon: "1970-01-01", // Amazon hard fork was never on preprod as we backfilled + RewardsFork_Nile: "2024-08-14", // Last calculation end timestamp was 8-13: https://holesky.etherscan.io/tx/0xb5a6855e88c79312b7c0e1c9f59ae9890b97f157ea27e69e4f0fadada4712b64#eventlog + RewardsFork_Panama: "2024-10-01", + RewardsFork_Arno: "2024-12-11", + RewardsFork_Trinity: "2025-01-09", }, nil case Chain_Holesky: return ForkMap{ - Fork_Amazon: "1970-01-01", // Amazon hard fork was never on testnet as we backfilled - Fork_Nile: "2024-08-13", // Last calculation end timestamp was 8-12: https://holesky.etherscan.io/tx/0x5fc81b5ed2a78b017ef313c181d8627737a97fef87eee85acedbe39fc8708c56#eventlog - Fork_Panama: "2024-10-01", - Fork_Arno: "2024-12-13", - Fork_Trinity: "2025-01-09", + RewardsFork_Amazon: "1970-01-01", // Amazon hard fork was never on testnet as we backfilled + RewardsFork_Nile: "2024-08-13", // Last calculation end timestamp was 8-12: https://holesky.etherscan.io/tx/0x5fc81b5ed2a78b017ef313c181d8627737a97fef87eee85acedbe39fc8708c56#eventlog + RewardsFork_Panama: "2024-10-01", + RewardsFork_Arno: "2024-12-13", + RewardsFork_Trinity: "2025-01-09", }, nil case Chain_Mainnet: return ForkMap{ - Fork_Amazon: "2024-08-02", // Last calculation end timestamp was 8-01: https://etherscan.io/tx/0x2aff6f7b0132092c05c8f6f41a5e5eeeb208aa0d95ebcc9022d7823e343dd012#eventlog - Fork_Nile: "2024-08-12", // Last calculation end timestamp was 8-11: https://etherscan.io/tx/0x922d29d93c02d189fc2332041f01a80e0007cd7a625a5663ef9d30082f7ef66f#eventlog - Fork_Panama: "2024-10-01", - Fork_Arno: "2025-01-21", - Fork_Trinity: "2025-01-21", + RewardsFork_Amazon: "2024-08-02", // Last calculation end timestamp was 8-01: https://etherscan.io/tx/0x2aff6f7b0132092c05c8f6f41a5e5eeeb208aa0d95ebcc9022d7823e343dd012#eventlog + RewardsFork_Nile: "2024-08-12", // Last calculation end timestamp was 8-11: https://etherscan.io/tx/0x922d29d93c02d189fc2332041f01a80e0007cd7a625a5663ef9d30082f7ef66f#eventlog + RewardsFork_Panama: "2024-10-01", + RewardsFork_Arno: "2025-01-21", + RewardsFork_Trinity: "2025-01-21", + }, nil + } + return nil, errors.New("unsupported chain") +} + +type ModelForkMap map[ForkName]uint64 + +// Model forks, named after US capitols +const ( + // ModelFork_Austin changes the formatting for merkel leaves in: ODRewardSubmissions, OperatorAVSSplits, and + // OperatorPISplits based on feedback from the rewards-v2 audit + ModelFork_Austin ForkName = "austin" +) + +func (c *Config) GetModelForks() (ModelForkMap, error) { + switch c.Chain { + case Chain_Preprod: + return ModelForkMap{ + ModelFork_Austin: 3113600, + }, nil + case Chain_Holesky: + return ModelForkMap{ + ModelFork_Austin: 3113600, + }, nil + case Chain_Mainnet: + return ModelForkMap{ + ModelFork_Austin: 0, // doesnt apply to mainnet }, nil } return nil, errors.New("unsupported chain") + } func (c *Config) GetEigenLayerGenesisBlockHeight() (uint64, error) { @@ -302,7 +338,7 @@ func (c *Config) GetOperatorRestakedStrategiesStartBlock() uint64 { } func (c *Config) IsRewardsV2EnabledForCutoffDate(cutoffDate string) (bool, error) { - forks, err := c.GetForkDates() + forks, err := c.GetRewardsSqlForkDates() if err != nil { return false, err } @@ -310,9 +346,9 @@ func (c *Config) IsRewardsV2EnabledForCutoffDate(cutoffDate string) (bool, error if err != nil { return false, errors.Join(fmt.Errorf("failed to parse cutoff date %s", cutoffDate), err) } - arnoForkDateTime, err := time.Parse(time.DateOnly, forks[Fork_Arno]) + arnoForkDateTime, err := time.Parse(time.DateOnly, forks[RewardsFork_Arno]) if err != nil { - return false, errors.Join(fmt.Errorf("failed to parse Arno fork date %s", forks[Fork_Arno]), err) + return false, errors.Join(fmt.Errorf("failed to parse Arno fork date %s", forks[RewardsFork_Arno]), err) } return cutoffDateTime.Compare(arnoForkDateTime) >= 0, nil diff --git a/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go b/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go index 72c8e2d4..c66fcb44 100644 --- a/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go +++ b/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go @@ -234,7 +234,10 @@ func (oas *OperatorAVSSplitModel) GenerateStateRoot(blockNumber uint64) ([]byte, return nil, err } - inputs := oas.sortValuesForMerkleTree(inserts) + inputs, err := oas.sortValuesForMerkleTree(inserts) + if err != nil { + return nil, err + } if len(inputs) == 0 { return nil, nil @@ -252,11 +255,43 @@ func (oas *OperatorAVSSplitModel) GenerateStateRoot(blockNumber uint64) ([]byte, return fullTree.Root(), nil } -func (oas *OperatorAVSSplitModel) sortValuesForMerkleTree(splits []*OperatorAVSSplit) []*base.MerkleTreeInput { +func (oas *OperatorAVSSplitModel) formatMerkleLeafValue( + blockNumber uint64, + operator string, + avs string, + activatedAt *time.Time, + oldOperatorAVSSplitBips uint64, + newOperatorAVSSplitBips uint64, +) (string, error) { + modelForks, err := oas.globalConfig.GetModelForks() + if err != nil { + return "", err + } + if oas.globalConfig.ChainIsOneOf(config.Chain_Holesky, config.Chain_Preprod) && blockNumber < modelForks[config.ModelFork_Austin] { + // This format was used on preprod and testnet for rewards-v2 before launching to mainnet + return fmt.Sprintf("%s_%s_%d_%d_%d", operator, avs, activatedAt.Unix(), oldOperatorAVSSplitBips, newOperatorAVSSplitBips), nil + } + + return fmt.Sprintf("%s_%s_%016x_%016x_%016x", operator, avs, activatedAt.Unix(), oldOperatorAVSSplitBips, newOperatorAVSSplitBips), nil +} + +func (oas *OperatorAVSSplitModel) sortValuesForMerkleTree(splits []*OperatorAVSSplit) ([]*base.MerkleTreeInput, error) { inputs := make([]*base.MerkleTreeInput, 0) for _, split := range splits { slotID := base.NewSlotID(split.TransactionHash, split.LogIndex) - value := fmt.Sprintf("%s_%s_%016x_%016x_%016x", split.Operator, split.Avs, split.ActivatedAt.Unix(), split.OldOperatorAVSSplitBips, split.NewOperatorAVSSplitBips) + value, err := oas.formatMerkleLeafValue(split.BlockNumber, split.Operator, split.Avs, split.ActivatedAt, split.OldOperatorAVSSplitBips, split.NewOperatorAVSSplitBips) + if err != nil { + oas.logger.Sugar().Errorw("Failed to format merkle leaf value", + zap.Error(err), + zap.Uint64("blockNumber", split.BlockNumber), + zap.String("operator", split.Operator), + zap.String("avs", split.Avs), + zap.Time("activatedAt", *split.ActivatedAt), + zap.Uint64("oldOperatorAVSSplitBips", split.OldOperatorAVSSplitBips), + zap.Uint64("newOperatorAVSSplitBips", split.NewOperatorAVSSplitBips), + ) + return nil, err + } inputs = append(inputs, &base.MerkleTreeInput{ SlotID: slotID, Value: []byte(value), @@ -267,7 +302,7 @@ func (oas *OperatorAVSSplitModel) sortValuesForMerkleTree(splits []*OperatorAVSS return strings.Compare(string(i.SlotID), string(j.SlotID)) }) - return inputs + return inputs, nil } func (oas *OperatorAVSSplitModel) DeleteState(startBlockNumber uint64, endBlockNumber uint64) error { diff --git a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go index dc86c990..318911d5 100644 --- a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go +++ b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go @@ -39,10 +39,6 @@ type OperatorDirectedRewardSubmission struct { LogIndex uint64 } -func NewSlotID(transactionHash string, logIndex uint64, rewardHash string, strategyIndex uint64, operatorIndex uint64) types.SlotID { - return base.NewSlotIDWithSuffix(transactionHash, logIndex, fmt.Sprintf("%s_%016x_%016x", rewardHash, strategyIndex, operatorIndex)) -} - type OperatorDirectedRewardSubmissionsModel struct { base.BaseEigenState StateTransitions types.StateTransitions[[]*OperatorDirectedRewardSubmission] @@ -80,6 +76,25 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) GetModelName() string { return "OperatorDirectedRewardSubmissionsModel" } +func (odrs *OperatorDirectedRewardSubmissionsModel) NewSlotID( + blockNumber uint64, + transactionHash string, + logIndex uint64, + rewardHash string, + strategyIndex uint64, + operatorIndex uint64, +) (types.SlotID, error) { + forks, err := odrs.globalConfig.GetModelForks() + if err != nil { + return "", err + } + if odrs.globalConfig.ChainIsOneOf(config.Chain_Holesky, config.Chain_Preprod) && blockNumber < forks[config.ModelFork_Austin] { + // This format was used on preprod and testnet for rewards-v2 before launching to mainnet + return base.NewSlotIDWithSuffix(transactionHash, logIndex, fmt.Sprintf("%s_%d_%d", rewardHash, strategyIndex, operatorIndex)), nil + } + return base.NewSlotIDWithSuffix(transactionHash, logIndex, fmt.Sprintf("%s_%016x_%016x", rewardHash, strategyIndex, operatorIndex)), nil +} + type operatorDirectedRewardData struct { StrategiesAndMultipliers []struct { Strategy string `json:"strategy"` @@ -178,7 +193,19 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) GetStateTransitions() (types } for _, rewardSubmission := range rewardSubmissions { - slotId := NewSlotID(rewardSubmission.TransactionHash, rewardSubmission.LogIndex, rewardSubmission.RewardHash, rewardSubmission.StrategyIndex, rewardSubmission.OperatorIndex) + slotId, err := odrs.NewSlotID(log.BlockNumber, rewardSubmission.TransactionHash, rewardSubmission.LogIndex, rewardSubmission.RewardHash, rewardSubmission.StrategyIndex, rewardSubmission.OperatorIndex) + if err != nil { + odrs.logger.Sugar().Errorw("Failed to create slot ID", + zap.Uint64("blockNumber", log.BlockNumber), + zap.String("transactionHash", log.TransactionHash), + zap.Uint64("logIndex", log.LogIndex), + zap.String("rewardHash", rewardSubmission.RewardHash), + zap.Uint64("strategyIndex", rewardSubmission.StrategyIndex), + zap.Uint64("operatorIndex", rewardSubmission.OperatorIndex), + zap.Error(err), + ) + return nil, err + } _, ok := odrs.stateAccumulator[log.BlockNumber][slotId] if ok { @@ -313,24 +340,70 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) GenerateStateRoot(blockNumbe return fullTree.Root(), nil } +func (odrs *OperatorDirectedRewardSubmissionsModel) formatMerkleLeafValue( + blockNumber uint64, + rewardHash string, + strategy string, + multiplier string, + operator string, + amount string, +) (string, error) { + modelForks, err := odrs.globalConfig.GetModelForks() + if err != nil { + return "", err + } + + if odrs.globalConfig.ChainIsOneOf(config.Chain_Holesky, config.Chain_Preprod) && blockNumber < modelForks[config.ModelFork_Austin] { + // This format was used on preprod and testnet for rewards-v2 before launching to mainnet + return fmt.Sprintf("%s_%s_%s_%s_%s", rewardHash, strategy, multiplier, operator, amount), nil + } + // Following was fixed as part of the rewards-v2 audit feedback before launching on mainnet. + // + // Multiplier is a uint96 in the contracts, which translates to 24 hex characters + // Amount is a uint256 in the contracts, which translates to 64 hex characters + multiplierBig, success := new(big.Int).SetString(multiplier, 10) + if !success { + return "", fmt.Errorf("failed to parse multiplier to BigInt: %s", multiplier) + } + + amountBig, success := new(big.Int).SetString(amount, 10) + if !success { + return "", fmt.Errorf("failed to parse amount to BigInt: %s", amount) + } + + return fmt.Sprintf("%s_%s_%024x_%s_%064x", rewardHash, strategy, multiplierBig, operator, amountBig), nil +} + func (odrs *OperatorDirectedRewardSubmissionsModel) sortValuesForMerkleTree(submissions []*OperatorDirectedRewardSubmission) ([]*base.MerkleTreeInput, error) { inputs := make([]*base.MerkleTreeInput, 0) for _, submission := range submissions { - slotID := NewSlotID(submission.TransactionHash, submission.LogIndex, submission.RewardHash, submission.StrategyIndex, submission.OperatorIndex) - - multiplierBig, success := new(big.Int).SetString(submission.Multiplier, 10) - if !success { - return nil, fmt.Errorf("failed to parse multiplier to BigInt: %s", submission.Multiplier) + slotID, err := odrs.NewSlotID(submission.BlockNumber, submission.TransactionHash, submission.LogIndex, submission.RewardHash, submission.StrategyIndex, submission.OperatorIndex) + if err != nil { + odrs.logger.Sugar().Errorw("Failed to create slot ID", + zap.Uint64("blockNumber", submission.BlockNumber), + zap.String("transactionHash", submission.TransactionHash), + zap.Uint64("logIndex", submission.LogIndex), + zap.String("rewardHash", submission.RewardHash), + zap.Uint64("strategyIndex", submission.StrategyIndex), + zap.Uint64("operatorIndex", submission.OperatorIndex), + zap.Error(err), + ) + return nil, err } - amountBig, success := new(big.Int).SetString(submission.Amount, 10) - if !success { - return nil, fmt.Errorf("failed to parse amount to BigInt: %s", submission.Amount) + value, err := odrs.formatMerkleLeafValue(submission.BlockNumber, submission.RewardHash, submission.Strategy, submission.Multiplier, submission.Operator, submission.Amount) + if err != nil { + odrs.Logger.Sugar().Errorw("Failed to format merkle leaf value", + zap.Error(err), + zap.Uint64("blockNumber", submission.BlockNumber), + zap.String("rewardHash", submission.RewardHash), + zap.String("strategy", submission.Strategy), + zap.String("multiplier", submission.Multiplier), + zap.String("operator", submission.Operator), + zap.String("amount", submission.Amount), + ) + return nil, err } - - // Multiplier is a uint96 in the contracts, which translates to 24 hex characters - // Amount is a uint256 in the contracts, which translates to 64 hex characters - value := fmt.Sprintf("%s_%s_%024x_%s_%064x", submission.RewardHash, submission.Strategy, multiplierBig, submission.Operator, amountBig) inputs = append(inputs, &base.MerkleTreeInput{ SlotID: slotID, Value: []byte(value), diff --git a/pkg/eigenState/operatorPISplits/operatorPISplits.go b/pkg/eigenState/operatorPISplits/operatorPISplits.go index 00387b00..bd0343e2 100644 --- a/pkg/eigenState/operatorPISplits/operatorPISplits.go +++ b/pkg/eigenState/operatorPISplits/operatorPISplits.go @@ -232,7 +232,10 @@ func (ops *OperatorPISplitModel) GenerateStateRoot(blockNumber uint64) ([]byte, return nil, err } - inputs := ops.sortValuesForMerkleTree(inserts) + inputs, err := ops.sortValuesForMerkleTree(inserts) + if err != nil { + return nil, err + } if len(inputs) == 0 { return nil, nil @@ -250,11 +253,41 @@ func (ops *OperatorPISplitModel) GenerateStateRoot(blockNumber uint64) ([]byte, return fullTree.Root(), nil } -func (ops *OperatorPISplitModel) sortValuesForMerkleTree(splits []*OperatorPISplit) []*base.MerkleTreeInput { +func (ops *OperatorPISplitModel) formatMerkleLeafValue( + blockNumber uint64, + operator string, + activatedAt *time.Time, + oldOperatorPISplitBips uint64, + newOperatorPISplitBips uint64, +) (string, error) { + modelForks, err := ops.globalConfig.GetModelForks() + if err != nil { + return "", err + } + if ops.globalConfig.ChainIsOneOf(config.Chain_Holesky, config.Chain_Preprod) && blockNumber < modelForks[config.ModelFork_Austin] { + // This format was used on preprod and testnet for rewards-v2 before launching to mainnet + return fmt.Sprintf("%s_%d_%d_%d", operator, activatedAt.Unix(), oldOperatorPISplitBips, newOperatorPISplitBips), nil + } + + return fmt.Sprintf("%s_%016x_%016x_%016x", operator, activatedAt.Unix(), oldOperatorPISplitBips, newOperatorPISplitBips), nil +} + +func (ops *OperatorPISplitModel) sortValuesForMerkleTree(splits []*OperatorPISplit) ([]*base.MerkleTreeInput, error) { inputs := make([]*base.MerkleTreeInput, 0) for _, split := range splits { slotID := base.NewSlotID(split.TransactionHash, split.LogIndex) - value := fmt.Sprintf("%s_%016x_%016x_%016x", split.Operator, split.ActivatedAt.Unix(), split.OldOperatorPISplitBips, split.NewOperatorPISplitBips) + value, err := ops.formatMerkleLeafValue(split.BlockNumber, split.Operator, split.ActivatedAt, split.OldOperatorPISplitBips, split.NewOperatorPISplitBips) + if err != nil { + ops.logger.Sugar().Errorw("Failed to format merkle leaf value", + zap.Error(err), + zap.Uint64("blockNumber", split.BlockNumber), + zap.String("operator", split.Operator), + zap.Time("activatedAt", *split.ActivatedAt), + zap.Uint64("oldOperatorPISplitBips", split.OldOperatorPISplitBips), + zap.Uint64("newOperatorPISplitBips", split.NewOperatorPISplitBips), + ) + return nil, err + } inputs = append(inputs, &base.MerkleTreeInput{ SlotID: slotID, Value: []byte(value), @@ -265,7 +298,7 @@ func (ops *OperatorPISplitModel) sortValuesForMerkleTree(splits []*OperatorPISpl return strings.Compare(string(i.SlotID), string(j.SlotID)) }) - return inputs + return inputs, nil } func (ops *OperatorPISplitModel) DeleteState(startBlockNumber uint64, endBlockNumber uint64) error { diff --git a/pkg/postgres/migrations/202501061613_reindexTestnetForStaterootChange/up.go b/pkg/postgres/migrations/202501061613_reindexTestnetForStaterootChange/up.go deleted file mode 100644 index b68df489..00000000 --- a/pkg/postgres/migrations/202501061613_reindexTestnetForStaterootChange/up.go +++ /dev/null @@ -1,40 +0,0 @@ -package _202501061613_reindexTestnetForStaterootChange - -import ( - "database/sql" - "github.com/Layr-Labs/sidecar/internal/config" - "gorm.io/gorm" -) - -type Migration struct { -} - -// Up -// In response to the rewards-v2 audit, we needed to change how a couple of model state roots -// were calculated. While this doesnt affect rewards generation, it does affect state roots that -// have already been calculated and stored for preprod and testnet. To ensure that all state roots -// are consistent, we need to prune back to the block where rewards-v2 was first deployed to allow -// rewards to be recaclulated with the new state root calculation. -func (m *Migration) Up(db *sql.DB, grm *gorm.DB, cfg *config.Config) error { - var blockNumber uint64 - if cfg.Chain == config.Chain_Preprod { - blockNumber = 2871556 - } else if cfg.Chain == config.Chain_Holesky { - blockNumber = 2930139 - } else { - // chain doesnt require pruning - return nil - } - - query := `delete from blocks where number >= @blockNumber` - - res := grm.Exec(query, sql.Named("blockNumber", blockNumber)) - if res.Error != nil { - return res.Error - } - return nil -} - -func (m *Migration) GetName() string { - return "202501061613_reindexTestnetForStaterootChange" -} diff --git a/pkg/postgres/migrations/migrator.go b/pkg/postgres/migrations/migrator.go index d0df9b11..85456d35 100644 --- a/pkg/postgres/migrations/migrator.go +++ b/pkg/postgres/migrations/migrator.go @@ -47,7 +47,6 @@ import ( _202412091100_fixOperatorPiSplitsFields "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202412091100_fixOperatorPiSplitsFields" _202501061029_addDescription "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202501061029_addDescription" _202501061422_defaultOperatorSplits "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202501061422_defaultOperatorSplits" - _202501061613_reindexTestnetForStaterootChange "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202501061613_reindexTestnetForStaterootChange" _202501071401_defaultOperatorSplitSnapshots "github.com/Layr-Labs/sidecar/pkg/postgres/migrations/202501071401_defaultOperatorSplitSnapshots" "go.uber.org/zap" @@ -132,7 +131,6 @@ func (m *Migrator) MigrateAll() error { &_202411221331_operatorPISplitSnapshots.Migration{}, &_202412091100_fixOperatorPiSplitsFields.Migration{}, &_202501061029_addDescription.Migration{}, - &_202501061613_reindexTestnetForStaterootChange.Migration{}, &_202501061422_defaultOperatorSplits.Migration{}, &_202501071401_defaultOperatorSplitSnapshots.Migration{}, } diff --git a/pkg/rewards/2_goldStakerRewardAmounts.go b/pkg/rewards/2_goldStakerRewardAmounts.go index 12173cd5..e1cb0804 100644 --- a/pkg/rewards/2_goldStakerRewardAmounts.go +++ b/pkg/rewards/2_goldStakerRewardAmounts.go @@ -153,10 +153,10 @@ func (rc *RewardsCalculator) GenerateGold2StakerRewardAmountsTable(snapshotDate rc.logger.Sugar().Infow("Generating staker reward amounts", zap.String("cutoffDate", snapshotDate), zap.String("destTableName", destTableName), - zap.String("amazonHardforkDate", forks[config.Fork_Amazon]), - zap.String("nileHardforkDate", forks[config.Fork_Nile]), - zap.String("arnoHardforkDate", forks[config.Fork_Arno]), - zap.String("trinityHardforkDate", forks[config.Fork_Trinity]), + zap.String("amazonHardforkDate", forks[config.RewardsFork_Amazon]), + zap.String("nileHardforkDate", forks[config.RewardsFork_Nile]), + zap.String("arnoHardforkDate", forks[config.RewardsFork_Arno]), + zap.String("trinityHardforkDate", forks[config.RewardsFork_Trinity]), ) query, err := rewardsUtils.RenderQueryTemplate(_2_goldStakerRewardAmountsQuery, map[string]interface{}{ @@ -169,10 +169,10 @@ func (rc *RewardsCalculator) GenerateGold2StakerRewardAmountsTable(snapshotDate } res := rc.grm.Exec(query, - sql.Named("amazonHardforkDate", forks[config.Fork_Amazon]), - sql.Named("nileHardforkDate", forks[config.Fork_Nile]), - sql.Named("arnoHardforkDate", forks[config.Fork_Arno]), - sql.Named("trinityHardforkDate", forks[config.Fork_Trinity]), + sql.Named("amazonHardforkDate", forks[config.RewardsFork_Amazon]), + sql.Named("nileHardforkDate", forks[config.RewardsFork_Nile]), + sql.Named("arnoHardforkDate", forks[config.RewardsFork_Arno]), + sql.Named("trinityHardforkDate", forks[config.RewardsFork_Trinity]), ) if res.Error != nil { rc.logger.Sugar().Errorw("Failed to create gold_staker_reward_amounts", "error", res.Error) diff --git a/pkg/rewards/5_goldRfaeStakers.go b/pkg/rewards/5_goldRfaeStakers.go index 64098db2..c72bf8a8 100644 --- a/pkg/rewards/5_goldRfaeStakers.go +++ b/pkg/rewards/5_goldRfaeStakers.go @@ -144,8 +144,8 @@ func (rc *RewardsCalculator) GenerateGold5RfaeStakersTable(snapshotDate string, rc.logger.Sugar().Infow("Generating rfae stakers table", zap.String("cutoffDate", snapshotDate), zap.String("destTableName", destTableName), - zap.String("arnoHardforkDate", forks[config.Fork_Arno]), - zap.String("trinityHardforkDate", forks[config.Fork_Trinity]), + zap.String("arnoHardforkDate", forks[config.RewardsFork_Arno]), + zap.String("trinityHardforkDate", forks[config.RewardsFork_Trinity]), ) query, err := rewardsUtils.RenderQueryTemplate(_5_goldRfaeStakersQuery, map[string]interface{}{ @@ -158,10 +158,10 @@ func (rc *RewardsCalculator) GenerateGold5RfaeStakersTable(snapshotDate string, } res := rc.grm.Exec(query, - sql.Named("panamaForkDate", forks[config.Fork_Panama]), + sql.Named("panamaForkDate", forks[config.RewardsFork_Panama]), sql.Named("network", rc.globalConfig.Chain.String()), - sql.Named("arnoHardforkDate", forks[config.Fork_Arno]), - sql.Named("trinityHardforkDate", forks[config.Fork_Trinity]), + sql.Named("arnoHardforkDate", forks[config.RewardsFork_Arno]), + sql.Named("trinityHardforkDate", forks[config.RewardsFork_Trinity]), ) if res.Error != nil { rc.logger.Sugar().Errorw("Failed to generate gold_rfae_stakers", "error", res.Error) diff --git a/pkg/rewards/8_goldOperatorODRewardAmounts.go b/pkg/rewards/8_goldOperatorODRewardAmounts.go index feab904b..0c6919a2 100644 --- a/pkg/rewards/8_goldOperatorODRewardAmounts.go +++ b/pkg/rewards/8_goldOperatorODRewardAmounts.go @@ -94,7 +94,7 @@ func (rc *RewardsCalculator) GenerateGold8OperatorODRewardAmountsTable(snapshotD rc.logger.Sugar().Infow("Generating Operator OD reward amounts", zap.String("cutoffDate", snapshotDate), zap.String("destTableName", destTableName), - zap.String("trinityHardforkDate", forks[config.Fork_Trinity]), + zap.String("trinityHardforkDate", forks[config.RewardsFork_Trinity]), ) query, err := rewardsUtils.RenderQueryTemplate(_8_goldOperatorODRewardAmountsQuery, map[string]interface{}{ @@ -106,7 +106,7 @@ func (rc *RewardsCalculator) GenerateGold8OperatorODRewardAmountsTable(snapshotD return err } - res := rc.grm.Exec(query, sql.Named("trinityHardforkDate", forks[config.Fork_Trinity])) + res := rc.grm.Exec(query, sql.Named("trinityHardforkDate", forks[config.RewardsFork_Trinity])) if res.Error != nil { rc.logger.Sugar().Errorw("Failed to create gold_operator_od_reward_amounts", "error", res.Error) return res.Error diff --git a/pkg/rewards/9_goldStakerODRewardAmounts.go b/pkg/rewards/9_goldStakerODRewardAmounts.go index 1d736162..a5fc2ab4 100644 --- a/pkg/rewards/9_goldStakerODRewardAmounts.go +++ b/pkg/rewards/9_goldStakerODRewardAmounts.go @@ -139,7 +139,7 @@ func (rc *RewardsCalculator) GenerateGold9StakerODRewardAmountsTable(snapshotDat rc.logger.Sugar().Infow("Generating Staker OD reward amounts", zap.String("cutoffDate", snapshotDate), zap.String("destTableName", destTableName), - zap.String("trinityHardforkDate", forks[config.Fork_Trinity]), + zap.String("trinityHardforkDate", forks[config.RewardsFork_Trinity]), ) query, err := rewardsUtils.RenderQueryTemplate(_9_goldStakerODRewardAmountsQuery, map[string]interface{}{ @@ -151,7 +151,7 @@ func (rc *RewardsCalculator) GenerateGold9StakerODRewardAmountsTable(snapshotDat return err } - res := rc.grm.Exec(query, sql.Named("trinityHardforkDate", forks[config.Fork_Trinity])) + res := rc.grm.Exec(query, sql.Named("trinityHardforkDate", forks[config.RewardsFork_Trinity])) if res.Error != nil { rc.logger.Sugar().Errorw("Failed to create gold_staker_od_reward_amounts", "error", res.Error) return res.Error diff --git a/pkg/rewards/rewards.go b/pkg/rewards/rewards.go index 21b3586d..4d94fa92 100644 --- a/pkg/rewards/rewards.go +++ b/pkg/rewards/rewards.go @@ -636,7 +636,7 @@ func (rc *RewardsCalculator) generateSnapshotData(snapshotDate string) error { } func (rc *RewardsCalculator) generateGoldTables(snapshotDate string) error { - forks, err := rc.globalConfig.GetForkDates() + forks, err := rc.globalConfig.GetRewardsSqlForkDates() if err != nil { return err } diff --git a/pkg/rewards/rewardsV2_test.go b/pkg/rewards/rewardsV2_test.go index 84a70e80..a96f2b50 100644 --- a/pkg/rewards/rewardsV2_test.go +++ b/pkg/rewards/rewardsV2_test.go @@ -95,7 +95,7 @@ func Test_RewardsV2(t *testing.T) { testStart = time.Now() t.Log("Generated and inserted snapshots") - forks, err := cfg.GetForkDates() + forks, err := cfg.GetRewardsSqlForkDates() assert.Nil(t, err) fmt.Printf("Running gold_1_active_rewards\n") diff --git a/pkg/rewards/rewards_test.go b/pkg/rewards/rewards_test.go index b318e2da..8d335417 100644 --- a/pkg/rewards/rewards_test.go +++ b/pkg/rewards/rewards_test.go @@ -243,7 +243,7 @@ func Test_Rewards(t *testing.T) { testStart = time.Now() t.Log("Generated and inserted snapshots") - forks, err := cfg.GetForkDates() + forks, err := cfg.GetRewardsSqlForkDates() assert.Nil(t, err) fmt.Printf("Running gold_1_active_rewards\n") diff --git a/pkg/rewards/stakerOperators/1_stakerStrategyPayouts.go b/pkg/rewards/stakerOperators/1_stakerStrategyPayouts.go index b0a06c53..dd14d897 100644 --- a/pkg/rewards/stakerOperators/1_stakerStrategyPayouts.go +++ b/pkg/rewards/stakerOperators/1_stakerStrategyPayouts.go @@ -157,8 +157,8 @@ func (sog *StakerOperatorsGenerator) GenerateAndInsert1StakerStrategyPayouts(cut } res := sog.db.Exec(query, - sql.Named("amazonHardforkDate", forks[config.Fork_Amazon]), - sql.Named("nileHardforkDate", forks[config.Fork_Nile]), + sql.Named("amazonHardforkDate", forks[config.RewardsFork_Amazon]), + sql.Named("nileHardforkDate", forks[config.RewardsFork_Nile]), ) if res.Error != nil { diff --git a/pkg/rewards/stakerOperators/stakerOperator.go b/pkg/rewards/stakerOperators/stakerOperator.go index 81d7a505..8a672210 100644 --- a/pkg/rewards/stakerOperators/stakerOperator.go +++ b/pkg/rewards/stakerOperators/stakerOperator.go @@ -26,7 +26,7 @@ func NewStakerOperatorGenerator( } func (sog *StakerOperatorsGenerator) GenerateStakerOperatorsTable(cutoffDate string) error { - forks, err := sog.globalConfig.GetForkDates() + forks, err := sog.globalConfig.GetRewardsSqlForkDates() if err != nil { return err }