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

feat: add anvil_dumpState/anvil_loadState #476

Merged
merged 5 commits into from
Dec 6, 2024
Merged

Conversation

itegulov
Copy link
Contributor

@itegulov itegulov commented Dec 6, 2024

What 💻

Closes #418

Ditto. Required making TransactionResult serializable so unfortunately touches some seemingly unrelated VM stuff. Had to drop some non-serializable VM structs from state which honestly simplified logic a little bit.

Why ✋

Anvil feature parity

@itegulov itegulov requested a review from a team as a code owner December 6, 2024 07:22
e2e-tests-rust/src/provider/testing.rs Outdated Show resolved Hide resolved
src/node/error.rs Show resolved Hide resolved
src/fork.rs Show resolved Hide resolved
/// # Returns
/// Buffer representing the chain state.
#[rpc(name = "anvil_dumpState")]
fn dump_state(&self, preserve_historical_states: Option<bool>) -> RpcResult<Bytes>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it interact with forked networks? I assume that load_state will not work on forked network because the state is not empty (or will it?), but if that's the case should we support dump_state at all?

Copy link
Contributor Author

@itegulov itegulov Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will work assuming you are using the same fork for both instances. This is actually a pretty important use case as this feature will be used for CLI options to automatically dump/load state to a local file in intervals of time (see anvil's --dump-state/--load-state/--state/--state-interval) and we shouldn't prohibit using forks with it.

That being said I did not design any fail-safe mechanism for using a different fork. Writing the fork state could be an option but only the user would know if two forks are really the same (URLs can change).

@itegulov itegulov merged commit 7d0b689 into main Dec 6, 2024
13 checks passed
@itegulov itegulov deleted the daniyar/anvil/dump-state branch December 6, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: implement anvil_dumpState/anvil_loadState API endpoints
2 participants