-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce transient storage support for inline assembly #14737
Conversation
36ce9cb
to
69fabc5
Compare
@@ -314,6 +314,11 @@ u256 EVMInstructionInterpreter::eval( | |||
accessMemory(arg[0], arg[1]); | |||
logTrace(_instruction, arg); | |||
return 0; | |||
case Instruction::TLOAD: | |||
return m_state.storage[h256(arg[0])]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/libsolidity/syntaxTests/inlineAssembly/tload_reserved_cancun.sol
Outdated
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
7449a20
to
e18de2e
Compare
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few optimizer tests missing, but otherwise looks good.
test/libyul/yulOptimizerTests/unusedPruner/transient_storage.yul
Outdated
Show resolved
Hide resolved
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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