From 3a41981e1a440a5a6abcbf898defdd720cc9e8f4 Mon Sep 17 00:00:00 2001 From: Sean McGary Date: Thu, 21 Nov 2024 21:41:35 -0600 Subject: [PATCH] bug: fix setting tx hash and log index on submitted distribution roots --- .../submittedDistributionRoots.go | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pkg/eigenState/submittedDistributionRoots/submittedDistributionRoots.go b/pkg/eigenState/submittedDistributionRoots/submittedDistributionRoots.go index f5111fb2..5569cc05 100644 --- a/pkg/eigenState/submittedDistributionRoots/submittedDistributionRoots.go +++ b/pkg/eigenState/submittedDistributionRoots/submittedDistributionRoots.go @@ -216,8 +216,8 @@ func (sdr *SubmittedDistributionRootsModel) HandleStateChange(log *storage.Trans } // prepareState prepares the state for commit by adding the new state to the existing state. -func (sdr *SubmittedDistributionRootsModel) prepareState(blockNumber uint64) ([]types.SubmittedDistributionRoot, error) { - preparedState := make([]types.SubmittedDistributionRoot, 0) +func (sdr *SubmittedDistributionRootsModel) prepareState(blockNumber uint64) ([]*types.SubmittedDistributionRoot, error) { + preparedState := make([]*types.SubmittedDistributionRoot, 0) accumulatedState, ok := sdr.stateAccumulator[blockNumber] if !ok { @@ -227,18 +227,7 @@ func (sdr *SubmittedDistributionRootsModel) prepareState(blockNumber uint64) ([] } for _, newState := range accumulatedState { - prepared := types.SubmittedDistributionRoot{ - Root: newState.Root, - BlockNumber: blockNumber, - RootIndex: newState.RootIndex, - RewardsCalculationEnd: newState.RewardsCalculationEnd, - RewardsCalculationEndUnit: newState.RewardsCalculationEndUnit, - ActivatedAt: newState.ActivatedAt, - ActivatedAtUnit: newState.ActivatedAtUnit, - CreatedAtBlockNumber: newState.CreatedAtBlockNumber, - } - - preparedState = append(preparedState, prepared) + preparedState = append(preparedState, newState) } return preparedState, nil } @@ -260,8 +249,8 @@ func (sdr *SubmittedDistributionRootsModel) CommitFinalState(blockNumber uint64) return nil } -func (sdr *SubmittedDistributionRootsModel) sortValuesForMerkleTree(inputs []types.SubmittedDistributionRoot) []*base.MerkleTreeInput { - slices.SortFunc(inputs, func(i, j types.SubmittedDistributionRoot) int { +func (sdr *SubmittedDistributionRootsModel) sortValuesForMerkleTree(inputs []*types.SubmittedDistributionRoot) []*base.MerkleTreeInput { + slices.SortFunc(inputs, func(i, j *types.SubmittedDistributionRoot) int { return int(i.RootIndex - j.RootIndex) })