Skip to content

Commit

Permalink
Use registered flag, not block number
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Sep 6, 2024
1 parent 4d5abd6 commit e5046be
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/eigenState/avsOperators/avsOperators.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,13 @@ func (a *AvsOperators) GenerateStateRoot(blockNumber uint64) (eigenState.StateRo
}

func (a *AvsOperators) merkelizeState(blockNumber uint64, avsOperators []RegisteredAvsOperatorDiff) (*merkletree.MerkleTree, error) {
// Avs -> operator:block_number
om := orderedmap.New[string, *orderedmap.OrderedMap[string, uint64]]()
// Avs -> operator:registered
om := orderedmap.New[string, *orderedmap.OrderedMap[string, bool]]()

for _, result := range avsOperators {
existingAvs, found := om.Get(result.Avs)
if !found {
existingAvs = orderedmap.New[string, uint64]()
existingAvs = orderedmap.New[string, bool]()
om.Set(result.Avs, existingAvs)

prev := om.GetPair(result.Avs).Prev()
Expand All @@ -351,7 +351,7 @@ func (a *AvsOperators) merkelizeState(blockNumber uint64, avsOperators []Registe
return nil, fmt.Errorf("avs not in order")
}
}
existingAvs.Set(result.Operator, result.BlockNumber)
existingAvs.Set(result.Operator, result.Registered)

prev := existingAvs.GetPair(result.Operator).Prev()
if prev != nil && strings.Compare(prev.Key, result.Operator) >= 0 {
Expand All @@ -367,8 +367,8 @@ func (a *AvsOperators) merkelizeState(blockNumber uint64, avsOperators []Registe
operatorLeafs := make([][]byte, 0)
for operator := avs.Value.Oldest(); operator != nil; operator = operator.Next() {
operatorAddr := operator.Key
block := operator.Value
operatorLeafs = append(operatorLeafs, encodeOperatorLeaf(operatorAddr, block))
registered := operator.Value
operatorLeafs = append(operatorLeafs, encodeOperatorLeaf(operatorAddr, registered))
}

avsTree, err := merkletree.NewTree(
Expand All @@ -388,8 +388,8 @@ func (a *AvsOperators) merkelizeState(blockNumber uint64, avsOperators []Registe
)
}

func encodeOperatorLeaf(operator string, blockNumber uint64) []byte {
return []byte(fmt.Sprintf("%s:%d", operator, blockNumber))
func encodeOperatorLeaf(operator string, registered bool) []byte {
return []byte(fmt.Sprintf("%s:%t", operator, registered))
}

func encodeAvsLeaf(avs string, avsOperatorRoot []byte) []byte {
Expand Down

0 comments on commit e5046be

Please sign in to comment.