From c1ec23a9fc4b18ed604cc4842ae841364aed5e6c Mon Sep 17 00:00:00 2001 From: zerosnacks Date: Thu, 9 Jan 2025 16:45:58 +0100 Subject: [PATCH] add anvil overview --- src/anvil/README.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/anvil/README.md b/src/anvil/README.md index 5e088b05e..08ac7561b 100644 --- a/src/anvil/README.md +++ b/src/anvil/README.md @@ -86,7 +86,45 @@ Listening on 127.0.0.1:8545 ### Features -TODO: add comprehensive list of features +#### Configuration + +Anvil is highly configurable, allowing you to: + +- **Mining Modes**: Choose automatic mining (default), interval mining (`--block-time `), or on-demand mining (`--no-mining`). +- **Accounts and Balances**: Set the number of accounts (`--accounts`) and their Ether balance (`--balance`). +- **Genesis Initialization**: Start with a custom genesis file (`--init `), defining parameters like `chainId`, `gasLimit`, and preallocated accounts. +- **EVM Hardforks**: Simulate specific Ethereum hardforks (e.g., `shanghai`, `paris`) using `--hardfork`. +- **Transport Layers**: Supports HTTP and WebSocket connections on port 8545 (customizable via `--port`). +- **Chain State**: Save/load states with `--state`, `--dump-state`, or `--load-state` for persistence. + +#### Forking + +Anvil can fork live Ethereum or EVM-compatible networks: + +- **State Replication**: Use `--fork-url` to replicate a network’s state at a specific block (`--fork-block-number`) or transaction (`--fork-transaction-hash`). +- **Offline Testing**: Combine `--fork-chain-id` with cached state for offline scenarios. +- **Caching and Rate Limits**: Disable caching with `--no-storage-caching` or manage RPC requests using `--compute-units-per-second` or `--no-rate-limit`. + +#### State Management + +Flexible state management options include: + +- **Snapshots**: Save and reload chain states with `--state`, `--dump-state`, and `--load-state`. + - `--state` is an alias for both `--load-state` and `--dump-state`, it initializes the chain with the state and block environment stored at the file, if it exists, and dumps the chain's state on exit. +- **Historical States**: Preserve or prune states with `--preserve-historical-states` or `--prune-history`. Set the number of persisted states using `--max-persisted-states`. +- **Intervals**: Control state dump intervals with `--state-interval`. + +#### RPC Methods + +Supports standard Ethereum RPC methods (`eth_getBlockByNumber`, `eth_sendTransaction`, etc.), Anvil-specific methods (`anvil_impersonateAccount`, `anvil_setBalance`, etc.), and tracing/debugging (`debug_traceTransaction`, `evm_snapshot`, etc.). + +#### Default CREATE2 Deployer + +Includes a CREATE2 deployer proxy (`0x4e59b44847b379578588920ca78fbf26c0b4956c`), allowing CREATE2 testing without forking. + +#### Genesis Configuration + +Customize network initialization using a `genesis.json` file to set `chainId`, `gasLimit`, preallocated accounts, and other parameters.