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

fix: fix localnet issues #265

Merged
merged 3 commits into from
Jul 30, 2024
Merged

fix: fix localnet issues #265

merged 3 commits into from
Jul 30, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Jul 26, 2024

closes: #261

Summary by CodeRabbit

  • New Features

    • Updated contract deployment processes to improve clarity and functionality.
    • Enhanced task parameters for EVM and ZEVM interactions to reflect new contract addresses.
  • Bug Fixes

    • Corrected references in event listeners for improved accuracy in contract interactions.
  • Chores

    • Adjusted several task parameters to align with the new contract infrastructure, ensuring proper functionality across the application.

Copy link
Contributor

coderabbitai bot commented Jul 26, 2024

Walkthrough

The recent changes focus on restructuring and enhancing the contract deployment functions within the codebase. Key functions were renamed and updated to improve clarity and functionality, while new parameters were introduced to facilitate better interaction with the protocol's contracts. Additionally, significant updates were made to task parameters for local network interactions, ensuring consistency across contract references and fostering correct operation in the evolving ecosystem.

Changes

Files Change Summary
scripts/worker.ts Renamed deploySystemContracts to deployProtocolContracts and added parameters for contract deployment. Updated deployTestContracts to reference protocolContracts.
tasks/localnet.ts Updated parameters for tasks (zevm-call, zevm-withdraw-and-call, evm-call, evm-deposit-and-call) to reflect new contract addresses, ensuring all tasks use correct references.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Worker
    participant Contract

    User->>Worker: Initiate deployProtocolContracts
    Worker->>Contract: Deploy contracts with new parameters
    Contract-->>Worker: Return contract addresses
    Worker-->>User: Output deployed contract addresses
Loading

Assessment against linked issues

Objective Addressed Explanation
Error when interacting with localnet (#225) The issue of not printing system contract addresses remains unresolved.

🐰 In the meadow, contracts bloom,
New names and paths dispel the gloom.
With clearer calls, we leap and play,
In vibrant fields, we find our way!
Hops of code, a joyful tune,
In our world, we'll all commune! 🌼


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.
    • @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 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 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.

@skosito skosito changed the title fix: extend localnet with latest changes fix: fix localnet issues Jul 26, 2024
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

Outside diff range, codebase verification and nitpick comments (1)
tasks/localnet.ts (1)

84-86: Issues found with the contract addresses.

The contract addresses 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0, 0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82, and 0x8A791620dd6260079BF849Dc5567aDC3F2FdC318 were not found in the codebase. This suggests that they might be incorrect or unused.

  • Ensure that the contract addresses are valid and correctly deployed.
  • Verify that the addresses are correctly referenced in the codebase.
Analysis chain

Verify the new contract addresses.

Ensure that the new contract addresses for gatewayEVM, zContract, and erc20 are valid and correctly deployed.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new contract addresses for `gatewayEVM`, `zContract`, and `erc20`.

# Test: Check if the contracts are deployed at the new addresses. Expect: Contract code at the addresses.
addresses=("0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82" "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318")
for address in "${addresses[@]}"; do
  echo "Checking contract at address: $address"
  code=$(npx hardhat --network localhost getCode $address)
  if [ "$code" == "0x" ]; then
    echo "No contract found at address: $address"
    exit 1
  else
    echo "Contract found at address: $address"
  fi
done

Length of output: 1717


Script:

#!/bin/bash
# Description: Search for the usage of the contract addresses in the codebase.

addresses=("0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82" "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318")
for address in "${addresses[@]}"; do
  echo "Searching for address: $address"
  ast-grep --lang javascript --pattern $address
done

Length of output: 922

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2b8508e and d6da65e.

Files selected for processing (2)
  • scripts/worker.ts (8 hunks)
  • tasks/localnet.ts (5 hunks)
Additional context used
Path-based instructions (2)
tasks/localnet.ts (1)

Pattern tasks/**: Review the Hardhat tasks for best practices.

scripts/worker.ts (1)

Pattern scripts/**: Review the Hardhat scripts for best practices.

Additional comments not posted (5)
tasks/localnet.ts (3)

10-11: Verify the new contract addresses.

Ensure that the new contract addresses for gatewayZEVM and receiverEVM are valid and correctly deployed.


32-34: Verify the new contract addresses.

Ensure that the new contract addresses for gatewayZEVM, receiverEVM, and zrc20 are valid and correctly deployed.

Verification successful

Verify the new contract addresses by examining their usage in the codebase.

We need to ensure that the new contract addresses for gatewayZEVM, receiverEVM, and zrc20 are correctly referenced and deployed by examining their usage in the codebase.


The new contract addresses are correctly referenced in the codebase.

The addresses 0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6, 0x610178dA211FEF7D417bC0e6FeD39F05609AD788, and 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe are correctly referenced in the tasks/localnet.ts file and found in multiple configuration files, indicating they are recognized addresses in different environments.

  • tasks/localnet.ts: Lines 32-34, 40-42, 47-49
  • data/addresses.testnet.json
  • data/addresses.mainnet.json
  • data/addresses.json
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the new contract addresses for `gatewayZEVM`, `receiverEVM`, and `zrc20`.

# Test: Check if the contracts are deployed at the new addresses. Expect: Contract code at the addresses.
addresses=("0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" "0x610178dA211FEF7D417bC0e6FeD39F05609AD788" "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe")
for address in "${addresses[@]}"; do
  echo "Checking contract at address: $address"
  code=$(npx hardhat --network localhost getCode $address)
  if [ "$code" == "0x" ]; then
    echo "No contract found at address: $address"
    exit 1
  else
    echo "Contract found at address: $address"
  fi
done

Length of output: 1717


Script:

#!/bin/bash
# Search for the usage of the contract addresses in the codebase
addresses=("0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6" "0x610178dA211FEF7D417bC0e6FeD39F05609AD788" "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe")
for address in "${addresses[@]}"; do
  echo "Searching for usage of address: $address"
  rg "$address" -A 5 -B 5
done

Length of output: 7322


66-67: Verify the new contract addresses.

Ensure that the new contract addresses for gatewayEVM and zContract are valid and correctly deployed.

scripts/worker.ts (2)

11-57: Verify the correct integration of new parameters and contract instances.

Ensure that the new parameters (ownerEVM, ownerZEVM, fungibleModuleSigner) and new contract instances (TestERC20, ZetaConnectorNonNative, WZETA) are correctly integrated and functioning as expected.


Line range hint 67-116:
Verify the correct integration of new references and management of contracts.

Ensure that the new references (protocolContracts) and management of contracts (e.g., TestERC20, ReceiverEVM, TestZContract, ZRC20New) are correctly integrated and functioning as expected.

Verification successful

Verified the correct integration of new references and management of contracts.

The deployment patterns for the contracts TestERC20, ReceiverEVM, TestZContract, and ZRC20New were found in the scripts/worker.ts file, confirming that the changes are correctly integrated.

  • TestERC20: Found at lines 19 and 74 in scripts/worker.ts.
  • ReceiverEVM: Found at line 75 in scripts/worker.ts.
  • TestZContract: Found at line 87 in scripts/worker.ts.
  • ZRC20New: Found at line 90 in scripts/worker.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct integration of new references and management of contracts.

# Test: Check if the contracts are deployed and initialized correctly.
contracts=("TestERC20" "ReceiverEVM" "TestZContract" "ZRC20New")
for contract in "${contracts[@]}"; do
  echo "Checking deployment of contract: $contract"
  code=$(npx hardhat --network localhost getContractFactory $contract)
  if [ -z "$code" ]; then
    echo "Failed to deploy contract: $contract"
    exit 1
  else
    echo "Successfully deployed contract: $contract"
  fi
done

Length of output: 448


Script:

#!/bin/bash
# Description: Verify the correct integration of new references and management of contracts.

# Use ast-grep to search for deployment and interaction patterns of the contracts within the codebase
patterns=(
  'await ethers.getContractFactory("TestERC20")'
  'await ethers.getContractFactory("ReceiverEVM")'
  'await ethers.getContractFactory("TestZContract")'
  'await ethers.getContractFactory("ZRC20New")'
)

for pattern in "${patterns[@]}"; do
  echo "Searching for pattern: $pattern"
  ast-grep --lang typescript --pattern "$pattern"
done

Length of output: 1842

@codecov-commenter
Copy link

codecov-commenter commented Jul 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.10%. Comparing base (d1746fd) to head (9a581fd).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #265      +/-   ##
==========================================
+ Coverage   49.13%   58.10%   +8.97%     
==========================================
  Files          16       16              
  Lines         403      401       -2     
  Branches      108       28      -80     
==========================================
+ Hits          198      233      +35     
- Misses        160      165       +5     
+ Partials       45        3      -42     

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

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Not sure if I do something wrong in the setup, I used to be able to run the command.

Get the following error with yarn localnet:

[WORKER] Error HH700: Artifact for contract "forge-std/Test.sol:Test" not found.

If I run yarn compile:

Error HH700: Artifact for contract "forge-std/Test.sol:Test" not found.

@fadeev
Copy link
Member

fadeev commented Jul 29, 2024

yarn localnet now works for me 👍

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

Approving following @fadeev feedbacks, as I assume the yarn errors I listed will be solved with the v1/v2 separation

@skosito
Copy link
Contributor Author

skosito commented Jul 29, 2024

Approving following @fadeev feedbacks, as I assume the yarn errors I listed will be solved with the v1/v2 separation

probably you can remove artifacts folder or force recompile to get artifacts from lib folder, but with separation it should be easier yes

@fadeev could you please approve if it works and i will merge this one?

@lumtis lumtis merged commit 2ea8f56 into main Jul 30, 2024
11 checks passed
@lumtis lumtis deleted the fix-localnet branch July 30, 2024 11:11
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.

yarn localnet throws an error
4 participants