-
Notifications
You must be signed in to change notification settings - Fork 36
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
Checking harhat version by requiring @nomicfoundation/ethereumjs-vm
package leads to errors
#61
Comments
I just tried reproducing this but it works on 2.18 as well as 2.19, on a fresh hardhat project created using
Unfortunately adding a dependency to this project would not work since this plugin intends to use an internal dependency used by hardhat. If hardhat installs the |
I'm indeed using node.js but the project is a monorepo leveraging on yarn workspaces with yarn 3. Unfortunately, the project is not public...
makes sense |
With yarn v3, I also face this issue with
And if After a bunch of playing around with yarn v3/v4, I've found that you can add to your nodeLinker: node-modules This switches the modules stuff to old node-modules style which also get rids of the errors. But this also might prevent some benefits introduced in yarn v3. |
switching back to node-modules is unfortunately not possible for me... I will try to investigate deeper to find a solution |
Sure, if you find any patch that allows this plugin to work with yarn v3/v4, happy to add it here / merge your PR! |
Same issue here. I wanted to use this project where I also use The @oumar-fall is this the case for you too? |
This should work for 2.14 (as it's 2.11 and above). Are you using something like yarn v3 instead of legacy node_modules? That does not allow this plugin to get access to the VM in order to get the trace data. You can still use v1.2.1 which instead uses debug_tt rpc instead of direct VM access. Or if your repo is public I can try having a look at the problem. |
A workaround is to set because the error is:
|
The v1 of this plugin was slow due to debug_tt overheads. In the current v2 of this plugin I had to use a non-standard apis from hardhat, basically hijack the JS VM that hardhat is using. Unfortunately I cannot add it as a dependency because it does not allow me to do some hacks. But I am taking help from hardhat team to officially expose the apis that are required for this plugin to work and if it works out well, it will solve this problem. |
Thanks for the reply! I understand the hacks you are doing. But I don't get what is blocking when adding ethereumjs-vm as a dependency? Is it a typing error? |
As patch versions are released for VM package, users might have a situation where hardhat-tracer uses a VM which is not exactly equal to the one hardhat uses, then hacky hooks added to the It would work if hardhat simply expose VM it's using, but it's risky on their side as it's very internal thing to be exposed this way. Discussing a more high-level api. Also typing error is usually not a problem because thankfully typescript is happy even if you have two different package versions with compatible interface on deep level (unlike rust which creates a scene and you have to either do or die). |
To be clear we are not suggesting to replace the check with a dependency reference ^^ We'd simply like ethereumjs-vm to be referenced as a dependency, in addition to the require check If this suggestion is implemented, I don't get this part:
How would the hacky hooks work more if the ethereumjs-vm is not referenced as a dependency than if it was? I believe the code behaves the same whether a version is referenced as dependency or not |
When single
This way, hardhat-tracer when it requires If the suggestion is implemented, it is possible that versions differ and that would cause the following (if user is upgrading hardhat and there's a new patch version available for VM):
Since VM object of v7.0.3 is updated by hardhat-tracer, it would not effect the VM v7.0.4 (for example) used by hardhat. Also note that after adding a dependency, the require check would pass 100% of the time, because a Does this make sense? |
Right, thanks for taking time to explain this, I learned something! For now, let's consider this solution enough then! |
Just released |
I can't manage to run [email protected] with [email protected]: |
Oh sorry, it will work with 2.23 (unreleased), this is a mistake from my side for releasing early, they actually have a pre-release of that minor version at I also need to add a check ensuring hardhat version should be >2.22. Will release a fix once hardhat dev branch is released. Will update here once done. |
Just released |
hardhat
version: 2.18.0hardhat-tracer
version: 2.7.0Problem
No matter the version of HardHat, I keep having the following error:
What I understand
I understand that this is comming from this part of the code:
Since the package is not defined in
hardhat-tracer
's dependencies, I kinda expect ts to throw the following error:Your application tried to access @nomicfoundation/ethereumjs-vm, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound
Which leads to the error
Potential solution
Adding the package as a dependency might be a solution
The text was updated successfully, but these errors were encountered: