Skip to content

fix: keep DCI account creations in the block aggregate - #1596

Merged
brunoguerios merged 2 commits into
mainfrom
bg/fix-dci-account-creation-labels
Oct 13, 2026
Merged

brunoguerios merged 2 commits into
mainfrom
bg/fix-dci-account-creation-labels

Conversation

@brunoguerios

Copy link
Copy Markdown
Contributor

Problem

Dev ethereum shadow mode logged a mismatch on 2026-10-09 20:49 UTC (uniswap_v4_hooks, /contract_state, block 26157347). For hook 0xa99e3d00ad56b1522eaa34f0f2fead9c6902e772, the cache returned empty code and no slots. The DB returned 8566 bytes of code and ~1188 slots. After block 26156852, every block logged Change for an unknown account skipped for the hook.

Root cause

In block 26156852, txs 3 to 10 touch the hook. The hooks DCI traces at tx 10, finds the hook for the first time, and attaches its full state to tx 10 as a Creation. Then it adds an Update to every tx in the block that changed the hook's storage (txs 3 to 10).

The DB path reads each tx on its own and inserts the contract. The window and the entity cache read the block aggregate. AccountDelta::merge keeps the first change type, so the aggregate is Update, and EntityCache skips an Update for an unknown account.

Fix

  • The DCI labels a slot re-fetch of an already-tracked account (tokens, blacklisted accounts) as Update. The account extractor labels every result Creation, and the DCI passed that label on.
  • AccountDelta::merge keeps a Creation from the newer delta. After the first fix, a DCI Creation means "new to this extractor's DCI", so the promotion is safe.

Notes for reviewers

  • WebSocket block messages now carry Creation, not Update, for a DCI-new account that an earlier tx in the block updated. This matches the DTO merge, which already keeps Creation.
  • When a tx already holds a Substreams Update for an account that the DCI finds as new, the tx-level delta becomes Creation. The DB path then runs insert_contract, which does nothing on conflict.
  • A re-fetch no longer calls insert_contract. It writes the same code and balance as before, so no new version rows appear.
  • Deletion in self merged with Creation in other now gives Creation. No forward producer emits account deletions.

Follow-ups

  • After the release, check dev ethereum Loki for Change for an unknown account skipped on the hooks extractors. Expect none for newly tracked accounts.

🤖 Generated with Claude Code

@brunoguerios brunoguerios self-assigned this Oct 13, 2026
@brunoguerios
brunoguerios marked this pull request as ready for review October 13, 2026 14:26
@brunoguerios
brunoguerios merged commit fe7bd85 into main Oct 13, 2026
29 checks passed
@brunoguerios
brunoguerios deleted the bg/fix-dci-account-creation-labels branch October 13, 2026 17:22
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants