Skip to content

Commit

Permalink
should clear transient storage after tx execution
Browse files Browse the repository at this point in the history
  • Loading branch information
yann300 authored and Aniket-Engg committed Sep 2, 2024
1 parent 06d02b8 commit 62bc90e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
36 changes: 35 additions & 1 deletion apps/remix-ide-e2e/src/tests/eip1153.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
})
}
}

Expand All @@ -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;
}
}`
1 change: 1 addition & 0 deletions libs/remix-lib/src/execution/txRunnerVM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 62bc90e

Please sign in to comment.