Skip to content

Commit

Permalink
Remove ics07 unwrap() and update ibc protocol spec link (#2115)
Browse files Browse the repository at this point in the history
* remve ics07-tendermint client_def.rs unwrap()

* update link

* Formatting

Co-authored-by: Romain Ruetschi <[email protected]>
  • Loading branch information
DaviRain-Su and romac authored Apr 25, 2022
1 parent 5e886ca commit dee7489
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
16 changes: 12 additions & 4 deletions modules/src/clients/ics07_tendermint/client_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ impl ClientDef for TendermintClient {
epoch: consensus_height.revision_number,
height: consensus_height.revision_height,
};
let value = expected_consensus_state.encode_vec().unwrap();
let value = expected_consensus_state
.encode_vec()
.map_err(Ics02Error::invalid_any_consensus_state)?;
verify_membership(client_state, prefix, proof, root, path, value)
}

Expand All @@ -225,7 +227,9 @@ impl ClientDef for TendermintClient {
client_state.verify_height(height)?;

let path = ConnectionsPath(connection_id.clone());
let value = expected_connection_end.encode_vec().unwrap();
let value = expected_connection_end
.encode_vec()
.map_err(Ics02Error::invalid_connection_end)?;
verify_membership(client_state, prefix, proof, root, path, value)
}

Expand All @@ -243,7 +247,9 @@ impl ClientDef for TendermintClient {
client_state.verify_height(height)?;

let path = ChannelEndsPath(port_id.clone(), *channel_id);
let value = expected_channel_end.encode_vec().unwrap();
let value = expected_channel_end
.encode_vec()
.map_err(Ics02Error::invalid_channel_end)?;
verify_membership(client_state, prefix, proof, root, path, value)
}

Expand All @@ -260,7 +266,9 @@ impl ClientDef for TendermintClient {
client_state.verify_height(height)?;

let path = ClientStatePath(client_id.clone());
let value = expected_client_state.encode_vec().unwrap();
let value = expected_client_state
.encode_vec()
.map_err(Ics02Error::invalid_any_client_state)?;
verify_membership(client_state, prefix, proof, root, path, value)
}

Expand Down
2 changes: 1 addition & 1 deletion modules/src/core/ics02_client/client_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub trait ClientDef: Clone {
) -> Result<(Self::ClientState, Self::ConsensusState), Error>;

/// Verification functions as specified in:
/// <https://github.com/cosmos/ibc/tree/master/spec/ics-002-client-semantics>
/// <https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics>
///
/// Verify a `proof` that the consensus state of a given client (at height `consensus_height`)
/// matches the input `consensus_state`. The parameter `counterparty_height` represent the
Expand Down
15 changes: 15 additions & 0 deletions modules/src/core/ics02_client/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ define_error! {
{ height: Height }
| e | { format_args!("the local consensus state could not be retrieved for height {}", e.height) },

InvalidConnectionEnd
[ TraceError<TendermintProtoError>]
| _ | { "invalid connection end" },

InvalidChannelEnd
[ TraceError<TendermintProtoError>]
| _ | { "invalid channel end" },

InvalidAnyClientState
[ TraceError<TendermintProtoError>]
| _ | { "invalid any client state" },

InvalidAnyConsensusState
[ TraceError<TendermintProtoError> ]
| _ | { "invalid any client consensus state" },
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/src/core/ics02_client/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! these messages can be found, for instance, in ICS 07 for Tendermint-specific chains. A chain
//! handles these messages in two layers: first with the general ICS 02 client handler, which
//! subsequently calls into the chain-specific (e.g., ICS 07) client handler. See:
//! <https://github.com/cosmos/ibc/tree/master/spec/ics-002-client-semantics#create>.
//! <https://github.com/cosmos/ibc/tree/master/spec/core/ics-002-client-semantics#create>.
use crate::core::ics02_client::msgs::create_client::MsgCreateAnyClient;
use crate::core::ics02_client::msgs::misbehavior::MsgSubmitAnyMisbehaviour;
Expand Down
2 changes: 1 addition & 1 deletion modules/src/core/ics03_connection/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! We define each of the four messages in the connection handshake protocol as a `struct`.
//! Each such message comprises the same fields as the datagrams defined in ICS3 English spec:
//! <https://github.com/cosmos/ibc/tree/master/spec/ics-003-connection-semantics>.
//! <https://github.com/cosmos/ibc/tree/master/spec/core/ics-003-connection-semantics>.
//!
//! One departure from ICS3 is that we abstract the three counterparty fields (connection id,
//! prefix, and client id) into a single field of type `Counterparty`; this applies to messages
Expand Down
2 changes: 1 addition & 1 deletion modules/src/core/ics24_host/path.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::prelude::*;

/// Path-space as listed in ICS-024
/// https://github.com/cosmos/ibc/tree/master/spec/ics-024-host-requirements#path-space
/// https://github.com/cosmos/ibc/tree/master/spec/core/ics-024-host-requirements#path-space
/// Some of these are implemented in other ICSs, but ICS-024 has a nice summary table.
///
use core::str::FromStr;
Expand Down

0 comments on commit dee7489

Please sign in to comment.