Skip to content
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

Problem: can't support prevrando opcode #1366

Merged
merged 6 commits into from
Apr 2, 2024

Conversation

mmsqe
Copy link
Collaborator

@mmsqe mmsqe commented Mar 29, 2024

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

Closes #1367

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Summary by CodeRabbit

  • New Features

    • Introduced a new Solidity smart contract Random for generating random token IDs.
    • Added a governance proposal test for updating EVM parameters.
    • Updated the upgrade process to version "v1.2" for simplification.
    • Added configuration for a RandomOpcodeFork to enable specific functionality based on block height and chain ID.
    • Enhanced the initialization logic with RandomOpcodeForkEnabled parameter in the New function call.
    • Implemented a map RandomOpcodeForkHeights to store fork heights and a function RandomOpcodeForkEnabled for checking random opcode fork status.
  • Bug Fixes

    • Enhanced the export method in cosmoscli.py for improved flexibility and customization.
  • Documentation

    • Updated the CHANGELOG.md to reflect changes in random opcode behavior.
  • Chores

    • Updated module version and repository in gomod2nix.toml.
    • Adjusted package version and path naming in upgrade-test-package.nix.
    • Refactored test and configuration files for clarity and efficiency.
  • Tests

    • Added and refactored integration tests to cover new features and changes.

@mmsqe mmsqe requested a review from a team as a code owner March 29, 2024 00:51
@mmsqe mmsqe requested review from calvinaco and devashishdxt and removed request for a team March 29, 2024 00:51
Copy link
Contributor

coderabbitai bot commented Mar 29, 2024

Walkthrough

This series of updates introduces a new Solidity smart contract for random number generation, enhances testing for EVM parameter updates, and simplifies the upgrade process in the application code. It also includes updates to configuration files and testing utilities to support these changes. The modifications aim to address issues with random number generation post-upgrade and improve the overall robustness and flexibility of the system.

Changes

Files Summary
integration_tests/contracts/contracts/Random.sol, integration_tests/utils.py Introduced a new smart contract for random number generation and updated utility mappings.
integration_tests/test_gov_update_params.py, integration_tests/network.py Enhanced testing for EVM parameter updates and added flexibility in network setup.
CHANGELOG.md, default.nix Updated software version and maintained random opcode functionality.
app/upgrades.go, app/app.go, app/forks.go Simplified upgrade process and added parameters for random opcode fork.
integration_tests/configs/cosmovisor.jsonnet, integration_tests/configs/upgrade-test-package.nix Adjusted configurations for testing environments and upgrade processes.

Assessment against linked issues

Objective Addressed Explanation
Random Number Generation Issue Post Titan Upgrade (#1367)

Poem

"In the realm of code, where logic reigns, 🌟
A rabbit hopped, through bugs and chains. 🐇
With each leap forward, a fix in sight,
It mended the code, with all its might.
Through tests and trials, it found its way,
A beacon of hope, in a world of gray.
So here's to the changes, both big and small,
A rabbit's touch, improving it all. 🚀"

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

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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 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/coderabbit-overrides.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 96642b2 and 6b4c2b5.
Files selected for processing (3)
  • integration_tests/contracts/contracts/Random.sol (1 hunks)
  • integration_tests/test_gov_update_params.py (1 hunks)
  • integration_tests/utils.py (1 hunks)
Additional Context Used
Additional comments not posted (3)
integration_tests/contracts/contracts/Random.sol (1)

4-8: The contract implementation looks correct and follows best practices for generating a pseudo-random number in Solidity. However, it's important to note that the use of block.prevrandao for randomness is environment-specific and might not be available on all EVM-compatible chains. Consider adding a comment to clarify this dependency.

integration_tests/test_gov_update_params.py (2)

11-51: The test test_evm_update_param is well-implemented and covers the process of deploying contracts, querying parameters, creating a governance proposal to update EVM parameters, and testing the parameter update process. Consider adding comments to explain the logic behind specific steps, especially the rationale for expecting certain error messages, to improve readability and maintainability.


53-53: The test test_gov_update_params appears to be correctly implemented but lacks detailed comments explaining its purpose and the steps involved. Adding such comments would enhance the readability and maintainability of the test.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6b4c2b5 and cd12326.
Files selected for processing (1)
  • integration_tests/test_gov_update_params.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • integration_tests/test_gov_update_params.py
Additional Context Used

@mmsqe mmsqe changed the title Problem: update evm param is not tested Problem: can't support prevrando opcode Mar 29, 2024
go.mod Outdated Show resolved Hide resolved
@mmsqe mmsqe requested a review from yihuang March 29, 2024 14:39
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between cd12326 and a96519d.
Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum
Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • app/upgrades.go (1 hunks)
  • gomod2nix.toml (1 hunks)
  • integration_tests/configs/cosmovisor.jsonnet (1 hunks)
  • integration_tests/configs/upgrade-test-package.nix (1 hunks)
  • integration_tests/cosmoscli.py (1 hunks)
  • integration_tests/test_upgrade.py (11 hunks)
Files not reviewed due to errors (2)
  • gomod2nix.toml (Error: unable to parse review)
  • CHANGELOG.md (Error: unable to parse review)
Additional Context Used
Additional comments not posted (7)
integration_tests/configs/upgrade-test-package.nix (1)

10-16: The update of the package version from v1.0.12 to v1.1.1 and the adjustment of the package path naming from "v1.1.0" to "v1.1" are noted. Please ensure that these changes are consistently applied across the entire project to avoid any potential issues with dependencies or package resolution.

Verification successful

The verification process confirms that the version update to v1.1.1 and the adjustment of the package path naming to "v1.1" are consistently applied across the project where necessary. The changes align with the project's requirements and objectives.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new version and path naming are consistently used across the project.
rg --type nix 'v1\.1\.1' || echo "Version v1.1.1 not found in other Nix files."
rg --type nix 'v1\.1' || echo "Path naming v1.1 not found in other Nix files."

Length of output: 330

integration_tests/configs/cosmovisor.jsonnet (2)

11-15: The addition of consensus_params with block settings is noted. Please ensure that these settings are aligned with the network's governance and consensus rules.


18-27: The restructuring of app_state by moving send_enabled under bank and adjusting feemarket parameters is noted. Please ensure that these changes are thoroughly reviewed and approved as per the network's governance processes.

integration_tests/test_upgrade.py (3)

64-68: Refactoring fixture names and adjusting function parameters in the setup for the upgrade test are noted. Please ensure that these changes accurately reflect the intended setup for testing the upgrade process.


85-91: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [88-100]

The changes to the upgrade process, including proposing an upgrade and passing it, are noted. Please ensure that the upgrade process is thoroughly reviewed and tested to confirm its accuracy and reliability.


118-124: The deployment of a new contract and the handling of contract calls differently post-upgrade are significant changes. Please ensure that these changes are thoroughly tested to confirm that they accurately reflect the intended behavior post-upgrade.

integration_tests/cosmoscli.py (1)

898-899: The modification to the export method to accept keyword arguments enhances its flexibility and is a good practice for future-proofing the method. Ensure that the use of this method across the codebase is audited to prevent the unintentional passing of parameters that could alter its behavior in unexpected ways.

Verification successful

The usage of the export method in integration_tests/test_upgrade.py with a keyword argument demonstrates correct utilization of the method's enhanced flexibility. This indicates that the change to the method is compatible with its current uses in the codebase. However, it's advisable to conduct a broader audit of the method's usage if more extensive changes are made in the future or if the method is used in more complex scenarios.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of the `export` method to ensure it's used correctly with the new keyword arguments capability.
rg --type py 'export\('

Length of output: 170

app/upgrades.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Mar 29, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 35.37%. Comparing base (96642b2) to head (abf3b62).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1366       +/-   ##
===========================================
+ Coverage   15.90%   35.37%   +19.47%     
===========================================
  Files          80      129       +49     
  Lines        6230    11643     +5413     
===========================================
+ Hits          991     4119     +3128     
- Misses       5160     7147     +1987     
- Partials       79      377      +298     
Files Coverage Δ
app/upgrades.go 25.00% <50.00%> (-18.00%) ⬇️

... and 74 files with indirect coverage changes

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a96519d and 2165988.
Files selected for processing (1)
  • integration_tests/test_gov_update_params.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • integration_tests/test_gov_update_params.py
Additional Context Used

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2165988 and 9d060fc.
Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum
Files selected for processing (6)
  • app/app.go (1 hunks)
  • app/forks.go (1 hunks)
  • gomod2nix.toml (1 hunks)
  • integration_tests/configs/fork.jsonnet (1 hunks)
  • integration_tests/network.py (2 hunks)
  • integration_tests/test_fork.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • gomod2nix.toml
Additional Context Used
Additional comments not posted (8)
integration_tests/configs/fork.jsonnet (1)

1-9: The configuration changes are well-structured and follow best practices for modularity and reusability.

integration_tests/test_fork.py (2)

11-18: The fixture setup is clear and well-structured. Consider adding a comment explaining why the specific chain ID and configuration are chosen for this test.


21-35: The test case is well-implemented. It would be beneficial to add more comments explaining each step of the test and the expected outcomes, especially why the "invalid memory address or nil pointer dereference" error is expected initially and why deploying the "Greeter" contract changes the outcome.

app/forks.go (2)

34-39: The RandomOpcodeForkHeights map is crucial for determining when the fork is enabled. Ensure that the fork heights are finalized and accurate. Consider removing the TODO comment after finalizing the values or providing more context about the decision-making process.


41-43: The implementation of RandomOpcodeForkEnabled is straightforward and effective. It's important to ensure that the fork heights in RandomOpcodeForkHeights are accurate for this function to work as intended.

integration_tests/network.py (2)

161-161: Adding a default value for the chain_id parameter in setup_custom_cronos increases flexibility for testing. Consider adding a comment explaining why "cronos_777-1" is chosen as the default value.


190-190: The modification to yield a Cronos instance with a dynamic path based on the chain_id is a good practice for ensuring test isolation and clarity. This change enhances the flexibility and readability of the testing setup.

app/app.go (1)

545-545: The addition of RandomOpcodeForkEnabled as a parameter in the New function is noted. Please ensure that this parameter is effectively used to toggle the support for the prevrando opcode, particularly in the EVM keeper's initialization or configuration.

@mmsqe mmsqe force-pushed the update_evm_param branch from 9d060fc to 7ba16e3 Compare April 2, 2024 02:49
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2165988 and 7ba16e3.
Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • app/upgrades.go (1 hunks)
  • default.nix (1 hunks)
  • integration_tests/configs/upgrade-test-package.nix (1 hunks)
  • integration_tests/test_upgrade.py (11 hunks)
Files not reviewed due to errors (1)
  • (no review received)
Files skipped from review as they are similar to previous changes (2)
  • integration_tests/configs/upgrade-test-package.nix
  • integration_tests/test_upgrade.py
Additional Context Used
Additional comments not posted (2)
app/upgrades.go (1)

12-12: The upgrade plan name has been updated to "v1.2". Ensure that all references to the upgrade plan across the codebase and documentation are consistently updated to reflect this change.

Verification successful

The search did not find any references to the old upgrade plan name "v1.1" in Go files, indicating that the upgrade plan name has been consistently updated to "v1.2" across the codebase in Go files.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any occurrences of the old upgrade plan name "v1.1" to ensure they have been updated.
rg 'v1\.1' --type go || echo "No references to the old upgrade plan name found."

Length of output: 131

default.nix (1)

14-14: The version has been updated to "v1.2.0". This change should be reflected in all relevant documentation, release notes, and any other places where the version number is mentioned to ensure consistency across the project.

app/upgrades.go Show resolved Hide resolved
@mmsqe mmsqe enabled auto-merge April 2, 2024 06:33
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 7ba16e3 and abf3b62.
Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum
Files selected for processing (1)
  • gomod2nix.toml (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • gomod2nix.toml

@mmsqe mmsqe added this pull request to the merge queue Apr 2, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 2, 2024
@mmsqe mmsqe added this pull request to the merge queue Apr 2, 2024
Merged via the queue into crypto-org-chain:main with commit 1ca1b14 Apr 2, 2024
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random Number Generation Issue Post Titan Upgrade
2 participants