Skip to content

fix(contract,backend): store AgentIds as Vec<BytesN<32>> and chunk into 500-item pages (#247) - #917

Open
Bojest001 wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
Bojest001:fix/247-agent-ids-bytes32-storage
Open

fix(contract,backend): store AgentIds as Vec<BytesN<32>> and chunk into 500-item pages (#247)#917
Bojest001 wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
Bojest001:fix/247-agent-ids-bytes32-storage

Conversation

@Bojest001

Copy link
Copy Markdown

Fixes #247

Changes

  1. Contract Storage Optimization ():

    • Updated DataKey::AgentIds to store Vec<BytesN<32>> instead of heavy Vec<Address> objects, saving ~40% storage overhead by keeping only the raw 32-byte Ed25519 public key.
    • Implemented address_to_bytes32 and bytes32_to_address Base32 + CRC16 conversion helpers to convert seamlessly between Address and BytesN<32>.
    • Chunked agent IDs into DataKey::AgentIdsBytesPage(u32) pages of 500 BytesN<32> entries each (~16KB per page), preventing storage limit bottlenecks.
    • Updated list_agents and list_agents_page to reconstruct Address from raw 32-byte keys for DataKey::Agent lookups.
    • Added get_agent_ids and get_agent_ids_page contract entry points.
    • Added contract unit test coverage for Address <-> BytesN<32> conversion, list_agents reconstruction, and pagination chunking.
  2. Registry Contract Confirmation ():

    • Confirmed and documented that DataKey::ServiceIds uses Vec<u64> compact integer ScVal representation (8 bytes per entry, ~8,000 services before 64KB limit).
  3. Backend ():

    • Added addressToBytes32 and bytes32ToAddress helper functions using StrKey.
    • Updated mapAgent and mapPolicy to automatically handle Buffer / Uint8Array raw 32-byte representations as well as Address objects and string addresses.
    • Added getAgentIds and getAgentIdsPage client methods to reconstruct addresses from raw byte entries.
  4. Testing & Documentation:

    • Added unit test coverage for addressToBytes32, bytes32ToAddress, mapAgent with Buffer addresses, getAgentIds, and getAgentIdsPage in backend/src/lib/contract.test.js.
    • Updated README.md documentation.

@Bojest001
Bojest001 requested a review from ritik4ever as a code owner August 30, 2026 23:07
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Bojest001 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

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 048b83b1-ac33-48fa-8854-ae0f833aeefd


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

AgentIds stores Vec<Address> where Address is a Soroban host object

1 participant