Manage state with checkpoints (snapshot and revert)
masterpyrevm supports state management through checkpoints. You can take a snapshot() of the current state and later revert(checkpoint) to that state. Alternatively, you can use commit() to clear all existing checkpoints.
Note: Unlike the Rust implementation, the Python library does not automatically commit to the database.
from pyrevm import EVM
evm = EVM()
checkpoint = evm.snapshot()
evm.message_call(
caller=...,
to=...,
value=...,
)
evm.revert(checkpoint) # or: evm.commit() to clear all checkpoints