@@ -56,20 +56,25 @@ npm run coverage:update-baseline
5656
5757** Step-by-step:**
58581 . Make your code changes
59- 2 . Run coverage locally:
59+ 2 . Ensure ` .env ` file exists with pinned fork blocks (copy from ` .env.example ` if needed):
60+ ``` bash
61+ cp .env.example .env
62+ ```
63+ ** Important:** Using the same fork blocks as ` .env.example ` ensures your local coverage matches CI coverage.
64+ 3 . Run coverage locally:
6065 ``` bash
6166 npm run coverage
6267 ```
63- 3 . Update the baseline file:
68+ 4 . Update the baseline file:
6469 ``` bash
6570 npm run coverage:update-baseline
6671 ```
67- 4 . Commit the baseline file:
72+ 5 . Commit the baseline file:
6873 ``` bash
6974 git add coverage-baseline.json
7075 git commit -m " chore: update coverage baseline"
7176 ```
72- 5 . Push your PR
77+ 6 . Push your PR
7378
7479** What CI validates:**
7580- ✅ ** Check 1:** Your committed baseline matches CI coverage (proves you ran coverage)
@@ -108,6 +113,35 @@ Current baseline (as of initial setup):
108113### Environment Setup for CI
109114The workflow copies ` .env.example ` to ` .env ` to enable fork tests with public RPC endpoints during coverage runs.
110115
116+ ### Fork Block Pinning for Deterministic Coverage
117+
118+ ** Why fork blocks are pinned:**
119+ Coverage tests fork mainnet at specific block heights. Without pinning:
120+ - Developer runs locally → forks at block X → gets 96.93% coverage
121+ - CI runs 30 mins later → forks at block Y → gets 96.82% coverage
122+ - Different blocks = different contract states = different test paths = different coverage
123+
124+ ** Solution:**
125+ Pin each chain to a specific block number in ` .env.example ` :
126+ ``` bash
127+ FORK_BLOCK_NUMBER_BASE=39550474
128+ FORK_BLOCK_NUMBER_ETHEREUM=24024515
129+ FORK_BLOCK_NUMBER_ARBITRUM_ONE=411254516
130+ # etc...
131+ ```
132+
133+ This ensures both local and CI environments fork from ** identical blockchain state** , producing ** identical coverage results** .
134+
135+ ** Updating fork blocks:**
136+ When you need to test against newer mainnet state:
137+ 1 . Run the helper script: ` node scripts/get-blocks.mjs `
138+ 2 . Copy the output to ` .env.example `
139+ 3 . Run coverage: ` npm run coverage `
140+ 4 . If tests pass, update baseline: ` npm run coverage:update-baseline `
141+ 5 . Commit both ` .env.example ` and ` coverage-baseline.json `
142+
143+ ** Note:** Each blockchain has independent block heights, so each needs its own pinned block number.
144+
111145### Branch Protection
112146To enforce coverage checks, enable branch protection on main:
1131471 . GitHub Settings → Branches → Branch protection rules
0 commit comments