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
import
std/[importutils, tables],
eth/trie/trie_defs,
eth/common/eth_types,
stew/[byteutils, endians2],
unittest2,
../nimbus/db/storage_types,
../nimbus/db/core_db,
../nimbus/db/ledger,
../nimbus/db/ledger/accounts_ledger {.all.} # import all private symbolsfuncinitAddr(z: int): EthAddress=const L =sizeof(result)
result[L-sizeof(uint32)..^1] =toBytesBE(z.uint32)
prockvtLen(db: CoreDbRef): int=let kvt = db.kvt
for _, _ in kvt:
incresultprocmptLen(db: LedgerRef): int=let mpt = db.getMpt
for _, _ in mpt:
incresulttest"storage trie removed from database":
let addr1 =initAddr(1)
let addr2 =initAddr(2)
let ac =LedgerRef.init(memDB, EMPTY_ROOT_HASH)
ac.addBalance(addr1, 1.u256)
ac.setStorage(addr1, 1.u256, 1.u256)
ac.persist()
# only one storage triecheck memDB.kvtLen ==1# only one accountcheck ac.mptLen ==1
ac.addBalance(addr2, 1.u256)
ac.setStorage(addr2, 1.u256, 1.u256)
ac.persist()
let root1 = ac.state()
# both addr1 and addr2 share the same storage trie# only one storage triecheck memDB.kvtLen ==1# ok # I think this should 2 storage tries, one for each account.# now there are two accountscheck ac.mptLen ==2# ok
ac.setStorage(addr2, 2.u256, 1.u256)
ac.persist()
# now there will be two storage triescheck memDB.kvtLen ==2# ok# delete slot 2
ac.setStorage(addr2, 2.u256, 0.u256)
ac.persist()
# the state root should be the same as when there is no slot 2 of addr2check ac.state() == root1 # okcheck memDB.kvtLen ==1# fails with 2 storage tries in db
ac.deleteAccount(addr2)
ac.persist()
check memDB.kvtLen ==1# fails with 2 storage tries in db# only one accountcheck ac.mptLen ==1# ok
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: