implement 'getCommittedStorage'
This commit is contained in:
parent
a3efd54d90
commit
97e89b3afe
|
@ -16,6 +16,7 @@ logScope:
|
|||
type
|
||||
AccountStateDB* = ref object
|
||||
trie: SecureHexaryTrie
|
||||
originalRoot: KeccakHash # will be updated for every transaction
|
||||
|
||||
ReadOnlyStateDB* = distinct AccountStateDB
|
||||
|
||||
|
@ -29,6 +30,7 @@ proc newAccountStateDB*(backingStore: TrieDatabaseRef,
|
|||
root: KeccakHash, pruneTrie: bool): AccountStateDB =
|
||||
result.new()
|
||||
result.trie = initSecureHexaryTrie(backingStore, root, pruneTrie)
|
||||
result.originalRoot = root
|
||||
|
||||
template createRangeFromAddress(address: EthAddress): ByteRange =
|
||||
## XXX: The name of this proc is intentionally long, because it
|
||||
|
@ -208,8 +210,15 @@ proc isDeadAccount*(db: AccountStateDB, address: EthAddress): bool =
|
|||
result = true
|
||||
|
||||
proc getCommittedStorage*(db: AccountStateDB, address: EthAddress, slot: UInt256): UInt256 =
|
||||
discard
|
||||
# TODO: stub
|
||||
let tmpHash = db.rootHash
|
||||
db.rootHash = db.originalRoot
|
||||
var exists: bool
|
||||
(result, exists) = db.getStorage(address, slot)
|
||||
db.rootHash = tmpHash
|
||||
|
||||
proc updateOriginalRoot*(db: AccountStateDB) =
|
||||
## this proc will be called for every transaction
|
||||
db.originalRoot = db.rootHash
|
||||
|
||||
proc rootHash*(db: ReadOnlyStateDB): KeccakHash {.borrow.}
|
||||
proc getAccount*(db: ReadOnlyStateDB, address: EthAddress): Account {.borrow.}
|
||||
|
|
|
@ -67,6 +67,7 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
|
|||
debug "state clearing", account
|
||||
db.deleteAccount(account)
|
||||
|
||||
vmState.accountDb.updateOriginalRoot()
|
||||
result = gasUsed
|
||||
|
||||
type
|
||||
|
|
Loading…
Reference in New Issue