Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
debugging logs
Browse files Browse the repository at this point in the history
  • Loading branch information
miha-stopar committed Apr 19, 2024
1 parent ab17509 commit bb8a625
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
19 changes: 19 additions & 0 deletions geth-utils/gethutil/mpt/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,27 @@ func (s *StateDB) SetStateObjectIfExists(addr common.Address) {
if len(ap) > 0 {
ret, _ := hex.DecodeString(ap[len(ap)-1][2:])

fmt.Println("=========== SetStateObjectIfExists ==================")
for i := 0; i < len(ap); i++ {
fmt.Println(ap[i])
fmt.Println("")
}

fmt.Println("===------=====")
fmt.Println(ret)

data := new(Account)
keyLen := ret[2] - 128

if int(3 + keyLen + 2) > len(ret) {
// Not account leaf, it's extension node
fmt.Println("")
fmt.Println("")
fmt.Println("extension node")
fmt.Println("")
return
}

accData := ret[3+keyLen+2:]

if err := rlp.DecodeBytes(accData, data); err != nil {
Expand Down
59 changes: 59 additions & 0 deletions geth-utils/gethutil/mpt/witness/prepare_witness.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package witness

import (
"fmt"
"math/big"

"main/gethutil/mpt/oracle"
Expand Down Expand Up @@ -226,6 +227,41 @@ func obtainTwoProofsAndConvertToWitness(trieModifications []TrieModification, st
storageProof1, neighbourNode2, extNibbles2, isLastLeaf2, isNeighbourNodeHashed2, err := statedb.GetStorageProof(addr, tMod.Key)
check(err)

fmt.Println("==== ??? ===== ?????????????????????????")
fmt.Println(tMod.Type)
fmt.Println(tMod.Value)

fmt.Println("")
fmt.Println("account proof 1")
for i := 0; i < len(accountProof); i++ {
fmt.Println(accountProof[i])
fmt.Println("")
}

fmt.Println("")
fmt.Println("storage proof 1")
for i := 0; i < len(storageProof); i++ {
fmt.Println(storageProof[i])
fmt.Println("")
}
fmt.Println("")

fmt.Println("")
fmt.Println("account proof 2")
for i := 0; i < len(accountProof1); i++ {
fmt.Println(accountProof1[i])
fmt.Println("")
}

fmt.Println("")
fmt.Println("storage proof 2")
for i := 0; i < len(storageProof1); i++ {
fmt.Println(storageProof1[i])
fmt.Println("")
}
fmt.Println("")


aNode := aNeighbourNode2
aIsLastLeaf := aIsLastLeaf1
aIsNeighbourNodeHashed := aIsNeighbourNodeHashed2
Expand Down Expand Up @@ -441,6 +477,29 @@ func convertProofToWitness(statedb *state.StateDB, addr common.Address, addrh []
leafRow0, key,
keyIndex, isShorterProofLastLeaf)

if isModifiedExtNode {
fmt.Println("===========================================")
fmt.Println("")
fmt.Println(isAccountProof)
fmt.Println(nonExistingAccountProof)
fmt.Println(nonExistingStorageProof)

fmt.Println("")
fmt.Println("isModExtNode proof 1")
for i := 0; i < len(proof1); i++ {
fmt.Println(proof1[i])
fmt.Println("")
}

fmt.Println("")
fmt.Println("isModExtNode proof 2")
for i := 0; i < len(proof2); i++ {
fmt.Println(proof2[i])
fmt.Println("")
}
fmt.Println("")
}

nodes = append(nodes, bNode)

var leafNode Node
Expand Down
13 changes: 13 additions & 0 deletions zkevm-circuits/src/mpt_circuit/mod_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,19 @@ impl<F: Field> ModExtensionGadget<F> {
if is_key_part_odd {
assert!(first_key_byte < 0b10_0000);
} else {
if first_key_byte != 0 {
println!("");
for r in rlp_values {
println!("{:?}", r.bytes);
println!("");
}
/*
println!("{:?}", key_items[0]);
println!("");
println!("{:?}", key_items[1]);
println!("");
*/
}
assert!(first_key_byte == 0);
}

Expand Down

0 comments on commit bb8a625

Please sign in to comment.