evmts/tevm-monorepo

State dumps / State loading

roninjin10 opened this issue · 1 comments

Description

An important blocking feature to important pieces of Tevm such as optimistic updates and data persistence require a state dump / state loading feature. Anvil has this feature via --dump-state and --load-state.

Spec

To start just implement the most basic functionality. User should be able to write to load state or read from dump state via an action. This state is shaped the same as foundry state

Later we will update this to be more granular about which state we want to load and dump.

const vm = createTevm()

import state from './same/shape/as/foundry/and/others.json'

await vm.loadState({state})
// vm should now have the state as specified by the json file loaded into the `viemStateManager` or `defaultstateManager

const state = vm.dumpState()

fs.writeFile('state', state)

Tasks

  • Implement TevmState type which should be the same shape as the foundry state json
  • Implement dumpState action in vm/src/actions/dumpState
  • Implement loadState action in vm/src/actions/loadState
  • Implement JSON rpc versions of these methods in `vm/src/json
  • Update client via rebasing change on top of this pr

CHA-109