Skip to content

Replace the placeholder route_tag with a deterministic keyed route identifier #46

Description

@mikewheeleer

Implement a deterministic route identifier

Description

route_tag in src/lib.rs is documented as a placeholder "used by the backend to verify route integrity," but it simply echoes its (source, destination) arguments back unchanged — it ignores the env, performs no hashing, and offers no integrity value whatsoever. Its only test asserts the echo. This issue replaces it with a real deterministic route identifier the backend can use to correlate on-chain routes with off-chain records.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-contracts only.
  • Implement route_tag(env, source, destination) -> BytesN<32> as a deterministic hash over (source, destination) using env.crypto() (e.g. keccak256/sha256 of the encoded symbols).
  • Make the tag direction-sensitive so USDC→EURC and EURC→USDC differ (matching the directional pair model).
  • Optionally include the tag in the route event payload so indexers can key on it (note this is additive and document the payload change).
  • Reject identical source/destination consistent with register_pair semantics, or document why echo-of-identity is acceptable.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feature/contracts-35-deterministic-route-tag
  • Implement changes
    • Write code in: src/lib.rs — hashed route_tag implementation.
    • Write comprehensive tests in: src/lib.rs #[cfg(test)] mod test — assert determinism (same input → same tag), direction sensitivity, and distinct tags for distinct pairs.
    • Add documentation: document the route-identifier scheme in README.md.
    • Include NatSpec-style doc comments (///) on the changed entrypoint.
    • Validate security assumptions: tag is collision-resistant for the symbol domain; no preimage leak of secrets.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases and failure paths: determinism, direction flip, two different pairs, repeated calls.
  • Include the full cargo test output and a short security notes section in the PR description (threat model + mitigations).

Example commit message

feat: replace placeholder route_tag with deterministic keyed identifier

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions