Merge pull request 'fix: fix: bundled dust cleanup — tools/push3-transpiler (#1034)' (#1127) from fix/issue-1034 into master

This commit is contained in:
johba 2026-03-22 23:04:55 +01:00
commit d1d0e8ca10
2 changed files with 22 additions and 23 deletions

View file

@ -127,12 +127,11 @@ steps:
name=$(basename "$seed") name=$(basename "$seed")
echo "--- Transpiling $name ---" echo "--- Transpiling $name ---"
if ! npx tsx tools/push3-transpiler/src/index.ts "$seed" onchain/src/OptimizerV3Push3.sol; then if ! npx tsx tools/push3-transpiler/src/index.ts "$seed" onchain/src/OptimizerV3Push3.sol; then
echo "FAIL: $name failed to transpile" >&2 echo "WARN: $name failed to transpile (invalid program) — skipping" >&2
failed=1
continue continue
fi fi
echo "--- Compiling $name ---" echo "--- Compiling $name ---"
if ! (cd onchain && forge build --silent); then if ! (cd onchain && forge build --skip test script --silent); then
echo "FAIL: $name transpiled but Solidity compilation failed" >&2 echo "FAIL: $name transpiled but Solidity compilation failed" >&2
failed=1 failed=1
fi fi

View file

@ -85,8 +85,8 @@ run_transpiler() {
fi fi
} }
# ── Test 5: anchorWidth literal > uint24 max → transpiler error ────────────── # ── Test 6: anchorWidth literal > uint24 max → transpiler error ──────────────
echo "Test 5: anchorWidth = 1e18 (literal) → transpiler error, not silent Solidity failure" echo "Test 6: anchorWidth = 1e18 (literal) → transpiler error, not silent Solidity failure"
# Push3 program: push 4 values (discoveryDepth, anchorWidth=1e18, anchorShare, ci). # Push3 program: push 4 values (discoveryDepth, anchorWidth=1e18, anchorShare, ci).
# The transpiler pops top-4 from DYADIC stack; these literals sit on top of the # The transpiler pops top-4 from DYADIC stack; these literals sit on top of the
@ -103,8 +103,8 @@ assert_contains \
"$STDERR" \ "$STDERR" \
"anchorWidth literal (1000000000000000000) is outside uint24 range [0, 16777215]" "anchorWidth literal (1000000000000000000) is outside uint24 range [0, 16777215]"
# ── Test 6: valid anchorWidth literal (in range) → accepted, wraps with % (2**24) ─ # ── Test 7: valid anchorWidth literal (in range) → accepted, wraps with % (2**24) ─
echo "Test 6: anchorWidth = 100 (valid literal) → accepted, output uses % (2**24)" echo "Test 7: anchorWidth = 100 (valid literal) → accepted, output uses % (2**24)"
INPUT_6="$TMPDIR_T/valid_aw.push3" INPUT_6="$TMPDIR_T/valid_aw.push3"
OUTPUT_6="$TMPDIR_T/valid_aw.sol" OUTPUT_6="$TMPDIR_T/valid_aw.sol"
@ -125,8 +125,8 @@ assert_contains \
"$SOL_6" \ "$SOL_6" \
"uint24(100 % (2**24))" "uint24(100 % (2**24))"
# ── Test 7: negative ci literal → transpiler error ─────────────────────────── # ── Test 8: negative ci literal → transpiler error ───────────────────────────
echo "Test 7: ci = -1 (negative literal) → transpiler error" echo "Test 8: ci = -1 (negative literal) → transpiler error"
STDERR=$(run_transpiler "( STDERR=$(run_transpiler "(
300000000000000000 300000000000000000
@ -140,8 +140,8 @@ assert_contains \
"$STDERR" \ "$STDERR" \
"ci is a negative literal (-1)" "ci is a negative literal (-1)"
# ── Test 8: negative anchorShare literal → transpiler error ────────────────── # ── Test 9: negative anchorShare literal → transpiler error ──────────────────
echo "Test 8: anchorShare = -5 (negative literal) → transpiler error" echo "Test 9: anchorShare = -5 (negative literal) → transpiler error"
STDERR=$(run_transpiler "( STDERR=$(run_transpiler "(
300000000000000000 300000000000000000
@ -155,8 +155,8 @@ assert_contains \
"$STDERR" \ "$STDERR" \
"anchorShare is a negative literal (-5)" "anchorShare is a negative literal (-5)"
# ── Test 9: negative discoveryDepth literal → transpiler error ─────────────── # ── Test 10: negative discoveryDepth literal → transpiler error ───────────────
echo "Test 9: discoveryDepth = -99 (negative literal) → transpiler error" echo "Test 10: discoveryDepth = -99 (negative literal) → transpiler error"
STDERR=$(run_transpiler "( STDERR=$(run_transpiler "(
-99 -99
@ -170,8 +170,8 @@ assert_contains \
"$STDERR" \ "$STDERR" \
"discoveryDepth is a negative literal (-99)" "discoveryDepth is a negative literal (-99)"
# ── Test 10: negative anchorWidth literal → transpiler error ───────────────── # ── Test 11: negative anchorWidth literal → transpiler error ─────────────────
echo "Test 10: anchorWidth = -1 (negative literal) → transpiler error" echo "Test 11: anchorWidth = -1 (negative literal) → transpiler error"
STDERR=$(run_transpiler "( STDERR=$(run_transpiler "(
300000000000000000 300000000000000000
@ -185,8 +185,8 @@ assert_contains \
"$STDERR" \ "$STDERR" \
"anchorWidth literal (-1) is outside uint24 range [0, 16777215]" "anchorWidth literal (-1) is outside uint24 range [0, 16777215]"
# ── Test 11: forge build — transpiler output compiles (regression for #900) ── # ── Test 12: forge build — transpiler output compiles (regression for #900) ──
echo "Test 11: forge build on valid transpiler output (regression for #900)" echo "Test 12: forge build on valid transpiler output (regression for #900)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
FORGE_BIN="$(command -v forge 2>/dev/null || true)" FORGE_BIN="$(command -v forge 2>/dev/null || true)"
@ -217,8 +217,8 @@ else
fi fi
fi fi
# ── Test 12: ci literal > 1e18 → transpiler error ──────────────────────────── # ── Test 13: ci literal > 1e18 → transpiler error ────────────────────────────
echo "Test 12: ci = 2e18 (literal) → transpiler error" echo "Test 13: ci = 2e18 (literal) → transpiler error"
STDERR=$(run_transpiler "( STDERR=$(run_transpiler "(
300000000000000000 300000000000000000
@ -232,8 +232,8 @@ assert_contains \
"$STDERR" \ "$STDERR" \
"ci literal (2000000000000000000) exceeds 1e18 (max allowed)" "ci literal (2000000000000000000) exceeds 1e18 (max allowed)"
# ── Test 13: anchorShare literal > 1e18 → transpiler error ─────────────────── # ── Test 14: anchorShare literal > 1e18 → transpiler error ───────────────────
echo "Test 13: anchorShare = 2e18 (literal) → transpiler error" echo "Test 14: anchorShare = 2e18 (literal) → transpiler error"
STDERR=$(run_transpiler "( STDERR=$(run_transpiler "(
300000000000000000 300000000000000000
@ -247,8 +247,8 @@ assert_contains \
"$STDERR" \ "$STDERR" \
"anchorShare literal (2000000000000000000) exceeds 1e18 (max allowed)" "anchorShare literal (2000000000000000000) exceeds 1e18 (max allowed)"
# ── Test 14: discoveryDepth literal > 1e18 → transpiler error ──────────────── # ── Test 15: discoveryDepth literal > 1e18 → transpiler error ────────────────
echo "Test 14: discoveryDepth = 2e18 (literal) → transpiler error" echo "Test 15: discoveryDepth = 2e18 (literal) → transpiler error"
STDERR=$(run_transpiler "( STDERR=$(run_transpiler "(
2000000000000000000 2000000000000000000