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: support saving Anvil state diffs based from account access dict #8424

Open
sambacha opened this issue Jul 12, 2024 · 0 comments
Open
Labels
C-anvil Command: anvil T-feature Type: feature

Comments

@sambacha
Copy link
Contributor

sambacha commented Jul 12, 2024

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

@sambacha sambacha added the T-feature Type: feature label Jul 12, 2024
@sambacha sambacha changed the title feat: support saving Anvil dump state file as a checksum/hash & RPC Method for checking state change feat: support saving Anvil state diffs based from account access dict Jul 12, 2024
@zerosnacks zerosnacks added the C-anvil Command: anvil label Jul 12, 2024
@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@jenpaff jenpaff removed this from the v1.0.0 milestone Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil T-feature Type: feature
Projects
None yet
Development

No branches or pull requests

3 participants