From f4b9988550d9791cff75ef2679f5c4289c3af521 Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Tue, 23 Feb 2021 18:04:01 -0500 Subject: [PATCH 01/11] Refactoring of signer from AccountId into String (#219) --- modules/src/address.rs | 11 ++++-- .../msgs/transfer.rs | 18 ++++------ .../src/ics02_client/handler/create_client.rs | 12 +++---- .../src/ics02_client/handler/update_client.rs | 10 +++--- .../src/ics02_client/msgs/create_client.rs | 21 ++++-------- .../src/ics02_client/msgs/update_client.rs | 19 ++++------- .../ics03_connection/msgs/conn_open_ack.rs | 15 ++------ .../msgs/conn_open_confirm.rs | 15 ++------ .../ics03_connection/msgs/conn_open_init.rs | 15 ++------ .../ics03_connection/msgs/conn_open_try.rs | 13 ++----- .../src/ics04_channel/msgs/acknowledgement.rs | 34 +++++++------------ .../ics04_channel/msgs/chan_close_confirm.rs | 15 ++------ .../src/ics04_channel/msgs/chan_close_init.rs | 15 ++------ .../src/ics04_channel/msgs/chan_open_ack.rs | 15 ++------ .../ics04_channel/msgs/chan_open_confirm.rs | 17 +++------- .../src/ics04_channel/msgs/chan_open_init.rs | 15 ++------ .../src/ics04_channel/msgs/chan_open_try.rs | 19 +++-------- modules/src/ics04_channel/msgs/recv_packet.rs | 34 +++++++------------ modules/src/ics04_channel/msgs/timeout.rs | 34 +++++++------------ .../ics04_channel/msgs/timeout_on_close.rs | 17 +++------- modules/src/ics18_relayer/context.rs | 3 +- modules/src/ics26_routing/handler.rs | 8 ++--- modules/src/mock/context.rs | 5 ++- modules/src/test_utils.rs | 2 +- modules/src/tx_msg.rs | 3 -- modules/tests/executor/mod.rs | 5 ++- relayer/src/chain.rs | 4 +-- relayer/src/chain/cosmos.rs | 8 ++--- relayer/src/chain/handle.rs | 6 ++-- relayer/src/chain/handle/prod.rs | 4 +-- relayer/src/chain/mock.rs | 7 ++-- relayer/src/chain/runtime.rs | 4 +-- relayer/src/foreign_client.rs | 9 ++++- 33 files changed, 143 insertions(+), 289 deletions(-) diff --git a/modules/src/address.rs b/modules/src/address.rs index 02cf9b4908..3ab3869bac 100644 --- a/modules/src/address.rs +++ b/modules/src/address.rs @@ -6,11 +6,16 @@ use anomaly::{BoxError, Context}; use bech32::ToBase32; use bech32::{FromBase32, Variant}; +use std::str::FromStr; use tendermint::account::Id as AccountId; -pub fn account_to_string(addr: AccountId) -> Result { - Ok(bech32::encode("cosmos", addr.to_base32(), Variant::Bech32) - .map_err(|e| Context::new("cannot generate bech32 account", Some(e.into())))?) +pub fn encode_to_bech32(addr: String, hrp: String) -> Result { + let account = + AccountId::from_str(addr.as_str()).map_err(|e| Context::new("bad address", Some(e)))?; + Ok( + bech32::encode(hrp.as_str(), account.to_base32(), Variant::Bech32) + .map_err(|e| Context::new("cannot generate bech32 account", Some(e.into())))?, + ) } pub fn string_to_account(raw: String) -> Result { diff --git a/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs b/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs index 7ae0f6825f..42418ed1cd 100644 --- a/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs +++ b/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs @@ -1,11 +1,9 @@ use std::convert::{TryFrom, TryInto}; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::applications::transfer::v1::MsgTransfer as RawMsgTransfer; -use crate::address::{account_to_string, string_to_account}; use crate::application::ics20_fungible_token_transfer::error::{Error, Kind}; use crate::ics02_client::height::Height; use crate::ics24_host::identifier::{ChannelId, PortId}; @@ -25,9 +23,9 @@ pub struct MsgTransfer { /// the tokens to be transferred pub token: Option, /// the sender address - pub sender: AccountId, + pub sender: String, /// the recipient address on the destination chain - pub receiver: AccountId, + pub receiver: String, /// Timeout height relative to the current block height. /// The timeout is disabled when set to 0. pub timeout_height: Height, @@ -46,10 +44,6 @@ impl Msg for MsgTransfer { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.sender] - } } impl Protobuf for MsgTransfer {} @@ -62,8 +56,8 @@ impl TryFrom for MsgTransfer { source_port: raw_msg.source_port.parse().unwrap(), source_channel: raw_msg.source_channel.parse().unwrap(), token: raw_msg.token, - sender: string_to_account(raw_msg.sender).unwrap(), - receiver: string_to_account(raw_msg.receiver).unwrap(), + sender: raw_msg.sender, + receiver: raw_msg.receiver, timeout_height: raw_msg.timeout_height.unwrap().try_into().unwrap(), timeout_timestamp: 0, }) @@ -76,8 +70,8 @@ impl From for RawMsgTransfer { source_port: domain_msg.source_port.to_string(), source_channel: domain_msg.source_channel.to_string(), token: domain_msg.token, - sender: account_to_string(domain_msg.sender).unwrap(), - receiver: account_to_string(domain_msg.receiver).unwrap(), + sender: domain_msg.sender, + receiver: domain_msg.receiver, timeout_height: Some(domain_msg.timeout_height.try_into().unwrap()), timeout_timestamp: 0, } diff --git a/modules/src/ics02_client/handler/create_client.rs b/modules/src/ics02_client/handler/create_client.rs index 984117ba35..2ad4293e42 100644 --- a/modules/src/ics02_client/handler/create_client.rs +++ b/modules/src/ics02_client/handler/create_client.rs @@ -71,13 +71,13 @@ mod tests { use crate::mock::client_state::{MockClientState, MockConsensusState}; use crate::mock::context::MockContext; use crate::mock::header::MockHeader; - use crate::test_utils::get_dummy_account_id; + use crate::test_utils::get_dummy_account_id_raw; use crate::Height; #[test] fn test_create_client_ok() { let ctx = MockContext::default(); - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let height = Height::new(0, 42); let msg = MsgCreateAnyClient::new( @@ -120,7 +120,7 @@ mod tests { #[test] fn test_create_client_ok_multiple() { let existing_client_id = ClientId::default(); - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let height = Height::new(0, 80); let ctx = MockContext::default().with_client(&existing_client_id, height); @@ -137,7 +137,7 @@ mod tests { ..height })) .into(), - signer, + signer.clone(), ) .unwrap(), MsgCreateAnyClient::new( @@ -151,7 +151,7 @@ mod tests { ..height })) .into(), - signer, + signer.clone(), ) .unwrap(), MsgCreateAnyClient::new( @@ -210,7 +210,7 @@ mod tests { #[test] fn test_tm_create_client_ok() { - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let ctx = MockContext::default(); diff --git a/modules/src/ics02_client/handler/update_client.rs b/modules/src/ics02_client/handler/update_client.rs index 56f3062456..80250066df 100644 --- a/modules/src/ics02_client/handler/update_client.rs +++ b/modules/src/ics02_client/handler/update_client.rs @@ -86,13 +86,13 @@ mod tests { use crate::mock::client_state::MockClientState; use crate::mock::context::MockContext; use crate::mock::header::MockHeader; - use crate::test_utils::get_dummy_account_id; + use crate::test_utils::get_dummy_account_id_raw; use crate::Height; #[test] fn test_update_client_ok() { let client_id = ClientId::default(); - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let ctx = MockContext::default().with_client(&client_id, Height::new(0, 42)); @@ -137,7 +137,7 @@ mod tests { #[test] fn test_update_nonexisting_client() { let client_id = ClientId::from_str("mockclient1").unwrap(); - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let ctx = MockContext::default().with_client(&client_id, Height::new(0, 42)); @@ -166,7 +166,7 @@ mod tests { ClientId::from_str("mockclient2").unwrap(), ClientId::from_str("mockclient3").unwrap(), ]; - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let initial_height = Height::new(0, 45); let update_height = Height::new(0, 49); @@ -180,7 +180,7 @@ mod tests { let msg = MsgUpdateAnyClient { client_id: cid.clone(), header: MockHeader(update_height).into(), - signer, + signer: signer.clone(), }; let output = dispatch(&ctx, ClientMsg::UpdateClient(msg.clone())); diff --git a/modules/src/ics02_client/msgs/create_client.rs b/modules/src/ics02_client/msgs/create_client.rs index 0ce5677fdd..b7ec3e69f8 100644 --- a/modules/src/ics02_client/msgs/create_client.rs +++ b/modules/src/ics02_client/msgs/create_client.rs @@ -6,12 +6,10 @@ use std::convert::TryFrom; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::client::v1::MsgCreateClient as RawMsgCreateClient; -use crate::address::{account_to_string, string_to_account}; use crate::ics02_client::client_def::{AnyClientState, AnyConsensusState}; use crate::ics02_client::error; use crate::ics02_client::error::{Error, Kind}; @@ -24,14 +22,14 @@ pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient"; pub struct MsgCreateAnyClient { pub client_state: AnyClientState, pub consensus_state: AnyConsensusState, - pub signer: AccountId, + pub signer: String, } impl MsgCreateAnyClient { pub fn new( client_state: AnyClientState, consensus_state: AnyConsensusState, - signer: AccountId, + signer: String, ) -> Result { if client_state.client_type() != consensus_state.client_type() { return Err(error::Kind::RawClientAndConsensusStateTypesMismatch { @@ -46,6 +44,7 @@ impl MsgCreateAnyClient { signer, }) } + pub fn client_state(&self) -> AnyClientState { self.client_state.clone() } @@ -64,10 +63,6 @@ impl Msg for MsgCreateAnyClient { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgCreateAnyClient {} @@ -84,14 +79,12 @@ impl TryFrom for MsgCreateAnyClient { .consensus_state .ok_or_else(|| Kind::InvalidRawConsensusState.context("missing consensus state"))?; - let signer = string_to_account(raw.signer).map_err(|e| Kind::InvalidAddress.context(e))?; - MsgCreateAnyClient::new( AnyClientState::try_from(raw_client_state) .map_err(|e| Kind::InvalidRawClientState.context(e))?, AnyConsensusState::try_from(raw_consensus_state) .map_err(|e| Kind::InvalidRawConsensusState.context(e))?, - signer, + raw.signer, ) } } @@ -101,7 +94,7 @@ impl From for RawMsgCreateClient { RawMsgCreateClient { client_state: Some(ics_msg.client_state.into()), consensus_state: Some(ics_msg.consensus_state.into()), - signer: account_to_string(ics_msg.signer).unwrap(), + signer: ics_msg.signer, } } } @@ -117,11 +110,11 @@ mod tests { use crate::ics07_tendermint::client_state::test_util::get_dummy_tendermint_client_state; use crate::ics07_tendermint::header::test_util::get_dummy_tendermint_header; - use crate::test_utils::get_dummy_account_id; + use crate::test_utils::get_dummy_account_id_raw; #[test] fn msg_create_client_serialization() { - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let tm_header = get_dummy_tendermint_header(); let tm_client_state = get_dummy_tendermint_client_state(tm_header.clone()); diff --git a/modules/src/ics02_client/msgs/update_client.rs b/modules/src/ics02_client/msgs/update_client.rs index 23aa97363b..9a8afcebe6 100644 --- a/modules/src/ics02_client/msgs/update_client.rs +++ b/modules/src/ics02_client/msgs/update_client.rs @@ -6,12 +6,10 @@ use std::convert::TryFrom; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::client::v1::MsgUpdateClient as RawMsgUpdateClient; -use crate::address::{account_to_string, string_to_account}; use crate::ics02_client::client_def::AnyHeader; use crate::ics02_client::error::{Error, Kind}; use crate::ics24_host::identifier::ClientId; @@ -24,11 +22,11 @@ pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpdateClient"; pub struct MsgUpdateAnyClient { pub client_id: ClientId, pub header: AnyHeader, - pub signer: AccountId, + pub signer: String, } impl MsgUpdateAnyClient { - pub fn new(client_id: ClientId, header: AnyHeader, signer: AccountId) -> Self { + pub fn new(client_id: ClientId, header: AnyHeader, signer: String) -> Self { MsgUpdateAnyClient { client_id, header, @@ -47,10 +45,6 @@ impl Msg for MsgUpdateAnyClient { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgUpdateAnyClient {} @@ -60,12 +54,11 @@ impl TryFrom for MsgUpdateAnyClient { fn try_from(raw: RawMsgUpdateClient) -> Result { let raw_header = raw.header.ok_or(Kind::InvalidRawHeader)?; - let signer = string_to_account(raw.signer).map_err(|e| Kind::InvalidAddress.context(e))?; Ok(MsgUpdateAnyClient { client_id: raw.client_id.parse().unwrap(), header: AnyHeader::try_from(raw_header).unwrap(), - signer, + signer: raw.signer, }) } } @@ -75,7 +68,7 @@ impl From for RawMsgUpdateClient { RawMsgUpdateClient { client_id: ics_msg.client_id.to_string(), header: Some(ics_msg.header.into()), - signer: account_to_string(ics_msg.signer).unwrap(), + signer: ics_msg.signer, } } } @@ -91,12 +84,12 @@ mod tests { use crate::ics24_host::identifier::ClientId; use crate::ics07_tendermint::header::test_util::get_dummy_ics07_header; - use crate::test_utils::get_dummy_account_id; + use crate::test_utils::get_dummy_account_id_raw; #[test] fn msg_update_client_serialization() { let client_id: ClientId = "tendermint".parse().unwrap(); - let signer = get_dummy_account_id(); + let signer = get_dummy_account_id_raw(); let header = get_dummy_ics07_header(); diff --git a/modules/src/ics03_connection/msgs/conn_open_ack.rs b/modules/src/ics03_connection/msgs/conn_open_ack.rs index c2e98ad792..fb863c0398 100644 --- a/modules/src/ics03_connection/msgs/conn_open_ack.rs +++ b/modules/src/ics03_connection/msgs/conn_open_ack.rs @@ -4,9 +4,6 @@ use std::str::FromStr; use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenAck as RawMsgConnectionOpenAck; use tendermint_proto::Protobuf; -use tendermint::account::Id as AccountId; - -use crate::address::{account_to_string, string_to_account}; use crate::ics02_client::client_def::AnyClientState; use crate::ics03_connection::error::{Error, Kind}; use crate::ics03_connection::version::Version; @@ -26,7 +23,7 @@ pub struct MsgConnectionOpenAck { pub client_state: Option, pub proofs: Proofs, pub version: Version, - pub signer: AccountId, + pub signer: String, } impl MsgConnectionOpenAck { @@ -72,10 +69,6 @@ impl Msg for MsgConnectionOpenAck { crate::keys::ROUTER_KEY.to_string() } - fn get_signers(&self) -> Vec { - vec![self.signer] - } - fn type_url(&self) -> String { TYPE_URL.to_string() } @@ -87,8 +80,6 @@ impl TryFrom for MsgConnectionOpenAck { type Error = anomaly::Error; fn try_from(msg: RawMsgConnectionOpenAck) -> Result { - let signer = string_to_account(msg.signer).map_err(|e| Kind::InvalidAddress.context(e))?; - let consensus_height = msg .consensus_height .ok_or(Kind::MissingConsensusHeight)? @@ -137,7 +128,7 @@ impl TryFrom for MsgConnectionOpenAck { proof_height, ) .map_err(|e| Kind::InvalidProof.context(e))?, - signer, + signer: msg.signer, }) } } @@ -168,7 +159,7 @@ impl From for RawMsgConnectionOpenAck { .consensus_proof() .map_or_else(|| None, |h| Some(h.height().into())), version: Some(ics_msg.version.into()), - signer: account_to_string(ics_msg.signer).unwrap(), + signer: ics_msg.signer, } } } diff --git a/modules/src/ics03_connection/msgs/conn_open_confirm.rs b/modules/src/ics03_connection/msgs/conn_open_confirm.rs index 03100d7a8a..ef7f32ef7c 100644 --- a/modules/src/ics03_connection/msgs/conn_open_confirm.rs +++ b/modules/src/ics03_connection/msgs/conn_open_confirm.rs @@ -3,9 +3,6 @@ use std::convert::{TryFrom, TryInto}; use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenConfirm as RawMsgConnectionOpenConfirm; use tendermint_proto::Protobuf; -use tendermint::account::Id as AccountId; - -use crate::address::{account_to_string, string_to_account}; use crate::ics03_connection::error::{Error, Kind}; use crate::ics24_host::identifier::ConnectionId; use crate::{proofs::Proofs, tx_msg::Msg}; @@ -19,7 +16,7 @@ pub const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenConfirm"; pub struct MsgConnectionOpenConfirm { pub connection_id: ConnectionId, pub proofs: Proofs, - pub signer: AccountId, + pub signer: String, } impl MsgConnectionOpenConfirm { @@ -41,10 +38,6 @@ impl Msg for MsgConnectionOpenConfirm { crate::keys::ROUTER_KEY.to_string() } - fn get_signers(&self) -> Vec { - vec![self.signer] - } - fn type_url(&self) -> String { TYPE_URL.to_string() } @@ -56,8 +49,6 @@ impl TryFrom for MsgConnectionOpenConfirm { type Error = anomaly::Error; fn try_from(msg: RawMsgConnectionOpenConfirm) -> Result { - let signer = string_to_account(msg.signer).map_err(|e| Kind::InvalidAddress.context(e))?; - let proof_height = msg .proof_height .ok_or(Kind::MissingProofHeight)? @@ -70,7 +61,7 @@ impl TryFrom for MsgConnectionOpenConfirm { .map_err(|e| Kind::IdentifierError.context(e))?, proofs: Proofs::new(msg.proof_ack.into(), None, None, None, proof_height) .map_err(|e| Kind::InvalidProof.context(e))?, - signer, + signer: msg.signer, }) } } @@ -81,7 +72,7 @@ impl From for RawMsgConnectionOpenConfirm { connection_id: ics_msg.connection_id.as_str().to_string(), proof_ack: ics_msg.proofs.object_proof().clone().into(), proof_height: Some(ics_msg.proofs.height().into()), - signer: account_to_string(ics_msg.signer).unwrap(), + signer: ics_msg.signer, } } } diff --git a/modules/src/ics03_connection/msgs/conn_open_init.rs b/modules/src/ics03_connection/msgs/conn_open_init.rs index a3c7ce5cf4..1f0d68bc25 100644 --- a/modules/src/ics03_connection/msgs/conn_open_init.rs +++ b/modules/src/ics03_connection/msgs/conn_open_init.rs @@ -3,9 +3,6 @@ use std::convert::{TryFrom, TryInto}; use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenInit as RawMsgConnectionOpenInit; use tendermint_proto::Protobuf; -use tendermint::account::Id as AccountId; - -use crate::address::{account_to_string, string_to_account}; use crate::ics03_connection::connection::Counterparty; use crate::ics03_connection::error::{Error, Kind}; use crate::ics03_connection::version::Version; @@ -23,7 +20,7 @@ pub struct MsgConnectionOpenInit { pub counterparty: Counterparty, pub version: Version, pub delay_period: u64, - pub signer: AccountId, + pub signer: String, } impl MsgConnectionOpenInit { @@ -50,10 +47,6 @@ impl Msg for MsgConnectionOpenInit { crate::keys::ROUTER_KEY.to_string() } - fn get_signers(&self) -> Vec { - vec![self.signer] - } - fn type_url(&self) -> String { TYPE_URL.to_string() } @@ -65,8 +58,6 @@ impl TryFrom for MsgConnectionOpenInit { type Error = anomaly::Error; fn try_from(msg: RawMsgConnectionOpenInit) -> Result { - let signer = string_to_account(msg.signer).map_err(|e| Kind::InvalidAddress.context(e))?; - Ok(Self { client_id: msg .client_id @@ -82,7 +73,7 @@ impl TryFrom for MsgConnectionOpenInit { .try_into() .map_err(|e| Kind::InvalidVersion.context(e))?, delay_period: msg.delay_period, - signer, + signer: msg.signer, }) } } @@ -94,7 +85,7 @@ impl From for RawMsgConnectionOpenInit { counterparty: Some(ics_msg.counterparty.into()), version: Some(ics_msg.version.into()), delay_period: ics_msg.delay_period, - signer: account_to_string(ics_msg.signer).unwrap(), + signer: ics_msg.signer, } } } diff --git a/modules/src/ics03_connection/msgs/conn_open_try.rs b/modules/src/ics03_connection/msgs/conn_open_try.rs index a389be30fd..6552bf3b46 100644 --- a/modules/src/ics03_connection/msgs/conn_open_try.rs +++ b/modules/src/ics03_connection/msgs/conn_open_try.rs @@ -4,9 +4,6 @@ use std::str::FromStr; use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenTry as RawMsgConnectionOpenTry; use tendermint_proto::Protobuf; -use tendermint::account::Id as AccountId; - -use crate::address::{account_to_string, string_to_account}; use crate::ics02_client::client_def::AnyClientState; use crate::ics03_connection::connection::Counterparty; use crate::ics03_connection::error::{Error, Kind}; @@ -31,7 +28,7 @@ pub struct MsgConnectionOpenTry { pub counterparty_versions: Vec, pub proofs: Proofs, pub delay_period: u64, - pub signer: AccountId, + pub signer: String, } impl MsgConnectionOpenTry { @@ -93,10 +90,6 @@ impl Msg for MsgConnectionOpenTry { crate::keys::ROUTER_KEY.to_string() } - fn get_signers(&self) -> Vec { - vec![self.signer] - } - fn type_url(&self) -> String { TYPE_URL.to_string() } @@ -171,7 +164,7 @@ impl TryFrom for MsgConnectionOpenTry { ) .map_err(|e| Kind::InvalidProof.context(e))?, delay_period: msg.delay_period, - signer: string_to_account(msg.signer).map_err(|e| Kind::InvalidAddress.context(e))?, + signer: msg.signer, }) } } @@ -208,7 +201,7 @@ impl From for RawMsgConnectionOpenTry { .proofs .consensus_proof() .map_or_else(|| None, |h| Some(h.height().into())), - signer: account_to_string(ics_msg.signer).unwrap(), + signer: ics_msg.signer, } } } diff --git a/modules/src/ics04_channel/msgs/acknowledgement.rs b/modules/src/ics04_channel/msgs/acknowledgement.rs index c73a916cf8..6f6e31598d 100644 --- a/modules/src/ics04_channel/msgs/acknowledgement.rs +++ b/modules/src/ics04_channel/msgs/acknowledgement.rs @@ -1,11 +1,9 @@ use std::convert::{TryFrom, TryInto}; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgAcknowledgement as RawMsgAcknowledgement; -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::Packet; use crate::{proofs::Proofs, tx_msg::Msg}; @@ -20,7 +18,7 @@ pub struct MsgAcknowledgement { pub packet: Packet, acknowledgement: Vec, proofs: Proofs, - signer: AccountId, + signer: String, } impl MsgAcknowledgement { @@ -28,7 +26,7 @@ impl MsgAcknowledgement { packet: Packet, acknowledgement: Vec, proofs: Proofs, - signer: AccountId, + signer: String, ) -> Result { Ok(Self { packet, @@ -49,10 +47,6 @@ impl Msg for MsgAcknowledgement { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgAcknowledgement {} @@ -61,9 +55,6 @@ impl TryFrom for MsgAcknowledgement { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgAcknowledgement) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_acked.into(), None, @@ -84,7 +75,7 @@ impl TryFrom for MsgAcknowledgement { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, acknowledgement: raw_msg.acknowledgement, - signer, + signer: raw_msg.signer, proofs, }) } @@ -95,7 +86,7 @@ impl From for RawMsgAcknowledgement { RawMsgAcknowledgement { packet: Some(domain_msg.packet.into()), acknowledgement: domain_msg.acknowledgement, - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, proof_height: Some(domain_msg.proofs.height().into()), proof_acked: domain_msg.proofs.object_proof().clone().into(), } @@ -169,14 +160,15 @@ mod test { }, want_pass: false, }, - Test { - name: "Missing signer".to_string(), - raw: RawMsgAcknowledgement { - signer: "".to_string(), - ..default_raw_msg.clone() - }, - want_pass: false, - }, + //TODO: Check why this is failing now + // Test { + // name: "Missing signer".to_string(), + // raw: RawMsgAcknowledgement { + // signer: "".to_string(), + // ..default_raw_msg.clone() + // }, + // want_pass: false, + // }, Test { name: "Empty proof acked".to_string(), raw: RawMsgAcknowledgement { diff --git a/modules/src/ics04_channel/msgs/chan_close_confirm.rs b/modules/src/ics04_channel/msgs/chan_close_confirm.rs index 5ee73782d9..8fbd0e694a 100644 --- a/modules/src/ics04_channel/msgs/chan_close_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_close_confirm.rs @@ -1,11 +1,9 @@ use std::convert::{TryFrom, TryInto}; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelCloseConfirm as RawMsgChannelCloseConfirm; -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::{ChannelId, PortId}; use crate::{proofs::Proofs, tx_msg::Msg}; @@ -21,7 +19,7 @@ pub struct MsgChannelCloseConfirm { pub port_id: PortId, pub channel_id: ChannelId, pub proofs: Proofs, - pub signer: AccountId, + pub signer: String, } impl Msg for MsgChannelCloseConfirm { @@ -34,10 +32,6 @@ impl Msg for MsgChannelCloseConfirm { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl MsgChannelCloseConfirm { @@ -59,9 +53,6 @@ impl TryFrom for MsgChannelCloseConfirm { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgChannelCloseConfirm) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_init.into(), None, @@ -85,7 +76,7 @@ impl TryFrom for MsgChannelCloseConfirm { .parse() .map_err(|e| Kind::IdentifierError.context(e))?, proofs, - signer, + signer: raw_msg.signer, }) } } @@ -97,7 +88,7 @@ impl From for RawMsgChannelCloseConfirm { channel_id: domain_msg.channel_id.to_string(), proof_init: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } diff --git a/modules/src/ics04_channel/msgs/chan_close_init.rs b/modules/src/ics04_channel/msgs/chan_close_init.rs index 216a0f7330..60b79ecd7d 100644 --- a/modules/src/ics04_channel/msgs/chan_close_init.rs +++ b/modules/src/ics04_channel/msgs/chan_close_init.rs @@ -1,11 +1,9 @@ use std::convert::TryFrom; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgChannelCloseInit as RawMsgChannelCloseInit; -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::{ChannelId, PortId}; use crate::tx_msg::Msg; @@ -19,7 +17,7 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseInit"; pub struct MsgChannelCloseInit { pub port_id: PortId, pub channel_id: ChannelId, - pub signer: AccountId, + pub signer: String, } impl MsgChannelCloseInit { @@ -42,10 +40,6 @@ impl Msg for MsgChannelCloseInit { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgChannelCloseInit {} @@ -54,9 +48,6 @@ impl TryFrom for MsgChannelCloseInit { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgChannelCloseInit) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - Ok(MsgChannelCloseInit { port_id: raw_msg .port_id @@ -66,7 +57,7 @@ impl TryFrom for MsgChannelCloseInit { .channel_id .parse() .map_err(|e| Kind::IdentifierError.context(e))?, - signer, + signer: raw_msg.signer, }) } } @@ -76,7 +67,7 @@ impl From for RawMsgChannelCloseInit { RawMsgChannelCloseInit { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_ack.rs b/modules/src/ics04_channel/msgs/chan_open_ack.rs index e385bec11b..08eacc749a 100644 --- a/modules/src/ics04_channel/msgs/chan_open_ack.rs +++ b/modules/src/ics04_channel/msgs/chan_open_ack.rs @@ -1,11 +1,9 @@ -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::channel::validate_version; use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::{ChannelId, PortId}; use crate::{proofs::Proofs, tx_msg::Msg}; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenAck as RawMsgChannelOpenAck; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use std::convert::{TryFrom, TryInto}; @@ -22,7 +20,7 @@ pub struct MsgChannelOpenAck { pub counterparty_channel_id: ChannelId, pub counterparty_version: String, pub proofs: Proofs, - pub signer: AccountId, + pub signer: String, } impl MsgChannelOpenAck { @@ -56,10 +54,6 @@ impl Msg for MsgChannelOpenAck { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgChannelOpenAck {} @@ -68,9 +62,6 @@ impl TryFrom for MsgChannelOpenAck { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgChannelOpenAck) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_try.into(), None, @@ -99,7 +90,7 @@ impl TryFrom for MsgChannelOpenAck { .map_err(|e| Kind::IdentifierError.context(e))?, counterparty_version: validate_version(raw_msg.counterparty_version)?, proofs, - signer, + signer: raw_msg.signer, }) } } @@ -113,7 +104,7 @@ impl From for RawMsgChannelOpenAck { counterparty_version: domain_msg.counterparty_version.to_string(), proof_try: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_confirm.rs b/modules/src/ics04_channel/msgs/chan_open_confirm.rs index 1f398ee5b1..2c8e7f3c63 100644 --- a/modules/src/ics04_channel/msgs/chan_open_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_open_confirm.rs @@ -1,11 +1,9 @@ -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::error::{Error, Kind}; use crate::ics23_commitment::commitment::CommitmentProofBytes; use crate::ics24_host::identifier::{ChannelId, PortId}; use crate::{proofs::Proofs, tx_msg::Msg, Height}; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenConfirm as RawMsgChannelOpenConfirm; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use std::convert::{TryFrom, TryInto}; @@ -21,7 +19,7 @@ pub struct MsgChannelOpenConfirm { pub port_id: PortId, pub channel_id: ChannelId, pub proofs: Proofs, - pub signer: AccountId, + pub signer: String, } impl MsgChannelOpenConfirm { @@ -32,7 +30,7 @@ impl MsgChannelOpenConfirm { channel_id: String, proof_ack: CommitmentProofBytes, proofs_height: Height, - signer: AccountId, + signer: String, ) -> Result { Ok(Self { port_id: port_id @@ -70,10 +68,6 @@ impl Msg for MsgChannelOpenConfirm { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgChannelOpenConfirm {} @@ -82,9 +76,6 @@ impl TryFrom for MsgChannelOpenConfirm { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgChannelOpenConfirm) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_ack.into(), None, @@ -108,7 +99,7 @@ impl TryFrom for MsgChannelOpenConfirm { .parse() .map_err(|e| Kind::IdentifierError.context(e))?, proofs, - signer, + signer: raw_msg.signer, }) } } @@ -120,7 +111,7 @@ impl From for RawMsgChannelOpenConfirm { channel_id: domain_msg.channel_id.to_string(), proof_ack: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_init.rs b/modules/src/ics04_channel/msgs/chan_open_init.rs index 8cdf063148..8496439b6a 100644 --- a/modules/src/ics04_channel/msgs/chan_open_init.rs +++ b/modules/src/ics04_channel/msgs/chan_open_init.rs @@ -1,11 +1,9 @@ -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::channel::ChannelEnd; use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::PortId; use crate::tx_msg::Msg; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenInit as RawMsgChannelOpenInit; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use std::convert::{TryFrom, TryInto}; @@ -19,7 +17,7 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenInit"; pub struct MsgChannelOpenInit { pub port_id: PortId, pub channel: ChannelEnd, - pub signer: AccountId, + pub signer: String, } impl MsgChannelOpenInit { @@ -44,10 +42,6 @@ impl Msg for MsgChannelOpenInit { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgChannelOpenInit {} @@ -56,16 +50,13 @@ impl TryFrom for MsgChannelOpenInit { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgChannelOpenInit) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - Ok(MsgChannelOpenInit { port_id: raw_msg .port_id .parse() .map_err(|e| Kind::IdentifierError.context(e))?, channel: raw_msg.channel.ok_or(Kind::MissingChannel)?.try_into()?, - signer, + signer: raw_msg.signer, }) } } @@ -75,7 +66,7 @@ impl From for RawMsgChannelOpenInit { RawMsgChannelOpenInit { port_id: domain_msg.port_id.to_string(), channel: Some(domain_msg.channel.into()), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_try.rs b/modules/src/ics04_channel/msgs/chan_open_try.rs index 9cb9e28e8a..78ef90ff49 100644 --- a/modules/src/ics04_channel/msgs/chan_open_try.rs +++ b/modules/src/ics04_channel/msgs/chan_open_try.rs @@ -1,15 +1,11 @@ use crate::ics04_channel::channel::{validate_version, ChannelEnd}; use crate::ics04_channel::error::{Error, Kind}; +use crate::ics24_host::error::ValidationError; use crate::ics24_host::error::ValidationKind; use crate::ics24_host::identifier::{ChannelId, PortId}; -use crate::{ - address::{account_to_string, string_to_account}, - ics24_host::error::ValidationError, -}; use crate::{proofs::Proofs, tx_msg::Msg}; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenTry as RawMsgChannelOpenTry; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use std::convert::{TryFrom, TryInto}; @@ -27,7 +23,7 @@ pub struct MsgChannelOpenTry { pub channel: ChannelEnd, pub counterparty_version: String, pub proofs: Proofs, - pub signer: AccountId, + pub signer: String, } impl MsgChannelOpenTry { @@ -59,10 +55,6 @@ impl Msg for MsgChannelOpenTry { TYPE_URL.to_string() } - fn get_signers(&self) -> Vec { - vec![self.signer] - } - fn validate_basic(&self) -> Result<(), ValidationError> { match self.channel().counterparty().channel_id() { None => Err(ValidationKind::InvalidCounterpartyChannelId.into()), @@ -77,9 +69,6 @@ impl TryFrom for MsgChannelOpenTry { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgChannelOpenTry) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_init.into(), None, @@ -108,7 +97,7 @@ impl TryFrom for MsgChannelOpenTry { channel: raw_msg.channel.ok_or(Kind::MissingChannel)?.try_into()?, counterparty_version: validate_version(raw_msg.counterparty_version)?, proofs, - signer, + signer: raw_msg.signer, }; match msg.validate_basic() { @@ -129,7 +118,7 @@ impl From for RawMsgChannelOpenTry { counterparty_version: domain_msg.counterparty_version, proof_init: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } diff --git a/modules/src/ics04_channel/msgs/recv_packet.rs b/modules/src/ics04_channel/msgs/recv_packet.rs index 9260ab5f92..a1a1a201e4 100644 --- a/modules/src/ics04_channel/msgs/recv_packet.rs +++ b/modules/src/ics04_channel/msgs/recv_packet.rs @@ -1,11 +1,9 @@ use std::convert::{TryFrom, TryInto}; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgRecvPacket as RawMsgRecvPacket; -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::Packet; use crate::{proofs::Proofs, tx_msg::Msg}; @@ -19,11 +17,11 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgRecvPacket"; pub struct MsgRecvPacket { pub packet: Packet, proofs: Proofs, - signer: AccountId, + signer: String, } impl MsgRecvPacket { - pub fn new(packet: Packet, proofs: Proofs, signer: AccountId) -> Result { + pub fn new(packet: Packet, proofs: Proofs, signer: String) -> Result { Ok(Self { packet, proofs, @@ -42,10 +40,6 @@ impl Msg for MsgRecvPacket { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgRecvPacket {} @@ -54,9 +48,6 @@ impl TryFrom for MsgRecvPacket { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgRecvPacket) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_commitment.into(), None, @@ -77,7 +68,7 @@ impl TryFrom for MsgRecvPacket { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, proofs, - signer, + signer: raw_msg.signer, }) } } @@ -88,7 +79,7 @@ impl From for RawMsgRecvPacket { packet: Some(domain_msg.packet.into()), proof_commitment: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } @@ -158,14 +149,15 @@ mod test { }, want_pass: false, }, - Test { - name: "Missing signer".to_string(), - raw: RawMsgRecvPacket { - signer: "".to_string(), - ..default_raw_msg - }, - want_pass: false, - }, + //TODO: Check why this is failing now + // Test { + // name: "Missing signer".to_string(), + // raw: RawMsgRecvPacket { + // signer: "".to_string(), + // ..default_raw_msg + // }, + // want_pass: false, + // }, ]; for test in tests { diff --git a/modules/src/ics04_channel/msgs/timeout.rs b/modules/src/ics04_channel/msgs/timeout.rs index ec6f43d3e6..1fdcddefac 100644 --- a/modules/src/ics04_channel/msgs/timeout.rs +++ b/modules/src/ics04_channel/msgs/timeout.rs @@ -1,11 +1,9 @@ use std::convert::{TryFrom, TryInto}; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgTimeout as RawMsgTimeout; -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::{Packet, Sequence}; use crate::{proofs::Proofs, tx_msg::Msg}; @@ -20,7 +18,7 @@ pub struct MsgTimeout { pub packet: Packet, next_sequence_recv: Sequence, proofs: Proofs, - signer: AccountId, + signer: String, } impl MsgTimeout { @@ -28,7 +26,7 @@ impl MsgTimeout { packet: Packet, next_sequence_recv: Sequence, proofs: Proofs, - signer: AccountId, + signer: String, ) -> Result { Ok(Self { packet, @@ -49,10 +47,6 @@ impl Msg for MsgTimeout { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgTimeout {} @@ -61,9 +55,6 @@ impl TryFrom for MsgTimeout { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgTimeout) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_unreceived.into(), None, @@ -86,7 +77,7 @@ impl TryFrom for MsgTimeout { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, next_sequence_recv: Sequence::from(raw_msg.next_sequence_recv), - signer, + signer: raw_msg.signer, proofs, }) } @@ -99,7 +90,7 @@ impl From for RawMsgTimeout { proof_unreceived: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), next_sequence_recv: domain_msg.next_sequence_recv.into(), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } @@ -179,14 +170,15 @@ mod test { }, want_pass: false, }, - Test { - name: "Missing signer".to_string(), - raw: RawMsgTimeout { - signer: "".to_string(), - ..default_raw_msg - }, - want_pass: false, - }, + //TODO: Check why this is failing now + // Test { + // name: "Missing signer".to_string(), + // raw: RawMsgTimeout { + // signer: "".to_string(), + // ..default_raw_msg + // }, + // want_pass: false, + // }, ]; for test in tests { diff --git a/modules/src/ics04_channel/msgs/timeout_on_close.rs b/modules/src/ics04_channel/msgs/timeout_on_close.rs index f3f00ab98f..7125072e3f 100644 --- a/modules/src/ics04_channel/msgs/timeout_on_close.rs +++ b/modules/src/ics04_channel/msgs/timeout_on_close.rs @@ -1,11 +1,9 @@ use std::convert::{TryFrom, TryInto}; -use tendermint::account::Id as AccountId; use tendermint_proto::Protobuf; use ibc_proto::ibc::core::channel::v1::MsgTimeoutOnClose as RawMsgTimeoutOnClose; -use crate::address::{account_to_string, string_to_account}; use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::{Packet, Sequence}; use crate::{proofs::Proofs, tx_msg::Msg}; @@ -20,7 +18,7 @@ pub struct MsgTimeoutOnClose { pub packet: Packet, next_sequence_recv: Sequence, proofs: Proofs, - signer: AccountId, + signer: String, } impl MsgTimeoutOnClose { @@ -28,7 +26,7 @@ impl MsgTimeoutOnClose { packet: Packet, next_sequence_recv: Sequence, proofs: Proofs, - signer: AccountId, + signer: String, ) -> Result { Ok(Self { packet, @@ -49,10 +47,6 @@ impl Msg for MsgTimeoutOnClose { fn type_url(&self) -> String { TYPE_URL.to_string() } - - fn get_signers(&self) -> Vec { - vec![self.signer] - } } impl Protobuf for MsgTimeoutOnClose {} @@ -61,9 +55,6 @@ impl TryFrom for MsgTimeoutOnClose { type Error = anomaly::Error; fn try_from(raw_msg: RawMsgTimeoutOnClose) -> Result { - let signer = - string_to_account(raw_msg.signer).map_err(|e| Kind::InvalidSigner.context(e))?; - let proofs = Proofs::new( raw_msg.proof_unreceived.into(), None, @@ -86,7 +77,7 @@ impl TryFrom for MsgTimeoutOnClose { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, next_sequence_recv: Sequence::from(raw_msg.next_sequence_recv), - signer, + signer: raw_msg.signer, proofs, }) } @@ -104,7 +95,7 @@ impl From for RawMsgTimeoutOnClose { .map_or_else(Vec::new, |v| v.into()), proof_height: Some(domain_msg.proofs.height().into()), next_sequence_recv: domain_msg.next_sequence_recv.into(), - signer: account_to_string(domain_msg.signer).unwrap(), + signer: domain_msg.signer, } } } diff --git a/modules/src/ics18_relayer/context.rs b/modules/src/ics18_relayer/context.rs index c4a1999cee..8632d0b0b4 100644 --- a/modules/src/ics18_relayer/context.rs +++ b/modules/src/ics18_relayer/context.rs @@ -1,5 +1,4 @@ use prost_types::Any; -use tendermint::account::Id as AccountId; use crate::events::IBCEvent; use crate::ics02_client::client_def::{AnyClientState, AnyHeader}; @@ -28,5 +27,5 @@ pub trait ICS18Context { fn send(&mut self, msgs: Vec) -> Result, Error>; /// Temporary solution. Similar to `CosmosSDKChain::key_and_signer()` but simpler. - fn signer(&self) -> AccountId; + fn signer(&self) -> String; } diff --git a/modules/src/ics26_routing/handler.rs b/modules/src/ics26_routing/handler.rs index f7786a392c..34a607b1d5 100644 --- a/modules/src/ics26_routing/handler.rs +++ b/modules/src/ics26_routing/handler.rs @@ -157,7 +157,7 @@ mod tests { use crate::mock::client_state::{MockClientState, MockConsensusState}; use crate::mock::context::MockContext; use crate::mock::header::MockHeader; - use crate::test_utils::get_dummy_account_id; + use crate::test_utils::get_dummy_account_id_raw; use crate::Height; #[test] @@ -172,14 +172,14 @@ mod tests { msg: ICS26Envelope, want_pass: bool, } - let default_signer = get_dummy_account_id(); + let default_signer = get_dummy_account_id_raw(); let start_client_height = Height::new(0, 5); let update_client_height = Height::new(0, 34); let create_client_msg = MsgCreateAnyClient::new( AnyClientState::from(MockClientState(MockHeader(start_client_height))), AnyConsensusState::from(MockConsensusState(MockHeader(start_client_height))), - get_dummy_account_id(), + get_dummy_account_id_raw(), ) .unwrap(); @@ -270,7 +270,7 @@ mod tests { msg: ICS26Envelope::ICS2Msg(ClientMsg::UpdateClient(MsgUpdateAnyClient { client_id: client_id.clone(), header: MockHeader(update_client_height).into(), - signer: default_signer, + signer: default_signer.clone(), })), want_pass: true, }, diff --git a/modules/src/mock/context.rs b/modules/src/mock/context.rs index c27f8a33d4..9f06b3cef9 100644 --- a/modules/src/mock/context.rs +++ b/modules/src/mock/context.rs @@ -6,7 +6,6 @@ use std::error::Error; use std::str::FromStr; use prost_types::Any; -use tendermint::account::Id; use crate::ics02_client::client_def::{AnyClientState, AnyConsensusState, AnyHeader}; use crate::ics02_client::client_type::ClientType; @@ -632,8 +631,8 @@ impl ICS18Context for MockContext { Ok(events) } - fn signer(&self) -> Id { - Id::from_str("0CDA3F47EF3C4906693B170EF650EB968C5F4B2C").unwrap() + fn signer(&self) -> String { + "0CDA3F47EF3C4906693B170EF650EB968C5F4B2C".to_string() } } diff --git a/modules/src/test_utils.rs b/modules/src/test_utils.rs index aa590882b8..abdfa2633f 100644 --- a/modules/src/test_utils.rs +++ b/modules/src/test_utils.rs @@ -29,7 +29,7 @@ pub fn get_dummy_proof() -> Vec { .to_vec() } -fn get_dummy_account_id_raw() -> String { +pub fn get_dummy_account_id_raw() -> String { "0CDA3F47EF3C4906693B170EF650EB968C5F4B2C".to_string() } diff --git a/modules/src/tx_msg.rs b/modules/src/tx_msg.rs index 14e80b501b..7b4c8f41c5 100644 --- a/modules/src/tx_msg.rs +++ b/modules/src/tx_msg.rs @@ -1,6 +1,5 @@ use crate::ics24_host::error::ValidationError; use prost_types::Any; -use tendermint::account::Id as AccountId; pub trait Msg: Clone { type ValidationError: std::error::Error; @@ -27,8 +26,6 @@ pub trait Msg: Clone { } } - fn get_signers(&self) -> Vec; - fn validate_basic(&self) -> Result<(), ValidationError> { Ok(()) } diff --git a/modules/tests/executor/mod.rs b/modules/tests/executor/mod.rs index 7dafed984c..df374637c1 100644 --- a/modules/tests/executor/mod.rs +++ b/modules/tests/executor/mod.rs @@ -21,7 +21,6 @@ use std::collections::HashMap; use std::error::Error; use std::fmt::{Debug, Display}; use step::{ActionOutcome, ActionType, Chain, Step}; -use tendermint::account::Id as AccountId; #[derive(Debug)] pub struct IBCTestExecutor { @@ -126,8 +125,8 @@ impl IBCTestExecutor { AnyConsensusState::Mock(MockConsensusState(Self::mock_header(height))) } - fn signer() -> AccountId { - AccountId::new([0; 20]) + fn signer() -> String { + "".to_string() } /// Check that chain heights match the ones in the model. diff --git a/relayer/src/chain.rs b/relayer/src/chain.rs index b56c501cea..13f81146fe 100644 --- a/relayer/src/chain.rs +++ b/relayer/src/chain.rs @@ -2,8 +2,6 @@ use std::{sync::Arc, thread}; use crossbeam_channel as channel; use prost_types::Any; -// TODO - tendermint deps should not be here -use tendermint::account::Id as AccountId; use tendermint::block::Height; use tokio::runtime::Runtime as TokioRuntime; @@ -105,7 +103,7 @@ pub trait Chain: Sized { /// Sends one or more transactions with `msgs` to chain. fn send_msgs(&mut self, proto_msgs: Vec) -> Result, Error>; - fn get_signer(&mut self) -> Result; + fn get_signer(&mut self) -> Result; fn get_key(&mut self) -> Result; diff --git a/relayer/src/chain/cosmos.rs b/relayer/src/chain/cosmos.rs index ac09d49c6c..4f85729467 100644 --- a/relayer/src/chain/cosmos.rs +++ b/relayer/src/chain/cosmos.rs @@ -9,7 +9,6 @@ use crossbeam_channel as channel; use prost::Message; use prost_types::Any; use tendermint::abci::Path as TendermintABCIPath; -use tendermint::account::Id as AccountId; use tendermint::block::Height; use tendermint::consensus::Params; use tendermint_light_client::types::LightBlock as TMLightBlock; @@ -363,7 +362,7 @@ impl Chain for CosmosSDKChain { } /// Get the account for the signer - fn get_signer(&mut self) -> Result { + fn get_signer(&mut self) -> Result { crate::time!("get_signer"); // Get the key from key seed file @@ -372,8 +371,9 @@ impl Chain for CosmosSDKChain { .get_key() .map_err(|e| Kind::KeyBase.context(e))?; - let signer: AccountId = - AccountId::from_str(&key.address.to_hex()).map_err(|e| Kind::KeyBase.context(e))?; + // let signer = + // string_to_account(key.address.to_hex()).map_err(|e| Kind::KeyBase.context(e))?; + let signer = key.address.to_hex(); Ok(signer) } diff --git a/relayer/src/chain/handle.rs b/relayer/src/chain/handle.rs index 287f297fe1..34be4ab792 100644 --- a/relayer/src/chain/handle.rs +++ b/relayer/src/chain/handle.rs @@ -4,8 +4,6 @@ use std::sync::Arc; use crossbeam_channel as channel; use dyn_clone::DynClone; use serde::{Serialize, Serializer}; -// FIXME: the handle should not depend on tendermint-specific types -use tendermint::account::Id as AccountId; use ibc::ics04_channel::packet::{PacketMsgType, Sequence}; use ibc::ics24_host::{identifier::ChainId, identifier::ClientId}; @@ -64,7 +62,7 @@ pub enum ChainRequest { }, Signer { - reply_to: ReplyTo, + reply_to: ReplyTo, }, Key { @@ -205,7 +203,7 @@ pub trait ChainHandle: DynClone + Send + Sync + Debug { fn get_minimal_set(&self, from: Height, to: Height) -> Result, Error>; - fn get_signer(&self) -> Result; + fn get_signer(&self) -> Result; fn get_key(&self) -> Result; diff --git a/relayer/src/chain/handle/prod.rs b/relayer/src/chain/handle/prod.rs index 7885fe5194..11c36cf87e 100644 --- a/relayer/src/chain/handle/prod.rs +++ b/relayer/src/chain/handle/prod.rs @@ -1,8 +1,6 @@ use std::fmt::Debug; use crossbeam_channel as channel; -// FIXME: the handle should not depend on tendermint-specific types -use tendermint::account::Id as AccountId; use ibc::ics04_channel::packet::{PacketMsgType, Sequence}; use ibc::{ @@ -85,7 +83,7 @@ impl ChainHandle for ProdChainHandle { self.send(|reply_to| ChainRequest::GetMinimalSet { from, to, reply_to }) } - fn get_signer(&self) -> Result { + fn get_signer(&self) -> Result { self.send(|reply_to| ChainRequest::Signer { reply_to }) } diff --git a/relayer/src/chain/mock.rs b/relayer/src/chain/mock.rs index d32b070bbd..5cddfcd4ea 100644 --- a/relayer/src/chain/mock.rs +++ b/relayer/src/chain/mock.rs @@ -5,7 +5,6 @@ use std::time::Duration; use crossbeam_channel as channel; use prost_types::Any; -use tendermint::account::Id; use tendermint_testgen::light_block::TMLightBlock; use tokio::runtime::Runtime; @@ -23,7 +22,7 @@ use ibc::ics23_commitment::commitment::CommitmentPrefix; use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}; use ibc::mock::context::MockContext; use ibc::mock::host::HostType; -use ibc::test_utils::get_dummy_account_id; +use ibc::test_utils::get_dummy_account_id_raw; use ibc::Height; use ibc_proto::ibc::core::channel::v1::{ PacketState, QueryChannelsRequest, QueryConnectionChannelsRequest, @@ -110,8 +109,8 @@ impl Chain for MockChain { Ok(events) } - fn get_signer(&mut self) -> Result { - Ok(get_dummy_account_id()) + fn get_signer(&mut self) -> Result { + Ok(get_dummy_account_id_raw()) } fn get_key(&mut self) -> Result { diff --git a/relayer/src/chain/runtime.rs b/relayer/src/chain/runtime.rs index eff23f3fa3..1a7ce6a4fa 100644 --- a/relayer/src/chain/runtime.rs +++ b/relayer/src/chain/runtime.rs @@ -1,8 +1,6 @@ use std::{sync::Arc, thread}; use crossbeam_channel as channel; -// FIXME: the handle should not depend on tendermint-specific types -use tendermint::account::Id as AccountId; use tokio::runtime::Runtime as TokioRuntime; use ibc::ics04_channel::packet::{PacketMsgType, Sequence}; @@ -320,7 +318,7 @@ impl ChainRuntime { todo!() } - fn get_signer(&mut self, reply_to: ReplyTo) -> Result<(), Error> { + fn get_signer(&mut self, reply_to: ReplyTo) -> Result<(), Error> { let result = self.chain.get_signer(); reply_to diff --git a/relayer/src/foreign_client.rs b/relayer/src/foreign_client.rs index 36111dcb47..24dd437291 100644 --- a/relayer/src/foreign_client.rs +++ b/relayer/src/foreign_client.rs @@ -16,6 +16,7 @@ use ibc_proto::ibc::core::client::v1::MsgCreateClient as RawMsgCreateClient; use ibc_proto::ibc::core::client::v1::MsgUpdateClient as RawMsgUpdateClient; use crate::chain::handle::ChainHandle; +use ibc::address::encode_to_bech32; #[derive(Debug, Error)] pub enum ForeignClientError { @@ -117,7 +118,13 @@ impl ForeignClient { .map_err(|e| ForeignClientError::ClientCreate(format!("failed while building client consensus state from src chain ({}) with error: {}", self.src_chain.id(), e)))? .wrap_any(); - let msg = MsgCreateAnyClient::new(client_state, consensus_state, signer).map_err(|e| { + //TODO Get acct_prefix + let msg = MsgCreateAnyClient::new( + client_state, + consensus_state, + encode_to_bech32(signer, "cosmos".to_string()).unwrap(), + ) + .map_err(|e| { ForeignClientError::ClientCreate(format!( "failed while building the create client message: {}", e From 4f032187a012b2db7988d7bdceaedb153ea64962 Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Wed, 24 Feb 2021 14:58:18 -0500 Subject: [PATCH 02/11] Logic to add the account_prefix from config to signer (#219) --- relayer/src/chain/cosmos.rs | 6 +++--- relayer/src/foreign_client.rs | 8 +------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/relayer/src/chain/cosmos.rs b/relayer/src/chain/cosmos.rs index 4f85729467..e9892da1f6 100644 --- a/relayer/src/chain/cosmos.rs +++ b/relayer/src/chain/cosmos.rs @@ -60,6 +60,7 @@ use crate::light_client::tendermint::LightClient as TMLightClient; use crate::light_client::LightClient; use super::Chain; +use ibc::address::encode_to_bech32; // TODO size this properly const DEFAULT_MAX_GAS: u64 = 300000; @@ -371,9 +372,8 @@ impl Chain for CosmosSDKChain { .get_key() .map_err(|e| Kind::KeyBase.context(e))?; - // let signer = - // string_to_account(key.address.to_hex()).map_err(|e| Kind::KeyBase.context(e))?; - let signer = key.address.to_hex(); + let signer = + encode_to_bech32(key.address.to_hex(), self.config.clone().account_prefix).unwrap(); Ok(signer) } diff --git a/relayer/src/foreign_client.rs b/relayer/src/foreign_client.rs index 24dd437291..097fc43caa 100644 --- a/relayer/src/foreign_client.rs +++ b/relayer/src/foreign_client.rs @@ -16,7 +16,6 @@ use ibc_proto::ibc::core::client::v1::MsgCreateClient as RawMsgCreateClient; use ibc_proto::ibc::core::client::v1::MsgUpdateClient as RawMsgUpdateClient; use crate::chain::handle::ChainHandle; -use ibc::address::encode_to_bech32; #[derive(Debug, Error)] pub enum ForeignClientError { @@ -119,12 +118,7 @@ impl ForeignClient { .wrap_any(); //TODO Get acct_prefix - let msg = MsgCreateAnyClient::new( - client_state, - consensus_state, - encode_to_bech32(signer, "cosmos".to_string()).unwrap(), - ) - .map_err(|e| { + let msg = MsgCreateAnyClient::new(client_state, consensus_state, signer).map_err(|e| { ForeignClientError::ClientCreate(format!( "failed while building the create client message: {}", e From c97c60ddc138bdeaa9e96b841045b99ce560bbf9 Mon Sep 17 00:00:00 2001 From: Andy Nogueira Date: Wed, 24 Feb 2021 15:40:42 -0500 Subject: [PATCH 03/11] Uncomment tests that are failing --- .../src/ics04_channel/msgs/acknowledgement.rs | 17 ++++++++--------- modules/src/ics04_channel/msgs/recv_packet.rs | 17 ++++++++--------- modules/src/ics04_channel/msgs/timeout.rs | 16 ++++++++-------- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/modules/src/ics04_channel/msgs/acknowledgement.rs b/modules/src/ics04_channel/msgs/acknowledgement.rs index 6f6e31598d..48209f2d85 100644 --- a/modules/src/ics04_channel/msgs/acknowledgement.rs +++ b/modules/src/ics04_channel/msgs/acknowledgement.rs @@ -160,15 +160,14 @@ mod test { }, want_pass: false, }, - //TODO: Check why this is failing now - // Test { - // name: "Missing signer".to_string(), - // raw: RawMsgAcknowledgement { - // signer: "".to_string(), - // ..default_raw_msg.clone() - // }, - // want_pass: false, - // }, + Test { + name: "Missing signer".to_string(), + raw: RawMsgAcknowledgement { + signer: "".to_string(), + ..default_raw_msg.clone() + }, + want_pass: false, + }, Test { name: "Empty proof acked".to_string(), raw: RawMsgAcknowledgement { diff --git a/modules/src/ics04_channel/msgs/recv_packet.rs b/modules/src/ics04_channel/msgs/recv_packet.rs index a1a1a201e4..29769e54b5 100644 --- a/modules/src/ics04_channel/msgs/recv_packet.rs +++ b/modules/src/ics04_channel/msgs/recv_packet.rs @@ -149,15 +149,14 @@ mod test { }, want_pass: false, }, - //TODO: Check why this is failing now - // Test { - // name: "Missing signer".to_string(), - // raw: RawMsgRecvPacket { - // signer: "".to_string(), - // ..default_raw_msg - // }, - // want_pass: false, - // }, + Test { + name: "Missing signer".to_string(), + raw: RawMsgRecvPacket { + signer: "".to_string(), + ..default_raw_msg + }, + want_pass: false, + }, ]; for test in tests { diff --git a/modules/src/ics04_channel/msgs/timeout.rs b/modules/src/ics04_channel/msgs/timeout.rs index 1fdcddefac..63668a767d 100644 --- a/modules/src/ics04_channel/msgs/timeout.rs +++ b/modules/src/ics04_channel/msgs/timeout.rs @@ -171,14 +171,14 @@ mod test { want_pass: false, }, //TODO: Check why this is failing now - // Test { - // name: "Missing signer".to_string(), - // raw: RawMsgTimeout { - // signer: "".to_string(), - // ..default_raw_msg - // }, - // want_pass: false, - // }, + Test { + name: "Missing signer".to_string(), + raw: RawMsgTimeout { + signer: "".to_string(), + ..default_raw_msg + }, + want_pass: false, + }, ]; for test in tests { From d2425106d2953a9ca78acd3171139b704bb5aa96 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 4 Mar 2021 16:21:42 +0100 Subject: [PATCH 04/11] Move bech32 encoding of accounts to cosmos chain impl --- Cargo.lock | 1 - modules/Cargo.toml | 1 - modules/src/address.rs | 29 ----------------------------- modules/src/lib.rs | 11 ++++++----- relayer/src/chain/cosmos.rs | 23 ++++++++++++++++------- relayer/src/error.rs | 6 ++++++ 6 files changed, 28 insertions(+), 43 deletions(-) delete mode 100644 modules/src/address.rs diff --git a/Cargo.lock b/Cargo.lock index f185d4eef6..d1241b2871 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -988,7 +988,6 @@ name = "ibc" version = "0.1.1" dependencies = [ "anomaly", - "bech32 0.8.0", "bytes", "chrono", "dyn-clonable", diff --git a/modules/Cargo.toml b/modules/Cargo.toml index 864dcb2837..e72175e1e6 100644 --- a/modules/Cargo.toml +++ b/modules/Cargo.toml @@ -35,7 +35,6 @@ prost-types = "0.7" bytes = "1.0.0" dyn-clonable = "0.9.0" regex = "1" -bech32 = "0.8.0" subtle-encoding = "0.5" [dependencies.tendermint] diff --git a/modules/src/address.rs b/modules/src/address.rs deleted file mode 100644 index 3ab3869bac..0000000000 --- a/modules/src/address.rs +++ /dev/null @@ -1,29 +0,0 @@ -// TODO - remove when ICS message signer changes from AccountId to String - -use std::convert::TryFrom; - -use anomaly::{BoxError, Context}; -use bech32::ToBase32; -use bech32::{FromBase32, Variant}; - -use std::str::FromStr; -use tendermint::account::Id as AccountId; - -pub fn encode_to_bech32(addr: String, hrp: String) -> Result { - let account = - AccountId::from_str(addr.as_str()).map_err(|e| Context::new("bad address", Some(e)))?; - Ok( - bech32::encode(hrp.as_str(), account.to_base32(), Variant::Bech32) - .map_err(|e| Context::new("cannot generate bech32 account", Some(e.into())))?, - ) -} - -pub fn string_to_account(raw: String) -> Result { - let (_hrp, data, _variant) = - bech32::decode(&raw).map_err(|e| Context::new("bad signer", Some(e.into())))?; - let addr_bytes = - Vec::::from_base32(&data).map_err(|e| Context::new("bad signer", Some(e.into())))?; - - let account_id = AccountId::try_from(addr_bytes).map_err(|e| format!("bad signer: {}", e))?; - Ok(account_id) -} diff --git a/modules/src/lib.rs b/modules/src/lib.rs index 0615bbf910..a5c6639511 100644 --- a/modules/src/lib.rs +++ b/modules/src/lib.rs @@ -23,10 +23,15 @@ //! - ICS 26: Routing //! - Applications: //! - ICS 20: Fungible Token Transfer -pub mod address; + pub mod application; pub mod events; pub mod handler; +pub mod keys; +pub mod macros; +pub mod proofs; +pub mod tx_msg; + pub mod ics02_client; pub mod ics03_connection; pub mod ics04_channel; @@ -36,10 +41,6 @@ pub mod ics18_relayer; pub mod ics23_commitment; pub mod ics24_host; pub mod ics26_routing; -pub mod keys; -pub mod macros; -pub mod proofs; -pub mod tx_msg; mod serializers; diff --git a/relayer/src/chain/cosmos.rs b/relayer/src/chain/cosmos.rs index ff39feaf7d..ca695ebff9 100644 --- a/relayer/src/chain/cosmos.rs +++ b/relayer/src/chain/cosmos.rs @@ -4,19 +4,22 @@ use std::{ }; use anomaly::fail; +use bech32::{ToBase32, Variant}; use bitcoin::hashes::hex::ToHex; use crossbeam_channel as channel; use prost::Message; use prost_types::Any; +use tokio::runtime::Runtime as TokioRuntime; +use tonic::codegen::http::Uri; + use tendermint::abci::Path as TendermintABCIPath; +use tendermint::account::Id as AccountId; use tendermint::block::Height; use tendermint::consensus::Params; use tendermint_light_client::types::LightBlock as TMLightBlock; use tendermint_proto::Protobuf; use tendermint_rpc::query::Query; use tendermint_rpc::{endpoint::broadcast::tx_commit::Response, Client, HttpClient, Order}; -use tokio::runtime::Runtime as TokioRuntime; -use tonic::codegen::http::Uri; use ibc::downcast; use ibc::events::{from_tx_response_event, IbcEvent}; @@ -60,7 +63,6 @@ use crate::light_client::tendermint::LightClient as TMLightClient; use crate::light_client::LightClient; use super::Chain; -use ibc::address::encode_to_bech32; // TODO size this properly const DEFAULT_MAX_GAS: u64 = 300000; @@ -372,10 +374,7 @@ impl Chain for CosmosSdkChain { .get_key() .map_err(|e| Kind::KeyBase.context(e))?; - let signer = - encode_to_bech32(key.address.to_hex(), self.config.clone().account_prefix).unwrap(); - - Ok(signer) + encode_to_bech32(&key.address.to_hex(), &self.config.account_prefix) } /// Get the signing key @@ -1200,3 +1199,13 @@ pub fn tx_result_to_event( } Ok(result) } + +fn encode_to_bech32(address: &str, account_prefix: &str) -> Result { + let account = + AccountId::from_str(address).map_err(|_| Kind::InvalidKeyAddress(address.to_string()))?; + + let encoded = bech32::encode(account_prefix, account.to_base32(), Variant::Bech32) + .map_err(Kind::Bech32Encoding)?; + + Ok(encoded) +} diff --git a/relayer/src/error.rs b/relayer/src/error.rs index cbc73adb09..176fa619f6 100644 --- a/relayer/src/error.rs +++ b/relayer/src/error.rs @@ -156,6 +156,12 @@ pub enum Kind { #[error("the input header is not recognized as a header for this chain")] InvalidInputHeader, + + #[error("invalid key address: {0}")] + InvalidKeyAddress(String), + + #[error("bech32 encoding failed")] + Bech32Encoding(#[from] bech32::Error), } impl Kind { From 9da5d96f5c974bc380dd7599c793e018165d5949 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 4 Mar 2021 17:07:29 +0100 Subject: [PATCH 05/11] Use a newtype for the signer --- .../msgs/transfer.rs | 13 +++---- .../src/ics02_client/msgs/create_client.rs | 10 +++--- .../src/ics02_client/msgs/update_client.rs | 9 ++--- .../ics03_connection/msgs/conn_open_ack.rs | 7 ++-- .../msgs/conn_open_confirm.rs | 10 +++--- .../ics03_connection/msgs/conn_open_init.rs | 7 ++-- .../ics03_connection/msgs/conn_open_try.rs | 9 ++--- .../src/ics04_channel/msgs/acknowledgement.rs | 12 ++++--- .../ics04_channel/msgs/chan_close_confirm.rs | 10 +++--- .../src/ics04_channel/msgs/chan_close_init.rs | 7 ++-- .../src/ics04_channel/msgs/chan_open_ack.rs | 12 ++++--- .../ics04_channel/msgs/chan_open_confirm.rs | 13 ++++--- .../src/ics04_channel/msgs/chan_open_init.rs | 7 ++-- .../src/ics04_channel/msgs/chan_open_try.rs | 10 +++--- modules/src/ics04_channel/msgs/recv_packet.rs | 14 ++++---- modules/src/ics04_channel/msgs/timeout.rs | 16 +++++---- .../ics04_channel/msgs/timeout_on_close.rs | 16 +++++---- modules/src/ics18_relayer/context.rs | 4 +-- modules/src/lib.rs | 1 + modules/src/mock/context.rs | 9 +++-- modules/src/signer.rs | 36 +++++++++++++++++++ modules/src/test_utils.rs | 6 ++-- modules/tests/executor/mod.rs | 5 +-- relayer/src/chain.rs | 4 ++- relayer/src/chain/cosmos.rs | 6 ++-- relayer/src/chain/handle.rs | 24 +++++++------ relayer/src/chain/handle/prod.rs | 3 +- relayer/src/chain/mock.rs | 3 +- relayer/src/chain/runtime.rs | 27 +++++++------- relayer/src/keyring/store.rs | 2 -- relayer/src/link.rs | 32 ++++++++++------- 31 files changed, 216 insertions(+), 128 deletions(-) create mode 100644 modules/src/signer.rs diff --git a/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs b/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs index 42418ed1cd..b0b7efe7a6 100644 --- a/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs +++ b/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs @@ -7,6 +7,7 @@ use ibc_proto::ibc::applications::transfer::v1::MsgTransfer as RawMsgTransfer; use crate::application::ics20_fungible_token_transfer::error::{Error, Kind}; use crate::ics02_client::height::Height; use crate::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.applications.transfer.v1.MsgTransfer"; @@ -23,9 +24,9 @@ pub struct MsgTransfer { /// the tokens to be transferred pub token: Option, /// the sender address - pub sender: String, + pub sender: Signer, /// the recipient address on the destination chain - pub receiver: String, + pub receiver: Signer, /// Timeout height relative to the current block height. /// The timeout is disabled when set to 0. pub timeout_height: Height, @@ -56,8 +57,8 @@ impl TryFrom for MsgTransfer { source_port: raw_msg.source_port.parse().unwrap(), source_channel: raw_msg.source_channel.parse().unwrap(), token: raw_msg.token, - sender: raw_msg.sender, - receiver: raw_msg.receiver, + sender: raw_msg.sender.into(), + receiver: raw_msg.receiver.into(), timeout_height: raw_msg.timeout_height.unwrap().try_into().unwrap(), timeout_timestamp: 0, }) @@ -70,8 +71,8 @@ impl From for RawMsgTransfer { source_port: domain_msg.source_port.to_string(), source_channel: domain_msg.source_channel.to_string(), token: domain_msg.token, - sender: domain_msg.sender, - receiver: domain_msg.receiver, + sender: domain_msg.sender.to_string(), + receiver: domain_msg.receiver.to_string(), timeout_height: Some(domain_msg.timeout_height.try_into().unwrap()), timeout_timestamp: 0, } diff --git a/modules/src/ics02_client/msgs/create_client.rs b/modules/src/ics02_client/msgs/create_client.rs index 0974bd3678..38a05aff09 100644 --- a/modules/src/ics02_client/msgs/create_client.rs +++ b/modules/src/ics02_client/msgs/create_client.rs @@ -13,6 +13,7 @@ use ibc_proto::ibc::core::client::v1::MsgCreateClient as RawMsgCreateClient; use crate::ics02_client::client_def::{AnyClientState, AnyConsensusState}; use crate::ics02_client::error; use crate::ics02_client::error::{Error, Kind}; +use crate::signer::Signer; use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient"; @@ -22,14 +23,14 @@ pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient"; pub struct MsgCreateAnyClient { pub client_state: AnyClientState, pub consensus_state: AnyConsensusState, - pub signer: String, + pub signer: Signer, } impl MsgCreateAnyClient { pub fn new( client_state: AnyClientState, consensus_state: AnyConsensusState, - signer: String, + signer: Signer, ) -> Result { if client_state.client_type() != consensus_state.client_type() { return Err(error::Kind::RawClientAndConsensusStateTypesMismatch { @@ -48,6 +49,7 @@ impl MsgCreateAnyClient { pub fn client_state(&self) -> AnyClientState { self.client_state.clone() } + pub fn consensus_state(&self) -> AnyConsensusState { self.consensus_state.clone() } @@ -84,7 +86,7 @@ impl TryFrom for MsgCreateAnyClient { .map_err(|e| Kind::InvalidRawClientState.context(e))?, AnyConsensusState::try_from(raw_consensus_state) .map_err(|e| Kind::InvalidRawConsensusState.context(e))?, - raw.signer, + raw.signer.into(), ) } } @@ -94,7 +96,7 @@ impl From for RawMsgCreateClient { RawMsgCreateClient { client_state: Some(ics_msg.client_state.into()), consensus_state: Some(ics_msg.consensus_state.into()), - signer: ics_msg.signer, + signer: ics_msg.signer.to_string(), } } } diff --git a/modules/src/ics02_client/msgs/update_client.rs b/modules/src/ics02_client/msgs/update_client.rs index c46ca29455..41cec4140e 100644 --- a/modules/src/ics02_client/msgs/update_client.rs +++ b/modules/src/ics02_client/msgs/update_client.rs @@ -13,6 +13,7 @@ use ibc_proto::ibc::core::client::v1::MsgUpdateClient as RawMsgUpdateClient; use crate::ics02_client::client_def::AnyHeader; use crate::ics02_client::error::{Error, Kind}; use crate::ics24_host::identifier::ClientId; +use crate::signer::Signer; use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpdateClient"; @@ -22,11 +23,11 @@ pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpdateClient"; pub struct MsgUpdateAnyClient { pub client_id: ClientId, pub header: AnyHeader, - pub signer: String, + pub signer: Signer, } impl MsgUpdateAnyClient { - pub fn new(client_id: ClientId, header: AnyHeader, signer: String) -> Self { + pub fn new(client_id: ClientId, header: AnyHeader, signer: Signer) -> Self { MsgUpdateAnyClient { client_id, header, @@ -58,7 +59,7 @@ impl TryFrom for MsgUpdateAnyClient { Ok(MsgUpdateAnyClient { client_id: raw.client_id.parse().unwrap(), header: AnyHeader::try_from(raw_header).unwrap(), - signer: raw.signer, + signer: raw.signer.into(), }) } } @@ -68,7 +69,7 @@ impl From for RawMsgUpdateClient { RawMsgUpdateClient { client_id: ics_msg.client_id.to_string(), header: Some(ics_msg.header.into()), - signer: ics_msg.signer, + signer: ics_msg.signer.to_string(), } } } diff --git a/modules/src/ics03_connection/msgs/conn_open_ack.rs b/modules/src/ics03_connection/msgs/conn_open_ack.rs index 4db795ab60..380725aa6f 100644 --- a/modules/src/ics03_connection/msgs/conn_open_ack.rs +++ b/modules/src/ics03_connection/msgs/conn_open_ack.rs @@ -10,6 +10,7 @@ use crate::ics03_connection::version::Version; use crate::ics23_commitment::commitment::CommitmentProofBytes; use crate::ics24_host::identifier::ConnectionId; use crate::proofs::{ConsensusProof, Proofs}; +use crate::signer::Signer; use crate::tx_msg::Msg; use crate::Height; @@ -23,7 +24,7 @@ pub struct MsgConnectionOpenAck { pub client_state: Option, pub proofs: Proofs, pub version: Version, - pub signer: String, + pub signer: Signer, } impl MsgConnectionOpenAck { @@ -125,7 +126,7 @@ impl TryFrom for MsgConnectionOpenAck { proof_height, ) .map_err(|e| Kind::InvalidProof.context(e))?, - signer: msg.signer, + signer: msg.signer.into(), }) } } @@ -154,7 +155,7 @@ impl From for RawMsgConnectionOpenAck { .consensus_proof() .map_or_else(|| None, |h| Some(h.height().into())), version: Some(ics_msg.version.into()), - signer: ics_msg.signer, + signer: ics_msg.signer.to_string(), } } } diff --git a/modules/src/ics03_connection/msgs/conn_open_confirm.rs b/modules/src/ics03_connection/msgs/conn_open_confirm.rs index 7af3fe6fc0..f08c34b6f2 100644 --- a/modules/src/ics03_connection/msgs/conn_open_confirm.rs +++ b/modules/src/ics03_connection/msgs/conn_open_confirm.rs @@ -6,7 +6,9 @@ use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenConfirm as RawMsgConn use crate::ics03_connection::error::{Error, Kind}; use crate::ics24_host::identifier::ConnectionId; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenConfirm"; @@ -17,7 +19,7 @@ pub const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenConfirm"; pub struct MsgConnectionOpenConfirm { pub connection_id: ConnectionId, pub proofs: Proofs, - pub signer: String, + pub signer: Signer, } impl MsgConnectionOpenConfirm { @@ -62,7 +64,7 @@ impl TryFrom for MsgConnectionOpenConfirm { .map_err(|e| Kind::IdentifierError.context(e))?, proofs: Proofs::new(msg.proof_ack.into(), None, None, None, proof_height) .map_err(|e| Kind::InvalidProof.context(e))?, - signer: msg.signer, + signer: msg.signer.into(), }) } } @@ -73,7 +75,7 @@ impl From for RawMsgConnectionOpenConfirm { connection_id: ics_msg.connection_id.as_str().to_string(), proof_ack: ics_msg.proofs.object_proof().clone().into(), proof_height: Some(ics_msg.proofs.height().into()), - signer: ics_msg.signer, + signer: ics_msg.signer.to_string(), } } } diff --git a/modules/src/ics03_connection/msgs/conn_open_init.rs b/modules/src/ics03_connection/msgs/conn_open_init.rs index 891466d566..065dfd3148 100644 --- a/modules/src/ics03_connection/msgs/conn_open_init.rs +++ b/modules/src/ics03_connection/msgs/conn_open_init.rs @@ -7,6 +7,7 @@ use crate::ics03_connection::connection::Counterparty; use crate::ics03_connection::error::{Error, Kind}; use crate::ics03_connection::version::Version; use crate::ics24_host::identifier::ClientId; +use crate::signer::Signer; use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.connection.v1.MsgConnectionOpenInit"; @@ -20,7 +21,7 @@ pub struct MsgConnectionOpenInit { pub counterparty: Counterparty, pub version: Version, pub delay_period: u64, - pub signer: String, + pub signer: Signer, } impl MsgConnectionOpenInit { @@ -68,7 +69,7 @@ impl TryFrom for MsgConnectionOpenInit { .try_into() .map_err(|e| Kind::InvalidVersion.context(e))?, delay_period: msg.delay_period, - signer: msg.signer, + signer: msg.signer.into(), }) } } @@ -80,7 +81,7 @@ impl From for RawMsgConnectionOpenInit { counterparty: Some(ics_msg.counterparty.into()), version: Some(ics_msg.version.into()), delay_period: ics_msg.delay_period, - signer: ics_msg.signer, + signer: ics_msg.signer.to_string(), } } } diff --git a/modules/src/ics03_connection/msgs/conn_open_try.rs b/modules/src/ics03_connection/msgs/conn_open_try.rs index f91d0b5e8c..b52cf2fc16 100644 --- a/modules/src/ics03_connection/msgs/conn_open_try.rs +++ b/modules/src/ics03_connection/msgs/conn_open_try.rs @@ -12,6 +12,7 @@ use crate::ics03_connection::version::Version; use crate::ics23_commitment::commitment::CommitmentProofBytes; use crate::ics24_host::identifier::{ClientId, ConnectionId}; use crate::proofs::{ConsensusProof, Proofs}; +use crate::signer::Signer; use crate::tx_msg::Msg; use crate::Height; @@ -28,8 +29,8 @@ pub struct MsgConnectionOpenTry { pub counterparty: Counterparty, pub counterparty_versions: Vec, pub proofs: Proofs, - pub delay_period: u64, - pub signer: String, + pub delay_period: u64, // FIXME(romac): Introduce newtype for `delay_period` + pub signer: Signer, } impl MsgConnectionOpenTry { @@ -154,7 +155,7 @@ impl TryFrom for MsgConnectionOpenTry { ) .map_err(|e| Kind::InvalidProof.context(e))?, delay_period: msg.delay_period, - signer: msg.signer, + signer: msg.signer.into(), }) } } @@ -191,7 +192,7 @@ impl From for RawMsgConnectionOpenTry { .proofs .consensus_proof() .map_or_else(|| None, |h| Some(h.height().into())), - signer: ics_msg.signer, + signer: ics_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/acknowledgement.rs b/modules/src/ics04_channel/msgs/acknowledgement.rs index 65932c86a2..1aeff4efb2 100644 --- a/modules/src/ics04_channel/msgs/acknowledgement.rs +++ b/modules/src/ics04_channel/msgs/acknowledgement.rs @@ -6,7 +6,9 @@ use ibc_proto::ibc::core::channel::v1::MsgAcknowledgement as RawMsgAcknowledgeme use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::Packet; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgAcknowledgement"; @@ -18,7 +20,7 @@ pub struct MsgAcknowledgement { pub packet: Packet, acknowledgement: Vec, proofs: Proofs, - signer: String, + signer: Signer, } impl MsgAcknowledgement { @@ -26,7 +28,7 @@ impl MsgAcknowledgement { packet: Packet, acknowledgement: Vec, proofs: Proofs, - signer: String, + signer: Signer, ) -> MsgAcknowledgement { Self { packet, @@ -75,7 +77,7 @@ impl TryFrom for MsgAcknowledgement { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, acknowledgement: raw_msg.acknowledgement, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), proofs, }) } @@ -86,7 +88,7 @@ impl From for RawMsgAcknowledgement { RawMsgAcknowledgement { packet: Some(domain_msg.packet.into()), acknowledgement: domain_msg.acknowledgement, - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), proof_height: Some(domain_msg.proofs.height().into()), proof_acked: domain_msg.proofs.object_proof().clone().into(), } diff --git a/modules/src/ics04_channel/msgs/chan_close_confirm.rs b/modules/src/ics04_channel/msgs/chan_close_confirm.rs index 3ece5bbf23..13be7552cf 100644 --- a/modules/src/ics04_channel/msgs/chan_close_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_close_confirm.rs @@ -6,7 +6,9 @@ use ibc_proto::ibc::core::channel::v1::MsgChannelCloseConfirm as RawMsgChannelCl use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::{ChannelId, PortId}; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseConfirm"; @@ -19,7 +21,7 @@ pub struct MsgChannelCloseConfirm { pub port_id: PortId, pub channel_id: ChannelId, pub proofs: Proofs, - pub signer: String, + pub signer: Signer, } impl Msg for MsgChannelCloseConfirm { @@ -76,7 +78,7 @@ impl TryFrom for MsgChannelCloseConfirm { .parse() .map_err(|e| Kind::IdentifierError.context(e))?, proofs, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), }) } } @@ -88,7 +90,7 @@ impl From for RawMsgChannelCloseConfirm { channel_id: domain_msg.channel_id.to_string(), proof_init: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/chan_close_init.rs b/modules/src/ics04_channel/msgs/chan_close_init.rs index 43e6793539..572f34582b 100644 --- a/modules/src/ics04_channel/msgs/chan_close_init.rs +++ b/modules/src/ics04_channel/msgs/chan_close_init.rs @@ -6,6 +6,7 @@ use ibc_proto::ibc::core::channel::v1::MsgChannelCloseInit as RawMsgChannelClose use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::{ChannelId, PortId}; +use crate::signer::Signer; use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseInit"; @@ -17,7 +18,7 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelCloseInit"; pub struct MsgChannelCloseInit { pub port_id: PortId, pub channel_id: ChannelId, - pub signer: String, + pub signer: Signer, } impl MsgChannelCloseInit { @@ -57,7 +58,7 @@ impl TryFrom for MsgChannelCloseInit { .channel_id .parse() .map_err(|e| Kind::IdentifierError.context(e))?, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), }) } } @@ -67,7 +68,7 @@ impl From for RawMsgChannelCloseInit { RawMsgChannelCloseInit { port_id: domain_msg.port_id.to_string(), channel_id: domain_msg.channel_id.to_string(), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_ack.rs b/modules/src/ics04_channel/msgs/chan_open_ack.rs index 209349ebe7..1d7f29bdc6 100644 --- a/modules/src/ics04_channel/msgs/chan_open_ack.rs +++ b/modules/src/ics04_channel/msgs/chan_open_ack.rs @@ -1,7 +1,9 @@ use crate::ics04_channel::channel::validate_version; use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::{ChannelId, PortId}; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenAck as RawMsgChannelOpenAck; use tendermint_proto::Protobuf; @@ -18,9 +20,9 @@ pub struct MsgChannelOpenAck { pub port_id: PortId, pub channel_id: ChannelId, pub counterparty_channel_id: ChannelId, - pub counterparty_version: String, + pub counterparty_version: String, // FIXME(romac): Introduce newtype for versions pub proofs: Proofs, - pub signer: String, + pub signer: Signer, } impl MsgChannelOpenAck { @@ -90,7 +92,7 @@ impl TryFrom for MsgChannelOpenAck { .map_err(|e| Kind::IdentifierError.context(e))?, counterparty_version: validate_version(raw_msg.counterparty_version)?, proofs, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), }) } } @@ -104,7 +106,7 @@ impl From for RawMsgChannelOpenAck { counterparty_version: domain_msg.counterparty_version.to_string(), proof_try: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_confirm.rs b/modules/src/ics04_channel/msgs/chan_open_confirm.rs index 5fad452d6a..77f1ccefcc 100644 --- a/modules/src/ics04_channel/msgs/chan_open_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_open_confirm.rs @@ -1,7 +1,10 @@ use crate::ics04_channel::error::{Error, Kind}; use crate::ics23_commitment::commitment::CommitmentProofBytes; use crate::ics24_host::identifier::{ChannelId, PortId}; -use crate::{proofs::Proofs, tx_msg::Msg, Height}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; +use crate::Height; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenConfirm as RawMsgChannelOpenConfirm; use tendermint_proto::Protobuf; @@ -19,7 +22,7 @@ pub struct MsgChannelOpenConfirm { pub port_id: PortId, pub channel_id: ChannelId, pub proofs: Proofs, - pub signer: String, + pub signer: Signer, } impl MsgChannelOpenConfirm { @@ -30,7 +33,7 @@ impl MsgChannelOpenConfirm { channel_id: String, proof_ack: CommitmentProofBytes, proofs_height: Height, - signer: String, + signer: Signer, ) -> Result { Ok(Self { port_id: port_id @@ -99,7 +102,7 @@ impl TryFrom for MsgChannelOpenConfirm { .parse() .map_err(|e| Kind::IdentifierError.context(e))?, proofs, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), }) } } @@ -111,7 +114,7 @@ impl From for RawMsgChannelOpenConfirm { channel_id: domain_msg.channel_id.to_string(), proof_ack: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_init.rs b/modules/src/ics04_channel/msgs/chan_open_init.rs index 5f1ed10716..0fa0cf8e5e 100644 --- a/modules/src/ics04_channel/msgs/chan_open_init.rs +++ b/modules/src/ics04_channel/msgs/chan_open_init.rs @@ -1,6 +1,7 @@ use crate::ics04_channel::channel::ChannelEnd; use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::identifier::PortId; +use crate::signer::Signer; use crate::tx_msg::Msg; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenInit as RawMsgChannelOpenInit; @@ -17,7 +18,7 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgChannelOpenInit"; pub struct MsgChannelOpenInit { pub port_id: PortId, pub channel: ChannelEnd, - pub signer: String, + pub signer: Signer, } impl MsgChannelOpenInit { @@ -56,7 +57,7 @@ impl TryFrom for MsgChannelOpenInit { .parse() .map_err(|e| Kind::IdentifierError.context(e))?, channel: raw_msg.channel.ok_or(Kind::MissingChannel)?.try_into()?, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), }) } } @@ -66,7 +67,7 @@ impl From for RawMsgChannelOpenInit { RawMsgChannelOpenInit { port_id: domain_msg.port_id.to_string(), channel: Some(domain_msg.channel.into()), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/chan_open_try.rs b/modules/src/ics04_channel/msgs/chan_open_try.rs index 6541e5a264..86a39be4a7 100644 --- a/modules/src/ics04_channel/msgs/chan_open_try.rs +++ b/modules/src/ics04_channel/msgs/chan_open_try.rs @@ -3,7 +3,9 @@ use crate::ics04_channel::error::{Error, Kind}; use crate::ics24_host::error::ValidationError; use crate::ics24_host::error::ValidationKind; use crate::ics24_host::identifier::{ChannelId, PortId}; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenTry as RawMsgChannelOpenTry; use tendermint_proto::Protobuf; @@ -23,7 +25,7 @@ pub struct MsgChannelOpenTry { pub channel: ChannelEnd, pub counterparty_version: String, pub proofs: Proofs, - pub signer: String, + pub signer: Signer, } impl MsgChannelOpenTry { @@ -97,7 +99,7 @@ impl TryFrom for MsgChannelOpenTry { channel: raw_msg.channel.ok_or(Kind::MissingChannel)?.try_into()?, counterparty_version: validate_version(raw_msg.counterparty_version)?, proofs, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), }; match msg.validate_basic() { @@ -118,7 +120,7 @@ impl From for RawMsgChannelOpenTry { counterparty_version: domain_msg.counterparty_version, proof_init: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/recv_packet.rs b/modules/src/ics04_channel/msgs/recv_packet.rs index 29769e54b5..e46f5206ea 100644 --- a/modules/src/ics04_channel/msgs/recv_packet.rs +++ b/modules/src/ics04_channel/msgs/recv_packet.rs @@ -6,7 +6,9 @@ use ibc_proto::ibc::core::channel::v1::MsgRecvPacket as RawMsgRecvPacket; use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::Packet; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgRecvPacket"; @@ -16,12 +18,12 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgRecvPacket"; #[derive(Clone, Debug, PartialEq)] pub struct MsgRecvPacket { pub packet: Packet, - proofs: Proofs, - signer: String, + pub proofs: Proofs, + pub signer: Signer, } impl MsgRecvPacket { - pub fn new(packet: Packet, proofs: Proofs, signer: String) -> Result { + pub fn new(packet: Packet, proofs: Proofs, signer: Signer) -> Result { Ok(Self { packet, proofs, @@ -68,7 +70,7 @@ impl TryFrom for MsgRecvPacket { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, proofs, - signer: raw_msg.signer, + signer: raw_msg.signer.into(), }) } } @@ -79,7 +81,7 @@ impl From for RawMsgRecvPacket { packet: Some(domain_msg.packet.into()), proof_commitment: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/timeout.rs b/modules/src/ics04_channel/msgs/timeout.rs index 9e62a7aa85..d5fd06672e 100644 --- a/modules/src/ics04_channel/msgs/timeout.rs +++ b/modules/src/ics04_channel/msgs/timeout.rs @@ -6,7 +6,9 @@ use ibc_proto::ibc::core::channel::v1::MsgTimeout as RawMsgTimeout; use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::{Packet, Sequence}; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeout"; @@ -16,9 +18,9 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeout"; #[derive(Clone, Debug, PartialEq)] pub struct MsgTimeout { pub packet: Packet, - next_sequence_recv: Sequence, - proofs: Proofs, - signer: String, + pub next_sequence_recv: Sequence, + pub proofs: Proofs, + pub signer: Signer, } impl MsgTimeout { @@ -26,7 +28,7 @@ impl MsgTimeout { packet: Packet, next_sequence_recv: Sequence, proofs: Proofs, - signer: String, + signer: Signer, ) -> MsgTimeout { Self { packet, @@ -77,7 +79,7 @@ impl TryFrom for MsgTimeout { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, next_sequence_recv: Sequence::from(raw_msg.next_sequence_recv), - signer: raw_msg.signer, + signer: raw_msg.signer.into(), proofs, }) } @@ -90,7 +92,7 @@ impl From for RawMsgTimeout { proof_unreceived: domain_msg.proofs.object_proof().clone().into(), proof_height: Some(domain_msg.proofs.height().into()), next_sequence_recv: domain_msg.next_sequence_recv.into(), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics04_channel/msgs/timeout_on_close.rs b/modules/src/ics04_channel/msgs/timeout_on_close.rs index 4fffbdffba..1cf5dc394b 100644 --- a/modules/src/ics04_channel/msgs/timeout_on_close.rs +++ b/modules/src/ics04_channel/msgs/timeout_on_close.rs @@ -6,7 +6,9 @@ use ibc_proto::ibc::core::channel::v1::MsgTimeoutOnClose as RawMsgTimeoutOnClose use crate::ics04_channel::error::{Error, Kind}; use crate::ics04_channel::packet::{Packet, Sequence}; -use crate::{proofs::Proofs, tx_msg::Msg}; +use crate::proofs::Proofs; +use crate::signer::Signer; +use crate::tx_msg::Msg; pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeoutOnClose"; @@ -16,9 +18,9 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgTimeoutOnClose"; #[derive(Clone, Debug, PartialEq)] pub struct MsgTimeoutOnClose { pub packet: Packet, - next_sequence_recv: Sequence, - proofs: Proofs, - signer: String, + pub next_sequence_recv: Sequence, + pub proofs: Proofs, + pub signer: Signer, } impl MsgTimeoutOnClose { @@ -26,7 +28,7 @@ impl MsgTimeoutOnClose { packet: Packet, next_sequence_recv: Sequence, proofs: Proofs, - signer: String, + signer: Signer, ) -> MsgTimeoutOnClose { Self { packet, @@ -77,7 +79,7 @@ impl TryFrom for MsgTimeoutOnClose { .try_into() .map_err(|e| Kind::InvalidPacket.context(e))?, next_sequence_recv: Sequence::from(raw_msg.next_sequence_recv), - signer: raw_msg.signer, + signer: raw_msg.signer.into(), proofs, }) } @@ -95,7 +97,7 @@ impl From for RawMsgTimeoutOnClose { .map_or_else(Vec::new, |v| v.into()), proof_height: Some(domain_msg.proofs.height().into()), next_sequence_recv: domain_msg.next_sequence_recv.into(), - signer: domain_msg.signer, + signer: domain_msg.signer.to_string(), } } } diff --git a/modules/src/ics18_relayer/context.rs b/modules/src/ics18_relayer/context.rs index f59bd0a984..c0251b58c7 100644 --- a/modules/src/ics18_relayer/context.rs +++ b/modules/src/ics18_relayer/context.rs @@ -1,10 +1,10 @@ use prost_types::Any; -use crate::events::IbcEvent; use crate::ics02_client::client_def::{AnyClientState, AnyHeader}; use crate::ics18_relayer::error::Error; use crate::ics24_host::identifier::ClientId; use crate::Height; +use crate::{events::IbcEvent, signer::Signer}; /// Trait capturing all dependencies (i.e., the context) which algorithms in ICS18 require to /// relay packets between chains. This trait comprises the dependencies towards a single chain. @@ -27,5 +27,5 @@ pub trait Ics18Context { fn send(&mut self, msgs: Vec) -> Result, Error>; /// Temporary solution. Similar to `CosmosSDKChain::key_and_signer()` but simpler. - fn signer(&self) -> String; + fn signer(&self) -> Signer; } diff --git a/modules/src/lib.rs b/modules/src/lib.rs index a5c6639511..4c5072defb 100644 --- a/modules/src/lib.rs +++ b/modules/src/lib.rs @@ -30,6 +30,7 @@ pub mod handler; pub mod keys; pub mod macros; pub mod proofs; +pub mod signer; pub mod tx_msg; pub mod ics02_client; diff --git a/modules/src/mock/context.rs b/modules/src/mock/context.rs index 4f991ef610..3e7a711f57 100644 --- a/modules/src/mock/context.rs +++ b/modules/src/mock/context.rs @@ -6,10 +6,13 @@ use std::error::Error; use prost_types::Any; -use crate::ics02_client::client_def::{AnyClientState, AnyConsensusState, AnyHeader}; use crate::ics02_client::client_type::ClientType; use crate::ics02_client::context::{ClientKeeper, ClientReader}; use crate::ics02_client::error::Error as ICS2Error; +use crate::{ + ics02_client::client_def::{AnyClientState, AnyConsensusState, AnyHeader}, + signer::Signer, +}; use crate::ics05_port::capabilities::Capability; use crate::ics05_port::context::PortReader; @@ -610,8 +613,8 @@ impl Ics18Context for MockContext { Ok(events) } - fn signer(&self) -> String { - "0CDA3F47EF3C4906693B170EF650EB968C5F4B2C".to_string() + fn signer(&self) -> Signer { + "0CDA3F47EF3C4906693B170EF650EB968C5F4B2C".parse().unwrap() } } diff --git a/modules/src/signer.rs b/modules/src/signer.rs new file mode 100644 index 0000000000..b4407ce187 --- /dev/null +++ b/modules/src/signer.rs @@ -0,0 +1,36 @@ +use std::{convert::Infallible, fmt::Display, str::FromStr}; + +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct Signer(String); + +impl Signer { + pub fn new(s: impl ToString) -> Self { + Self(s.to_string()) + } + + pub fn as_str(&self) -> &str { + &self.0 + } +} + +impl Display for Signer { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl From for Signer { + fn from(s: String) -> Self { + Self(s) + } +} + +impl FromStr for Signer { + type Err = Infallible; + + fn from_str(s: &str) -> Result { + Ok(Self(s.to_string())) + } +} diff --git a/modules/src/test_utils.rs b/modules/src/test_utils.rs index 2ce7a9f6d6..87eceb365f 100644 --- a/modules/src/test_utils.rs +++ b/modules/src/test_utils.rs @@ -2,6 +2,8 @@ use tendermint::{block, consensus, evidence, public_key::Algorithm}; +use crate::signer::Signer; + // Needed in mocks. pub fn default_consensus_params() -> consensus::Params { consensus::Params { @@ -27,8 +29,8 @@ pub fn get_dummy_proof() -> Vec { .to_vec() } -pub fn get_dummy_account_id() -> String { - "0CDA3F47EF3C4906693B170EF650EB968C5F4B2C".to_string() +pub fn get_dummy_account_id() -> Signer { + "0CDA3F47EF3C4906693B170EF650EB968C5F4B2C".parse().unwrap() } pub fn get_dummy_bech32_account() -> String { diff --git a/modules/tests/executor/mod.rs b/modules/tests/executor/mod.rs index 152fddba75..eb7fae1b41 100644 --- a/modules/tests/executor/mod.rs +++ b/modules/tests/executor/mod.rs @@ -30,6 +30,7 @@ use ibc::mock::context::MockContext; use ibc::mock::header::MockHeader; use ibc::mock::host::HostType; use ibc::proofs::{ConsensusProof, Proofs}; +use ibc::signer::Signer; use ibc::Height; use step::{Action, ActionOutcome, Chain, Step}; @@ -150,8 +151,8 @@ impl IBCTestExecutor { AnyConsensusState::Mock(MockConsensusState(Self::mock_header(height))) } - fn signer() -> String { - "".to_string() + fn signer() -> Signer { + Signer::new("") } pub fn counterparty(client_id: u64, connection_id: Option) -> Counterparty { diff --git a/relayer/src/chain.rs b/relayer/src/chain.rs index b822b9f33d..07afa275b8 100644 --- a/relayer/src/chain.rs +++ b/relayer/src/chain.rs @@ -16,7 +16,9 @@ use ibc::ics04_channel::packet::{PacketMsgType, Sequence}; use ibc::ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes}; use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}; use ibc::proofs::{ConsensusProof, Proofs}; +use ibc::signer::Signer; use ibc::Height as ICSHeight; + use ibc_proto::ibc::core::channel::v1::{ PacketState, QueryChannelsRequest, QueryConnectionChannelsRequest, QueryNextSequenceReceiveRequest, QueryPacketAcknowledgementsRequest, @@ -103,7 +105,7 @@ pub trait Chain: Sized { /// Sends one or more transactions with `msgs` to chain. fn send_msgs(&mut self, proto_msgs: Vec) -> Result, Error>; - fn get_signer(&mut self) -> Result; + fn get_signer(&mut self) -> Result; fn get_key(&mut self) -> Result; diff --git a/relayer/src/chain/cosmos.rs b/relayer/src/chain/cosmos.rs index ca695ebff9..c0cf7ed383 100644 --- a/relayer/src/chain/cosmos.rs +++ b/relayer/src/chain/cosmos.rs @@ -37,6 +37,7 @@ use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, Po use ibc::ics24_host::Path::ClientConsensusState as ClientConsensusPath; use ibc::ics24_host::Path::ClientState as ClientStatePath; use ibc::ics24_host::{Path, IBC_QUERY_PATH}; +use ibc::signer::Signer; use ibc::Height as ICSHeight; // Support for GRPC use ibc_proto::cosmos::auth::v1beta1::{BaseAccount, QueryAccountRequest}; @@ -365,7 +366,7 @@ impl Chain for CosmosSdkChain { } /// Get the account for the signer - fn get_signer(&mut self) -> Result { + fn get_signer(&mut self) -> Result { crate::time!("get_signer"); // Get the key from key seed file @@ -374,7 +375,8 @@ impl Chain for CosmosSdkChain { .get_key() .map_err(|e| Kind::KeyBase.context(e))?; - encode_to_bech32(&key.address.to_hex(), &self.config.account_prefix) + let bech32 = encode_to_bech32(&key.address.to_hex(), &self.config.account_prefix)?; + Ok(Signer::new(bech32)) } /// Get the signing key diff --git a/relayer/src/chain/handle.rs b/relayer/src/chain/handle.rs index 53246003dd..5e097532fe 100644 --- a/relayer/src/chain/handle.rs +++ b/relayer/src/chain/handle.rs @@ -5,30 +5,34 @@ use crossbeam_channel as channel; use dyn_clone::DynClone; use serde::{Serialize, Serializer}; -use ibc::ics04_channel::packet::{PacketMsgType, Sequence}; -use ibc::ics24_host::{identifier::ChainId, identifier::ClientId}; use ibc::{ events::IbcEvent, ics02_client::client_def::{AnyClientState, AnyConsensusState, AnyHeader}, - ics03_connection::connection::ConnectionEnd, - ics03_connection::version::Version, - ics04_channel::channel::{ChannelEnd, QueryPacketEventDataRequest}, - ics24_host::identifier::{ChannelId, ConnectionId, PortId}, + ics03_connection::{connection::ConnectionEnd, version::Version}, + ics04_channel::{ + channel::{ChannelEnd, QueryPacketEventDataRequest}, + packet::{PacketMsgType, Sequence}, + }, + ics23_commitment::commitment::CommitmentPrefix, + ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}, proofs::Proofs, + signer::Signer, + Height, }; -use ibc::{ics23_commitment::commitment::CommitmentPrefix, Height}; + use ibc_proto::ibc::core::channel::v1::{ PacketState, QueryNextSequenceReceiveRequest, QueryPacketAcknowledgementsRequest, QueryPacketCommitmentsRequest, QueryUnreceivedAcksRequest, QueryUnreceivedPacketsRequest, }; + use ibc_proto::ibc::core::commitment::v1::MerkleProof; -pub use prod::ProdChainHandle; use crate::connection::ConnectionMsgType; use crate::keyring::store::KeyEntry; use crate::{error::Error, event::monitor::EventBatch}; mod prod; +pub use prod::ProdChainHandle; pub type Subscription = channel::Receiver>; @@ -62,7 +66,7 @@ pub enum ChainRequest { }, Signer { - reply_to: ReplyTo, + reply_to: ReplyTo, }, Key { @@ -208,7 +212,7 @@ pub trait ChainHandle: DynClone + Send + Sync + Debug { fn get_minimal_set(&self, from: Height, to: Height) -> Result, Error>; - fn get_signer(&self) -> Result; + fn get_signer(&self) -> Result; fn get_key(&self) -> Result; diff --git a/relayer/src/chain/handle/prod.rs b/relayer/src/chain/handle/prod.rs index a8a157349f..ad943421f6 100644 --- a/relayer/src/chain/handle/prod.rs +++ b/relayer/src/chain/handle/prod.rs @@ -14,6 +14,7 @@ use ibc::{ ics24_host::identifier::ChannelId, ics24_host::identifier::{ClientId, ConnectionId, PortId}, proofs::Proofs, + signer::Signer, Height, }; use ibc_proto::ibc::core::channel::v1::{ @@ -83,7 +84,7 @@ impl ChainHandle for ProdChainHandle { self.send(|reply_to| ChainRequest::GetMinimalSet { from, to, reply_to }) } - fn get_signer(&self) -> Result { + fn get_signer(&self) -> Result { self.send(|reply_to| ChainRequest::Signer { reply_to }) } diff --git a/relayer/src/chain/mock.rs b/relayer/src/chain/mock.rs index ccb187926e..cf734bd252 100644 --- a/relayer/src/chain/mock.rs +++ b/relayer/src/chain/mock.rs @@ -22,6 +22,7 @@ use ibc::ics23_commitment::commitment::CommitmentPrefix; use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}; use ibc::mock::context::MockContext; use ibc::mock::host::HostType; +use ibc::signer::Signer; use ibc::Height; use ibc_proto::ibc::core::channel::v1::{ PacketState, QueryChannelsRequest, QueryConnectionChannelsRequest, @@ -110,7 +111,7 @@ impl Chain for MockChain { Ok(events) } - fn get_signer(&mut self) -> Result { + fn get_signer(&mut self) -> Result { Ok(get_dummy_account_id()) } diff --git a/relayer/src/chain/runtime.rs b/relayer/src/chain/runtime.rs index e6148a3707..f7e124398c 100644 --- a/relayer/src/chain/runtime.rs +++ b/relayer/src/chain/runtime.rs @@ -3,7 +3,6 @@ use std::{sync::Arc, thread}; use crossbeam_channel as channel; use tokio::runtime::Runtime as TokioRuntime; -use ibc::ics04_channel::packet::{PacketMsgType, Sequence}; use ibc::{ events::IbcEvent, ics02_client::{ @@ -11,21 +10,25 @@ use ibc::{ header::Header, state::{ClientState, ConsensusState}, }, - ics03_connection::connection::ConnectionEnd, - ics03_connection::version::Version, - ics04_channel::channel::{ChannelEnd, QueryPacketEventDataRequest}, + ics03_connection::{connection::ConnectionEnd, version::Version}, + ics04_channel::{ + channel::{ChannelEnd, QueryPacketEventDataRequest}, + packet::{PacketMsgType, Sequence}, + }, ics23_commitment::commitment::CommitmentPrefix, - ics24_host::identifier::ChannelId, - ics24_host::identifier::PortId, - ics24_host::identifier::{ClientId, ConnectionId}, + ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId}, proofs::Proofs, + signer::Signer, Height, }; -use ibc_proto::ibc::core::channel::v1::{ - PacketState, QueryNextSequenceReceiveRequest, QueryPacketAcknowledgementsRequest, - QueryPacketCommitmentsRequest, QueryUnreceivedAcksRequest, QueryUnreceivedPacketsRequest, + +use ibc_proto::ibc::core::{ + channel::v1::{ + PacketState, QueryNextSequenceReceiveRequest, QueryPacketAcknowledgementsRequest, + QueryPacketCommitmentsRequest, QueryUnreceivedAcksRequest, QueryUnreceivedPacketsRequest, + }, + commitment::v1::MerkleProof, }; -use ibc_proto::ibc::core::commitment::v1::MerkleProof; use crate::{ config::ChainConfig, @@ -322,7 +325,7 @@ impl ChainRuntime { todo!() } - fn get_signer(&mut self, reply_to: ReplyTo) -> Result<(), Error> { + fn get_signer(&mut self, reply_to: ReplyTo) -> Result<(), Error> { let result = self.chain.get_signer(); reply_to diff --git a/relayer/src/keyring/store.rs b/relayer/src/keyring/store.rs index 9083b962cd..6191168579 100644 --- a/relayer/src/keyring/store.rs +++ b/relayer/src/keyring/store.rs @@ -17,7 +17,6 @@ use k256::ecdsa::{signature::Signer, Signature, SigningKey}; use ripemd160::Ripemd160; use serde_json::Value; use sha2::{Digest, Sha256}; -use tendermint::account::Id as AccountId; use crate::config::ChainConfig; use crate::keyring::errors::{Error, Kind}; @@ -102,7 +101,6 @@ impl KeyRingOperations for KeyRing { let key_json: Value = serde_json::from_str(key_file_content).map_err(|e| Kind::InvalidKey.context(e))?; - let _signer: AccountId; let key: KeyEntry; let _mnemonic: String = "".to_string(); diff --git a/relayer/src/link.rs b/relayer/src/link.rs index f461d53378..690f4e0a99 100644 --- a/relayer/src/link.rs +++ b/relayer/src/link.rs @@ -5,23 +5,25 @@ use prost_types::Any; use thiserror::Error; use tracing::{error, info}; -use ibc::ics04_channel::channel::{ChannelEnd, State}; -use ibc::ics04_channel::msgs::chan_close_confirm::MsgChannelCloseConfirm; -use ibc::ics04_channel::msgs::timeout_on_close::MsgTimeoutOnClose; use ibc::{ downcast, events::{IbcEvent, IbcEventType}, ics03_connection::connection::State as ConnectionState, - ics04_channel::channel::{Order, QueryPacketEventDataRequest, State as ChannelState}, - ics04_channel::events::{SendPacket, WriteAcknowledgement}, - ics04_channel::msgs::acknowledgement::MsgAcknowledgement, - ics04_channel::msgs::recv_packet::MsgRecvPacket, - ics04_channel::msgs::timeout::MsgTimeout, - ics04_channel::packet::{Packet, PacketMsgType, Sequence}, + ics04_channel::{ + channel::{ChannelEnd, Order, QueryPacketEventDataRequest, State as ChannelState}, + events::{SendPacket, WriteAcknowledgement}, + msgs::{ + acknowledgement::MsgAcknowledgement, chan_close_confirm::MsgChannelCloseConfirm, + recv_packet::MsgRecvPacket, timeout::MsgTimeout, timeout_on_close::MsgTimeoutOnClose, + }, + packet::{Packet, PacketMsgType, Sequence}, + }, ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}, + signer::Signer, tx_msg::Msg, Height, }; + use ibc_proto::ibc::core::channel::v1::{ MsgAcknowledgement as RawMsgAck, MsgChannelCloseConfirm as RawMsgChannelCloseConfirm, MsgRecvPacket as RawMsgRecvPacket, MsgTimeout as RawMsgTimeout, @@ -157,7 +159,7 @@ impl RelayPath { .map_err(|e| ChannelError::QueryError(self.src_chain().id(), e))?) } - fn src_signer(&self) -> Result { + fn src_signer(&self) -> Result { self.src_chain.get_signer().map_err(|e| { LinkError::Failed(format!( "could not retrieve signer from src chain {} with error: {}", @@ -167,7 +169,7 @@ impl RelayPath { }) } - fn dst_signer(&self) -> Result { + fn dst_signer(&self) -> Result { self.dst_chain.get_signer().map_err(|e| { LinkError::Failed(format!( "could not retrieve signer from dst chain {} with error: {}", @@ -233,7 +235,9 @@ impl RelayPath { // we get a timeout packet event (this happens for both unordered and ordered channels) // Here we check it the channel is closed on src and send a channel close confirm // to the counterparty. - if self.ordered_channel() && self.src_channel()?.state_matches(&State::Closed) { + if self.ordered_channel() + && self.src_channel()?.state_matches(&ChannelState::Closed) + { info!( "{} => event {} closes the channel", self.src_chain.id(), @@ -948,7 +952,9 @@ impl Link { )) })?; - if a_channel.state_matches(&State::Closed) && b_channel.state_matches(&State::Closed) { + if a_channel.state_matches(&ChannelState::Closed) + && b_channel.state_matches(&ChannelState::Closed) + { Ok(true) } else { Ok(false) From 5eefdc61197640ec404051ebe04b621182a60ba2 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 5 Mar 2021 16:10:15 +0100 Subject: [PATCH 06/11] Allow empty signer in tests --- modules/src/ics04_channel/msgs/acknowledgement.rs | 4 ++-- modules/src/ics04_channel/msgs/recv_packet.rs | 4 ++-- modules/src/ics04_channel/msgs/timeout.rs | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/src/ics04_channel/msgs/acknowledgement.rs b/modules/src/ics04_channel/msgs/acknowledgement.rs index 1aeff4efb2..cb632271bd 100644 --- a/modules/src/ics04_channel/msgs/acknowledgement.rs +++ b/modules/src/ics04_channel/msgs/acknowledgement.rs @@ -163,12 +163,12 @@ mod test { want_pass: false, }, Test { - name: "Missing signer".to_string(), + name: "Empty signer".to_string(), raw: RawMsgAcknowledgement { signer: "".to_string(), ..default_raw_msg.clone() }, - want_pass: false, + want_pass: true, }, Test { name: "Empty proof acked".to_string(), diff --git a/modules/src/ics04_channel/msgs/recv_packet.rs b/modules/src/ics04_channel/msgs/recv_packet.rs index e46f5206ea..24f64dd20e 100644 --- a/modules/src/ics04_channel/msgs/recv_packet.rs +++ b/modules/src/ics04_channel/msgs/recv_packet.rs @@ -152,12 +152,12 @@ mod test { want_pass: false, }, Test { - name: "Missing signer".to_string(), + name: "Empty signer".to_string(), raw: RawMsgRecvPacket { signer: "".to_string(), ..default_raw_msg }, - want_pass: false, + want_pass: true, }, ]; diff --git a/modules/src/ics04_channel/msgs/timeout.rs b/modules/src/ics04_channel/msgs/timeout.rs index d5fd06672e..3345baf6f4 100644 --- a/modules/src/ics04_channel/msgs/timeout.rs +++ b/modules/src/ics04_channel/msgs/timeout.rs @@ -172,14 +172,13 @@ mod test { }, want_pass: false, }, - //TODO: Check why this is failing now Test { - name: "Missing signer".to_string(), + name: "Empty signer".to_string(), raw: RawMsgTimeout { signer: "".to_string(), ..default_raw_msg }, - want_pass: false, + want_pass: true, }, ]; From d3e70ba85d843c726ab2d78c825a384e681b69c1 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 5 Mar 2021 16:18:51 +0100 Subject: [PATCH 07/11] Add plain constructor to all ICS04 messages --- .../src/ics04_channel/msgs/acknowledgement.rs | 6 ++-- .../ics04_channel/msgs/chan_close_confirm.rs | 31 ++++++++++++------- .../src/ics04_channel/msgs/chan_close_init.rs | 8 +++++ .../src/ics04_channel/msgs/chan_open_ack.rs | 19 ++++++++++++ .../ics04_channel/msgs/chan_open_confirm.rs | 28 +++++------------ .../src/ics04_channel/msgs/chan_open_init.rs | 8 +++++ .../src/ics04_channel/msgs/chan_open_try.rs | 20 +++++++++++- modules/src/ics04_channel/msgs/recv_packet.rs | 6 ++-- relayer/src/link.rs | 10 +----- 9 files changed, 88 insertions(+), 48 deletions(-) diff --git a/modules/src/ics04_channel/msgs/acknowledgement.rs b/modules/src/ics04_channel/msgs/acknowledgement.rs index cb632271bd..d2f1a5d9a6 100644 --- a/modules/src/ics04_channel/msgs/acknowledgement.rs +++ b/modules/src/ics04_channel/msgs/acknowledgement.rs @@ -18,9 +18,9 @@ pub const TYPE_URL: &str = "/ibc.core.channel.v1.MsgAcknowledgement"; #[derive(Clone, Debug, PartialEq)] pub struct MsgAcknowledgement { pub packet: Packet, - acknowledgement: Vec, - proofs: Proofs, - signer: Signer, + pub acknowledgement: Vec, // TODO(romac): Introduce a newtype for this + pub proofs: Proofs, + pub signer: Signer, } impl MsgAcknowledgement { diff --git a/modules/src/ics04_channel/msgs/chan_close_confirm.rs b/modules/src/ics04_channel/msgs/chan_close_confirm.rs index 13be7552cf..5bf4e0f305 100644 --- a/modules/src/ics04_channel/msgs/chan_close_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_close_confirm.rs @@ -24,19 +24,16 @@ pub struct MsgChannelCloseConfirm { pub signer: Signer, } -impl Msg for MsgChannelCloseConfirm { - type ValidationError = Error; - - fn route(&self) -> String { - crate::keys::ROUTER_KEY.to_string() - } - - fn type_url(&self) -> String { - TYPE_URL.to_string() +impl MsgChannelCloseConfirm { + pub fn new(port_id: PortId, channel_id: ChannelId, proofs: Proofs, signer: Signer) -> Self { + Self { + port_id, + channel_id, + proofs, + signer, + } } -} -impl MsgChannelCloseConfirm { /// Getter: borrow the `port_id` from this message. pub fn port_id(&self) -> &PortId { &self.port_id @@ -49,6 +46,18 @@ impl MsgChannelCloseConfirm { } } +impl Msg for MsgChannelCloseConfirm { + type ValidationError = Error; + + fn route(&self) -> String { + crate::keys::ROUTER_KEY.to_string() + } + + fn type_url(&self) -> String { + TYPE_URL.to_string() + } +} + impl Protobuf for MsgChannelCloseConfirm {} impl TryFrom for MsgChannelCloseConfirm { diff --git a/modules/src/ics04_channel/msgs/chan_close_init.rs b/modules/src/ics04_channel/msgs/chan_close_init.rs index 572f34582b..00d0c4af34 100644 --- a/modules/src/ics04_channel/msgs/chan_close_init.rs +++ b/modules/src/ics04_channel/msgs/chan_close_init.rs @@ -22,6 +22,14 @@ pub struct MsgChannelCloseInit { } impl MsgChannelCloseInit { + pub fn new(port_id: PortId, channel_id: ChannelId, signer: Signer) -> Self { + Self { + port_id, + channel_id, + signer, + } + } + /// Getter: borrow the `port_id` from this message. pub fn port_id(&self) -> &PortId { &self.port_id diff --git a/modules/src/ics04_channel/msgs/chan_open_ack.rs b/modules/src/ics04_channel/msgs/chan_open_ack.rs index 1d7f29bdc6..ce12a7bd78 100644 --- a/modules/src/ics04_channel/msgs/chan_open_ack.rs +++ b/modules/src/ics04_channel/msgs/chan_open_ack.rs @@ -26,6 +26,24 @@ pub struct MsgChannelOpenAck { } impl MsgChannelOpenAck { + pub fn new( + port_id: PortId, + channel_id: ChannelId, + counterparty_channel_id: ChannelId, + counterparty_version: String, + proofs: Proofs, + signer: Signer, + ) -> Self { + Self { + port_id, + channel_id, + counterparty_channel_id, + counterparty_version, + proofs, + signer, + } + } + /// Getter: borrow the `port_id` from this message. pub fn port_id(&self) -> &PortId { &self.port_id @@ -37,6 +55,7 @@ impl MsgChannelOpenAck { pub fn counterparty_channel_id(&self) -> &ChannelId { &self.counterparty_channel_id } + pub fn counterparty_version(&self) -> &String { &self.counterparty_version } diff --git a/modules/src/ics04_channel/msgs/chan_open_confirm.rs b/modules/src/ics04_channel/msgs/chan_open_confirm.rs index 77f1ccefcc..63431e2ee2 100644 --- a/modules/src/ics04_channel/msgs/chan_open_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_open_confirm.rs @@ -1,10 +1,8 @@ use crate::ics04_channel::error::{Error, Kind}; -use crate::ics23_commitment::commitment::CommitmentProofBytes; use crate::ics24_host::identifier::{ChannelId, PortId}; use crate::proofs::Proofs; use crate::signer::Signer; use crate::tx_msg::Msg; -use crate::Height; use ibc_proto::ibc::core::channel::v1::MsgChannelOpenConfirm as RawMsgChannelOpenConfirm; use tendermint_proto::Protobuf; @@ -26,28 +24,16 @@ pub struct MsgChannelOpenConfirm { } impl MsgChannelOpenConfirm { - #[allow(dead_code)] - // TODO: Not in use (yet), hence private. - fn new( - port_id: String, - channel_id: String, - proof_ack: CommitmentProofBytes, - proofs_height: Height, - signer: Signer, - ) -> Result { - Ok(Self { - port_id: port_id - .parse() - .map_err(|e| Kind::IdentifierError.context(e))?, - channel_id: channel_id - .parse() - .map_err(|e| Kind::IdentifierError.context(e))?, - proofs: Proofs::new(proof_ack, None, None, None, proofs_height) - .map_err(|e| Kind::InvalidProof.context(e))?, + pub fn new(port_id: PortId, channel_id: ChannelId, proofs: Proofs, signer: Signer) -> Self { + Self { + port_id, + channel_id, + proofs, signer, - }) + } } } + impl MsgChannelOpenConfirm { /// Getter: borrow the `port_id` from this message. pub fn port_id(&self) -> &PortId { diff --git a/modules/src/ics04_channel/msgs/chan_open_init.rs b/modules/src/ics04_channel/msgs/chan_open_init.rs index 0fa0cf8e5e..a15ad7caec 100644 --- a/modules/src/ics04_channel/msgs/chan_open_init.rs +++ b/modules/src/ics04_channel/msgs/chan_open_init.rs @@ -22,6 +22,14 @@ pub struct MsgChannelOpenInit { } impl MsgChannelOpenInit { + pub fn new(port_id: PortId, channel: ChannelEnd, signer: Signer) -> Self { + Self { + port_id, + channel, + signer, + } + } + /// Getter: borrow the `port_id` from this message. pub fn port_id(&self) -> &PortId { &self.port_id diff --git a/modules/src/ics04_channel/msgs/chan_open_try.rs b/modules/src/ics04_channel/msgs/chan_open_try.rs index 86a39be4a7..b73bdd0945 100644 --- a/modules/src/ics04_channel/msgs/chan_open_try.rs +++ b/modules/src/ics04_channel/msgs/chan_open_try.rs @@ -23,12 +23,30 @@ pub struct MsgChannelOpenTry { pub port_id: PortId, pub previous_channel_id: Option, pub channel: ChannelEnd, - pub counterparty_version: String, + pub counterparty_version: String, // TODO(romac): newtype this pub proofs: Proofs, pub signer: Signer, } impl MsgChannelOpenTry { + pub fn new( + port_id: PortId, + previous_channel_id: Option, + channel: ChannelEnd, + counterparty_version: String, + proofs: Proofs, + signer: Signer, + ) -> Self { + Self { + port_id, + previous_channel_id, + channel, + counterparty_version, + proofs, + signer, + } + } + /// Getter: borrow the `port_id` from this message. pub fn port_id(&self) -> &PortId { &self.port_id diff --git a/modules/src/ics04_channel/msgs/recv_packet.rs b/modules/src/ics04_channel/msgs/recv_packet.rs index 24f64dd20e..5023f009ae 100644 --- a/modules/src/ics04_channel/msgs/recv_packet.rs +++ b/modules/src/ics04_channel/msgs/recv_packet.rs @@ -23,12 +23,12 @@ pub struct MsgRecvPacket { } impl MsgRecvPacket { - pub fn new(packet: Packet, proofs: Proofs, signer: Signer) -> Result { - Ok(Self { + pub fn new(packet: Packet, proofs: Proofs, signer: Signer) -> MsgRecvPacket { + Self { packet, proofs, signer, - }) + } } } diff --git a/relayer/src/link.rs b/relayer/src/link.rs index 690f4e0a99..4b894c9c8a 100644 --- a/relayer/src/link.rs +++ b/relayer/src/link.rs @@ -719,15 +719,7 @@ impl RelayPath { ) .map_err(|e| LinkError::PacketProofsConstructor(self.src_chain.id(), e))?; - let msg = MsgRecvPacket::new(packet.clone(), proofs.clone(), self.dst_signer()?).map_err( - |e| { - LinkError::Failed(format!( - "error while building the recv packet for src channel {} due to error {}", - packet.source_channel.clone(), - e - )) - }, - )?; + let msg = MsgRecvPacket::new(packet.clone(), proofs.clone(), self.dst_signer()?); info!( "built recv_packet msg {}, proofs at height {:?}", From d752efec3d3613d06ba44eedaa86c42eaa906bfb Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 5 Mar 2021 16:22:57 +0100 Subject: [PATCH 08/11] Remove default implementation of Msg::type_url --- modules/src/tx_msg.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/src/tx_msg.rs b/modules/src/tx_msg.rs index 7b4c8f41c5..d257bf6e0c 100644 --- a/modules/src/tx_msg.rs +++ b/modules/src/tx_msg.rs @@ -15,9 +15,7 @@ pub trait Msg: Clone { } /// Unique type identifier for this message, to support encoding to/from `prost_types::Any`. - fn type_url(&self) -> String { - unimplemented!() - } + fn type_url(&self) -> String; fn to_any + prost::Message>(&self) -> Any { Any { From d9c47a57707b0113d8533b18055a0a9cd1b0fa78 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 5 Mar 2021 16:43:05 +0100 Subject: [PATCH 09/11] Use associated type on Msg trait instead of type parameter on Msg::to_any --- .../msgs/transfer.rs | 1 + .../src/ics02_client/msgs/create_client.rs | 1 + .../src/ics02_client/msgs/update_client.rs | 1 + .../ics03_connection/msgs/conn_open_ack.rs | 1 + .../msgs/conn_open_confirm.rs | 1 + .../ics03_connection/msgs/conn_open_init.rs | 1 + .../ics03_connection/msgs/conn_open_try.rs | 1 + .../src/ics04_channel/msgs/acknowledgement.rs | 1 + .../ics04_channel/msgs/chan_close_confirm.rs | 1 + .../src/ics04_channel/msgs/chan_close_init.rs | 1 + .../src/ics04_channel/msgs/chan_open_ack.rs | 1 + .../ics04_channel/msgs/chan_open_confirm.rs | 1 + .../src/ics04_channel/msgs/chan_open_init.rs | 1 + .../src/ics04_channel/msgs/chan_open_try.rs | 1 + modules/src/ics04_channel/msgs/recv_packet.rs | 1 + modules/src/ics04_channel/msgs/timeout.rs | 1 + .../ics04_channel/msgs/timeout_on_close.rs | 1 + modules/src/tx_msg.rs | 22 ++++++++++--------- relayer/src/channel.rs | 20 ++++++----------- relayer/src/connection.rs | 13 ++++------- relayer/src/foreign_client.rs | 6 ++--- relayer/src/link.rs | 17 ++++++-------- relayer/src/transfer.rs | 16 ++++++-------- 23 files changed, 56 insertions(+), 55 deletions(-) diff --git a/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs b/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs index b0b7efe7a6..6daf3720ab 100644 --- a/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs +++ b/modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs @@ -37,6 +37,7 @@ pub struct MsgTransfer { impl Msg for MsgTransfer { type ValidationError = Error; + type Raw = RawMsgTransfer; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics02_client/msgs/create_client.rs b/modules/src/ics02_client/msgs/create_client.rs index 38a05aff09..197eb902c6 100644 --- a/modules/src/ics02_client/msgs/create_client.rs +++ b/modules/src/ics02_client/msgs/create_client.rs @@ -57,6 +57,7 @@ impl MsgCreateAnyClient { impl Msg for MsgCreateAnyClient { type ValidationError = crate::ics24_host::error::ValidationError; + type Raw = RawMsgCreateClient; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics02_client/msgs/update_client.rs b/modules/src/ics02_client/msgs/update_client.rs index 41cec4140e..227fb8e337 100644 --- a/modules/src/ics02_client/msgs/update_client.rs +++ b/modules/src/ics02_client/msgs/update_client.rs @@ -38,6 +38,7 @@ impl MsgUpdateAnyClient { impl Msg for MsgUpdateAnyClient { type ValidationError = crate::ics24_host::error::ValidationError; + type Raw = RawMsgUpdateClient; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics03_connection/msgs/conn_open_ack.rs b/modules/src/ics03_connection/msgs/conn_open_ack.rs index 380725aa6f..6a2c845cf1 100644 --- a/modules/src/ics03_connection/msgs/conn_open_ack.rs +++ b/modules/src/ics03_connection/msgs/conn_open_ack.rs @@ -65,6 +65,7 @@ impl MsgConnectionOpenAck { impl Msg for MsgConnectionOpenAck { type ValidationError = Error; + type Raw = RawMsgConnectionOpenAck; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics03_connection/msgs/conn_open_confirm.rs b/modules/src/ics03_connection/msgs/conn_open_confirm.rs index f08c34b6f2..cfe48e4dec 100644 --- a/modules/src/ics03_connection/msgs/conn_open_confirm.rs +++ b/modules/src/ics03_connection/msgs/conn_open_confirm.rs @@ -36,6 +36,7 @@ impl MsgConnectionOpenConfirm { impl Msg for MsgConnectionOpenConfirm { type ValidationError = Error; + type Raw = RawMsgConnectionOpenConfirm; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics03_connection/msgs/conn_open_init.rs b/modules/src/ics03_connection/msgs/conn_open_init.rs index 065dfd3148..ff22a260b5 100644 --- a/modules/src/ics03_connection/msgs/conn_open_init.rs +++ b/modules/src/ics03_connection/msgs/conn_open_init.rs @@ -38,6 +38,7 @@ impl MsgConnectionOpenInit { impl Msg for MsgConnectionOpenInit { type ValidationError = Error; + type Raw = RawMsgConnectionOpenInit; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics03_connection/msgs/conn_open_try.rs b/modules/src/ics03_connection/msgs/conn_open_try.rs index b52cf2fc16..0997936442 100644 --- a/modules/src/ics03_connection/msgs/conn_open_try.rs +++ b/modules/src/ics03_connection/msgs/conn_open_try.rs @@ -76,6 +76,7 @@ impl MsgConnectionOpenTry { impl Msg for MsgConnectionOpenTry { type ValidationError = Error; + type Raw = RawMsgConnectionOpenTry; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/acknowledgement.rs b/modules/src/ics04_channel/msgs/acknowledgement.rs index d2f1a5d9a6..1a775ce9f6 100644 --- a/modules/src/ics04_channel/msgs/acknowledgement.rs +++ b/modules/src/ics04_channel/msgs/acknowledgement.rs @@ -41,6 +41,7 @@ impl MsgAcknowledgement { impl Msg for MsgAcknowledgement { type ValidationError = Error; + type Raw = RawMsgAcknowledgement; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/chan_close_confirm.rs b/modules/src/ics04_channel/msgs/chan_close_confirm.rs index 5bf4e0f305..e4c83a61be 100644 --- a/modules/src/ics04_channel/msgs/chan_close_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_close_confirm.rs @@ -48,6 +48,7 @@ impl MsgChannelCloseConfirm { impl Msg for MsgChannelCloseConfirm { type ValidationError = Error; + type Raw = RawMsgChannelCloseConfirm; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/chan_close_init.rs b/modules/src/ics04_channel/msgs/chan_close_init.rs index 00d0c4af34..9d7544e5a1 100644 --- a/modules/src/ics04_channel/msgs/chan_close_init.rs +++ b/modules/src/ics04_channel/msgs/chan_close_init.rs @@ -41,6 +41,7 @@ impl MsgChannelCloseInit { impl Msg for MsgChannelCloseInit { type ValidationError = Error; + type Raw = RawMsgChannelCloseInit; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/chan_open_ack.rs b/modules/src/ics04_channel/msgs/chan_open_ack.rs index ce12a7bd78..bf3edd1969 100644 --- a/modules/src/ics04_channel/msgs/chan_open_ack.rs +++ b/modules/src/ics04_channel/msgs/chan_open_ack.rs @@ -67,6 +67,7 @@ impl MsgChannelOpenAck { impl Msg for MsgChannelOpenAck { type ValidationError = Error; + type Raw = RawMsgChannelOpenAck; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/chan_open_confirm.rs b/modules/src/ics04_channel/msgs/chan_open_confirm.rs index 63431e2ee2..f4820cc583 100644 --- a/modules/src/ics04_channel/msgs/chan_open_confirm.rs +++ b/modules/src/ics04_channel/msgs/chan_open_confirm.rs @@ -49,6 +49,7 @@ impl MsgChannelOpenConfirm { impl Msg for MsgChannelOpenConfirm { type ValidationError = Error; + type Raw = RawMsgChannelOpenConfirm; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/chan_open_init.rs b/modules/src/ics04_channel/msgs/chan_open_init.rs index a15ad7caec..c4009ea77b 100644 --- a/modules/src/ics04_channel/msgs/chan_open_init.rs +++ b/modules/src/ics04_channel/msgs/chan_open_init.rs @@ -43,6 +43,7 @@ impl MsgChannelOpenInit { impl Msg for MsgChannelOpenInit { type ValidationError = Error; + type Raw = RawMsgChannelOpenInit; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/chan_open_try.rs b/modules/src/ics04_channel/msgs/chan_open_try.rs index b73bdd0945..3cec7334b5 100644 --- a/modules/src/ics04_channel/msgs/chan_open_try.rs +++ b/modules/src/ics04_channel/msgs/chan_open_try.rs @@ -66,6 +66,7 @@ impl MsgChannelOpenTry { } impl Msg for MsgChannelOpenTry { type ValidationError = Error; + type Raw = RawMsgChannelOpenTry; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/recv_packet.rs b/modules/src/ics04_channel/msgs/recv_packet.rs index 5023f009ae..54c774eb1e 100644 --- a/modules/src/ics04_channel/msgs/recv_packet.rs +++ b/modules/src/ics04_channel/msgs/recv_packet.rs @@ -34,6 +34,7 @@ impl MsgRecvPacket { impl Msg for MsgRecvPacket { type ValidationError = Error; + type Raw = RawMsgRecvPacket; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/timeout.rs b/modules/src/ics04_channel/msgs/timeout.rs index 3345baf6f4..785b723c5a 100644 --- a/modules/src/ics04_channel/msgs/timeout.rs +++ b/modules/src/ics04_channel/msgs/timeout.rs @@ -41,6 +41,7 @@ impl MsgTimeout { impl Msg for MsgTimeout { type ValidationError = Error; + type Raw = RawMsgTimeout; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/ics04_channel/msgs/timeout_on_close.rs b/modules/src/ics04_channel/msgs/timeout_on_close.rs index 1cf5dc394b..7a0c67ac82 100644 --- a/modules/src/ics04_channel/msgs/timeout_on_close.rs +++ b/modules/src/ics04_channel/msgs/timeout_on_close.rs @@ -41,6 +41,7 @@ impl MsgTimeoutOnClose { impl Msg for MsgTimeoutOnClose { type ValidationError = Error; + type Raw = RawMsgTimeoutOnClose; fn route(&self) -> String { crate::keys::ROUTER_KEY.to_string() diff --git a/modules/src/tx_msg.rs b/modules/src/tx_msg.rs index d257bf6e0c..2f1ef10402 100644 --- a/modules/src/tx_msg.rs +++ b/modules/src/tx_msg.rs @@ -3,27 +3,29 @@ use prost_types::Any; pub trait Msg: Clone { type ValidationError: std::error::Error; + type Raw: From + prost::Message; - // TODO -- clarify what is this function supposed to do & its connection to ICS26 routing mod. + // TODO: Clarify what is this function supposed to do & its connection to ICS26 routing mod. fn route(&self) -> String; - fn get_sign_bytes + prost::Message>(&self) -> Vec { - let mut buf = Vec::new(); - let raw_msg: M = self.clone().into(); - prost::Message::encode(&raw_msg, &mut buf).unwrap(); - buf - } - /// Unique type identifier for this message, to support encoding to/from `prost_types::Any`. fn type_url(&self) -> String; - fn to_any + prost::Message>(&self) -> Any { + #[allow(clippy::wrong_self_convention)] + fn to_any(self) -> Any { Any { type_url: self.type_url(), - value: self.get_sign_bytes::(), + value: self.get_sign_bytes(), } } + fn get_sign_bytes(self) -> Vec { + let mut buf = Vec::new(); + let raw_msg: Self::Raw = self.into(); + prost::Message::encode(&raw_msg, &mut buf).unwrap(); + buf + } + fn validate_basic(&self) -> Result<(), ValidationError> { Ok(()) } diff --git a/relayer/src/channel.rs b/relayer/src/channel.rs index 8de58e36e0..9468d75241 100644 --- a/relayer/src/channel.rs +++ b/relayer/src/channel.rs @@ -14,12 +14,6 @@ use ibc::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}; use ibc::tx_msg::Msg; use ibc::Height; -use ibc_proto::ibc::core::channel::v1::MsgChannelCloseConfirm as RawMsgChannelCloseConfirm; -use ibc_proto::ibc::core::channel::v1::MsgChannelCloseInit as RawMsgChannelCloseInit; -use ibc_proto::ibc::core::channel::v1::MsgChannelOpenAck as RawMsgChannelOpenAck; -use ibc_proto::ibc::core::channel::v1::MsgChannelOpenConfirm as RawMsgChannelOpenConfirm; -use ibc_proto::ibc::core::channel::v1::MsgChannelOpenInit as RawMsgChannelOpenInit; -use ibc_proto::ibc::core::channel::v1::MsgChannelOpenTry as RawMsgChannelOpenTry; use crate::chain::handle::ChainHandle; use crate::connection::Connection; @@ -343,7 +337,7 @@ impl Channel { signer, }; - Ok(vec![new_msg.to_any::()]) + Ok(vec![new_msg.to_any()]) } pub fn build_chan_open_init_and_send(&self) -> Result { @@ -505,7 +499,7 @@ impl Channel { signer, }; - msgs.push(new_msg.to_any::()); + msgs.push(new_msg.to_any()); Ok(msgs) } @@ -594,7 +588,7 @@ impl Channel { signer, }; - msgs.push(new_msg.to_any::()); + msgs.push(new_msg.to_any()); Ok(msgs) } @@ -671,7 +665,7 @@ impl Channel { signer, }; - msgs.push(new_msg.to_any::()); + msgs.push(new_msg.to_any()); Ok(msgs) } @@ -724,7 +718,7 @@ impl Channel { signer, }; - Ok(vec![new_msg.to_any::()]) + Ok(vec![new_msg.to_any()]) } pub fn build_chan_close_init_and_send(&self) -> Result { @@ -802,7 +796,7 @@ impl Channel { signer, }; - msgs.push(new_msg.to_any::()); + msgs.push(new_msg.to_any()); Ok(msgs) } @@ -880,4 +874,4 @@ fn check_destination_channel_state( channel_id ))) } -} +} \ No newline at end of file diff --git a/relayer/src/connection.rs b/relayer/src/connection.rs index baf227531d..43839883c7 100644 --- a/relayer/src/connection.rs +++ b/relayer/src/connection.rs @@ -2,11 +2,6 @@ use prost_types::Any; use thiserror::Error; use tracing::{error, warn}; -use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenAck as RawMsgConnectionOpenAck; -use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenConfirm as RawMsgConnectionOpenConfirm; -use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenInit as RawMsgConnectionOpenInit; -use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenTry as RawMsgConnectionOpenTry; - use ibc::events::IbcEvent; use ibc::ics02_client::height::Height; use ibc::ics03_connection::connection::{ConnectionEnd, Counterparty, State}; @@ -370,7 +365,7 @@ impl Connection { signer, }; - Ok(vec![new_msg.to_any::()]) + Ok(vec![new_msg.to_any()]) } pub fn build_conn_init_and_send(&self) -> Result { @@ -494,7 +489,7 @@ impl Connection { signer, }; - msgs.push(new_msg.to_any::()); + msgs.push(new_msg.to_any()); Ok(msgs) } @@ -590,7 +585,7 @@ impl Connection { signer, }; - msgs.push(new_msg.to_any::()); + msgs.push(new_msg.to_any()); Ok(msgs) } @@ -677,7 +672,7 @@ impl Connection { signer, }; - msgs.push(new_msg.to_any::()); + msgs.push(new_msg.to_any()); Ok(msgs) } diff --git a/relayer/src/foreign_client.rs b/relayer/src/foreign_client.rs index 610fe1ef59..09d7faf5cb 100644 --- a/relayer/src/foreign_client.rs +++ b/relayer/src/foreign_client.rs @@ -13,8 +13,6 @@ use ibc::ics02_client::state::ConsensusState; use ibc::ics24_host::identifier::{ChainId, ClientId}; use ibc::tx_msg::Msg; use ibc::Height; -use ibc_proto::ibc::core::client::v1::MsgCreateClient as RawMsgCreateClient; -use ibc_proto::ibc::core::client::v1::MsgUpdateClient as RawMsgUpdateClient; use crate::chain::handle::ChainHandle; @@ -179,7 +177,7 @@ impl ForeignClient { let res = self .dst_chain - .send_msgs(vec![new_msg.to_any::()]) + .send_msgs(vec![new_msg.to_any()]) .map_err(|e| { ForeignClientError::ClientCreate(format!( "failed sending message to dst chain ({}) with err: {}", @@ -263,7 +261,7 @@ impl ForeignClient { signer, }; - Ok(vec![new_msg.to_any::()]) + Ok(vec![new_msg.to_any()]) } pub fn build_update_client_and_send(&self) -> Result { diff --git a/relayer/src/link.rs b/relayer/src/link.rs index 4b894c9c8a..226aff61dd 100644 --- a/relayer/src/link.rs +++ b/relayer/src/link.rs @@ -25,11 +25,8 @@ use ibc::{ }; use ibc_proto::ibc::core::channel::v1::{ - MsgAcknowledgement as RawMsgAck, MsgChannelCloseConfirm as RawMsgChannelCloseConfirm, - MsgRecvPacket as RawMsgRecvPacket, MsgTimeout as RawMsgTimeout, - MsgTimeoutOnClose as RawMsgTimeoutOnClose, QueryNextSequenceReceiveRequest, - QueryPacketAcknowledgementsRequest, QueryPacketCommitmentsRequest, QueryUnreceivedAcksRequest, - QueryUnreceivedPacketsRequest, + QueryNextSequenceReceiveRequest, QueryPacketAcknowledgementsRequest, + QueryPacketCommitmentsRequest, QueryUnreceivedAcksRequest, QueryUnreceivedPacketsRequest, }; use crate::chain::handle::ChainHandle; @@ -277,7 +274,7 @@ impl RelayPath { signer: self.dst_signer()?, }; - Ok(new_msg.to_any::()) + Ok(new_msg.to_any()) } fn handle_packet_event(&mut self, event: &IbcEvent) -> Result<(), LinkError> { @@ -727,7 +724,7 @@ impl RelayPath { proofs.height() ); - Ok(msg.to_any::()) + Ok(msg.to_any()) } fn build_ack_from_recv_event(&self, event: &WriteAcknowledgement) -> Result { @@ -756,7 +753,7 @@ impl RelayPath { proofs.height() ); - Ok(msg.to_any::()) + Ok(msg.to_any()) } fn build_timeout_packet(&self, packet: &Packet, height: Height) -> Result { @@ -797,7 +794,7 @@ impl RelayPath { proofs.height() ); - Ok(msg.to_any::()) + Ok(msg.to_any()) } fn build_timeout_on_close_packet( @@ -829,7 +826,7 @@ impl RelayPath { proofs.height() ); - Ok(msg.to_any::()) + Ok(msg.to_any()) } fn build_recv_or_timeout_from_send_packet_event( diff --git a/relayer/src/transfer.rs b/relayer/src/transfer.rs index 26d30f4404..46438c1156 100644 --- a/relayer/src/transfer.rs +++ b/relayer/src/transfer.rs @@ -1,17 +1,15 @@ -use crate::chain::{Chain, CosmosSdkChain}; use thiserror::Error; use tracing::error; -use crate::config::ChainConfig; -use crate::error::Error; +use ibc::application::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; use ibc::events::IbcEvent; +use ibc::ics24_host::identifier::ChainId; use ibc::ics24_host::identifier::{ChannelId, PortId}; use ibc::tx_msg::Msg; -use ibc::{ - application::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer, - ics24_host::identifier::ChainId, -}; -use ibc_proto::ibc::applications::transfer::v1::MsgTransfer as RawMsgTransfer; + +use crate::chain::{Chain, CosmosSdkChain}; +use crate::config::ChainConfig; +use crate::error::Error; #[derive(Debug, Error)] pub enum PacketError { @@ -69,7 +67,7 @@ pub fn build_and_send_transfer_messages( timeout_timestamp: 0, }; - let raw_msg = msg.to_any::(); + let raw_msg = msg.to_any(); let msgs = vec![raw_msg; opts.number_msgs]; let events = packet_src_chain From c325894b27835718fb7fd11a3545e9ddf238f274 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Fri, 5 Mar 2021 16:48:49 +0100 Subject: [PATCH 10/11] Formatting --- relayer/src/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/relayer/src/channel.rs b/relayer/src/channel.rs index 9468d75241..3f9c404369 100644 --- a/relayer/src/channel.rs +++ b/relayer/src/channel.rs @@ -874,4 +874,4 @@ fn check_destination_channel_state( channel_id ))) } -} \ No newline at end of file +} From 397d0cdc8ad889a06e966c682a1499f0cdfcd9c4 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Thu, 11 Mar 2021 10:52:13 +0100 Subject: [PATCH 11/11] Remove proto-compiler lockfile --- proto-compiler/Cargo.lock | 1184 ------------------------------------- 1 file changed, 1184 deletions(-) delete mode 100644 proto-compiler/Cargo.lock diff --git a/proto-compiler/Cargo.lock b/proto-compiler/Cargo.lock deleted file mode 100644 index cb87ef0bdf..0000000000 --- a/proto-compiler/Cargo.lock +++ /dev/null @@ -1,1184 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "anyhow" -version = "1.0.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" - -[[package]] -name = "argh" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91792f088f87cdc7a2cfb1d617fa5ea18d7f1dc22ef0e1b5f82f3157cdc522be" -dependencies = [ - "argh_derive", - "argh_shared", -] - -[[package]] -name = "argh_derive" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4eb0c0c120ad477412dc95a4ce31e38f2113e46bd13511253f79196ca68b067" -dependencies = [ - "argh_shared", - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "argh_shared" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "781f336cc9826dbaddb9754cb5db61e64cab4f69668bd19dcc4a0394a86f4cb1" - -[[package]] -name = "async-stream" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c" -dependencies = [ - "async-stream-impl", - "futures-core", -] - -[[package]] -name = "async-stream-impl" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "async-trait" -version = "0.1.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "bytes" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" - -[[package]] -name = "bytes" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" - -[[package]] -name = "cc" -version = "1.0.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95752358c8f7552394baf48cd82695b345628ad3f170d607de3ca03b8dacca15" -dependencies = [ - "jobserver", -] - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "fixedbitset" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" -dependencies = [ - "matches", - "percent-encoding", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] -name = "futures-channel" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b7109687aa4e177ef6fe84553af6280ef2778bdb7783ba44c9dc3399110fe64" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "847ce131b72ffb13b6109a221da9ad97a64cbe48feb1028356b836b47b8f1748" - -[[package]] -name = "futures-sink" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f878195a49cee50e006b02b93cf7e0a95a38ac7b776b4c4d9cc1207cd20fcb3d" - -[[package]] -name = "futures-task" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c554eb5bf48b2426c4771ab68c6b14468b6e76cc90996f528c3338d761a4d0d" - -[[package]] -name = "futures-util" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d304cff4a7b99cfb7986f7d43fbe93d175e72e704a8860787cc95e9ffd85cbd2" -dependencies = [ - "futures-core", - "futures-task", - "pin-project 1.0.2", - "pin-utils", -] - -[[package]] -name = "getrandom" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.10.2+wasi-snapshot-preview1", -] - -[[package]] -name = "git2" -version = "0.13.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6f1a0238d7f8f8fd5ee642f4ebac4dbc03e03d1f78fbe7a3ede35dcf7e2224" -dependencies = [ - "bitflags", - "libc", - "libgit2-sys", - "log", - "openssl-probe", - "openssl-sys", - "url", -] - -[[package]] -name = "h2" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" -dependencies = [ - "bytes 1.0.1", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", - "tracing-futures", -] - -[[package]] -name = "hashbrown" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" - -[[package]] -name = "heck" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" -dependencies = [ - "unicode-segmentation", -] - -[[package]] -name = "http" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" -dependencies = [ - "bytes 0.5.6", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2861bd27ee074e5ee891e8b539837a9430012e249d7f0ca2d795650f579c1994" -dependencies = [ - "bytes 1.0.1", - "http", -] - -[[package]] -name = "httparse" -version = "1.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" - -[[package]] -name = "httpdate" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" - -[[package]] -name = "hyper" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12219dc884514cb4a6a03737f4413c0e01c23a1b059b0156004b23f1e19dccbe" -dependencies = [ - "bytes 1.0.1", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project 1.0.2", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "ibc-proto-compiler" -version = "0.2.0" -dependencies = [ - "argh", - "git2", - "prost-build", - "tempdir", - "tonic", - "tonic-build", - "walkdir", -] - -[[package]] -name = "idna" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "itertools" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" - -[[package]] -name = "jobserver" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" -dependencies = [ - "libc", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" - -[[package]] -name = "libgit2-sys" -version = "0.12.14+1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f25af58e6495f7caf2919d08f212de550cfa3ed2f5e744988938ea292b9f549" -dependencies = [ - "cc", - "libc", - "libssh2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", -] - -[[package]] -name = "libssh2-sys" -version = "0.2.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df40b13fe7ea1be9b9dffa365a51273816c345fc1811478b57ed7d964fbfc4ce" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "libz-sys" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "log" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" -dependencies = [ - "cfg-if 0.1.10", -] - -[[package]] -name = "matches" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" - -[[package]] -name = "memchr" -version = "2.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" - -[[package]] -name = "mio" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e50ae3f04d169fcc9bde0b547d1c205219b7157e07ded9c5aff03e0637cb3ed7" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897" -dependencies = [ - "socket2", - "winapi", -] - -[[package]] -name = "multimap" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" - -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "petgraph" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" -dependencies = [ - "fixedbitset", - "indexmap", -] - -[[package]] -name = "pin-project" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" -dependencies = [ - "pin-project-internal 0.4.27", -] - -[[package]] -name = "pin-project" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ccc2237c2c489783abd8c4c80e5450fc0e98644555b1364da68cc29aa151ca7" -dependencies = [ - "pin-project-internal 1.0.2", -] - -[[package]] -name = "pin-project-internal" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - -[[package]] -name = "ppv-lite86" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" - -[[package]] -name = "proc-macro2" -version = "1.0.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "prost" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" -dependencies = [ - "bytes 1.0.1", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32d3ebd75ac2679c2af3a92246639f9fcc8a442ee420719cc4fe195b98dd5fa3" -dependencies = [ - "bytes 1.0.1", - "heck", - "itertools", - "log", - "multimap", - "petgraph", - "prost", - "prost-types", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "169a15f3008ecb5160cba7d37bcd690a7601b6d30cfb87a117d45e59d52af5d4" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "prost-types" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" -dependencies = [ - "bytes 1.0.1", - "prost", -] - -[[package]] -name = "quote" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -dependencies = [ - "fuchsia-cprng", - "libc", - "rand_core 0.3.1", - "rdrand", - "winapi", -] - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.15", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" -dependencies = [ - "libc", - "rand_chacha 0.3.0", - "rand_core 0.6.1", - "rand_hc 0.3.0", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.15", -] - -[[package]] -name = "rand_core" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" -dependencies = [ - "getrandom 0.2.2", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_hc" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" -dependencies = [ - "rand_core 0.6.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "redox_syscall" -version = "0.1.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" - -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" - -[[package]] -name = "socket2" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c29947abdee2a218277abeca306f25789c938e500ea5a9d4b12a5a504466902" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", - "winapi", -] - -[[package]] -name = "syn" -version = "1.0.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8833e20724c24de12bbaba5ad230ea61c3eafb05b881c7c9d3cfe8638b187e68" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "tempdir" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" -dependencies = [ - "rand 0.4.6", - "remove_dir_all", -] - -[[package]] -name = "tempfile" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "rand 0.7.3", - "redox_syscall", - "remove_dir_all", - "winapi", -] - -[[package]] -name = "thiserror" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tinyvec" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "tokio" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8efab2086f17abcddb8f756117665c958feee6b2e39974c2f1600592ab3a4195" -dependencies = [ - "autocfg", - "bytes 1.0.1", - "libc", - "memchr", - "mio", - "pin-project-lite", - "tokio-macros", -] - -[[package]] -name = "tokio-macros" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42517d2975ca3114b22a16192634e8241dc5cc1f130be194645970cc1c371494" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tokio-stream" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76066865172052eb8796c686f0b441a93df8b08d40a950b062ffb9a426f00edd" -dependencies = [ - "futures-core", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "tokio-util" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb971a26599ffd28066d387f109746df178eff14d5ea1e235015c5601967a4b" -dependencies = [ - "async-stream", - "bytes 1.0.1", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", - "tokio-stream", -] - -[[package]] -name = "tonic" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ba8f479158947373b6df40cf48f4779bb25c99ca3c661bd95e0ab1963ad8b0e" -dependencies = [ - "async-stream", - "async-trait", - "base64", - "bytes 1.0.1", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "percent-encoding", - "pin-project 1.0.2", - "prost", - "prost-derive", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tower-service", - "tracing", - "tracing-futures", -] - -[[package]] -name = "tonic-build" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e8546fd40d56d28089835c0a81bb396848103b00f888aea42d46eb5974df07" -dependencies = [ - "proc-macro2", - "prost-build", - "quote", - "syn", -] - -[[package]] -name = "tower" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd7b451959622e21de79261673d658a0944b835012c58c51878ea55957fb51a" -dependencies = [ - "futures-core", - "futures-util", - "indexmap", - "pin-project 1.0.2", - "rand 0.8.3", - "slab", - "tokio", - "tokio-stream", - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-layer" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "343bc9466d3fe6b0f960ef45960509f84480bf4fd96f92901afe7ff3df9d3a62" - -[[package]] -name = "tower-service" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" - -[[package]] -name = "tracing" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" -dependencies = [ - "cfg-if 1.0.0", - "log", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e0ccfc3378da0cce270c946b676a376943f5cd16aeba64568e7939806f4ada" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tracing-futures" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7bb6f14721aa00656086e9335d363c5c8747bae02ebe32ea2c7dece5689b4c" -dependencies = [ - "pin-project 0.4.27", - "tracing", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "unicode-bidi" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -dependencies = [ - "matches", -] - -[[package]] -name = "unicode-normalization" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-segmentation" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" - -[[package]] -name = "unicode-xid" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" - -[[package]] -name = "url" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" -dependencies = [ - "form_urlencoded", - "idna", - "matches", - "percent-encoding", -] - -[[package]] -name = "vcpkg" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" - -[[package]] -name = "walkdir" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" -dependencies = [ - "same-file", - "winapi", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[package]] -name = "which" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c14ef7e1b8b8ecfc75d5eca37949410046e66f15d185c01d70824f1f8111ef" -dependencies = [ - "libc", - "thiserror", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"