hardhat
hardhat copied to clipboard
Add flag to ignore unknown EIP-2718 types when forking
Note to reader: a temporary solution is shared at the bottom of this issue
Certain EVM blockchain (e.g. Arbitrum Nitro) have non-standard EIP-2718 typed transaction that would prevent hardhat fork from working due to Error HH604: Error running JSON-RPC server: Unknown transaction type 106
While it is rarely a good idea to use hardhat fork with these blockchain due to chain specific behavior and precompiles as discussed in https://github.com/NomicFoundation/hardhat/issues/1902, some devs found it helpful to test non-chain specific logic with existing states using hardhat fork. To workaround the Unknown transaction type error, I am proposing to add an optional --fork-ignore-unknown-tx-type flag to skip those transactions.
You can reproduce the error with
hardhat node --fork https://goerli-rollup.arbitrum.io/rpc
- Arbitrum Nitro specific EIP-2718 types https://github.com/OffchainLabs/go-ethereum/blob/141b0fcdf0e4d8e9e5de3f0466533b86563f2d29/core/types/transaction.go#L48-L54
ArbitrumDepositTxType = 100
ArbitrumUnsignedTxType = 101
ArbitrumContractTxType = 102
ArbitrumRetryTxType = 104
ArbitrumSubmitRetryableTxType = 105
ArbitrumInternalTxType = 106
ArbitrumLegacyTxType = 120
Here is a draft implementation: https://github.com/gzeoneth/hardhat/tree/2.10.2-gzeon
$ git clone --branch 2.10.2-gzeon https://github.com/gzeoneth/hardhat.git
$ cd hardhat
$ yarn install
$ yarn build
$ touch hardhat.config.js
$ yarn hardhat node --fork https://rinkeby.arbitrum.io/rpc --fork-ignore-unknown-tx-type true
Also published on npm and can be installed with yarn alias
$ yarn add -D hardhat@npm:@gzeoneth/[email protected]
$ yarn hardhat node --fork https://rinkeby.arbitrum.io/rpc --fork-ignore-unknown-tx-type true
27/8/2022: I have upload a patch file here if you don't want to install my package, this is also compatible with a few more hardhat version e.g. 2.9.9, 2.10.2 https://gist.github.com/gzeoneth/99ac30932bf07f91661d7bc621ba1f50
You can install it using patch-package, just follow the step there and put hardhat+2.10.2.patch into the patches folder and run yarn install again. Please note that I did not update the source mapping in this patch file to improve compatibility but it might cause some issue debugging.
10/9/2022:
Fixed a few bug with 2.10.2-gzeon-e972f1dda, updated link above
This issue is also being tracked on Linear.
We use Linear to manage our development process, but we keep the conversations on Github.
LINEAR-ID: 63ce06f8-76ab-40ec-8fdc-3fda8f581808
Hey @feuGeneA any opinion on this? Can I move on to create a PR if this approach is ok?
Hi @gzeoneth . Thank you for the thoughtful and complete submission. I've just solicited more input from the team. We'll follow up soon.
Would really like to be able to fork chains like arbitrum with the introduction of arbitrum nitro.
This issue has been added to our internal backlog. I can't say when we'll be able to prioritize it. But I can say that the more interest is shown here, the more likely we are to work on it sooner rather than later :)
Hey, i assumed it was supported to fork arbitrum rinkeby for testing... I am surprised it does not work :( (i based my entire work on this working)
Hey, i assumed it was supported to fork arbitrum rinkeby for testing... I am surprised it does not work :( (i based my entire work on this working)
just fyi you can use this as a workaround for now
$ yarn add -D hardhat@npm:@gzeoneth/[email protected]
$ yarn hardhat node --fork https://rinkeby.arbitrum.io/rpc --fork-ignore-unknown-tx-type true
Yes I also need this. I am trying to test on a fork of Wanchain and am having the same issue. Thanks!
looks great. works with hardhat_reset.
await hre.network.provider.request({
method: 'hardhat_reset',
params: [
{
forking: {
jsonRpcUrl: rpc,
enabled: true,
ignoreUnknownTxType: true,
},
},
],
})
I have upload a patch file here if you don't want to install my package, this is also compatible with a few more hardhat version e.g. 2.9.9, 2.10.2 https://gist.github.com/gzeoneth/195cb16f00eaa32fa868e6c0192616c1 see op for more detail
This is absolutely needed, Arbitrum is starting to be one of the most active networks after Ethereum Mainnet. Thanks @gzeoneth for providing an interim solution, will give it a try!
Definitely a needed change.
I am still getting the error:
Error HH604: Error running JSON-RPC server: Unknown transaction type 106, set --fork-ignore-unknown-tx-type true to ignore
after applying the patch.
I ran yarn hardhat node --fork https://rinkeby.arbitrum.io/rpc --fork-ignore-unknown-tx-type true
Patch works for me. Any update on this making it into an official release?
This issue has been added to our internal backlog. I can't say when we'll be able to prioritize it. But I can say that the more interest is shown here, the more likely we are to work on it sooner rather than later :)
more interest is shown
My infura and quicknodes Arbitrum mainnet RPC's stopped forking on Friday with this issue. I'm going to try the patch now, just showing interest @0xyqrz. Thanks everyone.
Hey, i assumed it was supported to fork arbitrum rinkeby for testing... I am surprised it does not work :( (i based my entire work on this working)
just fyi you can use this as a workaround for now
$ yarn add -D hardhat@npm:@gzeoneth/[email protected] $ yarn hardhat node --fork https://rinkeby.arbitrum.io/rpc --fork-ignore-unknown-tx-type true
How can this be used with hardhat tests?
Hey, i assumed it was supported to fork arbitrum rinkeby for testing... I am surprised it does not work :( (i based my entire work on this working)
just fyi you can use this as a workaround for now
$ yarn add -D hardhat@npm:@gzeoneth/[email protected] $ yarn hardhat node --fork https://rinkeby.arbitrum.io/rpc --fork-ignore-unknown-tx-type trueHow can this be used with hardhat tests?
see the first post you can use my patched hardhat or apply the patch file
@feuGeneA :+1: interest. thanks!
The patch is not working for me when using hardhat_reset like this
await network.provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: config.networks.hardhat.forking.url,
blockNumber,
ignoreUnknownTxType: true,
},
},
],
});
Before applying the patch
InternalError: Unknown transaction type 106
After applying the patch + adding ignoreUnknownTxType: true to hardhat_reset
InternalError: Unknown transaction type 106, set --fork-ignore-unknown-tx-type true to ignore
Using hardhat 2.10.1
await network.provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: "https://rinkeby.arbitrum.io/rpc",
blockNumber: 15216420,
ignoreUnknownTxType: true,
},
},
],
});
working fine with me, do you have a sample script?
await network.provider.request({ method: "hardhat_reset", params: [ { forking: { jsonRpcUrl: "https://rinkeby.arbitrum.io/rpc", blockNumber: 15216420, ignoreUnknownTxType: true, }, }, ], });
where exactly are we supposed to add this aforementioned file if trying to run hardhat tests?
Since the Arbitrum nitro upgrade I have installed the patch, as well as followed the steps laid out above but keep getting an InternalError: Unknown transaction type 106, set --fork-ignore-unknown-tx-type true to ignore error.
await network.provider.request({ method: "hardhat_reset", params: [ { forking: { jsonRpcUrl: "https://rinkeby.arbitrum.io/rpc", blockNumber: 15216420, ignoreUnknownTxType: true, }, }, ], });where exactly are we supposed to add this aforementioned file if trying to run hardhat tests?
Since the Arbitrum nitro upgrade I have installed the patch, as well as followed the steps laid out above but keep getting an
InternalError: Unknown transaction type 106, set --fork-ignore-unknown-tx-type true to ignoreerror.
I have no idea why it is not working, you can try this alternative patch where it always ignore unknown tx type.
await network.provider.request({ method: "hardhat_reset", params: [ { forking: { jsonRpcUrl: "https://rinkeby.arbitrum.io/rpc", blockNumber: 15216420, ignoreUnknownTxType: true, }, }, ], });
but which file are we adding the above stipulation to?
await network.provider.request({ method: "hardhat_reset", params: [ { forking: { jsonRpcUrl: "https://rinkeby.arbitrum.io/rpc", blockNumber: 15216420, ignoreUnknownTxType: true, }, }, ], });but which file are we adding the above stipulation to?
Fixed a few bug with 2.10.2-gzeon-e972f1dda, you can use this patch file https://gist.github.com/gzeoneth/99ac30932bf07f91661d7bc621ba1f50
In hardhat.confg.ts you need something like
networks: {
hardhat: {
forking: {
url: "https://rinkeby.arbitrum.io/rpc",
ignoreUnknownTxType: true
}
}
},
Then it should work when using the hardhat network.
Thank you so much this latest patch finally works.
await network.provider.request({ method: "hardhat_reset", params: [ { forking: { jsonRpcUrl: "https://rinkeby.arbitrum.io/rpc", blockNumber: 15216420, ignoreUnknownTxType: true, }, }, ], });where exactly are we supposed to add this aforementioned file if trying to run hardhat tests? Since the Arbitrum nitro upgrade I have installed the patch, as well as followed the steps laid out above but keep getting an
InternalError: Unknown transaction type 106, set --fork-ignore-unknown-tx-type true to ignoreerror.I have no idea why it is not working, you can try this alternative patch where it always ignore unknown tx type.
Could you share your Hardhat config file? I've installed this alternative patch in your latest reply, which helped me bypass the same InternalError: Unknown transaction type 106 as Abbie is experiencing above. This patch has successfully ignored the unknown type 106 error, but now we're getting Error HH604: Error running JSON-RPC server: Invalid URL and I'm assuming it's a configuration issue. We're currently using the following URL for Hardhat forking: https://rinkeby.arbitrum.io/rpc
await network.provider.request({
method: "hardhat_reset",params: [{forking: {jsonRpcUrl: "https://rinkeby.arbitrum.io/rpc",blockNumber: 15216420,ignoreUnknownTxType: true,},},],});
where exactly are we supposed to add this aforementioned file if trying to run hardhat tests?
Since the Arbitrum nitro upgrade I have installed the patch, as well as followed the steps laid out above but keep getting an
InternalError: Unknown transaction type 106, set --fork-ignore-unknown-tx-type true to ignoreerror.I have no idea why it is not working, you can try this alternative patch where it always ignore unknown tx type.
Could you share your Hardhat config file? I've installed this alternative patch in your latest reply, which helped me bypass the same
InternalError: Unknown transaction type 106as Abbie is experiencing above. This patch has successfully ignored the unknown type 106 error, but now we're gettingError HH604: Error running JSON-RPC server: Invalid URLand I'm assuming it's a configuration issue. We're currently using the following URL for Hardhat forking: https://rinkeby.arbitrum.io/rpc
See my previous reply.
https://gist.github.com/penandlim/790cebc4ddf204410654624aacb2efb4
I tried to forked the patch posted by @gzeoneth and update it for hardhat 2.11.1 code Seemed to work for me.
https://gist.github.com/penandlim/179a1f4a325c2815fa7f6837240439a5 Updated for 2.11.2
https://gist.github.com/penandlim/790cebc4ddf204410654624aacb2efb4
I tried to forked the patch posted by @gzeoneth and update it for hardhat 2.11.1 code
Seemed to work for me.
Nice, ya there was a breaking change in 2.11.1
https://gist.github.com/penandlim/790cebc4ddf204410654624aacb2efb4 I tried to forked the patch posted by @gzeoneth and update it for hardhat 2.11.1 code Seemed to work for me.
Nice, ya there was a breaking change in 2.11.1
how can i use this?