hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Add support to dump and reload the state of `HardhatNode`

Open dbeal-eth opened this issue 2 years ago • 15 comments

  • [x] Because this PR includes a new feature, the change was previously discussed on an Issue or with someone from the team. (Discussed with Patricio)

Adds new RPC methods to the hardhat network: hardhat_dumpState and hardhat_importState.

Properties:

  • On call to dumpState, generates an opaque data buffer with the full state of the hardhat network which can be saved to a file
  • On call to loadState, reads the data buffer created with dumpState and merges the state into the existing hardhat network, overriding if an address conflict arises.

This feature was recently shown and presented on Cannon, an EthDenver 2022 project. You can see the hacky code that this PR is inspired by. The code submitted here has been verified with Cannon downstream implementation with npm link.

This PR was discussed with Patricio before submitting this change.

Notes:

  • I had difficulty with some of the tests succeeding on my local node. Since I couldn't figure out how the failures were related to the code added by my PR, I left them be for now. Let me know what changes may be needed in order to correct the tests, if necessary.

dbeal-eth avatar Feb 26 '22 04:02 dbeal-eth

⚠️ No Changeset found

Latest commit: a77dba82d0e695e2d53c0e1e4b40b802830ace24

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Feb 26 '22 04:02 changeset-bot[bot]

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 26 '22 04:02 CLAassistant

If I'm forking off the wrong branch (ex. DefultStateManager rather than HardhatStateManager), please let me know, and I will rewrite my PR

Yes, the development branch is a bit behind, and we have actually entirely removed HardhatStateManager in the master branch. Can you please re-write your PR against master? :pray:

feuGeneA avatar Mar 11 '22 02:03 feuGeneA

If I'm forking off the wrong branch (ex. DefultStateManager rather than HardhatStateManager), please let me know, and I will rewrite my PR

Yes, the development branch is a bit behind, and we have actually entirely removed HardhatStateManager in the master branch. Can you please re-write your PR against master? pray

done!

dbeal-eth avatar Mar 11 '22 05:03 dbeal-eth

One more note: I wanted to let you know that there is a failure that you will see, when running with a defined ALCHEMY_URL, that is not the fault of this PR. It is regarding evm_increaseTime, and you can see the details at https://github.com/NomicFoundation/hardhat/pull/2480#issuecomment-1065774245 .

feuGeneA avatar Mar 12 '22 15:03 feuGeneA

Are those the failures you were talking about seeing on your local node? We'll definitely need to get those fixed.

No, they were different failures, but definitely something wrong here. Let me get that fixed.

the test failures that I was talking about earlier in my comment might have just been becuase I was on the development branch. I will try running this again and it will probably work better :pray:

dbeal-eth avatar Mar 12 '22 18:03 dbeal-eth

@feuGeneA if you could check this earlier this week that would be preferred, I will be limited availability starting next week. thanks :+1:

dbeal-eth avatar Mar 15 '22 17:03 dbeal-eth

Hey @dbeal-eth! Thanks once again for implementing this! I'll make a quick high-level review early next week and get back to you.

alcuadrado avatar Mar 18 '22 20:03 alcuadrado

@alcuadrado @feuGeneA any update on this? sorry been on vacation the last couple weeks but would love to get this finalized if you have a chance. ty

dbeal-eth avatar Mar 31 '22 23:03 dbeal-eth

This PR was marked as stale because it didn't have any activity in the last 30 days. Please excuse us if we didn't have enough time to review it and get it merged. If you are still interested in getting these changes applied, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar May 04 '22 22:05 github-actions[bot]

@alcuadrado since your team seems busy with the change to the rust hardhat network, will withhold this until its done.

dbeal-eth avatar May 04 '22 22:05 dbeal-eth

Sorry for the delay and confusion, @dbeal-eth. We really want to get this merged. @fvictorio will resume the work on this after our current sprint (in ~1 week) and give you a better estimate about when will merge it. We'll probably get back to you with questions, but will fix/implement whatever is needed.

alcuadrado avatar May 05 '22 15:05 alcuadrado

This PR was marked as stale because it didn't have any activity in the last 30 days. Please excuse us if we didn't have enough time to review it and get it merged. If you are still interested in getting these changes applied, please leave a comment indicating so. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Jun 05 '22 19:06 github-actions[bot]

Not stale.

fvictorio avatar Jun 07 '22 20:06 fvictorio

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
hardhat ✅ Ready (Inspect) Visit Preview Jun 20, 2022 at 7:26PM (UTC)
hardhat-storybook ✅ Ready (Inspect) Visit Preview Jun 20, 2022 at 7:26PM (UTC)

vercel[bot] avatar Jun 20 '22 19:06 vercel[bot]

Hey @dbeal-eth, I'm going to close this PR in favor of https://github.com/NomicFoundation/hardhat/issues/3599, which describes what we need to do and explains why we can't do it right now.

I feel super bad about having had this PR open for a year and then closing it like this :disappointed: We'll try to make this feature a top priority after rethnet is ready.

fvictorio avatar Jan 20 '23 10:01 fvictorio

hi @fvictorio thanks for your attention and concern on this issue. Happy to see this is still being tracked and planned soon.

Please let me know if you need any other information or support in developing this! The new issue appears to explain everything very well though so should be good :+1:

dbeal-eth avatar Jan 21 '23 00:01 dbeal-eth