Skip to content

Feat add regulatory limit event stream so indexers can rebuild aggregate cap usage per jurisdiction - #698

Merged
thlpkee20-wq merged 3 commits into
RevoraOrg:masterfrom
obswrld:feat-Add-regulatory-limit-event-stream-so-indexers-can-rebuild-aggregate-cap-usage-per-jurisdiction
Jul 29, 2026
Merged

Feat add regulatory limit event stream so indexers can rebuild aggregate cap usage per jurisdiction#698
thlpkee20-wq merged 3 commits into
RevoraOrg:masterfrom
obswrld:feat-Add-regulatory-limit-event-stream-so-indexers-can-rebuild-aggregate-cap-usage-per-jurisdiction

Conversation

@obswrld

@obswrld obswrld commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

closes #590

Summary
Adds a regulatory-limit event stream ( reg_limit_delta ) that emits a structured event on every holding change for jurisdiction-tagged holders, enabling indexers to rebuild aggregate cap usage per jurisdiction over time for periodic Reg D and Reg S reporting.

Changes
Core implementation ( src/lib.rs , +462 lines):

  • New event symbol EVENT_REG_LIMIT_DELTA ( rg_lim_d )
  • EVENT_JUR_UNSET sentinel ( jur_none ) — skips untagged holders
  • update_and_emit_reg_limit_delta() helper: reads holder jurisdiction tag, updates JurisdictionAggregateShare storage, emits event
  • Hooked into set_holder_share_internal — covers all issuance, transfer, and share-change paths automatically
  • get_indexer_fixture_topics() updated to include rg_lim_d as the 16th canonical fixture
  • Storage layout version bumped (4→5) and schema entry added for JurisdictionAggregateShare(OfferingId, Symbol) → i128
    Event schema:
    Topic: (rg_lim_d, issuer, namespace, token)
    Data: (holder, jurisdiction, delta_bps, new_aggregate_bps)
    Tests ( src/test_reg_limit_delta.rs , new, +430 lines):
  • 12 tests covering:
  • Issuance with jurisdiction → event emitted
  • Share zeroing → negative delta
  • No jurisdiction → no event
  • Cross-jurisdiction transfer → 2 events, net zero per jurisdiction
  • Same-jurisdiction transfer → 2 events, net zero total
  • Multi-holder, multi-jurisdiction → independent aggregation
  • Partial jurisdiction coverage → 1 event only
  • Neither holder has jurisdiction → 0 events
  • Event data shape (field ordering stable)
  • Symbol constant pinned
  • Gas budget: set_holder_share with event (≤1M CPU)
  • Gas budget: transfer with 2 events (≤2M CPU)
    Test updates:
  • src/test_indexer_fixtures.rs : expects 16 fixtures, added rg_lim_d assertion
  • src/milestone_signals.rs : updated 3 tests for new tuple return + 16 fixtures
  • docs/indexer-fixture-coverage.md : rg_lim_d listed as canonical fixture

obswrld and others added 3 commits July 29, 2026 18:38
- Add EVENT_REG_LIMIT_DELTA (rg_lim_d) event symbol with doc comments
- Add update_and_emit_reg_limit_delta helper that tracks
  JurisdictionAggregateShare per (offering, jurisdiction)
- Hook into set_holder_share_internal for automatic emission
  on every holding change (issuance, transfer)
- Add get_indexer_fixture_topics with 16 canonical fixture
  entries including rg_lim_d (non-period-scoped, period_id=0)
- Add EVENT_JUR_UNSET sentinel constant (was missing)
- Bump STORAGE_LAYOUT_VERSION from 4 to 5
- Add 12 tests (9 behavioral + 3 gas-budget) covering issuance,
  cross/same-jurisdiction transfers, no-jurisdiction edge cases,
  data shape, and gas bounds
- Update test_indexer_fixtures.rs to expect 16 fixtures
- Update milestone_signals.rs for new tuple return and fixture count
- Update docs/indexer-fixture-coverage.md with rg_lim_d entry
Resolved ~50 pre-existing compilation errors across 3 files:
- src/lib.rs: SafeMath import fix, RevoraError discriminant renumbering (62->77, 63->78, 67->79), 9 missing enum variants (80-88), symbol_short! length, sha256().into(), Proposal fields, set_holder_share_internal args, is_dispute_freeze_active param, MerkleLeaf contracttype, MigrationDataKey variants
- src/merkle_helpers.rs: Added #[contracttype] to MerkleLeaf struct
- tools/storage_layout_schema.rs: Added MigrationDataKey entries

~420 pre-existing structural errors remain (DataKey2 >50 variants exceeds Soroban #[contracttype] limit, plus cascading errors) — these are unrelated to the regulatory-limit feature.
@thlpkee20-wq
thlpkee20-wq merged commit 1195682 into RevoraOrg:master Jul 29, 2026
1 of 3 checks passed
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@obswrld 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.

Add regulatory-limit event stream so indexers can rebuild aggregate cap usage per jurisdiction

2 participants