Introduce transient storage support for inline assembly#14737
Conversation
36ce9cb to
69fabc5
Compare
| logTrace(_instruction, arg); | ||
| return 0; | ||
| case Instruction::TLOAD: | ||
| return m_state.storage[h256(arg[0])]; |
There was a problem hiding this comment.
This will need as separate key-value store in m_state, i.e. you'll need to add
std::map<util::h256, util::h256> triansientStorage; to InterpreterState. Also a quick look at whether we do anything specially for InterpreterState::storage would be good (e.g. if we reset it somewhere). Eventually for actual fuzzing/tracing, we will need an analog of InterpreterState::dumpStorage(std::ostream& _out) const; as well, but we can add that in a separate PR with fuzzing support for transient storage (@bshastry may want to get to that eventually - in that PR we can also check if we need to do anything further to account for the special lifetime of transient storage in the fuzzing setup)
|
I just had another quick look through this, and we should still really have some semantics tests for this. The easiest one would be a simple reentrancy lock, so something like: For more complex cases, like testing the behaviour across multiple transactions, we'd actually need to see how evmone handles this right now. So I'm actually not sure what the following test would do currently: Also a few of other sanity tests (showing collision-freeness with memory and storage and such) may be nice. |
This comment was marked as resolved.
This comment was marked as resolved.
b0b2f80 to
5e3c8d8
Compare
test/libsolidity/semanticTests/inlineAssembly/transient_storage_simple_reentrancy_lock.sol
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
4659659 to
d3f0271
Compare
test/libsolidity/syntaxTests/inlineAssembly/tstore_reserved_cancun.sol
Outdated
Show resolved
Hide resolved
test/libsolidity/semanticTests/inlineAssembly/transient_storage_simple_reentrancy_lock.sol
Outdated
Show resolved
Hide resolved
nikola-matic
left a comment
There was a problem hiding this comment.
This is gonna needs docs and a Changelog entry as well.
test/libsolidity/syntaxTests/inlineAssembly/transient_storage_invalid_pre_cancun.sol
Show resolved
Hide resolved
test/cmdlineTests/transient_storage_inline_assembly_opcodes_warning/args
Outdated
Show resolved
Hide resolved
d3f0271 to
461523a
Compare
|
I rebased the PR on |
4a440c8 to
dc62b1d
Compare
dc62b1d to
db30a43
Compare
...ity/semanticTests/inlineAssembly/transient_storage_multiple_calls_different_transactions.sol
Outdated
Show resolved
Hide resolved
2eefa79 to
35fe148
Compare
...ity/semanticTests/inlineAssembly/transient_storage_multiple_calls_different_transactions.sol
Outdated
Show resolved
Hide resolved
31de262 to
185bd64
Compare
d1f8767 to
dc4b94e
Compare
3764555 to
d3682a7
Compare
test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol
Outdated
Show resolved
Hide resolved
test/libsolidity/semanticTests/inlineAssembly/transient_storage_delegatecall.sol
Outdated
Show resolved
Hide resolved
test/libsolidity/semanticTests/inlineAssembly/transient_storage_call.sol
Outdated
Show resolved
Hide resolved
test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol
Outdated
Show resolved
Hide resolved
test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol
Outdated
Show resolved
Hide resolved
74da68c to
3638d7a
Compare
cameel
left a comment
There was a problem hiding this comment.
Looks like #14737 (comment) and #14737 (comment) are the only remaining things here. Once those are taken care of I'm going to approve it.
nikola-matic
left a comment
There was a problem hiding this comment.
There are a few optimizer tests missing, but otherwise looks good.
|
I just merged MCOPY PR so this needs conflict resolutions. |
b8f0d28 to
28e286a
Compare
|
Rebased and squashed commits. |
test/libsolidity/semanticTests/inlineAssembly/transient_storage_selfdestruct.sol
Show resolved
Hide resolved
cameel
left a comment
There was a problem hiding this comment.
ok, looks like we're done here. Please squash and we can merge.
37b2751 to
89b73b6
Compare
This PR introduces basic support for the transient storage opcodes TSTORE and TLOAD for inline assembly only.
Based on previous groundwork by @hrkrshnn (Thank you 🙏).
Part of #14739