Skip to content

feat: support saving Anvil state diffs based from account access dict #8424

Open
@sambacha

Description

@sambacha

Feature: Support saving State Diff File

Note

Originally this issue was created for "supporting saving Anvil dump state file as a checksum/hash & RPC Method for checking state change"

Upon a state change occurring from a configured account (meaning state mutation resulting from an account we defined to use for anvil rather than a built-in address such as the CREATE2 deployer addresses) or alt accepting some account access dict, anvil will write to disk a state-diff file using a hash as the filename (filename as hash or incremented sortable naming convention).

Anvil

Watching for state change using hash of state dump

When setting up Anvil we typically use this setup

MNEMONIC='test test test test test test test test test test test junk'
CHAIN_ID=31337
anvil --port 8545 --chain-id "${CHAIN_ID}" --state-interval 1 --dump-state anvil-state.json --config-out accounts --mnemonic "${MNEMONIC}" & \
while ! nc -z 127.0.0.1 8545; do echo "Waiting for Anvil Fork $CHAIN_ID to be available"; sleep 1; done && \
echo "Anvil state setup..." && \
# Create a hash of the anvil dump state to check
ANVIL_STATE_HASH=$(sha256sum anvil-state.json | cut -d ' ' -f 1) && \
echo "$ANVIL_STATE_HASH" > errata_logs.txt && \
forge script ./script/Setup.s.sol --account env_setup \
--password '' --sender 0x23CCa589Db0956cb6350d0Bd17A65f96A86eC3e6 \
--rpc-url local-8545 --sig "run_anvil()" --broadcast && \
echo "Pending Enviornment Setup and Deployments..." && \
# Check for state change
while [ "$(sha256sum anvil-state.json | cut -d ' ' -f 1)" = "$ANVIL_STATE_HASH" ]; do sleep 1; done

Having an anvil_checkState RPC method to query that would return ANVIL_STATE_HASH=$(sha256sum anvil-state.json | cut -d ' ' -f 1) would make orchestrating CI Matrix testing easier.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions