From 1279f1181b7e1c05b63601b1024bd9f892a10791 Mon Sep 17 00:00:00 2001 From: 0xrajath Date: Tue, 7 Jan 2025 11:55:15 -0500 Subject: [PATCH 1/3] number formatting --- .../operatorDirectedRewardSubmissions.go | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go index c7f19563..c091e86f 100644 --- a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go +++ b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go @@ -291,7 +291,10 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) GenerateStateRoot(blockNumbe return nil, err } - inputs := odrs.sortValuesForMerkleTree(inserts) + inputs, err := odrs.sortValuesForMerkleTree(inserts) + if err != nil { + return nil, err + } if len(inputs) == 0 { return nil, nil @@ -309,11 +312,24 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) GenerateStateRoot(blockNumbe return fullTree.Root(), nil } -func (odrs *OperatorDirectedRewardSubmissionsModel) sortValuesForMerkleTree(submissions []*OperatorDirectedRewardSubmission) []*base.MerkleTreeInput { +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) - value := fmt.Sprintf("%s_%s_%s_%s_%s", submission.RewardHash, submission.Strategy, submission.Multiplier, submission.Operator, submission.Amount) + + multiplierBig, success := numbers.NewBig257().SetString(submission.Multiplier, 10) + if !success { + return nil, fmt.Errorf("failed to parse multiplier to Big257: %s", submission.Multiplier) + } + + amountBig, success := numbers.NewBig257().SetString(submission.Amount, 10) + if !success { + return nil, fmt.Errorf("failed to parse amount to Big257: %s", submission.Amount) + } + + // 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), @@ -324,7 +340,7 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) sortValuesForMerkleTree(subm return strings.Compare(string(i.SlotID), string(j.SlotID)) }) - return inputs + return inputs, nil } func (odrs *OperatorDirectedRewardSubmissionsModel) DeleteState(startBlockNumber uint64, endBlockNumber uint64) error { From b0c513ed2296580f361f618dcd9f06e7613b2147 Mon Sep 17 00:00:00 2001 From: 0xrajath Date: Tue, 7 Jan 2025 15:39:43 -0500 Subject: [PATCH 2/3] big int --- .../operatorDirectedRewardSubmissions.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go index c091e86f..8d91588d 100644 --- a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go +++ b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go @@ -3,6 +3,7 @@ package operatorDirectedRewardSubmissions import ( "encoding/json" "fmt" + "math/big" "slices" "sort" "strings" @@ -317,12 +318,12 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) sortValuesForMerkleTree(subm for _, submission := range submissions { slotID := NewSlotID(submission.TransactionHash, submission.LogIndex, submission.RewardHash, submission.StrategyIndex, submission.OperatorIndex) - multiplierBig, success := numbers.NewBig257().SetString(submission.Multiplier, 10) + multiplierBig, success := new(big.Int).SetString(submission.Multiplier, 10) if !success { return nil, fmt.Errorf("failed to parse multiplier to Big257: %s", submission.Multiplier) } - amountBig, success := numbers.NewBig257().SetString(submission.Amount, 10) + amountBig, success := new(big.Int).SetString(submission.Amount, 10) if !success { return nil, fmt.Errorf("failed to parse amount to Big257: %s", submission.Amount) } From a3c07bb752dd320594f1d49df1ccd5d3b5a10a81 Mon Sep 17 00:00:00 2001 From: 0xrajath Date: Tue, 7 Jan 2025 15:42:07 -0500 Subject: [PATCH 3/3] error message --- .../operatorDirectedRewardSubmissions.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go index 8d91588d..dc86c990 100644 --- a/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go +++ b/pkg/eigenState/operatorDirectedRewardSubmissions/operatorDirectedRewardSubmissions.go @@ -320,12 +320,12 @@ func (odrs *OperatorDirectedRewardSubmissionsModel) sortValuesForMerkleTree(subm multiplierBig, success := new(big.Int).SetString(submission.Multiplier, 10) if !success { - return nil, fmt.Errorf("failed to parse multiplier to Big257: %s", submission.Multiplier) + return nil, fmt.Errorf("failed to parse multiplier to BigInt: %s", submission.Multiplier) } amountBig, success := new(big.Int).SetString(submission.Amount, 10) if !success { - return nil, fmt.Errorf("failed to parse amount to Big257: %s", submission.Amount) + return nil, fmt.Errorf("failed to parse amount to BigInt: %s", submission.Amount) } // Multiplier is a uint96 in the contracts, which translates to 24 hex characters