diff --git a/apps/remix-ide-e2e/src/tests/eip1153.test.ts b/apps/remix-ide-e2e/src/tests/eip1153.test.ts index 1f8598c49cd..acecf5a0136 100644 --- a/apps/remix-ide-e2e/src/tests/eip1153.test.ts +++ b/apps/remix-ide-e2e/src/tests/eip1153.test.ts @@ -31,7 +31,22 @@ module.exports = { 1: 'uint256: out2 15' } }) - .end() + }, + + 'Should clear transient storage after tx execution' : function (browser: NightwatchBrowser) { + browser.addFile('clear_transient.sol', { content: clearTransient }) + .clickLaunchIcon('solidity') + .verifyContracts(['ClearTransient']) + .clickLaunchIcon('udapp') + .createContract('') + .clickInstance(0) + .clickFunction('get - call') + .testFunction('last', + { + 'decoded output': { + 0: 'uint256: 0' + } + }) } } @@ -49,3 +64,22 @@ contract TestTransientStorage { } } }` + +const clearTransient = ` +// SPDX-License-Identifier: none +pragma solidity 0.8.26; +import "hardhat/console.sol"; + +contract ClearTransient { + uint p; + constructor() { + uint256 value; + assembly { value := tload(hex"1234") } + p = value; + assembly { tstore(hex"1234", 10) } + } + + function get () public view returns (uint) { + return p; + } +}` diff --git a/libs/remix-lib/src/execution/txRunnerVM.ts b/libs/remix-lib/src/execution/txRunnerVM.ts index 6c4c40b27b5..9447a8157bf 100644 --- a/libs/remix-lib/src/execution/txRunnerVM.ts +++ b/libs/remix-lib/src/execution/txRunnerVM.ts @@ -146,6 +146,7 @@ export class TxRunnerVM { const root = await this.getVMObject().stateManager.getStateRoot() this.runBlockInVm(tx, block, async (err, result) => { await this.getVMObject().stateManager.setStateRoot(root) + this.getVMObject().vm.evm.transientStorage.clear() callback(err, result) }) } else {