Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only generate root based on diffs #3

Merged
merged 7 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Include blockNumber in operator shares root
  • Loading branch information
seanmcgary committed Sep 6, 2024
commit a952fc2db3c4c75a3f3ebe8640ded38c06dabffe
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
Loading