Repository navigation
feat(registry): memo validation at registration time (type + length checks)Β #9
Copy link
Copy link
Open
Labels
complexity: mediumStandard features or involved bug fixes (150 pts)Standard features or involved bug fixes (150 pts)enhancementNew feature or requestNew feature or requestexternal-contributorsSuitable for contributors outside the maintainer teamSuitable for contributors outside the maintainer team
Description
π Sidera β Stellar Name Service. Contribute via Drips Wave / GrantFox. Comment with your approach and wait for assignment before starting.
Description
The registry stores the memo hint as an opaque string. But Stellar memos have hard protocol constraints β MEMO_ID is a u64, MEMO_TEXT is β€ 28 bytes β and a hint that violates them produces a registration that LOOKS helpful but builds un-sendable payments. The SDK's parser currently truncates defensively; the contract should reject garbage at the source instead.
Desired outcome: register and set_address validate the memo hint β pure digits (a valid u64) become a typed ID memo; otherwise text β€ 28 bytes β and reject anything else with a descriptive error.
Scope
- Crate/module:
crates/registry,src/lib.rs - API: no signature changes;
Resolution.memostaysOption<String>(rendering as ID vs text is a client concern); a sharedvalidate_memohelper is added - Storage: none
- Tests: valid ID memos (u64 boundaries 0, u64::MAX); valid text memos (1, 28-byte boundaries incl. multibyte UTF-8); over-long text rejected; digits exceeding u64 rejected; empty-string memo normalized to
None;set_addresspath covered identically - Docs: memo rules section (mirror the SDK's
parseMemoHintcontract)
Non-goals
- Storing typed memo enums on-chain (rendering stays client-side β document why)
- SDK-side changes (the SDK parser already handles legacy/foreign data)
- Migrating already-registered names (the deployed instance has one test name; state the clean-cutover assumption)
What "done" looks like
- New
RegistryError::InvalidMemoat the next free code, with doc comment -
registerwith memo "18446744073709551616" (u64::MAX+1) βInvalidMemo -
registerwith a 29-byte text memo βInvalidMemo; exactly 28 bytes (multibyte-safe) accepted - Empty/whitespace memo string stored as
None -
set_addressenforces identical rules (shared helper) - Property-style test isn't required β a boundary matrix is enough
- All gates pass
Implementation guidelines
- Byte-length via the string's bytes iterator (no std;
String::len()gives bytes in Soroban env strings) - u64 validation without allocation: length β€ 20 chars AND parseable β careful with leading zeros (allow them: exchange convention β but they must still parse as u64; document that "000123" is accepted and treated as ID)
- Keep validation BEFORE
require_authso bad calls fail cheap (existing house ordering for input validation) - Mirror the SDK's
parseMemoHintrules exactly so client and contract can never disagree
Verification
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test -p sidera-registry --all-targets --locked
PR guidelines
- Get assigned before starting; do not start work on a reserved issue.
- Work in a fork; branch off
upstream/main; open the PR againstSidera-Protocol/sidera-contracts:main. - PR description must include
Closes #9. - All CI checks must pass; human maintainer review required.
Metadata
- Affected crates/files:
contracts/registry/src/lib.rs - Complexity label:
complexity: medium(150 base points) - Type labels:
enhancement
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
complexity: mediumStandard features or involved bug fixes (150 pts)Standard features or involved bug fixes (150 pts)enhancementNew feature or requestNew feature or requestexternal-contributorsSuitable for contributors outside the maintainer teamSuitable for contributors outside the maintainer team
Activity
Rodrigoue9 commentedon Oct 7, 2026
Hi @maintainer! I would like to implement the memo validation logic for the registry.
Technical Outline:
validate_memohelper):u64(supporting leading zeros up to 20 digits, matching exchange conventions). Rejects> u64::MAX.bytes.len() <= 28(multibyte UTF-8 safe). Rejects 29+ bytes.None.validate_memoBEFORErequire_authin bothregisterandset_addressso invalid calls fail fast and cheap.RegistryError::InvalidMemowith explicit documentation.u64::MAX,u64::MAX + 1, 28-byte strings, 29-byte strings, multi-byte UTF-8 characters, and whitespace.Track Record
Looking forward to your assignment!