diff --git a/execution/commitment/hex_patricia_hashed.go b/execution/commitment/hex_patricia_hashed.go index f526dc75cbd..2d9c8b6bb05 100644 --- a/execution/commitment/hex_patricia_hashed.go +++ b/execution/commitment/hex_patricia_hashed.go @@ -1914,7 +1914,7 @@ func (hph *HexPatriciaHashed) foldPropagate(row int, nibble, upDepth, depth int1 // propagate cell into parent row upCell.fillFromLowerCell(cell, depth, hph.currentKey[upDepth:hph.currentKeyLen], childNibble) - if err := hph.collectDeleteUpdate(updateKey, row, true); err != nil { + if err := hph.collectDeleteUpdate(updateKey, row); err != nil { return err } if hph.traceW != nil { @@ -1946,15 +1946,14 @@ func (hph *HexPatriciaHashed) foldDelete(row int, nibble, upDepth int16, upCell } upCell.reset() - return hph.collectDeleteUpdate(updateKey, row, true) + return hph.collectDeleteUpdate(updateKey, row) } // collectDeleteUpdate encodes a branch deletion if a branch existed before at this row. -// If evictCache is true, it also evicts the branch from the cache. -func (hph *HexPatriciaHashed) collectDeleteUpdate(updateKey []byte, row int, evictCache bool) error { +func (hph *HexPatriciaHashed) collectDeleteUpdate(updateKey []byte, row int) error { if hph.branchBefore[row] { if err := hph.branchEncoder.CollectUpdate(hph.ctx, updateKey, 0, hph.touchMap[row], 0, nil, false); err != nil { - return fmt.Errorf("failed to encode leaf node update: %w", err) + return fmt.Errorf("failed to encode branch deletion: %w", err) } } return nil diff --git a/execution/commitment/keys_nibbles.go b/execution/commitment/keys_nibbles.go index f6474b14945..5aa2efa3a4f 100644 --- a/execution/commitment/keys_nibbles.go +++ b/execution/commitment/keys_nibbles.go @@ -1,7 +1,6 @@ package commitment import ( - "errors" "fmt" "strconv" "strings" @@ -107,30 +106,6 @@ func NibblesToString(nibbles []byte) string { return b.String() } -// CompactKey takes a slice of nibbles and compacts them into the original byte slice. -// It returns an error if the input contains invalid nibbles (values > 0xF). -func CompactKey(nibbles []byte) ([]byte, error) { - // If the number of nibbles is odd, you might decide to handle it differently. - // For this example, we'll return an error. - if len(nibbles)%2 != 0 { - return nil, errors.New("nibbles slice has an odd length") - } - - key := make([]byte, len(nibbles)/2) - for i := range key { - highNibble := nibbles[i*2] - lowNibble := nibbles[i*2+1] - - // Validate that each nibble is indeed a nibble - if highNibble > 0xF || lowNibble > 0xF { - return nil, fmt.Errorf("invalid nibble at position %d or %d: 0x%X, 0x%X", i*2, i*2+1, highNibble, lowNibble) - } - - key[i] = (highNibble << 4) | (lowNibble & 0x0F) - } - return key, nil -} - // updatedNibs returns a string of nibbles that are set in the given number. func updatedNibs(num uint16) string { var nibbles []string diff --git a/execution/commitment/streaming_deep_fold.go b/execution/commitment/streaming_deep_fold.go index 14c5bce4db0..f975c828acf 100644 --- a/execution/commitment/streaming_deep_fold.go +++ b/execution/commitment/streaming_deep_fold.go @@ -267,7 +267,7 @@ func storageRootFromSingleChild(base *HexPatriciaHashed) (cell, error) { // The prior on-disk branch at the account prefix, if any, is now an extension: no branch record. if base.branchBefore[0] { - if err := base.collectDeleteUpdate(nibbles.HexToCompact(base.currentKey[:base.currentKeyLen]), 0, true); err != nil { + if err := base.collectDeleteUpdate(nibbles.HexToCompact(base.currentKey[:base.currentKeyLen]), 0); err != nil { return cell{}, err } }