From bb8a6257ccbfbdc39a2e0806730b7882b94dcddf Mon Sep 17 00:00:00 2001 From: miha-stopar Date: Fri, 19 Apr 2024 12:02:45 +0200 Subject: [PATCH] debugging logs --- geth-utils/gethutil/mpt/state/statedb.go | 19 ++++++ .../gethutil/mpt/witness/prepare_witness.go | 59 +++++++++++++++++++ .../src/mpt_circuit/mod_extension.rs | 13 ++++ 3 files changed, 91 insertions(+) diff --git a/geth-utils/gethutil/mpt/state/statedb.go b/geth-utils/gethutil/mpt/state/statedb.go index 51f1f53115..4bff3087ec 100644 --- a/geth-utils/gethutil/mpt/state/statedb.go +++ b/geth-utils/gethutil/mpt/state/statedb.go @@ -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 { diff --git a/geth-utils/gethutil/mpt/witness/prepare_witness.go b/geth-utils/gethutil/mpt/witness/prepare_witness.go index 82926358ff..780c35bc68 100644 --- a/geth-utils/gethutil/mpt/witness/prepare_witness.go +++ b/geth-utils/gethutil/mpt/witness/prepare_witness.go @@ -1,6 +1,7 @@ package witness import ( + "fmt" "math/big" "main/gethutil/mpt/oracle" @@ -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 @@ -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 diff --git a/zkevm-circuits/src/mpt_circuit/mod_extension.rs b/zkevm-circuits/src/mpt_circuit/mod_extension.rs index c1ea30addd..ad7d19970e 100644 --- a/zkevm-circuits/src/mpt_circuit/mod_extension.rs +++ b/zkevm-circuits/src/mpt_circuit/mod_extension.rs @@ -305,6 +305,19 @@ impl ModExtensionGadget { 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); }