Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
62a9e32
add enums
zhongeric Oct 7, 2025
d5ab029
Add Fuzz helper contracts
zhongeric Oct 8, 2025
375e6de
fixing compilation issues
mgretzke Oct 9, 2025
821b298
Default FuzzGenerator path
mgretzke Oct 9, 2025
5ef3623
combinatorial integration start
mgretzke Oct 16, 2025
387e386
fixed rebase issues
mgretzke Oct 16, 2025
342cf64
improve bid verification (wip)
mgretzke Oct 17, 2025
a2b5e9e
add enums
zhongeric Oct 7, 2025
697733c
Add Fuzz helper contracts
zhongeric Oct 8, 2025
64805d9
fixing compilation issues
mgretzke Oct 9, 2025
1aa4f9f
Default FuzzGenerator path
mgretzke Oct 9, 2025
eefb0cd
cleanup
mgretzke Oct 17, 2025
22aef8e
clearingPrice helperFunctions
mgretzke Oct 17, 2025
0c20ae4
multiple bids to reach clearingPrice
mgretzke Oct 17, 2025
ed9f1f3
finished postBidScenario helper and tests
mgretzke Oct 20, 2025
c4a4e27
finished preBidScenario helper and tests
mgretzke Oct 20, 2025
6def2bf
implementing helpers
mgretzke Oct 20, 2025
6f1e6e5
Redesign combinatorial framework
mgretzke Oct 20, 2025
1f7ae88
Fixes, caps and logs
mgretzke Oct 21, 2025
c7ee8b0
fixes
mgretzke Oct 21, 2025
8e90d97
auction state verification
mgretzke Oct 23, 2025
4650fae
Implementing test reporting
mgretzke Oct 24, 2025
f86bc97
enhanced reporting
mgretzke Oct 27, 2025
fb1b422
increase possible ranges
mgretzke Oct 29, 2025
b1c4430
WIP - increase fill ratio variety
mgretzke Oct 29, 2025
525b5d4
increased fill ratio variety and improved reporting
mgretzke Oct 30, 2025
5c8535c
verify claimTokens function
mgretzke Oct 31, 2025
11cf517
add enums
zhongeric Oct 7, 2025
b0b1f4c
Add Fuzz helper contracts
zhongeric Oct 8, 2025
f0790b3
fixing compilation issues
mgretzke Oct 9, 2025
45e7b9e
Default FuzzGenerator path
mgretzke Oct 9, 2025
439a409
combinatorial integration start
mgretzke Oct 16, 2025
f88a676
fixed rebase issues
mgretzke Oct 16, 2025
61b6ace
improve bid verification (wip)
mgretzke Oct 17, 2025
3609d5b
add enums
zhongeric Oct 7, 2025
3357007
Add Fuzz helper contracts
zhongeric Oct 8, 2025
ea12dea
fixing compilation issues
mgretzke Oct 9, 2025
fdb48ba
Default FuzzGenerator path
mgretzke Oct 9, 2025
8cbeafb
cleanup
mgretzke Oct 17, 2025
53d1914
clearingPrice helperFunctions
mgretzke Oct 17, 2025
f2b9085
multiple bids to reach clearingPrice
mgretzke Oct 17, 2025
a5dd24e
finished postBidScenario helper and tests
mgretzke Oct 20, 2025
cd9707c
finished preBidScenario helper and tests
mgretzke Oct 20, 2025
85a5813
implementing helpers
mgretzke Oct 20, 2025
bf0fd27
Redesign combinatorial framework
mgretzke Oct 20, 2025
92361ad
Fixes, caps and logs
mgretzke Oct 21, 2025
348e67f
fixes
mgretzke Oct 21, 2025
c52b879
auction state verification
mgretzke Oct 23, 2025
9cf53c9
Implementing test reporting
mgretzke Oct 24, 2025
291facf
enhanced reporting
mgretzke Oct 27, 2025
81bfe4c
increase possible ranges
mgretzke Oct 29, 2025
95fe099
WIP - increase fill ratio variety
mgretzke Oct 29, 2025
ee67097
increased fill ratio variety and improved reporting
mgretzke Oct 30, 2025
b5496df
verify claimTokens function
mgretzke Oct 31, 2025
e100b9b
fixed stack too deep
mgretzke Nov 5, 2025
6dde3cd
rebase fixes and removed assumes
mgretzke Nov 6, 2025
132179f
Merge branch 'fuzz-generators-setup' of https://github.com/Uniswap/tw…
mgretzke Nov 6, 2025
f02d519
fixes
mgretzke Nov 6, 2025
b823f7b
Merge branch 'main' into fuzz-generators-setup
zhongeric Jan 26, 2026
3dc6e8a
fix: merge conflicts
zhongeric Jan 26, 2026
24f1e6e
chore: fix max price calculation
zhongeric Jan 26, 2026
85474cf
Merge branch 'main' into fuzz-generators-setup
zhongeric Jan 27, 2026
bbaeca6
chore: cleanup
zhongeric Jan 27, 2026
818a3b4
chore: clean up
zhongeric Jan 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ lcov.info
broadcast/*/31337
deployments/**/31337.*
visualizations/auction_simple.py
coverage_data.csv

broadcast/
161 changes: 161 additions & 0 deletions COVERAGE_TRACKING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Combinatorial Test Coverage Tracking

## Overview

This system tracks which test scenarios are covered during combinatorial fuzz testing. It collects detailed metrics about auction outcomes, bid behavior, and scenario distributions to help identify coverage gaps and understand test patterns.

## Quick Start

### 1. Run Tests and Collect Coverage Data

```bash
# Delete old coverage data (optional, starts fresh)
rm -f coverage_data.csv

# Run tests with desired number of fuzz runs
forge test --match-test testFuzz_CombinatorialExploration --fuzz-runs 100
```

### 2. Analyze Coverage

```bash
# View report in terminal
python3 analyze_csv_coverage.py coverage_data.csv

# Save report to file
python3 analyze_csv_coverage.py coverage_data.csv > report.txt
```

## CSV Data Format

The coverage data CSV contains **22 columns** capturing comprehensive test metrics:

### Core Columns (1-4)
1. **preBidScenario** - Pre-bid scenario enum (0-3)
2. **postBidScenario** - Post-bid scenario enum (0-4)
3. **bidAmount** - Bid amount in wei
4. **maxPrice** - Maximum price in Q96 format

### Fill Ratio Metrics (5-6)
5. **fillRatioMPS** - Fill ratio using MPS precision (0-10,000,000 where 10,000,000 = 100%)
6. **partialFillReason** - "full", "non_graduated", "partial_graduated", or "partial_outbid"

### Timing Metrics (7-9)
7. **bidLifetimeBlocks** - Blocks from bid start to exit
8. **blocksFromStart** - Blocks from auction start to bid submission
9. **timeToOutbid** - Blocks until bid was outbid (0 if never outbid)

### Status Flags (10-12)
10. **wasOutbid** - Boolean: bid was outbid by another bid
11. **neverFullyFilled** - Boolean: fill ratio < 100%
12. **nearGraduationBoundary** - Boolean: within last 10% of auction duration

### Price Analysis (13-14)
13. **clearingPriceStart** - Clearing price when bid started
14. **clearingPriceEnd** - Clearing price at auction end

### Token Outcomes (15-16)
15. **tokensReceived** - Tokens received in wei
16. **pricePerTokenETH** - Price paid per token in ETH (wei)

### Graduation Tracking (17)
17. **didGraduate** - Boolean: auction graduated

### Auction Context (18-22)
18. **auctionStartBlock** - Block number when auction started
19. **auctionDurationBlocks** - Total auction duration
20. **floorPrice** - Auction floor price in Q96 format
21. **tickSpacing** - Tick spacing in Q96 format
22. **totalSupply** - Token total supply in wei

## Test Scenarios

### Pre-Bid Scenarios (4 types)
- `NoBidsBeforeUser` (0): No other bids exist before user's bid
- `BidsBeforeUser` (1): Other bids exist before user's bid
- `ClearingPriceBelowMaxPrice` (2): Clearing price is below the max price before bidding
- `BidsAtClearingPrice` (3): Bids exist exactly at the clearing price

### Post-Bid Scenarios (5 types)
- `NoBidsAfterUser` (0): No bids placed after user's bid
- `UserAboveClearing` (1): User's bid remains above clearing price
- `UserAtClearing` (2): User's bid is at the clearing price
- `UserOutbidLater` (3): User gets outbid after some time
- `UserOutbidImmediately` (4): User gets outbid immediately

**Total Possible Combinations**: 4 × 5 = 20

## Accumulating Coverage Data

The system automatically **appends** new test data to the CSV file. This allows building coverage over multiple sessions:

```bash
# Run 1
forge test --match-test testFuzz_CombinatorialExploration --fuzz-runs 50
# CSV now has data from run 1

# Run 2 (appends to existing data)
forge test --match-test testFuzz_CombinatorialExploration --fuzz-runs 50
# CSV now has combined data from both runs

# Analyze combined coverage
python3 analyze_csv_coverage.py coverage_data.csv
```

To start fresh, delete the CSV file before running: `rm -f coverage_data.csv`

## Report Organization

The analysis script generates a comprehensive report organized as follows:

1. **Auction-Level Metrics** - Context, graduation rates, token outcomes
2. **Bid-Level Metrics** - Fill ratios, timing, bid patterns
3. **Parameter Statistics** - Bid amounts and max prices
4. **Scenario Analysis** - Coverage tables, distributions, heatmaps, gaps

## Important Notes

### Fill Ratio Precision
- Fill ratios use **MPS (Milli-Per-Second) precision**: 1e7 = 10,000,000 = 100%
- Example: 5,000,000 MPS = 50.00000%
- Provides 5 decimal place precision for accurate partial fill tracking

### Data Accumulation
- CSV file APPENDS data across test runs
- Delete `coverage_data.csv` to start fresh
- Large fuzz run counts generate large CSV files

### Compilation
- The combinatorial test file uses `via_ir` compilation to handle stack depth
- Other test files use `via_ir = false` for faster compilation
- See `foundry.toml` for compilation_restrictions details

### File Write Permissions
- `foundry.toml` is configured with file write permissions for `./`
- This allows the test to write `coverage_data.csv` to the project root

## Files

- `test/combinatorial/Auction.submitBid.combinatorial.t.sol` - Main test file with coverage collection
- `test/combinatorial/CombinatorialHelpers.sol` - Helper functions for scenario setup
- `coverage_data.csv` - Generated CSV file with test data (gitignored)
- `analyze_csv_coverage.py` - Python analysis script
- `report.txt` - Generated coverage report (optional)
- `foundry.toml` - Forge configuration with file write permissions

## Interpreting Results

### Good Coverage Indicators
- All or most of the 20 scenario combinations are covered
- Reasonable distribution across scenarios (not heavily skewed)
- Wide range of bid amounts and prices tested
- Diverse fill ratio distribution (not clustering at 0% or 100%)

### Coverage Gaps
If certain combinations are missing:
- Some scenarios might be mutually exclusive (expected)
- Increase fuzz runs to hit rare combinations
- Adjust helper functions if combinations should be possible but aren't generated

### Understanding Missing Combinations
Some scenario combinations may be impossible due to the auction mechanics. For example, if the clearing price is already below the user's max price before bidding, the user's bid will typically be above clearing after submission, making certain post-bid scenarios unlikely or impossible.
Loading
Loading