Skip to content

Commit

Permalink
Include blockNumber in operator shares root
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Sep 6, 2024
1 parent e5046be commit a952fc2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/eigenState/avsOperators/avsOperators.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func (a *AvsOperators) merkelizeState(blockNumber uint64, avsOperators []Registe
}
}

avsLeaves := a.InitializeBaseStateWithBlock(blockNumber)
avsLeaves := a.InitializeMerkleTreeBaseStateWithBlock(blockNumber)

for avs := om.Oldest(); avs != nil; avs = avs.Next() {

Expand Down
2 changes: 1 addition & 1 deletion internal/eigenState/eigenstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (b *BaseEigenState) ParseLogOutput(log *storage.TransactionLog) (map[string
// This does two things:
// 1. Ensures that the tree is always different for different blocks
// 2. Allows us to have at least 1 value if there are no model changes for a block
func (b *BaseEigenState) InitializeBaseStateWithBlock(blockNumber uint64) [][]byte {
func (b *BaseEigenState) InitializeMerkleTreeBaseStateWithBlock(blockNumber uint64) [][]byte {
return [][]byte{
[]byte(fmt.Sprintf("%d", blockNumber)),
}
Expand Down
6 changes: 3 additions & 3 deletions internal/eigenState/operatorShares/operatorShares.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,14 @@ func (osm *OperatorSharesModel) GenerateStateRoot(blockNumber uint64) (eigenStat
return "", err
}

fullTree, err := osm.merkelizeState(diffs)
fullTree, err := osm.merkelizeState(blockNumber, diffs)
if err != nil {
return "", err
}
return eigenState.StateRoot(utils.ConvertBytesToString(fullTree.Root())), nil
}

func (osm *OperatorSharesModel) merkelizeState(diffs []OperatorShares) (*merkletree.MerkleTree, error) {
func (osm *OperatorSharesModel) merkelizeState(blockNumber uint64, diffs []OperatorShares) (*merkletree.MerkleTree, error) {
// Create a merkle tree with the structure:
// strategy: map[operators]: shares
om := orderedmap.New[string, *orderedmap.OrderedMap[string, string]]()
Expand All @@ -318,7 +318,7 @@ func (osm *OperatorSharesModel) merkelizeState(diffs []OperatorShares) (*merklet
}
}

leaves := make([][]byte, 0)
leaves := osm.InitializeMerkleTreeBaseStateWithBlock(blockNumber)
for strat := om.Oldest(); strat != nil; strat = strat.Next() {

operatorLeaves := make([][]byte, 0)
Expand Down

0 comments on commit a952fc2

Please sign in to comment.