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

Livenet tests now run on local docker node and in CI #352

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

kubaplas
Copy link
Contributor

@kubaplas kubaplas commented Feb 7, 2024

Closes: #188

Summary by CodeRabbit

  • New Features
    • Introduced live network testing capabilities for ERC20 contract deployment and interaction.
    • Added a new example for deploying and interacting with ERC20 contracts on the live network.
  • Documentation
    • Updated examples to demonstrate new ERC20 deployment functionality.
  • Chores
    • Enhanced CI workflow to include tests on the live network.

Copy link
Contributor

coderabbitai bot commented Feb 7, 2024

Walkthrough

The changes involve the addition of a new service casper-nctl in the CI workflow for testing against the Casper live network. Significant updates were made to handle ERC20 contracts, including deploying ERC20 contracts with specific configurations and running an ERC20 example on the live network. These changes streamline interactions with ERC20 tokens by enhancing the deployment process and testing infrastructure.

Changes

File Path Change Summary
.github/workflows/odra-ci.yml Added casper-nctl service and just test-livenet step.
examples/bin/... (2 files) Updated for ERC20 deployment and testing.
examples/src/lib.rs Added deploy_erc20 function for ERC20 contract deployment.
justfile Added test-livenet and modified run-example-erc20-on-livenet targets.

Related issues

  • Docker-based tests for casper-livenet #188: The addition of the casper-nctl service and test-livenet target in the CI workflow aligns with the objective of running Casper live net tests in CI using Docker.
  • Further Casper Livenet features #103: The updates enable further Casper Livenet features by supporting ERC20 deployments and tests on the live network, contributing towards using Livenet as a backend for tests.

Poem

In the realm of code, where logic does abide,
A rabbit hopped along, with changes as its guide.
🌟 ERC20 shines, in tests it gleams and glitters,
Across the Casper net, where blockchain dreams do flitter.

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-tests for this file.
  • 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 tests 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 from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @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.
  • 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.

@kubaplas kubaplas force-pushed the feature/livenet-tests-in-ci branch 2 times, most recently from 596b38e to 71cf5ee Compare February 7, 2024 14:16
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 6c92428 and 71cf5ee.
Files selected for processing (4)
  • .github/workflows/odra-ci.yml (2 hunks)
  • examples/bin/erc20_on_livenet.rs (3 hunks)
  • examples/bin/livenet_tests.rs (2 hunks)
  • justfile (1 hunks)
Additional comments: 9
.github/workflows/odra-ci.yml (2)
  • 21-30: Ensure the DEPLOY_DELAY environment variable is appropriately configured for the expected deployment times in your CI environment to avoid potential timeouts or race conditions.
  • 43-43: Confirm that just test-livenet is integrated correctly with the rest of the CI pipeline, especially in terms of dependencies between steps and potential impacts on test execution times.
examples/bin/erc20_on_livenet.rs (1)
  • 15-15: Renaming deploy_new to deploy_erc20 improves clarity regarding the function's purpose. Ensure all references to this function are updated accordingly.
examples/bin/livenet_tests.rs (4)
  • 3-6: The addition of U256 and Erc20InitArgs imports is appropriate for the updated functionality. Ensure these are used correctly throughout the script.
  • 14-16: The update to deploy and log both contract and erc20 in the main function enhances the test's comprehensiveness. Verify that the gas settings are optimized for the deployment and interaction with these contracts.
  • 58-66: The deploy_new function's update to return a tuple of (LivenetContractHostRef, Erc20HostRef) and deploy an ERC20 contract is logical. Ensure that the transfer method call is correctly handling errors and exceptions.
  • 80-94: The deploy_erc20 function is well-implemented for deploying ERC20 contracts with specified parameters. Confirm that the gas limit set is sufficient and optimized for the deployment of these contracts.
justfile (2)
  • 74-89: The test-livenet target is correctly set up for running tests against a local Casper node. Ensure that the sleep duration in line 81 is sufficient for the node to start and stabilize before proceeding with tests.
  • 89-89: The run-example-erc20-on-livenet target description is missing in the provided context. Confirm that the modifications align with the objectives of running ERC20 examples on the live network.

examples/bin/erc20_on_livenet.rs Outdated Show resolved Hide resolved
@kubaplas kubaplas force-pushed the feature/livenet-tests-in-ci branch 4 times, most recently from d2f3368 to 74ae89a Compare February 7, 2024 15:17
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 6c92428 and 0879e2f.
Files selected for processing (5)
  • .github/workflows/odra-ci.yml (2 hunks)
  • examples/bin/erc20_on_livenet.rs (3 hunks)
  • examples/bin/livenet_tests.rs (2 hunks)
  • examples/src/lib.rs (1 hunks)
  • justfile (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/odra-ci.yml
  • examples/bin/erc20_on_livenet.rs
  • justfile
Additional comments: 6
examples/bin/livenet_tests.rs (6)
  • 1-6: Imports are correctly added for U256 and Erc20InitArgs. Ensure these imports are used effectively within the file.
  • 14-16: The deploy_new function is called with &env, which is correct. However, ensure that the gas limit set with env.set_gas(30_000_000_000u64); is appropriate for the deployment of both contracts.
  • 43-95: > 📝 NOTE

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

The logic for deploying, loading, and interacting with contracts appears sound. However, ensure that the gas limits set (e.g., env.set_gas(1_000_000_000u64);) are sufficient for the operations performed.

  • 58-66: The deploy_new function correctly deploys an ERC20 contract and a Livenet contract, linking them via the erc20_address. Ensure that the gas limit set before deploying the Livenet contract is appropriate.
  • 69-77: The load function is updated to accept an erc20_address parameter, correctly loading both contract references. This change is logical and maintains consistency.
  • 80-94: The deploy_erc20 function is well-structured, with clear initialization arguments for deploying an ERC20 contract. Ensure that the gas limit set is sufficient for the deployment.

@kubaplas kubaplas force-pushed the feature/livenet-tests-in-ci branch from 74ae89a to 5e07331 Compare February 7, 2024 16:05
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 6c92428 and 5e07331.
Files selected for processing (5)
  • .github/workflows/odra-ci.yml (2 hunks)
  • examples/bin/erc20_on_livenet.rs (3 hunks)
  • examples/bin/livenet_tests.rs (2 hunks)
  • examples/src/lib.rs (1 hunks)
  • justfile (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/odra-ci.yml
  • examples/bin/erc20_on_livenet.rs
  • examples/src/lib.rs
Additional comments: 9
examples/bin/livenet_tests.rs (6)
  • 1-6: Imports are correctly added for U256 and Erc20InitArgs. Ensure these are used appropriately in the subsequent code.
  • 14-16: The set_gas call before deploying contracts is a good practice for ensuring sufficient gas. However, verify that the gas limit is aligned with the expected cost of deploying ERC20 contracts on the Casper network.
  • 43-95: > 📝 NOTE

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

The logic for deploying, loading contracts, and executing various contract calls is clear and follows a logical sequence. Ensure that the gas limits set are appropriate for the operations being performed, especially for mutable calls and crosscalls.

  • 58-66: The deploy_new function correctly deploys an ERC20 contract and initializes a LivenetContract with its address. Ensure that the transfer call to seed the LivenetContract with tokens is intended and that the amount 1000.into() aligns with test requirements.
  • 69-77: The load function's update to accept an erc20_address parameter and return both contract references is correctly implemented. This change supports the enhanced testing capabilities by allowing both contract and ERC20 instances to be loaded for interaction.
  • 80-94: The deploy_erc20 function is well-structured, with clear initialization arguments for deploying an ERC20 contract. Ensure that the set_gas call before deployment is aligned with the expected deployment cost on the Casper network.
justfile (3)
  • 42-44: The start-casper-node target correctly uses Docker to run a Casper node. Ensure that the ports exposed match the Casper node's requirements and that the Docker image makesoftware/casper-nctl is the correct and latest version for testing purposes.
  • 77-87: The test-livenet target is well-structured for setting up a local Casper node, extracting secret keys, and running tests. Ensure that the paths and commands used for interacting with Docker and setting environment variables are correct and secure. Also, verify that the cleanup step rm -rf examples/.node-keys adequately addresses any potential security concerns regarding the handling of secret keys.
  • 87-87: The modification to run-example-erc20-on-livenet does not show any changes in the provided code. If there were intended modifications, ensure they are correctly implemented and aligned with the objectives of running ERC20 examples on the live network.

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6c92428) 80.72% compared to head (5e07331) 80.72%.

Additional details and impacted files
@@              Coverage Diff               @@
##           release/0.9.0     #352   +/-   ##
==============================================
  Coverage          80.72%   80.72%           
==============================================
  Files                127      127           
  Lines              13902    13902           
==============================================
  Hits               11223    11223           
  Misses              2679     2679           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kubaplas kubaplas requested review from zie1ony and kpob February 7, 2024 16:29
Copy link
Contributor

@zie1ony zie1ony left a comment

Choose a reason for hiding this comment

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

Great :)

@kubaplas kubaplas merged commit 05e110e into release/0.9.0 Feb 12, 2024
3 checks passed
@kubaplas kubaplas deleted the feature/livenet-tests-in-ci branch February 12, 2024 14:12
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.

Docker-based tests for casper-livenet
2 participants