-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fix(protocol): tstore is not suppported on L2 now #15802
Conversation
WalkthroughThe changes across the files aim to enhance the protocol's functionality and deployment process. Variable names are refined, storage operations are optimized, and deployment configurations are adjusted to improve efficiency and maintainability based on blockchain chain IDs. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (1)
- packages/protocol/contracts/common/OwnerUUPSUpgradable.sol (2 hunks)
Additional comments: 1
packages/protocol/contracts/common/OwnerUUPSUpgradable.sol (1)
- 97-100: The updated
_storeReentryLock
function directly assigns thereentry
parameter to the_reentry
variable, removing the need for assembly. This simplification improves readability and safety. However, ensure that the removal of assembly code does not impact the intended low-level functionality, especially in the context of L2 solutions.
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to path filters (2)
packages/protocol/foundry.toml
is excluded by:!**/*.toml
packages/protocol/package.json
is excluded by:!**/*.json
Files selected for processing (3)
- packages/protocol/contracts/common/OwnerUUPSUpgradable.sol (2 hunks)
- packages/protocol/genesis/generate_genesis.test.sh (1 hunks)
- packages/protocol/utils/generate_genesis/taikoL2.ts (5 hunks)
Files skipped from review due to trivial changes (1)
- packages/protocol/genesis/generate_genesis.test.sh
Files skipped from review as they are similar to previous changes (1)
- packages/protocol/contracts/common/OwnerUUPSUpgradable.sol
Additional comments: 5
packages/protocol/utils/generate_genesis/taikoL2.ts (5)
- 302-302: The addition of
_reentry: 1
is intended to indicate a false state for reentrancy checks. Confirm that the value1
correctly represents the intended false state in the context of the contract's logic.- 337-337: Similar to the previous comment, verify that
_reentry: 1
accurately reflects the intended logic, especially since it's being used to indicate a non-reentrant state.- 372-372: Ensure that the use of
_reentry: 1
for theERC721Vault
contract aligns with the contract's reentrancy guard logic and that1
is the correct representation of the non-reentrant state.- 407-407: For the
ERC1155Vault
contract, confirm that_reentry: 1
is the appropriate value to signify the non-reentrant state, consistent with the contract's reentrancy guard mechanism.- 466-466: Lastly, verify the correctness of
_reentry: 1
for theSignalService
contract, ensuring it properly represents the non-reentrant state as intended by the contract's logic.
|
A good idea, but I wonder if it will work. |
I dont think #15810 will work, since the compiled bytecode will still contain the |
Yes but that is currently okay right I think? Because currently the code is not checked yet when it is deployed (maybe in the future it will), so if some random opcode/byte value is part of the bytecode but it is not executed, I think it should be fine. |
I don't think it will work. Please see foundry-rs/foundry#6099 |
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- packages/protocol/script/test_deploy_on_l1.sh (1 hunks)
- packages/protocol/utils/generate_genesis/taikoL2.ts (5 hunks)
Files skipped from review due to trivial changes (1)
- packages/protocol/script/test_deploy_on_l1.sh
Files skipped from review as they are similar to previous changes (1)
- packages/protocol/utils/generate_genesis/taikoL2.ts
@Brechtpd I think for Bridge and OwnerUUPSUpgradable.sol, maybe we can extract the code that use transient storage into a small solidity file respectively then have a non-transient version. Then we write a preprocessing script to swap versions by renaming files, based on an env var. @davidtaikocha do you think that will work? |
So currently it should be fine to do it! But future versions of solidity it may be a problem. |
OK, seems we have a solution but PR still needs to be updated to change the Bridge.
Brecht, if you think this is a good solution, could you also modify the Bridge code? |
How long do we think it will take to update our L2 to cancun? Is the plan to do it before mainnet or not? If we will do it for mainnet, then maybe this seems more work than necessary, and the conditional trick should be okay I believe. If not, than indeed some longer term solution needs to be found and then something like this seems like a reasonable approach. Or maybe just use inheritance and have different contracts for L1 and L2? |
Tested in go-ethereum, it works. (compiled the code by a cancun compiler, then let it run inside a shanghai evm) |
Okay will do! |
I would say later, definitely not now. |
Okay, then conditional trick and just sticking to 0.8.24 compiler is actually fine as well. We can see with future compiler versions if there would be problems. |
Bridge updated |
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.
Review Status
Actionable comments generated: 4
Configuration used: CodeRabbit UI
Files selected for processing (2)
- packages/protocol/contracts/bridge/Bridge.sol (3 hunks)
- packages/protocol/contracts/common/OwnerUUPSUpgradable.sol (2 hunks)
Additional comments: 4
packages/protocol/contracts/bridge/Bridge.sol (4)
- 53-54: Introduction of
PLACEHOLDER
constant is a good practice for clarity when indicating non-use of transient storage. Ensure its usage is consistent across the contract.- 448-448: The check in
context
function usingPLACEHOLDER
ensures invalid contexts are correctly identified. This is a good use of the newly introduced constant.- 548-552: The conditional logic in
_resetContext
based onblock.chainid
is clear and maintains separation between L1 and L2 logic. However, ensure that the use ofPLACEHOLDER
for non-L1 chains aligns with the contract's overall design and security model.- 570-581: Similar to
_storeContext
, the_loadContext
function uses conditional logic based onblock.chainid
effectively. Ensure that the separation of logic does not introduce any unintended side effects.
According to David C, L2 is not on the same hardfork.
We can somehow use tstore for L1 contracts. But not sure what's the best way of doing it.
See foundry-rs/foundry#6099
Summary by CodeRabbit
OwnerUUPSUpgradable.sol
.Bridge.sol
for improved functionality.