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

Add option to provide the RPC URL for a localhost network deployment #13

Merged
merged 2 commits into from
Mar 25, 2024

Conversation

stubbsta
Copy link

This PR adds a feature required by the waku-simulator to enable deployment to a network other than sepolia or localhost.

  1. RPC_PROVIDER environment variable added
  2. If the RPC_PROVIDER variable is provided then it is assigned as the URL for the localhost_integration network in hardhat.config.ts

Copy link

LCOV of commit 8790db0 during CI #38

Summary coverage rate:
  lines......: 89.5% (34 of 38 lines)
  functions..: 84.6% (11 of 13 functions)
  branches...: 66.7% (12 of 18 branches)

Files changed coverage rate: n/a

Copy link

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

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

lgtm. Lets wait for @rymnc review.

hardhat.config.ts Outdated Show resolved Hide resolved
@rymnc rymnc self-requested a review March 20, 2024 13:16
Copy link

@rymnc rymnc left a comment

Choose a reason for hiding this comment

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

LGTM, can be merged after @stubbsta confirms it works with waku-simulator

Copy link

LCOV of commit 2354961 during CI #39

Summary coverage rate:
  lines......: 89.5% (34 of 38 lines)
  functions..: 84.6% (11 of 13 functions)
  branches...: 66.7% (12 of 18 branches)

Files changed coverage rate: n/a

@stubbsta
Copy link
Author

This change isn't working when testing in waku-simulator.
I looks like the config from hardhat.config.ts is ignored, because the error shows the localhost IP of 127.0.0.1:

HardhatError: HH108: Cannot connect to the network localhost.
Please make sure your node is running, and check your internet connection and networks config
    at HttpProvider._fetchJsonRpcResponse (/waku-rln-contract/node_modules/hardhat/src/internal/core/providers/http.ts:221:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HttpProvider.request (/waku-rln-contract/node_modules/hardhat/src/internal/core/providers/http.ts:85:29)
    at async DeploymentsManager.getChainId (/waku-rln-contract/node_modules/hardhat-deploy/src/DeploymentsManager.ts:443:23)
    at async DeploymentsManager.loadDeployments (/waku-rln-contract/node_modules/hardhat-deploy/src/DeploymentsManager.ts:619:17)
    at async DeploymentsManager.runDeploy (/waku-rln-contract/node_modules/hardhat-deploy/src/DeploymentsManager.ts:998:5)
    at async SimpleTaskDefinition.action (/waku-rln-contract/node_modules/hardhat-deploy/src/index.ts:438:5)
    at async Environment._runTaskDefinition (/waku-rln-contract/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
    at async Environment.run (/waku-rln-contract/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
    at async SimpleTaskDefinition.action (/waku-rln-contract/node_modules/hardhat-deploy/src/index.ts:584:32)

    Caused by: Error: connect ECONNREFUSED 127.0.0.1:8545
        at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Is there some hardhat setting required to ensure it uses the provided config?

@rymnc
Copy link

rymnc commented Mar 20, 2024

This change isn't working when testing in waku-simulator. I looks like the config from hardhat.config.ts is ignored, because the error shows the localhost IP of 127.0.0.1:

HardhatError: HH108: Cannot connect to the network localhost.
Please make sure your node is running, and check your internet connection and networks config
    at HttpProvider._fetchJsonRpcResponse (/waku-rln-contract/node_modules/hardhat/src/internal/core/providers/http.ts:221:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async HttpProvider.request (/waku-rln-contract/node_modules/hardhat/src/internal/core/providers/http.ts:85:29)
    at async DeploymentsManager.getChainId (/waku-rln-contract/node_modules/hardhat-deploy/src/DeploymentsManager.ts:443:23)
    at async DeploymentsManager.loadDeployments (/waku-rln-contract/node_modules/hardhat-deploy/src/DeploymentsManager.ts:619:17)
    at async DeploymentsManager.runDeploy (/waku-rln-contract/node_modules/hardhat-deploy/src/DeploymentsManager.ts:998:5)
    at async SimpleTaskDefinition.action (/waku-rln-contract/node_modules/hardhat-deploy/src/index.ts:438:5)
    at async Environment._runTaskDefinition (/waku-rln-contract/node_modules/hardhat/src/internal/core/runtime-environment.ts:330:14)
    at async Environment.run (/waku-rln-contract/node_modules/hardhat/src/internal/core/runtime-environment.ts:163:14)
    at async SimpleTaskDefinition.action (/waku-rln-contract/node_modules/hardhat-deploy/src/index.ts:584:32)

    Caused by: Error: connect ECONNREFUSED 127.0.0.1:8545
        at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Is there some hardhat setting required to ensure it uses the provided config?

can you try yarn deploy localhost_integration

@stubbsta
Copy link
Author

Running

yarn deploy localhost_integration

works and uses the provided URL.

Using the network name 'localhost' seems to bypass using the config from hardhat.config.ts.
With

yarn deploy localhost

I am able to successfully deploy the contracts from my local machine (not inside docker) with no .env file present or even with

networks: {},

instead of

networks: getNetworkConfig,

Is it acceptable to use "localhost_integration" as the network or do we want to find a way to use "localhost" with a given RPC URL?

@stubbsta
Copy link
Author

stubbsta commented Mar 25, 2024

We could also change the network name in hardhat.config.ts from 'localhost_integration' to 'localhost', then using
yarn deploy localhost works as expected

@stubbsta stubbsta requested review from alrevuelta and rymnc March 25, 2024 09:09
Copy link

@rymnc rymnc left a comment

Choose a reason for hiding this comment

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

LGTM

@stubbsta stubbsta merged commit 1f96610 into main Mar 25, 2024
1 check passed
@stubbsta stubbsta deleted the deploy-local-with-provided-url branch March 25, 2024 11:45
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