Conversation
…whitelist `get_whitelisted()` loaded whole `NFTCollection` rows, including `blockchain_metadata`. That column aggregates the distinct names, descriptions and trait values of every item in a collection, so it dominates the row size: 99 enabled collections currently weigh 6.7 MB, while its only caller — `fetch_wallet_details` — used nothing but `.address`, about 6.6 KB. The task runs on every wallet re-index, roughly 4.5 times per minute in production, so the query accounted for ~1.25 TB/month of traffic between the indexer pods and Postgres: `indexer-blockchain` averaged 483 kB/s of receive over 18 days, which is exactly 6.7 MB x 4.5/min. Every new whitelisted collection carrying 300 KB of metadata added ~56 GB/month on top. Select the address column instead. The WHERE clause is unchanged, so the same rows match; only the projection narrows. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0118Xs3FazE6Sf1ocbztppqC
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, updates the only verified call site, and adds targeted unit tests for the new behavior.
Pull request overview
This PR reduces unnecessary database/network load in the blockchain indexer by changing the NFT collection whitelist query to fetch only collection addresses (instead of full NFTCollection rows containing large blockchain_metadata blobs).
Changes:
- Updated
NftCollectionService.get_whitelisted()to returnlist[str](addresses only) and documented the rationale. - Simplified
fetch_wallet_details()to use the newget_whitelisted()return type directly. - Added unit tests to verify enabled collections are included and disabled ones are excluded.
File summaries
| File | Description |
|---|---|
| backend/core/src/core/services/nft.py | Narrowed whitelist query projection to NFTCollection.address and updated return type/documentation. |
| backend/indexer_blockchain/tasks.py | Adjusted whitelist address retrieval to match the new service return type. |
| backend/tests/unit/core/services/test_nft_collection_service.py | Added coverage for get_whitelisted() returning only enabled collection addresses. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
get_whitelisted() loaded whole NFTCollection rows, including blockchain_metadata, which aggregates the names, descriptions and traits of every item in a collection. Its only caller needs the addresses alone, so select the address column instead.