You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.
System info: [Include Ethermint commit, operating system name, and other relevant details]
branch development
Copy function:
The field "thash", "bhash", "txIndex", "validRevisions", "nextRevisionID", "accessList" are not copied to the new object
// Copy creates a deep, independent copy of the state.//// NOTE: Snapshots of the copied state cannot be applied to the copy.func (csdb*CommitStateDB) Copy() *CommitStateDB {
// copy all the basic fields, initialize the memory onesstate:=&CommitStateDB{}
CopyCommitStateDB(csdb, state)
returnstate
}
funcCopyCommitStateDB(from, to*CommitStateDB) {
from.lock.Lock()
deferfrom.lock.Unlock()
to.ctx=from.ctxto.storeKey=from.storeKeyto.paramSpace=from.paramSpaceto.accountKeeper=from.accountKeeperto.stateObjects= []stateEntry{}
to.addressToObjectIndex=make(map[ethcmn.Address]int)
to.stateObjectsDirty=make(map[ethcmn.Address]struct{})
to.refund=from.refundto.logSize=from.logSizeto.preimages=make([]preimageEntry, len(from.preimages))
to.hashToPreimageIndex=make(map[ethcmn.Hash]int, len(from.hashToPreimageIndex))
to.journal=newJournal()
// copy the dirty states, logs, and preimagesfor_, dirty:=rangefrom.journal.dirties {
// There is a case where an object is in the journal but not in the// stateObjects: OOG after touch on ripeMD prior to Byzantium. Thus, we// need to check for nil.//// Ref: https://github.com/ethereum/go-ethereum/pull/16485#issuecomment-380438527ifidx, exist:=from.addressToObjectIndex[dirty.address]; exist {
to.stateObjects=append(to.stateObjects, stateEntry{
address: dirty.address,
stateObject: from.stateObjects[idx].stateObject.deepCopy(to),
})
to.addressToObjectIndex[dirty.address] =len(to.stateObjects) -1to.stateObjectsDirty[dirty.address] =struct{}{}
}
}
// Above, we don't copy the actual journal. This means that if the copy is// copied, the loop above will be a no-op, since the copy's journal is empty.// Thus, here we iterate over stateObjects, to enable copies of copies.foraddr:=rangefrom.stateObjectsDirty {
ifidx, exist:=to.addressToObjectIndex[addr]; !exist {
to.setStateObject(from.stateObjects[idx].stateObject.deepCopy(to))
to.stateObjectsDirty[addr] =struct{}{}
}
}
// copy pre-imagesfori, preimageEntry:=rangefrom.preimages {
to.preimages[i] =preimageEntryto.hashToPreimageIndex[preimageEntry.hash] =i
}
}
The text was updated successfully, but these errors were encountered:
summerpro
changed the title
The function Copy from CommitStateDB did not complete the copy of some fields
The function "Copy" from "CommitStateDB" did not complete the copy of some fields
Jan 13, 2021
System info: [Include Ethermint commit, operating system name, and other relevant details]
branch development
Copy function:
The field "thash", "bhash", "txIndex", "validRevisions", "nextRevisionID", "accessList" are not copied to the new object
The text was updated successfully, but these errors were encountered: