feat: shared economy scenario for block builder contention testing#477
Open
vbuilder69420 wants to merge 5 commits intoflashbots:mainfrom
Open
feat: shared economy scenario for block builder contention testing#477vbuilder69420 wants to merge 5 commits intoflashbots:mainfrom
vbuilder69420 wants to merge 5 commits intoflashbots:mainfrom
Conversation
Add scenario TOML files covering a broad range of EVM gas patterns and real-world DeFi/infrastructure interactions: - erc721: NFT mint and transfer - erc1155: multi-token mint, transfer, and batch transfer - erc4626vault: vault deposit/withdraw with share accounting - governance: proposal creation and voting - lending: collateral deposit, borrow, and repay - simpleAMM: constant-product swaps with 0.3% fee - stablecoin: ETH-backed mint/burn/flash mint - nameRegistry: ENS-like name registration and renewal - multisig: multi-sig submit/confirm/execute - staking: stake/unstake/claim/compound rewards - precompiles/hashPrecompiles: SHA256, RIPEMD160, Identity stress - bridge: L1→L2 deposit simulation (ETH + ERC20) - dutchAuction: time-based pricing with ETH refunds - orderBook: on-chain limit orders with partial fills Also adds campaigns/full-spectrum.toml: a 4-stage campaign (warmup → DeFi ramp → full load → cooldown) that mixes all new scenarios for comprehensive chain stress testing. All contracts are self-contained Solidity 0.8.26, compiled with solc --optimize --optimize-runs 200. Each scenario includes deploy, setup (liquidity/approvals/funding), and fuzzed spam. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Research-driven wave 2: analyzed top gas consumers, block composition, and novel EVM patterns on Ethereum mainnet to identify the highest- impact scenarios missing from contender. New scenarios: - erc4337: Account Abstraction EntryPoint with two-loop validate→execute pattern, deposit accounting, UserOp helper - flashLoan: ERC-3156 flash loan with 5-level deep arbitrage callback (lender→borrower→poolA→poolB→repay) - bondingCurve: Pump.fun-style token launchpad with linear bonding curve math + CREATE2 factory deployment as spam - merkleAirdrop: keccak256-heavy proof verification with packed claimed bitmap (256 claims per storage slot) - create2Factory: ERC-1167 minimal proxy clones via CREATE2 (contract creation as the hot path, not function calls) - multicall3: Batched heterogeneous calls (5-50 per tx), testing memory expansion and loop overhead - weth: WETH9 wrap/unwrap — one of highest-volume mainnet contracts, covers payable+msg.value+ERC20 mint pattern - stableSwap: Curve-style StableSwap AMM with Newton's method iteration (up to 255 rounds per swap) — fundamentally different gas profile from constant-product AMMs - mevSandwich: MEV sandwich bundles using [[spam.bundle.tx]] with frontrun→victim→backrun atomic ordering - diamondProxy: EIP-2535 Diamond with delegatecall dispatch routing through CounterFacet, TokenFacet, StorageFacet All contracts self-contained Solidity 0.8.26, compiled with solc --optimize --optimize-runs 200. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…esting Adds sharedEconomy.toml — a single scenario that deploys an interconnected DeFi economy where 6 actor pools contend on the same contracts, creating realistic block builder ordering problems. Shared infrastructure: - EconToken (x2: TokenA, TokenB) - EconAMM (constant product, shared reserves) - EconOracle (price feed triggering cascades) - EconLending (collateral/borrow with oracle-based liquidations) - EconSearcher (MEV bot with block.coinbase tips) Actor pools competing on shared state: - traders: swap on AMM (low priority) - borrowers: deposit/borrow/repay on lending (low priority) - lps: add/remove AMM liquidity (medium priority) - oracle_nodes: push price updates (triggers downstream contention) - liquidators: race to liquidate underwater positions (high priority) - searchers: atomic oracle→arb bundles with validator tips (highest priority) Contention points: - AMM reserves (traders + arbers + LPs write same slots) - Lending positions (borrowers + liquidators) - Token balances (all 6 pools) - Oracle price (oracle→liquidator→AMM cascade) This tests what block builders actually struggle with: ordering transactions that compete for the same state while maximizing priority fee revenue. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix EconAMM and EconLending bytecodes (recompiled from source) - Use mint() instead of transfer() for funding lending pool and searcher (avoids balance dependency on admin's concurrent mint step) - Remove borrowers_initial_borrow from setup (lending pool funding runs concurrently and may not be confirmed in time) - Add gas_limit to all spam patterns to allow reverts without crashing Tested: setup + spam at 10 TPS against local anvil — all 6 contract deploys succeed, 29 setup steps complete, all 10 spam patterns fire. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tested all 24 new scenarios against local anvil (setup + spam).
Fixes applied:
Bytecode fixes:
- orderBook: fixed SimpleOrderBook bytecode (4 extra bytes)
- erc4337: fixed all 4 contract bytecodes (metadata hash diffs)
TOML structure fixes:
- multisig: replaced {max_tx_id} placeholder in fuzz params with "99"
- hashPrecompiles: moved from_pool into [spam.tx] sub-table
- bridge: added missing constructor signature for BridgeToken
bytes32 encoding fixes (contender fuzz generates odd-length hex):
- nameRegistry: changed bytes32 to uint256 in spam signature, removed fuzz
- create2Factory: changed bytes32 to uint256 in spam signatures, decimal fuzz
- bondingCurve: changed bytes32 to uint256, decimal fuzz ranges
- bridge: changed bytes32 to uint256 for processDeposit spam
Missing gas_limit fixes (reverts without gas_limit crash contender):
- erc721: added gas_limit to nft_transfer
- lending: added gas_limit to deposit_collateral
- stablecoin: added gas_limit to mint, transfer, flash_mint_burn
- staking: added gas_limit to stake
- stableSwap: added gas_limit to all 3 swap/liquidity patterns
- mevSandwich: added gas_limit to standalone victim_swap
Setup fixes:
- bondingCurve: reduced setup ETH values, removed token_5 (concurrent revert)
Result: 23/24 pass (flashLoan times out on slow anvil but works structurally)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A single mega-scenario that deploys an interconnected DeFi economy where 6 actor pools contend on the same contracts, creating realistic block builder ordering problems.
This is fundamentally different from existing scenarios — instead of isolated protocols, all actors compete for the same storage slots with different priority levels, forcing the block builder to resolve contention while maximizing tip revenue.
Architecture
6 Actor Pools (competing on shared state)
tradersborrowerslpsoracle_nodesliquidatorssearchersblock.coinbasetipsWhy this matters for block builders
block.coinbasemore, but contend with trader swaps on the same AMMSpecs
Test plan
[[spam.bundle.tx]]correctly🤖 Generated with Claude Code