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

ci: fix sdk build failure #377

Merged
merged 4 commits into from
Sep 3, 2024
Merged

ci: fix sdk build failure #377

merged 4 commits into from
Sep 3, 2024

Conversation

seolaoh
Copy link
Contributor

@seolaoh seolaoh commented Sep 2, 2024

No description provided.

@seolaoh seolaoh self-assigned this Sep 2, 2024
@seolaoh seolaoh requested review from a team as code owners September 2, 2024 09:07
Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

Walkthrough

The changes involve updating the pnpm package version from 8 to 9 in the CI workflow configuration files. Additionally, there are modifications to the ESLint configuration, reorganization of imports in the Hardhat configuration, and enhancements to type safety in several task files by explicitly typing parameters. A new file has also been introduced to extend the Hardhat runtime environment with deployment functionalities.

Changes

Files Change Summary
.github/workflows/ci.yml, .github/workflows/test.yml Updated pnpm version from 8 to 9.
packages/sdk/.eslintrc.js Removed ignorePatterns property, including hardhat.config.ts in linting checks.
packages/sdk/hardhat.config.ts Reorganized import statements and updated sources path from ./test/contracts to ./src.
packages/sdk/src/tasks/deposit-eth.ts, packages/sdk/src/tasks/initiate-withdrawal.ts Added type annotation for hre parameter as HardhatRuntimeEnvironment.
packages/sdk/src/type-extensions.ts Introduced new file to extend HardhatRuntimeEnvironment with a deployments property.

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

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

Tip

Early access features: enabled

We are currently testing the following features in early access:

  • Anthropic claude-3-5-sonnet for code reviews: Anthropic claims that the new Claude model has stronger code understanding and code generation capabilities than their previous models. Note: Our default code review model was also updated late last week. Please compare the quality of the reviews between the two models by toggling the early access feature.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.
  • Please join our Discord Community to provide feedback and report issues on the discussion post.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b83718c and 0e08e39.

Files ignored due to path filters (3)
  • package.json is excluded by !**/*.json
  • packages/sdk/package.json is excluded by !**/*.json
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/*.yaml
Files selected for processing (2)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/test.yml (1 hunks)
Additional comments not posted (4)
.github/workflows/test.yml (3)

Line range hint 1-72: Overall workflow structure and best practices

The workflow file is well-structured and follows GitHub Actions best practices. The pnpm version upgrade is the only change, and it's appropriately placed within the workflow.

A few points to note:

  1. The workflow uses a custom runner group and labels, which is good for specific infrastructure requirements.
  2. It properly sets up and caches dependencies for Go, Node.js, and pnpm.
  3. The Foundry installation uses a specific nightly version, which ensures consistency but may need periodic updates.
  4. The OP_E2E_DISABLE_PARALLEL environment variable is set to false for the test step, which could impact test execution speed and resource usage.

These aspects of the workflow are not directly related to the pnpm version change but are worth keeping in mind for future optimizations or troubleshooting.


31-31: Upgrade of pnpm version from 8 to 9

This change aligns with the PR objective to fix the SDK build failure. Upgrading pnpm could potentially resolve dependency-related issues.

To ensure compatibility and to catch any potential issues early, please run the following verification steps:

After running these checks, please ensure that:

  1. All workflow files use the same pnpm version (9).
  2. Any pnpm-related scripts in package.json are compatible with version 9.
  3. If a pnpm-lock.yaml file exists, regenerate it using pnpm 9 to ensure compatibility.

Line range hint 40-47: Consider potential impact on pnpm cache

The pnpm version upgrade might affect the contents of the pnpm-lock.yaml file. If this file changes, it could impact the effectiveness of the caching step.

To ensure the cache is working as expected after the upgrade, please run the following verification steps:

If the pnpm-lock.yaml file has changed or if you notice cache misses in recent runs, consider:

  1. Regenerating the pnpm-lock.yaml file with pnpm 9.
  2. Updating the cache key in the workflow if necessary.
  3. Running the workflow again to verify that the cache is working as expected.
Verification successful

Consider potential impact on pnpm cache

The pnpm version upgrade might affect the contents of the pnpm-lock.yaml file, potentially impacting the caching step. Recent workflow logs show both cache hits and misses, indicating that while the cache is functioning, there may be room for optimization. Please ensure that the pnpm-lock.yaml file is up-to-date and consider reviewing the cache key strategy if cache misses persist.

  • Cache hits were observed, indicating that the caching mechanism is working.
  • Cache misses suggest potential areas for improvement in cache configuration.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify pnpm-lock.yaml and cache effectiveness

# Test: Check if pnpm-lock.yaml has changed
echo "Checking if pnpm-lock.yaml has changed:"
git diff --name-only origin/main -- pnpm-lock.yaml

# Test: Look for cache hit/miss logs in recent workflow runs
echo "Checking recent workflow runs for cache hit/miss:"
gh run list --workflow=test.yml --limit=5 --json conclusion,databaseId --jq '.[] | "Run ID: \(.databaseId), Conclusion: \(.conclusion)"'
echo "Please manually check the logs of these runs for cache hit/miss information."

Length of output: 791


Script:

#!/bin/bash
# Description: Verify pnpm-lock.yaml changes and cache effectiveness

# Test: Check if pnpm-lock.yaml exists and its last modification time
echo "Checking if pnpm-lock.yaml exists and its last modification time:"
if [ -f pnpm-lock.yaml ]; then
  stat pnpm-lock.yaml
else
  echo "pnpm-lock.yaml does not exist."
fi

# Test: Attempt to extract cache hit/miss information from recent workflow logs
echo "Attempting to extract cache hit/miss information from recent workflow logs:"
gh run list --workflow=test.yml --limit=5 --json databaseId --jq '.[] | .databaseId' | while read -r run_id; do
  echo "Checking logs for Run ID: $run_id"
  gh run view "$run_id" --log | grep -i "cache hit\|cache miss"
done

Length of output: 6320

.github/workflows/ci.yml (1)

44-44: Approve pnpm version update to 9

This change aligns with the PR objective to fix the SDK build failure. The update from pnpm 8 to 9 might resolve dependency resolution issues or introduce new features that could fix the build process.

To ensure this change doesn't introduce any new issues, please verify the following:

  1. The build process completes successfully for all components (Node, Validator, Batcher) with the new pnpm version.
  2. The pnpm-lock.yaml file has been updated to reflect this version change.

You can use the following script to check for other workflow files that might need updating:

If other workflow files are found using different pnpm versions, consider updating them for consistency across the project.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (7)
packages/sdk/src/type-extensions.ts (1)

1-2: Consider grouping imports.

For better organization, consider grouping the imports by their source. You can separate third-party imports from local imports and sort them alphabetically.

Here's a suggested reorganization:

-import 'hardhat/types/runtime'
-import { DeploymentsExtension } from 'hardhat-deploy/types'
+import 'hardhat/types/runtime';
+
+import { DeploymentsExtension } from 'hardhat-deploy/types';
packages/sdk/hardhat.config.ts (1)

3-4: LGTM! Consider grouping related imports.

The reorganization of imports improves code structure and readability.

Consider grouping related imports together. You could move the @nomiclabs/hardhat-ethers import next to hardhat-deploy for better organization:

 import { HardhatUserConfig } from 'hardhat/types'
 
-import '@nomiclabs/hardhat-ethers'
 import 'hardhat-deploy'
+import '@nomiclabs/hardhat-ethers'
packages/sdk/src/tasks/initiate-withdrawal.ts (5)

Line range hint 1-14: Consider reorganizing imports for better readability.

The current import structure mixes Node.js built-ins, external libraries, and local imports. Consider grouping them as follows:

  1. Node.js built-ins
  2. External libraries
  3. Local imports

This organization can improve code readability and maintainability.

Here's a suggested reorganization:

import { promises as fs } from 'fs'

import { Wallet, providers, utils } from 'ethers'
import { task, types } from 'hardhat/config'
import { HardhatRuntimeEnvironment } from 'hardhat/types'
import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'

import {
  CONTRACT_ADDRESSES,
  ContractsLike,
  CrossChainMessenger,
  DEFAULT_L2_CONTRACT_ADDRESSES,
  assert,
} from '../'

Line range hint 21-38: Consider extracting default values and using constants.

The task definition uses some magic strings and numbers. It's generally a good practice to extract these into named constants, especially for values that might be used in multiple places or could change in the future.

Consider defining constants for default values:

const DEFAULT_L1_PROVIDER_URL = 'http://localhost:8545'
const DEFAULT_AMOUNT = '1'

// Then use these in the task definition
.addParam(
  'l1ProviderUrl',
  'L1 Provider URL',
  DEFAULT_L1_PROVIDER_URL,
  types.string
)
// ...
const amount = parseEther(args.amount ?? DEFAULT_AMOUNT)

Line range hint 41-43: Enhance error messages for better debugging.

The current assertions use basic error messages. Consider providing more context in these messages to aid in debugging.

Improve error messages:

assert(signers.length > 0, 'No configured signers found in the Hardhat Runtime Environment')
// ...
assert(balance.gt(0), `Signer ${address} has no balance`)

Line range hint 1-108: Consider breaking down the task action into smaller functions.

The task action is quite long and handles multiple concerns. Consider breaking it down into smaller, more focused functions to improve readability and maintainability.

You could extract logic into functions like:

  • getContractAddresses(hre, l1ContractsJsonPath)
  • setupMessenger(l1Signer, signer, chainId, contractAddrs)
  • performWithdrawal(messenger, amount, to)

This would make the main task action more concise and easier to understand at a glance.


6-6: Inconsistent use of HardhatRuntimeEnvironment type annotation in task files.

The following task files do not use the HardhatRuntimeEnvironment type annotation for the hre parameter, leading to inconsistency in type safety practices:

  • packages/sdk/src/tasks/register-erc20.ts
  • packages/sdk/src/tasks/deposit-erc20.ts

Consider updating these files to include the HardhatRuntimeEnvironment type annotation for improved type safety and consistency across the codebase.

Analysis chain

Improved type safety with HardhatRuntimeEnvironment.

The addition of the HardhatRuntimeEnvironment type for the hre parameter enhances type safety and code clarity. This is a good practice that should be applied consistently across the codebase.

To ensure consistency, let's check if other task files in the SDK use the same type annotation:

If this script returns results, consider updating those files for consistency.

Also applies to: 39-39

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if other task files use HardhatRuntimeEnvironment type annotation

# Test: Search for task definitions without HardhatRuntimeEnvironment type annotation
# Expect: No results, indicating all task files use the type annotation
rg --type typescript 'setAction\(async \(.*\) =>' packages/sdk/src/tasks/ | rg -v 'hre: HardhatRuntimeEnvironment'

Length of output: 151


Script:

#!/bin/bash
# Description: Check if other task files use HardhatRuntimeEnvironment type annotation

# Test: Search for task definitions without HardhatRuntimeEnvironment type annotation
# Expect: No results, indicating all task files use the type annotation
rg 'setAction\(async \(.*\) =>' --glob '**/*.ts' packages/sdk/src/tasks/ | rg -v 'hre: HardhatRuntimeEnvironment'

Length of output: 268

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0e08e39 and da70405.

Files ignored due to path filters (1)
  • packages/sdk/tsconfig.json is excluded by !**/*.json
Files selected for processing (5)
  • packages/sdk/.eslintrc.js (1 hunks)
  • packages/sdk/hardhat.config.ts (2 hunks)
  • packages/sdk/src/tasks/deposit-eth.ts (2 hunks)
  • packages/sdk/src/tasks/initiate-withdrawal.ts (2 hunks)
  • packages/sdk/src/type-extensions.ts (1 hunks)
Additional comments not posted (4)
packages/sdk/src/type-extensions.ts (1)

1-8: LGTM! New file for extending Hardhat runtime environment.

The new file correctly extends the Hardhat runtime environment with deployment functionalities. This is a good practice for adding custom capabilities to Hardhat.

packages/sdk/.eslintrc.js (1)

Line range hint 1-44: Removal of ignorePatterns property

The AI-generated summary mentions the removal of the ignorePatterns property, which previously excluded hardhat.config.ts from linting. This change is not visible in the provided code, but it's an important modification to note.

To verify the impact of this change, please run the following script:

This script will help verify if hardhat.config.ts is now being linted and if there are any ESLint disable comments in the file.

Existing configuration review

The current ESLint configuration follows good practices:

  1. It extends a base configuration from the root of the project.
  2. It includes specific overrides for TypeScript files in the src directory.
  3. The list of restricted imports helps maintain a clean dependency structure.
packages/sdk/hardhat.config.ts (1)

17-17: Verify project structure changes.

The update of the 'sources' path from './test/contracts' to './src' is approved.

This change suggests a shift in the project structure. Please ensure that:

  1. All contract source files have been moved from './test/contracts' to './src'.
  2. Any import statements in other files referencing these contracts have been updated.
  3. Other configuration files or scripts that might reference the old path have been updated.

Run the following script to verify these changes:

packages/sdk/src/tasks/deposit-eth.ts (1)

52-52: Improved type safety for hre parameter

The explicit type annotation HardhatRuntimeEnvironment for the hre parameter enhances type safety and improves code clarity. This change aligns with TypeScript best practices and will provide better IDE support and catch potential type-related errors earlier in the development process.

@seolaoh seolaoh merged commit 0750a8b into dev Sep 3, 2024
2 checks passed
@seolaoh seolaoh deleted the ci/fix-build-fail branch September 3, 2024 08:58
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.

4 participants