Skip to content

Change/deposit hardening - #134

Merged
anhthii merged 4 commits into
mainfrom
change/deposit-hardening
Nov 23, 2026
Merged

anhthii merged 4 commits into
mainfrom
change/deposit-hardening

Conversation

@anhthii

@anhthii anhthii commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Hardens deposit parsing against fake and mis-attributed credits on EVM, Bitcoin and Stellar.

Changes

EVM

  • Safe transfers are credited only from official Safes. Previously any contract that accepted execTransaction calldata and emitted ExecutionSuccess was reported as a native deposit of the decoded amount, with no value moved. When no trace is available, the indexer now confirms tx.To is an official Safe proxy (v1.1.1 to v1.5.0) whose slot 0 points at an official singleton, using eth_getCode and eth_getStorageAt.
    • Confirmed Safes are cached, so each Safe address costs two RPC calls once.
    • If the lookup fails, the block is marked failed and retried, so a real Safe deposit is not silently dropped.
    • Addresses come from safe-global/safe-deployments. Proxy code hashes were derived from the official proxy factories and are identical on Ethereum, BSC and Base.
  • EIP-7708 logs are skipped. On chains with EIP-7708, every native transfer also emits an ERC20-style Transfer log from 0xff…fe. These no longer become a second, token transfer.

Bitcoin

  • Bare multisig outputs are no longer credited. An output listing several addresses was emitted as a full-value deposit to each of them, although any listed key may be able to spend it. Only outputs that resolve to exactly one address are emitted as transfers and UTXOs.

Stellar

  • Text memos are passed through exactly. They were trimmed, so two different on-chain memos could look the same.
  • Muxed address ids are carried as the memo. A payment to an M... address lost its embedded id. When the transaction has no memo, the id is now emitted as an id memo. A transaction memo, if present, wins.

Behaviour changes to be aware of

  • Safes older than v1.1.1, on non-official implementations, or on zkSync Era are not credited without a trace (missed deposit, never a fake one). The allowlist needs updating when Safe ships a new version.
  • Bare multisig deposits are no longer detected. This reverses the earlier "Bug Continue to process unprossed blocks after downtime #3" behaviour of crediting each listed address; the three tests for it were rewritten.
  • Text memos with leading or trailing spaces are no longer trimmed. One existing test expectation changed.

Testing

  • New unit tests for the Safe check (fake code, real proxy with a foreign singleton, extra bytes, dirty slot, every official singleton), the indexer path (confirmed vs fake, caching, RPC failure fails the block, traced transactions skipped), EIP-7708, multisig outputs, muxed ids and memo handling.
  • Replayed one full recent block with receipts from each of BSC, Base and Ethereum mainnet (290 transactions, 1,065 logs) through the parser before and after: all 486 extracted transfers are identical.
  • Not yet run against a live node. The muxed id field names (to_muxed_id, into_muxed_id) should be confirmed with one real muxed payment on testnet.

…08 logs

A contract that emitted ExecutionSuccess and took execTransaction calldata was credited as a native deposit of any amount with no value moved. An untraced Safe transfer is now credited only when tx.To is an official Safe proxy (v1.1.1 to v1.5.0) pointing at an official singleton; a failed lookup fails the block so it is retried.

Chains with EIP-7708 log every native transfer as an ERC20-style Transfer from 0xff..fe. Those logs no longer become a second, token transfer.
An output listing several addresses was emitted as a full-value deposit to each of them, although any listed key may be able to spend it. Only outputs that resolve to exactly one address are now emitted as transfers and UTXOs.
Text memos were trimmed, so two different on-chain memos could look the same. They are now passed through exactly.

A payment to a muxed (M...) address lost its embedded id. When the transaction has no memo, the id is now emitted as an id memo.
@anhthii
anhthii requested a review from vietddude November 22, 2026 03:12
@vietddude

Copy link
Copy Markdown
Collaborator

Review findings:

  1. evm.go checkSafeCandidates: checked[address] is set before the lookup, so if the RPC fails only the first block with that Safe is retried. Later blocks with the same Safe are marked processed and their deposit is lost.
  2. isCanonicalSafe reads code and slot0 at latest. A real proxy can delegatecall into a fake singleton that emits ExecutionSuccess without moving funds, then write the official singleton back. Latest state looks clean and the fake deposit is credited.
  3. canonicalSafes caches confirmed Safes for the life of the process, but slot0 can be rewritten by the owners after confirmation.
  4. Safes whose proxy or singleton is not on the list (old v1.0.0 proxy, zkSync, unlisted versions) are skipped with only a Warn log and never retried.
  5. Bitcoin: multisig outputs are no longer created, but spends of them are still assigned to Addresses[0]. That produces a SpentUTXO with no matching create and a wrong FromAddress.
  6. Stellar: the tx memo beats the muxed id. In a batch to several M-addresses with one memo, no recipient is matched.
  7. TestParseGnosisSafeETHTransfer and the Sepolia variant pass nil confirmations to convertBlock, so they always fail.

Fixes pushed on top:

  • Safe check per block: proxy code read at block N, slot0 must be an official singleton at both N-1 and N. Only the proxy-code result is cached. A lookup error fails every block containing that Safe.
  • Unlisted Safes are still skipped, now logged at Error. Failing the block would let any fake contract stall the chain.
  • Known gap: a singleton swap and restore inside the same block N is not caught without traces.
  • GetInputAddress returns "" for multisig prevouts. The single-iteration loops in bitcoin.go are removed.
  • Stellar: the muxed id is used when present.
  • Tests updated, plus new cases: two blocks sharing one Safe, singleton swapped before the block, multisig spend, muxed id over tx memo.

… muxed id

- Read Safe proxy code at the tx block and require an official singleton at N-1 and N
- Cache only proxy code; fail every block whose Safe lookup errors
- Skip bare multisig prevouts on the spend side
- Use the muxed id over the tx memo for Stellar payments
- Fix Safe RPC tests passing nil confirmations
@anhthii
anhthii merged commit 1cd4a29 into main Nov 23, 2026
5 checks passed
@anhthii
anhthii deleted the change/deposit-hardening branch November 23, 2026 05:49
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.

2 participants