foundry-rs / foundry-rs/foundry

Feature request: chaos-anvil

Open
#3,788 4 comments 2 reactions 0 assignees View on GitHub
C-anvil T-feature
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
16h 38m
Merged PRs (30d)
511

Description

### Component

Anvil

### Describe the feature you would like

## Description

Add chaos modes to `anvil` to better simulate real network conditions.

## Motivation

RPC issues are common causes of bugs in foundry, script execution, and off-chain actors. Because mainnet nodes are consistently less reliable than testnet nodes and simulation nodes, it is difficult to test resilience to RPC issues in an application before production deployment

To support stress testing libs, applications, etc, we should add chaos features to anvil, to simulate faulty or weird behavior of mainnet RPC nodes

## Details

A `--chaos` flag for anvil that takes the following instructions each of which enables a specific feature:

- `tx` - `getTransaction` may not fail return a known transaction
- `send` - txns broadcast do not always confirm immediately. They may confirm after a delay (which should not block RPC), or not at all.
- `getLog` - events are sometimes randomly deleted from `eth_getLogs` request responses
- `streamLog` - events are sometimes randomly dropped from log streams

Example invocation
```anvil --chaos tx,send,getLog```

Bonus points if we can configure frequency at which each of these events occur :)

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating Anvil's CLI option handling and RPC implementations for transactions and logs. The issue names no files or tests, so first determine how Anvil exposes these behaviors and how chaos modes and event frequencies should be configured; done means the requested failure modes can be enabled through the documented --chaos invocation and are covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
blockchain, cli, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.