Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADR 009: ChainEndpoint/ChainHandle Consolidation #2108

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ To suggest an ADR, please make use of the [ADR template](./adr-template.md) prov

## Table of Contents

| ADR \# | Description | Status |
|--------------------------------------------------|-----------------------------------| ------ |
| [001](./adr-001-repo.md) | Repository structure for `ibc-rs` | Accepted |
| [002](./adr-002-ibc-relayer.md) | IBC Relayer in Rust | Accepted |
| [003](./adr-003-handler-implementation.md) | IBC handlers implementation | Accepted |
| [004](./adr-004-relayer-domain-decomposition.md) | Relayer domain decomposition | Accepted |
| [005](./adr-005-relayer-v0-implementation.md) | Relayer v0 implementation | Accepted |
| [006](./adr-006-hermes-v0.2-usecases.md) | Hermes v0.2.0 Use-Cases | Proposed |
| [007](./adr-007-ics20-implementation.md) | ICS20 implementation | Proposed |
| ADR \# | Description | Status |
| ------ | ----------- | ------ |
| [001](./adr-001-repo.md) | Repository structure for `ibc-rs` | Accepted |
| [002](./adr-002-ibc-relayer.md) | IBC Relayer in Rust | Accepted |
| [003](./adr-003-handler-implementation.md) | IBC handlers implementation | Accepted |
| [004](./adr-004-relayer-domain-decomposition.md) | Relayer domain decomposition | Accepted |
| [005](./adr-005-relayer-v0-implementation.md) | Relayer v0 implementation | Accepted |
| [006](./adr-006-hermes-v0.2-usecases.md) | Hermes v0.2.0 Use-Cases | Proposed |
| [007](./adr-007-error.md) | Error Management | Accepted |
| [008](./adr-008-ics20-implementation.md) | ICS20 implementation | Accepted |
| [009](./adr-009-chain-endpoint-handle-standardization.md) | ChainEndpoint and ChainHandle methods standardization | Accepted |
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# ADR 007: ICS20 Implementation Proposal
# ADR 008: ICS20 Implementation Proposal

## Status

Accepted

## Changelog

Expand Down Expand Up @@ -213,9 +217,6 @@ pub fn refund_packet_token<Ctx>(_ctx: &Ctx, _data: &FungibleTokenPacketData) ->
}
```

## Status

Proposed

## Consequences

Expand Down
51 changes: 51 additions & 0 deletions docs/architecture/adr-009-chain-endpoint-handle-standardization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# ADR 009: ChainEndpoint and ChainHandle methods standardization

## Status

Accepted - The PR has been merged in [#2108](https://github.com/informalsystems/ibc-rs/pull/2108)

## Changelog
* 2022-04-19: Initial Proposal

## Context
There is a lot of common methods in the `ChainHandle` and `ChainEndpoint` traits, sometimes with minute differences between one another. This document provides a way to remove the duplication of methods for increased maintainability of the codebase, along with a few suggestions to standardize the method signatures.

## Decision

### Query methods parameters
There are currently discrepancies between how methods take their arguments. Some take a `request` object, and others take fine-grained arguments that will be used to build a `request` object in the implementation of the method. For example, `query_consensus_state()` takes arguments that will be used to build a request object, whereas `query_consensus_states()` takes a request object directly.
```rust
fn query_consensus_state(
&self,
client_id: ClientId,
consensus_height: Height,
query_height: Height,
) -> ...;

fn query_consensus_states(
&self,
request: QueryConsensusStatesRequest,
) -> ...;
```

All methods will be refactored to take a request object as argument.

### Query request objects
Currently, the type for the request objects is the "raw type", coming from the compiled protobuf files. For each such type, we will create a corresponding domain type, following a similar pattern as elsewhere in the codebase.

This will allow us to modify the domain type as we wish, without requiring a change in the protobuf file (and thus, requiring a change in the communication protocol). A first such change of the domain type we foresee would alter the type to specify a height in queries; however this is out of scope for this particular ADR.


## Consequences

### Positive
+ The protobuf types are not exposed directly, which allows `hermes` to work with future non-tendermint chains
+ Increased readability of the codebase; similar methods have a similar format

### Negative


## References

* [Option type should be used with non-zero Height #1009](https://github.com/informalsystems/ibc-rs/issues/1009)
+ The new domain types proposed here, as well as the reduced deduplication of methods, will make fixing this issue easier