-
Notifications
You must be signed in to change notification settings - Fork 393
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 Hardhat Fork Functionality #3247
Conversation
This branch is a branch created from `mainnet-fork-triage` (PR #3247). It contains changes that allow for mainnet fork interactions. The branch keeps the fork config in a yarn workspace. In order to use it: ``` cd <root-folder> nvm use 16 yarn install yarn start #optional ``` And in other shell: ``` cd ci yarn install npx hardhat node --network hardhat ``` Sending txs, swapping, NFT discovery should work. No activity history. Some strange assets listed. Note that this is a WIP branch and there are some scripts and docs which should be removed before merging the branch to `main`.
This branch is a branch created from `mainnet-fork-triage` (PR #3247). It contains changes that allow for mainnet fork interactions. The branch keeps the fork config in a yarn workspace. In order to use it: ``` cd <root-folder> nvm use 16 yarn install yarn start #optional ``` And in other shell: ``` cd ci yarn install npx hardhat node --network hardhat ``` Sending txs, swapping, NFT discovery should work. No activity history. Some strange assets listed. Note that this is a WIP branch and there are some scripts and docs which should be removed before merging the branch to `main`.
In this commit we create a Hardhat project that allows for running Taho extension on a forked Mainnet. As part of this we're configuring a `hardhat` network in the Hardhat config file. The fork will begin on a block specified in the `blockNumber` parameter. The `url` parameter should hold an url to a JSON-RPC node that's based on your personal Infura/Alchemy API key (e.g. `https://mainnet.infura.io/v3/<key>`). The suggested value for `chainId` is `1337`. The steps to run the network are described in the README file. Any actions performed on the `hardhat` network will only be applied locally, they will not affect the real Mainnet network.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love to try moving the hardhat dependency into the ci
package and removing that package from workspaces
given how much yarn.lock
garbage it pulls in.
What I expect would happen:
- Drop
hardhat
from top-levelpackage.json
and dropci
from theworkspaces
list there as well. - Add
hardhat
toci/package.json
. git checkout main -- yarn.lock
to revert yarn.lock to the latest main version.yarn install
cd ci; yarn install
- Then add
ci/yarn.lock
.
If any of this runs into issues I think we can merge as-is rather than wasting too much more time on it though.
ci/README.md
Outdated
`yarn install` | ||
`yarn start` (or `yarn build`) | ||
`cd ci` | ||
`npx hardhat node --network hardhat` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be yarn hardhat node --network hardhat
for simplicity fwiw.
forking: { | ||
enabled: true, | ||
url: process.env.CHAIN_API_URL || "", | ||
blockNumber: parseInt(process.env.FORKING_BLOCK ?? "", 10), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if this is NaN
? (The result of parsing ""
.)
{ | ||
"name": "@tallyho/ci", | ||
"version": "0.0.1", | ||
"description": "Taho, the community owned and operated Web3 wallet: window provider is responsible for creating the in-page object for communication.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably update the second part to reference CI.
package.json
Outdated
@@ -56,7 +56,8 @@ | |||
"background", | |||
"provider-bridge", | |||
"provider-bridge-shared", | |||
"window-provider" | |||
"window-provider", | |||
"ci" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this listed as a workspace?
package.json
Outdated
@@ -110,6 +111,7 @@ | |||
"eslint-plugin-react": "^7.24.0", | |||
"eslint-plugin-react-hooks": "^4.2.0", | |||
"fork-ts-checker-webpack-plugin": "^6.3.2", | |||
"hardhat": "^2.14.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dependency should probably be in the ci
package, no? It's unused elsewhere afaict.
This instead of a workspace in the top-level project. This allows the ci project to have its own dependencies, rather than polluting the lockfile for the top-level extension project with the large amount of hardhat dependencies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All righty let's rock and roll 🎸
I guess also not clear to me is how much this differs from what's in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok but this time though let's do it lol.
## What's Changed * Repeater Connection: Forward requests to new default when default is switched off during dApp connection flow by @Shadowfiend in #3462 * Auto-Not-So-Matic: Fix two matic.network URLs to polygon.technology by @Shadowfiend in #3483 * v0.38.0 by @kkosiorowska in #3480 * Case Dismissed: Forcibly show DAppConnectionInfoBar popover on first dApp connection by @Shadowfiend in #3464 * Add Hardhat Fork Functionality by @0xDaedalus in #3247 * Faded Jeans: Rename fadeIn class to fade_in by @Shadowfiend in #3485 * Fix issue for discovery transaction hash by @kkosiorowska in #3458 * Full Sweep: Drop the USE_UPDATED_SIGNING_UI feature flag by @Shadowfiend in #3475 * Token Discovery - Remap redux asset balances by @hyphenized in #3195 * Make specific warnings for adding custom asset by @kkosiorowska in #3478 * Run NFTs e2e tests on a controlled wallet address by @michalinacienciala in #3487 * v0.38.1 by @jagodarybacka in #3484 **Full Changelog**: v0.38.1...v0.39.0 Latest build: [extension-builds-3496](https://github.com/tahowallet/extension/suites/13792957673/artifacts/764738599) (as of Thu, 22 Jun 2023 14:27:32 GMT).
This commit introduces automated E2E tests for asset transactions and changes to the testing framework needed for the tests to run successfully. Changes to the framework include: * The changes from #3247 which added support for the hardhat functionality in the wallet's code. * Creation of a Hardhat project in `./ci` folder. In the project we configure a `hardhat` network, which is a network that's a fork of Mainnet. The fork begins on the block specified in the `blockNumber` parameter in `hardhat.config.ts` (currently it's set to `17094516`, which is a starting point for our fork-based E2E tests). Any actions performed on the `hardhat` network will only be applied locally, they will not affect the real Mainnet network. * Creation of the helper files and functions in `./e2e-tests/utils`. * Modification of the GH Actions workflow. A new job (`e2e-tests-fork`) is added to the `build.yml` workflow. The job uses the build artifact from earlier jobs, installs the project, installs Hardhat and runs the local `hardhat` network with the Mainnet fork. Then it runs the Playwright E2E tests designed for fork (the ones with `-fork` suffix) and upload the test artifacts in case of tests failure. Also the old `e2e-tests` job gets modified - it's now running only those E2E tests which are not intended for running on fork (don't contain the `-fork` suffix.) The following tests got added: * User can send base asset (executed on forked Mainnet) * User can open ERC-20 transfer from asset list and can reject the transfer (executed on forked Mainnet) * User can send ERC-20 from header (executed on forked Mainnet) * User can send base asset (executed on Goerli testnet) Most of the tests are run on Mainnet fork (to not waste the funds), but one test is run on Goerli - this is to verify the display of the transaction on the activity views (activity history doesn't work currently on fork). TODO: - [x] Change the settings of workflow artifacts accessibility (storing of artifacts turned off until we switch to importing accounts using JSON, not seed) - [x] Change the `TEST_WALLET_RECOVERY_PHRASE` secret to the seed phrase of the `testertesting.eth` wallet (**please don't do that before previous TODOs are checked!**) - [x] Once secrets are set, do final testing of the workflow - [x] Clean the testing config from the workflow once tests are done Latest build: [extension-builds-3418](https://github.com/tahowallet/extension/suites/14283396113/artifacts/802860953) (as of Thu, 13 Jul 2023 18:53:15 GMT).
Necessary environment variables:
Latest build: extension-builds-3247 (as of Fri, 16 Jun 2023 18:14:21 GMT).