Skip to content

feat(decompile): retain canonical SSA sidecar - #752

Open
Jon-Becker wants to merge 1 commit into
feat/contextual-stack-ssafrom
feat/decompiler-ssa-sidecar
Open

feat(decompile): retain canonical SSA sidecar#752
Jon-Becker wants to merge 1 commit into
feat/contextual-stack-ssafrom
feat/decompiler-ssa-sidecar

Conversation

@Jon-Becker

Copy link
Copy Markdown
Owner

What changed? Why?

Builds and retains contextual stack SSA inside the decompiler's canonical sidecar.

CanonicalAnalysis now keeps the ID-consistent tuple of:

  • canonical Program;
  • contextual abstract CFG and diagnostics;
  • expression and state-version arenas owned by that CFG;
  • contextual SSA blocks, phi nodes, and lowered effect operands; and
  • selector-to-canonical-block mappings.

This makes canonical SSA available to upcoming function recovery and graph-based typed lowering without recomputing analysis or flattening calling contexts. Legacy source and ABI generation remain unchanged.

This PR is stacked on #751.

Notes to reviewers

  • SSA is derived immediately after contextual analysis so all ExprId, StateVersionId, ContextualPoint, and SsaValueId relationships remain scoped to one CanonicalAnalysis artifact.
  • This is still a sidecar migration stage. It intentionally does not switch production source lowering.
  • The additional SSA construction cost measured in feat(vm): build contextual stack SSA #751 is 1ms for USDT/Uniswap V2, 8ms for Uniswap V3 SwapRouter, and 103ms for Seaport.
  • Consumers should use points_for_selector and then index the corresponding contextual SSA blocks rather than projecting contexts onto a single block prematurely.

How has it been tested?

  • cargo test -p heimdall-decompiler --lib — 75 passed
  • cargo test -p heimdall-vm --lib — 204 passed
  • cargo check --workspace --all-targets — passed
  • cargo +nightly fmt --all -- --check — passed
  • git diff --check — passed
  • Extended the canonical-sidecar test to assert one SSA block per contextual entry state and verify that retained storage effects are available through the sidecar.

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

❌ AI Evaluation Suite for 6ee877b

📊 View the full HTML evaluation report.
Completed heimdall-eval. View workflow run.

📊 View evaluation scores
Test Case CFG Decompilation
NestedLoop 100 10
SimpleLoop 100 15
TransientStorage 100 10
NestedMappings 100 48
SimpleStorage 100 96
WhileLoop 100 10
NestedMapping 100 2
Events 100 62
Mapping 100 96
SwapRouter 100 20
WETH9 100 82
UniswapV2Pair 96 12
TetherToken 98 32
Seaport 98 5
Average 99 35
  • Run AI Evaluation Suite

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

✅ Coverage Report for d7fe889

Metric Value
Base branch 71.08%
PR branch 75.18%
Diff +4.10%

@Jon-Becker
Jon-Becker force-pushed the feat/decompiler-ssa-sidecar branch from 839026b to 5af5e2d Compare September 6, 2026 21:41
@Jon-Becker
Jon-Becker force-pushed the feat/decompiler-ssa-sidecar branch from 5af5e2d to 6ee877b Compare September 6, 2026 23:40
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Benchmark for d7fe889

Click to view benchmark
Test Base PR %
heimdall_cfg/complex 13.7±0.15ms 199.8±1.17ms +1358.39%
heimdall_cfg/simple 1405.5±44.19µs 632.5±8.37µs -55.00%
heimdall_decoder/seaport 58.4±2.91µs 56.3±1.99µs -3.60%
heimdall_decoder/transfer 4.2±0.33µs 4.2±0.30µs 0.00%
heimdall_decoder/uniswap 16.0±0.74µs 15.8±0.55µs -1.25%
heimdall_decompiler/abi_complex 57.0±1.12ms 277.5±4.06ms +386.84%
heimdall_decompiler/abi_simple 1497.2±32.20µs 2.1±0.01ms +40.26%
heimdall_decompiler/sol_complex 74.6±1.39ms 288.6±1.96ms +286.86%
heimdall_decompiler/sol_simple 1927.8±17.28µs 2.6±0.01ms +34.87%
heimdall_decompiler/yul_complex 63.2±1.05ms 278.9±7.03ms +341.30%
heimdall_decompiler/yul_simple 1691.8±43.97µs 2.4±0.04ms +41.86%
heimdall_disassembler/complex 1269.7±37.45µs 1511.2±22.30µs +19.02%
heimdall_disassembler/simple 62.0±4.82µs 71.7±4.48µs +15.65%
heimdall_vm/erc20_transfer 262.7±8.16µs 262.2±8.81µs -0.19%
heimdall_vm/fib 880.5±38.47µs 868.6±9.90µs -1.35%
heimdall_vm/ten_thousand_hashes 709.9±19.02ms 730.3±31.65ms +2.87%

📊 View the full Criterion report

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