EstimateGas support the latest hardhat #329
Merged
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.
Proposed changes
This PR fixes the issue #326, make xdc blockchain supports the latest hardhat.
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅
in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅
in the boxes that applyChecklist
Put an
✅
in the boxes once you have confirmed below actions (or provide reasons on not doing so) thatThe problem
The issue #326 and the post reported that hardhat failed to deploy upgradeable contract to xdc blockchain. Below is the error message:
I found the user is using @openzeppelin/hardhat-upgrades v2 and ethers v6. The problem was gone after downgrade to @openzeppelin/hardhat-upgrades v1 and ethers v5, so the user closed this issue. There are same issues in hardhat's repository:
Further research
The error
too many arguments, want at most 1
is reported by the functionparsePositionalArguments
in file rpc/json.go:I debugged the input parameter
rawArgs
in my development environment, found is error is triggered by an extra field "pending" inrawArgs
array:rawArgs
has a field "pending":rawArgs
has no field "pending":It is that xdc blockchain can't handle the extra field "pending".
More tests
From the output of hardhat, it's
estimateGas
trigger the error. The following tests showed that the method eth_estimateGas does not support "pending", but the method eth_call support "pending".1. test eth_estimateGas with field "pending"
request:
respond with error:
2. test eth_estimateGas without field "pending"
request:
works fine:
3. test eth_call with field "pending"
request:
works fine:
How to test this PR
1. prepare the environment
Use nodejs v16 and yarn v1.
2. Test @openzeppelin/hardhat-upgrades v2 and ethers v6
Clean environment:
git checkout main rm -rf node_modules deploy/dev.json yarn yarn clean && yarn compile
Deploy an upgradeable contract
TestTokenV1
:Upgrade contract
TestTokenV1
toTestTokenV2
:Test method eth_estimateGas:
The all outputs are normal.
3. Test @openzeppelin/hardhat-upgrades v1 and ethers v5
Clean environment:
git checkout ethers-v5 rm -rf node_modules deploy/dev.json yarn yarn clean && yarn compile
Deploy an upgradeable contract
TestTokenV1
:Upgrade contract
TestTokenV1
toTestTokenV2
:Test method eth_estimateGas:
The all outputs are normal.