Enable hardhat forking RSK mainnet#433
Merged
tjcloa merged 15 commits intodevelopmentfrom Jun 23, 2022
Merged
Conversation
Requires a bit of patching because of RSK.
Calling a forked node (hardhat node --fork MY_RSK_NODE_RPC_URL) failed with:
eth_call
Invalid JSON-RPC response's result. Errors: Invalid value null supplied
to: RpcBlockWithTransactions | null/transactions: RpcTransaction
Array/0: RpcTransaction/v: QUANTITY, Invalid value null supplied to:
RpcBlockWithTransactions | null/transactions: RpcTransaction Array/0:
RpcTransaction/r: QUANTITY, Invalid value null supplied to:
RpcBlockWithTransactions | null/transactions: RpcTransaction Array/0:
RpcTransaction/s: QUANTITY
This patch is based on:
https://gist.github.com/0x0scion/0422f9135bc37642ba36d55b59e8b424
More reading:
NomicFoundation/hardhat#2395
https://github.com/NomicFoundation/hardhat/pull/2313/files
NomicFoundation/hardhat#2106
39ec42d to
ec2606a
Compare
tjcloa
reviewed
May 3, 2022
Contributor
There was a problem hiding this comment.
lgtm
to work around possible issues with future hh updates, i suggest:
- create a hh task from the forking.test.js and remove the test as it does not test the domain logic; this way we can avoid false-negatives due to the node issues etc. when running the tests
- add the PR comment as disclaimer and containing the instruction on removing the patch as .md doc;
2.1. do a hook - overload hh task with initial warning with the doc link which can be removed once the patch is included in hh
Contributor
Author
|
@tjcloa changes lgtm |
|
Could you provide some instructions on how to apply this? I was trying to fork Harmony mainnet and received this error: An unexpected error occurred:
InvalidResponseError: Invalid JSON-RPC response's result.
Errors: Invalid value undefined supplied to : RpcBlockWithTransactions | null/totalDifficulty: QUANTITY |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable
npx hardhat node --fork(and related test patterns) with RSK. Requires a bit of patching because of RSK.The hardhat patch is automatically applied after running
npm installThere's a command (
npm run fork:rsk-mainnet) to start a local node forking from mainnet (npm run fork:rsk-testnetfor the testnet).Forking can be also used in tests. Please refer to Hardhat forking documentation https://hardhat.org/hardhat-network/guides/mainnet-forking#resetting-the-fork
IMPORTANT!! Consider before merging
testhardhat taskcheck-fork-patchto verify if the forking patch works. It will fail if there's no network connection or if the mainnet sovryn rpc node is down, which causes tests to fail.This PR doesn't have thepackage-lock.jsonoryarn.lockmodifications, because I'm not sure if we're usingnpmoryarnand which version ofnodeandnpmwe're usingpackage-lock.jsonis added too.There are some issues withShould be fixed.eth_getStorageAtreturning0x0-- a fix in progress.Technical details
Calling a forked node (
hardhat node --fork MY_RSK_NODE_RPC_URL) failed with:We use
patch-packageto patch the localhardhatinstallation, since there's no upstream patchThis patch is based on:
https://gist.github.com/0x0scion/0422f9135bc37642ba36d55b59e8b424
More reading:
NomicFoundation/hardhat#2395
https://github.com/NomicFoundation/hardhat/pull/2313/files
NomicFoundation/hardhat#2106