Skip to content

Feat/1037 key discovery registry - #1058

Open
Bolajiomo99 wants to merge 2 commits into
accesslayerorg:mainfrom
Bolajiomo99:feat/1037-key-discovery-registry
Open

Bolajiomo99 wants to merge 2 commits into
accesslayerorg:mainfrom
Bolajiomo99:feat/1037-key-discovery-registry

Conversation

@Bolajiomo99

Copy link
Copy Markdown

Summary

This PR introduces the key-discovery-registry contract, a new on-chain discovery index for creator keys. It tracks keys deployed through the creator-keys factory, records per-key trade volume over rolling windows, and exposes sorted discovery views ("trending" and "new keys").

Key features:

  • Registration: register_key(caller, key_id, creator) records deployment metadata (key_id, creator, deploy_timestamp). Only the admin or an authorised registrar may call this. Re-registering the same key is rejected.
  • Volume tracking: record_volume(caller, key_id, amount) appends a positive volume entry for a registered key. Entries older than 48 hours are pruned on write. Only the admin or an authorised recorder may call this.
  • Discovery views:
    • get_trending(limit) returns top keys by 24h volume (descending), ties broken by earlier deployment; keys with zero 24h volume are omitted.
    • get_new_keys(since_timestamp, limit) returns keys deployed at/after since_timestamp, newest-first.
  • Housekeeping & reads: prune(key_id) removes records older than 48h (callable by anyone). Read-only helpers: get_volume_24h, get_volume_entries, get_key_info, get_registered_count.
  • Admin: initialise(admin) (one-time), set_registrar(registrar, allowed), set_recorder(recorder, allowed). All admin operations require auth.
  • Events: key_reg(key_id) with KeyInfo payload; vol_rec(key_id) with VolumeEntry payload.

The crate is added to the workspace. Unit tests cover registration/auth, volume windows/pruning, trending ordering, and new-keys filtering.

closes #1037

Testing

  • cargo fmt --all -- --check
  • cargo clippy -p key-discovery-registry --all-targets -- -D warnings
  • cargo test -p key-discovery-registry

Checklist

  • Linked issue or backlog item (closes Implement on-chain key discovery registry for trending and new key indexing #1037)
  • Added/updated unit tests in key-discovery-registry/src/test.rs covering success and failure paths (unauthorised, duplicate registration, non-positive amount, unregistered key, pruning, trending, new keys). No creator-keys behavior changed, so no new creator-keys tests required.
  • Ran cargo fmt --all -- --check, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace (all workspace tests pass; unrelated snapshot artifacts modified during workspace test run were reverted to keep scope clean)
  • Reviewed persistent storage changes against docs/storage-key-invariants.md. New contract uses instance/persistent storage under its own DataKey namespace (Admin, Initialised, Registrar, Recorder, KeyInfo, KeyIndex, Volume). No existing storage keys are modified.
  • Confirmed event names, topic order, payloads: events publish (EVENT_NAME, key_id) as topic and the corresponding struct as payload (KeyInfo for key_reg, VolumeEntry for vol_rec). Order/meanings align with existing Soroban event conventions.
  • Updated docs: N/A (new contract; no existing public interface modified). README/docs can be updated separately if needed.
  • Scope: limited to the new key-discovery-registry contract, workspace member addition, and its tests. No unrelated formatting, generated artifacts, or unnecessary dependency changes.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@Bolajiomo99 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 on-chain key discovery registry for trending and new key indexing

1 participant