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: push0 opcode is not tested #1273

Merged
merged 14 commits into from
Dec 22, 2023

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Dec 22, 2023

  • shanghai hardfork introduces push0 opcode, can be enabled in solc

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

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

  • Documentation

    • Updated the Solidity compiler version in documentation to reflect the latest version used in smart contracts.
  • New Features

    • Introduced support for hard-fork style upgrades in integration tests.
    • Enabled the push0 opcode in integration tests for enhanced smart contract capabilities.
  • Bug Fixes

    • Adjusted gas usage expectations in integration tests to align with the latest contract behavior.
  • Tests

    • Improved test configurations by adding new markers for unmarked and gas-related tests.
    • Enhanced test cases to assert correct gas usage after contract interactions.
    • Included additional test steps to wait for new blocks before transactions, ensuring more reliable test execution.

- shanghai hardfork introduces push0 opcode, can be enabled in solc
@yihuang yihuang requested a review from a team as a code owner December 22, 2023 01:35
@yihuang yihuang requested review from devashishdxt and thomas-nguy and removed request for a team December 22, 2023 01:35
Copy link
Contributor

coderabbitai bot commented Dec 22, 2023

Walkthrough

The updates across the various files primarily involve a shift in the Solidity version from 0.8.10 to 0.8.21, suggesting an alignment with the latest compiler features and optimizations. There's also a new evmVersion configuration, addition of test markers, and changes in gas usage expectations in tests, indicating refinements in testing strategies to accommodate new Ethereum Virtual Machine capabilities and adjustments in gas economics.

Changes

Files Summary
.../contracts/*.sol Updated Solidity pragma version from 0.8.10 to 0.8.21.
.../contracts/hardhat.config.ts Updated Solidity compiler version to 0.8.21 and added evmVersion as "shanghai".
.../conftest.py Added new test markers for unmarked and gas-related tests.
CHANGELOG.md Introduced support for hard-fork style upgrades and the push0 opcode.
.../test_basic.py, .../test_ibc_rly_gas.py, .../test_pruned_node.py, .../utils.py, .../test_min_gas_price.py, .../test_upgrade.py Adjustments in gas usage assertions and test setups, with additional test conditions and operations.

🐇✨
In the realm of code where smart contracts thrive,
A rabbit hopped through, version point twenty-one arrived.
With each Solidity line, the compiler entices,
Our tests now refined, with gas usage precise. 🌟📜

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions. Examples:
    • @coderabbitai render interesting statistics about this repository as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai generate unit tests for the src/utils.ts file.

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.
  • The JSON schema for the configuration file is available here.
  • 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

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: yihuang <[email protected]>
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b47e5c1 and 2c4fdb9.
Files selected for processing (11)
  • CHANGELOG.md (1 hunks)
  • integration_tests/contracts/contracts/CosmosToken.sol (1 hunks)
  • integration_tests/contracts/contracts/Gravity.sol (1 hunks)
  • integration_tests/contracts/contracts/ICosmosToken.sol (1 hunks)
  • integration_tests/contracts/contracts/TestBlackListERC20.sol (1 hunks)
  • integration_tests/contracts/contracts/TestCRC20.sol (1 hunks)
  • integration_tests/contracts/contracts/TestERC20A.sol (1 hunks)
  • integration_tests/contracts/contracts/TestERC20Utility.sol (1 hunks)
  • integration_tests/contracts/contracts/TestERC21Source.sol (1 hunks)
  • integration_tests/contracts/contracts/TestMaliciousSupply.sol (1 hunks)
  • integration_tests/contracts/hardhat.config.ts (1 hunks)
Files skipped from review due to trivial changes (3)
  • integration_tests/contracts/contracts/ICosmosToken.sol
  • integration_tests/contracts/contracts/TestBlackListERC20.sol
  • integration_tests/contracts/contracts/TestERC20Utility.sol
Additional comments: 7
integration_tests/contracts/contracts/TestERC20A.sol (1)
  • 1-1: Ensure that the contract TestERC20A has been thoroughly tested with the updated Solidity version 0.8.21 to prevent any unexpected behavior due to changes in the compiler.
integration_tests/contracts/hardhat.config.ts (1)
  • 7-12: Confirm that the Hardhat configuration changes, including the Solidity version upgrade to 0.8.21 and the evmVersion set to "shanghai", are compatible with the entire project and do not introduce any breaking changes.
integration_tests/contracts/contracts/TestMaliciousSupply.sol (1)
  • 1-1: Ensure that the contract TestMaliciousSupply has been thoroughly tested with the updated Solidity version 0.8.21 to prevent any unexpected behavior due to changes in the compiler, especially given the contract's purpose for testing edge cases.
integration_tests/contracts/contracts/TestCRC20.sol (1)
  • 1-1: Ensure that the contract TestCRC20 has been thoroughly tested with the updated Solidity version 0.8.21 to prevent any unexpected behavior due to changes in the compiler.
integration_tests/contracts/contracts/CosmosToken.sol (1)
  • 1-1: Ensure that the contract CosmosToken has been thoroughly tested with the updated Solidity version 0.8.21 to prevent any unexpected behavior due to changes in the compiler.
integration_tests/contracts/contracts/TestERC21Source.sol (1)
  • 1-1: Ensure that the contract TestERC21Source has been thoroughly tested with the updated Solidity version 0.8.21 to prevent any unexpected behavior due to changes in the compiler.
integration_tests/contracts/contracts/Gravity.sol (1)
  • 1-4: Ensure that the contract Gravity has been thoroughly tested with the updated Solidity version 0.8.21 and the new imports from the "@openzeppelin/contracts" library to prevent any unexpected behavior due to changes in the compiler and new dependencies.

CHANGELOG.md Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2c4fdb9 and 5df17e3.
Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

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.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 5df17e3 and a183cce.
Files selected for processing (5)
  • integration_tests/conftest.py (1 hunks)
  • integration_tests/test_basic.py (2 hunks)
  • integration_tests/test_ibc_rly_gas.py (1 hunks)
  • integration_tests/test_pruned_node.py (1 hunks)
  • integration_tests/utils.py (2 hunks)
Additional comments: 4
integration_tests/conftest.py (1)
  • 14-14: The addition of the "unmarked" marker to the pytest configuration is a good practice to handle tests without specific markers. Ensure that this new configuration is documented and that the team is aware of its usage.
integration_tests/test_pruned_node.py (1)
  • 49-49: The decrement of exp_gas_used by 1 should reflect an accurate expectation of gas usage for the transaction. Verify that this change is consistent with the gas costs observed after the push0 opcode update.
integration_tests/test_basic.py (2)
  • 54-54: The addition of assert receipt.gasUsed == 21000 assumes that the gas used for the transaction will always be exactly 21000. This is a common amount for a simple ETH transfer, but it may not hold true for all environments or future updates. Consider verifying if this value should be hardcoded or if it should allow for some variance.

  • 63-63: The addition of exp_gas_used=633810 as an argument to the deploy_contract function call seems to be a specific expectation for the gas used during contract deployment. Ensure that this value is accurate and consider if it should be a constant or derived from some configuration, especially since gas usage can change with contract complexity or EVM changes.

integration_tests/test_ibc_rly_gas.py Show resolved Hide resolved
integration_tests/utils.py Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a183cce and 83d22fd.
Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • integration_tests/test_basic.py (2 hunks)
  • integration_tests/utils.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
Files skipped from review as they are similar to previous changes (2)
  • integration_tests/test_basic.py
  • integration_tests/utils.py

@mmsqe mmsqe added this pull request to the merge queue Dec 22, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 22, 2023
yihuang and others added 4 commits December 22, 2023 14:08
* Problem: there are flaky integration tests

wait for first block

* add missing markers
- shanghai hardfork introduces push0 opcode, can be enabled in solc

Update CHANGELOG.md

Signed-off-by: yihuang <[email protected]>

enlarge gas gap

assert some exact gas number

fix python lint

test upgrade

test push0 opcode in upgrade
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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 83d22fd and 6a47518.
Files selected for processing (5)
  • integration_tests/conftest.py (2 hunks)
  • integration_tests/contracts/contracts/Greeter.sol (1 hunks)
  • integration_tests/contracts/hardhat.config.ts (1 hunks)
  • integration_tests/test_min_gas_price.py (4 hunks)
  • integration_tests/test_upgrade.py (2 hunks)
Files skipped from review due to trivial changes (2)
  • integration_tests/contracts/contracts/Greeter.sol
  • integration_tests/contracts/hardhat.config.ts
Files skipped from review as they are similar to previous changes (1)
  • integration_tests/conftest.py
Additional comments: 7
integration_tests/test_min_gas_price.py (4)
  • 6-6: The addition of wait_for_new_blocks to the import statement is noted. Ensure that this function is used appropriately within the test cases.

  • 29-29: The change in the directory name from "min-gas-price-gt" to "min-gas-price-lte" is observed. Confirm that this change aligns with the intended test environment setup and that no references to the old directory name remain in the codebase or documentation.

  • 68-68: The addition of wait_for_new_blocks before the test_dynamic_fee_tx function is appropriate to ensure the blockchain state is ready for the test. This is a good practice to avoid flaky tests due to timing issues.

  • 106-106: Similarly, the addition of wait_for_new_blocks before the test_base_fee_adjustment function is a good practice to ensure the blockchain state is consistent before running the test.

integration_tests/test_upgrade.py (3)
  • 127-131: The conditional block checking for testnet and asserting the absence of support for the PUSH0 opcode before the upgrade is a good addition. It ensures that the test environment correctly reflects the capabilities of the system before and after the upgrade.

  • 191-193: The conditional block checking for testnet and deploying a new contract to verify support for the PUSH0 opcode after the upgrade is a good validation step. It confirms that the upgrade has taken effect and the new opcode is now supported.

  • 195-197: The JSON-RPC query assertions are correct and ensure that the state of the blockchain before the upgrade is still accessible and consistent after the upgrade.

integration_tests/test_upgrade.py Outdated Show resolved Hide resolved
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6a47518 and 02ee4da.
Files selected for processing (1)
  • integration_tests/test_upgrade.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • integration_tests/test_upgrade.py

@yihuang yihuang requested a review from mmsqe December 22, 2023 06:47
@yihuang yihuang enabled auto-merge December 22, 2023 06:47
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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 02ee4da and cf651a8.
Files selected for processing (2)
  • integration_tests/test_basic.py (2 hunks)
  • integration_tests/test_upgrade.py (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • integration_tests/test_basic.py
  • integration_tests/test_upgrade.py

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.

2 participants