diff --git a/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go b/pkg/eigenState/operatorAVSSplits/operatorAVSSplits.go index 57400955..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 @@ -272,7 +275,7 @@ func (oas *OperatorAVSSplitModel) formatMerkleLeafValue( return fmt.Sprintf("%s_%s_%016x_%016x_%016x", operator, avs, activatedAt.Unix(), oldOperatorAVSSplitBips, newOperatorAVSSplitBips), nil } -func (oas *OperatorAVSSplitModel) sortValuesForMerkleTree(splits []*OperatorAVSSplit) []*base.MerkleTreeInput { +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) @@ -287,7 +290,7 @@ func (oas *OperatorAVSSplitModel) sortValuesForMerkleTree(splits []*OperatorAVSS zap.Uint64("oldOperatorAVSSplitBips", split.OldOperatorAVSSplitBips), zap.Uint64("newOperatorAVSSplitBips", split.NewOperatorAVSSplitBips), ) - continue + return nil, err } inputs = append(inputs, &base.MerkleTreeInput{ SlotID: slotID, @@ -299,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 d463431a..318911d5 100644 --- a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go +++ b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go @@ -76,12 +76,23 @@ 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 { - if odrs.globalConfig.ChainIsOneOf(config.Chain_Holesky, config.Chain_Preprod) && blockNumber < 3118055 { +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)) + 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)) + return base.NewSlotIDWithSuffix(transactionHash, logIndex, fmt.Sprintf("%s_%016x_%016x", rewardHash, strategyIndex, operatorIndex)), nil } type operatorDirectedRewardData struct { @@ -182,7 +193,19 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) GetStateTransitions() (types } for _, rewardSubmission := range rewardSubmissions { - slotId := odrs.NewSlotID(log.BlockNumber, 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 { @@ -354,7 +377,19 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) formatMerkleLeafValue( func (odrs *OperatorDirectedRewardSubmissionsModel) sortValuesForMerkleTree(submissions []*OperatorDirectedRewardSubmission) ([]*base.MerkleTreeInput, error) { inputs := make([]*base.MerkleTreeInput, 0) for _, submission := range submissions { - slotID := odrs.NewSlotID(submission.BlockNumber, submission.TransactionHash, submission.LogIndex, submission.RewardHash, submission.StrategyIndex, submission.OperatorIndex) + 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 + } value, err := odrs.formatMerkleLeafValue(submission.BlockNumber, submission.RewardHash, submission.Strategy, submission.Multiplier, submission.Operator, submission.Amount) if err != nil { diff --git a/pkg/eigenState/operatorPISplits/operatorPISplits.go b/pkg/eigenState/operatorPISplits/operatorPISplits.go index c7a220e9..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 @@ -269,7 +272,7 @@ func (ops *OperatorPISplitModel) formatMerkleLeafValue( return fmt.Sprintf("%s_%016x_%016x_%016x", operator, activatedAt.Unix(), oldOperatorPISplitBips, newOperatorPISplitBips), nil } -func (ops *OperatorPISplitModel) sortValuesForMerkleTree(splits []*OperatorPISplit) []*base.MerkleTreeInput { +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) @@ -283,7 +286,7 @@ func (ops *OperatorPISplitModel) sortValuesForMerkleTree(splits []*OperatorPISpl zap.Uint64("oldOperatorPISplitBips", split.OldOperatorPISplitBips), zap.Uint64("newOperatorPISplitBips", split.NewOperatorPISplitBips), ) - continue + return nil, err } inputs = append(inputs, &base.MerkleTreeInput{ SlotID: slotID, @@ -295,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 {