Skip to content

Commit

Permalink
Merge branch 'zkevm' into 1458-rpc-generate-witness-locally-during-ex…
Browse files Browse the repository at this point in the history
…ecution
  • Loading branch information
V-Staykov authored Nov 28, 2024
2 parents e30a623 + ba0a89e commit 55cabf0
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 146 deletions.
11 changes: 8 additions & 3 deletions smt/pkg/smt/smt.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,9 @@ func (s *SMT) insert(k utils.NodeKey, v utils.NodeValue8, newValH [4]uint64, old

utils.RemoveOver(siblings, level+1)

s.updateDepth(len(siblings))
if err := s.updateDepth(len(siblings)); err != nil {
return nil, fmt.Errorf("updateDepth: %w", err)
}

for level >= 0 {
hashValueIn, err := utils.NodeValue8FromBigIntArray(siblings[level][0:8])
Expand Down Expand Up @@ -639,7 +641,7 @@ func (s *SMT) CheckOrphanedNodes(ctx context.Context) int {
return len(orphanedNodes)
}

func (s *SMT) updateDepth(newDepth int) {
func (s *SMT) updateDepth(newDepth int) error {
oldDepth, err := s.Db.GetDepth()
if err != nil {
oldDepth = 0
Expand All @@ -652,8 +654,11 @@ func (s *SMT) updateDepth(newDepth int) {

newDepthAsByte := byte(newDepth & 0xFF)
if oldDepth < newDepthAsByte {
_ = s.Db.SetDepth(newDepthAsByte)
if err := s.Db.SetDepth(newDepthAsByte); err != nil {
return fmt.Errorf("s.Db.SetDepth: %w", err)
}
}
return nil
}

/*
Expand Down
Loading

0 comments on commit 55cabf0

Please sign in to comment.