feat: TIP-1022 virtual address forwarding detection#167
Draft
Conversation
Add is_virtual_forward column to logs table and detection logic to identify two-hop Transfer event pairs from virtual address forwarding. When a TIP-20 transfer targets a virtual address, the precompile emits two Transfer events: sender→virtualAddr (attribution) and virtualAddr→master (forwarding). Without annotation, downstream consumers double-count transfers, inflate holder counts, and can't attribute deposits to specific users. Changes: - src/virtual_address.rs: detection logic + 10 unit tests - types.rs: add is_virtual_forward to LogRow - decoder.rs: default to false on decode - engine.rs: mark_virtual_forward_hops after log decoding (all 4 paths) - writer.rs: include column in PG COPY BINARY (both write_logs and write_batch) - ch_sink.rs: include column in ClickHouse wire format - sink.rs: read column in CH backfill fetch_logs - db/logs.sql + db/clickhouse/logs.sql: schema additions Co-authored-by: malleshpai <5857042+malleshpai@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d8d8d-a38a-727b-ab3e-125654f1e65a
9cc4094 to
5ac34eb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Annotates indexed logs with
is_virtual_forwardso downstream consumers (explorer, tidx.ts) can distinguish the two-hopTransferevents emitted by TIP-1022 virtual address forwarding.Also includes additive DB migrations for existing PostgreSQL and ClickHouse deployments.
Motivation
TIP-1022 virtual addresses emit two
Transferevents per deposit:sender → virtualAddr(attribution hop) andvirtualAddr → master(forwarding hop). Without annotation at the indexer level, the explorer and any tidx.ts consumer will:This PR adds detection at the indexer layer so consumers can filter with
WHERE is_virtual_forward = falseto exclude forwarding hops, or include them when they need deposit attribution.TODO (follow-up)
is_virtual_forwardfilterTransferdisplaysPrompted by: mallesh