Skip to content

WIP: maxStore example + stdlib slot helpers#1

Merged
Th0rgal merged 2 commits intomainfrom
wip/edsl-maxstore-stdlib
Feb 9, 2026
Merged

WIP: maxStore example + stdlib slot helpers#1
Th0rgal merged 2 commits intomainfrom
wip/edsl-maxstore-stdlib

Conversation

@Th0rgal
Copy link
Member

@Th0rgal Th0rgal commented Feb 9, 2026

Summary

  • split the example contracts into focused files and add a small maxStore example
  • add stdlib helpers for variable-based slot access (sloadVar/sstoreVar)
  • wire the new example into the compiler + main dispatcher and add a Foundry test

Testing

  • PATH=/opt/lean-4.27.0/bin:$PATH lake build
  • forge test

Note

Medium Risk
Touches contract entrypoint dispatch/selector wiring and adds new CI execution paths, so failures would surface at build/test time but could break generated artifacts if selectors or asm mismatch.

Overview
Adds a small EDSL “stdlib” (DumbContracts/Stdlib.lean) with wrappers like require/unless and slot/var helpers, then refactors the large Examples.lean monolith into focused modules under DumbContracts/Examples/.

Introduces a new maxStore example end-to-end: new entrypoint in Compiler.lean (and exampleEntries/healthEntries wiring), updated hand-written dispatcher in EvmAsm.lean, plus a new generated-contract Foundry test GeneratedMaxStore.t.sol.

CI is extended to run legacy Foundry tests via a new foundry-legacy job and adds the forge-std git submodule/lockfile needed by legacy/foundry, alongside doc/status updates.

Written by Cursor Bugbot for commit 0974d96. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dumbcontracts Error Error Feb 9, 2026 10:18pm

Request Review

@Th0rgal Th0rgal marked this pull request as ready for review February 9, 2026 22:19
@Th0rgal Th0rgal merged commit fd0aeee into main Feb 9, 2026
3 of 10 checks passed
Th0rgal pushed a commit that referenced this pull request Feb 10, 2026
**Critical Bugbot Fixes:**

1. **HIGH SEVERITY - SafeCounter overflow protection restored**
   - Added `Expr.gt` and `Expr.le` operators to ContractSpec DSL
   - Implemented overflow check in SafeCounter.increment: `require (count + 1 > count)`
   - On overflow (MAX_UINT + 1 = 0), check fails: 0 is NOT > MAX_UINT
   - Generated Yul now includes: `if iszero(gt(add(sload(0), 1), sload(0))) { revert(0, 0) }`
   - Matches original manual Yul and EDSL safeAdd semantics
   - All 80 Foundry tests passing including overflow protection tests

2. **MEDIUM SEVERITY - Zip function safety**
   - Added compile-time validation in Compiler/Specs.lean
   - 7 #guard statements ensure selector count matches function count
   - Build fails immediately if mismatch occurs
   - Prevents silent function dropping at compile time

3. **LOW SEVERITY - Dead code removal**
   - Deleted Compiler/Parser.lean (141 lines, never imported)
   - Was placeholder for future AST parsing, never used

**CI Fixes:**

4. **Fix hardcoded path in differential tests**
   - Removed `/workspaces/mission-482e3014/dumbcontracts` path (local-only)
   - Changed to relative path: `export PATH="$HOME/.elan/bin:$PATH" && lake exe ...`
   - Works in both local dev and GitHub Actions CI
   - Commented out random-gen call (not needed, using inline PRNG)

**Test Results:**
```
All 80 Foundry tests passing:
- 76 original tests ✓
- 4 differential tests ✓ (including 100 random transactions)
- SafeCounter overflow protection ✓
- All contracts compile ✓
- All 252 Lean proofs verify ✓
```

**Files Changed:**
- Compiler/ContractSpec.lean: Added gt/le operators, updated codegen
- Compiler/Specs.lean: Added overflow check to SafeCounter, compile-time validation
- Compiler/Parser.lean: Deleted (unused)
- compiler/yul/SafeCounter.yul: Regenerated with overflow check
- test/DifferentialSimpleStorage.t.sol: Fixed CI path issues

**Bugbot Review Thread Responses:**

Issue #1 (SafeCounter overflow): Fixed - overflow check restored with new gt operator
Issue #2 (Parser dead code): Fixed - file deleted
Issue #3 (Zip silent truncation): Fixed - compile-time guards added

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Th0rgal pushed a commit that referenced this pull request Feb 14, 2026
Critical finding: Layer 3 statement proofs are blocked by fundamental
architectural issue that must be resolved first.

Problem:
- execIRStmt is marked 'partial' (unprovable in Lean)
- execYulStmtFuel uses fuel parameter (provable)
- Cannot prove equivalence between partial and total functions
- All theorem stubs in StatementEquivalence.lean need 'sorry'

Solution:
- Add execIRStmtFuel: fuel-parametric version of execIRStmt
- Mirror structure of execYulStmtFuel
- Update execIRStmtsFuel to use it
- Prove adequacy: fuel version equals partial version
- Update theorem stubs to use fuel versions

Impact:
- BLOCKS all 8 statement proofs until resolved
- Estimated 1 week of work to implement
- Once complete, statement proofs become straightforward

Updates to roadmap:
- Added item #0: "Add execIRStmtFuel" as prerequisite
- Marked as blocker for items #1-8
- Added detailed explanation section
- Updated effort estimates (3-5 weeks total, up from 2-4)
- Updated status count (0/10 instead of 0/9)

This explains why StatementEquivalence.lean has all 'sorry' statements
- the proof infrastructure wasn't complete yet!

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant