Fix CalcTrieRoot result in tests (#472)

* Try to fix CalcTrieRoots

* Fix

* Remove root.txt

* Fix in go.mod

* Trying to fix
This commit is contained in:
ledgerwatch 2020-04-20 14:07:50 +01:00 committed by GitHub
parent a9f71298aa
commit 93875738ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 20 deletions

View File

@ -2714,8 +2714,6 @@ func TestDeleteCreateRevert(t *testing.T) {
// Expected outcome is that _all_ slots are cleared from A, due to the selfdestruct,
// and then the new slots exist
func TestDeleteRecreateSlots(t *testing.T) {
// FIXME: restore
t.Skip("restore for turbo-geth 1.0 release")
var (
// Generate a canonical chain to act as the main dataset
engine = ethash.NewFaker()
@ -2925,8 +2923,6 @@ func TestDeleteRecreateAccount(t *testing.T) {
// Expected outcome is that _all_ slots are cleared from A, due to the selfdestruct,
// and then the new slots exist
func TestDeleteRecreateSlotsAcrossManyBlocks(t *testing.T) {
// FIXME: restore
t.Skip("restore for turbo-geth 1.0 release")
var (
// Generate a canonical chain to act as the main dataset
engine = ethash.NewFaker()

View File

@ -168,6 +168,7 @@ func (b *Buffer) merge(other *Buffer) {
}
for addrHash := range other.deleted {
b.deleted[addrHash] = struct{}{}
delete(b.storageUpdates, addrHash)
}
for addrHash := range other.created {
b.created[addrHash] = struct{}{}
@ -355,11 +356,6 @@ func (tds *TrieDbState) buildStorageTouches(withReads bool, withValues bool) (co
storageTouches := common.StorageKeys{}
var values [][]byte
for addrHash, m := range tds.aggregateBuffer.storageUpdates {
if withValues {
if _, ok := tds.aggregateBuffer.deleted[addrHash]; ok {
continue
}
}
for keyHash := range m {
var storageKey common.StorageKey
copy(storageKey[:], addrHash[:])
@ -784,17 +780,6 @@ func (tds *TrieDbState) updateTrieRoots(forward bool) ([]common.Hash, error) {
// For the contracts that got deleted
for addrHash := range b.deleted {
if _, ok := b.created[addrHash]; ok {
// In some rather artificial circumstances, an account can be recreated after having been self-destructed
// in the same block. It can only happen when contract is introduced in the genesis state with nonce 0
// rather than created by a transaction (in that case, its starting nonce is 1). The self-destructed
// contract actually gets removed from the state only at the end of the block, so if its nonce is not 0,
// it will prevent any re-creation within the same block. However, if the contract is introduced in
// the genesis state, its nonce is 0, and that means it can be self-destructed, and then re-created,
// all in the same block. In such cases, we must preserve storage modifications happening after the
// self-destruction
continue
}
if account, ok := b.accountUpdates[addrHash]; ok && account != nil {
//fmt.Printf("(b)Set empty root for addrHash %x due to deleted\n", addrHash)
account.Root = trie.EmptyRoot

BIN
libz3.a

Binary file not shown.

View File

@ -488,6 +488,10 @@ func (tr *ResolverStatefulCached) MultiWalk2(db *bolt.DB, blockNr uint64, bucket
keyAsNibbles.Reset()
DecompressNibbles(minKey, &keyAsNibbles.B)
if len(keyAsNibbles.B) < currentReq.extResolvePos {
cacheK, cacheV = cache.Next() // go to children, not to sibling
continue
}
canUseCache = currentRs.HashOnly(keyAsNibbles.B[currentReq.extResolvePos:])
if !canUseCache { // can't use cache as is, need go to children
cacheK, cacheV = cache.Next() // go to children, not to sibling