Repository navigation
fix(solidity): link a call on a typed receiver to the type's member - #5060
rohit-jsfreaky wants to merge 2 commits into
Conversation
Read the declared type of `recv` in `recv.f(..)` and park the call as a
`member` raw call carrying that type, so a later pass can bind it through
the receiver's contract type or the `using` directives in scope. Nothing
binds `member` calls yet, so no edge changes.
A receiver is typed from a parameter, return variable or local of the
calling function (a name declared with two different types is ambiguous
and stays untyped), a state variable of the calling contract, an element
of a typed mapping or array, a field of a struct declared in the same
file, a conversion (`IERC20(a)`, `uint256(x)`, `payable(a)`) or a few
builtins (`msg.sender`, `keccak256(..)`, `abi.encode(..)`). The type is
normalized (`uint` -> `uint256`, whitespace) and a struct, enum or value
type declared in a contract is qualified with that contract's name, so
`Trace208` inside library Checkpoints and `Checkpoints.Trace208` in a
caller compare equal. A type name (`Lib.f()`) is not a typed receiver and
keeps its qualified-call path.
What only the cross-file pass can know is left to it: a state variable
node carries its `declared_type` and a function with one return value
its `returns` type, and `g(..).f()` records the call `g` it is the result
of. resolve_solidity_inherited_calls gains the helpers the binding passes
share: `receiver_types` (the extractor's reading, a base contract's state
variable, or the return type of `g`), `visible_types` (optionally through
re-exporting imports: `import {IERC20} from "./ERC20.sol"`) and a cached
`linearization`.
Co-Authored-By: Claude <[email protected]>
`IERC20 token; token.transfer(to, v)`, `IERC20(a).transfer(..)` and
`Ownable(x).owner()` got no edge: the extractor parked `token.transfer`
as a qualified call on a type named `token`, which never exists, and a
call on a conversion as a bare member call the shared pass drops. On
OpenZeppelin v5.4.0, 0 of the 74 such calls solc resolves were linked.
Bind `recv.f(..)` by name and arity through the receiver's declared
contract or interface type and that type's C3 linearization, the lookup
the compiler does. The type comes from the receiver typing the previous
commit adds, or from a base contract's state variable (`hevm.prank()`)
or the return type of `g` in `g().f()`. An interface method links to the
interface's declaration; no implementer is guessed. A type may be
imported through a file that re-exports it (`import {IERC20} from
"../ERC20.sol"`, the usual OpenZeppelin form), searched only when the
file declares and directly imports no type of that name.
Fail closed: no edge when the receiver is untyped, its type is not
exactly one visible contract/interface, the name/arity matches two
overloads, or a public state variable of that name (a getter) is found
first.
OpenZeppelin v5.4.0 (solc 0.8.28 AST as the answer key): typed calls
0/74 -> 71/74; solmate: 0/725 -> 716/725. No other kind changes. The 3
calls left on OpenZeppelin are made inside `_installModule` and
`_uninstallModule`, which share a node with `installModule` /
`uninstallModule` (the `_name` / `name` id merge), so they land on that
merged node until the id merge is fixed.
Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @rohit-jsfreaky. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
|
The one red check, |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 3 changed function(s) (1 sampled, not proven, 2 not verified).
Formal verification. PR-changed functions: 1/3 verified (0 proven, 1 may-equivalent, 0 distinguished) · 2 not verified (1 vacuous, 1 unsupported).
Not verified on this run: \_callee\_text (unsupported), resolve\_solidity\_inherited\_calls (vacuous: never exercised).
Graphify review — findings
Adds receiver-type resolution for Solidity member calls, so x.f() links to the member it names when x is a typed parameter, local, return variable, state variable (including inherited ones or getters), a re-exported type, a type conversion like T(x).f(), or a negated library call. Receivers with an ambiguous or missing type produce no edge instead of a guess, and field and mapping value types are normalized through _element_type, where a named mapping value of array or paren type keeps its name. Bumps _AST_CACHE_SCHEMA to 40 so cached extractions re-run with the new edges.
Review partial — this diff was larger than one review pass covers, so later files were not reviewed; some findings may be missing.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 3236 functions depend on the 171 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1154 callers, 68 callees - worse:
resolve_solidity_inherited_calls()— 1 callers, 6 callees
Verification — 3236 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1611 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
526 of 526 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety (
uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/pi.test.ts— full-run-safetytests/test_4874_jvm_resolution.py— full-run-safetytests/test_4909_reference_binding_scale.py— full-run-safetytests/test_4978_reconcile_cost.py— full-run-safetytests/test_4992_ts_import_types.py— full-run-safetytests/test_affected_cli.py— full-run-safetytests/test_affected_defines.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_affected_overrides.py— full-run-safetytests/test_affected_path_file_node.py— full-run-safetytests/test_affected_seed_reference_forms.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_alias_folding.py— full-run-safetytests/test_analyze.py— full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— full-run-safetytests/test_astro_import_ids.py— full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_backend_opt_in.py— full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_benchmark_real_query.py— full-run-safetytests/test_binary_media_words.py— impact, full-run-safetytests/test_blade_extractor.py— full-run-safetytests/test_build.py— full-run-safetytests/test_build_located_semantic_identity.py— full-run-safetytests/test_build_merge_dedup_scope.py— full-run-safetytests/test_build_merge_ghost_fold_4955.py— full-run-safetytests/test_build_merge_hyperedges_and_prune.py— full-run-safetytests/test_build_merge_shrink_guard.py— full-run-safetytests/test_builtin_global_type_refs.py— full-run-safetytests/test_c_include_resolution.py— full-run-safetytests/test_cache.py— impact, full-run-safetytests/test_cache_long_paths.py— impact, full-run-safetytests/test_cache_stale_import_target.py— impact, full-run-safetytests/test_cache_windows_case_4925.py— impact, full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— full-run-safetytests/test_case_only_decl_ids_4904.py— full-run-safetytests/test_case_sensitive_resolution.py— full-run-safetytests/test_charmap_encoding.py— impact, full-run-safety- … and 476 more
changed code file(s) with no mapped test (
graphify/extractors/solidity.py) — a coverage gap or a missing link — running the full suite rather than only the selected tests
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Docs that may be stale (advisory)
CHANGELOG.md§ 0.9.92 (2026-10-16) (lines 270-295): references changed symbolslinearizationCHANGELOG.md§ 0.9.22 (2026-07-20) (lines 1223-1232): references changed symbolsreachable
Formal verification
Could not verify: Could not verify \_callee\_text.
The verifier did not have enough to check \_callee\_text, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: parameter `callee` is annotated `Node` — outside the synthesizable primitive/collection set
No difference found (not proven): No behavior difference found in extract\_solidity (not a proof).
The verifier ran both versions of extract\_solidity on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
Could not verify: Could not verify resolve\_solidity\_inherited\_calls.
The verifier did not have enough to check resolve\_solidity\_inherited\_calls, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: non-vacuity: domain too small (only 1 distinct inputs exercised, need 3) — 'no divergence' would be near-vacuous
· 2 more finding(s) on lines outside this diff (see the check run).
#5058, #5060, #5062, #5054 and #5056 each change per-file Solidity or C# extraction output and each bumped _AST_CACHE_SCHEMA to 40 on their own. Landed together in one release window they share a single bump; this folds their descriptions into one chained schema-40 comment over the prior 39 so a warm cache re-runs the affected Solidity and C# extractions exactly once. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed on |
Closes #5059
What does this PR do?
recv.f(..)now links tofon the contract or interface type ofrecv. The receiver can be:IERC20(a);token().f()).The member is found by name and arity on the type and its bases, through the existing linearization. For an interface method the edge goes to the interface declaration; no implementer is guessed. No edge when the type is unknown or the (name, arity) pair is ambiguous.
Both this PR and the
using forPR need the receiver's type, so that code is the first commit here (refactor(solidity): type the receiver of a member call). On its own it changes no edges: I measured it, and it gives exactly v8's output. Theusing forPR builds on this same commit.State-variable nodes now carry
declared_type, and single-return functions carryreturns. Node ids don't change. AST cache schema 39 -> 40.Diff: +627 / -35 in total (shared commit +417 / -30, fix +212 / -7), 5 new tests.
Numbers
Compared with the solc 0.8.28 AST. Every other kind is unchanged on both projects.
callsedges, OZ / solmateThe 3 OZ misses and the 3 extra wrong edges are the same calls, made inside
_installModule/_uninstallModule. That is the_name/nameid merge (#5058). With #5058 applied too, OZ is 74/74 with 0 wrong edges. The 9 solmate misses are correct fail-closed cases:expectReverthas two overloads with the same arity, and 4 calls are written inside?:, which the callee parser doesn't read for any kind today.Limitations
slot.asBoolean().tload()are not typed.?:are not read (an existing parser gap, for every call kind).Type of change
Verification & Invariants
Invariant: a typed-receiver link is added only when the receiver has one declared contract/interface type and exactly one member of that name and arity is visible on it.
How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (Not needed: no skill fragments changed.)🤖 Generated with Claude Code