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
WIP: add support for transient storage in the solidity #14957
base: develop
Are you sure you want to change the base?
Conversation
Thank you for your contribution to the Solidity compiler! A team member will follow up shortly. If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother. If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix. |
890cbef
to
432df7f
Compare
Great initiative! I think it should also allow declaring function arguments as transient, e.g. |
Yes, AFAIK
|
NOTE: This is far from being complete or usable in production. The parser is modified to expect the "transient" keyword on contract-level declarations, as well as local variables. Most of the focus is spent on making the former correct, so YMMV with the latter, espcially in regards to array/reference handling. The CompilerContext internally separates storage variables from transient variables and computes a StorageOffset map for each. This is used to ensure transient and persistent storage aren't overwriting each other in the same namespace. Compiling the Test.sol and TestStorage.sol contracts and diffing the bytecode results in the SLOAD/SSTORE instructions being replaced by TLOAD/TSTORE instructions. AFAICT there are unreachable portions of the bytecode that differ between the two, which presumably relates to the metadata hash appended by the compiler. There are certainly a ton of edge cases in regard to properly processing the AST, but this should suffice for some demos.
mapping(uint256 => uint256) transient myMapping; not processed correctly
- support Transient location in ArrayType and ArrayUtils. - support location in derivation of Mapping. (mapping might be in a storage struct or a transient struct)
162a193
to
ba8e5e7
Compare
WIP:
|
1f83e79
to
5ad7fb7
Compare
--optimize-yul does appear to work, but --optimize removes some transiant operations
Compiler can be found here: ethereum/solidity#14957 Commit: Amxx/solidity@f2c760e
Compiler can be found here: ethereum/solidity#14957 Commit: Amxx/solidity@f2c760e
@Amxx thank you for your effort! |
Hey @Amxx! Thanks so much for putting in the time and effort in understanding the compiler and putting this PR together. We appreciate you for taking this crucial first step and helping the team gauge the community's interest for high-level language support for transient storage. We just posted a discussion thread on our forum as our public response to recognise the current community interest and efforts around support for transient storage and share the challenges around implementation discussed with you during the previous language design call. Our post also outlines the next steps that the team will be working on to further the progress in this area. You can check out the catch-all issue to stay updated. Cheers! |
Interesting fact, that @1inch team started using Can't wait to uncomment |
Hey @Amxx ! I would like to assist in this build. Please let me know if you need any help or have any tasks for me! |
EIP-1153 is now live on mainnet since DenCun, a week ago. The community shows a lot of interrest for transient storage, yet it is not nativelly supported by solidity. A quick search did not bring any ongoing effort to add that support.
EIP-1153 states that:
Its unfortunatrlly not that easy ... but come on, I'm sure as a community we can do this!
Note: this is very early ... No where near ready ... Probably not doing things the right way ... but at least its something.
I'l try to work on that. Anyone if free to comment on this, or start another effort (based or not on this).
My analysis so far
transient is both a "Mutation" and a "Location"
Note that this mutation applies to non-value type (struct, string, array, even mapping!)
sload
/sstore
withtload
/tstore
TODO