ethereum / eth-tester

Tool suite for testing ethereum applications.
MIT License
367 stars 151 forks source link

Snapshot state to a genesis file #130

Open carver opened 6 years ago

carver commented 6 years ago

What was wrong?

Inspired by https://github.com/ethereum/eth-tester/issues/88#issuecomment-387666145

People want to pick up chain state from somewhere they left off in a test chain. It would be cool to use this to set up integration tests for non-eth-tester nodes too!

How can it be fixed?

It would be sweet to have an easy way to snapshot state into a genesis file (which can then be reimported using #129).

I think a good API is: genesis_dict = tester.genesis_snapshot(). First step is consensus on that.

pipermerriam commented 6 years ago

I suspect we should also be able to use an extended version of EIP1085 for this, with something like an additional blocks key.

evertonfraga commented 5 years ago

With the risk of being too late in the game, I ask: how should contract accounts' state be represented in a "non zero-block" snapshot?

carver commented 5 years ago

I've been defaulting to this (unmerged) proposal for genesis file format: https://github.com/ethereum/EIPs/issues/1085

So you would list the storage slots. in each contract account.

Probably the most work for implementing this is that we do not currently track preimages (of slots or account addresses). So we can't just iterate the database to create the state, we have to add a preimage tracker, I think. Maybe this belongs as a custom AccountDB and StorageDB, but I'm not sure without diving in to design it.