Skip to content

feat(backend): expose backend capabilities#256

Open
wolf31o2 wants to merge 1 commit into
masterfrom
codex-audit-capabilities
Open

feat(backend): expose backend capabilities#256
wolf31o2 wants to merge 1 commit into
masterfrom
codex-audit-capabilities

Conversation

@wolf31o2

Copy link
Copy Markdown
Collaborator

Summary

  • add an optional, backward-compatible backend capability reporting API
  • return typed unsupported errors for unavailable provider operations
  • reject unsupported UTxO RPC additional UTxOs instead of silently ignoring them

Validation

  • go test -race ./...
  • go test -race ./backend/...

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an optional capability-reporting layer for backend.ChainContext implementations, allowing callers to detect which operations a backend truly supports while preserving source compatibility for existing third-party contexts. It also standardizes “unsupported operation” failures via a typed ErrUnsupported / UnsupportedError, and tightens UTxO RPC evaluation behavior by rejecting unsupported additionalUtxos.

Changes:

  • Add Capability, CapabilitySet, CapabilityReporter, and typed ErrUnsupported/UnsupportedError to the backend interface layer.
  • Implement Capabilities() and return ErrUnsupported for unavailable operations across multiple backends (and wrappers).
  • Add/extend tests to validate capability reporting and unsupported-operation error identity.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
backend/base.go Introduces capability types/reporting helpers and the typed unsupported error used by backends.
backend/capabilities_test.go Adds unit coverage for CapabilitySet.Has, legacy default behavior, and ErrUnsupported identity.
backend/blockfrost/blockfrost.go Adds capability reporting (not advertising general additional-UTxO evaluation support).
backend/blockfrost/blockfrost_test.go Tests Blockfrost capability reporting expectations.
backend/maestro/maestro.go Adds capability reporting and returns typed unsupported errors for unsupported operations.
backend/maestro/maestro_test.go Verifies Maestro capability reporting and typed unsupported error for GenesisParams.
backend/ogmios/ogmios.go Adds capability reporting that depends on whether Kupo is configured; returns typed unsupported errors when Kupo is missing.
backend/ogmios/ogmios_test.go Verifies capability reporting and typed unsupported errors for Ogmios-without-Kupo.
backend/utxorpc/utxorpc.go Adds capability reporting, converts unsupported operations to typed errors, and rejects non-empty additionalUtxos for EvaluateTx.
backend/utxorpc/utxorpc_test.go Tests UTxO RPC capabilities and typed unsupported errors for unsupported operations.
backend/cache/cache.go Adds Capabilities() passthrough so cached contexts preserve wrapped capability sets.
backend/cache/cache_test.go Tests that cached contexts preserve capability reporting.
backend/fixed/fixed.go Adds capability reporting and converts several operations to typed unsupported errors (including changing some previously-successful stub returns).
backend/fixed/fixed_test.go Tests fixed context capability reporting and typed unsupported errors for unsupported operations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/base.go Outdated
Comment on lines +159 to +161
// see on-chain. Check CapabilityEvaluateTxAdditionalUtxos before relying on
// these UTxOs; backends that do not support them return ErrUnsupported when
// additionalUtxos is non-empty.
Comment thread backend/fixed/fixed.go
Comment on lines 117 to 119
func (f *FixedChainContext) CurrentEpoch() (uint64, error) {
return 0, nil
return 0, backend.NewUnsupportedError("fixed chain context", backend.CapabilityCurrentEpoch)
}
@wolf31o2
wolf31o2 force-pushed the codex-audit-capabilities branch from 9f50eef to 8c76d82 Compare July 21, 2026 22:42
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.

2 participants