Indexer: event-driven fee-tier sync instead of full trader scan (#364) #876
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic!876
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue-364-event-driven-tier-sync"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces the 10-minute O(traders) LCD
get_registrationscan with event-driven tier updates during block parsing, plus a daily (configurable) reconcile loop for drift correction (#364).register,register_wallet,deregister,deregister_walletwasm events onFEE_DISCOUNT_ADDRESSupserttraders.tier_id/tier_name/registeredwithin the indexed block.get_registrationLCD query.run_tier_reconcile_loopdefaults to 86400s (TIER_SYNC_RECONCILE_INTERVAL, min 60s); logstier_sync_lag_secondson completion.Docs:
docs/indexer-invariants.md,skills/AGENTS_FEE_DISCOUNT_TIERS.md,indexer/.env.example.Acceptance checklist
traderswithin one indexed blockcd indexer && cargo test --test indexer_tier_sync registration_event_updates_trader_within_block -- --test-threads=1TIER_SYNC_RECONCILE_INTERVAL= 86400s;run_tier_reconcile_loopreplaces 600srun_tier_sync_loopcd indexer && cargo test --test indexer_tier_sync route_solve_uses_tier_after_registration_event -- --test-threads=1cd indexer && cargo test --test indexer_tier_sync reconcile_corrects_missed_registration_event -- --test-threads=1cd indexer && cargo test --libmake test-indexer-integrationThird-party verification
make setup-indexer-postgrescd indexer && cargo test --libcd indexer && cargo test --test indexer_tier_sync -- --test-threads=1make test-indexer-integrationmake setup-cloud-localterra, register tier on fee-discount contract, confirmGET /api/v1/traders/{addr}andGET /api/v1/route/solve?...&sender={addr}reflect tier within one block — no 10-minute wait.Attack / abuse coverage
trader_tracker::parse_fee_discount_registry_events).changed the description
changed the description
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.
Reviewed by Cursor Bugbot for commit
a0cca80b3f. Configure here.Global skipped ignores valid register
Medium Severity
parse_fee_discount_registry_eventstreats anyskippedattribute in the whole wasm event as applying to every registryaction, not only the segment after thataction. A later skippedderegister_walletin the same flattened event can cause an earlier validregisterto be dropped, sotraderstier data stays wrong until the daily reconcile.Reviewed by Cursor Bugbot for commit
a0cca80b3f. Configure here.Security review — MR !876
Commit reviewed:
a0cca80b3fc28031b1e4344213061f08514d697fScope: Event-driven fee-discount tier sync (
trader_tracker.rs,parser.rs,poller.rs,traders.rsqueries,config.rs, tests/docs). Focus: injection, authz, tier spoofing, quote/cache integrity, secret leakage, SSRF/deserialization.Method: Traced attacker-controlled inputs (wasm tx attributes, LCD responses, API query params) to sinks (SQL upserts, route tier resolution, logging). Cross-checked fee-discount contract event emission and existing route-solver controls.
Outcome:
FINDINGS: 0medium+Areas examined (no exploitable path found)
parse_fee_discount_registry_eventsscopes on_contract_address == FEE_DISCOUNT_ADDRESS; CosmWasm runtime binds that attribute to the executing contract, so arbitrary contracts cannot forge fee-discount registry events. Malformed attrs warn-and-skip;tier_idbounded 0–255.upsert_trader_tier/upsert_traderuse parameterizedsqlxbinds for wallet/tier fields.get_discountwhen configured; DBtraders.tier_idis fallback. Event-driven DB updates do not bypass on-chain discount enforcement at execution. Optionalsender/traderquote params are pre-existing (#245) and unchanged by this diff.Inline threads: none (no medium+ findings).
Security review: no medium+ findings on this diff.
added 1 commit
d0443492- fix(indexer): scope skipped guard to per-action wasm segmentCompare with previous version
resolved all threads
changed the description
mentioned in commit
9ec4c66a0a