Skip to content

Feat/onchain history mode - #1

Merged
jayeshy14 merged 5 commits into
mainfrom
feat/onchain-history-mode
Jun 7, 2026
Merged

jayeshy14 merged 5 commits into
mainfrom
feat/onchain-history-mode

Conversation

@jayeshy14

Copy link
Copy Markdown
Owner

No description provided.

jayeshy14 added 5 commits June 7, 2026 17:27
…y-type collisions

Two facets that independently declare the same elementary-typed variable (for
example address owner) at the same slot previously collapsed to one declaration
key and went undetected, because solc embeds the astId in struct type ids but not
in elementary type ids. Keying declarationKey on the underlying VariableDeclaration
astId closes that false negative while keeping genuinely inherited shared state,
which carries one stable astId across artifacts, correctly unflagged.
A build without ast = true ran only the storage-layout analyzers while the
namespace, EIP-7201, and inline-assembly analyzers silently produced nothing, and
the CLI still exited 0, so a misconfigured CI passed green on a scan that checked
almost nothing. The CLI now exits 2 in that case. The decision is extracted into a
pure decideCoverageAction so the fail-closed policy is unit tested rather than
buried in the action handler, and --allow-missing-ast downgrades it to a warning
for a deliberate storage-layout-only scan.
The inline ERC-7201 formula matcher accepted any bitwise-and, so a constant masked
with a value other than ~bytes32(uint256(0xff)) was misread as ERC-7201 and assigned
the standard slot it does not occupy. The matcher now requires the ~ and the 0xff
literal of the canonical low-byte clear.
… registered

Static scans only see facets that compile today, but storage persists after a
facet is removed, so the real collision space is every region the proxy has ever
used. History mode reconstructs that set from the chain:

  - replay the DiamondCut event log (read from Etherscan's logs endpoint, since
    free RPC tiers cap eth_getLogs to as few as 10 blocks) to recover every facet
    address ever registered, removed ones included
  - fetch each facet's verified source from Etherscan and recompile it with its
    exact solc version so AST and storage layout match what was deployed
  - run the existing five analyzers over the union; shared libraries keep one
    canonical source path so they do not false-positive against themselves

New flags: --onchain <address>, --rpc, --etherscan-key, --chainid. detect() now
accepts preloaded artifacts so the offline Foundry path is unchanged. Adds offline
tests for the event decoder and the Etherscan source-format parser.
@jayeshy14
jayeshy14 merged commit dbe156f into main Jun 7, 2026
2 checks passed
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