Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 28 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,25 +174,37 @@ jobs:
LEAN_ABORT_ON_PANIC: '1'
run: bash test/run_tests.sh

# ---- Stage 6 (schema-only): REQ-PBT-008 against committed CSV ----
# bench/bench.sh itself is intentionally NOT run in CI: b6_erc20
# routinely takes 10+ minutes locally, which is too slow for the
# hot path. The schema enforcer is run against the committed
# bench/results.csv so any drift in the CSV header or row shape
# (REQ-TEST-032..REQ-TEST-034) blocks the merge.
- name: bench/check_csv_schema.py (REQ-PBT-008, committed CSV)
run: python3 bench/check_csv_schema.py bench/results.csv

# ---- Stage 7: SARIF 2.1.0 schema compliance (REQ-PBT-004) ----
# The pytest fixture spawns strata-verify.sh --sarif against curated
# fixtures and validates the stdout against the vendored OASIS schema.
# Skipped automatically if the binary or solc are missing (the test
# prints a Skip with a reason); this stage fails only on a real
# schema violation.
# ---- Stage 6: REQ-PBT-008 benchmark CSV ----
# Runs the benchmarks (about 5 s in total) and validates the CSV they
# write, so the schema check applies to the current binary's output,
# not only to the committed bench/results.csv.
- name: bench/bench.sh (REQ-PBT-008)
env:
LEAN_ABORT_ON_PANIC: '1'
run: bash bench/bench.sh

# ---- Stage 7: SARIF 2.1.0 schema and verdicts (REQ-PBT-004) ----
# The tests run strata-verify.sh --sarif on curated fixtures: they
# validate the output against the vendored OASIS schema and check
# that its verdicts, locations, fingerprints and counterexamples
# agree with the plain-text and --json output. A test skips itself
# when the binary or solc is missing; under CI a skipped test fails
# the run (Tools/Solidity/test/conftest.py), so this stage cannot
# pass without checking anything.
- name: pytest Tools/Solidity/test (REQ-PBT-004 SARIF schema)
env:
LEAN_ABORT_ON_PANIC: '1'
run: python3 -m pytest Tools/Solidity/test -v
run: python3 -m pytest Tools/Solidity/test -v -rs

# ---- Stage 7b: pipeline determinism (REQ-PBT-002) ----
# Two --pipeline-json runs of the same fixture must agree on the
# Laurel and Core programs, the obligations and their statuses.
- name: pipeline determinism (REQ-PBT-002)
env:
LEAN_ABORT_ON_PANIC: '1'
run: |
lake run pbt-determinism
lake run pbt-determinism test/examples/b3_token.sol

# ---- Stage 8: docs/site builds from current docs/guide/src ----
# Catches a broken template placeholder or a SUMMARY.md/file-name
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ lake build

1. Checks out StrataSolidity with `submodules: recursive` so the Strata submodule is materialized at the recorded SHA
2. Verifies the submodule layout via `scripts/check-strata.sh`
3. Installs `solc` (via the `ethereum/ethereum` PPA) and the CI-only Python deps in `Tools/Solidity/requirements-dev.txt`
4. Runs `lake build` and `lake test` via [`leanprover/lean-action`](https://github.com/leanprover/lean-action), which handles elan install and caches the root `.lake`; Strata builds into `Strata/.lake`, which separate steps restore and save, keyed on the toolchain, the manifest and the submodule commit
3. Installs `solc` (via the `ethereum/ethereum` PPA), z3, and the CI-only Python deps in `Tools/Solidity/requirements-dev.txt`
4. Runs `lake build` and `lake test` via [`leanprover/lean-action`](https://github.com/leanprover/lean-action), which handles elan install and caches the root `.lake`; Strata builds into `Strata/.lake`, which separate steps restore and save, keyed on the toolchain, the manifest and the submodule commit. `lake test` runs the tests again when the binary or a fixture under `StrataSolidityTest/Solidity/tests` changes
5. Runs `test/run_tests.sh` (golden suite + REQ-PBT-007 exit-code sub-stage)
6. Runs `python3 bench/check_csv_schema.py bench/results.csv` (REQ-PBT-008 schema enforcer against the committed CSV)
7. Runs `python3 -m pytest Tools/Solidity/test` (REQ-PBT-004 SARIF 2.1.0 schema compliance)

`bench/bench.sh` itself is intentionally not in the hot path (b6_erc20 is slow).
6. Runs `bench/bench.sh`, which validates the CSV it writes (REQ-PBT-008)
7. Runs `python3 -m pytest Tools/Solidity/test` (REQ-PBT-004 SARIF 2.1.0 schema and verdicts); a skipped test fails the run under CI
8. Runs the pipeline-determinism check twice (`lake run pbt-determinism`, REQ-PBT-002)
9. Builds the documentation site (`docs/site`)

Lean panics are errors in CI. A `panic!` prints a message and continues with
a default value, which in the verifier could mean a wrong verdict, so every
Expand Down
20 changes: 9 additions & 11 deletions StrataSolidityTest/Solidity/run_pbt_determinism.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
# JSON outputs for informational evidence; any difference there is printed as
# a warning, but only differences in the five structural fields fail the run.
#
# Note — SMT field variance. The `obligations[*].smt` field embeds the
# `strata-verify.sh` temp-directory path in a `(set-info :file …)` annotation,
# which differs per run because `strata-verify.sh` calls `mktemp -d`. This is
# an incidental artifact of the shell wrapper, not a pipeline determinism
# violation, so REQ-PBT-002 deliberately excludes `smt` and `smtResult` from
# the determinism contract (see tasks.md task 2.3 and requirements.md §13).
# Note — SMT field. REQ-PBT-002 excludes `obligations[*].smt` and `smtResult`
# from the contract (see tasks.md task 2.3 and requirements.md §13). In
# practice the raw output is byte-equal too: `--pipeline-json` writes its SMT
# files to the same fixed directory on every run, so no per-run path ends up
# in them.
#
# Usage:
# StrataSolidityTest/Solidity/run_pbt_determinism.sh [fixture.sol]
#
# If no fixture is given, defaults to
# StrataSolidityTest/Solidity/tests/test_arithmetic.sol, a compact pass-only
# fixture that minimizes noise from VC status and exercises the full
# Python → Ion → Lean → Laurel → Core → SMT pipeline (REQ-PIPE-001..005).
# fixture that minimizes noise from VC status and exercises the whole
# pipeline (solc → Lean frontend → Laurel → Core → SMT).

set -euo pipefail

Expand Down Expand Up @@ -81,9 +80,8 @@ if cmp -s "$RUN_A" "$RUN_B"; then
raw_equal=1
else
echo "[warn] raw --pipeline-json output differs across runs"
echo " (diff below; expected to be confined to obligations[*].smt"
echo " which embeds the per-run strata-verify.sh TMPDIR and is NOT"
echo " part of the REQ-PBT-002 determinism contract)"
echo " (diff below; outside the REQ-PBT-002 contract only if it is"
echo " confined to obligations[*].smt)"
diff -u "$RUN_A" "$RUN_B" || true
raw_equal=0
fi
Expand Down
28 changes: 24 additions & 4 deletions Tools/Solidity/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,28 @@

"""pytest configuration for the Tools/Solidity characterization tests.

Keeping this file empty (aside from the module docstring) is intentional: the
individual tests carry their own fixtures. Its presence lets pytest discover
this directory as a test package regardless of the invocation's working
directory.
The tests skip themselves when the `strataSolidity` binary or solc is
missing, which is convenient locally. Under CI (the `CI` environment
variable is set, as on GitHub Actions) a skipped test fails the run
instead: a CI stage whose tests all skipped would otherwise pass while
checking nothing.
"""

import os

import pytest


def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
if not os.environ.get("CI") or exitstatus != pytest.ExitCode.OK:
return
reporter = session.config.pluginmanager.get_plugin("terminalreporter")
skipped = len(reporter.stats.get("skipped", [])) if reporter else 0
if skipped:
if reporter:
reporter.write_line(
f"error: {skipped} test(s) skipped under CI; "
"build strataSolidity and put solc and z3 on PATH",
red=True,
)
session.exitstatus = pytest.ExitCode.TESTS_FAILED
12 changes: 6 additions & 6 deletions bench/results.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
benchmark,functions,specs,state_vars,mappings,status,time_ms,pass,fail,unknown,total
b1_trivial,2,1,1,0,ok,551,2,0,0,2
b2_counter,2,7,2,0,ok,311,6,0,0,6
b3_token,3,12,2,1,ok,330,9,0,0,9
b4_vault,3,10,4,1,ok,329,8,0,0,8
b5_escrow,4,14,5,0,error,197,0,0,0,0
b6_erc20,4,16,5,3,ok,899061,14,0,0,14
b1_trivial,2,1,1,0,ok,751,2,0,0,2
b2_counter,2,7,2,0,ok,615,6,0,0,6
b3_token,3,12,2,1,ok,714,12,0,0,12
b4_vault,3,10,4,1,ok,642,8,0,0,8
b5_escrow,4,14,5,0,ok,1018,9,0,0,9
b6_erc20,4,16,5,3,ok,818,11,0,0,11
16 changes: 13 additions & 3 deletions lakefile.lean
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ require Strata from "Strata"

@[default_target] lean_exe strataSolidity where root := `StrataSolidityMain

/-- The Solidity fixtures that `JsonOutputTest` runs the binary on. Lake does
not see the files a test reads while it runs; listing them here makes the
tests run again when a fixture changes, instead of replaying their cached
result. -/
input_dir solidityTestFixtures where
path := "StrataSolidityTest/Solidity/tests"
text := true
filter := .extension "sol"

lean_lib StrataSolidityTest where
globs := #[`StrataSolidityTest.+]
-- `JsonOutputTest` runs the binary: build it first, and run the tests
-- again whenever it changes (otherwise Lake replays their cached result).
needs := #[strataSolidity]
-- `JsonOutputTest` runs the binary on fixtures: build it first, and run
-- the tests again whenever the binary or a fixture changes (otherwise
-- Lake replays their cached result).
needs := #[strataSolidity, solidityTestFixtures]

/--
Group A step 2: print a structural summary of the Lean-built Solidity DDM
Expand Down
Loading