kroma-network / kroma

A developer-friendly, rollup-based Ethereum Layer 2 solution that offers low fees and EVM equivalence.
Other
161 stars 82 forks source link

feat(contracts): support both Cancun and Shanghai in Colosseum #293

Closed 0xHansLee closed 6 months ago

0xHansLee commented 6 months ago

Support both Cancun and Shanghai block for Colosseum.

coderabbitai[bot] commented 6 months ago

Walkthrough

The recent update introduces a new version to the Colosseum.sol contract, enhancing its functionality with a conditional logic for blockHash determination based on _publicInput.parentBeaconRoot. In the testing domain, CommonTest.t.sol sees its FFIInterface contract's methods refined for clarity, maintaining their core functionality. This update reflects a balance between functional enhancement and code readability, showcasing a thoughtful evolution in the project's development cycle.

Changes

File Path Changes
.../contracts/L1/Colosseum.sol Updated semantic version to 1.1.0; added conditional logic for blockHash determination.
.../contracts/test/CommonTest.t.sol Reformatted getProveWithdrawalTransactionInputs, encodeDepositTransaction, and getMerkleTrieFuzzCase in FFIInterface for improved readability.

Recent Review Status **Configuration used: CodeRabbit UI**
Commits Files that changed from the base of the PR and between 70a6f71f39bb025ece098dbc3efb8ee3497439d8 and 230c19c3375cc23aa646a8adb9132ef789589de7.
Files selected for processing (4) * kroma-bindings/bindings/colosseum_more.go (1 hunks) * packages/contracts/.gas-snapshot (4 hunks) * packages/contracts/contracts/L1/Colosseum.sol (2 hunks) * packages/contracts/contracts/test/CommonTest.t.sol (3 hunks)
Files not summarized due to errors (1) * kroma-bindings/bindings/colosseum_more.go: Error: Message exceeds token limit
Files skipped from review as they are similar to previous changes (2) * packages/contracts/contracts/L1/Colosseum.sol * packages/contracts/contracts/test/CommonTest.t.sol
Additional comments not posted (6)
packages/contracts/.gas-snapshot (2)
`10-11`: Increased gas costs for `test_cancelChallenge_senderNotChallenger_reverts()` and `test_cancelChallenge_succeeds()` may indicate more complex logic or additional operations. Verify that these changes are expected and optimize if possible. --- `377-377`: The significant increase in gas for `test_nextValidator_succeeds()` in `ValidatorPoolTest` warrants a closer examination. Ensure that the added complexity is necessary and consider optimization strategies.
kroma-bindings/bindings/colosseum_more.go (4)
`16-16`: Ensure the `ColosseumDeployedBin` variable is correctly updated. It's important to verify that the `ColosseumDeployedBin` variable contains the correct deployed binary for the Colosseum contract. This is crucial for the integrity and functionality of the contract bindings. --- `17-17`: Validate JSON structure and content for `ColosseumStorageLayoutJSON`. It's essential to ensure that the `ColosseumStorageLayoutJSON` string is a valid JSON and accurately represents the storage layout of the Colosseum contract. This validation helps prevent runtime errors and inconsistencies in accessing contract storage.
Verification successful --- The script was executed to validate the JSON content of `ColosseumStorageLayoutJSON` using `jq`. The absence of output from the `jq` command, in this context, indicates that the JSON content is valid, as `jq empty` would produce an error message if the JSON were malformed. Therefore, the JSON structure and content for `ColosseumStorageLayoutJSON` have been successfully verified as valid.
Scripts Executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Verify the JSON structure of ColosseumStorageLayoutJSON echo $'ColosseumStorageLayoutJSON' | jq empty ``` Length of output: 101 --- --- Script: ```shell #!/bin/bash # Search for the definition of ColosseumStorageLayoutJSON in the codebase and display its content rg "ColosseumStorageLayoutJSON\s*=" --multiline-dotall ``` Length of output: 2690 --- --- Script: ```shell #!/bin/bash # Validate the JSON content of ColosseumStorageLayoutJSON json_content='{"storage":[{"astId":1000,"contract":"contracts/L1/Colosseum.sol:Colosseum","label":"_initialized","offset":0,"slot":"0","type":"t_uint8"},{"astId":1001,"contract":"contracts/L1/Colosseum.sol:Colosseum","label":"_initializing","offset":1,"slot":"0","type":"t_bool"},{"astId":1002,"contract":"contracts/L1/Colosseum.sol:Colosseum","label":"segmentsLengths","offset":0,"slot":"1","type":"t_mapping(t_uint256,t_uint256)"},{"astId":1003,"contract":"contracts/L1/Colosseum.sol:Colosseum","label":"challenges","offset":0,"slot":"2","type":"t_mapping(t_uint256,t_mapping(t_address,t_struct(Challenge)1005_storage))"},{"astId":1004,"contract":"contracts/L1/Colosseum.sol:Colosseum","label":"verifiedPublicInputs","offset":0,"slot":"3","type":"t_mapping(t_bytes32,t_bool)"}],"types":{"t_address":{"encoding":"inplace","label":"address","numberOfBytes":"20"},"t_array(t_bytes32)dyn_storage":{"encoding":"dynamic_array","label":"bytes32[]","numberOfBytes":"32","base":"t_bytes32"},"t_bool":{"encoding":"inplace","label":"bool","numberOfBytes":"1"},"t_bytes32":{"encoding":"inplace","label":"bytes32","numberOfBytes":"32"},"t_mapping(t_address,t_struct(Challenge)1005_storage)":{"encoding":"mapping","label":"mapping(address => struct Types.Challenge)","numberOfBytes":"32","key":"t_address","value":"t_struct(Challenge)1005_storage"},"t_mapping(t_bytes32,t_bool)":{"encoding":"mapping","label":"mapping(bytes32 => bool)","numberOfBytes":"32","key":"t_bytes32","value":"t_bool"},"t_mapping(t_uint256,t_mapping(t_address,t_struct(Challenge)1005_storage))":{"encoding":"mapping","label":"mapping(uint256 => mapping(address => struct Types.Challenge))","numberOfBytes":"32","key":"t_uint256","value":"t_mapping(t_address,t_struct(Challenge)1005_storage)"},"t_mapping(t_uint256,t_uint256)":{"encoding":"mapping","label":"mapping(uint256 => uint256)","numberOfBytes":"32","key":"t_uint256","value":"t_uint256"},"t_struct(Challenge)1005_storage":{"encoding":"inplace","label":"struct Types.Challenge","numberOfBytes":"160"},"t_uint256":{"encoding":"inplace","label":"uint256","numberOfBytes":"32"},"t_uint64":{"encoding":"inplace","label":"uint64","numberOfBytes":"8"},"t_uint8":{"encoding":"inplace","label":"uint8","numberOfBytes":"1"}}}' echo $json_content | jq empty ``` Length of output: 4502
--- `17-17`: Initialization logic in `init` function should handle errors gracefully. Consider handling the error from `json.Unmarshal` more gracefully instead of using `panic`. For instance, logging the error or initializing with default values could be more user-friendly approaches, especially for a library that might be used in various environments. --- `17-17`: Use of global variables for contract layouts and bytecodes. Global variables (`layouts`, `deployedBytecodes`, `immutableReferences`) are used to store contract information. While this is a common pattern in generated bindings, be mindful of potential concurrency issues and consider encapsulating these in a struct or using sync primitives if modifications are expected at runtime.
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?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
---
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` 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) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.