diff --git a/mpt-witness-generator/oracle/preimage.go b/mpt-witness-generator/oracle/preimage.go index a3461d4895..65733a340e 100644 --- a/mpt-witness-generator/oracle/preimage.go +++ b/mpt-witness-generator/oracle/preimage.go @@ -13,7 +13,6 @@ var preimages = make(map[common.Hash][]byte) func Preimage(hash common.Hash) ([]byte, error) { val, ok := preimages[hash] if !ok { - fmt.Println("can't find preimage", hash) return nil, errors.New("can't find preimage") } comphash := crypto.Keccak256Hash(val) diff --git a/mpt-witness-generator/state/statedb.go b/mpt-witness-generator/state/statedb.go index c0926fd80b..6502bba1c4 100644 --- a/mpt-witness-generator/state/statedb.go +++ b/mpt-witness-generator/state/statedb.go @@ -437,7 +437,7 @@ func (s *StateDB) SetStateObjectIfExists(addr common.Address) { ap := oracle.PrefetchAccount(s.Db.BlockNumber, addr, nil) if len(ap) > 0 { ret, _ := hex.DecodeString(ap[len(ap)-1][2:]) - s.setStateObjectFromEncoding(addr, ret) + s.SetStateObjectFromEncoding(addr, ret) } } } @@ -594,7 +594,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject { // Added for MPT generator. This loads account into stateObjects - if an account is not // in stateObjects, a new account is created in GetOrNewStateObject. -func (s *StateDB) setStateObjectFromEncoding(addr common.Address, enc []byte) error { +func (s *StateDB) SetStateObjectFromEncoding(addr common.Address, enc []byte) error { if len(enc) == 0 { return errors.New("encoding of account is of length 0") } @@ -605,7 +605,7 @@ func (s *StateDB) setStateObjectFromEncoding(addr common.Address, enc []byte) er if err := rlp.DecodeBytes(accData, data); err != nil { // If it's not account RLP, nothing is set (in stateObjects) - this is to prevent // the need of checking whether enc is account RLP or something else (like branch RLP). - fmt.Println("failed to decode account") + // fmt.Println("failed to decode account") return nil } diff --git a/mpt-witness-generator/trie/stacktrie.go b/mpt-witness-generator/trie/stacktrie.go index 9f3a63a23f..6a11cd2a99 100644 --- a/mpt-witness-generator/trie/stacktrie.go +++ b/mpt-witness-generator/trie/stacktrie.go @@ -503,7 +503,6 @@ func (st *StackTrie) hash(doUpdate bool) { if st.db != nil { // TODO! Is it safe to Put the slice here? // Do all db implementations copy the value provided? - fmt.Println("into db:", st.val) st.db.Put(st.val, h.tmp) } } diff --git a/mpt-witness-generator/trie/trie.go b/mpt-witness-generator/trie/trie.go index 433da4a1b6..e309d6c74f 100644 --- a/mpt-witness-generator/trie/trie.go +++ b/mpt-witness-generator/trie/trie.go @@ -335,10 +335,6 @@ func (t *Trie) insert(n Node, prefix, key []byte, value Node) (bool, Node, error } // Otherwise, replace it with a short node leading up to the branch. // (this is extension node) - if matchlen > 2 { - fmt.Println(matchlen) - fmt.Println("====") - } return true, &ShortNode{key[:matchlen], branch, t.newFlag()}, nil case *FullNode: diff --git a/mpt-witness-generator/witness/prepare_witness.go b/mpt-witness-generator/witness/prepare_witness.go index 90be7fcd62..8e4b6085bf 100644 --- a/mpt-witness-generator/witness/prepare_witness.go +++ b/mpt-witness-generator/witness/prepare_witness.go @@ -1,6 +1,7 @@ package witness import ( + "encoding/hex" "fmt" "math/big" @@ -200,7 +201,7 @@ func obtainTwoProofsAndConvertToWitness(trieModifications []TrieModification, st addrh := crypto.Keccak256(addr.Bytes()) accountAddr := trie.KeybytesToHex(addrh) - oracle.PrefetchAccount(statedb.Db.BlockNumber, tMod.Address, nil) + ap := oracle.PrefetchAccount(statedb.Db.BlockNumber, tMod.Address, nil) oracle.PrefetchStorage(statedb.Db.BlockNumber, addr, tMod.Key, nil) if specialTest == 1 { @@ -211,7 +212,10 @@ func obtainTwoProofsAndConvertToWitness(trieModifications []TrieModification, st check(err) if !statedb.Exist(addr) { - statedb.CreateObject(addr) + if len(ap) > 0 { + ret, _ := hex.DecodeString(ap[len(ap)-1][2:]) + statedb.SetStateObjectFromEncoding(addr, ret) + } } storageProof, neighbourNode1, extNibbles1, isLastLeaf1, isNeighbourNodeHashed1, err := statedb.GetStorageProof(addr, tMod.Key)