Skip to content
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

Support WaffleJS testing #46

Closed
2 of 14 tasks
arianejasuwienas opened this issue Jul 18, 2024 · 5 comments
Closed
2 of 14 tasks

Support WaffleJS testing #46

arianejasuwienas opened this issue Jul 18, 2024 · 5 comments
Assignees
Labels
design Feature design, pilot or prototyping exploration work or documentation test Improve tests or tests quality

Comments

@arianejasuwienas
Copy link
Contributor

arianejasuwienas commented Jul 18, 2024

Problem

To create a custom Fixture Service, we need the ability to snapshot and revert the blockchain state. This feature is essential for efficient testing and development workflows using tools like the fixtures system of the WaffleJs library.

Solution

Implement snapshotting (evm_snapshot) and reverting (evm_revert) functionalities on the Hedera network. These functionalities should be integrated into separate Fixtures Service, utilising the alternative of the Hedera JSON RPC Relay to allow interaction through standard JSON RPC calls but also being able to create snapshot and revert the state of the machine.

Alternatives

No response

Research

Project management

Implement the evm_snapshot endpoint in the Fixtures Service utilising the Hedera JSON RPC Relay.

Implement the evm_snapshot endpoint in the Fixtures Service utilising the Hedera JSON RPC Relay

Sample usage example, tests

@arianejasuwienas arianejasuwienas self-assigned this Jul 18, 2024
@arianejasuwienas arianejasuwienas changed the title Enable Snapshotting and Reverting Feature on the Network Draft: Enable Snapshotting and Reverting Feature on the Network Jul 18, 2024
@acuarica acuarica transferred this issue from hashgraph/hedera-json-rpc-relay Sep 12, 2024
@acuarica acuarica changed the title Draft: Enable Snapshotting and Reverting Feature on the Network Enable Snapshotting and Reverting Feature on the Network Sep 12, 2024
@acuarica acuarica changed the title Enable Snapshotting and Reverting Feature on the Network Support WaffleJS testing Sep 12, 2024
@acuarica
Copy link
Contributor

acuarica commented Sep 12, 2024

Both evm_snapshot and evm_revert are implemented by the Ethereum Development Environment to support forking. See for example foundry-rs/foundry#1162. Instead of implementing these into Hedera Network, we provide HTS emulation as part of our current solution.

However, we need to ensure that WaffleJS library works as expected with our forking support. Create a WaffleJS minimal project that uses fixtures/forking similar to the tests we currently have. Put this under test-e2e/waffle folder. We have similar examples showcasing the Waffle on the Relay here

@arianejasuwienas
Copy link
Contributor Author

Something like that?

hashgraph/hedera-json-rpc-relay#3016 (comment)

@acuarica
Copy link
Contributor

Exactly.

@arianejasuwienas arianejasuwienas linked a pull request Sep 20, 2024 that will close this issue
2 tasks
@arianejasuwienas arianejasuwienas added the New Feature A new feature, service, or documentation. Major changes that are not backwards compatible. label Sep 20, 2024
@arianejasuwienas arianejasuwienas linked a pull request Oct 9, 2024 that will close this issue
2 tasks
@arianejasuwienas
Copy link
Contributor Author

Ganache is not capable of creating the necessary fork for our use case, as it fails to download the HTS Smart Contract code at runtime from the forked network JSON RPC API. Given that we are already focusing on Hardhat for our development, and the addition of Waffle doesn't provide any significant benefit, I've closed the PR.

More details:

  1. before processing eth_call ganache tries to deduct the accounts taking part in the simulation:

https://github.com/trufflesuite/ganache/blob/develop/packages/ethereum/ethereum/src/helpers/run-call.ts#L115

  1. and fetches the code for each of them:

https://github.com/trufflesuite/ganache/blob/547c900a50d19b094ef636a9aeccf4f7f2356430/packages/ethereum/ethereum/src/forking/trie.ts#L198

  1. Then starts an EVM simulation on the prepared data. Unfortunately as soon as the EVM is called it no longer tries to fetch any additional data for calls to different smart contracts (as it happens in hardhat); it fails instead....

Let me know if we should close this issue too @acuarica .

@acuarica
Copy link
Contributor

Thanks for the detailed information @arianejasuwienas. Yes, I'll close this.

@acuarica acuarica closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
@github-project-automation github-project-automation bot moved this from Epics In Progress to Done in Smart Contract Sprint Board Oct 15, 2024
@acuarica acuarica added test Improve tests or tests quality design Feature design, pilot or prototyping exploration work or documentation and removed New Feature A new feature, service, or documentation. Major changes that are not backwards compatible. labels Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Feature design, pilot or prototyping exploration work or documentation test Improve tests or tests quality
Projects
Status: Done
2 participants