Skip to content

Refactor block range calculations for token and exchange events in Transfer/TransferApproval indexers#1768

Merged
YoshihitoAso merged 1 commit intodev-26.3from
fix/indexer-transfer-skip-block
Feb 25, 2026
Merged

Refactor block range calculations for token and exchange events in Transfer/TransferApproval indexers#1768
YoshihitoAso merged 1 commit intodev-26.3from
fix/indexer-transfer-skip-block

Conversation

@purplesmoke05
Copy link
Member

📌 Description

This pull request refactors and improves the logic for determining the starting block (fromBlock) when querying blockchain logs for both token and exchange events in the indexer_Transfer.py and indexer_TransferApproval.py files. The main goal is to ensure that log queries start from the correct minimum block for each target, preventing redundant or missed log retrievals, while also simplifying the code structure.

✅ Related Issues

🔄 Changes

1. Improved Minimum Block Calculation Logic

  • Introduced new static methods (__calculate_minimum_from_block_for_targets, __calculate_minimum_from_block_for_token_targets, and __calculate_minimum_from_block_for_exchange_targets) to accurately determine the minimum fromBlock for log queries based on per-target cursors or skip blocks, replacing the previous approach of using a single oldest_block_from value.

2. Refactored Mapping of Targets and Decoders

  • Combined the mapping of targets and their event decoders into a single dictionary (target_by_address) that stores tuples of (target, event_decoder), eliminating the need for separate decoder dictionaries and reducing redundant lookups.

📌 Checklist

  • I have added tests where necessary.
  • I have updated the documentation where necessary.

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Coverage

Coverage Report •
FileStmtsMissCoverMissing
batch/sub_indexers
   indexer_Transfer.py3023289%95, 189–191, 247–251, 273, 294, 368–369, 392, 396, 423, 425, 465–466, 495, 512–513, 538–539, 568, 585–586, 611–612, 643, 660–661
   indexer_TransferApproval.py3814987%99–102, 110–113, 155–159, 196, 220, 305–308, 376, 427–428, 467–468, 492–493, 506, 520–521, 543–544, 564–565, 589–590, 610–611, 635–636, 657–658, 770, 776–777, 779, 793, 799–800, 802
tests/batch/sub_indexers
   indexer_Transfer_test.py6070100% 
TOTAL37858173295% 

Tests Skipped Failures Errors Time
1268 0 💤 0 ❌ 0 🔥 10m 2s ⏱️

@purplesmoke05 purplesmoke05 force-pushed the fix/indexer-transfer-skip-block branch from 61c70ba to 5af3db5 Compare February 25, 2026 08:05
@YoshihitoAso YoshihitoAso merged commit e750bfd into dev-26.3 Feb 25, 2026
11 checks passed
@YoshihitoAso YoshihitoAso deleted the fix/indexer-transfer-skip-block branch February 25, 2026 12:05
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