Skip to content

Commit 601e84e

Browse files
author
Your Name
committed
Expand formal coverage and resilience brief
1 parent cd65805 commit 601e84e

7 files changed

Lines changed: 83 additions & 9 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<a href="docs/INVESTOR_ONE_PAGER.md">Investor One-Pager</a> •
3636
<a href="docs/ASSURANCE.md">Assurance Packet</a> •
3737
<a href="docs/FORMAL_VERIFICATION.md">Formal Verification</a> •
38+
<a href="docs/RESILIENCE_BRIEF.md">Resilience Brief</a> •
3839
<a href="docs/CHAOS_ENGINEERING.md">Chaos Engineering</a> •
3940
<a href="docs/PANCAKECALL_AUDIT.md">Callback Audit</a> •
4041
<a href="docs/RELEASE_NOTES.md">Release Notes</a> •
@@ -336,7 +337,7 @@ python scripts/backtest.py --days 90 --tvl 100000 --cycles-per-day 4 --gas-gwei
336337

337338
Latest local validation: `54/54` tests passing.
338339

339-
Formal verification: `9/9` symbolic properties passing via `python scripts/run_formal.py`.
340+
Formal verification: `10/10` symbolic properties passing via `python scripts/run_formal.py`.
340341

341342
Invariant tests:
342343

docs/ASSURANCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Faster investor diligence
4343
| Economic framing | formulas and caveats are explicit | `ECONOMICS.md` |
4444
| Regression tests | main contract behavior stays intact | `forge test` |
4545
| Invariants | key capital-safety properties hold across randomized sequences | `test/Invariant.t.sol` |
46-
| Formal verification | nine core internal properties hold under symbolic execution | `test/FormalEngineVault.t.sol` |
46+
| Formal verification | ten core internal properties hold under symbolic execution | `test/FormalEngineVault.t.sol` |
4747
| Adversarial tests | bad dependencies end in safe revert or safe degradation | `test/AssuranceAdversarial.t.sol` |
4848
| Static analysis | flash callback and external-call hotspots stay visible | `docs/SLITHER_NOTES.md` |
4949
| Manual audit focus | remaining callback hotspot has a written human review | `docs/PANCAKECALL_AUDIT.md` |

docs/FORMAL_VERIFICATION.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This repo now includes an actual symbolic-proof layer using `halmos`, not just conventional tests.
66

7-
Current local result: `9/9` symbolic properties passing via `python scripts/run_formal.py`.
7+
Current local result: `10/10` symbolic properties passing via `python scripts/run_formal.py`.
88

99
The goal is not to claim that the entire strategy and all external markets are mathematically proven.
1010

@@ -23,7 +23,8 @@ Formal targets
2323
├─ ONLY_UNWIND blocks fresh exposure
2424
├─ ONLY_UNWIND recovers after two safe cycles
2525
├─ flash borrowed base caps at zero when underwater
26-
└─ deposits pause when risk mode is `ONLY_UNWIND`
26+
├─ deposits pause when risk mode is `ONLY_UNWIND`
27+
└─ zero borrowed-base context preserves totalAssets
2728
```
2829

2930
These properties are implemented in `test/FormalEngineVault.t.sol` and run by `scripts/run_formal.py`.

docs/INVESTOR_ONE_PAGER.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ It is presented as a strategy system with a growing assurance stack:
4747

4848
- `54/54` contract tests passing locally.
4949
- `5/5` invariant checks passing.
50-
- `9/9` symbolic formal properties passing via Halmos.
50+
- `10/10` symbolic formal properties passing via Halmos.
5151
- adversarial tests covering dependency and unwind edge cases.
5252
- Slither reduced to `1` remaining finding family focused on flash-callback event ordering.
5353

docs/RELEASE_NOTES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Self-Driving Yield Engine now ships with a stronger investor-proof story: a dedi
1616
## Highlights
1717

1818
- Added an investor-facing `docs/ASSURANCE.md` that links research, tests, static analysis, and fork checks into one proof index.
19-
- Added an actual Halmos-based formal layer proving nine core internal properties.
19+
- Added an actual Halmos-based formal layer proving ten core internal properties.
2020
- Expanded machine-checked invariants around asset conservation, flash-borrow cleanup, and no-profit/no-bounty behavior.
2121
- Added adversarial tests for `ONLY_UNWIND`, blocked hedge closes, and ALP cooldown-constrained unwinds.
2222
- Added minimal GitHub Actions CI for `forge build/test`, invariant runs, research script checks, scenario backtests, and Slither.
@@ -42,7 +42,7 @@ This release makes the project easier to diligence:
4242

4343
- `forge test``54/54 PASS`
4444
- `forge test --match-path test/Invariant.t.sol``5/5 PASS`
45-
- `python scripts/run_formal.py``9/9 PASS`
45+
- `python scripts/run_formal.py``10/10 PASS`
4646
- `python -m py_compile scripts/backtest.py``PASS`
4747
- `python scripts/backtest.py --days 90 --tvl 100000 --cycles-per-day 4 --gas-gwei 50 --compare-scenarios --json-out cache/backtest-report.json``PASS`
4848
- `slither . --exclude-dependencies --exclude incorrect-equality,timestamp,low-level-calls,naming-convention,cyclomatic-complexity``1 finding triaged`
@@ -86,7 +86,7 @@ This release makes the project easier to diligence:
8686
#### 2. Safety Coverage
8787

8888
- Invariants now cover asset conservation, flash state cleanup, and zero bounty without profit.
89-
- Formal verification now covers nine symbolic properties around accounting, share math, price-guard behavior, `ONLY_UNWIND`, deposit pausing, and no-profit bounty behavior.
89+
- Formal verification now covers ten symbolic properties around accounting, share math, price-guard behavior, `ONLY_UNWIND`, deposit pausing, no-profit bounty behavior, and zero-borrow flash accounting consistency.
9090
- Added a dedicated manual review note for the remaining flash-callback hotspot in `docs/PANCAKECALL_AUDIT.md`.
9191
- Adversarial tests now prove safer behavior under dependency stress.
9292

@@ -105,7 +105,7 @@ This release makes the project easier to diligence:
105105

106106
- Solidity regression: `forge test``54/54 PASS`
107107
- Invariants: `forge test --match-path test/Invariant.t.sol``5/5 PASS`
108-
- Formal verification: `python scripts/run_formal.py``9/9 PASS`
108+
- Formal verification: `python scripts/run_formal.py``10/10 PASS`
109109
- Research script: `python -m py_compile scripts/backtest.py``PASS`
110110
- Scenario research run: `python scripts/backtest.py --days 90 --tvl 100000 --cycles-per-day 4 --gas-gwei 50 --compare-scenarios --json-out cache/backtest-report.json``PASS`
111111
- Static analysis: Slither run completed and triaged; only `pancakeCall()` event-order warnings remain

docs/RESILIENCE_BRIEF.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Operational Resilience Brief
2+
3+
## Main Point
4+
5+
Self-Driving Yield Engine now has a clearer resilience story than a typical hackathon repo.
6+
7+
It is no longer just “contracts + tests”.
8+
9+
It is now:
10+
11+
- CI-gated,
12+
- partially formally verified,
13+
- static-analysis triaged,
14+
- manually reviewed at the main callback hotspot,
15+
- and backed by nightly DeFi-adapted chaos experiments.
16+
17+
18+
## Current Evidence Stack
19+
20+
```text
21+
Operational resilience
22+
├─ main CI green
23+
├─ nightly chaos green
24+
├─ formal 10/10
25+
├─ invariants 5/5
26+
├─ regression 54/54
27+
├─ one known Slither finding
28+
└─ callback manual review written down
29+
```
30+
31+
32+
## What This Means For Investors
33+
34+
- The system is not being presented as “perfect” or “finished forever”.
35+
- The main remaining hotspot is visible and documented.
36+
- The validation stack now tests both correctness and failure behavior.
37+
38+
39+
## Current Status
40+
41+
- Regression tests: `54/54`
42+
- Invariants: `5/5`
43+
- Formal properties: `10/10`
44+
- Slither: `1` known triaged finding
45+
- Main callback review: `docs/PANCAKECALL_AUDIT.md`
46+
- Nightly chaos workflow: `.github/workflows/nightly-chaos.yml`
47+
48+
49+
## Failure Modes We Now Exercise
50+
51+
- oracle divergence
52+
- `ONLY_UNWIND` entry and recovery
53+
- blocked hedge close
54+
- ALP cooldown unwind limits
55+
- gas spike / bounded bounty
56+
- flash liquidity shortfall
57+
- degraded RPC timeout behavior
58+
59+
60+
## Remaining Honest Boundary
61+
62+
- This is still not a claim that the full strategy and external markets are mathematically proven.
63+
- It is a claim that the repo now has a credible resilience process around the highest-risk internal and dependency-driven behaviors.

test/FormalEngineVault.t.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,13 @@ contract EngineVaultFormalTest is Test {
311311

312312
assert(vault.totalAssetsExcludingBorrowedBase(borrowed) == 0);
313313
}
314+
315+
function check_totalAssetsExcludingZeroBorrowMatchesTotalAssets(uint16 baseBalance) public {
316+
_assumeReasonableAmount(baseBalance);
317+
318+
(EngineVaultFormalHarness vault,, MockERC20 base) = _deployFlashAccountingVault();
319+
base.mint(address(vault), baseBalance);
320+
321+
assert(vault.totalAssetsExcludingBorrowedBase(0) == vault.totalAssets());
322+
}
314323
}

0 commit comments

Comments
 (0)