informalsystems / hermes

IBC Relayer in Rust
https://hermes.informal.systems
Apache License 2.0
445 stars 328 forks source link

ChainEndpoint trait makes restrictive assumptions about signing keys #3641

Open hdevalence opened 1 year ago

hdevalence commented 1 year ago

Summary

The current ChainEndpoint trait makes too restrictive assumptions about the shape and role of signing keys. This makes it difficult to properly add support for chains like Penumbra with different authorization behaviors.

Problem Definition

The ChainEndpoint trait used to create pluggable, chain-specific backends has a SigningKeyPair associated type.

This type must implement the SigningKeyPair trait, which demands the following behavior:

This is a layering violation, because it bakes in assumptions from the Cosmos SDK that may not apply to other chains. In fact, none of these properties obtain for Penumbra keys:

However, although these assumptions are all violated by Penumbra's design, there is no real problem with relaying. There's just a different authorization mechanism. The only problem here arises from the layering violation of lifting chain-specific authorization mechanisms into the common ChainEndpoint trait.

Proposal

Transaction authorization should move out of the ChainEndpoint trait into the endpoint implementation itself.

Rather than demanding an opinionated KeyPair, the ChainEndpoint should only require the endpoint to provide the Signer field that should be used when building related packets.

Signing transactions should be an opaque and internal responsibility of the endpoint implementation.

Acceptance Criteria


For Admin Use

romac commented 1 year ago

Thanks so much for taking the time to write this up 🙏

Overall, I fully agree with your assessment that exposing the underlying signing key type is a layering violation and prevents non-Cosmos chains from integrating with Hermes.

Your proposal sounds good as well, but before we can move forward with it, we need to figure out how to deal with the hermes keys command, which I guess would either:

a) need to be adapted to work with both Cosmos and Penumbra keys b) be moved under a new cosmos subcommand, leaving it up to you to add a penumbra keys subcommand should you find the need for it c) left as-is

Option (a) might be the most satisfying for both of us, provided m we manage to make it work for both types of chain without changing the interface of these commands too much.

Option (b) would be a breaking change of the CLIs, which we try to keep as infrequent as possible. But if (a) proves not to be doable or desirable, I am not completely moving everything Cosmos-specific under an aptly named subcommand for clarity now that we will have support for at least one non-Cosmos SDK chain.

Option (c) might be a good option in case you don't ever plan to add Penumbra-specific commands for managing keys.

What do you think?