zeta-chain / protocol-contracts

Protocol contracts implementing the core logic of the protocol, deployed on ZetaChain and on connected chains
MIT License
68 stars 55 forks source link

Fix solidy from 0.8.7 to ^0.8.0 and fix build command failed issue #243

Closed lispking closed 1 month ago

lispking commented 2 months ago

Summary by CodeRabbit

coderabbitai[bot] commented 2 months ago

Walkthrough

The primary change across the Solidity files involves updating the version pragma from a fixed version (0.8.7) to a more flexible range (^0.8.0). This enhancement improves compatibility with future compiler versions while ensuring stability within the 0.8.x series. Overall logic and functionality of the contracts remain unchanged, facilitating smoother upgrades and integration with newer features.

Changes

Files Grouped by Changes Change Summary
contracts/evm/*.sol, contracts/prototypes/*.sol, contracts/zevm/*.sol, contracts/zevm/interfaces/*.sol, contracts/evm/interfaces/*.sol Updated Solidity pragma from 0.8.7 to ^0.8.0, enhancing compatibility with future compiler versions while preserving existing functionality.
hardhat.config.ts Updated dependency version from 0.8.7 to 0.8.18, suggesting an upgrade that may include improvements or new features.
test/fuzz/readme.md Updated documentation to reflect the use of Solidity compiler version 0.8.18 instead of 0.8.7.
testFoundry/*.t.sol Updated Solidity pragma from 0.8.7 to ^0.8.0, enhancing compatibility with future compiler versions while maintaining functionality.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Compiler
    participant Contract

    Developer->>Compiler: Compile with ^0.8.0
    Compiler->>Contract: Load and prepare for execution
    Contract->>Compiler: Execute logic
    Compiler-->>Developer: Provide output and results

🐇 In the fields, the rabbit hops,
Twisting code like candy shops.
With versions flexed, the future's bright,
Upgrades come, a joyful sight.
In Solidity's garden, we all play,
Hopping along, come what may! 🐰✨


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.` - `@coderabbitai help me debug CodeRabbit configuration file.` 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 an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configuration 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.
lispking commented 2 months ago

I may think it is in general a better practice to specify a fixed version for Solidity if these are production contracts

I don't think so, because what you have is a library that others depend on. You can't require all dependencies to use version 0.8.7. Moreover, if this version causes other users to be on a different version(like 0.8.18), it would force them to downgrade to the same version. It's not right to impose such restrictions on users.

Additionally, when integrating with your contracts, the demo requires users to initialize by depending on SystemContract. This design is also very unreasonable. For users, they only need to know the contract address.

lispking commented 2 months ago

The specific version should be resolved by the compiler, not hardcoded into the code like this. @lumtis

lispking commented 2 months ago

@lumtis These are all industry best practices.

For example, with a library like IERC20, a similar approach is taken by specifying a minimum version requirement:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol

skosito commented 2 months ago

@lumtis @lispking good discussion, i also had issue with hardcoded 0.8.7 when importing 3rd party contracts making it not possible for foundry to resolve sol version, so i changed to ^0.8.0 version in some contracts and version was resolved

will check these changes in more details

fadeev commented 2 months ago

@lispking thanks for taking the time to look into versions of the protocol contracts! It's up to the protocol team to decide how to move forward, but if you want to contribute to ZetaChain on a more regular basis, consider the tech ambassador program: https://zetachain.deform.cc/TechAmbassadors 🙌

lumtis commented 2 months ago

Hi @lispking , we are currently in the process of refactoring the environment to have v1 and v2 contracts separated and use latest Solidity version for v2 contracts.

v1 contracts are no longer in active development.

Did you want this change for some specific contracts in the codebase?

lispking commented 2 months ago

Hi @lispking , we are currently in the process of refactoring the environment to have v1 and v2 contracts separated and use latest Solidity version for v2 contracts.

v1 contracts are no longer in active development.

Did you want this change for some specific contracts in the codebase?

@lumtis Sure, no problem. Which is the codebase contract address? If needed, I can help with modifications and testing.

If there are no issues with this, it can be merged first. thx.

lumtis commented 2 months ago

Hi @lispking , we are currently in the process of refactoring the environment to have v1 and v2 contracts separated and use latest Solidity version for v2 contracts. v1 contracts are no longer in active development. Did you want this change for some specific contracts in the codebase?

@lumtis Sure, no problem. Which is the codebase contract address? If needed, I can help with modifications and testing.

If there are no issues with this, it can be merged first. thx.

This is the PR for separating the two codebases: https://github.com/zeta-chain/protocol-contracts/pull/268

To reduce the overhead on conflicts, we will prioritize merging it. We can check if there is still an issue afterward.

andresaiello commented 2 months ago

I may think it is in general a better practice to specify a fixed version for Solidity if these are production contracts

in general every audit (I had several) recommend to use a fixed version. The main reason is to guarantee if someone else (or you on test enviroments) wants to replicate can be sure to have the same results. I have opposite feelings about this but according to audits always is fixed.

lumtis commented 1 month ago

Closing as version as been updated for contracts V2