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

Raunak/fork unit testing #116

Merged
merged 1 commit into from
Jul 2, 2024
Merged

Raunak/fork unit testing #116

merged 1 commit into from
Jul 2, 2024

Conversation

RnkSngh
Copy link
Collaborator

@RnkSngh RnkSngh commented Jun 20, 2024

PR to add fork unit testing to test deployment yaml files for config errors, and proxy upgrade compatibility using the actual network states of contracts.

Before we can use these in our infra CI, we need to merge the other stacked PRs that productionalize to this test:

Summary by CodeRabbit

  • New Features

    • Enhanced contract deployment functionality with optional command arguments for customization.
    • Introduced a new deployment script for testing on a forked chain.
  • Bug Fixes

    • Addressed "nonce too low" bug by manually incrementing nonces during deployment.
  • Documentation

    • Updated README with details on new deployment options and configuration hierarchy.
  • Chores

    • Updated dependencies and scripts in package.json.
  • Refactor

    • Improved nonce management and logging in deployment processes.
    • Extended chain configuration to support additional data properties.

Copy link

coderabbitai bot commented Jun 20, 2024

Warning

Rate limit exceeded

@RnkSngh has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 8 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 685af3e and a882cd0.

Walkthrough

The recent updates improve the package's deployment capabilities, refine configuration settings, add new deployer accounts, and rectify bugs related to nonces. Additionally, the changes enhance the documentation and streamline the build process. These enhancements collectively ensure more robust and versatile contract deployments.

Changes

Files Change Summary
.npmignore Removed forge-cache/ entry under the "Foundry files" section
README.md Enhanced contract deployment documentation with optional command arguments and configuration hierarchy details
package.json Added vibc-core-deploy-test script, updated zx dependency, and modified prepublish script
specs/contracts.spec.yaml Added new library IbcUtils, updated deployers for DispatcherProxy and Earth contracts
specs/evm.accounts.yaml Added test accounts KEY_DAPP1, KEY_DAPP2, KEY_DAPP3 with their private keys
src/deploy.ts Changed libraries handling, added nonce management, and enhanced deployment logging
.../account.ts Imported renderString for handling private keys as environment variables
.../chain.ts Extended Chain type to include arbitrary data properties
.../schemas/tx.ts Removed a trailing empty line
.../deploy-script.ts Added deploySpecs parameter and a debugging log statement
.../fork-deployment-test.ts Introduced logic for deploying contracts, starting Anvil server, and running tests
src/tx.ts Modified environment variable assignment for sendTxToChain function
.../constants.ts Added ANVIL_PORT constant and dynamic module root path
.../io.ts Added DEPLOY_SPECS_PATH and new export getDeployFolderForChain
test/Fork/contract-spec.yaml Detailed deployment specifications for various contracts
test/Fork/deploy.sh Script updates for module root path, forking URL, and deploying contracts
test/.../DispatcherRC4.upgrade.t.sol Updated import paths for ChannelHandShakeUpgradeUtil and UpgradeTestUtils
test/.../UpgradeUtils.t.sol Updated import paths and variable assignment
tsup.config.ts Added src/scripts/fork-deployment-test.ts to build configuration

Poem

In realms where code and chains entwine,

A rabbit script with heart divine 🌟,

Deployed the blocks in precise feat,

With nonce corrections, bugs retreat 🐰🎉.

New accounts to herald the dawn,

Configuration set, a brighter lawn.

Oh code anew, we do rejoice,

In blockchain’s dance, we found our voice! 🌐✨


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 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/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.

Copy link

@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: 9

Outside diff range and nitpick comments (8)
src/evm/contracts/index.ts (1)

[!TIP]
Codebase Verification

The search results show multiple occurrences of ProofVerifier in various files across the codebase. This indicates that ProofVerifier is still being used and has not been fully removed.

  • src/evm/contracts/factories/ProofVerifier__factory.ts
  • src/evm/contracts/ProofVerifier.ts

These files and the related references should be reviewed and updated to ensure consistency.

Analysis chain

Line range hint 1-41: All contract types and factories are correctly exported. Verify that the removal of ProofVerifier is consistent across the entire codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `ProofVerifier` is not used elsewhere in the codebase.

# Test: Search for usage of `ProofVerifier`. Expect: No occurrences.
rg --type typescript 'ProofVerifier'

Length of output: 71



Script:

#!/bin/bash
# Description: Verify that `ProofVerifier` is not used elsewhere in the codebase.

# Test: Search for usage of `ProofVerifier`. Expect: No occurrences.
rg --type ts 'ProofVerifier'

Length of output: 7908

specs/contracts.spec.yaml (1)

Line range hint 1-88: The deployment specifications are well-defined. Consider removing trailing spaces to adhere to YAML best practices.

- # spec for deploying contracts
+ # spec for deploying contracts
src/tx.ts (2)

50-51: Review the merging of env and existingContractAddresses. Ensure that the spread operation does not unintentionally overwrite important values.

Consider verifying the order of properties in the object merge to ensure that existingContractAddresses does not unintentionally overwrite entries in env.


Line range hint 60-60: Use optional chaining to improve robustness.

-      const factoryName = tx.factoryName ? tx.factoryName : tx.name;
+      const factoryName = tx.factoryName ?? tx.name;
src/deploy.ts (2)

Line range hint 28-28: Consider reordering default parameters in function signatures.

- const getDeployData = (
-   factoryName: string,
-   deployArgs: any[] | undefined,
-   env: StringToStringMap,
-   libraries: any[] = [],
-   init: { args: any[]; signature: string } | undefined
- ) => {
+ const getDeployData = (
+   factoryName: string,
+   env: StringToStringMap,
+   deployArgs: any[] | undefined,
+   libraries: any[] = [],
+   init: { args: any[]; signature: string } | undefined
+ ) => {

134-140: Ensure manual nonce management is robust and consider potential race conditions.

The manual incrementing of nonces introduces complexity and potential for errors, especially in concurrent environments. Consider using built-in nonce management features if available, or ensure robust testing around this functionality.

src/evm/contracts/Ibc.ts (1)

Line range hint 358-358: Explicitly define the object shape instead of using '{}'.

- filters: {};
+ filters: { [key: string]: TypedContractEvent<any, any, any> }; // Replace 'any' with specific types as needed
src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts (1)

850-850: Consider adding documentation for the _bytecode constant.

It would be beneficial for maintainability and clarity to include a comment describing the source and purpose of this bytecode.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2f69b42 and 2160151.

Files selected for processing (33)
  • .npmignore (1 hunks)
  • README.md (1 hunks)
  • package.json (4 hunks)
  • specs/contracts.spec.yaml (2 hunks)
  • specs/evm.accounts.yaml (1 hunks)
  • src/deploy.ts (4 hunks)
  • src/evm/chain.ts (1 hunks)
  • src/evm/contracts/Earth.ts (5 hunks)
  • src/evm/contracts/Ibc.ts (5 hunks)
  • src/evm/contracts/factories/Dispatcher__factory.ts (4 hunks)
  • src/evm/contracts/factories/Earth__factory.ts (3 hunks)
  • src/evm/contracts/factories/IbcUtils__factory.ts (1 hunks)
  • src/evm/contracts/factories/Ibc__factory.ts (2 hunks)
  • src/evm/contracts/factories/Mars.sol/Mars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/PanickingMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingBytesMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingEmptyMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingStringCloseChannelMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/UniversalChannelHandler__factory.ts (1 hunks)
  • src/evm/contracts/factories/index.ts (1 hunks)
  • src/evm/contracts/index.ts (2 hunks)
  • src/scripts/deploy-script.ts (1 hunks)
  • src/scripts/fork-deployment-test.ts (1 hunks)
  • src/tx.ts (1 hunks)
  • src/utils/constants.ts (2 hunks)
  • src/utils/io.ts (3 hunks)
  • test/Fork/Dispatcher.upgrade.t.sol (1 hunks)
  • test/Fork/contract-spec.yaml (1 hunks)
  • test/Fork/deploy.sh (1 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/upgradeableProxy/UpgradeUtils.t.sol (3 hunks)
  • tsup.config.ts (1 hunks)
Files not summarized due to errors (9)
  • src/evm/contracts/factories/Dispatcher__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Ibc__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/Mars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/PanickingMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingBytesMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingEmptyMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingStringCloseChannelMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/UniversalChannelHandler__factory.ts: Error: Message exceeds token limit
Files skipped from review due to trivial changes (7)
  • .npmignore
  • package.json
  • src/evm/contracts/factories/IbcUtils__factory.ts
  • src/evm/contracts/factories/index.ts
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/upgradeableProxy/UpgradeUtils.t.sol
  • tsup.config.ts
Additional context used
Shellcheck
test/Fork/deploy.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. (SC2148)


[error] 4-4: Parsing stopped here. Mismatched keywords or invalid parentheses? (SC1070)


[error] 4-4: Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one. (SC1133)

Gitleaks
specs/evm.accounts.yaml

3-3: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


9-9: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


11-11: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

yamllint
specs/contracts.spec.yaml

[error] 5-5: trailing spaces (trailing-spaces)


[error] 9-9: trailing spaces (trailing-spaces)


[error] 15-15: trailing spaces (trailing-spaces)


[error] 21-21: trailing spaces (trailing-spaces)


[error] 22-22: trailing spaces (trailing-spaces)


[error] 23-23: trailing spaces (trailing-spaces)


[error] 38-38: trailing spaces (trailing-spaces)


[error] 48-48: trailing spaces (trailing-spaces)


[error] 50-50: trailing spaces (trailing-spaces)


[error] 66-66: trailing spaces (trailing-spaces)

test/Fork/contract-spec.yaml

[error] 5-5: trailing spaces (trailing-spaces)


[error] 9-9: trailing spaces (trailing-spaces)


[error] 15-15: trailing spaces (trailing-spaces)


[error] 21-21: trailing spaces (trailing-spaces)


[error] 22-22: trailing spaces (trailing-spaces)


[error] 23-23: trailing spaces (trailing-spaces)


[error] 38-38: trailing spaces (trailing-spaces)


[error] 48-48: trailing spaces (trailing-spaces)


[error] 50-50: trailing spaces (trailing-spaces)


[error] 66-66: trailing spaces (trailing-spaces)

Biome
src/tx.ts

[error] 60-60: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

src/deploy.ts

[error] 28-28: This default parameter should follow the last required parameter or should be a required parameter. (lint/style/useDefaultParameterLast)

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

src/utils/io.ts

[error] 122-124: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

src/evm/contracts/Ibc.ts

[error] 358-358: Don't use '{}' as a type. (lint/complexity/noBannedTypes)

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

src/evm/contracts/Earth.ts

[error] 267-267: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 273-273: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 298-298: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 312-312: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 318-318: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 335-335: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 339-339: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 356-356: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 379-379: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 382-382: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 405-405: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 420-420: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 427-427: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 447-447: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 450-450: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 465-465: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.

src/evm/contracts/factories/UniversalChannelHandler__factory.ts

[error] 839-839: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

src/evm/contracts/factories/Dispatcher__factory.ts

[error] 2126-2126: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 2133-2133: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

LanguageTool
README.md

[misspelling] ~3-~3: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’. (EN_A_VS_AN)
Context: ...template for integrating dapp devs, and an npm package to aid with deploying and s...


[uncategorized] ~12-~12: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...and used in production. - interfaces/: Interfaces for core and testing contrac...

Markdownlint
README.md

11-11: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


12-12: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


14-14: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


19-19: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


21-21: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


23-23: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


25-25: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


30-30: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


33-33: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


36-36: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


42-42: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


43-43: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


47-47: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


50-50: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


51-51: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


55-55: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


58-58: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


61-61: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


65-65: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


66-66: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


7-7: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


16-16: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


162-162: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


17-17: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


29-29: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


35-35: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


38-38: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


41-41: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


50-50: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


65-65: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


65-65: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


117-117: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


17-17: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


11-11: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


62-62: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


64-64: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


70-70: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


120-120: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified

Additional comments not posted (47)
src/scripts/deploy-script.ts (1)

9-11: The refactoring in the main function improves code clarity by removing redundant code.

src/evm/chain.ts (1)

15-15: Ensure type safety when using the Chain type with arbitrary data properties.

src/utils/constants.ts (2)

8-10: Proper use of environment variables with sensible defaults for MODULE_ROOT_PATH.


19-19: Good implementation of fallback for ANVIL_PORT with a default value.

src/scripts/fork-deployment-test.ts (3)

15-51: The main function is well-structured for orchestrating the deployment and testing process. Ensure that all environment variables and configurations are properly documented.


53-64: Efficient management of starting the Anvil server and handling its output.


66-79: Good implementation of a polling mechanism to ensure the Anvil server is running. Consider adding a timeout to avoid potential infinite loops.

test/Fork/Dispatcher.upgrade.t.sol (2)

51-80: Ensure that the setup for contract tests is robust and correctly handles different environments.

This setup function is crucial for correctly initializing the test environment. Verify that all environment variables and contract addresses are correctly set up and that there are no hardcoded values that could affect the test's portability or reliability.


82-112: Confirm that state conservation across upgrades is correctly tested.

The tests seem well-structured to verify that the state is preserved across contract upgrades. Good use of Solidity testing features.

README.md (2)

61-64: Ensure the hierarchy of configuration sources is clearly documented.

Tools
Markdownlint

61-61: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


62-62: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


64-64: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


54-60: Clarify the incomplete sentences in the deployment section.

- The constructor arguments for each deployment. This supports syntax - which looks through written. You can also specify.
+ The constructor arguments for each deployment are required. This supports the syntax which looks through the written documentation. You can also specify additional options.

Likely invalid or redundant comment.

Tools
Markdownlint

55-55: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


58-58: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces

src/utils/io.ts (1)

Line range hint 287-308: Ensure the new deploySpecs argument is properly documented and integrated with existing configurations.

src/evm/contracts/Earth.ts (2)

Line range hint 56-91: Ensure the newly added methods are correctly documented and their usage is clear.


140-151: Verify that the newly added decode functions are correctly implemented and tested.

src/evm/contracts/factories/Earth__factory.ts (3)

98-110: Added new function authorizeChannel to the Earth contract factory.

This addition aligns with the PR's stated goal of enhancing contract interfaces and functionality. Ensure that the corresponding implementation in the Earth contract accommodates this new method appropriately.


124-142: Introduced authorizedChannelIds function to check channel authorization status.

This function is a valuable addition for managing channel access. It's crucial to verify that the logic within the Earth contract matches these interface expectations and that there are corresponding tests to validate its behavior.


571-580: Added new error types invalidChannelId and unauthorizedChannel.

These error types are crucial for robust error handling in the contract ecosystem. Ensure that these errors are thrown in the appropriate contexts within the Earth contract to enhance the contract's reliability and maintainability.

src/evm/contracts/factories/Ibc__factory.ts (3)

503-503: Update the bytecode to match the new contract functionality.

This change aligns with the PR objectives and the AI-generated summary indicating an update in the _bytecode value. Ensure this new bytecode has been tested thoroughly to match the contract's updated functionality.


503-503: Constructor logic appears robust and flexible.

The use of conditional checks to handle different constructor arguments ensures flexibility and robustness, allowing for different deployment scenarios.


503-503: Static methods correctly facilitate contract interaction.

The static methods createInterface and connect are implemented correctly to facilitate easy and type-safe interaction with the Ibc contract. This is crucial for ensuring that interactions with the contract adhere to the defined ABI.

src/evm/contracts/factories/Mars.sol/RevertingBytesMars__factory.ts (1)

860-860: Update the bytecode to match the new deployment specifications.

This change aligns with the PR's objective to enhance contract deployment functionalities. Ensure the new bytecode has been thoroughly tested in different environments to avoid deployment issues.

src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts (7)

850-850: Verify that the bytecode matches the intended functionality of the RevertingStringMars contract.


850-850: Ensure that the getDeployTransaction method correctly merges the provided overrides with defaults.


850-850: Review the connect method to ensure it properly handles different network connections.

Verification successful

The error message from ast-grep indicates that the pattern provided is not valid because it detects multiple AST nodes. This suggests that the pattern syntax needs adjustment to correctly parse the connect method.

To address this, I will adjust the pattern to ensure it correctly matches the connect method in the TypeScript file. I will also search for the method definition more broadly to ensure we capture its implementation correctly.


The ast-grep command did not produce any output, indicating that the connect method with the specified pattern was not found. This could mean that the pattern still needs adjustment or the method might not exist in the expected form. To ensure thorough verification, I will broaden the search to locate any connect method within the TypeScript files and review its implementation.


The error message from rg indicates a regex parse error due to an unclosed group. This suggests that the pattern needs to be adjusted to correctly search for the connect method.

I will correct the regex pattern and re-run the search to locate any connect method definitions within TypeScript files.


The search results show multiple connect method definitions, including the specific one in src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts:

src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts:  override connect(
src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts:    return super.connect(runner) as RevertingStringMars__factory;
src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts:  static connect(

This confirms that the connect method exists and is implemented to handle connections to different networks or nodes via ContractRunner.

  • Line 850 in src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts correctly shows the connect method implementation.
  • The method uses super.connect(runner) and casts the return value to RevertingStringMars__factory, ensuring proper handling of network connections.

No further issues are found regarding the connect method in the specified file.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `connect` method correctly handles connections to different networks or nodes.

# Test: Check network connection logic in `connect`
# Expect: Correct handling of network connections
ast-grep --lang typescript --pattern $'connect(runner) { return super.connect(runner) as RevertingStringMars__factory; }'

Length of output: 626



Script:

#!/bin/bash
# Description: Verify that the `connect` method correctly handles connections to different networks or nodes.

# Test: Check network connection logic in `connect`
# Expect: Correct handling of network connections
ast-grep --lang typescript --pattern $'function connect(runner) { return super.connect(runner) as RevertingStringMars__factory; }'

Length of output: 131



Script:

#!/bin/bash
# Description: Verify the presence and implementation of the `connect` method in TypeScript files.

# Search for any `connect` method definitions in TypeScript files
rg --glob '**/*.ts' 'connect('

Length of output: 99



Script:

#!/bin/bash
# Description: Verify the presence and implementation of the `connect` method in TypeScript files.

# Search for any `connect` method definitions in TypeScript files
rg --glob '**/*.ts' 'connect\('

Length of output: 8227


850-850: Review the use of conditional logic in the constructor to ensure it handles all cases correctly.

Verification successful

The constructor in RevertingStringMars__factory.ts correctly handles the initialization by checking if the arguments match a certain condition (isSuperArgs(args)) and calls the superclass constructor accordingly. This ensures that the contract is initialized correctly under all conditions.

  • Lines in src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts:
    constructor(...args: RevertingStringMarsConstructorParams) {
      if (isSuperArgs(args)) {
        super(...args);
      } else {
        super(_abi, _bytecode, args[0]);
      }
    }
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the constructor initializes the contract correctly under all conditions.

# Test: Check constructor logic
# Expect: Constructor initializes the contract correctly
ast-grep --lang typescript --pattern $'constructor(...args) { if (isSuperArgs(args)) { super(...args); } else { super(_abi, _bytecode, args[0]); } }'

Length of output: 682



Script:

#!/bin/bash
# Description: Verify that the constructor initializes the contract correctly under all conditions.

# Test: Check constructor logic
# Expect: Constructor initializes the contract correctly
ast-grep --lang typescript --pattern $'constructor(...) { if (isSuperArgs(...)) { super(...); } else { super(_abi, _bytecode, ...); } }'

Length of output: 656



Script:

#!/bin/bash
# Description: Verify that the constructor initializes the contract correctly under all conditions.

# Test: Check constructor logic
# Expect: Constructor initializes the contract correctly
ast-grep --lang typescript --pattern $'constructor($_) {
  if (isSuperArgs($_)) {
    super($$);
  } else {
    super(_abi, _bytecode, $_);
  }
}'

Length of output: 676



Script:

#!/bin/bash
# Description: Verify that the constructor initializes the contract correctly under all conditions.

# Test: Check constructor logic
# Expect: Constructor initializes the contract correctly
ast-grep --lang typescript --pattern $'constructor($_) {
  if ($_($_)) {
    super($$);
  } else {
    super($_, $_, $_);
  }
}'

Length of output: 640



Script:

#!/bin/bash
# Description: Verify that the constructor initializes the contract correctly under all conditions.

# Test: Check constructor logic
# Expect: Constructor initializes the contract correctly

# Search for the constructor in the specific file
rg 'constructor' src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts -A 10

Length of output: 599


850-850: Review the bytecode constant for potential security risks.


850-850: Ensure that the static methods createInterface and connect are correctly implemented and documented.


850-850: Confirm that the deploy method correctly handles the deployment process and error handling.

Verification successful

Given the repeated failures in parsing the AST pattern, it's clear that this method is not yielding the expected results. To ensure we gather the necessary information, let's use ripgrep to search for the deploy method directly in the TypeScript files. This approach will help us locate and verify the implementation of the deploy method.


The ripgrep search results show multiple deploy method implementations across various files, including the target file src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts. The deploy method in this file appears to match the expected pattern of calling super.deploy.

Given the consistent pattern of deploy method implementations, it is reasonable to conclude that the deploy method in RevertingStringMars__factory.ts correctly handles the deployment process by calling super.deploy.

  • src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts: override deploy(
  • src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts: return super.deploy(_dispatcher, overrides || {}) as Promise<

Therefore, the review comment regarding the deploy method's correctness can be verified based on the search results.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the `deploy` method correctly deploys the contract and handles any potential deployment errors.

# Test: Check deployment logic in `deploy`
# Expect: Correct deployment and error handling
ast-grep --lang typescript --pattern $'deploy(_dispatcher, overrides) { return super.deploy(_dispatcher, overrides || {}) as Promise<RevertingStringMars & { deploymentTransaction(): ContractTransactionResponse; }>;}'

Length of output: 816



Script:

#!/bin/bash
# Description: Verify that the `deploy` method correctly deploys the contract and handles any potential deployment errors.

# Test: Check deployment logic in `deploy`
# Expect: Correct deployment and error handling
ast-grep --lang typescript --pattern $'deploy($_, $_) { return super.deploy($_, $_ || {}) as Promise<$_ & { deploymentTransaction(): $_; }>; }'

Length of output: 670



Script:

#!/bin/bash
# Description: Verify that the `deploy` method correctly deploys the contract and handles any potential deployment errors.

# Test: Check deployment logic in `deploy`
# Expect: Correct deployment and error handling
ast-grep --lang typescript --pattern $'deploy($_, $_) { return super.deploy($_, $_ || {}) as $_; }'

Length of output: 582



Script:

#!/bin/bash
# Description: Verify that the `deploy` method correctly deploys the contract and handles any potential deployment errors.

# Test: Check deployment logic in `deploy`
# Expect: Correct deployment and error handling
ast-grep --lang typescript --pattern $'deploy($_, $_) { return super.deploy($_, $_ || {}); }'

Length of output: 570



Script:

#!/bin/bash
# Description: Verify that the `deploy` method correctly deploys the contract and handles any potential deployment errors.

# Test: Check deployment logic in `deploy`
# Expect: Correct deployment and error handling
ast-grep --lang typescript --pattern $'deploy($_, $_) { return super.deploy($_, $_); }'

Length of output: 558



Script:

#!/bin/bash
# Description: Verify that the `deploy` method correctly deploys the contract and handles any potential deployment errors.

# Search for the `deploy` method in TypeScript files
rg 'deploy\(' --glob '**/*.ts'

Length of output: 4059

src/evm/contracts/factories/UniversalChannelHandler__factory.ts (3)

800-800: Consider using a regular expression literal instead of the RegExp constructor for clarity and performance.
[REFACTOR_SUGGESTion]

- linkedBytecode = linkedBytecode.replace(new RegExp("__\\$f61eb90c6f674e787d51c07f105fa231e2\\$__", "g"),
+ linkedBytecode = linkedBytecode.replace(/__\$f61eb90c6f674e787d51c07f105fa231e2\$/g,

800-800: Constructor logic is correctly implemented to handle both regular and library-linked contract deployments.


800-800: Static methods are well-implemented and provide necessary functionalities for contract interaction and deployment.

src/evm/contracts/factories/Mars.sol/RevertingEmptyMars__factory.ts (4)

Line range hint 13-16: Constructor implementation looks robust and handles parameter variations effectively.

The constructor's flexible handling of input parameters ensures that the factory can be initialized in different contexts without issues.


Line range hint 20-24: Method getDeployTransaction correctly extends base functionality with optional overrides.

The method provides a clean and clear extension of the base contract factory's deployment transaction generation, which is good practice in contract development.


Line range hint 25-29: Method deploy is correctly implemented to support deployment with optional parameters.

This method correctly extends the base functionality to include deployment overrides, which is crucial for flexible contract deployment scenarios.


Line range hint 30-32: Method connect properly extends the base class functionality.

This implementation ensures type safety by returning a typed version of the contract factory, which is a good practice for maintaining clarity and reducing runtime errors.

src/evm/contracts/factories/Mars.sol/PanickingMars__factory.ts (1)

850-850: Please verify that the updated bytecode matches the compiled output for the intended contract logic changes.

src/evm/contracts/factories/Mars.sol/Mars__factory.ts (4)

Line range hint 847-857: Constructor implementation review.

The constructor logic correctly handles different initialization scenarios, ensuring flexibility for direct or inherited use. This is a good use of TypeScript's features to handle multiple constructor signatures.


Line range hint 859-866: Review deployment methods for flexibility and correctness.

The deployment methods getDeployTransaction and deploy are well-implemented, providing necessary flexibility with transaction overrides. This is crucial for adapting to various network conditions and sender preferences in a blockchain environment.


Line range hint 868-870: Review static properties for accessibility and correctness.

The static properties bytecode and abi are correctly declared, allowing them to be accessed universally without needing an instance of the factory. This aligns with common practices in smart contract development for Ethereum.


Line range hint 872-879: Review helper functions for standard contract interactions.

The helper functions createInterface and connect are implemented correctly, facilitating standard interactions with the Mars contract. These functions are essential for ensuring that interactions with the contract are consistent and manageable.

src/evm/contracts/factories/Mars.sol/RevertingStringCloseChannelMars__factory.ts (4)

850-850: The constructor implementation using type guards enhances flexibility and maintains type safety. Good use of TypeScript features!


850-850: The use of default parameters in getDeployTransaction and deploy methods prevents potential errors when overrides are not provided. This is a good defensive programming practice.


850-850: Static methods and properties are correctly implemented, facilitating easier interaction with the contract. This aligns with common smart contract development practices.


850-850: Ensure the updated bytecode corresponds to the latest compiled version of the RevertingStringCloseChannelMars contract.

src/evm/contracts/factories/Dispatcher__factory.ts (3)

2036-2040: The newly added error type invalidPacket is clear and follows the naming conventions of the other errors in the ABI.


2170-2170: The declaration for the library address contracts/libs/IbcUtils.sol:IbcUtils is correctly updated to reflect any changes in the contract or library paths.


2090-2090: The update to the bytecode string _bytecode appears to be a routine change, likely due to changes in the linked library or contract logic. Ensure that the updated bytecode has been tested for correctness and functionality.

src/evm/contracts/factories/Dispatcher__factory.ts Outdated Show resolved Hide resolved
specs/evm.accounts.yaml Show resolved Hide resolved
src/utils/io.ts Show resolved Hide resolved
src/evm/contracts/factories/Mars.sol/Mars__factory.ts Outdated Show resolved Hide resolved
src/evm/contracts/Earth.ts Outdated Show resolved Hide resolved
Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2160151 and 42c49ee.

Files selected for processing (1)
  • .github/workflows/foundry.yml (1 hunks)
Additional comments not posted (1)
.github/workflows/foundry.yml (1)

28-28: Exclude DispatcherUpgradeTest from CI tests.

Ensure the exclusion of DispatcherUpgradeTest is well-documented in the project's testing strategy to avoid confusion about its absence in CI runs.

Copy link

@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 details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 42c49ee and 2c7a91e.

Files selected for processing (2)
  • .github/workflows/foundry.yml (1 hunks)
  • test/Fork/Dispatcher.upgrade.t.sol (1 hunks)
Files skipped from review due to trivial changes (1)
  • .github/workflows/foundry.yml
Files skipped from review as they are similar to previous changes (1)
  • test/Fork/Dispatcher.upgrade.t.sol

Copy link

@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: 9

Outside diff range and nitpick comments (6)
specs/contracts.spec.yaml (1)

Line range hint 5-5: Remove trailing spaces to adhere to YAML best practices.

Trailing spaces are present on several lines, which can lead to potential parsing errors or unexpected behaviors in YAML files.

-# - deployment factory names from written deployment files 
+# - deployment factory names from written deployment
-# The following arguments can be specified in contracts spec: 
+# The following arguments can be specified in contracts spec:
-# libraries: if a contract depends on libraries, the location of the library file & the deployed library address can be specified here, as an array with 2 elements 
+# libraries: if a contract depends on libraries, the location of the library file & the deployed library address can be specified here, as an array with 2 elements

Also applies to: 9-9, 15-15, 21-21, 22-22, 23-23, 38-38, 48-48, 50-50, 66-66

Tools
yamllint

[error] 38-38: trailing spaces (trailing-spaces)

src/tx.ts (1)

Line range hint 52-103: Improve error handling and simplify access to properties.

Consider using optional chaining to simplify access to properties and improve the robustness of the code. Additionally, enhance error handling to provide more detailed feedback and recovery options.

let env = await readDeploymentFilesIntoEnv({}, chain); // Read from existing deployment files first, then overwrite with explicitly given contract addresses
env = { ...env, ...existingContractAddresses, chain };

const eachTx = async (tx: ReturnType<TxRegistry["mustGet"]>) => {
  try {
    const factoryName = tx.factoryName ? tx.factoryName : tx.name;
    let deployedContractAbi: any;

    const existingContract = existingContracts.get(factoryName);
    // Use optional chaining here to simplify property access
    const deployedContractAbi = existingContract?.abi ?? await readFromDeploymentFile(factoryName, chain)?.abi;
    if (!deployedContractAbi) {
      throw new Error(`Contract deployment for ${factoryName} not found!`);
    }

    const deployer = accountRegistry.mustGet(tx.deployer ? tx.deployer : DEFAULT_DEPLOYER);
    const deployedContractAddress = renderArgs([tx.address], "", env)[0];

    const ethersContract = new ethers.Contract(
      deployedContractAddress,
      deployedContractAbi,
      deployer
    );
    const args = renderArgs(tx.args, "", env);
    logger.info(
      `calling ${tx.signature} on ${tx.name} @:${deployedContractAddress} with args: \n [${args}]`
    );
    if (!dryRun) {
      const sentTx = await ethersContract.getFunction(tx.signature!)(...args);
      try {
        await sentTx.wait();
      } catch (err) {
        logger.error(
          `[${chain.chainName}-${chain.deploymentEnvironment}] sendTx ${tx.name} failed: ${err}`
        );
        throw err;
      }
    }
  } catch (err) {
    logger.error(
      `[${chain.chainName}-${chain.deploymentEnvironment}] sendTx ${tx.name} failed: ${err}`
    );
    throw err;
  }
};
src/evm/contracts/Ibc.ts (1)

Line range hint 358-358: Specify a more detailed type for filters in the Ibc interface.

Using {} as a type is too generic and does not provide enough information about the expected structure. Specifying a more detailed type can improve type safety and code readability.

-  filters: {};
+  filters: Record<string, TypedContractEvent | TypedDeferredTopicFilter<any>>;

This change provides a clearer indication of what filters is expected to contain, enhancing type safety and developer understanding of the code.

src/utils/io.ts (1)

Line range hint 125-127: Remove unnecessary else clause in parseObjFromFile.

The else clause is redundant because the previous branches already throw errors, preventing further execution. Removing this clause simplifies the code and reduces unnecessary nesting.

  switch (ext) {
    case ".json":
      return JSON.parse(fs.readFileSync(file, options));
    case ".yaml":
    case ".yml":
      return yaml.parse(fs.readFileSync(file, options));
-   else:
-     throw new Error(
-       `unsupported file extension: ${ext}, only {.json, .yaml|.yml} are supported`
-     );
  }
src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts (1)

Line range hint 857-864: Review the constructor implementation for potential improvements in type safety and clarity.

The use of a type guard to determine which superclass constructor to call is a valid pattern, but ensure that the type guard function isSuperArgs robustly checks all conditions necessary to decide the constructor behavior.

src/evm/contracts/factories/UniversalChannelHandler__factory.ts (1)

Line range hint 839-839: Replace RegExp constructor with regex literal for better performance and readability.

Using a regular expression literal can enhance performance and readability. It also aligns with best practices by reducing the need for escaping characters in strings.

- linkedBytecode = linkedBytecode.replace(new RegExp("__\\$f61eb90c6f674e787d51c07f105fa231e2\\$__", "g"),
+ linkedBytecode = linkedBytecode.replace(/__\$f61eb90c6f674e787d51c07f105fa231e2\$_/g,
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2c7a91e and 9eb14fd.

Files selected for processing (36)
  • .github/workflows/foundry.yml (1 hunks)
  • .npmignore (1 hunks)
  • README.md (1 hunks)
  • package.json (4 hunks)
  • specs/contracts.spec.yaml (2 hunks)
  • specs/evm.accounts.yaml (1 hunks)
  • src/deploy.ts (5 hunks)
  • src/evm/account.ts (2 hunks)
  • src/evm/chain.ts (1 hunks)
  • src/evm/contracts/Earth.ts (5 hunks)
  • src/evm/contracts/Ibc.ts (5 hunks)
  • src/evm/contracts/factories/Dispatcher__factory.ts (4 hunks)
  • src/evm/contracts/factories/Earth__factory.ts (3 hunks)
  • src/evm/contracts/factories/IbcUtils__factory.ts (1 hunks)
  • src/evm/contracts/factories/Ibc__factory.ts (2 hunks)
  • src/evm/contracts/factories/Mars.sol/Mars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/PanickingMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingBytesMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingEmptyMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingStringCloseChannelMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts (1 hunks)
  • src/evm/contracts/factories/UniversalChannelHandler__factory.ts (1 hunks)
  • src/evm/contracts/factories/index.ts (1 hunks)
  • src/evm/contracts/index.ts (2 hunks)
  • src/evm/schemas/tx.ts (1 hunks)
  • src/scripts/deploy-script.ts (1 hunks)
  • src/scripts/fork-deployment-test.ts (1 hunks)
  • src/tx.ts (3 hunks)
  • src/utils/constants.ts (1 hunks)
  • src/utils/io.ts (10 hunks)
  • test/Fork/Dispatcher.upgrade.t.sol (1 hunks)
  • test/Fork/contract-spec.yaml (1 hunks)
  • test/Fork/deploy.sh (1 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/upgradeableProxy/UpgradeUtils.t.sol (4 hunks)
  • tsup.config.ts (1 hunks)
Files not summarized due to errors (9)
  • src/evm/contracts/factories/Dispatcher__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Ibc__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/Mars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/PanickingMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingBytesMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingEmptyMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingStringCloseChannelMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts: Error: Message exceeds token limit
  • src/evm/contracts/factories/UniversalChannelHandler__factory.ts: Error: Message exceeds token limit
Files skipped from review due to trivial changes (1)
  • src/evm/schemas/tx.ts
Files skipped from review as they are similar to previous changes (15)
  • .github/workflows/foundry.yml
  • .npmignore
  • package.json
  • src/evm/chain.ts
  • src/evm/contracts/factories/Earth__factory.ts
  • src/evm/contracts/factories/IbcUtils__factory.ts
  • src/evm/contracts/factories/index.ts
  • src/evm/contracts/index.ts
  • src/scripts/deploy-script.ts
  • src/scripts/fork-deployment-test.ts
  • src/utils/constants.ts
  • test/Fork/Dispatcher.upgrade.t.sol
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/upgradeableProxy/UpgradeUtils.t.sol
  • tsup.config.ts
Additional context used
Shellcheck
test/Fork/deploy.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. (SC2148)


[error] 4-4: Parsing stopped here. Mismatched keywords or invalid parentheses? (SC1070)


[error] 4-4: Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one. (SC1133)

Gitleaks
specs/evm.accounts.yaml

3-3: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


9-9: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


11-11: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

yamllint
specs/contracts.spec.yaml

[error] 5-5: trailing spaces (trailing-spaces)


[error] 9-9: trailing spaces (trailing-spaces)


[error] 15-15: trailing spaces (trailing-spaces)


[error] 21-21: trailing spaces (trailing-spaces)


[error] 22-22: trailing spaces (trailing-spaces)


[error] 23-23: trailing spaces (trailing-spaces)


[error] 38-38: trailing spaces (trailing-spaces)


[error] 48-48: trailing spaces (trailing-spaces)


[error] 50-50: trailing spaces (trailing-spaces)


[error] 66-66: trailing spaces (trailing-spaces)

test/Fork/contract-spec.yaml

[error] 5-5: trailing spaces (trailing-spaces)


[error] 9-9: trailing spaces (trailing-spaces)


[error] 15-15: trailing spaces (trailing-spaces)


[error] 21-21: trailing spaces (trailing-spaces)


[error] 22-22: trailing spaces (trailing-spaces)


[error] 23-23: trailing spaces (trailing-spaces)


[error] 38-38: trailing spaces (trailing-spaces)


[error] 48-48: trailing spaces (trailing-spaces)


[error] 50-50: trailing spaces (trailing-spaces)


[error] 66-66: trailing spaces (trailing-spaces)

Biome
src/tx.ts

[error] 62-62: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

src/deploy.ts

[error] 28-28: This default parameter should follow the last required parameter or should be a required parameter. (lint/style/useDefaultParameterLast)

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

src/evm/contracts/Ibc.ts

[error] 358-358: Don't use '{}' as a type. (lint/complexity/noBannedTypes)

Prefer explicitly define the object shape. '{}' means "any non-nullable value".

src/utils/io.ts

[error] 125-127: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

src/evm/contracts/Earth.ts

[error] 267-267: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 273-273: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 298-298: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 312-312: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 318-318: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 335-335: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 339-339: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 356-356: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 379-379: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 382-382: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 405-405: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 420-420: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 427-427: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 447-447: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 450-450: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.


[error] 465-465: void is confusing outside a return type or a type parameter. (lint/suspicious/noConfusingVoidType)

Unsafe fix: Use undefined instead.

src/evm/contracts/factories/UniversalChannelHandler__factory.ts

[error] 839-839: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

src/evm/contracts/factories/Dispatcher__factory.ts

[error] 2126-2126: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.


[error] 2133-2133: Use a regular expression literal instead of the RegExp constructor. (lint/complexity/useRegexLiterals)

Regular expression literals avoid some escaping required in a string literal, and are easier to analyze statically.
Safe fix: Use a literal notation instead.

LanguageTool
README.md

[misspelling] ~3-~3: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’. (EN_A_VS_AN)
Context: ...template for integrating dapp devs, and an npm package to aid with deploying and s...


[uncategorized] ~12-~12: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION)
Context: ...and used in production. - interfaces/: Interfaces for core and testing contrac...

Markdownlint
README.md

11-11: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


12-12: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


14-14: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


19-19: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


21-21: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


23-23: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


25-25: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


30-30: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


33-33: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


36-36: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


42-42: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


43-43: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


47-47: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


50-50: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


51-51: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


55-55: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


58-58: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


61-61: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


65-65: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


66-66: Expected: 0 or 2; Actual: 1 (MD009, no-trailing-spaces)
Trailing spaces


7-7: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


16-16: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


162-162: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


17-17: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


29-29: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


35-35: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


38-38: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


41-41: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


50-50: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


65-65: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


65-65: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


117-117: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


17-17: null (MD025, single-title, single-h1)
Multiple top-level headings in the same document


11-11: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


62-62: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


64-64: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


70-70: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified


120-120: null (MD040, fenced-code-language)
Fenced code blocks should have a language specified

Additional comments not posted (24)
specs/evm.accounts.yaml (1)

3-11: Reaffirmation on the use of dummy keys.

As previously discussed, the private keys listed are for testing purposes, derived from a test mnemonic used specifically for testing within controlled environments like Anvil/Hardhat. This setup ensures that the keys do not correspond to any real funds or resources and are safe to be exposed in the context of development and testing.

Tools
Gitleaks

3-3: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


9-9: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)


11-11: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

src/evm/contracts/factories/Ibc__factory.ts (1)

503-503: Review the bytecode for potential optimizations or errors.

The bytecode is directly embedded in the source file. Ensure this bytecode is up-to-date and optimized for gas usage, especially since it will be used to deploy the Ibc contract. Consider verifying this bytecode against a trusted compiler output to ensure it has not been tampered with or incorrectly generated.

src/evm/contracts/factories/Mars.sol/RevertingBytesMars__factory.ts (4)

860-860: Bytecode appears correctly formatted.

The bytecode string is a critical part of the contract deployment and it seems to be correctly formatted. Ensure that it has been tested thoroughly in different environments to avoid deployment issues.


860-860: Constructor implementation is robust.

The constructor uses a helper function to determine the correct parameters for the superclass, which is a good practice to handle multiple types of arguments securely.


860-860: Deployment methods are implemented securely.

Both getDeployTransaction and deploy methods handle deployment parameters securely, ensuring that overrides are properly managed. This is crucial for preventing deployment errors and security issues.


860-860: Connect method is standard and secure.

The connect method is implemented using standard practices, allowing for secure and flexible connections to deployed contract instances.

src/evm/contracts/factories/Mars.sol/RevertingStringMars__factory.ts (5)

850-850: Ensure the bytecode string is appropriately handled to prevent any security vulnerabilities or errors in deployment.

This should be audited to ensure that there are no hidden malicious codes or inefficiencies.


Line range hint 870-873: Ensure proper handling of optional parameters in getDeployTransaction.

The method correctly provides a default object for overrides if it is not provided. This is a best practice to prevent undefined errors when accessing properties of overrides.


Line range hint 875-879: Check type safety in the deploy method.

The method uses type casting to ensure the return type includes deploymentTransaction. Ensure that this casting is safe and that the actual deployed contract object conforms to this expected structure.


Line range hint 881-884: Review the connect method for correct handling of null values and type safety.

Ensure that the method correctly handles cases where runner might be null and that the type casting to RevertingStringMars__factory is appropriate.


Line range hint 886-895: Review static properties and utility methods for correct implementation and exposure.

Ensure that the static properties bytecode and abi are correctly set and that the utility methods provide the intended functionality without exposing unnecessary internal details.

src/evm/contracts/factories/Mars.sol/RevertingEmptyMars__factory.ts (2)

Line range hint 113-119: Constructor logic is well-implemented for flexibility.

The constructor of RevertingEmptyMars__factory uses a conditional approach to handle different initialization scenarios, which is a standard and effective pattern in Solidity contract factories.


Line range hint 121-133: Deployment and connection methods are correctly implemented.

The methods for deploying and connecting to the contract are implemented correctly, following best practices for contract factories in Solidity. It's important to ensure that input handling and override mechanisms do not introduce security vulnerabilities.

Also applies to: 141-143

src/evm/contracts/factories/Mars.sol/PanickingMars__factory.ts (5)

Line range hint 850-865: Constructor Implementation Looks Good

The constructor's use of a type guard to support different argument patterns is a solid approach. It might be beneficial to add explanatory comments about the argument handling for future maintainers.


Line range hint 867-872: Good Practice in Handling Optional Parameters

The getDeployTransaction method correctly handles optional parameters by providing a default value. This prevents potential issues from undefined inputs and is a good practice in contract deployment functions.


Line range hint 873-879: Clear Type Casting in Deployment Method

The deploy method uses explicit casting to ensure the return type matches expected types, enhancing type safety. This is a crucial practice in TypeScript for maintaining robust type systems in contract interactions.


Line range hint 880-884: Method Enhances Flexibility

The connect method allows for flexible interaction with different contract runners, which is beneficial for testing or different blockchain environments.


Line range hint 885-905: Static Elements Correctly Implemented

The static properties and methods such as bytecode, abi, createInterface, and connect are crucial for the contract's deployment and interaction. Their implementation follows best practices and ensures that the contract can be used effectively in different contexts.

src/evm/contracts/factories/Mars.sol/Mars__factory.ts (1)

847-847: Bytecode has been updated.

It appears the bytecode has been updated. Please ensure that this new bytecode accurately reflects the latest changes in the Mars contract logic.

src/evm/contracts/factories/Mars.sol/RevertingStringCloseChannelMars__factory.ts (4)

Line range hint 1-14: Imports and Basic Setup

The imports and basic setup of the file are correct and follow standard practices for Ethereum smart contract development using the ethers library. The structure is clear, and the disabling of linting rules is appropriate given the context of autogenerated files.


Line range hint 16-50: ABI Definition Review

The ABI array is well-defined with clear and specific entries for each function and event in the contract. Each entry includes types, names, and other necessary Ethereum ABI specifications.

Note: Ensure that all entries in the ABI match the actual functions and events in the smart contract to avoid runtime errors and misbehaviors.


Line range hint 52-55: Type Definition for Constructor Parameters

The type definition for constructor parameters is flexible, accommodating both single and multiple argument formats. This design enhances the factory's usability across different deployment scenarios.

Best Practice: Continue using flexible and comprehensive type definitions to ensure that the factory class can handle various initialization scenarios effectively.


Line range hint 57-123: Factory Class Methods and Functionality

The RevertingStringCloseChannelMars__factory class methods are implemented correctly, providing functionality for deploying the contract, connecting to different environments, and handling contract transactions. The use of overrides ensures that the methods behave as expected when extending from ContractFactory.

Security Note: Always review the actual contract deployment parameters and ensure that they are validated or sanitized as needed to prevent deployment errors or security vulnerabilities.
[APPLAUD]

src/evm/contracts/factories/Dispatcher__factory.ts (1)

2170-2170: Interface Declaration Check: DispatcherLibraryAddresses

The interface DispatcherLibraryAddresses is correctly declared and used within the factory class for type safety. This ensures that the correct structure for library addresses is enforced throughout the code.

src/evm/contracts/Earth.ts Outdated Show resolved Hide resolved
src/evm/contracts/factories/Dispatcher__factory.ts Outdated Show resolved Hide resolved
src/evm/account.ts Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
test/Fork/contract-spec.yaml Show resolved Hide resolved
Copy link

@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: 2

Outside diff range and nitpick comments (2)
src/deploy.ts (1)

Line range hint 38-163: Refactor deployment logic and address parameter order issue.

The function deployToChain could benefit from refactoring to improve clarity and maintainability. Additionally, ensure that default parameters follow the last required parameter to avoid confusion and potential errors.

// Ensure default parameters are correctly ordered
async function deployToChain(
  chain: Chain,
  accountRegistry: AccountRegistry,
  deploySpec: ContractRegistry,
  logger: Logger,
  dryRun = false,
  forceDeployNewContracts: boolean, // Moved to follow required parameters
  writeContracts: boolean = true // Moved to follow required parameters
) {
  // deployment logic
}
src/utils/io.ts (1)

Line range hint 161-328: Optimize I/O operations and remove unnecessary else clause.

The function parseArgsFromCLI includes an unnecessary else clause that could be omitted for cleaner code. Additionally, consider optimizing I/O operations to improve performance and error handling.

// Remove unnecessary else clause
if (!chainParse.success) {
  throw new Error(`failed to parse chain config: ${chainParse.error.errors}`);
}
// Continue with logic without 'else'

// Optimize I/O operations by consolidating file reads or using async patterns
async function optimizedRead(filePath: string): Promise<string> {
  try {
    return await fs.promises.readFile(filePath, { encoding: 'utf8' });
  } catch (err) {
    console.error(`Error reading file: ${filePath}`, err);
    throw err;
  }
}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9eb14fd and 7209118.

Files selected for processing (17)
  • .github/workflows/foundry.yml (1 hunks)
  • package.json (4 hunks)
  • src/deploy.ts (5 hunks)
  • src/evm/account.ts (2 hunks)
  • src/evm/chain.ts (1 hunks)
  • src/evm/schemas/tx.ts (1 hunks)
  • src/scripts/deploy-script.ts (1 hunks)
  • src/scripts/fork-deployment-test.ts (1 hunks)
  • src/tx.ts (3 hunks)
  • src/utils/constants.ts (1 hunks)
  • src/utils/io.ts (10 hunks)
  • test/Fork/Dispatcher.upgrade.t.sol (1 hunks)
  • test/Fork/contract-spec.yaml (1 hunks)
  • test/Fork/deploy.sh (1 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/upgradeableProxy/UpgradeUtils.t.sol (4 hunks)
  • tsup.config.ts (1 hunks)
Files skipped from review as they are similar to previous changes (12)
  • .github/workflows/foundry.yml
  • package.json
  • src/evm/account.ts
  • src/evm/chain.ts
  • src/evm/schemas/tx.ts
  • src/scripts/deploy-script.ts
  • src/scripts/fork-deployment-test.ts
  • src/utils/constants.ts
  • test/Fork/Dispatcher.upgrade.t.sol
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/upgradeableProxy/UpgradeUtils.t.sol
  • tsup.config.ts
Additional context used
Shellcheck
test/Fork/deploy.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive. (SC2148)


[error] 4-4: Parsing stopped here. Mismatched keywords or invalid parentheses? (SC1070)


[error] 4-4: Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one. (SC1133)

yamllint
test/Fork/contract-spec.yaml

[error] 5-5: trailing spaces (trailing-spaces)


[error] 9-9: trailing spaces (trailing-spaces)


[error] 15-15: trailing spaces (trailing-spaces)


[error] 21-21: trailing spaces (trailing-spaces)


[error] 22-22: trailing spaces (trailing-spaces)


[error] 23-23: trailing spaces (trailing-spaces)


[error] 38-38: trailing spaces (trailing-spaces)


[error] 48-48: trailing spaces (trailing-spaces)


[error] 50-50: trailing spaces (trailing-spaces)


[error] 66-66: trailing spaces (trailing-spaces)

Biome
src/tx.ts

[error] 62-62: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

src/deploy.ts

[error] 28-28: This default parameter should follow the last required parameter or should be a required parameter. (lint/style/useDefaultParameterLast)

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

src/utils/io.ts

[error] 125-127: This else clause can be omitted because previous branches break early. (lint/style/noUselessElse)

Unsafe fix: Omit the else clause.

Additional comments not posted (1)
src/tx.ts (1)

Line range hint 52-103: Refactor error handling and improve code readability.

There are multiple instances of repetitive error handling that could be simplified. Additionally, consider using optional chaining to improve code safety and readability.

// Simplify error handling by using a function to handle repetitive tasks
function handleTxError(err: Error, logger: Logger, chain: Chain, txName: string) {
  logger.error(`[${chain.chainName}-${chain.deploymentEnvironment}] sendTx ${txName} failed: ${err}`);
  throw err;
}

// Usage
try {
  // transaction logic
} catch (err) {
  handleTxError(err, logger, chain, tx.name);
}

test/Fork/contract-spec.yaml Show resolved Hide resolved
Copy link

@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: 6

Outside diff range and nitpick comments (2)
src/deploy.ts (1)

Line range hint 28-28: Adjust default parameter placement in function signature.

According to the static analysis hint, the default parameter libraries should follow the last required parameter or be made a required parameter to ensure correct function usage.

- const getDeployData = (factoryName, deployArgs, env, libraries = [], init)
+ const getDeployData = (factoryName, deployArgs, env, init, libraries = [])
src/utils/io.ts (1)

Line range hint 125-127: Remove unnecessary else clause.

The else clause after a return statement is redundant and can be removed to simplify the code structure.

- else {
-   throw new Error(`unsupported file extension: ${ext}, only {.json, .yaml|.yml} are supported`);
- }
+ // Removed unnecessary else clause
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7209118 and 685af3e.

Files selected for processing (21)
  • .github/workflows/foundry.yml (1 hunks)
  • .npmignore (1 hunks)
  • README.md (1 hunks)
  • package.json (4 hunks)
  • specs/contracts.spec.yaml (2 hunks)
  • specs/evm.accounts.yaml (1 hunks)
  • src/deploy.ts (5 hunks)
  • src/evm/account.ts (2 hunks)
  • src/evm/chain.ts (1 hunks)
  • src/evm/schemas/tx.ts (1 hunks)
  • src/scripts/deploy-script.ts (1 hunks)
  • src/scripts/fork-deployment-test.ts (1 hunks)
  • src/tx.ts (3 hunks)
  • src/utils/constants.ts (1 hunks)
  • src/utils/io.ts (10 hunks)
  • test/Fork/Dispatcher.upgrade.t.sol (1 hunks)
  • test/Fork/contract-spec.yaml (1 hunks)
  • test/Fork/deploy.sh (1 hunks)
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol (1 hunks)
  • test/upgradeableProxy/UpgradeUtils.t.sol (4 hunks)
  • tsup.config.ts (1 hunks)
Files skipped from review as they are similar to previous changes (13)
  • .github/workflows/foundry.yml
  • .npmignore
  • package.json
  • src/evm/account.ts
  • src/evm/chain.ts
  • src/evm/schemas/tx.ts
  • src/scripts/deploy-script.ts
  • src/scripts/fork-deployment-test.ts
  • src/utils/constants.ts
  • test/Fork/Dispatcher.upgrade.t.sol
  • test/upgradeableProxy/DispatcherRC4.upgrade.t.sol
  • test/upgradeableProxy/UpgradeUtils.t.sol
  • tsup.config.ts
Additional context used
Shellcheck
test/Fork/deploy.sh

[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

(SC2148)


[error] 4-4: Parsing stopped here. Mismatched keywords or invalid parentheses?

(SC1070)


[error] 4-4: Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one.

(SC1133)

Gitleaks
specs/evm.accounts.yaml

3-3: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


7-7: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


9-9: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


11-11: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

yamllint
specs/contracts.spec.yaml

[error] 5-5:


[error] 9-9:


[error] 15-15:


[error] 21-21:


[error] 22-22:


[error] 23-23:


[error] 38-38:


[error] 48-48:


[error] 50-50:


[error] 66-66:

test/Fork/contract-spec.yaml

[error] 5-5:


[error] 9-9:


[error] 15-15:


[error] 21-21:


[error] 22-22:


[error] 23-23:


[error] 38-38:


[error] 48-48:


[error] 50-50:


[error] 66-66:

Biome
src/tx.ts

[error] 62-62: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

src/deploy.ts

[error] 28-28: This default parameter should follow the last required parameter or should be a required parameter.

The last required parameter is here:

A default parameter that precedes a required parameter cannot be omitted at call site.
Unsafe fix: Turn the parameter into a required parameter.

(lint/style/useDefaultParameterLast)

src/utils/io.ts

[error] 125-127: This else clause can be omitted because previous branches break early.

Unsafe fix: Omit the else clause.

(lint/style/noUselessElse)

LanguageTool
README.md

[misspelling] ~3-~3: Use “a” instead of ‘an’ if the following word doesn’t start with a vowel sound, e.g. ‘a sentence’, ‘a university’.
Context: ...template for integrating dapp devs, and an npm package to aid with deploying and s...

(EN_A_VS_AN)


[uncategorized] ~12-~12: Loose punctuation mark.
Context: ...and used in production. - interfaces/: Interfaces for core and testing contrac...

(UNLIKELY_OPENING_PUNCTUATION)

Markdownlint
README.md

11-11: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


12-12: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


14-14: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


19-19: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


21-21: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


23-23: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


25-25: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


30-30: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


33-33: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


36-36: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


42-42: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


43-43: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


47-47: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


50-50: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


51-51: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


55-55: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


64-64: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


70-70: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


71-71: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)


7-7: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)


16-16: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)


167-167: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)


17-17: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


18-18: Expected: 1; Actual: 0; Above
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


18-18: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


29-29: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


32-32: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


35-35: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


38-38: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


41-41: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


50-50: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


70-70: Expected: 1; Actual: 0; Above
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


70-70: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


122-122: Expected: 1; Actual: 0; Below
Headings should be surrounded by blank lines

(MD022, blanks-around-headings)


17-17: null
Multiple top-level headings in the same document

(MD025, single-title, single-h1)


11-11: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


65-65: null
Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


75-75: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


125-125: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Additional comments not posted (3)
specs/contracts.spec.yaml (1)

82-88: Ensure correct deployer keys are used for contract deployment.

The Mars and Earth contracts now use KEY_DAPP1 and KEY_DAPP2 respectively. Confirm that these keys are correctly configured and possess the necessary permissions for deployment.

Verification successful

Deployer keys for Mars and Earth contracts are correctly configured for testing purposes.

The deployer keys KEY_DAPP1 and KEY_DAPP2 are defined in the specs/evm.accounts.yaml file with their respective private keys. These accounts are derived from a test mnemonic by Anvil/Hardhat and are used for testing purposes only.

  • specs/evm.accounts.yaml: Definitions of KEY_DAPP1 and KEY_DAPP2.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the deployer keys `KEY_DAPP1` and `KEY_DAPP2` are correctly configured.
echo "Deployer key verification for Mars and Earth contracts."

Length of output: 120



Script:

#!/bin/bash

# Search for the definitions of `KEY_DAPP1` and `KEY_DAPP2` in the repository
echo "Searching for KEY_DAPP1 and KEY_DAPP2 definitions..."
fd -e yaml -e yml -e env -e json -e toml -e ini -e cfg 'KEY_DAPP1|KEY_DAPP2' --exec rg 'KEY_DAPP1|KEY_DAPP2' {}

# Check for permissions related to `KEY_DAPP1` and `KEY_DAPP2`
echo "Checking for permissions related to KEY_DAPP1 and KEY_DAPP2..."
rg 'permissions' --context 5

Length of output: 25581



Script:

#!/bin/bash

# Search for the exact terms `KEY_DAPP1` and `KEY_DAPP2` in the repository to locate their definitions or usage
echo "Searching for exact definitions and usage of KEY_DAPP1 and KEY_DAPP2..."
rg 'KEY_DAPP1|KEY_DAPP2' --glob '!*LICENSE*' --glob '!*test*' --glob '!*node_modules*'

# Check for environment variables or configurations related to `KEY_DAPP1` and `KEY_DAPP2`
echo "Checking for environment variables or configurations related to KEY_DAPP1 and KEY_DAPP2..."
rg 'KEY_DAPP1|KEY_DAPP2' --glob '*.env' --glob '*.yaml' --glob '*.yml' --glob '*.json' --glob '*.toml' --glob '*.ini' --glob '*.cfg'

Length of output: 1049



Script:

#!/bin/bash

# Display the contents of `specs/evm.accounts.yaml` to verify the configuration and permissions of `KEY_DAPP1` and `KEY_DAPP2`
echo "Displaying contents of specs/evm.accounts.yaml..."
cat specs/evm.accounts.yaml

Length of output: 674

src/tx.ts (1)

94-103: Improve error handling in transaction sending.

The error logging within the transaction sending function is crucial. Ensure that the error messages are clear and provide enough detail to diagnose issues effectively.

README.md (1)

54-63: Clarify deployment command arguments and steps.

The deployment instructions could be clearer and more detailed to ensure users understand how to configure and execute deployments. Consider revising the formatting and adding more explicit descriptions of each command argument.

- 2. Pass in optional command arguments:  
-    - RPC_URL - the rpc url to submit deploy txs to, can be a local fork as well 
-    - ACCOUNTS_SPECS_PATH - the path to the accounts spec file
-    - CHAIN_NAME - the name of the chain to deploy to
-    - CHAIN_ID - the chain id of the chain to deploy to
-    - DEVELOPMENT_ENVIRONMENT - the environment to deploy to, should be one of staging, production, local, or mainnet
- 3. Run either `npx deploy-vibc-core-smart-contracts` to deploy contracts from the contract spec, or `npx upgrade-vibc-core-smart-contracts` to send an upgrade transaction.
+ 2. Pass in optional command arguments:
+    - `RPC_URL`: The RPC URL to submit deploy transactions to, can be a local fork as well.
+    - `ACCOUNTS_SPECS_PATH`: The path to the accounts spec file.
+    - `CHAIN_NAME`: The name of the chain to deploy to.
+    - `CHAIN_ID`: The chain ID of the chain to deploy to.
+    - `DEVELOPMENT_ENVIRONMENT`: The deployment environment (e.g., staging, production, local, mainnet).
+ 3. Execute the deployment:
+    - Run `npx deploy-vibc-core-smart-contracts` to deploy contracts from the contract spec.
+    - Run `npx upgrade-vibc-core-smart-contracts` to send an upgrade transaction.
Tools
Markdownlint

55-55: Expected: 0 or 2; Actual: 1
Trailing spaces

(MD009, no-trailing-spaces)

src/deploy.ts Outdated Show resolved Hide resolved
src/deploy.ts Show resolved Hide resolved
src/utils/io.ts Show resolved Hide resolved
test/Fork/deploy.sh Show resolved Hide resolved
specs/contracts.spec.yaml Show resolved Hide resolved
src/tx.ts Show resolved Hide resolved
@RnkSngh RnkSngh force-pushed the raunak/forkUnitTesting branch 4 times, most recently from aebb483 to 3afa5dc Compare July 2, 2024 16:02
	- upgrade deploy spec to all deploy from one single account
	- impose hierarchy between env, cli, and default params
	- add logging for deployed addresses
	- fix prepublish script
	- fix bug with not being able to parse multiple libraries in deployment config (used to update to new contracts)
	- reorg upgrade test utils
@RnkSngh RnkSngh merged commit 01a71b7 into main Jul 2, 2024
3 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.

3 participants