feat: implement blacklist to block indexing of malicious contracts#707
Open
Xaxxoo wants to merge 1 commit into
Open
feat: implement blacklist to block indexing of malicious contracts#707Xaxxoo wants to merge 1 commit into
Xaxxoo wants to merge 1 commit into
Conversation
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.
|
@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! 🚀 |
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.
Closes #470
Summary
BlacklistedContractmodel (contract_id,reason,added_by,created_at) with a unique index and Base32 address validation, along with migration0042_blacklistedcontract.ingest_latest_eventsintasks.pyto load all blacklisted contract IDs before the RPC poll, filter them out of the active-contract query sent toget_events, and write anINFOlog entry for each skipped contract (includescontract_idandreason: "blacklisted"as structured extras).test_blacklisted_contract.pywith model tests and ingestion skip-logic tests.Test plan
test_create_with_valid_address— BlacklistedContract saves and__str__renders correctlytest_duplicate_contract_id_raises— unique constraint enforcedtest_invalid_address_rejected— non-C-prefixed address failsfull_clean()test_reason_is_optional/test_added_by_nullable— optional fields default correctlytest_added_by_links_user— FK to User workstest_blacklisted_contract_excluded_from_rpc_query— blacklisted ID absent fromget_eventscalltest_blacklisted_contract_logged— INFO log entry contains contract_id and "blacklisted"test_non_blacklisted_contract_included— non-blacklisted ID still sent to RPCtest_multiple_blacklisted_all_excluded— all three blacklisted contracts logged and excluded