Skip to content

Enforce ABI-version compatibility between aggregator and its target shards (#432) - #440

Merged
Inkman007 merged 1 commit into
Ledger-Lenz:mainfrom
soloking1412:feat/issue-432-abi-version-compatibility
Jul 21, 2026
Merged

Enforce ABI-version compatibility between aggregator and its target shards (#432)#440
Inkman007 merged 1 commit into
Ledger-Lenz:mainfrom
soloking1412:feat/issue-432-abi-version-compatibility

Conversation

@soloking1412

Copy link
Copy Markdown
Contributor

Closes #432

Problem

ledgerlens-aggregator registered ledgerlens-score shards via add_shard with no check that a candidate shard actually implements the interface version the aggregator expects. A shard whose interface had drifted (older build, changed signature) would be accepted silently, surfacing later as failed or subtly incorrect cross-contract calls instead of a clear error at registration time.

Changes

  • add_shard now verifies compatibility before accepting a shard. It calls the candidate's supports_interface for each capability the aggregator invokes on shards — score (get_score), gate (query_risk_gate), and aggr (get_aggregate_score) — and rejects the shard unless all are supported. The call is made defensively via try_supports_interface, so a shard lacking the function (an older/drifted build) traps gracefully and is treated as incompatible rather than aborting the registration transaction.
  • Clear, dedicated error. Rejections return Error::IncompatibleInterface. Because the #[contracterror] enum is at the hard 50-variant XDR limit, this follows the crate's existing alias pattern.
  • Capability detection over version comparison, consistent with the versioning policy in docs/interface-spec.md §3: an additive shard upgrade that keeps the three required capabilities still registers cleanly.
  • Documentation. New §7 "Aggregator compatibility contract" in docs/interface-spec.md defines the targeted interface version, the required capabilities, the enforcement behavior, and the rationale.

Tests

Added to contracts/ledgerlens-aggregator/src/test.rs:

  • accepts a compatible LedgerLensScoreContract
  • rejects a shard advertising no capabilities
  • rejects a shard missing only aggr
  • rejects a legacy shard that lacks supports_interface entirely

Verification

  • Aggregator: 8/8 tests pass (4 new)
  • ledgerlens-score: 879 passed, 6 ignored, 0 failed
  • cargo build --workspace and clippy clean

@Inkman007
Inkman007 merged commit c4a1c13 into Ledger-Lenz:main Jul 21, 2026
3 of 6 checks passed
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.

Document and enforce ABI-version compatibility between ledgerlens-aggregator and its target shards

2 participants