Skip to content

feat: implement blacklist to block indexing of malicious contracts#707

Open
Xaxxoo wants to merge 1 commit into
SoroScan:mainfrom
Xaxxoo:feat/contract-blacklist-470
Open

feat: implement blacklist to block indexing of malicious contracts#707
Xaxxoo wants to merge 1 commit into
SoroScan:mainfrom
Xaxxoo:feat/contract-blacklist-470

Conversation

@Xaxxoo
Copy link
Copy Markdown

@Xaxxoo Xaxxoo commented Jun 1, 2026

Closes #470

Summary

  • Adds BlacklistedContract model (contract_id, reason, added_by, created_at) with a unique index and Base32 address validation, along with migration 0042_blacklistedcontract.
  • Updates ingest_latest_events in tasks.py to load all blacklisted contract IDs before the RPC poll, filter them out of the active-contract query sent to get_events, and write an INFO log entry for each skipped contract (includes contract_id and reason: "blacklisted" as structured extras).
  • Adds test_blacklisted_contract.py with model tests and ingestion skip-logic tests.

Test plan

  • test_create_with_valid_address — BlacklistedContract saves and __str__ renders correctly
  • test_duplicate_contract_id_raises — unique constraint enforced
  • test_invalid_address_rejected — non-C-prefixed address fails full_clean()
  • test_reason_is_optional / test_added_by_nullable — optional fields default correctly
  • test_added_by_links_user — FK to User works
  • test_blacklisted_contract_excluded_from_rpc_query — blacklisted ID absent from get_events call
  • test_blacklisted_contract_logged — INFO log entry contains contract_id and "blacklisted"
  • test_non_blacklisted_contract_included — non-blacklisted ID still sent to RPC
  • test_multiple_blacklisted_all_excluded — all three blacklisted contracts logged and excluded

Closes SoroScan#470

- Add BlacklistedContract model with contract_id (unique, validated
  Base32 Soroban address), reason, added_by (FK to User), and
  created_at fields, along with migration 0042.
- Update ingest_latest_events in tasks.py to fetch all blacklisted
  contract_ids before the RPC query, exclude them from the list of
  active contracts sent to get_events, and emit an INFO log entry for
  each skipped contract so operators can audit the decision.
- Add test_blacklisted_contract.py covering: model creation, duplicate
  rejection, invalid address validation, optional fields, ingestion
  exclusion from RPC query, skip logging, and multi-contract scenarios.
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Jun 1, 2026

@Xaxxoo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Implement a blacklist to block indexing of malicious contracts

1 participant