iron-fish / ironfish

A novel cryptocurrency focused on privacy and accessibility.
https://ironfish.network
Mozilla Public License 2.0
964 stars 579 forks source link

wip: adds IronfishEvm methods to simulate tx execution #5109

Open hughy opened 2 days ago

hughy commented 2 days ago

Summary

adds 'withStatelessVM', inspired by withTransaction, to use a shallow copy of the underlying vm for execution

using challowCopy creates a vm instance with empty caches over the committed database state. use of shallowCopy follows the example of gas estimation https://github.com/ethereumjs/ethereumjs-monorepo/blob/cc2848a1f3fc0ebb8c04cf6e9f76b0992e506c2c/packages/client/src/rpc/modules/eth.ts#L535

wraps handler execution with checkpoint/revert logic over the evm journal to ensure that cached state is not committed to the database

updates EvmStateDB to return itself in shallowCopy so that it does not create a duplicate datastore

Testing Plan

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API Reference)? If yes, link a related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and label it with breaking-change-rpc or breaking-change-sdk.

[ ] Yes