fix: Backtesting: replay red-team attack sequences against optimizer candidates (#536)
- Add AttackRunner.s.sol: structured forge script that reads attack ops from a JSONL file (ATTACK_FILE env), executes them against the local Anvil deployment, and emits full state snapshots (tick, positions, VWAP, optimizer output, adversary balances) as JSON lines after every recenter and at start/end. - Add 5 canonical attack files in onchain/script/backtesting/attacks/: * il-crystallization-15.jsonl — 15 buy-recenter cycles + sell (extraction) * il-crystallization-80.jsonl — 80 buy-recenter cycles + sell (extraction) * fee-drain-oscillation.jsonl — buy-recenter-sell-recenter oscillation * round-trip-safe.jsonl — 20 full round-trips (regression: safe) * staking-safe.jsonl — staking manipulation (regression: safe) - Add scripts/harb-evaluator/export-attacks.py: parses red-team-stream.jsonl for tool_use Bash blocks containing cast send commands and converts them to AttackRunner-compatible JSONL (buy/sell/recenter/stake/unstake/mint_lp/burn_lp). - Update scripts/harb-evaluator/red-team.sh: after each agent run, automatically exports the attack sequence via export-attacks.py and replays it with AttackRunner to capture structured snapshots in tmp/red-team-snapshots.jsonl. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
08b9a3df30
commit
c8453f6a33
8 changed files with 1261 additions and 2 deletions
14
onchain/script/backtesting/attacks/staking-safe.jsonl
Normal file
14
onchain/script/backtesting/attacks/staking-safe.jsonl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{"op":"buy","amount":"50000000000000000000","token":"WETH"}
|
||||
{"op":"recenter"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":0}
|
||||
{"op":"recenter"}
|
||||
{"op":"buy","amount":"50000000000000000000","token":"WETH"}
|
||||
{"op":"recenter"}
|
||||
{"op":"stake","amount":"1000000000000000000000","taxRateIndex":5}
|
||||
{"op":"recenter"}
|
||||
{"op":"buy","amount":"50000000000000000000","token":"WETH"}
|
||||
{"op":"recenter"}
|
||||
{"op":"unstake","positionId":1}
|
||||
{"op":"recenter"}
|
||||
{"op":"sell","amount":"all","token":"KRK"}
|
||||
{"op":"recenter"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue