Skip to content

Commit

Permalink
VM: reimplement transient storage clear method
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrocheleau committed May 17, 2022
1 parent b494c72 commit 575a679
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vm/src/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise<RunTxResult> {
this.evm._refund = BigInt(0)
await state.cleanupTouchedAccounts()
state.clearOriginalStorageCache()
if (this._common.isActivatedEIP(1153)) this.evm._transientStorage.clear()

// Generate the tx receipt
const gasUsed = opts.blockGasUsed !== undefined ? opts.blockGasUsed : block.header.gasUsed
Expand Down
8 changes: 8 additions & 0 deletions packages/vm/src/state/transientStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,12 @@ export default class TransientStorage {
}
return result
}

/**
* Clear transient storage state.
*/
public clear(): void {
this._storage = new Map()
this._changeJournal = []
}
}

0 comments on commit 575a679

Please sign in to comment.