Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
rian committed Jun 12, 2024
1 parent a6ec82b commit db9bf2c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions core/trie/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,11 @@ func VerifyProof(root *felt.Felt, key *Key, value *felt.Felt, proofs []ProofNode
return false
}

// Todo:
// If we are verifying the key doesn't exist, then we should
// update subKey to point in the other direction
if value == nil && i == len(proofs)-1 {
return true // todo: hack for non-set proof nodes
return true
}

if !proofNode.Edge.Path.Equal(subKey) {
Expand Down Expand Up @@ -294,13 +295,13 @@ func ensureMonotonicIncreasing(proofKeys [2]*Key, keys []*felt.Felt) error {
func shouldSquish(idx int, proofNodes []ProofNode, hashF hashFunc) (int, uint8, error) {
parent := &proofNodes[idx]
if idx == len(proofNodes)-1 { // The node may have children, but we can only derive their hashes here
var hack int
var isEdge int
if parent.Edge != nil {
hack = 1
isEdge = 1
} else if parent.Binary != nil {
hack = 0
isEdge = 0
}
return hack, parent.Len(), nil
return isEdge, parent.Len(), nil
}

child := &proofNodes[idx+1]
Expand Down Expand Up @@ -344,7 +345,7 @@ func assignChild(crntNode *Node, nilKey, childKey *Key, isRight bool) {
func ProofToPath(proofNodes []ProofNode, leafKey *Key, hashF hashFunc) ([]StorageNode, error) {
pathNodes := []StorageNode{}

// Hack: this allows us to store a right without an existing left node.
// Child keys that can't be derived are set to nilKey, so that we can store the node
zeroFeltBytes := new(felt.Felt).Bytes()
nilKey := NewKey(0, zeroFeltBytes[:])

Expand Down

0 comments on commit db9bf2c

Please sign in to comment.