0xMiden / 0xMiden/protocol

refactor(protocol): Address routing decode memory optimization and missing symbol traits

Offen
#3,627 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
132
Forks
167
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
110

Beschreibung

### Problem Description

1. **RoutingParameters Decode Overhead & Invariant Documentation:**
- `RoutingParameters::decode(mut bech32_string: String)` currently requires an owned `String`, causing callers in `Address::from_str` to perform an unnecessary `.to_owned()` allocation on substring slices. Inside `decode`, two `insert_str(0, ...)` calls cause additional heap reallocations.
- `RoutingParameters::encode_to_string` contains an unfinished `expect("TODO")` on line 160.

2. **Missing Symbol Traits for `TokenSymbol` and `RoleSymbol`:**
- Neither `TokenSymbol` nor `RoleSymbol` implements `core::str::FromStr`, preventing standard `s.parse::()` usage.
- Neither implements `core::hash::Hash`, preventing usage in hashed collections (`HashSet`/`HashMap`).
- `TokenSymbol` is missing ordering traits (`Ord`, `PartialOrd`).

3. **Doctest Panics in `miden-standards`:**
- Doc examples in `authority.rs` and `access/mod.rs` contain `unimplemented!()` placeholders that panic when doctests are run.

### Proposed Solution
- Update `RoutingParameters::decode` to take `&str` and construct the full bech32 string in a single allocation.
- Implement `FromStr`, `Hash`, and `AsRef` for `TokenSymbol` and `RoleSymbol`.
- Replace doctest `unimplemented!()` with valid `AccountId` test fixtures.

I have a branch ready with all fixes and signed commits.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.