From fb6de4e945cafd1b20c6b27716cd6a59d3d46c88 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 13 May 2022 17:38:48 +0200 Subject: [PATCH 01/36] fix coding for ack and ftt --- shared/src/ledger/ibc/handler.rs | 79 +++++++++++++++++++------------ shared/src/ledger/ibc/vp/mod.rs | 8 ++-- shared/src/ledger/ibc/vp/token.rs | 19 ++++---- shared/src/types/ibc/data.rs | 63 ++++++++++++++++++------ shared/src/types/token.rs | 7 +-- tests/src/vm_host_env/ibc.rs | 6 +-- 6 files changed, 115 insertions(+), 67 deletions(-) diff --git a/shared/src/ledger/ibc/handler.rs b/shared/src/ledger/ibc/handler.rs index ac510d8b91c..55453ed0203 100644 --- a/shared/src/ledger/ibc/handler.rs +++ b/shared/src/ledger/ibc/handler.rs @@ -675,9 +675,17 @@ pub trait IbcActions { msg: &MsgRecvPacket, ) -> std::result::Result<(), Self::Error> { // check the packet data - if let Ok(data) = serde_json::from_slice(&msg.packet.data) { - self.receive_token(&msg.packet, &data)?; - } + let packet_ack = + if let Ok(data) = serde_json::from_slice(&msg.packet.data) { + match self.receive_token(&msg.packet, &data) { + Ok(_) => PacketAck::result_success(), + Err(_) => PacketAck::result_error( + "receiving a token failed".to_string(), + ), + } + } else { + PacketAck::result_error("unknown packet data".to_string()) + }; // store the receipt let receipt_key = storage::receipt_key( @@ -693,7 +701,7 @@ pub trait IbcActions { &msg.packet.destination_channel, msg.packet.sequence, ); - let ack = PacketAck::default().encode_to_vec(); + let ack = packet_ack.encode_to_vec(); let ack_commitment = sha2::Sha256::digest(&ack).to_vec(); self.write_ibc_data(&ack_key, ack_commitment)?; @@ -718,6 +726,14 @@ pub trait IbcActions { &mut self, msg: &MsgAcknowledgement, ) -> std::result::Result<(), Self::Error> { + let ack = PacketAck::try_from(msg.acknowledgement.clone()) + .map_err(Error::IbcData)?; + if !ack.is_success() { + if let Ok(data) = serde_json::from_slice(&msg.packet.data) { + self.refund_token(&msg.packet, &data)?; + } + } + let commitment_key = storage::commitment_key( &msg.packet.source_port, &msg.packet.source_channel, @@ -725,6 +741,14 @@ pub trait IbcActions { ); self.delete_ibc_data(&commitment_key)?; + // get and increment the next sequence ack + let port_channel_id = port_channel_id( + msg.packet.source_port.clone(), + msg.packet.source_channel, + ); + let seq_key = storage::next_sequence_ack_key(&port_channel_id); + self.get_and_inc_sequence(&seq_key)?; + let event = make_ack_event(msg.packet.clone()).try_into().unwrap(); self.emit_ibc_event(event)?; @@ -917,13 +941,12 @@ pub trait IbcActions { data.sender, e )) })?; - let token_str = - data.denomination.split('/').last().ok_or_else(|| { - Error::SendingToken(format!( - "No token was specified: {}", - data.denomination - )) - })?; + let token_str = data.denom.split('/').last().ok_or_else(|| { + Error::SendingToken(format!( + "No token was specified: {}", + data.denom + )) + })?; let token = Address::decode(token_str).map_err(|e| { Error::SendingToken(format!( "Invalid token address: token {}, error {}", @@ -937,13 +960,13 @@ pub trait IbcActions { )) })?; - // check the denomination field + // check the denom field let prefix = format!( "{}/{}/", msg.source_port.clone(), msg.source_channel.clone() ); - if data.denomination.starts_with(&prefix) { + if data.denom.starts_with(&prefix) { // sink zone let burn = Address::Internal(InternalAddress::IbcBurn); self.transfer_token(&source, &burn, &token, amount)?; @@ -982,13 +1005,12 @@ pub trait IbcActions { data.receiver, e )) })?; - let token_str = - data.denomination.split('/').last().ok_or_else(|| { - Error::ReceivingToken(format!( - "No token was specified: {}", - data.denomination - )) - })?; + let token_str = data.denom.split('/').last().ok_or_else(|| { + Error::ReceivingToken(format!( + "No token was specified: {}", + data.denom + )) + })?; let token = Address::decode(token_str).map_err(|e| { Error::ReceivingToken(format!( "Invalid token address: token {}, error {}", @@ -1007,7 +1029,7 @@ pub trait IbcActions { packet.source_port.clone(), packet.source_channel.clone() ); - if data.denomination.starts_with(&prefix) { + if data.denom.starts_with(&prefix) { // unescrow the token because this chain is the source let escrow = Address::Internal(InternalAddress::ibc_escrow_address( @@ -1035,13 +1057,12 @@ pub trait IbcActions { data.sender, e )) })?; - let token_str = - data.denomination.split('/').last().ok_or_else(|| { - Error::ReceivingToken(format!( - "No token was specified: {}", - data.denomination - )) - })?; + let token_str = data.denom.split('/').last().ok_or_else(|| { + Error::ReceivingToken(format!( + "No token was specified: {}", + data.denom + )) + })?; let token = Address::decode(token_str).map_err(|e| { Error::ReceivingToken(format!( "Invalid token address: token {}, error {}", @@ -1060,7 +1081,7 @@ pub trait IbcActions { packet.source_port.clone(), packet.source_channel.clone() ); - if data.denomination.starts_with(&prefix) { + if data.denom.starts_with(&prefix) { // mint the token because the sender chain is the sink zone let mint = Address::Internal(InternalAddress::IbcMint); self.transfer_token(&mint, &dest, &token, amount)?; diff --git a/shared/src/ledger/ibc/vp/mod.rs b/shared/src/ledger/ibc/vp/mod.rs index b5dec0293c6..fa500d5e430 100644 --- a/shared/src/ledger/ibc/vp/mod.rs +++ b/shared/src/ledger/ibc/vp/mod.rs @@ -1570,7 +1570,7 @@ mod tests { .write(&key, PacketReceipt::default().as_bytes().to_vec()) .expect("write failed"); let key = ack_key(&get_port_id(), &get_channel_id(), sequence); - let ack = PacketAck::default().encode_to_vec(); + let ack = PacketAck::result_success().encode_to_vec(); write_log.write(&key, ack).expect("write failed"); let tx_code = vec![]; @@ -1648,7 +1648,7 @@ mod tests { write_log.commit_block(&mut storage).expect("commit failed"); // prepare data - let ack = PacketAck::default().encode_to_vec(); + let ack = PacketAck::result_success().encode_to_vec(); let proof_packet = CommitmentProofBytes::try_from(vec![0]).unwrap(); let proofs = Proofs::new(proof_packet, None, None, None, Height::new(0, 1)) @@ -1837,7 +1837,7 @@ mod tests { &msg.packet.destination_channel, msg.packet.sequence, ); - let ack = PacketAck::default().encode_to_vec(); + let ack = PacketAck::result_success().encode_to_vec(); write_log.write(&ack_key, ack).expect("write failed"); write_log.commit_tx(); @@ -1886,7 +1886,7 @@ mod tests { .expect("write failed"); let ack_key = ack_key(&get_port_id(), &get_channel_id(), Sequence::from(1)); - let ack = PacketAck::default().encode_to_vec(); + let ack = PacketAck::result_success().encode_to_vec(); write_log.write(&ack_key, ack).expect("write failed"); write_log.commit_tx(); diff --git a/shared/src/ledger/ibc/vp/token.rs b/shared/src/ledger/ibc/vp/token.rs index 06181bdd45e..da67f222c7e 100644 --- a/shared/src/ledger/ibc/vp/token.rs +++ b/shared/src/ledger/ibc/vp/token.rs @@ -121,18 +121,17 @@ where { fn validate_sending_token(&self, msg: &MsgTransfer) -> Result { let data = FungibleTokenPacketData::from(msg.clone()); - let token_str = - data.denomination.split('/').last().ok_or(Error::NoToken)?; + let token_str = data.denom.split('/').last().ok_or(Error::NoToken)?; let token = Address::decode(token_str).map_err(Error::Address)?; let amount = Amount::from_str(&data.amount).map_err(Error::Amount)?; - // check the denomination field + // check the denom field let prefix = format!( "{}/{}/", msg.source_port.clone(), msg.source_channel.clone() ); - let change = if data.denomination.starts_with(&prefix) { + let change = if data.denom.starts_with(&prefix) { // sink zone let target = Address::Internal(InternalAddress::IbcBurn); let target_key = token::balance_key(&token, &target); @@ -174,8 +173,7 @@ where let data: FungibleTokenPacketData = serde_json::from_slice(&packet.data) .map_err(Error::DecodingPacketData)?; - let token_str = - data.denomination.split('/').last().ok_or(Error::NoToken)?; + let token_str = data.denom.split('/').last().ok_or(Error::NoToken)?; let token = Address::decode(token_str).map_err(Error::Address)?; let amount = Amount::from_str(&data.amount).map_err(Error::Amount)?; @@ -184,7 +182,7 @@ where packet.source_port.clone(), packet.source_channel.clone() ); - let change = if data.denomination.starts_with(&prefix) { + let change = if data.denom.starts_with(&prefix) { // this chain is the source let source = Address::Internal(InternalAddress::ibc_escrow_address( @@ -226,18 +224,17 @@ where let data: FungibleTokenPacketData = serde_json::from_slice(&packet.data) .map_err(Error::DecodingPacketData)?; - let token_str = - data.denomination.split('/').last().ok_or(Error::NoToken)?; + let token_str = data.denom.split('/').last().ok_or(Error::NoToken)?; let token = Address::decode(token_str).map_err(Error::Address)?; let amount = Amount::from_str(&data.amount).map_err(Error::Amount)?; - // check the denomination field + // check the denom field let prefix = format!( "{}/{}/", packet.source_port.clone(), packet.source_channel.clone() ); - let change = if data.denomination.starts_with(&prefix) { + let change = if data.denom.starts_with(&prefix) { // sink zone: mint the token for the refund let source = Address::Internal(InternalAddress::IbcMint); let source_key = token::balance_key(&token, &source); diff --git a/shared/src/types/ibc/data.rs b/shared/src/types/ibc/data.rs index 4c5d5f2469c..947142ab97a 100644 --- a/shared/src/types/ibc/data.rs +++ b/shared/src/types/ibc/data.rs @@ -16,7 +16,9 @@ use crate::ibc::core::ics03_connection::msgs::conn_open_confirm::MsgConnectionOp use crate::ibc::core::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit; use crate::ibc::core::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry; use crate::ibc::core::ics03_connection::msgs::ConnectionMsg; -use crate::ibc::core::ics04_channel::msgs::acknowledgement::MsgAcknowledgement; +use crate::ibc::core::ics04_channel::msgs::acknowledgement::{ + Acknowledgement, MsgAcknowledgement, +}; use crate::ibc::core::ics04_channel::msgs::chan_close_confirm::MsgChannelCloseConfirm; use crate::ibc::core::ics04_channel::msgs::chan_close_init::MsgChannelCloseInit; use crate::ibc::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenAck; @@ -32,14 +34,14 @@ use crate::ibc::core::ics26_routing::error::Error as Ics26Error; use crate::ibc::core::ics26_routing::msgs::Ics26Envelope; use crate::ibc::downcast; use crate::ibc_proto::google::protobuf::Any; -use crate::ibc_proto::ibc::core::channel::v1::acknowledgement::Response; -use crate::ibc_proto::ibc::core::channel::v1::Acknowledgement; #[allow(missing_docs)] #[derive(Error, Debug)] pub enum Error { #[error("Decoding IBC data error: {0}")] DecodingData(prost::DecodeError), + #[error("Decoding Json data error: {0}")] + DecodingJsonData(serde_json::Error), #[error("Decoding message error: {0}")] DecodingMessage(Ics26Error), #[error("Downcast error: {0}")] @@ -326,39 +328,70 @@ impl Default for PacketReceipt { } /// Acknowledgement for a packet -#[derive(Clone, Debug)] -pub struct PacketAck(pub Acknowledgement); +#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum PacketAck { + /// Success Acknowledgement + Result(String), + /// Error Acknowledgement + Error(String), +} + +/// Success acknowledgement +const ACK_SUCCESS_B64: &str = "AQ=="; +/// Error acknowledgement +const ACK_ERR_STR: &str = + "error handling packet on destination chain: see events for details"; // TODO temporary type. add a new type for ack to ibc-rs impl PacketAck { + /// Success acknowledgement + pub fn result_success() -> Self { + Self::Result(ACK_SUCCESS_B64.to_string()) + } + + /// Acknowledgement with an error + pub fn result_error(err: String) -> Self { + Self::Error(format!("{}: {}", ACK_ERR_STR, err)) + } + + /// Check if the ack is for success + pub fn is_success(&self) -> bool { + match self { + Self::Result(_) => true, + Self::Error(_) => false, + } + } + /// Encode the ack pub fn encode_to_vec(&self) -> Vec { - serde_json::to_vec(&self.0) + serde_json::to_vec(&self) .expect("Encoding acknowledgement shouldn't fail") } } -impl Default for PacketAck { - fn default() -> Self { - Self(Acknowledgement { - response: Some(Response::Result(vec![1_u8])), - }) +impl TryFrom for PacketAck { + type Error = Error; + + fn try_from(ack: Acknowledgement) -> Result { + serde_json::from_slice(&ack.into_bytes()) + .map_err(Error::DecodingJsonData) } } // for the string to be used by the current reader impl Display for PacketAck { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "{}", serde_json::to_string(&self.0).unwrap()) + write!(f, "{}", serde_json::to_string(&self).unwrap()) } } -// TODO temporary type. add a new type for ack to ibc-rs +// TODO temporary type. add a new type for packet data to ibc-rs /// Data to transfer a token #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] pub struct FungibleTokenPacketData { /// the token denomination to be transferred - pub denomination: String, + pub denom: String, /// the token amount to be transferred pub amount: String, /// the sender address @@ -372,7 +405,7 @@ impl From for FungibleTokenPacketData { // TODO validation let token = msg.token.unwrap(); Self { - denomination: token.denom, + denom: token.denom, amount: token.amount, sender: msg.sender.to_string(), receiver: msg.receiver.to_string(), diff --git a/shared/src/types/token.rs b/shared/src/types/token.rs index 787a8855dc5..2831b532fab 100644 --- a/shared/src/types/token.rs +++ b/shared/src/types/token.rs @@ -411,11 +411,8 @@ impl TryFrom for Transfer { Address::decode(&data.sender).map_err(TransferError::Address)?; let target = Address::decode(&data.receiver).map_err(TransferError::Address)?; - let token_str = data - .denomination - .split('/') - .last() - .ok_or(TransferError::NoToken)?; + let token_str = + data.denom.split('/').last().ok_or(TransferError::NoToken)?; let token = Address::decode(token_str).map_err(TransferError::Address)?; let amount = diff --git a/tests/src/vm_host_env/ibc.rs b/tests/src/vm_host_env/ibc.rs index 9a8ead4be76..c9f03d34506 100644 --- a/tests/src/vm_host_env/ibc.rs +++ b/tests/src/vm_host_env/ibc.rs @@ -64,7 +64,7 @@ use namada::ledger::tx_env::TxEnv; use namada::proto::Tx; use namada::tendermint_proto::Protobuf; use namada::types::address::{self, Address, InternalAddress}; -use namada::types::ibc::data::FungibleTokenPacketData; +use namada::types::ibc::data::{FungibleTokenPacketData, PacketAck}; use namada::types::storage::{self, BlockHash, BlockHeight}; use namada::types::token::{self, Amount}; use namada::vm::{wasm, WasmCacheRwAccess}; @@ -584,7 +584,7 @@ pub fn msg_packet_recv(packet: Packet) -> MsgRecvPacket { pub fn msg_packet_ack(packet: Packet) -> MsgAcknowledgement { MsgAcknowledgement { packet, - acknowledgement: vec![0].into(), + acknowledgement: PacketAck::result_success().encode_to_vec().into(), proofs: dummy_proofs(), signer: Signer::new("test"), } @@ -601,7 +601,7 @@ pub fn received_packet( let timeout_timestamp = (Timestamp::now() + Duration::from_secs(100)).unwrap(); let data = FungibleTokenPacketData { - denomination: token, + denom: token, amount: 100u64.to_string(), sender: address::testing::gen_established_address().to_string(), receiver: receiver.to_string(), From 868b8da9aad0ed477b080c0530067f7df22bbb03 Mon Sep 17 00:00:00 2001 From: yito88 Date: Wed, 18 May 2022 18:11:07 +0200 Subject: [PATCH 02/36] fix IBC token VP for ack error --- shared/src/ledger/ibc/vp/token.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shared/src/ledger/ibc/vp/token.rs b/shared/src/ledger/ibc/vp/token.rs index da67f222c7e..c4af1135505 100644 --- a/shared/src/ledger/ibc/vp/token.rs +++ b/shared/src/ledger/ibc/vp/token.rs @@ -102,6 +102,9 @@ where Ics26Envelope::Ics4PacketMsg(PacketMsg::RecvPacket(msg)) => { self.validate_receiving_token(&msg.packet) } + Ics26Envelope::Ics4PacketMsg(PacketMsg::AckPacket(msg)) => { + self.validate_refunding_token(&msg.packet) + } Ics26Envelope::Ics4PacketMsg(PacketMsg::ToPacket(msg)) => { self.validate_refunding_token(&msg.packet) } From bd2f9222bdf4462d071078f446bbfedcb7a4df29 Mon Sep 17 00:00:00 2001 From: yito88 Date: Mon, 29 Aug 2022 18:35:39 +0200 Subject: [PATCH 03/36] fix relay transfer --- apps/src/lib/node/ledger/protocol/mod.rs | 3 +- shared/src/ledger/ibc/handler.rs | 277 +++++++++++++++-------- shared/src/ledger/ibc/storage.rs | 89 +++++++- shared/src/ledger/ibc/vp/mod.rs | 10 + shared/src/ledger/ibc/vp/packet.rs | 45 +++- shared/src/ledger/ibc/vp/token.rs | 207 ++++++++++++----- shared/src/types/address.rs | 105 ++++++--- shared/src/types/token.rs | 20 +- tests/src/vm_host_env/ibc.rs | 42 +--- tests/src/vm_host_env/mod.rs | 91 +++++--- 10 files changed, 608 insertions(+), 281 deletions(-) diff --git a/apps/src/lib/node/ledger/protocol/mod.rs b/apps/src/lib/node/ledger/protocol/mod.rs index ed776fe21af..66f73843033 100644 --- a/apps/src/lib/node/ledger/protocol/mod.rs +++ b/apps/src/lib/node/ledger/protocol/mod.rs @@ -336,7 +336,8 @@ where gas_meter = slash_fund.ctx.gas_meter.into_inner(); result } - InternalAddress::IbcEscrow(_) + InternalAddress::IbcToken(_) + | InternalAddress::IbcEscrow | InternalAddress::IbcBurn | InternalAddress::IbcMint => { // validate the transfer diff --git a/shared/src/ledger/ibc/handler.rs b/shared/src/ledger/ibc/handler.rs index 55453ed0203..61592974ff7 100644 --- a/shared/src/ledger/ibc/handler.rs +++ b/shared/src/ledger/ibc/handler.rs @@ -115,6 +115,8 @@ pub enum Error { SendingToken(String), #[error("Receiving a token error: {0}")] ReceivingToken(String), + #[error("IBC storage error: {0}")] + IbcStorage(storage::Error), } // This is needed to use `ibc::Handler::Error` with `IbcActions` in @@ -161,9 +163,8 @@ pub trait IbcActions { /// Transfer token fn transfer_token( &mut self, - src: &Address, - dest: &Address, - token: &Address, + src: &Key, + dest: &Key, amount: Amount, ) -> std::result::Result<(), Self::Error>; @@ -934,25 +935,25 @@ pub trait IbcActions { &mut self, msg: &MsgTransfer, ) -> std::result::Result<(), Self::Error> { - let data = FungibleTokenPacketData::from(msg.clone()); - let source = Address::decode(data.sender.clone()).map_err(|e| { - Error::SendingToken(format!( - "Invalid sender address: sender {}, error {}", - data.sender, e - )) - })?; - let token_str = data.denom.split('/').last().ok_or_else(|| { - Error::SendingToken(format!( - "No token was specified: {}", - data.denom - )) - })?; - let token = Address::decode(token_str).map_err(|e| { - Error::SendingToken(format!( - "Invalid token address: token {}, error {}", - token_str, e - )) - })?; + let mut data = FungibleTokenPacketData::from(msg.clone()); + if let Some(hash) = storage::token_hash_from_denom(&data.denom)? { + let denom_key = storage::ibc_denom_key(&hash); + let denom_bytes = + self.read_ibc_data(&denom_key).ok_or_else(|| { + Error::SendingToken(format!( + "No original denom: denom_key {}", + denom_key + )) + })?; + let denom = std::str::from_utf8(&denom_bytes).map_err(|e| { + Error::SendingToken(format!( + "Decoding the denom failed: denom_key {}, error {}", + denom_key, e + )) + })?; + data.denom = denom.to_string(); + } + let token = storage::token(&data.denom)?; let amount = Amount::from_str(&data.amount).map_err(|e| { Error::SendingToken(format!( "Invalid amount: amount {}, error {}", @@ -960,25 +961,58 @@ pub trait IbcActions { )) })?; - // check the denom field + let source_addr = + Address::decode(data.sender.clone()).map_err(|e| { + Error::SendingToken(format!( + "Invalid sender address: sender {}, error {}", + data.sender, e + )) + })?; + + // check the denomination field let prefix = format!( "{}/{}/", msg.source_port.clone(), msg.source_channel.clone() ); - if data.denom.starts_with(&prefix) { - // sink zone - let burn = Address::Internal(InternalAddress::IbcBurn); - self.transfer_token(&source, &burn, &token, amount)?; + let (source, target) = if data.denom.starts_with(&prefix) { + // the receiver's chain was the source + // transfer from the origin-specific account of the token + let key_prefix = storage::ibc_token_prefix(&data.denom)?; + let src = token::multitoken_balance_key(&key_prefix, &source_addr); + + let key_prefix = storage::ibc_account_prefix( + &msg.source_port, + &msg.source_channel, + &token, + ); + let burn = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcBurn), + ); + (src, burn) } else { - // source zone - let escrow = - Address::Internal(InternalAddress::ibc_escrow_address( - msg.source_port.to_string(), - msg.source_channel.to_string(), - )); - self.transfer_token(&source, &escrow, &token, amount)?; - } + // this chain is the source + // escrow the amount of the token + let src = if data.denom == token.to_string() { + token::balance_key(&token, &source_addr) + } else { + let key_prefix = storage::ibc_token_prefix(&data.denom)?; + token::multitoken_balance_key(&key_prefix, &source_addr) + }; + + let key_prefix = storage::ibc_account_prefix( + &msg.source_port, + &msg.source_channel, + &token, + ); + let escrow = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcEscrow), + ); + (src, escrow) + }; + self.transfer_token(&source, &target, amount); // send a packet let port_channel_id = @@ -999,49 +1033,81 @@ pub trait IbcActions { packet: &Packet, data: &FungibleTokenPacketData, ) -> std::result::Result<(), Self::Error> { - let dest = Address::decode(data.receiver.clone()).map_err(|e| { - Error::ReceivingToken(format!( - "Invalid receiver address: receiver {}, error {}", - data.receiver, e - )) - })?; - let token_str = data.denom.split('/').last().ok_or_else(|| { - Error::ReceivingToken(format!( - "No token was specified: {}", - data.denom - )) - })?; - let token = Address::decode(token_str).map_err(|e| { - Error::ReceivingToken(format!( - "Invalid token address: token {}, error {}", - token_str, e - )) - })?; + let token = storage::token(&data.denom)?; let amount = Amount::from_str(&data.amount).map_err(|e| { Error::ReceivingToken(format!( "Invalid amount: amount {}, error {}", data.amount, e )) })?; + // The receiver should be an address because the origin-specific account + // key should be assigned internally + let dest_addr = + Address::decode(data.receiver.clone()).map_err(|e| { + Error::ReceivingToken(format!( + "Invalid receiver address: receiver {}, error {}", + data.receiver, e + )) + })?; let prefix = format!( "{}/{}/", packet.source_port.clone(), packet.source_channel.clone() ); - if data.denom.starts_with(&prefix) { - // unescrow the token because this chain is the source - let escrow = - Address::Internal(InternalAddress::ibc_escrow_address( - packet.destination_port.to_string(), - packet.destination_channel.to_string(), - )); - self.transfer_token(&escrow, &dest, &token, amount)?; - } else { - // mint the token because the sender chain is the source - let mint = Address::Internal(InternalAddress::IbcMint); - self.transfer_token(&mint, &dest, &token, amount)?; - } + let (source, target) = match data.denom.strip_prefix(&prefix) { + Some(denom) => { + // unescrow the token because this chain was the source + let escrow_prefix = storage::ibc_account_prefix( + &packet.destination_port, + &packet.destination_channel, + &token, + ); + let escrow = token::multitoken_balance_key( + &escrow_prefix, + &Address::Internal(InternalAddress::IbcEscrow), + ); + let dest = if denom == token.to_string() { + token::balance_key(&token, &dest_addr) + } else { + let key_prefix = storage::ibc_token_prefix(denom)?; + token::multitoken_balance_key(&key_prefix, &dest_addr) + }; + (escrow, dest) + } + None => { + // mint the token because the sender chain is the source + let key_prefix = storage::ibc_account_prefix( + &packet.destination_port, + &packet.destination_channel, + &token, + ); + let mint = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcMint), + ); + + // prefix the denom with the this chain port and channel + let denom = format!( + "{}/{}/{}", + &packet.destination_port, + &packet.destination_channel, + &data.denom + ); + let key_prefix = storage::ibc_token_prefix(&denom)?; + let dest = + token::multitoken_balance_key(&key_prefix, &dest_addr); + + // store the prefixed denom + let token_hash = storage::calc_hash(&denom); + let denom_key = storage::ibc_denom_key(token_hash); + self.write_ibc_data(&denom_key, denom.as_bytes()); + + (mint, dest) + } + }; + self.transfer_token(&source, &target, amount); + Ok(()) } @@ -1051,24 +1117,7 @@ pub trait IbcActions { packet: &Packet, data: &FungibleTokenPacketData, ) -> std::result::Result<(), Self::Error> { - let dest = Address::decode(data.sender.clone()).map_err(|e| { - Error::ReceivingToken(format!( - "Invalid sender address: sender {}, error {}", - data.sender, e - )) - })?; - let token_str = data.denom.split('/').last().ok_or_else(|| { - Error::ReceivingToken(format!( - "No token was specified: {}", - data.denom - )) - })?; - let token = Address::decode(token_str).map_err(|e| { - Error::ReceivingToken(format!( - "Invalid token address: token {}, error {}", - token_str, e - )) - })?; + let token = storage::token(&data.denom)?; let amount = Amount::from_str(&data.amount).map_err(|e| { Error::ReceivingToken(format!( "Invalid amount: amount {}, error {}", @@ -1076,24 +1125,54 @@ pub trait IbcActions { )) })?; + let dest_addr = Address::decode(data.sender.clone()).map_err(|e| { + Error::SendingToken(format!( + "Invalid sender address: sender {}, error {}", + data.sender, e + )) + })?; + let prefix = format!( "{}/{}/", packet.source_port.clone(), packet.source_channel.clone() ); - if data.denom.starts_with(&prefix) { - // mint the token because the sender chain is the sink zone - let mint = Address::Internal(InternalAddress::IbcMint); - self.transfer_token(&mint, &dest, &token, amount)?; + let (source, target) = if data.denom.starts_with(&prefix) { + // mint the token because the amount was burned + let key_prefix = storage::ibc_account_prefix( + &packet.source_port, + &packet.source_channel, + &token, + ); + let mint = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcMint), + ); + let key_prefix = storage::ibc_token_prefix(&data.denom)?; + let dest = token::multitoken_balance_key(&key_prefix, &dest_addr); + (mint, dest) } else { - // unescrow the token because the sender chain is the source zone - let escrow = - Address::Internal(InternalAddress::ibc_escrow_address( - packet.source_port.to_string(), - packet.source_channel.to_string(), - )); - self.transfer_token(&escrow, &dest, &token, amount)?; - } + // unescrow the token because the acount was escrowed + let dest = if data.denom == token.to_string() { + token::balance_key(&token, &dest_addr) + } else { + let key_prefix = storage::ibc_token_prefix(&data.denom)?; + token::multitoken_balance_key(&key_prefix, &dest_addr) + }; + + let key_prefix = storage::ibc_account_prefix( + &packet.source_port, + &packet.source_channel, + &token, + ); + let escrow = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcEscrow), + ); + (escrow, dest) + }; + self.transfer_token(&source, &target, amount); + Ok(()) } } @@ -1518,3 +1597,9 @@ pub fn make_timeout_event(packet: Packet) -> IbcEvent { packet, }) } + +impl From for Error { + fn from(err: storage::Error) -> Self { + Self::IbcStorage(err) + } +} diff --git a/shared/src/ledger/ibc/storage.rs b/shared/src/ledger/ibc/storage.rs index 51cfc8890ed..ed47b4c68a7 100644 --- a/shared/src/ledger/ibc/storage.rs +++ b/shared/src/ledger/ibc/storage.rs @@ -2,6 +2,7 @@ use std::str::FromStr; +use sha2::{Digest, Sha256}; use thiserror::Error; use crate::ibc::core::ics02_client::height::Height; @@ -16,7 +17,7 @@ use crate::ibc::core::ics24_host::path::{ SeqAcksPath, SeqRecvsPath, SeqSendsPath, }; use crate::ibc::core::ics24_host::Path; -use crate::types::address::{Address, InternalAddress}; +use crate::types::address::{Address, InternalAddress, HASH_LEN}; use crate::types::storage::{self, DbKeySeg, Key, KeySeg}; const CLIENTS_COUNTER: &str = "clients/counter"; @@ -24,6 +25,9 @@ const CONNECTIONS_COUNTER: &str = "connections/counter"; const CHANNELS_COUNTER: &str = "channelEnds/counter"; const CAPABILITIES_INDEX: &str = "capabilities/index"; const CAPABILITIES: &str = "capabilities"; +const DENOM: &str = "denom"; +/// Key segment for a multitoken related to IBC +pub const MULTITOKEN_STORAGE_KEY: &str = "ibc"; #[allow(missing_docs)] #[derive(Error, Debug)] @@ -34,6 +38,8 @@ pub enum Error { InvalidKey(String), #[error("Port capability error: {0}")] InvalidPortCapability(String), + #[error("Denom error: {0}")] + Denom(String), } /// IBC storage functions result @@ -54,6 +60,7 @@ pub enum IbcPrefix { Receipt, Ack, Event, + Denom, Unknown, } @@ -76,6 +83,7 @@ pub fn ibc_prefix(key: &Key) -> Option { "receipts" => IbcPrefix::Receipt, "acks" => IbcPrefix::Ack, "event" => IbcPrefix::Event, + "denom" => IbcPrefix::Denom, _ => IbcPrefix::Unknown, }) } @@ -482,3 +490,82 @@ pub fn capability(key: &Key) -> Result { ))), } } + +/// The storage key to get the denom name from the hashed token +pub fn ibc_denom_key(token_hash: impl AsRef) -> Key { + let path = format!("{}/{}", DENOM, token_hash.as_ref()); + ibc_key(path).expect("Creating a key for the denom key shouldn't fail") +} + +/// Key's prefix for the escrow, burn, or mint account +pub fn ibc_account_prefix( + port_id: &PortId, + channel_id: &ChannelId, + token: &Address, +) -> Key { + Key::from(token.to_db_key()) + .push(&MULTITOKEN_STORAGE_KEY.to_owned()) + .expect("Cannot obtain a storage key") + .push(&port_id.to_string().to_db_key()) + .expect("Cannot obtain a storage key") + .push(&channel_id.to_string().to_db_key()) + .expect("Cannot obtain a storage key") +} + +/// Token address from the denom string +pub fn token(denom: impl AsRef) -> Result
{ + let token_str = denom.as_ref().split('/').last().ok_or_else(|| { + Error::Denom(format!("No token was specified: {}", denom.as_ref())) + })?; + Address::decode(token_str).map_err(|e| { + Error::Denom(format!( + "Invalid token address: token {}, error {}", + token_str, e + )) + }) +} + +/// Get the hash of IBC token address from the denom string +pub fn token_hash_from_denom(denom: impl AsRef) -> Result> { + match denom + .as_ref() + .strip_prefix(&format!("{}/", MULTITOKEN_STORAGE_KEY)) + { + Some(addr_str) => { + let addr = Address::decode(addr_str).map_err(|e| { + Error::Denom(format!( + "Decoding the denom failed: ibc_token {}, error {}", + addr_str, e + )) + })?; + match addr { + Address::Internal(InternalAddress::IbcToken(h)) => Ok(Some(h)), + _ => Err(Error::Denom(format!( + "Unexpected address was given: {}", + addr + ))), + } + } + None => Ok(None), + } +} + +/// Hash the denom +pub fn calc_hash(denom: impl AsRef) -> String { + let mut hasher = Sha256::new(); + hasher.update(denom.as_ref()); + format!("{:.width$x}", hasher.finalize(), width = HASH_LEN) +} + +/// Key's prefix of the received token over IBC +pub fn ibc_token_prefix(denom: impl AsRef) -> Result { + let token = token(&denom)?; + let hash = calc_hash(&denom); + let ibc_token = Address::Internal(InternalAddress::IbcToken(hash)); + let prefix = Key::from(token.to_db_key()) + .push(&MULTITOKEN_STORAGE_KEY.to_owned()) + .expect("Cannot obtain a storage key") + .push(&ibc_token.to_db_key()) + .expect("Cannot obtain a storage key"); + Ok(prefix) +} diff --git a/shared/src/ledger/ibc/vp/mod.rs b/shared/src/ledger/ibc/vp/mod.rs index fa500d5e430..930d8df8709 100644 --- a/shared/src/ledger/ibc/vp/mod.rs +++ b/shared/src/ledger/ibc/vp/mod.rs @@ -3,6 +3,7 @@ mod channel; mod client; mod connection; +mod denom; mod packet; mod port; mod sequence; @@ -46,6 +47,8 @@ pub enum Error { PacketError(packet::Error), #[error("Sequence validation error: {0}")] SequenceError(sequence::Error), + #[error("Denom validation error: {0}")] + DenomError(denom::Error), #[error("IBC event error: {0}")] IbcEvent(String), #[error("Decoding transaction data error: {0}")] @@ -141,6 +144,7 @@ where } IbcPrefix::Ack => self.validate_ack(key)?, IbcPrefix::Event => {} + IbcPrefix::Denom => self.validate_denom(tx_data)?, IbcPrefix::Unknown => { return Err(Error::KeyError(format!( "Invalid IBC-related key: {}", @@ -288,6 +292,12 @@ impl From for Error { } } +impl From for Error { + fn from(err: denom::Error) -> Self { + Self::DenomError(err) + } +} + /// A dummy header used for testing #[cfg(any(feature = "test", feature = "testing"))] pub fn get_dummy_header() -> crate::types::storage::Header { diff --git a/shared/src/ledger/ibc/vp/packet.rs b/shared/src/ledger/ibc/vp/packet.rs index 207727e91cd..026b56ff2f8 100644 --- a/shared/src/ledger/ibc/vp/packet.rs +++ b/shared/src/ledger/ibc/vp/packet.rs @@ -6,7 +6,8 @@ use super::super::handler::{ self, make_send_packet_event, make_timeout_event, packet_from_message, }; use super::super::storage::{ - port_channel_sequence_id, Error as IbcStorageError, + ibc_denom_key, port_channel_sequence_id, token_hash_from_denom, + Error as IbcStorageError, }; use super::{Ibc, StateChange}; use crate::ibc::core::ics02_client::height::Height; @@ -33,7 +34,9 @@ use crate::ibc::core::ics24_host::identifier::{ use crate::ibc::core::ics26_routing::msgs::Ics26Envelope; use crate::ibc::proofs::Proofs; use crate::ledger::storage::{self, StorageHasher}; -use crate::types::ibc::data::{Error as IbcDataError, IbcMessage}; +use crate::types::ibc::data::{ + Error as IbcDataError, FungibleTokenPacketData, IbcMessage, +}; use crate::types::storage::Key; use crate::vm::WasmCacheAccess; @@ -64,6 +67,8 @@ pub enum Error { IbcEvent(String), #[error("IBC proof error: {0}")] Proof(String), + #[error("IBC denom error: {0}")] + Denom(String), } /// IBC packet functions result @@ -99,11 +104,12 @@ where let channel = self .channel_end(&(commitment_key.0.clone(), commitment_key.1)) .map_err(|e| Error::InvalidChannel(e.to_string()))?; - let packet = packet_from_message( + let mut packet = packet_from_message( &msg, commitment_key.2, channel.counterparty(), ); + self.update_denom(&mut packet)?; let commitment = self .get_packet_commitment(&commitment_key) .map_err(|_| { @@ -694,6 +700,39 @@ where Ok(()) } } + + fn update_denom(&self, packet: &mut Packet) -> Result<()> { + if let Ok(mut data) = + serde_json::from_slice::(&packet.data) + { + if let Some(token_hash) = token_hash_from_denom(&data.denom) + .map_err(|e| { + Error::Denom(format!("Invalid denom: error {}", e)) + })? + { + let denom_key = ibc_denom_key(&token_hash); + let denom_bytes = match self.ctx.read_pre(&denom_key) { + Ok(Some(v)) => v, + _ => { + return Err(Error::Denom(format!( + "No original denom: denom_key {}", + denom_key + ))); + } + }; + let denom = std::str::from_utf8(&denom_bytes).map_err(|e| { + Error::Denom(format!( + "Decoding the denom failed: denom_key {}, error {}", + denom_key, e + )) + })?; + data.denom = denom.to_string(); + packet.data = serde_json::to_vec(&data) + .expect("encoding the packet data shouldn't fail"); + } + } + Ok(()) + } } /// The proof for the counterpart channel should be in proofs.other_proof diff --git a/shared/src/ledger/ibc/vp/token.rs b/shared/src/ledger/ibc/vp/token.rs index c4af1135505..917361eaf22 100644 --- a/shared/src/ledger/ibc/vp/token.rs +++ b/shared/src/ledger/ibc/vp/token.rs @@ -10,6 +10,7 @@ use crate::ibc::applications::ics20_fungible_token_transfer::msgs::transfer::Msg use crate::ibc::core::ics04_channel::msgs::PacketMsg; use crate::ibc::core::ics04_channel::packet::Packet; use crate::ibc::core::ics26_routing::msgs::Ics26Envelope; +use crate::ledger::ibc::storage as ibc_storage; use crate::ledger::native_vp::{self, Ctx, NativeVp, VpEnv}; use crate::ledger::storage::{self as ledger_storage, StorageHasher}; use crate::proto::SignedTxData; @@ -18,9 +19,7 @@ use crate::types::ibc::data::{ Error as IbcDataError, FungibleTokenPacketData, IbcMessage, }; use crate::types::storage::Key; -use crate::types::token::{ - self, is_non_owner_balance_key, Amount, AmountParseError, -}; +use crate::types::token::{self, Amount, AmountParseError}; use crate::vm::WasmCacheAccess; #[allow(missing_docs)] @@ -32,20 +31,22 @@ pub enum Error { IbcMessage(IbcDataError), #[error("Invalid message error")] InvalidMessage, - #[error("Invalid address error")] + #[error("Invalid address error: {0}")] Address(AddressError), #[error("Token error")] NoToken, - #[error("Parsing amount error")] + #[error("Parsing amount error: {0}")] Amount(AmountParseError), - #[error("Decoding error")] + #[error("Decoding error: {0}")] Decoding(std::io::Error), - #[error("Decoding PacketData error")] + #[error("Decoding PacketData error: {0}")] DecodingPacketData(serde_json::Error), - #[error("Invalid token transfer error")] + #[error("Invalid token transfer error: {0}")] TokenTransfer(String), #[error("IBC message is required as transaction data")] NoTxData, + #[error("Invalid denom error: {0}")] + Denom(String), } /// Result for IBC token VP @@ -85,10 +86,27 @@ where // Check the non-onwer balance updates let keys_changed: HashSet = keys_changed .iter() - .filter(|k| is_non_owner_balance_key(k).is_some()) + .filter(|k| { + matches!( + token::is_any_multitoken_balance_key(k), + Some((_, Address::Internal(InternalAddress::IbcEscrow))) + | Some(( + _, + Address::Internal(InternalAddress::IbcBurn) + )) + | Some(( + _, + Address::Internal(InternalAddress::IbcMint) + )) + ) + }) .cloned() .collect(); - if keys_changed.len() != 1 { + if keys_changed.is_empty() { + // no account is checked by this VP + return Ok(true); + } else if keys_changed.len() > 1 { + // a transaction can update at most 1 special IBC account for now // a transaction can update at most 1 non-owner balance for now return Err(Error::TokenTransfer( "Invalid transfer for multiple non-owner balances".to_owned(), @@ -123,37 +141,94 @@ where CA: 'static + WasmCacheAccess, { fn validate_sending_token(&self, msg: &MsgTransfer) -> Result { - let data = FungibleTokenPacketData::from(msg.clone()); - let token_str = data.denom.split('/').last().ok_or(Error::NoToken)?; - let token = Address::decode(token_str).map_err(Error::Address)?; + let mut data = FungibleTokenPacketData::from(msg.clone()); + if let Some(token_hash) = + ibc_storage::token_hash_from_denom(&data.denom).map_err(|e| { + Error::Denom(format!("Invalid denom: error {}", e)) + })? + { + let denom_key = ibc_storage::ibc_denom_key(&token_hash); + let denom_bytes = match self.ctx.read_pre(&denom_key) { + Ok(Some(v)) => v, + _ => { + return Err(Error::Denom(format!( + "No original denom: denom_key {}", + denom_key + ))); + } + }; + let denom = std::str::from_utf8(&denom_bytes).map_err(|e| { + Error::Denom(format!( + "Decoding the denom failed: denom_key {}, error {}", + denom_key, e + )) + })?; + data.denom = denom.to_string(); + } + let token = ibc_storage::token(&data.denom) + .map_err(|e| Error::Denom(e.to_string()))?; let amount = Amount::from_str(&data.amount).map_err(Error::Amount)?; - // check the denom field + let denom = if let Some(denom) = data + .denom + .strip_prefix(&format!("{}/", ibc_storage::MULTITOKEN_STORAGE_KEY)) + { + let denom_key = ibc_storage::ibc_denom_key(&denom); + match self.ctx.read_pre(&denom_key)? { + Some(v) => std::str::from_utf8(&v) + .map_err(|e| { + Error::TokenTransfer(format!( + "Decoding the denom failed: denom_key {}, error {}", + denom_key, e + )) + })? + .to_string(), + None => { + return Err(Error::TokenTransfer(format!( + "No original denom: denom_key {}", + denom_key + ))); + } + } + } else { + data.denom.clone() + }; + + // check the denomination field let prefix = format!( "{}/{}/", msg.source_port.clone(), msg.source_channel.clone() ); - let change = if data.denom.starts_with(&prefix) { + let key_prefix = ibc_storage::ibc_account_prefix( + &msg.source_port, + &msg.source_channel, + &token, + ); + + let change = if denom.starts_with(&prefix) { // sink zone - let target = Address::Internal(InternalAddress::IbcBurn); - let target_key = token::balance_key(&token, &target); - let post = try_decode_token_amount( - self.ctx.read_bytes_temp(&target_key)?, - )? - .unwrap_or_default(); + // check the amount of the token has been burned + let target_key = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcBurn), + ); + let post = + try_decode_token_amount(self.ctx.read_temp(&target_key)?)? + .unwrap_or_default(); // the previous balance of the burn address should be zero post.change() } else { // source zone - let target = - Address::Internal(InternalAddress::ibc_escrow_address( - msg.source_port.to_string(), - msg.source_channel.to_string(), - )); - let target_key = token::balance_key(&token, &target); - let pre = - try_decode_token_amount(self.ctx.read_bytes_pre(&target_key)?)? + // check the amount of the token has been escrowed + let target_key = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcEscrow), + ); + let pre = try_decode_token_amount(self.ctx.read_pre(&target_key)?)? + .unwrap_or_default(); + let post = + try_decode_token_amount(self.ctx.read_post(&target_key)?)? .unwrap_or_default(); let post = try_decode_token_amount( self.ctx.read_bytes_post(&target_key)?, @@ -176,8 +251,8 @@ where let data: FungibleTokenPacketData = serde_json::from_slice(&packet.data) .map_err(Error::DecodingPacketData)?; - let token_str = data.denom.split('/').last().ok_or(Error::NoToken)?; - let token = Address::decode(token_str).map_err(Error::Address)?; + let token = ibc_storage::token(&data.denom) + .map_err(|e| Error::Denom(e.to_string()))?; let amount = Amount::from_str(&data.amount).map_err(Error::Amount)?; let prefix = format!( @@ -185,16 +260,22 @@ where packet.source_port.clone(), packet.source_channel.clone() ); + let key_prefix = ibc_storage::ibc_account_prefix( + &packet.destination_port, + &packet.destination_channel, + &token, + ); let change = if data.denom.starts_with(&prefix) { // this chain is the source - let source = - Address::Internal(InternalAddress::ibc_escrow_address( - packet.destination_port.to_string(), - packet.destination_channel.to_string(), - )); - let source_key = token::balance_key(&token, &source); - let pre = - try_decode_token_amount(self.ctx.read_bytes_pre(&source_key)?)? + // check the amount of the token has been unescrowed + let source_key = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcEscrow), + ); + let pre = try_decode_token_amount(self.ctx.read_pre(&source_key)?)? + .unwrap_or_default(); + let post = + try_decode_token_amount(self.ctx.read_post(&source_key)?)? .unwrap_or_default(); let post = try_decode_token_amount( self.ctx.read_bytes_post(&source_key)?, @@ -203,12 +284,14 @@ where pre.change() - post.change() } else { // the sender is the source - let source = Address::Internal(InternalAddress::IbcMint); - let source_key = token::balance_key(&token, &source); - let post = try_decode_token_amount( - self.ctx.read_bytes_temp(&source_key)?, - )? - .unwrap_or_default(); + // check the amount of the token has been minted + let source_key = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcMint), + ); + let post = + try_decode_token_amount(self.ctx.read_temp(&source_key)?)? + .unwrap_or_default(); // the previous balance of the mint address should be the maximum Amount::max().change() - post.change() }; @@ -237,26 +320,32 @@ where packet.source_port.clone(), packet.source_channel.clone() ); + let key_prefix = ibc_storage::ibc_account_prefix( + &packet.source_port, + &packet.source_channel, + &token, + ); let change = if data.denom.starts_with(&prefix) { // sink zone: mint the token for the refund - let source = Address::Internal(InternalAddress::IbcMint); - let source_key = token::balance_key(&token, &source); - let post = try_decode_token_amount( - self.ctx.read_bytes_temp(&source_key)?, - )? - .unwrap_or_default(); + let source_key = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcMint), + ); + let post = + try_decode_token_amount(self.ctx.read_temp(&source_key)?)? + .unwrap_or_default(); // the previous balance of the mint address should be the maximum Amount::max().change() - post.change() } else { // source zone: unescrow the token for the refund - let source = - Address::Internal(InternalAddress::ibc_escrow_address( - packet.source_port.to_string(), - packet.source_channel.to_string(), - )); - let source_key = token::balance_key(&token, &source); - let pre = - try_decode_token_amount(self.ctx.read_bytes_pre(&source_key)?)? + let source_key = token::multitoken_balance_key( + &key_prefix, + &Address::Internal(InternalAddress::IbcEscrow), + ); + let pre = try_decode_token_amount(self.ctx.read_pre(&source_key)?)? + .unwrap_or_default(); + let post = + try_decode_token_amount(self.ctx.read_post(&source_key)?)? .unwrap_or_default(); let post = try_decode_token_amount( self.ctx.read_bytes_post(&source_key)?, diff --git a/shared/src/types/address.rs b/shared/src/types/address.rs index 6f047730fed..a503b796f0d 100644 --- a/shared/src/types/address.rs +++ b/shared/src/types/address.rs @@ -53,18 +53,20 @@ mod internal { "ano::Proof of Stake "; pub const POS_SLASH_POOL: &str = "ano::Proof of Stake Slash Pool "; - pub const IBC: &str = - "ano::Inter-Blockchain Communication "; pub const PARAMETERS: &str = "ano::Protocol Parameters "; pub const GOVERNANCE: &str = "ano::Governance "; pub const SLASH_FUND: &str = "ano::Slash Fund "; + pub const IBC: &str = + "ibc::Inter-Blockchain Communication "; + pub const IBC_ESCROW: &str = + "ibc::IBC Escrow Address "; pub const IBC_BURN: &str = - "ano::IBC Burn Address "; + "ibc::IBC Burn Address "; pub const IBC_MINT: &str = - "ano::IBC Mint Address "; + "ibc::IBC Mint Address "; pub const ETH_BRIDGE: &str = "ano::ETH Bridge Address "; } @@ -75,6 +77,8 @@ const PREFIX_ESTABLISHED: &str = "est"; const PREFIX_IMPLICIT: &str = "imp"; /// Fixed-length address strings prefix for internal addresses. const PREFIX_INTERNAL: &str = "ano"; +/// Fixed-length address strings prefix for IBC addresses. +const PREFIX_IBC: &str = "ibc"; #[allow(missing_docs)] #[derive(Error, Debug)] @@ -178,7 +182,6 @@ impl Address { InternalAddress::PosSlashPool => { internal::POS_SLASH_POOL.to_string() } - InternalAddress::Ibc => internal::IBC.to_string(), InternalAddress::Parameters => { internal::PARAMETERS.to_string() } @@ -188,8 +191,12 @@ impl Address { InternalAddress::SlashFund => { internal::SLASH_FUND.to_string() } - InternalAddress::IbcEscrow(hash) => { - format!("{}::{}", PREFIX_INTERNAL, hash) + InternalAddress::Ibc => internal::IBC.to_string(), + InternalAddress::IbcToken(hash) => { + format!("{}::{}", PREFIX_IBC, hash) + } + InternalAddress::IbcEscrow => { + internal::IBC_ESCROW.to_string() } InternalAddress::IbcBurn => internal::IBC_BURN.to_string(), InternalAddress::IbcMint => internal::IBC_MINT.to_string(), @@ -232,36 +239,45 @@ impl Address { .map_err(|err| Error::new(ErrorKind::InvalidData, err))?; Ok(Address::Implicit(ImplicitAddress(pkh))) } - Some((PREFIX_INTERNAL, raw)) => match string { + Some((PREFIX_INTERNAL, _)) => match string { internal::POS => Ok(Address::Internal(InternalAddress::PoS)), internal::POS_SLASH_POOL => { Ok(Address::Internal(InternalAddress::PosSlashPool)) } - internal::IBC => Ok(Address::Internal(InternalAddress::Ibc)), internal::PARAMETERS => { Ok(Address::Internal(InternalAddress::Parameters)) } - internal::IBC_BURN => { - Ok(Address::Internal(InternalAddress::IbcBurn)) - } internal::GOVERNANCE => { Ok(Address::Internal(InternalAddress::Governance)) } internal::SLASH_FUND => { Ok(Address::Internal(InternalAddress::SlashFund)) } - internal::IBC_MINT => { - Ok(Address::Internal(InternalAddress::IbcMint)) - } internal::ETH_BRIDGE => { Ok(Address::Internal(InternalAddress::EthBridge)) } + _ => Err(Error::new( + ErrorKind::InvalidData, + "Invalid internal address", + )), + }, + Some((PREFIX_IBC, raw)) => match string { + internal::IBC => Ok(Address::Internal(InternalAddress::Ibc)), + internal::IBC_ESCROW => { + Ok(Address::Internal(InternalAddress::IbcEscrow)) + } + internal::IBC_BURN => { + Ok(Address::Internal(InternalAddress::IbcBurn)) + } + internal::IBC_MINT => { + Ok(Address::Internal(InternalAddress::IbcMint)) + } _ if raw.len() == HASH_LEN => Ok(Address::Internal( - InternalAddress::IbcEscrow(raw.to_string()), + InternalAddress::IbcToken(raw.to_string()), )), _ => Err(Error::new( ErrorKind::InvalidData, - "Invalid internal address", + "Invalid IBC internal address", )), }, _ => Err(Error::new( @@ -437,12 +453,14 @@ pub enum InternalAddress { PoS, /// Proof-of-stake slash pool contains slashed tokens PosSlashPool, - /// Inter-blockchain communication - Ibc, /// Protocol parameters Parameters, + /// Inter-blockchain communication + Ibc, + /// IBC-related token + IbcToken(String), /// Escrow for IBC token transfer - IbcEscrow(String), + IbcEscrow, /// Burn tokens with IBC token transfer IbcBurn, /// Mint tokens from this address with IBC token transfer @@ -456,13 +474,17 @@ pub enum InternalAddress { } impl InternalAddress { - /// Get an escrow address from the port ID and channel ID - pub fn ibc_escrow_address(port_id: String, channel_id: String) -> Self { + /// Get an IBC token address from the port ID and channel ID + pub fn ibc_token_address( + port_id: String, + channel_id: String, + token: &Address, + ) -> Self { let mut hasher = Sha256::new(); - let s = format!("{}/{}", port_id, channel_id); + let s = format!("{}/{}/{}", port_id, channel_id, token); hasher.update(&s); - let hash = format!("{:.width$X}", hasher.finalize(), width = HASH_LEN); - InternalAddress::IbcEscrow(hash) + let hash = format!("{:.width$x}", hasher.finalize(), width = HASH_LEN); + InternalAddress::IbcToken(hash) } } @@ -474,11 +496,12 @@ impl Display for InternalAddress { match self { Self::PoS => "PoS".to_string(), Self::PosSlashPool => "PosSlashPool".to_string(), - Self::Ibc => "IBC".to_string(), Self::Parameters => "Parameters".to_string(), Self::Governance => "Governance".to_string(), Self::SlashFund => "SlashFund".to_string(), - Self::IbcEscrow(hash) => format!("IbcEscrow: {}", hash), + Self::Ibc => "IBC".to_string(), + Self::IbcToken(hash) => format!("IbcToken: {}", hash), + Self::IbcEscrow => "IbcEscrow".to_string(), Self::IbcBurn => "IbcBurn".to_string(), Self::IbcMint => "IbcMint".to_string(), Self::EthBridge => "EthBridge".to_string(), @@ -712,11 +735,12 @@ pub mod testing { match InternalAddress::PoS { InternalAddress::PoS => {} InternalAddress::PosSlashPool => {} - InternalAddress::Ibc => {} InternalAddress::Governance => {} InternalAddress::SlashFund => {} InternalAddress::Parameters => {} - InternalAddress::IbcEscrow(_) => {} + InternalAddress::Ibc => {} + InternalAddress::IbcToken(_) => {} + InternalAddress::IbcEscrow => {} InternalAddress::IbcBurn => {} InternalAddress::IbcMint => {} InternalAddress::EthBridge => {} /* Add new addresses in the @@ -727,8 +751,9 @@ pub mod testing { Just(InternalAddress::PosSlashPool), Just(InternalAddress::Ibc), Just(InternalAddress::Parameters), - arb_port_channel_id() - .prop_map(|(p, c)| InternalAddress::ibc_escrow_address(p, c)), + Just(InternalAddress::Ibc), + arb_ibc_token(), + Just(InternalAddress::IbcEscrow), Just(InternalAddress::IbcBurn), Just(InternalAddress::IbcMint), Just(InternalAddress::Governance), @@ -737,8 +762,20 @@ pub mod testing { ] } - fn arb_port_channel_id() -> impl Strategy { - ("[a-zA-Z0-9_]{2,128}", any::()) - .prop_map(|(id, counter)| (id, format!("channel-{}", counter))) + fn arb_ibc_token() -> impl Strategy { + // use sha2::{Digest, Sha256}; + ("[a-zA-Z0-9_]{2,128}", any::()).prop_map(|(id, counter)| { + let mut hasher = sha2::Sha256::new(); + let s = format!( + "{}/{}/{}", + id, + format_args!("channel-{}", counter), + &xan() + ); + hasher.update(&s); + let hash = + format!("{:.width$x}", hasher.finalize(), width = HASH_LEN); + InternalAddress::IbcToken(hash) + }) } } diff --git a/shared/src/types/token.rs b/shared/src/types/token.rs index 2831b532fab..8b811f6de89 100644 --- a/shared/src/types/token.rs +++ b/shared/src/types/token.rs @@ -9,7 +9,7 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use serde::{Deserialize, Serialize}; use thiserror::Error; -use crate::types::address::{Address, Error as AddressError, InternalAddress}; +use crate::types::address::{Address, Error as AddressError}; use crate::types::ibc::data::FungibleTokenPacketData; use crate::types::storage::{DbKeySeg, Key, KeySeg}; @@ -302,24 +302,6 @@ pub fn is_any_token_balance_key(key: &Key) -> Option<&Address> { } } -/// Check if the given storage key is non-owner's balance key. If it is, returns -/// the address. -pub fn is_non_owner_balance_key(key: &Key) -> Option<&Address> { - match &key.segments[..] { - [ - DbKeySeg::AddressSeg(_), - DbKeySeg::StringSeg(key), - DbKeySeg::AddressSeg(owner), - ] if key == BALANCE_STORAGE_KEY => match owner { - Address::Internal(InternalAddress::IbcEscrow(_)) - | Address::Internal(InternalAddress::IbcBurn) - | Address::Internal(InternalAddress::IbcMint) => Some(owner), - _ => None, - }, - _ => None, - } -} - /// Check if the given storage key is multitoken balance key for the given /// token. If it is, returns the sub prefix and the owner. pub fn is_multitoken_balance_key<'a>( diff --git a/tests/src/vm_host_env/ibc.rs b/tests/src/vm_host_env/ibc.rs index c9f03d34506..3803ebe774d 100644 --- a/tests/src/vm_host_env/ibc.rs +++ b/tests/src/vm_host_env/ibc.rs @@ -146,16 +146,16 @@ pub fn validate_ibc_vp_from_tx<'a>( pub fn validate_token_vp_from_tx<'a>( tx_env: &'a TestTxEnv, tx: &'a Tx, - addr: &Address, + target: &Key, ) -> std::result::Result { let (verifiers, keys_changed) = tx_env .write_log .verifiers_and_changed_keys(&tx_env.verifiers); - if !verifiers.contains(addr) { + if !keys_changed.contains(target) { panic!( - "The given token address {} isn't part of the tx verifiers set: \ + "The given target address {} isn't part of the tx verifiers set: \ {:#?}", - addr, verifiers + target, keys_changed, ); } let (vp_wasm_cache, _vp_cache_dir) = @@ -176,40 +176,6 @@ pub fn validate_token_vp_from_tx<'a>( TestIbcTokenVp { token }.validate(tx.data.as_ref().unwrap()) } -// /// Initialize the native token VP for the given address -// pub fn init_token_vp_from_tx<'a>( -// tx_env: &'a TestTxEnv, -// tx: &'a Tx, -// addr: &Address, -// ) -> (TestIbcTokenVp<'a>, TempDir) { -// let (verifiers, keys_changed) = tx_env -// .write_log -// .verifiers_and_changed_keys(&tx_env.verifiers); -// if !verifiers.contains(addr) { -// panic!( -// "The given token address {} isn't part of the tx verifiers set: \ -// {:#?}", -// addr, verifiers -// ); -// } -// let (vp_wasm_cache, vp_cache_dir) = -// wasm::compilation_cache::common::testing::cache(); - -// let ctx = Ctx::new( -// &ADDRESS, -// &tx_env.storage, -// &tx_env.write_log, -// tx, -// VpGasMeter::new(0), -// &keys_changed, -// &verifiers, -// vp_wasm_cache, -// ); -// let token = IbcToken { ctx }; - -// (TestIbcTokenVp { token }, vp_cache_dir) -// } - /// Initialize the test storage. Requires initialized [`tx_host_env::ENV`]. pub fn init_storage() -> (Address, Address) { tx_host_env::with(|env| { diff --git a/tests/src/vm_host_env/mod.rs b/tests/src/vm_host_env/mod.rs index 3325c6eb6a7..c44cc25c2e7 100644 --- a/tests/src/vm_host_env/mod.rs +++ b/tests/src/vm_host_env/mod.rs @@ -23,6 +23,7 @@ mod tests { use itertools::Itertools; use namada::ibc::tx_msg::Msg; use namada::ledger::ibc::handler::IbcActions; + use namada::ledger::ibc::storage as ibc_storage; use namada::ledger::ibc::vp::{ get_dummy_header as tm_dummy_header, Error as IbcError, }; @@ -1215,11 +1216,14 @@ mod tests { let result = ibc::validate_ibc_vp_from_tx(&env, &tx); assert!(result.expect("validation failed unexpectedly")); // Check if the token was escrowed - let escrow = address::Address::Internal( - address::InternalAddress::ibc_escrow_address( - msg.source_port.to_string(), - msg.source_channel.to_string(), - ), + let key_prefix = ibc_storage::ibc_account_prefix( + &msg.source_port, + &msg.source_channel, + &token, + ); + let escrow = token::multitoken_balance_key( + &key_prefix, + &address::Address::Internal(address::InternalAddress::IbcEscrow), ); let token_vp_result = ibc::validate_token_vp_from_tx(&env, &tx, &escrow); @@ -1266,6 +1270,12 @@ mod tests { let (port_id, channel_id, channel_writes) = ibc::prepare_opened_channel(&conn_id, false); writes.extend(channel_writes); + // the origin-specific token + let denom = format!("{}/{}/{}", port_id, channel_id, token); + let key_prefix = ibc_storage::ibc_token_prefix(&denom).unwrap(); + let key = token::multitoken_balance_key(&key_prefix, &sender); + let init_bal = Amount::from(1_000_000_000u64); + writes.insert(key, init_bal.try_to_vec().unwrap()); writes.into_iter().for_each(|(key, val)| { tx_host_env::with(|env| { env.storage.write(&key, &val).expect("write error"); @@ -1274,8 +1284,9 @@ mod tests { // Start a transaction to send a packet // Set this chain is the sink zone - let token = format!("{}/{}/{}", port_id, channel_id, token); - let msg = ibc::msg_transfer(port_id, channel_id, token, &sender); + let denom = format!("{}/{}/{}", port_id, channel_id, token); + let msg = + ibc::msg_transfer(port_id.clone(), channel_id, denom, &sender); let mut tx_data = vec![]; msg.to_any().encode(&mut tx_data).expect("encoding failed"); let tx = Tx { @@ -1294,8 +1305,12 @@ mod tests { let result = ibc::validate_ibc_vp_from_tx(&env, &tx); assert!(result.expect("validation failed unexpectedly")); // Check if the token was burned - let burn = - address::Address::Internal(address::InternalAddress::IbcBurn); + let key_prefix = + ibc_storage::ibc_account_prefix(&port_id, &channel_id, &token); + let burn = token::multitoken_balance_key( + &key_prefix, + &address::Address::Internal(address::InternalAddress::IbcBurn), + ); let result = ibc::validate_token_vp_from_tx(&env, &tx, &burn); assert!(result.expect("token validation failed unexpectedly")); } @@ -1313,6 +1328,13 @@ mod tests { let (port_id, channel_id, channel_writes) = ibc::prepare_opened_channel(&conn_id, false); writes.extend(channel_writes); + // the origin-specific token + let denom = format!("{}/{}/{}", port_id, channel_id, token); + let key_prefix = ibc_storage::ibc_token_prefix(&denom).unwrap(); + let key = token::multitoken_balance_key(&key_prefix, &receiver); + let init_bal = Amount::from(1_000_000_000u64); + writes.insert(key, init_bal.try_to_vec().unwrap()); + writes.into_iter().for_each(|(key, val)| { tx_host_env::with(|env| { env.storage.write(&key, &val).expect("write error"); @@ -1321,7 +1343,7 @@ mod tests { // packet let packet = ibc::received_packet( - port_id, + port_id.clone(), channel_id, ibc::sequence(1), token.to_string(), @@ -1348,8 +1370,12 @@ mod tests { let result = ibc::validate_ibc_vp_from_tx(&env, &tx); assert!(result.expect("validation failed unexpectedly")); // Check if the token was minted - let mint = - address::Address::Internal(address::InternalAddress::IbcMint); + let key_prefix = + ibc_storage::ibc_account_prefix(&port_id, &channel_id, &token); + let mint = token::multitoken_balance_key( + &key_prefix, + &address::Address::Internal(address::InternalAddress::IbcMint), + ); let result = ibc::validate_token_vp_from_tx(&env, &tx, &mint); assert!(result.expect("token validation failed unexpectedly")); } @@ -1373,20 +1399,19 @@ mod tests { }); }); // escrow in advance - let counterparty = ibc::dummy_channel_counterparty(); - let escrow = address::Address::Internal( - address::InternalAddress::ibc_escrow_address( - port_id.to_string(), - channel_id.to_string(), - ), + let key_prefix = + ibc_storage::ibc_account_prefix(&port_id, &channel_id, &token); + let escrow = token::multitoken_balance_key( + &key_prefix, + &address::Address::Internal(address::InternalAddress::IbcEscrow), ); - let key = token::balance_key(&token, &escrow); let val = Amount::from(1_000_000_000u64).try_to_vec().unwrap(); tx_host_env::with(|env| { - env.storage.write(&key, &val).expect("write error"); + env.storage.write(&escrow, &val).expect("write error"); }); // Set this chain as the source zone + let counterparty = ibc::dummy_channel_counterparty(); let token = format!( "{}/{}/{}", counterparty.port_id().clone(), @@ -1612,11 +1637,14 @@ mod tests { let result = ibc::validate_ibc_vp_from_tx(&env, &tx); assert!(result.expect("validation failed unexpectedly")); // Check if the token was refunded - let escrow = address::Address::Internal( - address::InternalAddress::ibc_escrow_address( - packet.source_port.to_string(), - packet.source_channel.to_string(), - ), + let key_prefix = ibc_storage::ibc_account_prefix( + &packet.source_port, + &packet.source_channel, + &token, + ); + let escrow = token::multitoken_balance_key( + &key_prefix, + &address::Address::Internal(address::InternalAddress::IbcEscrow), ); let result = ibc::validate_token_vp_from_tx(&env, &tx, &escrow); assert!(result.expect("token validation failed unexpectedly")); @@ -1681,11 +1709,14 @@ mod tests { let result = ibc::validate_ibc_vp_from_tx(&env, &tx); assert!(result.expect("validation failed unexpectedly")); // Check if the token was refunded - let escrow = address::Address::Internal( - address::InternalAddress::ibc_escrow_address( - packet.source_port.to_string(), - packet.source_channel.to_string(), - ), + let key_prefix = ibc_storage::ibc_account_prefix( + &packet.source_port, + &packet.source_channel, + &token, + ); + let escrow = token::multitoken_balance_key( + &key_prefix, + &address::Address::Internal(address::InternalAddress::IbcEscrow), ); let result = ibc::validate_token_vp_from_tx(&env, &tx, &escrow); assert!(result.expect("token validation failed unexpectedly")); From 49c7cefb3eebde85fecd01a2d8acbb368429d065 Mon Sep 17 00:00:00 2001 From: yito88 Date: Mon, 29 Aug 2022 19:34:43 +0200 Subject: [PATCH 04/36] add denom.rs --- shared/src/ledger/ibc/vp/denom.rs | 87 +++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 shared/src/ledger/ibc/vp/denom.rs diff --git a/shared/src/ledger/ibc/vp/denom.rs b/shared/src/ledger/ibc/vp/denom.rs new file mode 100644 index 00000000000..bdfe31be47e --- /dev/null +++ b/shared/src/ledger/ibc/vp/denom.rs @@ -0,0 +1,87 @@ +//! IBC validity predicate for denom + +use thiserror::Error; + +use super::Ibc; +use crate::ledger::ibc::storage; +use crate::ledger::storage::{self as ledger_storage, StorageHasher}; +use crate::types::ibc::data::{ + Error as IbcDataError, FungibleTokenPacketData, IbcMessage, +}; +use crate::types::storage::KeySeg; +use crate::vm::WasmCacheAccess; + +#[allow(missing_docs)] +#[derive(Error, Debug)] +pub enum Error { + #[error("Decoding TX data error: {0}")] + DecodingTxData(std::io::Error), + #[error("IBC data error: {0}")] + InvalidIbcData(IbcDataError), + #[error("Invalid packet data: {0}")] + PacketData(String), + #[error("Denom error: {0}")] + Denom(String), +} + +/// IBC channel functions result +pub type Result = std::result::Result; + +impl<'a, DB, H, CA> Ibc<'a, DB, H, CA> +where + DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, + H: 'static + StorageHasher, + CA: 'static + WasmCacheAccess, +{ + pub(super) fn validate_denom(&self, tx_data: &[u8]) -> Result<()> { + let ibc_msg = IbcMessage::decode(tx_data)?; + let msg = ibc_msg.msg_recv_packet()?; + match serde_json::from_slice::( + &msg.packet.data, + ) { + Ok(data) => { + let denom = format!( + "{}/{}/{}", + &msg.packet.destination_port, + &msg.packet.destination_channel, + &data.denom + ); + let token_hash = storage::calc_hash(&denom); + let denom_key = storage::ibc_denom_key(&token_hash.raw()); + match self.ctx.read_post(&denom_key) { + Ok(Some(v)) => match std::str::from_utf8(&v) { + Ok(d) if d == denom => Ok(()), + Ok(d) => Err(Error::Denom(format!( + "Mismatch the denom: original {}, denom {}", + denom, d + ))), + Err(e) => Err(Error::Denom(format!( + "Decoding the denom failed: key {}, error {}", + denom_key, e + ))), + }, + _ => Err(Error::Denom(format!( + "Looking up the denom failed: Key {}", + denom_key + ))), + } + } + Err(e) => Err(Error::PacketData(format!( + "unknown packet data: error {}", + e + ))), + } + } +} + +impl From for Error { + fn from(err: IbcDataError) -> Self { + Self::InvalidIbcData(err) + } +} + +impl From for Error { + fn from(err: std::io::Error) -> Self { + Self::DecodingTxData(err) + } +} From ee601e03603824d84940703d872897423be1484c Mon Sep 17 00:00:00 2001 From: yito88 Date: Mon, 17 Oct 2022 22:33:23 +0200 Subject: [PATCH 05/36] fix VP reads --- shared/src/ledger/ibc/handler.rs | 44 ++++++++++++++++-------------- shared/src/ledger/ibc/vp/denom.rs | 3 +- shared/src/ledger/ibc/vp/packet.rs | 3 +- shared/src/ledger/ibc/vp/token.rs | 43 ++++++++++++++--------------- tests/src/vm_host_env/ibc.rs | 2 +- tx_prelude/src/ibc.rs | 10 +++---- 6 files changed, 52 insertions(+), 53 deletions(-) diff --git a/shared/src/ledger/ibc/handler.rs b/shared/src/ledger/ibc/handler.rs index 61592974ff7..7a0ae1a8589 100644 --- a/shared/src/ledger/ibc/handler.rs +++ b/shared/src/ledger/ibc/handler.rs @@ -936,10 +936,12 @@ pub trait IbcActions { msg: &MsgTransfer, ) -> std::result::Result<(), Self::Error> { let mut data = FungibleTokenPacketData::from(msg.clone()); - if let Some(hash) = storage::token_hash_from_denom(&data.denom)? { + if let Some(hash) = storage::token_hash_from_denom(&data.denom) + .map_err(Error::IbcStorage)? + { let denom_key = storage::ibc_denom_key(&hash); let denom_bytes = - self.read_ibc_data(&denom_key).ok_or_else(|| { + self.read_ibc_data(&denom_key)?.ok_or_else(|| { Error::SendingToken(format!( "No original denom: denom_key {}", denom_key @@ -953,7 +955,7 @@ pub trait IbcActions { })?; data.denom = denom.to_string(); } - let token = storage::token(&data.denom)?; + let token = storage::token(&data.denom).map_err(Error::IbcStorage)?; let amount = Amount::from_str(&data.amount).map_err(|e| { Error::SendingToken(format!( "Invalid amount: amount {}, error {}", @@ -978,7 +980,8 @@ pub trait IbcActions { let (source, target) = if data.denom.starts_with(&prefix) { // the receiver's chain was the source // transfer from the origin-specific account of the token - let key_prefix = storage::ibc_token_prefix(&data.denom)?; + let key_prefix = storage::ibc_token_prefix(&data.denom) + .map_err(Error::IbcStorage)?; let src = token::multitoken_balance_key(&key_prefix, &source_addr); let key_prefix = storage::ibc_account_prefix( @@ -997,7 +1000,8 @@ pub trait IbcActions { let src = if data.denom == token.to_string() { token::balance_key(&token, &source_addr) } else { - let key_prefix = storage::ibc_token_prefix(&data.denom)?; + let key_prefix = storage::ibc_token_prefix(&data.denom) + .map_err(Error::IbcStorage)?; token::multitoken_balance_key(&key_prefix, &source_addr) }; @@ -1012,7 +1016,7 @@ pub trait IbcActions { ); (src, escrow) }; - self.transfer_token(&source, &target, amount); + self.transfer_token(&source, &target, amount)?; // send a packet let port_channel_id = @@ -1033,7 +1037,7 @@ pub trait IbcActions { packet: &Packet, data: &FungibleTokenPacketData, ) -> std::result::Result<(), Self::Error> { - let token = storage::token(&data.denom)?; + let token = storage::token(&data.denom).map_err(Error::IbcStorage)?; let amount = Amount::from_str(&data.amount).map_err(|e| { Error::ReceivingToken(format!( "Invalid amount: amount {}, error {}", @@ -1070,7 +1074,8 @@ pub trait IbcActions { let dest = if denom == token.to_string() { token::balance_key(&token, &dest_addr) } else { - let key_prefix = storage::ibc_token_prefix(denom)?; + let key_prefix = storage::ibc_token_prefix(denom) + .map_err(Error::IbcStorage)?; token::multitoken_balance_key(&key_prefix, &dest_addr) }; (escrow, dest) @@ -1094,19 +1099,20 @@ pub trait IbcActions { &packet.destination_channel, &data.denom ); - let key_prefix = storage::ibc_token_prefix(&denom)?; + let key_prefix = storage::ibc_token_prefix(&denom) + .map_err(Error::IbcStorage)?; let dest = token::multitoken_balance_key(&key_prefix, &dest_addr); // store the prefixed denom let token_hash = storage::calc_hash(&denom); let denom_key = storage::ibc_denom_key(token_hash); - self.write_ibc_data(&denom_key, denom.as_bytes()); + self.write_ibc_data(&denom_key, denom.as_bytes())?; (mint, dest) } }; - self.transfer_token(&source, &target, amount); + self.transfer_token(&source, &target, amount)?; Ok(()) } @@ -1117,7 +1123,7 @@ pub trait IbcActions { packet: &Packet, data: &FungibleTokenPacketData, ) -> std::result::Result<(), Self::Error> { - let token = storage::token(&data.denom)?; + let token = storage::token(&data.denom).map_err(Error::IbcStorage)?; let amount = Amount::from_str(&data.amount).map_err(|e| { Error::ReceivingToken(format!( "Invalid amount: amount {}, error {}", @@ -1148,7 +1154,8 @@ pub trait IbcActions { &key_prefix, &Address::Internal(InternalAddress::IbcMint), ); - let key_prefix = storage::ibc_token_prefix(&data.denom)?; + let key_prefix = storage::ibc_token_prefix(&data.denom) + .map_err(Error::IbcStorage)?; let dest = token::multitoken_balance_key(&key_prefix, &dest_addr); (mint, dest) } else { @@ -1156,7 +1163,8 @@ pub trait IbcActions { let dest = if data.denom == token.to_string() { token::balance_key(&token, &dest_addr) } else { - let key_prefix = storage::ibc_token_prefix(&data.denom)?; + let key_prefix = storage::ibc_token_prefix(&data.denom) + .map_err(Error::IbcStorage)?; token::multitoken_balance_key(&key_prefix, &dest_addr) }; @@ -1171,7 +1179,7 @@ pub trait IbcActions { ); (escrow, dest) }; - self.transfer_token(&source, &target, amount); + self.transfer_token(&source, &target, amount)?; Ok(()) } @@ -1597,9 +1605,3 @@ pub fn make_timeout_event(packet: Packet) -> IbcEvent { packet, }) } - -impl From for Error { - fn from(err: storage::Error) -> Self { - Self::IbcStorage(err) - } -} diff --git a/shared/src/ledger/ibc/vp/denom.rs b/shared/src/ledger/ibc/vp/denom.rs index bdfe31be47e..40e95c51c2d 100644 --- a/shared/src/ledger/ibc/vp/denom.rs +++ b/shared/src/ledger/ibc/vp/denom.rs @@ -4,6 +4,7 @@ use thiserror::Error; use super::Ibc; use crate::ledger::ibc::storage; +use crate::ledger::native_vp::VpEnv; use crate::ledger::storage::{self as ledger_storage, StorageHasher}; use crate::types::ibc::data::{ Error as IbcDataError, FungibleTokenPacketData, IbcMessage, @@ -48,7 +49,7 @@ where ); let token_hash = storage::calc_hash(&denom); let denom_key = storage::ibc_denom_key(&token_hash.raw()); - match self.ctx.read_post(&denom_key) { + match self.ctx.read_bytes_post(&denom_key) { Ok(Some(v)) => match std::str::from_utf8(&v) { Ok(d) if d == denom => Ok(()), Ok(d) => Err(Error::Denom(format!( diff --git a/shared/src/ledger/ibc/vp/packet.rs b/shared/src/ledger/ibc/vp/packet.rs index 026b56ff2f8..aafb8890b62 100644 --- a/shared/src/ledger/ibc/vp/packet.rs +++ b/shared/src/ledger/ibc/vp/packet.rs @@ -33,6 +33,7 @@ use crate::ibc::core::ics24_host::identifier::{ }; use crate::ibc::core::ics26_routing::msgs::Ics26Envelope; use crate::ibc::proofs::Proofs; +use crate::ledger::native_vp::VpEnv; use crate::ledger::storage::{self, StorageHasher}; use crate::types::ibc::data::{ Error as IbcDataError, FungibleTokenPacketData, IbcMessage, @@ -711,7 +712,7 @@ where })? { let denom_key = ibc_denom_key(&token_hash); - let denom_bytes = match self.ctx.read_pre(&denom_key) { + let denom_bytes = match self.ctx.read_bytes_pre(&denom_key) { Ok(Some(v)) => v, _ => { return Err(Error::Denom(format!( diff --git a/shared/src/ledger/ibc/vp/token.rs b/shared/src/ledger/ibc/vp/token.rs index 917361eaf22..fd7ad298323 100644 --- a/shared/src/ledger/ibc/vp/token.rs +++ b/shared/src/ledger/ibc/vp/token.rs @@ -148,7 +148,7 @@ where })? { let denom_key = ibc_storage::ibc_denom_key(&token_hash); - let denom_bytes = match self.ctx.read_pre(&denom_key) { + let denom_bytes = match self.ctx.read_bytes_pre(&denom_key) { Ok(Some(v)) => v, _ => { return Err(Error::Denom(format!( @@ -174,7 +174,7 @@ where .strip_prefix(&format!("{}/", ibc_storage::MULTITOKEN_STORAGE_KEY)) { let denom_key = ibc_storage::ibc_denom_key(&denom); - match self.ctx.read_pre(&denom_key)? { + match self.ctx.read_bytes_pre(&denom_key)? { Some(v) => std::str::from_utf8(&v) .map_err(|e| { Error::TokenTransfer(format!( @@ -213,9 +213,10 @@ where &key_prefix, &Address::Internal(InternalAddress::IbcBurn), ); - let post = - try_decode_token_amount(self.ctx.read_temp(&target_key)?)? - .unwrap_or_default(); + let post = try_decode_token_amount( + self.ctx.read_bytes_temp(&target_key)?, + )? + .unwrap_or_default(); // the previous balance of the burn address should be zero post.change() } else { @@ -225,10 +226,8 @@ where &key_prefix, &Address::Internal(InternalAddress::IbcEscrow), ); - let pre = try_decode_token_amount(self.ctx.read_pre(&target_key)?)? - .unwrap_or_default(); - let post = - try_decode_token_amount(self.ctx.read_post(&target_key)?)? + let pre = + try_decode_token_amount(self.ctx.read_bytes_pre(&target_key)?)? .unwrap_or_default(); let post = try_decode_token_amount( self.ctx.read_bytes_post(&target_key)?, @@ -272,10 +271,8 @@ where &key_prefix, &Address::Internal(InternalAddress::IbcEscrow), ); - let pre = try_decode_token_amount(self.ctx.read_pre(&source_key)?)? - .unwrap_or_default(); - let post = - try_decode_token_amount(self.ctx.read_post(&source_key)?)? + let pre = + try_decode_token_amount(self.ctx.read_bytes_pre(&source_key)?)? .unwrap_or_default(); let post = try_decode_token_amount( self.ctx.read_bytes_post(&source_key)?, @@ -289,9 +286,10 @@ where &key_prefix, &Address::Internal(InternalAddress::IbcMint), ); - let post = - try_decode_token_amount(self.ctx.read_temp(&source_key)?)? - .unwrap_or_default(); + let post = try_decode_token_amount( + self.ctx.read_bytes_temp(&source_key)?, + )? + .unwrap_or_default(); // the previous balance of the mint address should be the maximum Amount::max().change() - post.change() }; @@ -331,9 +329,10 @@ where &key_prefix, &Address::Internal(InternalAddress::IbcMint), ); - let post = - try_decode_token_amount(self.ctx.read_temp(&source_key)?)? - .unwrap_or_default(); + let post = try_decode_token_amount( + self.ctx.read_bytes_temp(&source_key)?, + )? + .unwrap_or_default(); // the previous balance of the mint address should be the maximum Amount::max().change() - post.change() } else { @@ -342,10 +341,8 @@ where &key_prefix, &Address::Internal(InternalAddress::IbcEscrow), ); - let pre = try_decode_token_amount(self.ctx.read_pre(&source_key)?)? - .unwrap_or_default(); - let post = - try_decode_token_amount(self.ctx.read_post(&source_key)?)? + let pre = + try_decode_token_amount(self.ctx.read_bytes_pre(&source_key)?)? .unwrap_or_default(); let post = try_decode_token_amount( self.ctx.read_bytes_post(&source_key)?, diff --git a/tests/src/vm_host_env/ibc.rs b/tests/src/vm_host_env/ibc.rs index 3803ebe774d..4b21e97b79f 100644 --- a/tests/src/vm_host_env/ibc.rs +++ b/tests/src/vm_host_env/ibc.rs @@ -65,7 +65,7 @@ use namada::proto::Tx; use namada::tendermint_proto::Protobuf; use namada::types::address::{self, Address, InternalAddress}; use namada::types::ibc::data::{FungibleTokenPacketData, PacketAck}; -use namada::types::storage::{self, BlockHash, BlockHeight}; +use namada::types::storage::{self, BlockHash, BlockHeight, Key}; use namada::types::token::{self, Amount}; use namada::vm::{wasm, WasmCacheRwAccess}; use namada_tx_prelude::StorageWrite; diff --git a/tx_prelude/src/ibc.rs b/tx_prelude/src/ibc.rs index cd2f0a12934..e17270cfb90 100644 --- a/tx_prelude/src/ibc.rs +++ b/tx_prelude/src/ibc.rs @@ -3,13 +3,12 @@ pub use namada::ledger::ibc::handler::{Error, IbcActions, Result}; use namada::ledger::storage_api::{StorageRead, StorageWrite}; use namada::ledger::tx_env::TxEnv; -use namada::types::address::Address; pub use namada::types::ibc::IbcEvent; use namada::types::storage::{BlockHeight, Key}; use namada::types::time::Rfc3339String; use namada::types::token::Amount; -use crate::token::transfer; +use crate::token::transfer_with_keys; use crate::Ctx; impl IbcActions for Ctx { @@ -50,12 +49,11 @@ impl IbcActions for Ctx { fn transfer_token( &mut self, - src: &Address, - dest: &Address, - token: &Address, + src: &Key, + dest: &Key, amount: Amount, ) -> std::result::Result<(), Self::Error> { - transfer(self, src, dest, token, None, amount)?; + transfer_with_keys(self, src, dest, amount)?; Ok(()) } From 3357a1de008240cd6136620d75d0df76012886e1 Mon Sep 17 00:00:00 2001 From: yito88 Date: Mon, 17 Oct 2022 23:34:47 +0200 Subject: [PATCH 06/36] add ibc-transfer command --- apps/src/bin/anoma-client/cli.rs | 3 + apps/src/bin/anoma/cli.rs | 1 + apps/src/lib/cli.rs | 95 ++++++++++++++++++++++++++++++ apps/src/lib/client/tx.rs | 99 ++++++++++++++++++++++++++++++++ 4 files changed, 198 insertions(+) diff --git a/apps/src/bin/anoma-client/cli.rs b/apps/src/bin/anoma-client/cli.rs index b87cdb5c661..5b084c842ec 100644 --- a/apps/src/bin/anoma-client/cli.rs +++ b/apps/src/bin/anoma-client/cli.rs @@ -18,6 +18,9 @@ pub async fn main() -> Result<()> { Sub::TxTransfer(TxTransfer(args)) => { tx::submit_transfer(ctx, args).await; } + Sub::TxIbcTransfer(TxIbcTransfer(args)) => { + tx::submit_ibc_transfer(ctx, args).await; + } Sub::TxUpdateVp(TxUpdateVp(args)) => { tx::submit_update_vp(ctx, args).await; } diff --git a/apps/src/bin/anoma/cli.rs b/apps/src/bin/anoma/cli.rs index ccde0c36185..cda1e8bc630 100644 --- a/apps/src/bin/anoma/cli.rs +++ b/apps/src/bin/anoma/cli.rs @@ -45,6 +45,7 @@ fn handle_command(cmd: cli::cmds::Anoma, raw_sub_cmd: String) -> Result<()> { cli::cmds::Anoma::Client(_) | cli::cmds::Anoma::TxCustom(_) | cli::cmds::Anoma::TxTransfer(_) + | cli::cmds::Anoma::TxIbcTransfer(_) | cli::cmds::Anoma::TxUpdateVp(_) | cli::cmds::Anoma::TxInitNft(_) | cli::cmds::Anoma::TxMintNft(_) diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index 4534d5bc0db..ea70f137b6d 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -46,6 +46,7 @@ pub mod cmds { // Inlined commands from the client. TxCustom(TxCustom), TxTransfer(TxTransfer), + TxIbcTransfer(TxIbcTransfer), TxUpdateVp(TxUpdateVp), TxInitNft(TxInitNft), TxMintNft(TxMintNft), @@ -61,6 +62,7 @@ pub mod cmds { .subcommand(Ledger::def()) .subcommand(TxCustom::def()) .subcommand(TxTransfer::def()) + .subcommand(TxIbcTransfer::def()) .subcommand(TxUpdateVp::def()) .subcommand(TxInitNft::def()) .subcommand(TxMintNft::def()) @@ -75,6 +77,8 @@ pub mod cmds { let ledger = SubCmd::parse(matches).map(Self::Ledger); let tx_custom = SubCmd::parse(matches).map(Self::TxCustom); let tx_transfer = SubCmd::parse(matches).map(Self::TxTransfer); + let tx_ibc_transfer = + SubCmd::parse(matches).map(Self::TxIbcTransfer); let tx_update_vp = SubCmd::parse(matches).map(Self::TxUpdateVp); let tx_nft_create = SubCmd::parse(matches).map(Self::TxInitNft); let tx_nft_mint = SubCmd::parse(matches).map(Self::TxMintNft); @@ -87,6 +91,7 @@ pub mod cmds { .or(ledger) .or(tx_custom) .or(tx_transfer) + .or(tx_ibc_transfer) .or(tx_update_vp) .or(tx_nft_create) .or(tx_nft_mint) @@ -152,6 +157,7 @@ pub mod cmds { // Simple transactions .subcommand(TxCustom::def().display_order(1)) .subcommand(TxTransfer::def().display_order(1)) + .subcommand(TxIbcTransfer::def().display_order(1)) .subcommand(TxUpdateVp::def().display_order(1)) .subcommand(TxInitAccount::def().display_order(1)) .subcommand(TxInitValidator::def().display_order(1)) @@ -184,6 +190,7 @@ pub mod cmds { use AnomaClientWithContext::*; let tx_custom = Self::parse_with_ctx(matches, TxCustom); let tx_transfer = Self::parse_with_ctx(matches, TxTransfer); + let tx_ibc_transfer = Self::parse_with_ctx(matches, TxIbcTransfer); let tx_update_vp = Self::parse_with_ctx(matches, TxUpdateVp); let tx_init_account = Self::parse_with_ctx(matches, TxInitAccount); let tx_init_validator = @@ -213,6 +220,7 @@ pub mod cmds { let utils = SubCmd::parse(matches).map(Self::WithoutContext); tx_custom .or(tx_transfer) + .or(tx_ibc_transfer) .or(tx_update_vp) .or(tx_init_account) .or(tx_init_validator) @@ -271,6 +279,7 @@ pub mod cmds { // Ledger cmds TxCustom(TxCustom), TxTransfer(TxTransfer), + TxIbcTransfer(TxIbcTransfer), QueryResult(QueryResult), TxUpdateVp(TxUpdateVp), TxInitAccount(TxInitAccount), @@ -794,6 +803,25 @@ pub mod cmds { } } + #[derive(Clone, Debug)] + pub struct TxIbcTransfer(pub args::TxIbcTransfer); + + impl SubCmd for TxIbcTransfer { + const CMD: &'static str = "ibc-transfer"; + + fn parse(matches: &ArgMatches) -> Option { + matches.subcommand_matches(Self::CMD).map(|matches| { + TxIbcTransfer(args::TxIbcTransfer::parse(matches)) + }) + } + + fn def() -> App { + App::new(Self::CMD) + .about("Send a signed IBC transfer transaction.") + .add_args::() + } + } + #[derive(Clone, Debug)] pub struct TxUpdateVp(pub args::TxUpdateVp); @@ -1248,6 +1276,7 @@ pub mod args { use std::path::PathBuf; use std::str::FromStr; + use namada::ibc::core::ics24_host::identifier::{ChannelId, PortId}; use namada::types::address::Address; use namada::types::chain::{ChainId, ChainIdPrefix}; use namada::types::governance::ProposalVote; @@ -1281,6 +1310,7 @@ pub mod args { const CHAIN_ID: Arg = arg("chain-id"); const CHAIN_ID_OPT: ArgOpt = CHAIN_ID.opt(); const CHAIN_ID_PREFIX: Arg = arg("chain-prefix"); + const CHANNEL_ID: Arg = arg("channel-id"); const CODE_PATH: Arg = arg("code-path"); const CODE_PATH_OPT: ArgOpt = CODE_PATH.opt(); const CONSENSUS_TIMEOUT_COMMIT: ArgDefault = arg_default( @@ -1318,6 +1348,10 @@ pub mod args { const NET_ADDRESS: Arg = arg("net-address"); const NFT_ADDRESS: Arg
= arg("nft-address"); const OWNER: ArgOpt = arg_opt("owner"); + const PORT_ID: ArgDefault = arg_default( + "port-id", + DefaultFn(|| PortId::from_str("transfer").unwrap()), + ); const PROPOSAL_OFFLINE: ArgFlag = flag("offline"); const PROTOCOL_KEY: ArgOpt = arg_opt("protocol-key"); const PRE_GENESIS_PATH: ArgOpt = arg_opt("pre-genesis-path"); @@ -1328,6 +1362,7 @@ pub mod args { const RAW_ADDRESS: Arg
= arg("address"); const RAW_ADDRESS_OPT: ArgOpt
= RAW_ADDRESS.opt(); const RAW_PUBLIC_KEY_OPT: ArgOpt = arg_opt("public-key"); + const RECEIVER: Arg = arg("receiver"); const REWARDS_CODE_PATH: ArgOpt = arg_opt("rewards-code-path"); const REWARDS_KEY: ArgOpt = arg_opt("rewards-key"); const SCHEME: ArgDefault = @@ -1515,6 +1550,66 @@ pub mod args { } } + /// IBC transfer transaction arguments + #[derive(Clone, Debug)] + pub struct TxIbcTransfer { + /// Common tx arguments + pub tx: Tx, + /// Transfer source address + pub source: WalletAddress, + /// Transfer target address + pub receiver: String, + /// Transferred token address + pub token: WalletAddress, + /// Transferred token address + pub sub_prefix: Option, + /// Transferred token amount + pub amount: token::Amount, + /// Port ID + pub port_id: PortId, + /// Channel ID + pub channel_id: ChannelId, + } + + impl Args for TxIbcTransfer { + fn parse(matches: &ArgMatches) -> Self { + let tx = Tx::parse(matches); + let source = SOURCE.parse(matches); + let receiver = RECEIVER.parse(matches); + let token = TOKEN.parse(matches); + let sub_prefix = SUB_PREFIX.parse(matches); + let amount = AMOUNT.parse(matches); + let port_id = PORT_ID.parse(matches); + let channel_id = CHANNEL_ID.parse(matches); + Self { + tx, + source, + receiver, + token, + sub_prefix, + amount, + port_id, + channel_id, + } + } + + fn def(app: App) -> App { + app.add_args::() + .arg(SOURCE.def().about( + "The source account address. The source's key is used to \ + produce the signature.", + )) + .arg(RECEIVER.def().about( + "The receiver address on the destination chain as string.", + )) + .arg(TOKEN.def().about("The transfer token.")) + .arg(SUB_PREFIX.def().about("The token's sub prefix.")) + .arg(AMOUNT.def().about("The amount to transfer in decimal.")) + .arg(PORT_ID.def().about("The port ID.")) + .arg(CHANNEL_ID.def().about("The channel ID.")) + } + } + /// Transaction to initialize a new account #[derive(Clone, Debug)] pub struct TxInitAccount { diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index 7a4d542536a..4dd3e12e788 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -8,6 +8,12 @@ use async_std::io::prelude::WriteExt; use async_std::io::{self}; use borsh::BorshSerialize; use itertools::Either::*; +use namada::ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; +use namada::ibc::signer::Signer; +use namada::ibc::timestamp::Timestamp as IbcTimestamp; +use namada::ibc::tx_msg::Msg; +use namada::ibc::Height as IbcHeight; +use namada::ibc_proto::cosmos::base::v1beta1::Coin; use namada::ledger::governance::storage as gov_storage; use namada::ledger::pos::{BondId, Bonds, Unbonds}; use namada::proto::Tx; @@ -49,6 +55,7 @@ const TX_INIT_PROPOSAL: &str = "tx_init_proposal.wasm"; const TX_VOTE_PROPOSAL: &str = "tx_vote_proposal.wasm"; const TX_UPDATE_VP_WASM: &str = "tx_update_vp.wasm"; const TX_TRANSFER_WASM: &str = "tx_transfer.wasm"; +const TX_IBC_WASM: &str = "tx_ibc.wasm"; const TX_INIT_NFT: &str = "tx_init_nft.wasm"; const TX_MINT_NFT: &str = "tx_mint_nft.wasm"; const VP_USER_WASM: &str = "vp_user.wasm"; @@ -465,6 +472,98 @@ pub async fn submit_transfer(ctx: Context, args: args::TxTransfer) { process_tx(ctx, &args.tx, tx, Some(&args.source)).await; } +pub async fn submit_ibc_transfer(ctx: Context, args: args::TxIbcTransfer) { + let source = ctx.get(&args.source); + // Check that the source address exists on chain + let source_exists = + rpc::known_address(&source, args.tx.ledger_address.clone()).await; + if !source_exists { + eprintln!("The source address {} doesn't exist on chain.", source); + if !args.tx.force { + safe_exit(1) + } + } + + // We cannot check the receiver + + let token = ctx.get(&args.token); + // Check that the token address exists on chain + let token_exists = + rpc::known_address(&token, args.tx.ledger_address.clone()).await; + if !token_exists { + eprintln!("The token address {} doesn't exist on chain.", token); + if !args.tx.force { + safe_exit(1) + } + } + // Check source balance + let (sub_prefix, balance_key) = match args.sub_prefix { + Some(sub_prefix) => { + let sub_prefix = storage::Key::parse(sub_prefix).unwrap(); + let prefix = token::multitoken_balance_prefix(&token, &sub_prefix); + ( + Some(sub_prefix), + token::multitoken_balance_key(&prefix, &source), + ) + } + None => (None, token::balance_key(&token, &source)), + }; + let client = HttpClient::new(args.tx.ledger_address.clone()).unwrap(); + match rpc::query_storage_value::(&client, &balance_key).await + { + Some(balance) => { + if balance < args.amount { + eprintln!( + "The balance of the source {} of token {} is lower than \ + the amount to be transferred. Amount to transfer is {} \ + and the balance is {}.", + source, token, args.amount, balance + ); + if !args.tx.force { + safe_exit(1) + } + } + } + None => { + eprintln!( + "No balance found for the source {} of token {}", + source, token + ); + if !args.tx.force { + safe_exit(1) + } + } + } + let tx_code = ctx.read_wasm(TX_IBC_WASM); + + let denom = match sub_prefix { + Some(sp) => format!("{}/{}", sp, token), + None => token.to_string(), + }; + let token = Some(Coin { + denom, + amount: args.amount.to_string(), + }); + let msg = MsgTransfer { + source_port: args.port_id, + source_channel: args.channel_id, + token, + sender: Signer::new(source.to_string()), + receiver: Signer::new(args.receiver), + // TODO timeout isn't supported for now + timeout_height: IbcHeight::new(0, 1000), + timeout_timestamp: IbcTimestamp::none(), + }; + tracing::debug!("IBC transfer message {:?}", msg); + let any_msg = msg.to_any(); + let mut data = vec![]; + prost::Message::encode(&any_msg, &mut data) + .expect("Encoding tx data shouldn't fail"); + + let tx = Tx::new(tx_code, Some(data)); + process_tx(ctx, &args.tx, tx, Some(&args.source)).await; +} + pub async fn submit_init_nft(ctx: Context, args: args::NftCreate) { let file = File::open(&args.nft_data).expect("File must exist."); let nft: Nft = serde_json::from_reader(file) From b202c2fd3490cc96693a184e278dd67611fc7e34 Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 18 Oct 2022 00:11:56 +0200 Subject: [PATCH 07/36] fix timeout --- apps/src/lib/cli.rs | 16 ++++++++++++++++ apps/src/lib/client/tx.rs | 26 +++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index ea70f137b6d..4b67e25c4f7 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -1375,6 +1375,8 @@ pub mod args { const STORAGE_KEY: Arg = arg("storage-key"); const SUB_PREFIX: ArgOpt = arg_opt("sub-prefix"); const TARGET: Arg = arg("target"); + const TIMEOUT_HEIGHT_OFFSET: ArgOpt = arg_opt("timeout-height-offset"); + const TIMEOUT_SEC_OFFSET: ArgOpt = arg_opt("timeout-sec-offset"); const TOKEN_OPT: ArgOpt = TOKEN.opt(); const TOKEN: Arg = arg("token"); const TX_HASH: Arg = arg("tx-hash"); @@ -1569,6 +1571,10 @@ pub mod args { pub port_id: PortId, /// Channel ID pub channel_id: ChannelId, + /// Timeout height offset + pub timeout_height_offset: Option, + /// Timeout timestamp offset + pub timeout_sec_offset: Option, } impl Args for TxIbcTransfer { @@ -1581,6 +1587,8 @@ pub mod args { let amount = AMOUNT.parse(matches); let port_id = PORT_ID.parse(matches); let channel_id = CHANNEL_ID.parse(matches); + let timeout_height_offset = TIMEOUT_HEIGHT_OFFSET.parse(matches); + let timeout_sec_offset = TIMEOUT_SEC_OFFSET.parse(matches); Self { tx, source, @@ -1590,6 +1598,8 @@ pub mod args { amount, port_id, channel_id, + timeout_height_offset, + timeout_sec_offset, } } @@ -1607,6 +1617,12 @@ pub mod args { .arg(AMOUNT.def().about("The amount to transfer in decimal.")) .arg(PORT_ID.def().about("The port ID.")) .arg(CHANNEL_ID.def().about("The channel ID.")) + .arg( + TIMEOUT_HEIGHT_OFFSET + .def() + .about("The timeout height offset."), + ) + .arg(TIMEOUT_SEC_OFFSET.def().about("The timeout as seconds.")) } } diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index 4dd3e12e788..bc70765793c 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -544,15 +544,35 @@ pub async fn submit_ibc_transfer(ctx: Context, args: args::TxIbcTransfer) { denom, amount: args.amount.to_string(), }); + + let timeout_height = match args.timeout_height_offset { + Some(offset) => { + let current_height: u64 = match client.status().await { + Ok(resp) => resp.sync_info.latest_block_height.into(), + Err(e) => { + eprintln!("Getting the current height failed: {}", e); + safe_exit(1) + } + }; + IbcHeight::new(0, current_height + offset) + } + None => IbcHeight::zero(), + }; + + let timeout_timestamp = if let Some(offset) = args.timeout_sec_offset { + (IbcTimestamp::now() + Duration::new(offset, 0)).unwrap() + } else { + IbcTimestamp::none() + }; + let msg = MsgTransfer { source_port: args.port_id, source_channel: args.channel_id, token, sender: Signer::new(source.to_string()), receiver: Signer::new(args.receiver), - // TODO timeout isn't supported for now - timeout_height: IbcHeight::new(0, 1000), - timeout_timestamp: IbcTimestamp::none(), + timeout_height, + timeout_timestamp, }; tracing::debug!("IBC transfer message {:?}", msg); let any_msg = msg.to_any(); From 3b8f1dd85f211dd072220c300bdb0348b6508ce2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 18 Oct 2022 09:07:30 +0000 Subject: [PATCH 08/36] [ci] wasm checksums update --- wasm/checksums.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/wasm/checksums.json b/wasm/checksums.json index 8ddbe1dc853..680cea0e824 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,18 +1,18 @@ { - "tx_bond.wasm": "tx_bond.865260ca3ca9ed4c611cc5cbc8b4d864232f447f06c59afa0b7c1c63c3fa897c.wasm", - "tx_ibc.wasm": "tx_ibc.1360fdf276c4591d937aaac3bb40ddb573abeba382651474ae23138aac65c3e5.wasm", - "tx_init_account.wasm": "tx_init_account.72d9e1daa43998ce617eafba1547b34f26b128f0fb6e02cfdbc85ecf1f345fd4.wasm", - "tx_init_nft.wasm": "tx_init_nft.22a886305fda24438dbf3fc0f864ee32db4a398bf748edd2fddba1fc4679bc35.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.649bde547179ebee5449f5954425cd266c5063fae97f98f06de327387e8898ba.wasm", - "tx_init_validator.wasm": "tx_init_validator.d40077c1bf1263e1e8e42f54cd893473c5d9c1f395e5d30f44a34d98d9b8dde4.wasm", - "tx_mint_nft.wasm": "tx_mint_nft.78b3a43c5c5b4362cb3023c8e7e25755447e9022952306a62f2d8aab6e99dbee.wasm", - "tx_transfer.wasm": "tx_transfer.4c06f6af1f008fccdd42fefdc8015adea9fa60f802603a8be149ec2c6421656e.wasm", - "tx_unbond.wasm": "tx_unbond.c3d54895e1a271c86838d54d821d52b5bf5764928811cff30767a4445ebbf653.wasm", - "tx_update_vp.wasm": "tx_update_vp.3b709f301e55cb970ec1df98c85c2486561c3243ab1c191d3e078ee345b8b93a.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.671b46a77d03d10ca4e406f2bbc48adba0e541272a2963fd88d3a8c60e888fcd.wasm", - "tx_withdraw.wasm": "tx_withdraw.39e0012e110b19c7000400d11adc355bd8e89605b3c9ca10017c4766eed0ad69.wasm", - "vp_nft.wasm": "vp_nft.b23df820ae3faa13c9ed73121886b712fa0c613b7f43567f528cda05ef75fab6.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.45c740dcfa6e803d55a56cb51b02f2086147dfef3e955c0e8c3f18bf93ae0227.wasm", - "vp_token.wasm": "vp_token.74bca3c9999640c39bbd1c1364b65ffe8086e2d3ed124413251295d527326b57.wasm", - "vp_user.wasm": "vp_user.1c75ea1e55eb1244f023a525f9e20f0d34e52aebf0bd008dcf122fdc13bdf16a.wasm" + "tx_bond.wasm": "tx_bond.f3ba26325f3aa922fd51321361c2725650d176e81e47899bac00774583bd5b83.wasm", + "tx_ibc.wasm": "tx_ibc.609c755f203ea8533ac6785049cef86f17c92fc53e3476febc1104ad2f1ed928.wasm", + "tx_init_account.wasm": "tx_init_account.67ebdbdb799a4a6e7e25b01de31efff1f21be4a0361ff77c74ffde2643d55b91.wasm", + "tx_init_nft.wasm": "tx_init_nft.ce249fb6a4bae1ad0e0d7f82d6091d6c357bbfdcc3a9fbb6d81a1693babb81ca.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.a1dae1cf75f6abccd78d62adc6df7d480e246acc681b894e380d3aecda1d3c5b.wasm", + "tx_init_validator.wasm": "tx_init_validator.ba0557060c670f0604b6e9326c438cc1f5d211bc66d3a8beae2b409a4ce70ed0.wasm", + "tx_mint_nft.wasm": "tx_mint_nft.f466c132545d08a58b5ea1f969b2dbd3267f93d1cde13e38cafd90d26daccf20.wasm", + "tx_transfer.wasm": "tx_transfer.8bb17847b0a69eb71b29fc2f672f5e2bace2c18ac73cacc0fa78738d6ce8a194.wasm", + "tx_unbond.wasm": "tx_unbond.2ce3ac3112c21c2f395dc705598545a8308e8e6071d812cf2c2604158444cb35.wasm", + "tx_update_vp.wasm": "tx_update_vp.e35177857c71be91f6af278d67e0c9704befeec895089376a3ead30d5d38aa74.wasm", + "tx_vote_proposal.wasm": "tx_vote_proposal.567e4954ffdab694ce67beb92219d2e40f91150fd77a371dddb1fcaf3b936347.wasm", + "tx_withdraw.wasm": "tx_withdraw.8042162a4b64afccdbd97e03f687d6470e98b8ec53b1d5b6326daa18f30a7fb0.wasm", + "vp_nft.wasm": "vp_nft.9d70c00149e9b82971bc79d275e717b243aea576b77e533ec1340ab3bc2f80ce.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.7cf7fde2edad89c6997088dcc36aa5b6dbb47614742e85dc50a7f49cc7c3820d.wasm", + "vp_token.wasm": "vp_token.dd90fa4da0f4fc3f024d0b975adac57bc47e224a7a7ad2e4b6658e58ac104381.wasm", + "vp_user.wasm": "vp_user.acd21959bd5cb3277893eaca048c7d94855e79de418af0083ebcecc84b0dba78.wasm" } \ No newline at end of file From fbad8c5cc39b00893c8aa1e713716cc4d2abe0d4 Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 18 Oct 2022 12:26:09 +0200 Subject: [PATCH 09/36] fix timeout height --- apps/src/lib/cli.rs | 14 +++++++------- apps/src/lib/client/tx.rs | 14 +++----------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/apps/src/lib/cli.rs b/apps/src/lib/cli.rs index 4b67e25c4f7..ce53859ee88 100644 --- a/apps/src/lib/cli.rs +++ b/apps/src/lib/cli.rs @@ -1375,7 +1375,7 @@ pub mod args { const STORAGE_KEY: Arg = arg("storage-key"); const SUB_PREFIX: ArgOpt = arg_opt("sub-prefix"); const TARGET: Arg = arg("target"); - const TIMEOUT_HEIGHT_OFFSET: ArgOpt = arg_opt("timeout-height-offset"); + const TIMEOUT_HEIGHT: ArgOpt = arg_opt("timeout-height"); const TIMEOUT_SEC_OFFSET: ArgOpt = arg_opt("timeout-sec-offset"); const TOKEN_OPT: ArgOpt = TOKEN.opt(); const TOKEN: Arg = arg("token"); @@ -1571,8 +1571,8 @@ pub mod args { pub port_id: PortId, /// Channel ID pub channel_id: ChannelId, - /// Timeout height offset - pub timeout_height_offset: Option, + /// Timeout height of the destination chain + pub timeout_height: Option, /// Timeout timestamp offset pub timeout_sec_offset: Option, } @@ -1587,7 +1587,7 @@ pub mod args { let amount = AMOUNT.parse(matches); let port_id = PORT_ID.parse(matches); let channel_id = CHANNEL_ID.parse(matches); - let timeout_height_offset = TIMEOUT_HEIGHT_OFFSET.parse(matches); + let timeout_height = TIMEOUT_HEIGHT.parse(matches); let timeout_sec_offset = TIMEOUT_SEC_OFFSET.parse(matches); Self { tx, @@ -1598,7 +1598,7 @@ pub mod args { amount, port_id, channel_id, - timeout_height_offset, + timeout_height, timeout_sec_offset, } } @@ -1618,9 +1618,9 @@ pub mod args { .arg(PORT_ID.def().about("The port ID.")) .arg(CHANNEL_ID.def().about("The channel ID.")) .arg( - TIMEOUT_HEIGHT_OFFSET + TIMEOUT_HEIGHT .def() - .about("The timeout height offset."), + .about("The timeout height of the destination chain."), ) .arg(TIMEOUT_SEC_OFFSET.def().about("The timeout as seconds.")) } diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index bc70765793c..a7e063d62a4 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -545,17 +545,9 @@ pub async fn submit_ibc_transfer(ctx: Context, args: args::TxIbcTransfer) { amount: args.amount.to_string(), }); - let timeout_height = match args.timeout_height_offset { - Some(offset) => { - let current_height: u64 = match client.status().await { - Ok(resp) => resp.sync_info.latest_block_height.into(), - Err(e) => { - eprintln!("Getting the current height failed: {}", e); - safe_exit(1) - } - }; - IbcHeight::new(0, current_height + offset) - } + // this height should be that of the destination chain, not this chain + let timeout_height = match args.timeout_height { + Some(h) => IbcHeight::new(0, h), None => IbcHeight::zero(), }; From 24e7619eebf41f01eabccff13ab0cf094595d63b Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 18 Oct 2022 12:29:20 +0200 Subject: [PATCH 10/36] fix timeout timestamp --- apps/src/lib/client/tx.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index a7e063d62a4..b42bc57f9ec 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -553,6 +553,9 @@ pub async fn submit_ibc_transfer(ctx: Context, args: args::TxIbcTransfer) { let timeout_timestamp = if let Some(offset) = args.timeout_sec_offset { (IbcTimestamp::now() + Duration::new(offset, 0)).unwrap() + } else if timeout_height.is_zero() { + // we cannot set 0 to both the height and the timestamp + (IbcTimestamp::now() + Duration::new(3600, 0)).unwrap() } else { IbcTimestamp::none() }; From 0e4093b9622938f78d431ceb19bd5132fbf8cb9d Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 18 Oct 2022 14:01:05 +0200 Subject: [PATCH 11/36] replace now func --- apps/src/lib/client/tx.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index b42bc57f9ec..0783700d6a7 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -24,6 +24,7 @@ use namada::types::governance::{ use namada::types::key::*; use namada::types::nft::{self, Nft, NftToken}; use namada::types::storage::Epoch; +use namada::types::time::DateTimeUtc; use namada::types::transaction::governance::{ InitProposalData, VoteProposalData, }; @@ -551,11 +552,13 @@ pub async fn submit_ibc_transfer(ctx: Context, args: args::TxIbcTransfer) { None => IbcHeight::zero(), }; + let now: namada::tendermint::Time = DateTimeUtc::now().try_into().unwrap(); + let now: IbcTimestamp = now.into(); let timeout_timestamp = if let Some(offset) = args.timeout_sec_offset { - (IbcTimestamp::now() + Duration::new(offset, 0)).unwrap() + (now + Duration::new(offset, 0)).unwrap() } else if timeout_height.is_zero() { // we cannot set 0 to both the height and the timestamp - (IbcTimestamp::now() + Duration::new(3600, 0)).unwrap() + (now + Duration::new(3600, 0)).unwrap() } else { IbcTimestamp::none() }; From 40666b1539c7dde16b5d0371fe1ee3ab67e2c2f5 Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 18 Oct 2022 15:34:45 +0200 Subject: [PATCH 12/36] fix sub-prefix --- apps/src/lib/client/tx.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/src/lib/client/tx.rs b/apps/src/lib/client/tx.rs index 0783700d6a7..edb8c56f131 100644 --- a/apps/src/lib/client/tx.rs +++ b/apps/src/lib/client/tx.rs @@ -23,7 +23,7 @@ use namada::types::governance::{ }; use namada::types::key::*; use namada::types::nft::{self, Nft, NftToken}; -use namada::types::storage::Epoch; +use namada::types::storage::{Epoch, RESERVED_ADDRESS_PREFIX}; use namada::types::time::DateTimeUtc; use namada::types::transaction::governance::{ InitProposalData, VoteProposalData, @@ -538,7 +538,8 @@ pub async fn submit_ibc_transfer(ctx: Context, args: args::TxIbcTransfer) { let tx_code = ctx.read_wasm(TX_IBC_WASM); let denom = match sub_prefix { - Some(sp) => format!("{}/{}", sp, token), + // To parse IbcToken address, remove the address prefix + Some(sp) => sp.to_string().replace(RESERVED_ADDRESS_PREFIX, ""), None => token.to_string(), }; let token = Some(Coin { From d41b2ef84b083e125239cf9bf5ed027e6dfa10b4 Mon Sep 17 00:00:00 2001 From: yito88 Date: Thu, 20 Oct 2022 15:44:03 +0200 Subject: [PATCH 13/36] fix header hash --- apps/src/lib/node/ledger/shims/abcipp_shim.rs | 1 - apps/src/lib/node/ledger/shims/abcipp_shim_types.rs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/apps/src/lib/node/ledger/shims/abcipp_shim.rs index e919610f8e0..bda232f59ca 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -149,7 +149,6 @@ impl AbcippShim { self.begin_block_request.take().unwrap().into(); let hash = self.get_hash(); end_block_request.hash = BlockHash::from(hash.clone()); - end_block_request.header.hash = hash; end_block_request.txs = txs; self.service .call(Request::FinalizeBlock(end_block_request)) diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs index 5d9f2c420c7..b6be70b2849 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs @@ -249,7 +249,8 @@ pub mod shim { FinalizeBlock { hash: BlockHash::default(), header: Header { - hash: Hash::default(), + hash: Hash::try_from(header.app_hash.as_slice()) + .unwrap_or_default(), time: DateTimeUtc::try_from(header.time.unwrap()) .unwrap(), next_validators_hash: Hash::try_from( From c85e8c2214d013dc11007b05b6497a174bb55c77 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 21 Oct 2022 10:52:28 +0200 Subject: [PATCH 14/36] remove clone --- shared/src/ledger/ibc/handler.rs | 28 +++++++++++++--------------- shared/src/ledger/ibc/vp/token.rs | 17 ++++++++--------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/shared/src/ledger/ibc/handler.rs b/shared/src/ledger/ibc/handler.rs index 7a0ae1a8589..21425718d14 100644 --- a/shared/src/ledger/ibc/handler.rs +++ b/shared/src/ledger/ibc/handler.rs @@ -963,13 +963,12 @@ pub trait IbcActions { )) })?; - let source_addr = - Address::decode(data.sender.clone()).map_err(|e| { - Error::SendingToken(format!( - "Invalid sender address: sender {}, error {}", - data.sender, e - )) - })?; + let source_addr = Address::decode(&data.sender).map_err(|e| { + Error::SendingToken(format!( + "Invalid sender address: sender {}, error {}", + data.sender, e + )) + })?; // check the denomination field let prefix = format!( @@ -1046,13 +1045,12 @@ pub trait IbcActions { })?; // The receiver should be an address because the origin-specific account // key should be assigned internally - let dest_addr = - Address::decode(data.receiver.clone()).map_err(|e| { - Error::ReceivingToken(format!( - "Invalid receiver address: receiver {}, error {}", - data.receiver, e - )) - })?; + let dest_addr = Address::decode(&data.receiver).map_err(|e| { + Error::ReceivingToken(format!( + "Invalid receiver address: receiver {}, error {}", + data.receiver, e + )) + })?; let prefix = format!( "{}/{}/", @@ -1131,7 +1129,7 @@ pub trait IbcActions { )) })?; - let dest_addr = Address::decode(data.sender.clone()).map_err(|e| { + let dest_addr = Address::decode(&data.sender).map_err(|e| { Error::SendingToken(format!( "Invalid sender address: sender {}, error {}", data.sender, e diff --git a/shared/src/ledger/ibc/vp/token.rs b/shared/src/ledger/ibc/vp/token.rs index fd7ad298323..1ef67d4543a 100644 --- a/shared/src/ledger/ibc/vp/token.rs +++ b/shared/src/ledger/ibc/vp/token.rs @@ -89,15 +89,14 @@ where .filter(|k| { matches!( token::is_any_multitoken_balance_key(k), - Some((_, Address::Internal(InternalAddress::IbcEscrow))) - | Some(( - _, - Address::Internal(InternalAddress::IbcBurn) - )) - | Some(( - _, - Address::Internal(InternalAddress::IbcMint) - )) + Some(( + _, + Address::Internal( + InternalAddress::IbcEscrow + | InternalAddress::IbcBurn + | InternalAddress::IbcMint + ) + )) ) }) .cloned() From c4b369e8089abe14b8b6b9f1741358722ff83b43 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 21 Oct 2022 10:50:10 +0000 Subject: [PATCH 15/36] [ci] wasm checksums update --- wasm/checksums.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/wasm/checksums.json b/wasm/checksums.json index 8ddbe1dc853..59b0074caca 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,18 +1,18 @@ { - "tx_bond.wasm": "tx_bond.865260ca3ca9ed4c611cc5cbc8b4d864232f447f06c59afa0b7c1c63c3fa897c.wasm", - "tx_ibc.wasm": "tx_ibc.1360fdf276c4591d937aaac3bb40ddb573abeba382651474ae23138aac65c3e5.wasm", - "tx_init_account.wasm": "tx_init_account.72d9e1daa43998ce617eafba1547b34f26b128f0fb6e02cfdbc85ecf1f345fd4.wasm", - "tx_init_nft.wasm": "tx_init_nft.22a886305fda24438dbf3fc0f864ee32db4a398bf748edd2fddba1fc4679bc35.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.649bde547179ebee5449f5954425cd266c5063fae97f98f06de327387e8898ba.wasm", - "tx_init_validator.wasm": "tx_init_validator.d40077c1bf1263e1e8e42f54cd893473c5d9c1f395e5d30f44a34d98d9b8dde4.wasm", - "tx_mint_nft.wasm": "tx_mint_nft.78b3a43c5c5b4362cb3023c8e7e25755447e9022952306a62f2d8aab6e99dbee.wasm", - "tx_transfer.wasm": "tx_transfer.4c06f6af1f008fccdd42fefdc8015adea9fa60f802603a8be149ec2c6421656e.wasm", - "tx_unbond.wasm": "tx_unbond.c3d54895e1a271c86838d54d821d52b5bf5764928811cff30767a4445ebbf653.wasm", - "tx_update_vp.wasm": "tx_update_vp.3b709f301e55cb970ec1df98c85c2486561c3243ab1c191d3e078ee345b8b93a.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.671b46a77d03d10ca4e406f2bbc48adba0e541272a2963fd88d3a8c60e888fcd.wasm", - "tx_withdraw.wasm": "tx_withdraw.39e0012e110b19c7000400d11adc355bd8e89605b3c9ca10017c4766eed0ad69.wasm", - "vp_nft.wasm": "vp_nft.b23df820ae3faa13c9ed73121886b712fa0c613b7f43567f528cda05ef75fab6.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.45c740dcfa6e803d55a56cb51b02f2086147dfef3e955c0e8c3f18bf93ae0227.wasm", - "vp_token.wasm": "vp_token.74bca3c9999640c39bbd1c1364b65ffe8086e2d3ed124413251295d527326b57.wasm", - "vp_user.wasm": "vp_user.1c75ea1e55eb1244f023a525f9e20f0d34e52aebf0bd008dcf122fdc13bdf16a.wasm" + "tx_bond.wasm": "tx_bond.cfd4508bed8da57ff8cb89b030534ca7e4fe1c802b90a89a8cd4abbe6871fe0a.wasm", + "tx_ibc.wasm": "tx_ibc.0cf0332b4f69a989b79c5068d36053949b01ac462fd6f3978a1c0278b85ba450.wasm", + "tx_init_account.wasm": "tx_init_account.4881a8dc127f16e0e08ed18b04013e1f386688ce7391218a57be3eab3a884c96.wasm", + "tx_init_nft.wasm": "tx_init_nft.ea5285472e11de3b3a1bef60bb9e227252976c31a9f60c0d388d70f361679ac0.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.86269b4a7e90efb297d60dc97a79a94c2ba2727b4173083c5d39db5f7a64a459.wasm", + "tx_init_validator.wasm": "tx_init_validator.cf81a933705f4b027e47c51b53d788b56accc05e1b15b32537b6fece6d9f7b60.wasm", + "tx_mint_nft.wasm": "tx_mint_nft.6ccd6d4f01dacaac3057592b3fe32f4478e2698d51a722ba059d49e8e2e7194d.wasm", + "tx_transfer.wasm": "tx_transfer.4fdb8a897d579c244fbb77ab7e21b6121d46aa1087aa41059ec49474b970c571.wasm", + "tx_unbond.wasm": "tx_unbond.9dc2c92511bcac6f181f1287fce24ce592ef6da00ca913f151cc75f14bf28553.wasm", + "tx_update_vp.wasm": "tx_update_vp.370eb3cb15f66363319211355350117bb11b2effb4c57a52d18813371aa143bf.wasm", + "tx_vote_proposal.wasm": "tx_vote_proposal.7fe9da954ad4e837d5a618d214d1a4264c7daabf73158188724f82464e82a935.wasm", + "tx_withdraw.wasm": "tx_withdraw.cefbf27a1eead88c02b2f846c8bb7b0995dbcac49c9b412692eb71b1c186c29f.wasm", + "vp_nft.wasm": "vp_nft.202e3dc8a01740b438507d624898ad1c8c8771f41746f49fbf099dfa4a582ae4.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.46dc197e952cada03200deae88ba0f9491e5cc5d86faf25152c681572c444fbf.wasm", + "vp_token.wasm": "vp_token.746b17c48d1541a29ccbf861c21280351489970e672fb54505788fc910877025.wasm", + "vp_user.wasm": "vp_user.67cf3481ce8ae0f859c4f1f9025120b202263438ea9e6602267337643073d7c1.wasm" } \ No newline at end of file From 9e6c49343bb8da7a3382ae2b1e24d2d9780ebc6a Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 25 Feb 2022 17:28:17 +0900 Subject: [PATCH 16/36] add transfer test --- apps/src/lib/client/rpc.rs | 27 +- tests/Cargo.toml | 5 + tests/src/e2e.rs | 1 + tests/src/e2e/ibc_tests.rs | 606 +++++++++++++++++++++++++++++++++++++ tests/src/e2e/setup.rs | 26 +- 5 files changed, 658 insertions(+), 7 deletions(-) create mode 100644 tests/src/e2e/ibc_tests.rs diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index 6c1e3fb5f31..8e13639469c 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -36,6 +36,7 @@ use namada::types::{address, storage, token}; use crate::cli::{self, args, Context}; use crate::client::tendermint_rpc_types::TxResponse; use crate::facade::tendermint::abci::Code; +use crate::facade::tendermint::merkle::proof::Proof; use crate::facade::tendermint_config::net::Address as TendermintAddress; use crate::facade::tendermint_rpc::error::Error as TError; use crate::facade::tendermint_rpc::query::Query; @@ -1293,20 +1294,34 @@ pub async fn query_storage_value( where T: BorshDeserialize, { + let (value, _proof) = query_storage_value_bytes(client, key, false).await; + match value { + Some(v) => match T::try_from_slice(&v[..]) { + Ok(value) => return Some(value), + Err(err) => eprintln!("Error decoding the value: {}", err), + }, + None => return None, + } + cli::safe_exit(1) +} + +/// Query a storage value and the proof without decoding. +pub async fn query_storage_value_bytes( + client: &HttpClient, + key: &storage::Key, + prove: bool, +) -> (Option>, Option) { let path = Path::Value(key.to_owned()); let data = vec![]; let response = client - .abci_query(Some(path.into()), data, None, false) + .abci_query(Some(path.into()), data, None, prove) .await .unwrap(); match response.code { - Code::Ok => match T::try_from_slice(&response.value[..]) { - Ok(value) => return Some(value), - Err(err) => eprintln!("Error decoding the value: {}", err), - }, + Code::Ok => return (Some(response.value), response.proof), Code::Err(err) => { if err == 1 { - return None; + return (None, response.proof); } else { eprintln!( "Error in the query {} (error code {})", diff --git a/tests/Cargo.toml b/tests/Cargo.toml index dc3bf7b8aaf..765da93c1cf 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -22,6 +22,11 @@ serde_json = {version = "1.0.65"} sha2 = "0.9.3" test-log = {version = "0.2.7", default-features = false, features = ["trace"]} tempfile = "3.2.0" +tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tokio = {version = "1.8.2", features = ["full"]} tracing = "0.1.30" tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} derivative = "2.2.0" diff --git a/tests/src/e2e.rs b/tests/src/e2e.rs index 0afc343098c..df177f87dca 100644 --- a/tests/src/e2e.rs +++ b/tests/src/e2e.rs @@ -13,6 +13,7 @@ pub mod eth_bridge_tests; pub mod helpers; +pub mod ibc_tests; pub mod ledger_tests; pub mod setup; pub mod wallet_tests; diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs new file mode 100644 index 00000000000..ef71b9a14ee --- /dev/null +++ b/tests/src/e2e/ibc_tests.rs @@ -0,0 +1,606 @@ +use core::convert::TryFrom; +use core::str::FromStr; +use core::time::Duration; + +use namada::ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; +use namada::ibc::clients::ics07_tendermint::client_state::{ + AllowUpdate, ClientState as TmClientState, +}; +use namada::ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState; +use namada::ibc::core::ics02_client::client_consensus::{ + AnyConsensusState, ConsensusState, +}; +use namada::ibc::core::ics02_client::client_state::{ + AnyClientState, ClientState, +}; +use namada::ibc::core::ics02_client::height::Height; +use namada::ibc::core::ics02_client::msgs::create_client::MsgCreateAnyClient; +use namada::ibc::core::ics02_client::trust_threshold::TrustThreshold; +use namada::ibc::core::ics03_connection::connection::Counterparty as ConnCounterparty; +use namada::ibc::core::ics03_connection::msgs::conn_open_ack::MsgConnectionOpenAck; +use namada::ibc::core::ics03_connection::msgs::conn_open_confirm::MsgConnectionOpenConfirm; +use namada::ibc::core::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit; +use namada::ibc::core::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry; +use namada::ibc::core::ics03_connection::version::Version as ConnVersion; +use namada::ibc::core::ics04_channel::channel::{ + ChannelEnd, Counterparty as ChanCounterparty, Order as ChanOrder, + State as ChanState, +}; +use namada::ibc::core::ics04_channel::msgs::acknowledgement::MsgAcknowledgement; +use namada::ibc::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenAck; +use namada::ibc::core::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm; +use namada::ibc::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; +use namada::ibc::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; +use namada::ibc::core::ics04_channel::msgs::recv_packet::MsgRecvPacket; +use namada::ibc::core::ics04_channel::packet::Packet; +use namada::ibc::core::ics04_channel::Version as ChanVersion; +use namada::ibc::core::ics23_commitment::commitment::CommitmentProofBytes; +use namada::ibc::core::ics23_commitment::merkle::convert_tm_to_ics_merkle_proof; +use namada::ibc::core::ics24_host::identifier::{ + ChainId, ClientId, ConnectionId, PortChannelId, PortId, +}; +use namada::ibc::events::{from_tx_response_event, IbcEvent}; +use namada::ibc::proofs::Proofs; +use namada::ibc::signer::Signer; +use namada::ibc::timestamp::Timestamp; +use namada::ibc::tx_msg::Msg; +use namada::ibc_proto::cosmos::base::v1beta1::Coin; +use namada::ledger::ibc::handler::{commitment_prefix, port_channel_id}; +use namada::ledger::ibc::storage::*; +use namada::ledger::storage::{MerkleTree, Sha256Hasher}; +use namada::types::storage::Key; +use namada_apps::client::rpc::query_storage_value_bytes; +use color_eyre::eyre::Result; +use eyre::eyre; +use setup::constants::*; +use tendermint::block::Header as TmHeader; +use tendermint::merkle::proof::Proof as TmProof; +use tendermint_config::net::Address as TendermintAddress; +use tendermint_rpc::query::Query; +use tendermint_rpc::{Client, HttpClient, Order}; +use tokio::runtime::Runtime; + +use crate::e2e::helpers::{find_address, get_actor_rpc, get_epoch}; +use crate::e2e::setup::{self, constants, Bin, Test, Who}; +use crate::{run, run_as}; + +const TX_IBC_WASM: &str = "tx_ibc.wasm"; +const DATA_PATH: &str = "tx.data"; +const TX_IBC_ARGS: [&str; 5] = + ["tx", "--code-path", TX_IBC_WASM, "--data-path", DATA_PATH]; + +#[test] +fn run_ledger_ibc() -> Result<()> { + let (test_a, test_b) = setup::two_single_node_nets()?; + + // Run Chain A + let mut ledger_a = + run_as!(test_a, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?; + ledger_a.exp_string("Anoma ledger node started")?; + // Run Chain B + let mut ledger_b = + run_as!(test_b, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?; + ledger_b.exp_string("Anoma ledger node started")?; + + let (client_id_a, client_id_b) = create_client(&test_a, &test_b)?; + + let (conn_id_a, conn_id_b) = + connection_handshake(&test_a, &test_b, &client_id_a, &client_id_b)?; + + let (port_channel_id_a, port_channel_id_b) = + channel_handshake(&test_a, &test_b, &conn_id_a, &conn_id_b)?; + + transfer_token(&test_a, &test_b, port_channel_id_a, port_channel_id_b)?; + + // Check the balance on Chain A + let rpc_a = get_actor_rpc(&test_a, &Who::Validator(0)); + let query_args = vec![ + "balance", + "--owner", + ALBERT, + "--token", + XAN, + "--ledger-address", + &rpc_a, + ]; + let expected = r"XAN: 0"; + let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; + client.exp_regex(expected)?; + client.assert_success(); + + // Check the balance on Chain B + let rpc_b = get_actor_rpc(&test_b, &Who::Validator(0)); + let query_args = vec![ + "balance", + "--owner", + BERTHA, + "--token", + XAN, + "--ledger-address", + &rpc_b, + ]; + let expected = r"XAN: 2000000"; + let mut client = run!(test_b, Bin::Client, query_args, Some(40))?; + client.exp_regex(expected)?; + client.assert_success(); + + Ok(()) +} + +fn create_client(test_a: &Test, test_b: &Test) -> Result<(ClientId, ClientId)> { + let height = query_height(test_b)?; + let client_state = make_client_state(test_b, height); + let height = client_state.latest_height(); + let message = MsgCreateAnyClient { + client_state, + consensus_state: make_consensus_state(test_b, height)?, + signer: Signer::new("test_a"), + }; + let hash_a = submit_ibc_tx(test_a, message)?; + + let height = query_height(test_a)?; + let client_state = make_client_state(test_a, height); + let height = client_state.latest_height(); + let message = MsgCreateAnyClient { + client_state, + consensus_state: make_consensus_state(test_a, height)?, + signer: Signer::new("test_b"), + }; + let hash_b = submit_ibc_tx(test_b, message)?; + + let client_id_a = match get_event(test_a, hash_a)? { + IbcEvent::CreateClient(event) => event.client_id().clone(), + _ => return Err(eyre!("Unexpected event happened")), + }; + let client_id_b = match get_event(test_b, hash_b)? { + IbcEvent::CreateClient(event) => event.client_id().clone(), + _ => return Err(eyre!("Unexpected event happened")), + }; + + // `client_id_a` represents the ID of the B's client on Chain A + Ok((client_id_a, client_id_b)) +} + +fn make_client_state(test: &Test, height: Height) -> AnyClientState { + let unbonding_period = Duration::new(1814400, 0); + let trusting_period = 2 * unbonding_period / 3; + let max_clock_drift = Duration::new(60, 0); + let chain_id = ChainId::from_str(test.net.chain_id.as_str()).unwrap(); + TmClientState::new( + chain_id, + TrustThreshold::default(), + trusting_period, + unbonding_period, + max_clock_drift, + height, + MerkleTree::::default().proof_specs().into(), + vec!["upgrade".to_string(), "upgradedIBCState".to_string()], + AllowUpdate { + after_expiry: true, + after_misbehaviour: true, + }, + ) + .unwrap() + .wrap_any() +} + +fn make_consensus_state( + test: &Test, + height: Height, +) -> Result { + let header = query_header(test, height)?; + Ok(TmConsensusState::from(header).wrap_any()) +} + +fn connection_handshake( + test_a: &Test, + test_b: &Test, + client_id_a: &ClientId, + client_id_b: &ClientId, +) -> Result<(ConnectionId, ConnectionId)> { + // OpenInitConnection on Chain A + let msg = MsgConnectionOpenInit { + client_id: client_id_a.clone(), + counterparty: ConnCounterparty::new( + client_id_b.clone(), + None, + commitment_prefix(), + ), + version: Some(ConnVersion::default()), + delay_period: Duration::new(30, 0), + signer: Signer::new("test_a"), + }; + let hash = submit_ibc_tx(test_a, msg)?; + let conn_id_a = match get_event(test_a, hash)? { + IbcEvent::OpenInitConnection(event) => event + .connection_id() + .clone() + .ok_or(eyre!("No connection ID is set"))?, + _ => return Err(eyre!("Unexpected event happened")), + }; + + // OpenTryConnection on Chain B + // get the B's client state and the proofs on Chain A + let proofs = get_connection_proofs(test_a, client_id_a, &conn_id_a)?; + let counterparty = ConnCounterparty::new( + client_id_a.clone(), + Some(conn_id_a.clone()), + commitment_prefix(), + ); + let msg = MsgConnectionOpenTry { + previous_connection_id: None, + client_id: client_id_b.clone(), + client_state: None, + counterparty, + counterparty_versions: vec![ConnVersion::default()], + proofs, + delay_period: Duration::new(30, 0), + signer: Signer::new("test_b"), + }; + let hash = submit_ibc_tx(test_b, msg)?; + let conn_id_b = match get_event(test_b, hash)? { + IbcEvent::OpenTryConnection(event) => event + .connection_id() + .clone() + .ok_or(eyre!("No connection ID is set"))?, + _ => return Err(eyre!("Unexpected event happened")), + }; + + // OpenAckConnection on Chain A + // get the A's client state and the proofs on Chain B + let proofs = get_connection_proofs(test_b, client_id_b, &conn_id_b)?; + let msg = MsgConnectionOpenAck { + connection_id: conn_id_a.clone(), + counterparty_connection_id: conn_id_b.clone(), + client_state: None, + proofs, + version: ConnVersion::default(), + signer: Signer::new("test_a"), + }; + submit_ibc_tx(test_a, msg)?; + + // OpenConfirmConnection on Chain B + // get the proofs on Chain A + let proofs = get_connection_proofs(test_a, client_id_a, &conn_id_a)?; + let msg = MsgConnectionOpenConfirm { + connection_id: conn_id_b.clone(), + proofs, + signer: Signer::new("test_b"), + }; + submit_ibc_tx(test_b, msg)?; + + Ok((conn_id_a, conn_id_b)) +} + +fn get_connection_proofs( + test: &Test, + client_id: &ClientId, + conn_id: &ConnectionId, +) -> Result { + let height = query_height(test)?; + let key = connection_key(&conn_id); + let tm_proof = query_proof(test, &key)?; + let connection_proof = convert_proof(tm_proof)?; + + Proofs::new(connection_proof, None, None, None, height) + .map_err(|e| eyre!("Creating proofs failed: error {}", e)) +} + +fn channel_handshake( + test_a: &Test, + test_b: &Test, + conn_id_a: &ConnectionId, + conn_id_b: &ConnectionId, +) -> Result<(PortChannelId, PortChannelId)> { + // OpenInitChannel on Chain A + let port_id = PortId::from_str("test_port").unwrap(); + let counterparty = ChanCounterparty::new(port_id.clone(), None); + let channel = ChannelEnd::new( + ChanState::Uninitialized, + ChanOrder::Unordered, + counterparty, + vec![conn_id_a.clone()], + ChanVersion::ics20(), + ); + let msg = MsgChannelOpenInit { + port_id: port_id.clone(), + channel, + signer: Signer::new("test_a"), + }; + let hash = submit_ibc_tx(test_a, msg)?; + let channel_id_a = match get_event(test_a, hash)? { + IbcEvent::OpenInitChannel(event) => event + .channel_id() + .ok_or(eyre!("No channel ID is set"))? + .clone(), + _ => return Err(eyre!("Unexpected event happened")), + }; + let port_channel_id_a = + port_channel_id(port_id.clone(), channel_id_a.clone()); + + // OpenTryChannel on Chain B + let counterparty = + ChanCounterparty::new(port_id.clone(), Some(channel_id_a.clone())); + let channel = ChannelEnd::new( + ChanState::Uninitialized, + ChanOrder::Unordered, + counterparty, + vec![conn_id_b.clone()], + ChanVersion::ics20(), + ); + let proofs = get_channel_proofs(test_a, &port_channel_id_a)?; + let msg = MsgChannelOpenTry { + port_id: port_id.clone(), + previous_channel_id: None, + channel, + counterparty_version: ChanVersion::ics20(), + proofs, + signer: Signer::new("test_b"), + }; + let hash = submit_ibc_tx(test_b, msg)?; + let channel_id_b = match get_event(test_b, hash)? { + IbcEvent::OpenInitChannel(event) => event + .channel_id() + .ok_or(eyre!("No channel ID is set"))? + .clone(), + _ => return Err(eyre!("Unexpected event happened")), + }; + let port_channel_id_b = + port_channel_id(port_id.clone(), channel_id_b.clone()); + + // OpenAckChannel on Chain A + let proofs = get_channel_proofs(test_b, &port_channel_id_b)?; + let msg = MsgChannelOpenAck { + port_id: port_id.clone(), + channel_id: channel_id_a.clone(), + counterparty_channel_id: channel_id_b.clone(), + counterparty_version: ChanVersion::ics20(), + proofs, + signer: Signer::new("test_a"), + }; + submit_ibc_tx(test_a, msg)?; + + // OpenConfirmChannel on Chain B + let proofs = get_channel_proofs(test_a, &port_channel_id_a)?; + let msg = MsgChannelOpenConfirm { + port_id, + channel_id: channel_id_b.clone(), + proofs, + signer: Signer::new("test_b"), + }; + submit_ibc_tx(test_b, msg)?; + + Ok((port_channel_id_a, port_channel_id_b)) +} + +fn get_channel_proofs( + test: &Test, + port_channel_id: &PortChannelId, +) -> Result { + let height = query_height(test)?; + let key = channel_key(port_channel_id); + let tm_proof = query_proof(test, &key)?; + let proof = convert_proof(tm_proof)?; + + Proofs::new(proof, None, None, None, height) + .map_err(|e| eyre!("Creating proofs failed: error {}", e)) +} + +fn transfer_token( + test_a: &Test, + test_b: &Test, + port_channel_id_a: PortChannelId, + port_channel_id_b: PortChannelId, +) -> Result<()> { + let xan = find_address(&test_a, constants::XAN)?; + let sender = find_address(&test_a, constants::ALBERT)?; + let receiver = find_address(&test_b, constants::BERTHA)?; + + // Send a token from Chain A + let token = Some(Coin { + denom: xan.to_string(), + amount: "1000000".to_string(), + }); + let msg = MsgTransfer { + source_port: port_channel_id_a.port_id, + source_channel: port_channel_id_a.channel_id, + token, + sender: Signer::new(sender.to_string()), + receiver: Signer::new(receiver.to_string()), + timeout_height: Height::new(100, 100), + timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), + }; + let hash = submit_ibc_tx(test_a, msg)?; + let packet = match get_event(test_a, hash)? { + IbcEvent::SendPacket(event) => event.packet, + _ => return Err(eyre!("Unexpected event happened")), + }; + + // Receive the token on Chain B + let proofs = get_commitment_proof(test_a, &packet)?; + let msg = MsgRecvPacket { + packet, + proofs, + signer: Signer::new("test_b"), + }; + let hash = submit_ibc_tx(test_b, msg)?; + let (acknowledgement, packet) = match get_event(test_b, hash)? { + IbcEvent::WriteAcknowledgement(event) => (event.ack, event.packet), + _ => return Err(eyre!("Unexpected event happened")), + }; + + // Acknowledge on Chain A + let proofs = get_ack_proof(test_a, &packet)?; + let msg = MsgAcknowledgement { + packet, + acknowledgement: acknowledgement.into(), + proofs, + signer: Signer::new("test_a"), + }; + submit_ibc_tx(test_b, msg)?; + + Ok(()) +} + +fn get_commitment_proof(test: &Test, packet: &Packet) -> Result { + let height = query_height(test)?; + let key = commitment_key( + &packet.source_port, + &packet.source_channel, + packet.sequence, + ); + let tm_proof = query_proof(test, &key)?; + let commitment_proof = convert_proof(tm_proof)?; + + Proofs::new(commitment_proof, None, None, None, height) + .map_err(|e| eyre!("Creating proofs failed: error {}", e)) +} + +fn get_ack_proof(test: &Test, packet: &Packet) -> Result { + let height = query_height(test)?; + let key = ack_key( + &packet.destination_port, + &packet.destination_channel, + packet.sequence, + ); + let tm_proof = query_proof(test, &key)?; + let ack_proof = convert_proof(tm_proof)?; + + Proofs::new(ack_proof, None, None, None, height) + .map_err(|e| eyre!("Creating proofs failed: error {}", e)) +} + +fn submit_ibc_tx(test: &Test, message: impl Msg) -> Result { + let data = make_ibc_data(message); + std::fs::write(DATA_PATH, data).expect("writing data failed"); + let mut client = run!(test, Bin::Client, TX_IBC_ARGS, Some(40))?; + if !cfg!(feature = "ABCI") { + client.exp_string("Transaction accepted")?; + } + client.exp_string("Transaction applied")?; + client.exp_string("Transaction is valid.")?; + let (unread, matched) = if !cfg!(feature = "ABCI") { + client.exp_regex("Wrapper transaction hash: .*\n")? + } else { + client.exp_regex("Transaction hash: .*\n")? + }; + let hash = matched.trim().rsplit_once(' ').unwrap().1.to_string(); + client.assert_success(); + + Ok(hash) +} + +fn make_ibc_data(message: impl Msg) -> Vec { + let msg = message.to_any(); + let mut tx_data = vec![]; + prost::Message::encode(&msg, &mut tx_data) + .expect("encoding IBC message shouldn't fail"); + tx_data +} + +fn query_height(test: &Test) -> Result { + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); + let client = HttpClient::new(ledger_address).unwrap(); + let rt = Runtime::new().unwrap(); + + let status = rt + .block_on(client.status()) + .map_err(|e| eyre!("Getting the status failed: {}", e))?; + let epoch = get_epoch(test, &rpc)?; + + Ok(Height::new( + epoch.0, + status.sync_info.latest_block_height.into(), + )) +} + +fn query_header(test: &Test, height: Height) -> Result { + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); + let client = HttpClient::new(ledger_address).unwrap(); + let height = height.revision_height as u32; + let result = Runtime::new() + .unwrap() + .block_on(client.blockchain(height, height)); + match result { + Ok(mut response) => match response.block_metas.pop() { + Some(meta) => Ok(meta.header), + None => Err(eyre!("No meta exists")), + }, + Err(e) => Err(eyre!("Header query failed: {}", e)), + } +} + +fn get_event(test: &Test, tx_hash: String) -> Result { + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); + let client = HttpClient::new(ledger_address).unwrap(); + + // get the epoch + let epoch = get_epoch(test, &rpc)?; + // get the result of the transaction + let query = Query::eq("tx.hash", tx_hash.clone()); + let response = Runtime::new() + .unwrap() + .block_on(client.tx_search(query, false, 1, 1, Order::Ascending)) + .map_err(|e| eyre!("tx_search for an IBC event failed: {}", e))?; + let tx_resp = response.txs.get(0).ok_or_else(|| { + eyre!("The transaction has not been executed: hash {}", tx_hash) + })?; + let tx_result = &tx_resp.tx_result; + if tx_result.code.is_err() { + return Err(eyre!( + "The transaction failed: hash {}, code {:?}, log {}", + tx_hash, + tx_result.code, + tx_result.log + )); + } + + let height = Height::new(epoch.0, u64::from(tx_resp.height)); + let event = tx_result.events.get(0).ok_or_else(|| { + eyre!("The transaction response doesn't have any event") + })?; + match from_tx_response_event(height, &event) { + Some(ibc_event) => Ok(ibc_event), + None => Err(eyre!( + "The transaction response doesn't have any IBC event: hash {}", + tx_hash, + )), + } +} + +fn query_with_proof(test: &Test, key: &Key) -> Result<(Vec, TmProof)> { + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); + let client = HttpClient::new(ledger_address).unwrap(); + let result = Runtime::new() + .unwrap() + .block_on(query_storage_value_bytes(&client, key, true)); + match result { + (Some(value), Some(proof)) => Ok((value, proof)), + _ => Err(eyre!("The value doesn't exist: key {}", key)), + } +} + +fn query_proof(test: &Test, key: &Key) -> Result { + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); + let client = HttpClient::new(ledger_address).unwrap(); + let result = Runtime::new() + .unwrap() + .block_on(query_storage_value_bytes(&client, key, true)); + match result { + (_, Some(proof)) => Ok(proof), + _ => Err(eyre!("Proof doesn't exist: key {}", key)), + } +} + +fn convert_proof(tm_proof: TmProof) -> Result { + let merkle_proof = convert_tm_to_ics_merkle_proof(&tm_proof) + .map_err(|e| eyre!("Proof conversion to MerkleProof failed: {}", e))?; + CommitmentProofBytes::try_from(merkle_proof).map_err(|e| { + eyre!("Proof conversion to CommitmentProofBytes failed: {}", e) + }) +} diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index b20f14d54f0..b1a4b195003 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -57,6 +57,11 @@ pub struct Network { pub chain_id: ChainId, } +/// Offset the ports used in the network configuration by 1000 for ABCI++ to +/// avoid shared resources +pub const ABCI_PLUS_PLUS_PORT_OFFSET: u16 = 1000; +pub const ANOTHER_CHAIN_PORT_OFFSET: u16 = 1; + /// Add `num` validators to the genesis config. Note that called from inside /// the [`network`]'s first argument's closure, there is 1 validator already /// present to begin with, so e.g. `add_validators(1, _)` will configure a @@ -89,8 +94,27 @@ pub fn single_node_net() -> Result { network(|genesis| genesis, None) } +pub fn two_single_node_nets() -> Result<(Test, Test)> { + Ok(( + network(|genesis| genesis, None)?, + network(set_another_address, None)?, + )) +} + +fn set_another_address(mut genesis: GenesisConfig) -> GenesisConfig { + let validator_0 = genesis.validator.get_mut("validator-0").unwrap(); + let mut net_address_0 = + SocketAddr::from_str(validator_0.net_address.as_ref().unwrap()) + .unwrap(); + let current_port = net_address_0.port(); + net_address_0.set_port(current_port + ANOTHER_CHAIN_PORT_OFFSET); + validator_0.net_address = Some(net_address_0.to_string()); + genesis +} + +/// Setup a configurable network. pub fn network( - update_genesis: impl Fn(GenesisConfig) -> GenesisConfig, + mut update_genesis: impl FnMut(GenesisConfig) -> GenesisConfig, consensus_timeout_commit: Option<&'static str>, ) -> Result { INIT.call_once(|| { From 7d6072e34e205b35f07a1e21f44d430d9ad04c64 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 25 Feb 2022 19:42:29 +0900 Subject: [PATCH 17/36] add sleep --- tests/src/e2e/ibc_tests.rs | 24 ++++++++++++------------ tests/src/e2e/setup.rs | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index ef71b9a14ee..0463ea35718 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -61,7 +61,7 @@ use tendermint_rpc::{Client, HttpClient, Order}; use tokio::runtime::Runtime; use crate::e2e::helpers::{find_address, get_actor_rpc, get_epoch}; -use crate::e2e::setup::{self, constants, Bin, Test, Who}; +use crate::e2e::setup::{self, constants, sleep, Bin, Test, Who}; use crate::{run, run_as}; const TX_IBC_WASM: &str = "tx_ibc.wasm"; @@ -82,15 +82,17 @@ fn run_ledger_ibc() -> Result<()> { run_as!(test_b, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?; ledger_b.exp_string("Anoma ledger node started")?; + sleep(5); + let (client_id_a, client_id_b) = create_client(&test_a, &test_b)?; let (conn_id_a, conn_id_b) = connection_handshake(&test_a, &test_b, &client_id_a, &client_id_b)?; - let (port_channel_id_a, port_channel_id_b) = + let (port_channel_id_a, _) = channel_handshake(&test_a, &test_b, &conn_id_a, &conn_id_b)?; - transfer_token(&test_a, &test_b, port_channel_id_a, port_channel_id_b)?; + transfer_token(&test_a, &test_b, &port_channel_id_a)?; // Check the balance on Chain A let rpc_a = get_actor_rpc(&test_a, &Who::Validator(0)); @@ -221,7 +223,7 @@ fn connection_handshake( // OpenTryConnection on Chain B // get the B's client state and the proofs on Chain A - let proofs = get_connection_proofs(test_a, client_id_a, &conn_id_a)?; + let proofs = get_connection_proofs(test_a, &conn_id_a)?; let counterparty = ConnCounterparty::new( client_id_a.clone(), Some(conn_id_a.clone()), @@ -248,7 +250,7 @@ fn connection_handshake( // OpenAckConnection on Chain A // get the A's client state and the proofs on Chain B - let proofs = get_connection_proofs(test_b, client_id_b, &conn_id_b)?; + let proofs = get_connection_proofs(test_b, &conn_id_b)?; let msg = MsgConnectionOpenAck { connection_id: conn_id_a.clone(), counterparty_connection_id: conn_id_b.clone(), @@ -261,7 +263,7 @@ fn connection_handshake( // OpenConfirmConnection on Chain B // get the proofs on Chain A - let proofs = get_connection_proofs(test_a, client_id_a, &conn_id_a)?; + let proofs = get_connection_proofs(test_a, &conn_id_a)?; let msg = MsgConnectionOpenConfirm { connection_id: conn_id_b.clone(), proofs, @@ -274,7 +276,6 @@ fn connection_handshake( fn get_connection_proofs( test: &Test, - client_id: &ClientId, conn_id: &ConnectionId, ) -> Result { let height = query_height(test)?; @@ -389,8 +390,7 @@ fn get_channel_proofs( fn transfer_token( test_a: &Test, test_b: &Test, - port_channel_id_a: PortChannelId, - port_channel_id_b: PortChannelId, + source_port_channel_id: &PortChannelId, ) -> Result<()> { let xan = find_address(&test_a, constants::XAN)?; let sender = find_address(&test_a, constants::ALBERT)?; @@ -402,8 +402,8 @@ fn transfer_token( amount: "1000000".to_string(), }); let msg = MsgTransfer { - source_port: port_channel_id_a.port_id, - source_channel: port_channel_id_a.channel_id, + source_port: source_port_channel_id.port_id.clone(), + source_channel: source_port_channel_id.channel_id.clone(), token, sender: Signer::new(sender.to_string()), receiver: Signer::new(receiver.to_string()), @@ -479,7 +479,7 @@ fn submit_ibc_tx(test: &Test, message: impl Msg) -> Result { } client.exp_string("Transaction applied")?; client.exp_string("Transaction is valid.")?; - let (unread, matched) = if !cfg!(feature = "ABCI") { + let (_unread, matched) = if !cfg!(feature = "ABCI") { client.exp_regex("Wrapper transaction hash: .*\n")? } else { client.exp_regex("Transaction hash: .*\n")? diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index b1a4b195003..6c1275c8b5f 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -60,7 +60,7 @@ pub struct Network { /// Offset the ports used in the network configuration by 1000 for ABCI++ to /// avoid shared resources pub const ABCI_PLUS_PLUS_PORT_OFFSET: u16 = 1000; -pub const ANOTHER_CHAIN_PORT_OFFSET: u16 = 1; +pub const ANOTHER_CHAIN_PORT_OFFSET: u16 = 1001; /// Add `num` validators to the genesis config. Note that called from inside /// the [`network`]'s first argument's closure, there is 1 validator already From 199c4982efb98f9152c716dc4d617907ccc809c1 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 4 Mar 2022 12:14:18 +0900 Subject: [PATCH 18/36] fix requests --- tests/src/e2e/ibc_tests.rs | 69 ++++++++++++++++++++++++++------------ tests/src/e2e/setup.rs | 1 + 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 0463ea35718..6cac7446bb1 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -1,3 +1,14 @@ +//! By default, these tests will run in release mode. This can be disabled +//! by setting environment variable `ANOMA_E2E_DEBUG=true`. For debugging, +//! you'll typically also want to set `RUST_BACKTRACE=1`, e.g.: +//! +//! ```ignore,shell +//! ANOMA_E2E_DEBUG=true RUST_BACKTRACE=1 cargo test e2e::ibc_tests -- --test-threads=1 --nocapture +//! ``` +//! +//! To keep the temporary files created by a test, use env var +//! `ANOMA_E2E_KEEP_TEMP=true`. + use core::convert::TryFrom; use core::str::FromStr; use core::time::Duration; @@ -61,14 +72,9 @@ use tendermint_rpc::{Client, HttpClient, Order}; use tokio::runtime::Runtime; use crate::e2e::helpers::{find_address, get_actor_rpc, get_epoch}; -use crate::e2e::setup::{self, constants, sleep, Bin, Test, Who}; +use crate::e2e::setup::{self, sleep, Bin, Test, Who}; use crate::{run, run_as}; -const TX_IBC_WASM: &str = "tx_ibc.wasm"; -const DATA_PATH: &str = "tx.data"; -const TX_IBC_ARGS: [&str; 5] = - ["tx", "--code-path", TX_IBC_WASM, "--data-path", DATA_PATH]; - #[test] fn run_ledger_ibc() -> Result<()> { let (test_a, test_b) = setup::two_single_node_nets()?; @@ -353,7 +359,7 @@ fn channel_handshake( let proofs = get_channel_proofs(test_b, &port_channel_id_b)?; let msg = MsgChannelOpenAck { port_id: port_id.clone(), - channel_id: channel_id_a.clone(), + channel_id: channel_id_a, counterparty_channel_id: channel_id_b.clone(), counterparty_version: ChanVersion::ics20(), proofs, @@ -365,7 +371,7 @@ fn channel_handshake( let proofs = get_channel_proofs(test_a, &port_channel_id_a)?; let msg = MsgChannelOpenConfirm { port_id, - channel_id: channel_id_b.clone(), + channel_id: channel_id_b, proofs, signer: Signer::new("test_b"), }; @@ -392,9 +398,9 @@ fn transfer_token( test_b: &Test, source_port_channel_id: &PortChannelId, ) -> Result<()> { - let xan = find_address(&test_a, constants::XAN)?; - let sender = find_address(&test_a, constants::ALBERT)?; - let receiver = find_address(&test_b, constants::BERTHA)?; + let xan = find_address(test_a, XAN)?; + let sender = find_address(test_a, ALBERT)?; + let receiver = find_address(test_b, BERTHA)?; // Send a token from Chain A let token = Some(Coin { @@ -471,21 +477,42 @@ fn get_ack_proof(test: &Test, packet: &Packet) -> Result { } fn submit_ibc_tx(test: &Test, message: impl Msg) -> Result { + let data_path = test.test_dir.path().join("tx.data"); let data = make_ibc_data(message); - std::fs::write(DATA_PATH, data).expect("writing data failed"); - let mut client = run!(test, Bin::Client, TX_IBC_ARGS, Some(40))?; - if !cfg!(feature = "ABCI") { - client.exp_string("Transaction accepted")?; - } - client.exp_string("Transaction applied")?; - client.exp_string("Transaction is valid.")?; + std::fs::write(&data_path, data).expect("writing data failed"); + + let code_path = wasm_abs_path(TX_IBC_WASM); + let code_path = code_path.to_string_lossy(); + let data_path = data_path.to_string_lossy(); + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let mut client = run!( + test, + Bin::Client, + [ + "tx", + "--code-path", + &code_path, + "--data-path", + &data_path, + "--signer", + ALBERT, + "--fee-amount", + "0", + "--gas-limit", + "0", + "--fee-token", + XAN, + "--ledger-address", + &rpc + ], + Some(40) + )?; let (_unread, matched) = if !cfg!(feature = "ABCI") { client.exp_regex("Wrapper transaction hash: .*\n")? } else { client.exp_regex("Transaction hash: .*\n")? }; - let hash = matched.trim().rsplit_once(' ').unwrap().1.to_string(); - client.assert_success(); + let hash = matched.trim().rsplit_once(' ').unwrap().1.replace('"', ""); Ok(hash) } @@ -562,7 +589,7 @@ fn get_event(test: &Test, tx_hash: String) -> Result { let event = tx_result.events.get(0).ok_or_else(|| { eyre!("The transaction response doesn't have any event") })?; - match from_tx_response_event(height, &event) { + match from_tx_response_event(height, event) { Some(ibc_event) => Ok(ibc_event), None => Err(eyre!( "The transaction response doesn't have any IBC event: hash {}", diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index 6c1275c8b5f..9d67f53d7c9 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -807,6 +807,7 @@ pub mod constants { pub const TX_INIT_PROPOSAL: &str = "wasm_for_tests/tx_init_proposal.wasm"; pub const TX_WRITE_STORAGE_KEY_WASM: &str = "wasm_for_tests/tx_write_storage_key.wasm"; + pub const TX_IBC_WASM: &str = "wasm/tx_ibc.wasm"; pub const VP_ALWAYS_TRUE_WASM: &str = "wasm_for_tests/vp_always_true.wasm"; pub const VP_ALWAYS_FALSE_WASM: &str = "wasm_for_tests/vp_always_false.wasm"; From 46b457e3f266f01f5095a3ee5d17d203081dbd3c Mon Sep 17 00:00:00 2001 From: yito88 Date: Wed, 9 Mar 2022 00:22:40 +0900 Subject: [PATCH 19/36] add update_client --- apps/src/lib/client/utils.rs | 2 +- tests/Cargo.toml | 3 +- tests/src/e2e/ibc_tests.rs | 299 ++++++++++++++++++++++++++--------- tests/src/e2e/setup.rs | 4 +- 4 files changed, 228 insertions(+), 80 deletions(-) diff --git a/apps/src/lib/client/utils.rs b/apps/src/lib/client/utils.rs index 88487267924..c6cd7c24852 100644 --- a/apps/src/lib/client/utils.rs +++ b/apps/src/lib/client/utils.rs @@ -362,7 +362,7 @@ pub async fn fetch_wasms_aux(base_dir: &Path, chain_id: &ChainId) { const TENDERMINT_NODE_ID_LENGTH: usize = 20; /// Derive Tendermint node ID from public key -fn id_from_pk(pk: &common::PublicKey) -> TendermintNodeId { +pub fn id_from_pk(pk: &common::PublicKey) -> TendermintNodeId { let mut bytes = [0u8; TENDERMINT_NODE_ID_LENGTH]; match pk { diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 765da93c1cf..e586c79e26d 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -18,12 +18,11 @@ namada_tx_prelude = {path = "../tx_prelude"} chrono = {version = "0.4.22", default-features = false, features = ["clock", "std"]} concat-idents = "1.1.2" prost = "0.9.0" +ibc-relayer = {git = "https://github.com/heliaxdev/ibc-rs", rev = "9fcc1c8c19db6af50806ffe5b2f6c214adcbfd5d", default-features = false} serde_json = {version = "1.0.65"} sha2 = "0.9.3" test-log = {version = "0.2.7", default-features = false, features = ["trace"]} tempfile = "3.2.0" -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} tokio = {version = "1.8.2", features = ["full"]} diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 6cac7446bb1..30b22b85af2 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -24,8 +24,10 @@ use namada::ibc::core::ics02_client::client_consensus::{ use namada::ibc::core::ics02_client::client_state::{ AnyClientState, ClientState, }; +use namada::ibc::core::ics02_client::header::Header; use namada::ibc::core::ics02_client::height::Height; use namada::ibc::core::ics02_client::msgs::create_client::MsgCreateAnyClient; +use namada::ibc::core::ics02_client::msgs::update_client::MsgUpdateAnyClient; use namada::ibc::core::ics02_client::trust_threshold::TrustThreshold; use namada::ibc::core::ics03_connection::connection::Counterparty as ConnCounterparty; use namada::ibc::core::ics03_connection::msgs::conn_open_ack::MsgConnectionOpenAck; @@ -47,6 +49,7 @@ use namada::ibc::core::ics04_channel::packet::Packet; use namada::ibc::core::ics04_channel::Version as ChanVersion; use namada::ibc::core::ics23_commitment::commitment::CommitmentProofBytes; use namada::ibc::core::ics23_commitment::merkle::convert_tm_to_ics_merkle_proof; +use namada::ibc::core::ics23_commitment::specs::ProofSpecs; use namada::ibc::core::ics24_host::identifier::{ ChainId, ClientId, ConnectionId, PortChannelId, PortId, }; @@ -59,16 +62,25 @@ use namada::ibc_proto::cosmos::base::v1beta1::Coin; use namada::ledger::ibc::handler::{commitment_prefix, port_channel_id}; use namada::ledger::ibc::storage::*; use namada::ledger::storage::{MerkleTree, Sha256Hasher}; +use namada::tendermint::block::Header as TmHeader; +use namada::tendermint::merkle::proof::Proof as TmProof; +use namada::tendermint::node::Id as TendermintNodeId; +use namada::tendermint::trust_threshold::TrustThresholdFraction; +use namada::tendermint_proto::Protobuf; use namada::types::storage::Key; use namada_apps::client::rpc::query_storage_value_bytes; +use namada_apps::client::utils::id_from_pk; use color_eyre::eyre::Result; use eyre::eyre; +use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo}; +use ibc_relayer::config::ChainConfig; +use ibc_relayer::config::{AddressType, GasPrice, PacketFilter}; +use ibc_relayer::keyring::Store; +use ibc_relayer::light_client::tendermint::LightClient as TmLightClient; +use ibc_relayer::light_client::{LightClient, Verified}; use setup::constants::*; -use tendermint::block::Header as TmHeader; -use tendermint::merkle::proof::Proof as TmProof; use tendermint_config::net::Address as TendermintAddress; -use tendermint_rpc::query::Query; -use tendermint_rpc::{Client, HttpClient, Order}; +use tendermint_rpc::{Client, HttpClient, Url}; use tokio::runtime::Runtime; use crate::e2e::helpers::{find_address, get_actor_rpc, get_epoch}; @@ -144,7 +156,7 @@ fn create_client(test_a: &Test, test_b: &Test) -> Result<(ClientId, ClientId)> { consensus_state: make_consensus_state(test_b, height)?, signer: Signer::new("test_a"), }; - let hash_a = submit_ibc_tx(test_a, message)?; + let height_a = submit_ibc_tx(test_a, message)?; let height = query_height(test_a)?; let client_state = make_client_state(test_a, height); @@ -154,15 +166,15 @@ fn create_client(test_a: &Test, test_b: &Test) -> Result<(ClientId, ClientId)> { consensus_state: make_consensus_state(test_a, height)?, signer: Signer::new("test_b"), }; - let hash_b = submit_ibc_tx(test_b, message)?; + let height_b = submit_ibc_tx(test_b, message)?; - let client_id_a = match get_event(test_a, hash_a)? { - IbcEvent::CreateClient(event) => event.client_id().clone(), - _ => return Err(eyre!("Unexpected event happened")), + let client_id_a = match get_event(test_a, height_a)? { + Some(IbcEvent::CreateClient(event)) => event.client_id().clone(), + _ => return Err(eyre!("Transaction failed")), }; - let client_id_b = match get_event(test_b, hash_b)? { - IbcEvent::CreateClient(event) => event.client_id().clone(), - _ => return Err(eyre!("Unexpected event happened")), + let client_id_b = match get_event(test_b, height_b)? { + Some(IbcEvent::CreateClient(event)) => event.client_id().clone(), + _ => return Err(eyre!("Transaction failed")), }; // `client_id_a` represents the ID of the B's client on Chain A @@ -200,6 +212,103 @@ fn make_consensus_state( Ok(TmConsensusState::from(header).wrap_any()) } +fn proof_specs() -> ProofSpecs { + MerkleTree::::default().proof_specs().into() +} + +fn update_to_latest_client( + src_test: &Test, + target_test: &Test, + client_id: &ClientId, +) -> Result<()> { + // check the current state on the target chain + let client_state = query_client_state(target_test, client_id)?; + let trusted_height = client_state.latest_height(); + // get the latest height on the source chain + let target_height = query_height(src_test)?; + update_client( + target_test, + client_id, + trusted_height, + target_height, + &client_state, + ) +} + +fn update_client( + test: &Test, + client_id: &ClientId, + trusted_height: Height, + target_height: Height, + client_state: &AnyClientState, +) -> Result<()> { + let config = dummy_chain_config(test); + let pk = test + .genesis + .validator + .get("validator-0") + .unwrap() + .account_public_key + .as_ref() + .unwrap(); + let peer_id: TendermintNodeId = id_from_pk(&pk.to_public_key().unwrap()); + let mut light_client = + TmLightClient::from_config(&config, peer_id).unwrap(); + let Verified { target, supporting } = light_client + .header_and_minimal_set(trusted_height, target_height, client_state) + .map_err(|e| eyre!("Building the header failed: {}", e))?; + + for header in supporting { + let message = MsgUpdateAnyClient { + header: header.wrap_any(), + client_id: client_id.clone(), + signer: Signer::new("test"), + }; + submit_ibc_tx(test, message)?; + } + + let message = MsgUpdateAnyClient { + header: target.wrap_any(), + client_id: client_id.clone(), + signer: Signer::new("test"), + }; + submit_ibc_tx(test, message)?; + + Ok(()) +} + +fn dummy_chain_config(test: &Test) -> ChainConfig { + let rpc_addr = + Url::from_str(&get_actor_rpc(test, &Who::Validator(0))).unwrap(); + // use only id and rpc_addr + ChainConfig { + id: ChainId::new(test.net.chain_id.as_str().to_string(), 0), + rpc_addr: rpc_addr.clone(), + websocket_addr: rpc_addr.clone(), + grpc_addr: rpc_addr, + rpc_timeout: Duration::new(10, 0), + account_prefix: "dummy".to_string(), + key_name: "dummy".to_string(), + key_store_type: Store::default(), + store_prefix: "dummy".to_string(), + default_gas: None, + max_gas: None, + gas_adjustment: None, + fee_granter: None, + max_msg_num: MaxMsgNum::default(), + max_tx_size: MaxTxSize::default(), + clock_drift: Duration::new(5, 0), + max_block_time: Duration::new(5, 0), + trusting_period: None, + memo_prefix: Memo::default(), + proof_specs: proof_specs(), + trust_threshold: TrustThresholdFraction::ONE_THIRD, + gas_price: GasPrice::new(0.0, "dummy".to_string()), + packet_filter: PacketFilter::default(), + address_type: AddressType::Cosmos, + } +} + fn connection_handshake( test_a: &Test, test_b: &Test, @@ -218,17 +327,20 @@ fn connection_handshake( delay_period: Duration::new(30, 0), signer: Signer::new("test_a"), }; - let hash = submit_ibc_tx(test_a, msg)?; - let conn_id_a = match get_event(test_a, hash)? { - IbcEvent::OpenInitConnection(event) => event + let height = submit_ibc_tx(test_a, msg)?; + let conn_id_a = match get_event(test_a, height)? { + Some(IbcEvent::OpenInitConnection(event)) => event .connection_id() .clone() .ok_or(eyre!("No connection ID is set"))?, - _ => return Err(eyre!("Unexpected event happened")), + _ => return Err(eyre!("Transaction failed")), }; + // Update the client state of Chain A on Chain B + update_to_latest_client(test_a, test_b, client_id_b)?; + // OpenTryConnection on Chain B - // get the B's client state and the proofs on Chain A + // get the B's proofs on Chain A let proofs = get_connection_proofs(test_a, &conn_id_a)?; let counterparty = ConnCounterparty::new( client_id_a.clone(), @@ -245,17 +357,17 @@ fn connection_handshake( delay_period: Duration::new(30, 0), signer: Signer::new("test_b"), }; - let hash = submit_ibc_tx(test_b, msg)?; - let conn_id_b = match get_event(test_b, hash)? { - IbcEvent::OpenTryConnection(event) => event + let height = submit_ibc_tx(test_b, msg)?; + let conn_id_b = match get_event(test_b, height)? { + Some(IbcEvent::OpenTryConnection(event)) => event .connection_id() .clone() .ok_or(eyre!("No connection ID is set"))?, - _ => return Err(eyre!("Unexpected event happened")), + _ => return Err(eyre!("Transaction failed")), }; // OpenAckConnection on Chain A - // get the A's client state and the proofs on Chain B + // get the A's proofs on Chain B let proofs = get_connection_proofs(test_b, &conn_id_b)?; let msg = MsgConnectionOpenAck { connection_id: conn_id_a.clone(), @@ -314,13 +426,13 @@ fn channel_handshake( channel, signer: Signer::new("test_a"), }; - let hash = submit_ibc_tx(test_a, msg)?; - let channel_id_a = match get_event(test_a, hash)? { - IbcEvent::OpenInitChannel(event) => event + let height = submit_ibc_tx(test_a, msg)?; + let channel_id_a = match get_event(test_a, height)? { + Some(IbcEvent::OpenInitChannel(event)) => event .channel_id() .ok_or(eyre!("No channel ID is set"))? .clone(), - _ => return Err(eyre!("Unexpected event happened")), + _ => return Err(eyre!("Transaction failed")), }; let port_channel_id_a = port_channel_id(port_id.clone(), channel_id_a.clone()); @@ -344,13 +456,13 @@ fn channel_handshake( proofs, signer: Signer::new("test_b"), }; - let hash = submit_ibc_tx(test_b, msg)?; - let channel_id_b = match get_event(test_b, hash)? { - IbcEvent::OpenInitChannel(event) => event + let height = submit_ibc_tx(test_b, msg)?; + let channel_id_b = match get_event(test_b, height)? { + Some(IbcEvent::OpenInitChannel(event)) => event .channel_id() .ok_or(eyre!("No channel ID is set"))? .clone(), - _ => return Err(eyre!("Unexpected event happened")), + _ => return Err(eyre!("Transaction failed")), }; let port_channel_id_b = port_channel_id(port_id.clone(), channel_id_b.clone()); @@ -416,10 +528,10 @@ fn transfer_token( timeout_height: Height::new(100, 100), timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), }; - let hash = submit_ibc_tx(test_a, msg)?; - let packet = match get_event(test_a, hash)? { - IbcEvent::SendPacket(event) => event.packet, - _ => return Err(eyre!("Unexpected event happened")), + let height = submit_ibc_tx(test_a, msg)?; + let packet = match get_event(test_a, height)? { + Some(IbcEvent::SendPacket(event)) => event.packet, + _ => return Err(eyre!("Transaction failed")), }; // Receive the token on Chain B @@ -429,10 +541,12 @@ fn transfer_token( proofs, signer: Signer::new("test_b"), }; - let hash = submit_ibc_tx(test_b, msg)?; - let (acknowledgement, packet) = match get_event(test_b, hash)? { - IbcEvent::WriteAcknowledgement(event) => (event.ack, event.packet), - _ => return Err(eyre!("Unexpected event happened")), + let height = submit_ibc_tx(test_b, msg)?; + let (acknowledgement, packet) = match get_event(test_b, height)? { + Some(IbcEvent::WriteAcknowledgement(event)) => { + (event.ack, event.packet) + } + _ => return Err(eyre!("Transaction failed")), }; // Acknowledge on Chain A @@ -476,9 +590,12 @@ fn get_ack_proof(test: &Test, packet: &Packet) -> Result { .map_err(|e| eyre!("Creating proofs failed: error {}", e)) } -fn submit_ibc_tx(test: &Test, message: impl Msg) -> Result { +fn submit_ibc_tx( + test: &Test, + message: impl Msg + std::fmt::Debug, +) -> Result { let data_path = test.test_dir.path().join("tx.data"); - let data = make_ibc_data(message); + let data = make_ibc_data(message.clone()); std::fs::write(&data_path, data).expect("writing data failed"); let code_path = wasm_abs_path(TX_IBC_WASM); @@ -507,14 +624,33 @@ fn submit_ibc_tx(test: &Test, message: impl Msg) -> Result { ], Some(40) )?; - let (_unread, matched) = if !cfg!(feature = "ABCI") { - client.exp_regex("Wrapper transaction hash: .*\n")? - } else { - client.exp_regex("Transaction hash: .*\n")? - }; - let hash = matched.trim().rsplit_once(' ').unwrap().1.replace('"', ""); + let (unread, matched) = client.exp_regex("\"height\": .*,")?; + let height_str = matched + .trim() + .rsplit_once(' ') + .unwrap() + .1 + .replace('"', "") + .replace(',', ""); + let height = height_str.parse().unwrap(); + + let (_unread, matched) = client.exp_regex("\"code\": .*,")?; + let code = matched + .trim() + .rsplit_once(' ') + .unwrap() + .1 + .replace('"', "") + .replace(',', ""); + if code != "0" { + return Err(eyre!( + "The transaction failed: message {:?}, unread {}", + message, + unread + )); + } - Ok(hash) + Ok(height) } fn make_ibc_data(message: impl Msg) -> Vec { @@ -559,42 +695,57 @@ fn query_header(test: &Test, height: Height) -> Result { } } -fn get_event(test: &Test, tx_hash: String) -> Result { +fn get_event(test: &Test, height: u32) -> Result> { let rpc = get_actor_rpc(test, &Who::Validator(0)); let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); let client = HttpClient::new(ledger_address).unwrap(); - // get the epoch - let epoch = get_epoch(test, &rpc)?; - // get the result of the transaction - let query = Query::eq("tx.hash", tx_hash.clone()); let response = Runtime::new() .unwrap() - .block_on(client.tx_search(query, false, 1, 1, Order::Ascending)) - .map_err(|e| eyre!("tx_search for an IBC event failed: {}", e))?; - let tx_resp = response.txs.get(0).ok_or_else(|| { - eyre!("The transaction has not been executed: hash {}", tx_hash) + .block_on(client.block_results(height)) + .map_err(|e| eyre!("block_results() for an IBC event failed: {}", e))?; + let tx_results = response.txs_results.ok_or_else(|| { + eyre!("No transaction has been executed: height {}", height) })?; - let tx_result = &tx_resp.tx_result; - if tx_result.code.is_err() { - return Err(eyre!( - "The transaction failed: hash {}, code {:?}, log {}", - tx_hash, - tx_result.code, - tx_result.log - )); + for result in tx_results { + if result.code.is_err() { + return Err(eyre!( + "The transaction failed: code {:?}, log {}", + result.code, + result.log + )); + } } + let events = response + .end_block_events + .ok_or_else(|| eyre!("IBC event was not found: height {}", height))?; + for event in &events { + // The height will be set, but not be used + let dummy_height = Height::new(0, 0); + match from_tx_response_event(dummy_height, event) { + Some(ibc_event) => return Ok(Some(ibc_event)), + None => continue, + } + } + // No IBC event was found + Ok(None) +} - let height = Height::new(epoch.0, u64::from(tx_resp.height)); - let event = tx_result.events.get(0).ok_or_else(|| { - eyre!("The transaction response doesn't have any event") - })?; - match from_tx_response_event(height, event) { - Some(ibc_event) => Ok(ibc_event), - None => Err(eyre!( - "The transaction response doesn't have any IBC event: hash {}", - tx_hash, - )), +fn query_client_state( + test: &Test, + client_id: &ClientId, +) -> Result { + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); + let client = HttpClient::new(ledger_address).unwrap(); + let key = client_state_key(client_id); + let result = Runtime::new() + .unwrap() + .block_on(query_storage_value_bytes(&client, &key, false)); + match result { + (Some(value), _) => AnyClientState::decode_vec(&value) + .map_err(|e| eyre!("Decoding the client state failed: {}", e)), + _ => Err(eyre!("Getting the client state failed")), } } diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index 9d67f53d7c9..33a4341a5c2 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -57,9 +57,7 @@ pub struct Network { pub chain_id: ChainId, } -/// Offset the ports used in the network configuration by 1000 for ABCI++ to -/// avoid shared resources -pub const ABCI_PLUS_PLUS_PORT_OFFSET: u16 = 1000; +/// Offset the ports used in the network configuration to avoid shared resources pub const ANOTHER_CHAIN_PORT_OFFSET: u16 = 1001; /// Add `num` validators to the genesis config. Note that called from inside From 805bc99c3d8ae22e693c12bb18a72b9f9142cf2f Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 18 Mar 2022 16:30:18 +0900 Subject: [PATCH 20/36] wait the next block --- tests/src/e2e/helpers.rs | 20 +++ tests/src/e2e/ibc_tests.rs | 309 +++++++++++++++++++++++-------------- 2 files changed, 217 insertions(+), 112 deletions(-) diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index 705c8227609..363f9bc93c9 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -5,6 +5,7 @@ use std::process::Command; use std::str::FromStr; use std::{env, time}; +use namada_apps::config::genesis::genesis_config; use color_eyre::eyre::Result; use color_eyre::owo_colors::OwoColorize; use escargot::CargoBuild; @@ -54,6 +55,25 @@ pub fn get_actor_rpc(test: &Test, who: &Who) -> String { config.ledger.tendermint.rpc_address.to_string() } +/// Get the public key of the validator +pub fn get_validator_pk(test: &Test, who: &Who) -> Option { + let index = match who { + Who::NonValidator => return None, + Who::Validator(i) => i, + }; + let file = format!("{}.toml", test.net.chain_id.as_str()); + let path = test.test_dir.path().join(file); + let config = genesis_config::open_genesis_config(path).unwrap(); + let pk = config + .validator + .get(&format!("validator-{}", index)) + .unwrap() + .account_public_key + .as_ref() + .unwrap(); + Some(pk.to_public_key().unwrap()) +} + /// Find the address of an account by its alias from the wallet #[allow(dead_code)] pub fn find_keypair( diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 30b22b85af2..6ff007f4254 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -54,7 +54,7 @@ use namada::ibc::core::ics24_host::identifier::{ ChainId, ClientId, ConnectionId, PortChannelId, PortId, }; use namada::ibc::events::{from_tx_response_event, IbcEvent}; -use namada::ibc::proofs::Proofs; +use namada::ibc::proofs::{ConsensusProof, Proofs}; use namada::ibc::signer::Signer; use namada::ibc::timestamp::Timestamp; use namada::ibc::tx_msg::Msg; @@ -83,7 +83,7 @@ use tendermint_config::net::Address as TendermintAddress; use tendermint_rpc::{Client, HttpClient, Url}; use tokio::runtime::Runtime; -use crate::e2e::helpers::{find_address, get_actor_rpc, get_epoch}; +use crate::e2e::helpers::{find_address, get_actor_rpc, get_validator_pk}; use crate::e2e::setup::{self, sleep, Bin, Test, Who}; use crate::{run, run_as}; @@ -107,10 +107,22 @@ fn run_ledger_ibc() -> Result<()> { let (conn_id_a, conn_id_b) = connection_handshake(&test_a, &test_b, &client_id_a, &client_id_b)?; - let (port_channel_id_a, _) = - channel_handshake(&test_a, &test_b, &conn_id_a, &conn_id_b)?; + let (port_channel_id_a, _) = channel_handshake( + &test_a, + &test_b, + &client_id_a, + &client_id_b, + &conn_id_a, + &conn_id_b, + )?; - transfer_token(&test_a, &test_b, &port_channel_id_a)?; + transfer_token( + &test_a, + &test_b, + &client_id_a, + &client_id_b, + &port_channel_id_a, + )?; // Check the balance on Chain A let rpc_a = get_actor_rpc(&test_a, &Who::Validator(0)); @@ -193,7 +205,7 @@ fn make_client_state(test: &Test, height: Height) -> AnyClientState { unbonding_period, max_clock_drift, height, - MerkleTree::::default().proof_specs().into(), + proof_specs(), vec!["upgrade".to_string(), "upgradedIBCState".to_string()], AllowUpdate { after_expiry: true, @@ -216,19 +228,31 @@ fn proof_specs() -> ProofSpecs { MerkleTree::::default().proof_specs().into() } -fn update_to_latest_client( +fn update_client_with_height( src_test: &Test, target_test: &Test, - client_id: &ClientId, + target_client_id: &ClientId, + target_height: Height, ) -> Result<()> { - // check the current state on the target chain - let client_state = query_client_state(target_test, client_id)?; + // check the current(stale) state on the target chain + let key = client_state_key(target_client_id); + let (value, _) = query_value_with_proof(target_test, &key)?; + let client_state = match value { + Some(v) => AnyClientState::decode_vec(&v) + .map_err(|e| eyre!("Decoding the client state failed: {}", e))?, + None => { + return Err(eyre!( + "The client state doesn't exist: client ID {}", + target_client_id + )); + } + }; let trusted_height = client_state.latest_height(); - // get the latest height on the source chain - let target_height = query_height(src_test)?; + update_client( + src_test, target_test, - client_id, + target_client_id, trusted_height, target_height, &client_state, @@ -236,22 +260,16 @@ fn update_to_latest_client( } fn update_client( - test: &Test, + src_test: &Test, + target_test: &Test, client_id: &ClientId, trusted_height: Height, target_height: Height, client_state: &AnyClientState, ) -> Result<()> { - let config = dummy_chain_config(test); - let pk = test - .genesis - .validator - .get("validator-0") - .unwrap() - .account_public_key - .as_ref() - .unwrap(); - let peer_id: TendermintNodeId = id_from_pk(&pk.to_public_key().unwrap()); + let config = dummy_chain_config(src_test); + let pk = get_validator_pk(src_test, &Who::Validator(0)).unwrap(); + let peer_id: TendermintNodeId = id_from_pk(&pk); let mut light_client = TmLightClient::from_config(&config, peer_id).unwrap(); let Verified { target, supporting } = light_client @@ -264,7 +282,7 @@ fn update_client( client_id: client_id.clone(), signer: Signer::new("test"), }; - submit_ibc_tx(test, message)?; + submit_ibc_tx(target_test, message)?; } let message = MsgUpdateAnyClient { @@ -272,14 +290,14 @@ fn update_client( client_id: client_id.clone(), signer: Signer::new("test"), }; - submit_ibc_tx(test, message)?; + submit_ibc_tx(target_test, message)?; Ok(()) } fn dummy_chain_config(test: &Test) -> ChainConfig { - let rpc_addr = - Url::from_str(&get_actor_rpc(test, &Who::Validator(0))).unwrap(); + let addr = format!("http://{}", get_actor_rpc(test, &Who::Validator(0))); + let rpc_addr = Url::from_str(&addr).unwrap(); // use only id and rpc_addr ChainConfig { id: ChainId::new(test.net.chain_id.as_str().to_string(), 0), @@ -315,7 +333,6 @@ fn connection_handshake( client_id_a: &ClientId, client_id_b: &ClientId, ) -> Result<(ConnectionId, ConnectionId)> { - // OpenInitConnection on Chain A let msg = MsgConnectionOpenInit { client_id: client_id_a.clone(), counterparty: ConnCounterparty::new( @@ -327,6 +344,7 @@ fn connection_handshake( delay_period: Duration::new(30, 0), signer: Signer::new("test_a"), }; + // OpenInitConnection on Chain A let height = submit_ibc_tx(test_a, msg)?; let conn_id_a = match get_event(test_a, height)? { Some(IbcEvent::OpenInitConnection(event)) => event @@ -336,12 +354,10 @@ fn connection_handshake( _ => return Err(eyre!("Transaction failed")), }; - // Update the client state of Chain A on Chain B - update_to_latest_client(test_a, test_b, client_id_b)?; - - // OpenTryConnection on Chain B - // get the B's proofs on Chain A - let proofs = get_connection_proofs(test_a, &conn_id_a)?; + // get the proofs from Chain A + let height_a = query_height(test_a)?; + let (client_state, proofs) = + get_connection_proofs(test_a, client_id_a, &conn_id_a, height_a)?; let counterparty = ConnCounterparty::new( client_id_a.clone(), Some(conn_id_a.clone()), @@ -350,13 +366,16 @@ fn connection_handshake( let msg = MsgConnectionOpenTry { previous_connection_id: None, client_id: client_id_b.clone(), - client_state: None, + client_state: Some(client_state), counterparty, counterparty_versions: vec![ConnVersion::default()], proofs, delay_period: Duration::new(30, 0), signer: Signer::new("test_b"), }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // OpenTryConnection on Chain B let height = submit_ibc_tx(test_b, msg)?; let conn_id_b = match get_event(test_b, height)? { Some(IbcEvent::OpenTryConnection(event)) => event @@ -366,48 +385,71 @@ fn connection_handshake( _ => return Err(eyre!("Transaction failed")), }; - // OpenAckConnection on Chain A // get the A's proofs on Chain B - let proofs = get_connection_proofs(test_b, &conn_id_b)?; + let height_b = query_height(test_b)?; + let (client_state, proofs) = + get_connection_proofs(test_b, client_id_b, &conn_id_b, height_b)?; let msg = MsgConnectionOpenAck { connection_id: conn_id_a.clone(), counterparty_connection_id: conn_id_b.clone(), - client_state: None, + client_state: Some(client_state), proofs, version: ConnVersion::default(), signer: Signer::new("test_a"), }; + // Update the client state of Chain B on Chain A + update_client_with_height(test_b, test_a, client_id_a, height_b)?; + // OpenAckConnection on Chain A submit_ibc_tx(test_a, msg)?; - // OpenConfirmConnection on Chain B // get the proofs on Chain A - let proofs = get_connection_proofs(test_a, &conn_id_a)?; + let height_a = query_height(test_a)?; + let (_, proofs) = + get_connection_proofs(test_a, client_id_a, &conn_id_a, height_a)?; let msg = MsgConnectionOpenConfirm { connection_id: conn_id_b.clone(), proofs, signer: Signer::new("test_b"), }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // OpenConfirmConnection on Chain B submit_ibc_tx(test_b, msg)?; Ok((conn_id_a, conn_id_b)) } +// get the proofs on the target height fn get_connection_proofs( test: &Test, + client_id: &ClientId, conn_id: &ConnectionId, -) -> Result { - let height = query_height(test)?; - let key = connection_key(&conn_id); - let tm_proof = query_proof(test, &key)?; + target_height: Height, +) -> Result<(AnyClientState, Proofs)> { + let key = connection_key(conn_id); + let (_, tm_proof) = query_value_with_proof(test, &key)?; let connection_proof = convert_proof(tm_proof)?; - Proofs::new(connection_proof, None, None, None, height) - .map_err(|e| eyre!("Creating proofs failed: error {}", e)) + let (client_state, client_state_proof, consensus_proof) = + get_client_states(test, client_id)?; + + let proofs = Proofs::new( + connection_proof, + Some(client_state_proof), + Some(consensus_proof), + None, + target_height, + ) + .map_err(|e| eyre!("Creating proofs failed: error {}", e))?; + + Ok((client_state, proofs)) } fn channel_handshake( test_a: &Test, test_b: &Test, + client_id_a: &ClientId, + client_id_b: &ClientId, conn_id_a: &ConnectionId, conn_id_b: &ConnectionId, ) -> Result<(PortChannelId, PortChannelId)> { @@ -415,7 +457,7 @@ fn channel_handshake( let port_id = PortId::from_str("test_port").unwrap(); let counterparty = ChanCounterparty::new(port_id.clone(), None); let channel = ChannelEnd::new( - ChanState::Uninitialized, + ChanState::Init, ChanOrder::Unordered, counterparty, vec![conn_id_a.clone()], @@ -437,17 +479,19 @@ fn channel_handshake( let port_channel_id_a = port_channel_id(port_id.clone(), channel_id_a.clone()); - // OpenTryChannel on Chain B + // get the proofs from Chain A + let height_a = query_height(test_a)?; + let proofs = + get_channel_proofs(test_a, client_id_a, &port_channel_id_a, height_a)?; let counterparty = ChanCounterparty::new(port_id.clone(), Some(channel_id_a.clone())); let channel = ChannelEnd::new( - ChanState::Uninitialized, + ChanState::TryOpen, ChanOrder::Unordered, counterparty, vec![conn_id_b.clone()], ChanVersion::ics20(), ); - let proofs = get_channel_proofs(test_a, &port_channel_id_a)?; let msg = MsgChannelOpenTry { port_id: port_id.clone(), previous_channel_id: None, @@ -456,9 +500,12 @@ fn channel_handshake( proofs, signer: Signer::new("test_b"), }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // OpenTryChannel on Chain B let height = submit_ibc_tx(test_b, msg)?; let channel_id_b = match get_event(test_b, height)? { - Some(IbcEvent::OpenInitChannel(event)) => event + Some(IbcEvent::OpenTryChannel(event)) => event .channel_id() .ok_or(eyre!("No channel ID is set"))? .clone(), @@ -467,8 +514,10 @@ fn channel_handshake( let port_channel_id_b = port_channel_id(port_id.clone(), channel_id_b.clone()); - // OpenAckChannel on Chain A - let proofs = get_channel_proofs(test_b, &port_channel_id_b)?; + // get the A's proofs on Chain B + let height_b = query_height(test_b)?; + let proofs = + get_channel_proofs(test_b, client_id_b, &port_channel_id_b, height_b)?; let msg = MsgChannelOpenAck { port_id: port_id.clone(), channel_id: channel_id_a, @@ -477,16 +526,24 @@ fn channel_handshake( proofs, signer: Signer::new("test_a"), }; + // Update the client state of Chain B on Chain A + update_client_with_height(test_b, test_a, client_id_a, height_b)?; + // OpenAckChannel on Chain A submit_ibc_tx(test_a, msg)?; - // OpenConfirmChannel on Chain B - let proofs = get_channel_proofs(test_a, &port_channel_id_a)?; + // get the proofs on Chain A + let height_a = query_height(test_a)?; + let proofs = + get_channel_proofs(test_a, client_id_a, &port_channel_id_a, height_a)?; let msg = MsgChannelOpenConfirm { port_id, channel_id: channel_id_b, proofs, signer: Signer::new("test_b"), }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // OpenConfirmChannel on Chain B submit_ibc_tx(test_b, msg)?; Ok((port_channel_id_a, port_channel_id_b)) @@ -494,27 +551,68 @@ fn channel_handshake( fn get_channel_proofs( test: &Test, + client_id: &ClientId, port_channel_id: &PortChannelId, + target_height: Height, ) -> Result { - let height = query_height(test)?; let key = channel_key(port_channel_id); - let tm_proof = query_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key)?; let proof = convert_proof(tm_proof)?; - Proofs::new(proof, None, None, None, height) - .map_err(|e| eyre!("Creating proofs failed: error {}", e)) + let (_, client_state_proof, consensus_proof) = + get_client_states(test, client_id)?; + + Proofs::new( + proof, + Some(client_state_proof), + Some(consensus_proof), + None, + target_height, + ) + .map_err(|e| eyre!("Creating proofs failed: error {}", e)) +} + +// get the client state, the proof of the client state, and the proof of the +// consensus state +fn get_client_states( + test: &Test, + client_id: &ClientId, +) -> Result<(AnyClientState, CommitmentProofBytes, ConsensusProof)> { + let key = client_state_key(client_id); + let (value, tm_proof) = query_value_with_proof(test, &key)?; + let client_state = match value { + Some(v) => AnyClientState::decode_vec(&v) + .map_err(|e| eyre!("Decoding the client state failed: {}", e))?, + None => { + return Err(eyre!( + "The client state doesn't exist: client ID {}", + client_id + )); + } + }; + let client_state_proof = convert_proof(tm_proof)?; + + let height = client_state.latest_height(); + let key = consensus_state_key(client_id, height); + let (_, tm_proof) = query_value_with_proof(test, &key)?; + let proof = convert_proof(tm_proof)?; + let consensus_proof = ConsensusProof::new(proof, height) + .map_err(|e| eyre!("Creating ConsensusProof failed: error {}", e))?; + + Ok((client_state, client_state_proof, consensus_proof)) } fn transfer_token( test_a: &Test, test_b: &Test, + client_id_a: &ClientId, + client_id_b: &ClientId, source_port_channel_id: &PortChannelId, ) -> Result<()> { let xan = find_address(test_a, XAN)?; let sender = find_address(test_a, ALBERT)?; let receiver = find_address(test_b, BERTHA)?; - // Send a token from Chain A let token = Some(Coin { denom: xan.to_string(), amount: "1000000".to_string(), @@ -528,19 +626,23 @@ fn transfer_token( timeout_height: Height::new(100, 100), timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), }; + // Send a token from Chain A let height = submit_ibc_tx(test_a, msg)?; let packet = match get_event(test_a, height)? { Some(IbcEvent::SendPacket(event)) => event.packet, _ => return Err(eyre!("Transaction failed")), }; - // Receive the token on Chain B - let proofs = get_commitment_proof(test_a, &packet)?; + let height_a = query_height(test_a)?; + let proofs = get_commitment_proof(test_a, &packet, height_a)?; let msg = MsgRecvPacket { packet, proofs, signer: Signer::new("test_b"), }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // Receive the token on Chain B let height = submit_ibc_tx(test_b, msg)?; let (acknowledgement, packet) = match get_event(test_b, height)? { Some(IbcEvent::WriteAcknowledgement(event)) => { @@ -549,44 +651,54 @@ fn transfer_token( _ => return Err(eyre!("Transaction failed")), }; - // Acknowledge on Chain A - let proofs = get_ack_proof(test_a, &packet)?; + // get the proof on Chain B + let height_b = query_height(test_b)?; + let proofs = get_ack_proof(test_b, &packet, height_b)?; let msg = MsgAcknowledgement { packet, acknowledgement: acknowledgement.into(), proofs, signer: Signer::new("test_a"), }; - submit_ibc_tx(test_b, msg)?; + // Update the client state of Chain B on Chain A + update_client_with_height(test_b, test_a, client_id_a, height_b)?; + // Acknowledge on Chain A + submit_ibc_tx(test_a, msg)?; Ok(()) } -fn get_commitment_proof(test: &Test, packet: &Packet) -> Result { - let height = query_height(test)?; +fn get_commitment_proof( + test: &Test, + packet: &Packet, + target_height: Height, +) -> Result { let key = commitment_key( &packet.source_port, &packet.source_channel, packet.sequence, ); - let tm_proof = query_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key)?; let commitment_proof = convert_proof(tm_proof)?; - Proofs::new(commitment_proof, None, None, None, height) + Proofs::new(commitment_proof, None, None, None, target_height) .map_err(|e| eyre!("Creating proofs failed: error {}", e)) } -fn get_ack_proof(test: &Test, packet: &Packet) -> Result { - let height = query_height(test)?; +fn get_ack_proof( + test: &Test, + packet: &Packet, + target_height: Height, +) -> Result { let key = ack_key( &packet.destination_port, &packet.destination_channel, packet.sequence, ); - let tm_proof = query_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key)?; let ack_proof = convert_proof(tm_proof)?; - Proofs::new(ack_proof, None, None, None, height) + Proofs::new(ack_proof, None, None, None, target_height) .map_err(|e| eyre!("Creating proofs failed: error {}", e)) } @@ -650,6 +762,11 @@ fn submit_ibc_tx( )); } + // wait for the next block to use the app hash + while height as u64 + 1 > query_height(test)?.revision_height { + sleep(1); + } + Ok(height) } @@ -670,12 +787,8 @@ fn query_height(test: &Test) -> Result { let status = rt .block_on(client.status()) .map_err(|e| eyre!("Getting the status failed: {}", e))?; - let epoch = get_epoch(test, &rpc)?; - Ok(Height::new( - epoch.0, - status.sync_info.latest_block_height.into(), - )) + Ok(Height::new(0, status.sync_info.latest_block_height.into())) } fn query_header(test: &Test, height: Height) -> Result { @@ -731,38 +844,10 @@ fn get_event(test: &Test, height: u32) -> Result> { Ok(None) } -fn query_client_state( +fn query_value_with_proof( test: &Test, - client_id: &ClientId, -) -> Result { - let rpc = get_actor_rpc(test, &Who::Validator(0)); - let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); - let client = HttpClient::new(ledger_address).unwrap(); - let key = client_state_key(client_id); - let result = Runtime::new() - .unwrap() - .block_on(query_storage_value_bytes(&client, &key, false)); - match result { - (Some(value), _) => AnyClientState::decode_vec(&value) - .map_err(|e| eyre!("Decoding the client state failed: {}", e)), - _ => Err(eyre!("Getting the client state failed")), - } -} - -fn query_with_proof(test: &Test, key: &Key) -> Result<(Vec, TmProof)> { - let rpc = get_actor_rpc(test, &Who::Validator(0)); - let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); - let client = HttpClient::new(ledger_address).unwrap(); - let result = Runtime::new() - .unwrap() - .block_on(query_storage_value_bytes(&client, key, true)); - match result { - (Some(value), Some(proof)) => Ok((value, proof)), - _ => Err(eyre!("The value doesn't exist: key {}", key)), - } -} - -fn query_proof(test: &Test, key: &Key) -> Result { + key: &Key, +) -> Result<(Option>, TmProof)> { let rpc = get_actor_rpc(test, &Who::Validator(0)); let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); let client = HttpClient::new(ledger_address).unwrap(); @@ -770,8 +855,8 @@ fn query_proof(test: &Test, key: &Key) -> Result { .unwrap() .block_on(query_storage_value_bytes(&client, key, true)); match result { - (_, Some(proof)) => Ok(proof), - _ => Err(eyre!("Proof doesn't exist: key {}", key)), + (value, Some(proof)) => Ok((value, proof)), + _ => Err(eyre!("Query failed: key {}", key)), } } From bd17fa2d2acdca0c76ffb92b645760788bb3efab Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 22 Mar 2022 19:44:12 +0900 Subject: [PATCH 21/36] query with the height --- tests/src/e2e/ibc_tests.rs | 43 +++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 6ff007f4254..a97426c8517 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -67,7 +67,7 @@ use namada::tendermint::merkle::proof::Proof as TmProof; use namada::tendermint::node::Id as TendermintNodeId; use namada::tendermint::trust_threshold::TrustThresholdFraction; use namada::tendermint_proto::Protobuf; -use namada::types::storage::Key; +use namada::types::storage::{BlockHeight, Key}; use namada_apps::client::rpc::query_storage_value_bytes; use namada_apps::client::utils::id_from_pk; use color_eyre::eyre::Result; @@ -236,7 +236,7 @@ fn update_client_with_height( ) -> Result<()> { // check the current(stale) state on the target chain let key = client_state_key(target_client_id); - let (value, _) = query_value_with_proof(target_test, &key)?; + let (value, _) = query_value_with_proof(target_test, &key, target_height)?; let client_state = match value { Some(v) => AnyClientState::decode_vec(&v) .map_err(|e| eyre!("Decoding the client state failed: {}", e))?, @@ -341,7 +341,7 @@ fn connection_handshake( commitment_prefix(), ), version: Some(ConnVersion::default()), - delay_period: Duration::new(30, 0), + delay_period: Duration::new(1, 0), signer: Signer::new("test_a"), }; // OpenInitConnection on Chain A @@ -370,7 +370,7 @@ fn connection_handshake( counterparty, counterparty_versions: vec![ConnVersion::default()], proofs, - delay_period: Duration::new(30, 0), + delay_period: Duration::new(1, 0), signer: Signer::new("test_b"), }; // Update the client state of Chain A on Chain B @@ -426,12 +426,14 @@ fn get_connection_proofs( conn_id: &ConnectionId, target_height: Height, ) -> Result<(AnyClientState, Proofs)> { + // we need proofs at the height of the previous block + let query_height = target_height.decrement().unwrap(); let key = connection_key(conn_id); - let (_, tm_proof) = query_value_with_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key, query_height)?; let connection_proof = convert_proof(tm_proof)?; let (client_state, client_state_proof, consensus_proof) = - get_client_states(test, client_id)?; + get_client_states(test, client_id, query_height)?; let proofs = Proofs::new( connection_proof, @@ -555,12 +557,14 @@ fn get_channel_proofs( port_channel_id: &PortChannelId, target_height: Height, ) -> Result { + // we need proofs at the height of the previous block + let query_height = target_height.decrement().unwrap(); let key = channel_key(port_channel_id); - let (_, tm_proof) = query_value_with_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key, query_height)?; let proof = convert_proof(tm_proof)?; let (_, client_state_proof, consensus_proof) = - get_client_states(test, client_id)?; + get_client_states(test, client_id, query_height)?; Proofs::new( proof, @@ -577,9 +581,10 @@ fn get_channel_proofs( fn get_client_states( test: &Test, client_id: &ClientId, + target_height: Height, // should have been already decremented ) -> Result<(AnyClientState, CommitmentProofBytes, ConsensusProof)> { let key = client_state_key(client_id); - let (value, tm_proof) = query_value_with_proof(test, &key)?; + let (value, tm_proof) = query_value_with_proof(test, &key, target_height)?; let client_state = match value { Some(v) => AnyClientState::decode_vec(&v) .map_err(|e| eyre!("Decoding the client state failed: {}", e))?, @@ -594,7 +599,7 @@ fn get_client_states( let height = client_state.latest_height(); let key = consensus_state_key(client_id, height); - let (_, tm_proof) = query_value_with_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key, target_height)?; let proof = convert_proof(tm_proof)?; let consensus_proof = ConsensusProof::new(proof, height) .map_err(|e| eyre!("Creating ConsensusProof failed: error {}", e))?; @@ -673,12 +678,14 @@ fn get_commitment_proof( packet: &Packet, target_height: Height, ) -> Result { + // we need proofs at the height of the previous block + let query_height = target_height.decrement().unwrap(); let key = commitment_key( &packet.source_port, &packet.source_channel, packet.sequence, ); - let (_, tm_proof) = query_value_with_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key, query_height)?; let commitment_proof = convert_proof(tm_proof)?; Proofs::new(commitment_proof, None, None, None, target_height) @@ -690,12 +697,14 @@ fn get_ack_proof( packet: &Packet, target_height: Height, ) -> Result { + // we need proofs at the height of the previous block + let query_height = target_height.decrement().unwrap(); let key = ack_key( &packet.destination_port, &packet.destination_channel, packet.sequence, ); - let (_, tm_proof) = query_value_with_proof(test, &key)?; + let (_, tm_proof) = query_value_with_proof(test, &key, query_height)?; let ack_proof = convert_proof(tm_proof)?; Proofs::new(ack_proof, None, None, None, target_height) @@ -847,13 +856,17 @@ fn get_event(test: &Test, height: u32) -> Result> { fn query_value_with_proof( test: &Test, key: &Key, + height: Height, ) -> Result<(Option>, TmProof)> { let rpc = get_actor_rpc(test, &Who::Validator(0)); let ledger_address = TendermintAddress::from_str(&rpc).unwrap(); let client = HttpClient::new(ledger_address).unwrap(); - let result = Runtime::new() - .unwrap() - .block_on(query_storage_value_bytes(&client, key, true)); + let result = Runtime::new().unwrap().block_on(query_storage_value_bytes( + &client, + key, + Some(BlockHeight(height.revision_height)), + true, + )); match result { (value, Some(proof)) => Ok((value, proof)), _ => Err(eyre!("Query failed: key {}", key)), From 39b69b1dd3b04a9b11f436826cd173a4ea6ca2bb Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 22 Mar 2022 23:37:49 +0900 Subject: [PATCH 22/36] with height --- apps/src/lib/client/rpc.rs | 10 +++++++--- tests/src/e2e/ibc_tests.rs | 35 +++++++++++++++++------------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index 8e13639469c..4b3ae40afec 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -29,13 +29,14 @@ use namada::types::governance::{ VotePower, }; use namada::types::key::*; -use namada::types::storage::{Epoch, Key, KeySeg, PrefixValue}; +use namada::types::storage::{BlockHeight, Epoch, Key, KeySeg, PrefixValue}; use namada::types::token::{balance_key, Amount}; use namada::types::{address, storage, token}; use crate::cli::{self, args, Context}; use crate::client::tendermint_rpc_types::TxResponse; use crate::facade::tendermint::abci::Code; +use crate::facade::tendermint::block::Height; use crate::facade::tendermint::merkle::proof::Proof; use crate::facade::tendermint_config::net::Address as TendermintAddress; use crate::facade::tendermint_rpc::error::Error as TError; @@ -1294,7 +1295,8 @@ pub async fn query_storage_value( where T: BorshDeserialize, { - let (value, _proof) = query_storage_value_bytes(client, key, false).await; + let (value, _proof) = + query_storage_value_bytes(client, key, None, false).await; match value { Some(v) => match T::try_from_slice(&v[..]) { Ok(value) => return Some(value), @@ -1309,12 +1311,14 @@ where pub async fn query_storage_value_bytes( client: &HttpClient, key: &storage::Key, + height: Option, prove: bool, ) -> (Option>, Option) { let path = Path::Value(key.to_owned()); let data = vec![]; + let height = height.map(|h| Height::try_from(h.0).unwrap()); let response = client - .abci_query(Some(path.into()), data, None, prove) + .abci_query(Some(path.into()), data, height, prove) .await .unwrap(); match response.code { diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index a97426c8517..08a917e709c 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -64,9 +64,9 @@ use namada::ledger::ibc::storage::*; use namada::ledger::storage::{MerkleTree, Sha256Hasher}; use namada::tendermint::block::Header as TmHeader; use namada::tendermint::merkle::proof::Proof as TmProof; -use namada::tendermint::node::Id as TendermintNodeId; use namada::tendermint::trust_threshold::TrustThresholdFraction; use namada::tendermint_proto::Protobuf; +use namada::types::key::PublicKey; use namada::types::storage::{BlockHeight, Key}; use namada_apps::client::rpc::query_storage_value_bytes; use namada_apps::client::utils::id_from_pk; @@ -269,7 +269,7 @@ fn update_client( ) -> Result<()> { let config = dummy_chain_config(src_test); let pk = get_validator_pk(src_test, &Who::Validator(0)).unwrap(); - let peer_id: TendermintNodeId = id_from_pk(&pk); + let peer_id = id_from_pk(&PublicKey::try_from_pk(&pk).unwrap()); let mut light_client = TmLightClient::from_config(&config, peer_id).unwrap(); let Verified { target, supporting } = light_client @@ -471,22 +471,22 @@ fn channel_handshake( signer: Signer::new("test_a"), }; let height = submit_ibc_tx(test_a, msg)?; - let channel_id_a = match get_event(test_a, height)? { - Some(IbcEvent::OpenInitChannel(event)) => event - .channel_id() - .ok_or(eyre!("No channel ID is set"))? - .clone(), - _ => return Err(eyre!("Transaction failed")), - }; - let port_channel_id_a = - port_channel_id(port_id.clone(), channel_id_a.clone()); + let channel_id_a = + match get_event(test_a, height)? { + Some(IbcEvent::OpenInitChannel(event)) => event + .channel_id() + .cloned() + .ok_or(eyre!("No channel ID is set"))?, + _ => return Err(eyre!("Transaction failed")), + }; + let port_channel_id_a = port_channel_id(port_id.clone(), channel_id_a); // get the proofs from Chain A let height_a = query_height(test_a)?; let proofs = get_channel_proofs(test_a, client_id_a, &port_channel_id_a, height_a)?; let counterparty = - ChanCounterparty::new(port_id.clone(), Some(channel_id_a.clone())); + ChanCounterparty::new(port_id.clone(), Some(channel_id_a)); let channel = ChannelEnd::new( ChanState::TryOpen, ChanOrder::Unordered, @@ -509,12 +509,11 @@ fn channel_handshake( let channel_id_b = match get_event(test_b, height)? { Some(IbcEvent::OpenTryChannel(event)) => event .channel_id() - .ok_or(eyre!("No channel ID is set"))? - .clone(), + .cloned() + .ok_or(eyre!("No channel ID is set"))?, _ => return Err(eyre!("Transaction failed")), }; - let port_channel_id_b = - port_channel_id(port_id.clone(), channel_id_b.clone()); + let port_channel_id_b = port_channel_id(port_id.clone(), channel_id_b); // get the A's proofs on Chain B let height_b = query_height(test_b)?; @@ -523,7 +522,7 @@ fn channel_handshake( let msg = MsgChannelOpenAck { port_id: port_id.clone(), channel_id: channel_id_a, - counterparty_channel_id: channel_id_b.clone(), + counterparty_channel_id: channel_id_b, counterparty_version: ChanVersion::ics20(), proofs, signer: Signer::new("test_a"), @@ -624,7 +623,7 @@ fn transfer_token( }); let msg = MsgTransfer { source_port: source_port_channel_id.port_id.clone(), - source_channel: source_port_channel_id.channel_id.clone(), + source_channel: source_port_channel_id.channel_id, token, sender: Signer::new(sender.to_string()), receiver: Signer::new(receiver.to_string()), From 71e5ca3b378324fc1a56f404e2f54b1a1a09ed59 Mon Sep 17 00:00:00 2001 From: yito88 Date: Wed, 27 Jul 2022 16:05:54 +0200 Subject: [PATCH 23/36] add sub_prefix --- tests/src/e2e/ibc_tests.rs | 22 +++++++++++++++++++++- tests/src/e2e/setup.rs | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 08a917e709c..e819895abd1 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -99,6 +99,15 @@ fn run_ledger_ibc() -> Result<()> { let mut ledger_b = run_as!(test_b, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?; ledger_b.exp_string("Anoma ledger node started")?; + if !cfg!(feature = "ABCI") { + ledger_a.exp_string("started node")?; + ledger_b.exp_string("started node")?; + } else { + ledger_a.exp_string("Started node")?; + ledger_b.exp_string("Started node")?; + } + let _bg_ledger_a = ledger_a.background(); + let _bg_ledger_b = ledger_b.background(); sleep(5); @@ -142,16 +151,26 @@ fn run_ledger_ibc() -> Result<()> { // Check the balance on Chain B let rpc_b = get_actor_rpc(&test_b, &Who::Validator(0)); + let sub_prefix = ibc_token_prefix( + &port_channel_id_a.port_id, + &port_channel_id_a.channel_id, + &find_address(&test_b, XAN).unwrap(), + ) + .sub_key() + .unwrap() + .to_string(); let query_args = vec![ "balance", "--owner", BERTHA, "--token", XAN, + "--sub-prefix", + &sub_prefix, "--ledger-address", &rpc_b, ]; - let expected = r"XAN: 2000000"; + let expected = r"XAN with ibc/.*: 1000000"; let mut client = run!(test_b, Bin::Client, query_args, Some(40))?; client.exp_regex(expected)?; client.assert_success(); @@ -744,6 +763,7 @@ fn submit_ibc_tx( ], Some(40) )?; + client.exp_string("Transaction applied")?; let (unread, matched) = client.exp_regex("\"height\": .*,")?; let height_str = matched .trim() diff --git a/tests/src/e2e/setup.rs b/tests/src/e2e/setup.rs index 33a4341a5c2..a963dbcb8df 100644 --- a/tests/src/e2e/setup.rs +++ b/tests/src/e2e/setup.rs @@ -92,6 +92,7 @@ pub fn single_node_net() -> Result { network(|genesis| genesis, None) } +/// Setup two networks with a single genesis validator node. pub fn two_single_node_nets() -> Result<(Test, Test)> { Ok(( network(|genesis| genesis, None)?, From ae8414d3b49d309dfaf23ffbda97d345e38006f8 Mon Sep 17 00:00:00 2001 From: yito88 Date: Thu, 28 Jul 2022 18:43:55 +0200 Subject: [PATCH 24/36] check balances --- tests/src/e2e/ibc_tests.rs | 48 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index e819895abd1..1d0fa1e4249 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -66,6 +66,7 @@ use namada::tendermint::block::Header as TmHeader; use namada::tendermint::merkle::proof::Proof as TmProof; use namada::tendermint::trust_threshold::TrustThresholdFraction; use namada::tendermint_proto::Protobuf; +use namada::types::address::{Address, InternalAddress}; use namada::types::key::PublicKey; use namada::types::storage::{BlockHeight, Key}; use namada_apps::client::rpc::query_storage_value_bytes; @@ -133,32 +134,33 @@ fn run_ledger_ibc() -> Result<()> { &port_channel_id_a, )?; - // Check the balance on Chain A + // Check the balances on Chain A + let key_prefix = ibc_token_prefix( + &port_channel_id_a.port_id, + &port_channel_id_a.channel_id, + &find_address(&test_b, XAN).unwrap(), + ); + let sub_prefix = key_prefix.sub_key().unwrap().to_string(); + let rpc_a = get_actor_rpc(&test_a, &Who::Validator(0)); - let query_args = vec![ - "balance", - "--owner", - ALBERT, - "--token", - XAN, - "--ledger-address", - &rpc_a, - ]; - let expected = r"XAN: 0"; + let query_args = + vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; - client.exp_regex(expected)?; + // Check the source balance + let sender = find_address(&test_a, ALBERT)?; + let expected = format!(": 900000, owned by {}", sender); + client.exp_string(&expected)?; + // Check the escrowed balance + let expected = format!( + " with {}: 100000, owned by {}", + sub_prefix, + Address::Internal(InternalAddress::IbcEscrow) + ); + client.exp_string(&expected)?; client.assert_success(); // Check the balance on Chain B let rpc_b = get_actor_rpc(&test_b, &Who::Validator(0)); - let sub_prefix = ibc_token_prefix( - &port_channel_id_a.port_id, - &port_channel_id_a.channel_id, - &find_address(&test_b, XAN).unwrap(), - ) - .sub_key() - .unwrap() - .to_string(); let query_args = vec![ "balance", "--owner", @@ -170,9 +172,9 @@ fn run_ledger_ibc() -> Result<()> { "--ledger-address", &rpc_b, ]; - let expected = r"XAN with ibc/.*: 1000000"; + let expected = format!("XAN with {}: 100000", sub_prefix); let mut client = run!(test_b, Bin::Client, query_args, Some(40))?; - client.exp_regex(expected)?; + client.exp_string(&expected)?; client.assert_success(); Ok(()) @@ -638,7 +640,7 @@ fn transfer_token( let token = Some(Coin { denom: xan.to_string(), - amount: "1000000".to_string(), + amount: "100000".to_string(), }); let msg = MsgTransfer { source_port: source_port_channel_id.port_id.clone(), From d490e7840fc6b8e9f3e546fb09beea8b3918e839 Mon Sep 17 00:00:00 2001 From: yito88 Date: Wed, 3 Aug 2022 11:57:55 +0200 Subject: [PATCH 25/36] add transfer back --- tests/src/e2e/ibc_tests.rs | 249 ++++++++++++++++++++++++++++++------- 1 file changed, 207 insertions(+), 42 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 1d0fa1e4249..f3bf86527c1 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -117,7 +117,7 @@ fn run_ledger_ibc() -> Result<()> { let (conn_id_a, conn_id_b) = connection_handshake(&test_a, &test_b, &client_id_a, &client_id_b)?; - let (port_channel_id_a, _) = channel_handshake( + let (port_channel_id_a, port_channel_id_b) = channel_handshake( &test_a, &test_b, &client_id_a, @@ -126,6 +126,7 @@ fn run_ledger_ibc() -> Result<()> { &conn_id_b, )?; + // transfer from the normal account transfer_token( &test_a, &test_b, @@ -133,49 +134,24 @@ fn run_ledger_ibc() -> Result<()> { &client_id_b, &port_channel_id_a, )?; + check_balances(&port_channel_id_a, &port_channel_id_b, &test_a, &test_b)?; - // Check the balances on Chain A - let key_prefix = ibc_token_prefix( - &port_channel_id_a.port_id, - &port_channel_id_a.channel_id, - &find_address(&test_b, XAN).unwrap(), - ); - let sub_prefix = key_prefix.sub_key().unwrap().to_string(); - - let rpc_a = get_actor_rpc(&test_a, &Who::Validator(0)); - let query_args = - vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; - let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; - // Check the source balance - let sender = find_address(&test_a, ALBERT)?; - let expected = format!(": 900000, owned by {}", sender); - client.exp_string(&expected)?; - // Check the escrowed balance - let expected = format!( - " with {}: 100000, owned by {}", - sub_prefix, - Address::Internal(InternalAddress::IbcEscrow) - ); - client.exp_string(&expected)?; - client.assert_success(); + // transfer back from the normal account + transfer_back( + &test_a, + &test_b, + &client_id_a, + &client_id_b, + &port_channel_id_b, + )?; + check_balances_after_back( + &port_channel_id_a, + &port_channel_id_b, + &test_a, + &test_b, + )?; - // Check the balance on Chain B - let rpc_b = get_actor_rpc(&test_b, &Who::Validator(0)); - let query_args = vec![ - "balance", - "--owner", - BERTHA, - "--token", - XAN, - "--sub-prefix", - &sub_prefix, - "--ledger-address", - &rpc_b, - ]; - let expected = format!("XAN with {}: 100000", sub_prefix); - let mut client = run!(test_b, Bin::Client, query_args, Some(40))?; - client.exp_string(&expected)?; - client.assert_success(); + // TODO: packet timeout and refund Ok(()) } @@ -693,6 +669,77 @@ fn transfer_token( Ok(()) } +/// Give the token back after transfer_token +fn transfer_back( + test_a: &Test, + test_b: &Test, + client_id_a: &ClientId, + client_id_b: &ClientId, + port_channel_id_b: &PortChannelId, +) -> Result<()> { + let xan = find_address(test_b, XAN)?; + let sender = find_address(test_b, BERTHA)?; + let receiver = find_address(test_a, ALBERT)?; + + // Chain A was the source for the sent token + let token = Some(Coin { + denom: format!( + "{}/{}/{}", + port_channel_id_b.port_id, port_channel_id_b.channel_id, xan + ), + amount: "50000".to_string(), + }); + let msg = MsgTransfer { + source_port: port_channel_id_b.port_id.clone(), + source_channel: port_channel_id_b.channel_id, + token, + sender: Signer::new(sender.to_string()), + receiver: Signer::new(receiver.to_string()), + timeout_height: Height::new(100, 100), + timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), + }; + // Send a token from Chain B + let height = submit_ibc_tx(test_b, msg)?; + let packet = match get_event(test_b, height)? { + Some(IbcEvent::SendPacket(event)) => event.packet, + _ => return Err(eyre!("Transaction failed")), + }; + + let height_b = query_height(test_b)?; + let proofs = get_commitment_proof(test_b, &packet, height_b)?; + let msg = MsgRecvPacket { + packet, + proofs, + signer: Signer::new("test_a"), + }; + // Update the client state of Chain B on Chain A + update_client_with_height(test_b, test_a, client_id_a, height_b)?; + // Receive the token on Chain A + let height = submit_ibc_tx(test_a, msg)?; + let (acknowledgement, packet) = match get_event(test_a, height)? { + Some(IbcEvent::WriteAcknowledgement(event)) => { + (event.ack, event.packet) + } + _ => return Err(eyre!("Transaction failed")), + }; + + // get the proof on Chain A + let height_a = query_height(test_a)?; + let proofs = get_ack_proof(test_a, &packet, height_a)?; + let msg = MsgAcknowledgement { + packet, + acknowledgement: acknowledgement.into(), + proofs, + signer: Signer::new("test_b"), + }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // Acknowledge on Chain B + submit_ibc_tx(test_b, msg)?; + + Ok(()) +} + fn get_commitment_proof( test: &Test, packet: &Packet, @@ -901,3 +948,121 @@ fn convert_proof(tm_proof: TmProof) -> Result { eyre!("Proof conversion to CommitmentProofBytes failed: {}", e) }) } + +/// Check balances after IBC transfer +fn check_balances( + src_port_channel_id: &PortChannelId, + dest_port_channel_id: &PortChannelId, + test_a: &Test, + test_b: &Test, +) -> Result<()> { + let sender = find_address(test_a, ALBERT)?; + let token = find_address(test_a, XAN)?; + + // Check the balances on Chain A + let rpc_a = get_actor_rpc(test_a, &Who::Validator(0)); + let query_args = + vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; + let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; + // Check the source balance + let expected = format!(": 900000, owned by {}", sender); + client.exp_string(&expected)?; + // Check the escrowed balance + let key_prefix = ibc_account_prefix( + &src_port_channel_id.port_id, + &src_port_channel_id.channel_id, + &token, + ); + let sub_prefix = key_prefix.sub_key().unwrap().to_string(); + let expected = format!( + " with {}: 100000, owned by {}", + sub_prefix, + Address::Internal(InternalAddress::IbcEscrow) + ); + client.exp_string(&expected)?; + client.assert_success(); + + // Check the balance on Chain B + let denom = format!( + "{}/{}/{}", + &dest_port_channel_id.port_id, &dest_port_channel_id.channel_id, &token, + ); + let key_prefix = ibc_token_prefix(&denom)?; + let sub_prefix = key_prefix.sub_key().unwrap().to_string(); + let rpc_b = get_actor_rpc(test_b, &Who::Validator(0)); + let query_args = vec![ + "balance", + "--owner", + BERTHA, + "--token", + XAN, + "--sub-prefix", + &sub_prefix, + "--ledger-address", + &rpc_b, + ]; + let expected = format!("XAN with {}: 100000", sub_prefix); + let mut client = run!(test_b, Bin::Client, query_args, Some(40))?; + client.exp_string(&expected)?; + client.assert_success(); + Ok(()) +} + +/// Check balances after IBC transfer back +fn check_balances_after_back( + src_port_channel_id: &PortChannelId, + dest_port_channel_id: &PortChannelId, + test_a: &Test, + test_b: &Test, +) -> Result<()> { + let sender = find_address(test_a, ALBERT)?; + let token = find_address(test_b, XAN)?; + + // Check the balances on Chain A + let rpc_a = get_actor_rpc(test_a, &Who::Validator(0)); + let query_args = + vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; + let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; + // Check the source balance + let expected = format!(": 950000, owned by {}", sender); + client.exp_string(&expected)?; + // Check the escrowed balance + let key_prefix = ibc_account_prefix( + &src_port_channel_id.port_id, + &src_port_channel_id.channel_id, + &token, + ); + let sub_prefix = key_prefix.sub_key().unwrap().to_string(); + let expected = format!( + " with {}: 50000, owned by {}", + sub_prefix, + Address::Internal(InternalAddress::IbcEscrow) + ); + client.exp_string(&expected)?; + client.assert_success(); + + // Check the balance on Chain B + let denom = format!( + "{}/{}/{}", + &dest_port_channel_id.port_id, &dest_port_channel_id.channel_id, &token, + ); + let key_prefix = ibc_token_prefix(&denom)?; + let sub_prefix = key_prefix.sub_key().unwrap().to_string(); + let rpc_b = get_actor_rpc(test_b, &Who::Validator(0)); + let query_args = vec![ + "balance", + "--owner", + BERTHA, + "--token", + XAN, + "--sub-prefix", + &sub_prefix, + "--ledger-address", + &rpc_b, + ]; + let expected = format!("XAN with {}: 50000", sub_prefix); + let mut client = run!(test_b, Bin::Client, query_args, Some(40))?; + client.exp_string(&expected)?; + client.assert_success(); + Ok(()) +} From 8dbd7ca72549dee69960502e1ff13c76cd2aa91c Mon Sep 17 00:00:00 2001 From: yito88 Date: Thu, 4 Aug 2022 18:13:53 +0200 Subject: [PATCH 26/36] add timeout and close tests --- tests/src/e2e/ibc_tests.rs | 254 +++++++++++++++++++++++++++++++++---- 1 file changed, 229 insertions(+), 25 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index f3bf86527c1..41ceb50a66b 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -40,11 +40,15 @@ use namada::ibc::core::ics04_channel::channel::{ State as ChanState, }; use namada::ibc::core::ics04_channel::msgs::acknowledgement::MsgAcknowledgement; +use namada::ibc::core::ics04_channel::msgs::chan_close_confirm::MsgChannelCloseConfirm; +use namada::ibc::core::ics04_channel::msgs::chan_close_init::MsgChannelCloseInit; use namada::ibc::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenAck; use namada::ibc::core::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm; use namada::ibc::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; use namada::ibc::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; use namada::ibc::core::ics04_channel::msgs::recv_packet::MsgRecvPacket; +use namada::ibc::core::ics04_channel::msgs::timeout::MsgTimeout; +use namada::ibc::core::ics04_channel::msgs::timeout_on_close::MsgTimeoutOnClose; use namada::ibc::core::ics04_channel::packet::Packet; use namada::ibc::core::ics04_channel::Version as ChanVersion; use namada::ibc::core::ics23_commitment::commitment::CommitmentProofBytes; @@ -136,7 +140,7 @@ fn run_ledger_ibc() -> Result<()> { )?; check_balances(&port_channel_id_a, &port_channel_id_b, &test_a, &test_b)?; - // transfer back from the normal account + // transfer back from the origin-specific account transfer_back( &test_a, &test_b, @@ -151,7 +155,45 @@ fn run_ledger_ibc() -> Result<()> { &test_b, )?; - // TODO: packet timeout and refund + // transfer a token and it will time out + transfer_timeout(&test_a, &test_b, &client_id_a, &port_channel_id_a)?; + // the balance should not be changed + check_balances_after_back( + &port_channel_id_a, + &port_channel_id_b, + &test_a, + &test_b, + )?; + + // Close the channel on Chain A + close_channel_init(&test_a, &port_channel_id_a)?; + + // Try transfer from Chain B and it will refund with TimeoutOnClose + transfer_timeout_on_close( + &test_a, + &test_b, + &client_id_a, + &client_id_b, + &port_channel_id_a, + &port_channel_id_b, + )?; + // the balance should not be changed + check_balances_after_back( + &port_channel_id_a, + &port_channel_id_b, + &test_a, + &test_b, + )?; + + // Close the channel on Chain B + close_channel_confirm( + &test_a, + &test_b, + &client_id_a, + &client_id_b, + &port_channel_id_a, + &port_channel_id_b, + )?; Ok(()) } @@ -165,7 +207,7 @@ fn create_client(test_a: &Test, test_b: &Test) -> Result<(ClientId, ClientId)> { consensus_state: make_consensus_state(test_b, height)?, signer: Signer::new("test_a"), }; - let height_a = submit_ibc_tx(test_a, message)?; + let height_a = submit_ibc_tx(test_a, message, ALBERT)?; let height = query_height(test_a)?; let client_state = make_client_state(test_a, height); @@ -175,7 +217,7 @@ fn create_client(test_a: &Test, test_b: &Test) -> Result<(ClientId, ClientId)> { consensus_state: make_consensus_state(test_a, height)?, signer: Signer::new("test_b"), }; - let height_b = submit_ibc_tx(test_b, message)?; + let height_b = submit_ibc_tx(test_b, message, ALBERT)?; let client_id_a = match get_event(test_a, height_a)? { Some(IbcEvent::CreateClient(event)) => event.client_id().clone(), @@ -279,7 +321,7 @@ fn update_client( client_id: client_id.clone(), signer: Signer::new("test"), }; - submit_ibc_tx(target_test, message)?; + submit_ibc_tx(target_test, message, ALBERT)?; } let message = MsgUpdateAnyClient { @@ -287,7 +329,7 @@ fn update_client( client_id: client_id.clone(), signer: Signer::new("test"), }; - submit_ibc_tx(target_test, message)?; + submit_ibc_tx(target_test, message, ALBERT)?; Ok(()) } @@ -342,7 +384,7 @@ fn connection_handshake( signer: Signer::new("test_a"), }; // OpenInitConnection on Chain A - let height = submit_ibc_tx(test_a, msg)?; + let height = submit_ibc_tx(test_a, msg, ALBERT)?; let conn_id_a = match get_event(test_a, height)? { Some(IbcEvent::OpenInitConnection(event)) => event .connection_id() @@ -373,7 +415,7 @@ fn connection_handshake( // Update the client state of Chain A on Chain B update_client_with_height(test_a, test_b, client_id_b, height_a)?; // OpenTryConnection on Chain B - let height = submit_ibc_tx(test_b, msg)?; + let height = submit_ibc_tx(test_b, msg, ALBERT)?; let conn_id_b = match get_event(test_b, height)? { Some(IbcEvent::OpenTryConnection(event)) => event .connection_id() @@ -397,7 +439,7 @@ fn connection_handshake( // Update the client state of Chain B on Chain A update_client_with_height(test_b, test_a, client_id_a, height_b)?; // OpenAckConnection on Chain A - submit_ibc_tx(test_a, msg)?; + submit_ibc_tx(test_a, msg, ALBERT)?; // get the proofs on Chain A let height_a = query_height(test_a)?; @@ -411,7 +453,7 @@ fn connection_handshake( // Update the client state of Chain A on Chain B update_client_with_height(test_a, test_b, client_id_b, height_a)?; // OpenConfirmConnection on Chain B - submit_ibc_tx(test_b, msg)?; + submit_ibc_tx(test_b, msg, ALBERT)?; Ok((conn_id_a, conn_id_b)) } @@ -467,7 +509,7 @@ fn channel_handshake( channel, signer: Signer::new("test_a"), }; - let height = submit_ibc_tx(test_a, msg)?; + let height = submit_ibc_tx(test_a, msg, ALBERT)?; let channel_id_a = match get_event(test_a, height)? { Some(IbcEvent::OpenInitChannel(event)) => event @@ -502,7 +544,7 @@ fn channel_handshake( // Update the client state of Chain A on Chain B update_client_with_height(test_a, test_b, client_id_b, height_a)?; // OpenTryChannel on Chain B - let height = submit_ibc_tx(test_b, msg)?; + let height = submit_ibc_tx(test_b, msg, ALBERT)?; let channel_id_b = match get_event(test_b, height)? { Some(IbcEvent::OpenTryChannel(event)) => event .channel_id() @@ -527,7 +569,7 @@ fn channel_handshake( // Update the client state of Chain B on Chain A update_client_with_height(test_b, test_a, client_id_a, height_b)?; // OpenAckChannel on Chain A - submit_ibc_tx(test_a, msg)?; + submit_ibc_tx(test_a, msg, ALBERT)?; // get the proofs on Chain A let height_a = query_height(test_a)?; @@ -542,11 +584,52 @@ fn channel_handshake( // Update the client state of Chain A on Chain B update_client_with_height(test_a, test_b, client_id_b, height_a)?; // OpenConfirmChannel on Chain B - submit_ibc_tx(test_b, msg)?; + submit_ibc_tx(test_b, msg, ALBERT)?; Ok((port_channel_id_a, port_channel_id_b)) } +fn close_channel_init( + test: &Test, + port_channel_id: &PortChannelId, +) -> Result<()> { + let msg = MsgChannelCloseInit { + port_id: port_channel_id.port_id.clone(), + channel_id: port_channel_id.channel_id, + signer: Signer::new("test"), + }; + // CloseInitChannel on Chain A + submit_ibc_tx(test, msg, ALBERT)?; + + Ok(()) +} + +fn close_channel_confirm( + test_a: &Test, + test_b: &Test, + client_id_a: &ClientId, + client_id_b: &ClientId, + port_channel_id_a: &PortChannelId, + port_channel_id_b: &PortChannelId, +) -> Result<()> { + // get the proofs on Chain A + let height_a = query_height(test_a)?; + let proofs = + get_channel_proofs(test_a, client_id_a, port_channel_id_a, height_a)?; + let msg = MsgChannelCloseConfirm { + port_id: port_channel_id_b.port_id.clone(), + channel_id: port_channel_id_b.channel_id, + proofs, + signer: Signer::new("test_b"), + }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // CloseConfirmChannel on Chain B + submit_ibc_tx(test_b, msg, ALBERT)?; + + Ok(()) +} + fn get_channel_proofs( test: &Test, client_id: &ClientId, @@ -628,7 +711,7 @@ fn transfer_token( timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), }; // Send a token from Chain A - let height = submit_ibc_tx(test_a, msg)?; + let height = submit_ibc_tx(test_a, msg, ALBERT)?; let packet = match get_event(test_a, height)? { Some(IbcEvent::SendPacket(event)) => event.packet, _ => return Err(eyre!("Transaction failed")), @@ -644,7 +727,7 @@ fn transfer_token( // Update the client state of Chain A on Chain B update_client_with_height(test_a, test_b, client_id_b, height_a)?; // Receive the token on Chain B - let height = submit_ibc_tx(test_b, msg)?; + let height = submit_ibc_tx(test_b, msg, ALBERT)?; let (acknowledgement, packet) = match get_event(test_b, height)? { Some(IbcEvent::WriteAcknowledgement(event)) => { (event.ack, event.packet) @@ -664,7 +747,7 @@ fn transfer_token( // Update the client state of Chain B on Chain A update_client_with_height(test_b, test_a, client_id_a, height_b)?; // Acknowledge on Chain A - submit_ibc_tx(test_a, msg)?; + submit_ibc_tx(test_a, msg, ALBERT)?; Ok(()) } @@ -682,11 +765,13 @@ fn transfer_back( let receiver = find_address(test_a, ALBERT)?; // Chain A was the source for the sent token + let denom_raw = format!( + "{}/{}/{}", + port_channel_id_b.port_id, port_channel_id_b.channel_id, xan + ); + let token_hash = ibc_token_hash(&denom_raw); let token = Some(Coin { - denom: format!( - "{}/{}/{}", - port_channel_id_b.port_id, port_channel_id_b.channel_id, xan - ), + denom: format!("{}/{}", MULTITOKEN_STORAGE_KEY, token_hash), amount: "50000".to_string(), }); let msg = MsgTransfer { @@ -699,7 +784,7 @@ fn transfer_back( timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), }; // Send a token from Chain B - let height = submit_ibc_tx(test_b, msg)?; + let height = submit_ibc_tx(test_b, msg, BERTHA)?; let packet = match get_event(test_b, height)? { Some(IbcEvent::SendPacket(event)) => event.packet, _ => return Err(eyre!("Transaction failed")), @@ -715,7 +800,7 @@ fn transfer_back( // Update the client state of Chain B on Chain A update_client_with_height(test_b, test_a, client_id_a, height_b)?; // Receive the token on Chain A - let height = submit_ibc_tx(test_a, msg)?; + let height = submit_ibc_tx(test_a, msg, ALBERT)?; let (acknowledgement, packet) = match get_event(test_a, height)? { Some(IbcEvent::WriteAcknowledgement(event)) => { (event.ack, event.packet) @@ -735,7 +820,106 @@ fn transfer_back( // Update the client state of Chain A on Chain B update_client_with_height(test_a, test_b, client_id_b, height_a)?; // Acknowledge on Chain B - submit_ibc_tx(test_b, msg)?; + submit_ibc_tx(test_b, msg, ALBERT)?; + + Ok(()) +} + +fn transfer_timeout( + test_a: &Test, + test_b: &Test, + client_id_a: &ClientId, + source_port_channel_id: &PortChannelId, +) -> Result<()> { + let xan = find_address(test_a, XAN)?; + let sender = find_address(test_a, ALBERT)?; + let receiver = find_address(test_b, BERTHA)?; + + let token = Some(Coin { + denom: xan.to_string(), + amount: "100000".to_string(), + }); + let msg = MsgTransfer { + source_port: source_port_channel_id.port_id.clone(), + source_channel: source_port_channel_id.channel_id, + token, + sender: Signer::new(sender.to_string()), + receiver: Signer::new(receiver.to_string()), + timeout_height: Height::new(0, 1000), + timeout_timestamp: (Timestamp::now() + Duration::new(5, 0)).unwrap(), + }; + // Send a token from Chain A + let height = submit_ibc_tx(test_a, msg, ALBERT)?; + let packet = match get_event(test_a, height)? { + Some(IbcEvent::SendPacket(event)) => event.packet, + _ => return Err(eyre!("Transaction failed")), + }; + + // wait for the timeout + sleep(5); + + let height_b = query_height(test_b)?; + let proofs = get_receipt_absence_proof(test_b, &packet, height_b)?; + let msg = MsgTimeout { + next_sequence_recv: packet.sequence, + packet, + proofs, + signer: Signer::new("test_a"), + }; + // Update the client state of Chain B on Chain A + update_client_with_height(test_b, test_a, client_id_a, height_b)?; + // Timeout on Chain A + submit_ibc_tx(test_a, msg, ALBERT)?; + + Ok(()) +} + +fn transfer_timeout_on_close( + test_a: &Test, + test_b: &Test, + client_id_a: &ClientId, + client_id_b: &ClientId, + port_channel_id_a: &PortChannelId, + port_channel_id_b: &PortChannelId, +) -> Result<()> { + let xan = find_address(test_b, XAN)?; + let sender = find_address(test_b, BERTHA)?; + let receiver = find_address(test_a, ALBERT)?; + + let token = Some(Coin { + denom: xan.to_string(), + amount: "100000".to_string(), + }); + let msg = MsgTransfer { + source_port: port_channel_id_b.port_id.clone(), + source_channel: port_channel_id_b.channel_id, + token, + sender: Signer::new(sender.to_string()), + receiver: Signer::new(receiver.to_string()), + timeout_height: Height::new(0, 1000), + timeout_timestamp: (Timestamp::now() + Duration::new(1000, 0)).unwrap(), + }; + // Send a token from Chain B + let height = submit_ibc_tx(test_b, msg, BERTHA)?; + let packet = match get_event(test_b, height)? { + Some(IbcEvent::SendPacket(event)) => event.packet, + _ => return Err(eyre!("Transaction failed")), + }; + + // get the proof of the channel on Chain A + let height_a = query_height(test_a)?; + let proofs = + get_channel_proofs(test_a, client_id_a, port_channel_id_a, height_a)?; + let msg = MsgTimeoutOnClose { + next_sequence_recv: packet.sequence, + packet, + proofs, + signer: Signer::new("test_b"), + }; + // Update the client state of Chain A on Chain B + update_client_with_height(test_a, test_b, client_id_b, height_a)?; + // TimeoutOnClose on Chain B + submit_ibc_tx(test_b, msg, ALBERT)?; Ok(()) } @@ -778,9 +962,29 @@ fn get_ack_proof( .map_err(|e| eyre!("Creating proofs failed: error {}", e)) } +fn get_receipt_absence_proof( + test: &Test, + packet: &Packet, + target_height: Height, +) -> Result { + // we need proofs at the height of the previous block + let query_height = target_height.decrement().unwrap(); + let key = receipt_key( + &packet.destination_port, + &packet.destination_channel, + packet.sequence, + ); + let (_, tm_proof) = query_value_with_proof(test, &key, query_height)?; + let absence_proof = convert_proof(tm_proof)?; + + Proofs::new(absence_proof, None, None, None, target_height) + .map_err(|e| eyre!("Creating proofs failed: error {}", e)) +} + fn submit_ibc_tx( test: &Test, message: impl Msg + std::fmt::Debug, + signer: &str, ) -> Result { let data_path = test.test_dir.path().join("tx.data"); let data = make_ibc_data(message.clone()); @@ -800,7 +1004,7 @@ fn submit_ibc_tx( "--data-path", &data_path, "--signer", - ALBERT, + signer, "--fee-amount", "0", "--gas-limit", From d24154d89d456d13817c2a3b38d682701ffe60f5 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 5 Aug 2022 12:23:25 +0200 Subject: [PATCH 27/36] add a failure test --- tests/src/e2e/ibc_tests.rs | 56 ++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 41ceb50a66b..306ae10abb1 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -130,7 +130,7 @@ fn run_ledger_ibc() -> Result<()> { &conn_id_b, )?; - // transfer from the normal account + // Transfer from the normal account on Chain A to Chain B transfer_token( &test_a, &test_b, @@ -140,7 +140,7 @@ fn run_ledger_ibc() -> Result<()> { )?; check_balances(&port_channel_id_a, &port_channel_id_b, &test_a, &test_b)?; - // transfer back from the origin-specific account + // Transfer back from the origin-specific account on Chain B to Chain A transfer_back( &test_a, &test_b, @@ -155,9 +155,9 @@ fn run_ledger_ibc() -> Result<()> { &test_b, )?; - // transfer a token and it will time out + // Transfer a token and it will time out and refund transfer_timeout(&test_a, &test_b, &client_id_a, &port_channel_id_a)?; - // the balance should not be changed + // The balance should not be changed check_balances_after_back( &port_channel_id_a, &port_channel_id_b, @@ -177,7 +177,7 @@ fn run_ledger_ibc() -> Result<()> { &port_channel_id_a, &port_channel_id_b, )?; - // the balance should not be changed + // The balance should not be changed check_balances_after_back( &port_channel_id_a, &port_channel_id_b, @@ -195,6 +195,9 @@ fn run_ledger_ibc() -> Result<()> { &port_channel_id_b, )?; + // Check a transfer will fail + try_transfer_on_close(&test_a, &test_b, &port_channel_id_a)?; + Ok(()) } @@ -691,7 +694,7 @@ fn transfer_token( test_b: &Test, client_id_a: &ClientId, client_id_b: &ClientId, - source_port_channel_id: &PortChannelId, + port_channel_id_a: &PortChannelId, ) -> Result<()> { let xan = find_address(test_a, XAN)?; let sender = find_address(test_a, ALBERT)?; @@ -702,8 +705,8 @@ fn transfer_token( amount: "100000".to_string(), }); let msg = MsgTransfer { - source_port: source_port_channel_id.port_id.clone(), - source_channel: source_port_channel_id.channel_id, + source_port: port_channel_id_a.port_id.clone(), + source_channel: port_channel_id_a.channel_id, token, sender: Signer::new(sender.to_string()), receiver: Signer::new(receiver.to_string()), @@ -829,7 +832,7 @@ fn transfer_timeout( test_a: &Test, test_b: &Test, client_id_a: &ClientId, - source_port_channel_id: &PortChannelId, + port_channel_id_a: &PortChannelId, ) -> Result<()> { let xan = find_address(test_a, XAN)?; let sender = find_address(test_a, ALBERT)?; @@ -840,8 +843,8 @@ fn transfer_timeout( amount: "100000".to_string(), }); let msg = MsgTransfer { - source_port: source_port_channel_id.port_id.clone(), - source_channel: source_port_channel_id.channel_id, + source_port: port_channel_id_a.port_id.clone(), + source_channel: port_channel_id_a.channel_id, token, sender: Signer::new(sender.to_string()), receiver: Signer::new(receiver.to_string()), @@ -924,6 +927,37 @@ fn transfer_timeout_on_close( Ok(()) } +fn try_transfer_on_close( + test_a: &Test, + test_b: &Test, + port_channel_id_a: &PortChannelId, +) -> Result<()> { + let xan = find_address(test_a, XAN)?; + let sender = find_address(test_a, ALBERT)?; + let receiver = find_address(test_b, BERTHA)?; + + let token = Some(Coin { + denom: xan.to_string(), + amount: "100000".to_string(), + }); + let msg = MsgTransfer { + source_port: port_channel_id_a.port_id.clone(), + source_channel: port_channel_id_a.channel_id, + token, + sender: Signer::new(sender.to_string()), + receiver: Signer::new(receiver.to_string()), + timeout_height: Height::new(100, 100), + timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), + }; + // Send a token from Chain A + match submit_ibc_tx(test_a, msg, ALBERT) { + Ok(_) => Err(eyre!( + "Sending a token succeeded in spite of closing the channel" + )), + Err(_) => Ok(()), + } +} + fn get_commitment_proof( test: &Test, packet: &Packet, From c1d87de340415f442861cda1769ed33dbf9ea903 Mon Sep 17 00:00:00 2001 From: yito88 Date: Mon, 8 Aug 2022 17:24:13 +0200 Subject: [PATCH 28/36] get receipt absence proof for TimeoutOnClose --- tests/src/e2e/ibc_tests.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 306ae10abb1..80cd5d7efb7 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -909,10 +909,19 @@ fn transfer_timeout_on_close( _ => return Err(eyre!("Transaction failed")), }; - // get the proof of the channel on Chain A + // get the proof for the receipt and the channel on Chain A let height_a = query_height(test_a)?; - let proofs = + let proofs_receipt = get_receipt_absence_proof(test_a, &packet, height_a)?; + let proofs_closed = get_channel_proofs(test_a, client_id_a, port_channel_id_a, height_a)?; + let proofs = Proofs::new( + proofs_receipt.object_proof().clone(), + proofs_closed.client_proof().clone(), + proofs_closed.consensus_proof(), + Some(proofs_closed.object_proof().clone()), + proofs_receipt.height(), + ) + .unwrap(); let msg = MsgTimeoutOnClose { next_sequence_recv: packet.sequence, packet, From cd189f90588f56abc2e56ddf1b84ea5f41e5091d Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 12 Aug 2022 18:01:02 +0200 Subject: [PATCH 29/36] fix for denom decoding --- tests/src/e2e/ibc_tests.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 80cd5d7efb7..66bd34c90ea 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -772,9 +772,10 @@ fn transfer_back( "{}/{}/{}", port_channel_id_b.port_id, port_channel_id_b.channel_id, xan ); - let token_hash = ibc_token_hash(&denom_raw); + let hash = calc_hash(&denom_raw); + let ibc_token = Address::Internal(InternalAddress::IbcToken(hash)); let token = Some(Coin { - denom: format!("{}/{}", MULTITOKEN_STORAGE_KEY, token_hash), + denom: format!("{}/{}", MULTITOKEN_STORAGE_KEY, ibc_token), amount: "50000".to_string(), }); let msg = MsgTransfer { From e8af43ece16a179ff4e3b2a2bcd49e59b196d2a4 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 26 Aug 2022 12:07:16 +0200 Subject: [PATCH 30/36] add a test for non-IBC transfer on the same chain --- tests/src/e2e/ibc_tests.rs | 108 +++++++++++++++++++++++++++++++++++-- 1 file changed, 105 insertions(+), 3 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 66bd34c90ea..ca4f0428282 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -130,7 +130,7 @@ fn run_ledger_ibc() -> Result<()> { &conn_id_b, )?; - // Transfer from the normal account on Chain A to Chain B + // Transfer 100000 from the normal account on Chain A to Chain B transfer_token( &test_a, &test_b, @@ -140,7 +140,12 @@ fn run_ledger_ibc() -> Result<()> { )?; check_balances(&port_channel_id_a, &port_channel_id_b, &test_a, &test_b)?; - // Transfer back from the origin-specific account on Chain B to Chain A + // Transfer 50000 received over IBC on Chain B + transfer_received_token(&port_channel_id_b, &test_b)?; + check_balances_after_non_ibc(&port_channel_id_b, &test_b)?; + + // Transfer 50000 back from the origin-specific account on Chain B to Chain + // A transfer_back( &test_a, &test_b, @@ -755,6 +760,51 @@ fn transfer_token( Ok(()) } +fn transfer_received_token( + port_channel_id: &PortChannelId, + test: &Test, +) -> Result<()> { + let xan = find_address(test, XAN)?; + // token received via the port and channel + let denom = format!( + "{}/{}/{}", + port_channel_id.port_id, port_channel_id.channel_id, xan + ); + let sub_prefix = ibc_token_prefix(denom) + .unwrap() + .sub_key() + .unwrap() + .to_string(); + + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let tx_args = [ + "transfer", + "--source", + BERTHA, + "--target", + ALBERT, + "--token", + XAN, + "--sub-prefix", + &sub_prefix, + "--amount", + "50000", + "--fee-amount", + "0", + "--gas-limit", + "0", + "--fee-token", + XAN, + "--ledger-address", + &rpc, + ]; + let mut client = run!(test, Bin::Client, tx_args, Some(40))?; + client.exp_string("Transaction is valid.")?; + client.assert_success(); + + Ok(()) +} + /// Give the token back after transfer_token fn transfer_back( test_a: &Test, @@ -1256,6 +1306,58 @@ fn check_balances( Ok(()) } +/// Check balances after non IBC transfer +fn check_balances_after_non_ibc( + port_channel_id: &PortChannelId, + test: &Test, +) -> Result<()> { + // Check the balance on Chain B + let token = find_address(test, XAN)?; + let denom = format!( + "{}/{}/{}", + port_channel_id.port_id, port_channel_id.channel_id, token + ); + let key_prefix = ibc_token_prefix(denom)?; + let sub_prefix = key_prefix.sub_key().unwrap().to_string(); + + // Check the source + let rpc = get_actor_rpc(test, &Who::Validator(0)); + let query_args = vec![ + "balance", + "--owner", + BERTHA, + "--token", + XAN, + "--sub-prefix", + &sub_prefix, + "--ledger-address", + &rpc, + ]; + let expected = format!("XAN with {}: 50000", sub_prefix); + let mut client = run!(test, Bin::Client, query_args, Some(40))?; + client.exp_string(&expected)?; + client.assert_success(); + + // Check the traget + let query_args = vec![ + "balance", + "--owner", + ALBERT, + "--token", + XAN, + "--sub-prefix", + &sub_prefix, + "--ledger-address", + &rpc, + ]; + let expected = format!("XAN with {}: 50000", sub_prefix); + let mut client = run!(test, Bin::Client, query_args, Some(40))?; + client.exp_string(&expected)?; + client.assert_success(); + + Ok(()) +} + /// Check balances after IBC transfer back fn check_balances_after_back( src_port_channel_id: &PortChannelId, @@ -1308,7 +1410,7 @@ fn check_balances_after_back( "--ledger-address", &rpc_b, ]; - let expected = format!("XAN with {}: 50000", sub_prefix); + let expected = format!("XAN with {}: 0", sub_prefix); let mut client = run!(test_b, Bin::Client, query_args, Some(40))?; client.exp_string(&expected)?; client.assert_success(); From eeb4597649d95ee5c5809b6af07318d9bab3192a Mon Sep 17 00:00:00 2001 From: yito88 Date: Wed, 21 Sep 2022 15:38:37 +0200 Subject: [PATCH 31/36] fix for ibc integration branch --- tests/src/e2e/ibc_tests.rs | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index ca4f0428282..6a08e2fd346 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -13,6 +13,13 @@ use core::convert::TryFrom; use core::str::FromStr; use core::time::Duration; +use color_eyre::eyre::Result; +use eyre::eyre; +use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo}; +use ibc_relayer::config::{AddressType, ChainConfig, GasPrice, PacketFilter}; +use ibc_relayer::keyring::Store; +use ibc_relayer::light_client::tendermint::LightClient as TmLightClient; +use ibc_relayer::light_client::{LightClient, Verified}; use namada::ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; use namada::ibc::clients::ics07_tendermint::client_state::{ AllowUpdate, ClientState as TmClientState, @@ -75,14 +82,6 @@ use namada::types::key::PublicKey; use namada::types::storage::{BlockHeight, Key}; use namada_apps::client::rpc::query_storage_value_bytes; use namada_apps::client::utils::id_from_pk; -use color_eyre::eyre::Result; -use eyre::eyre; -use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo}; -use ibc_relayer::config::ChainConfig; -use ibc_relayer::config::{AddressType, GasPrice, PacketFilter}; -use ibc_relayer::keyring::Store; -use ibc_relayer::light_client::tendermint::LightClient as TmLightClient; -use ibc_relayer::light_client::{LightClient, Verified}; use setup::constants::*; use tendermint_config::net::Address as TendermintAddress; use tendermint_rpc::{Client, HttpClient, Url}; @@ -104,13 +103,8 @@ fn run_ledger_ibc() -> Result<()> { let mut ledger_b = run_as!(test_b, Who::Validator(0), Bin::Node, &["ledger"], Some(40))?; ledger_b.exp_string("Anoma ledger node started")?; - if !cfg!(feature = "ABCI") { - ledger_a.exp_string("started node")?; - ledger_b.exp_string("started node")?; - } else { - ledger_a.exp_string("Started node")?; - ledger_b.exp_string("Started node")?; - } + ledger_a.exp_string("This node is a validator")?; + ledger_b.exp_string("This node is a validator")?; let _bg_ledger_a = ledger_a.background(); let _bg_ledger_b = ledger_b.background(); @@ -272,7 +266,9 @@ fn make_consensus_state( } fn proof_specs() -> ProofSpecs { - MerkleTree::::default().proof_specs().into() + MerkleTree::::default() + .ibc_proof_specs() + .into() } fn update_client_with_height( @@ -1263,7 +1259,7 @@ fn check_balances( vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; // Check the source balance - let expected = format!(": 900000, owned by {}", sender); + let expected = format!(": 900000, owned by {}", sender); client.exp_string(&expected)?; // Check the escrowed balance let key_prefix = ibc_account_prefix( @@ -1273,7 +1269,7 @@ fn check_balances( ); let sub_prefix = key_prefix.sub_key().unwrap().to_string(); let expected = format!( - " with {}: 100000, owned by {}", + "with {}: 100000, owned by {}", sub_prefix, Address::Internal(InternalAddress::IbcEscrow) ); @@ -1374,7 +1370,7 @@ fn check_balances_after_back( vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; // Check the source balance - let expected = format!(": 950000, owned by {}", sender); + let expected = format!(": 950000, owned by {}", sender); client.exp_string(&expected)?; // Check the escrowed balance let key_prefix = ibc_account_prefix( @@ -1384,7 +1380,7 @@ fn check_balances_after_back( ); let sub_prefix = key_prefix.sub_key().unwrap().to_string(); let expected = format!( - " with {}: 50000, owned by {}", + "with {}: 50000, owned by {}", sub_prefix, Address::Internal(InternalAddress::IbcEscrow) ); From 2452ea23193d1cb1a2c66dbfdf59bfdc36f18e70 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 21 Oct 2022 10:43:21 +0200 Subject: [PATCH 32/36] fix a way to call ibc_proof_specs --- shared/src/ledger/storage/mod.rs | 2 +- tests/src/e2e/helpers.rs | 2 +- tests/src/e2e/ibc_tests.rs | 14 ++++---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/shared/src/ledger/storage/mod.rs b/shared/src/ledger/storage/mod.rs index 16c3ecf1803..2681b1e5e3e 100644 --- a/shared/src/ledger/storage/mod.rs +++ b/shared/src/ledger/storage/mod.rs @@ -1,6 +1,6 @@ //! Ledger's state storage with key-value backed store and a merkle tree -mod ics23_specs; +pub mod ics23_specs; mod merkle_tree; #[cfg(any(test, feature = "testing"))] pub mod mockdb; diff --git a/tests/src/e2e/helpers.rs b/tests/src/e2e/helpers.rs index 363f9bc93c9..faf1697d1a2 100644 --- a/tests/src/e2e/helpers.rs +++ b/tests/src/e2e/helpers.rs @@ -5,7 +5,6 @@ use std::process::Command; use std::str::FromStr; use std::{env, time}; -use namada_apps::config::genesis::genesis_config; use color_eyre::eyre::Result; use color_eyre::owo_colors::OwoColorize; use escargot::CargoBuild; @@ -13,6 +12,7 @@ use eyre::eyre; use namada::types::address::Address; use namada::types::key::*; use namada::types::storage::Epoch; +use namada_apps::config::genesis::genesis_config; use namada_apps::config::{Config, TendermintMode}; use super::setup::{Test, ENV_VAR_DEBUG, ENV_VAR_USE_PREBUILT_BINARIES}; diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 6a08e2fd346..b34b6d08099 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -60,7 +60,6 @@ use namada::ibc::core::ics04_channel::packet::Packet; use namada::ibc::core::ics04_channel::Version as ChanVersion; use namada::ibc::core::ics23_commitment::commitment::CommitmentProofBytes; use namada::ibc::core::ics23_commitment::merkle::convert_tm_to_ics_merkle_proof; -use namada::ibc::core::ics23_commitment::specs::ProofSpecs; use namada::ibc::core::ics24_host::identifier::{ ChainId, ClientId, ConnectionId, PortChannelId, PortId, }; @@ -72,7 +71,8 @@ use namada::ibc::tx_msg::Msg; use namada::ibc_proto::cosmos::base::v1beta1::Coin; use namada::ledger::ibc::handler::{commitment_prefix, port_channel_id}; use namada::ledger::ibc::storage::*; -use namada::ledger::storage::{MerkleTree, Sha256Hasher}; +use namada::ledger::storage::ics23_specs::ibc_proof_specs; +use namada::ledger::storage::Sha256Hasher; use namada::tendermint::block::Header as TmHeader; use namada::tendermint::merkle::proof::Proof as TmProof; use namada::tendermint::trust_threshold::TrustThresholdFraction; @@ -246,7 +246,7 @@ fn make_client_state(test: &Test, height: Height) -> AnyClientState { unbonding_period, max_clock_drift, height, - proof_specs(), + ibc_proof_specs::().into(), vec!["upgrade".to_string(), "upgradedIBCState".to_string()], AllowUpdate { after_expiry: true, @@ -265,12 +265,6 @@ fn make_consensus_state( Ok(TmConsensusState::from(header).wrap_any()) } -fn proof_specs() -> ProofSpecs { - MerkleTree::::default() - .ibc_proof_specs() - .into() -} - fn update_client_with_height( src_test: &Test, target_test: &Test, @@ -362,7 +356,7 @@ fn dummy_chain_config(test: &Test) -> ChainConfig { max_block_time: Duration::new(5, 0), trusting_period: None, memo_prefix: Memo::default(), - proof_specs: proof_specs(), + proof_specs: ibc_proof_specs::().into(), trust_threshold: TrustThresholdFraction::ONE_THIRD, gas_price: GasPrice::new(0.0, "dummy".to_string()), packet_filter: PacketFilter::default(), From 9d28494ef445fae1b129473e559c3278e9840c7e Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 21 Oct 2022 14:35:28 +0200 Subject: [PATCH 33/36] fix for v0.8.1 --- Cargo.lock | 670 ++++++++- Cargo.toml | 2 + tests/Cargo.toml | 10 +- tests/src/e2e/ibc_tests.rs | 102 +- wasm/Cargo.lock | 1827 ++++++++++++++++++++++++- wasm/Cargo.toml | 6 +- wasm_for_tests/wasm_source/Cargo.lock | 1823 +++++++++++++++++++++++- wasm_for_tests/wasm_source/Cargo.toml | 5 + 8 files changed, 4289 insertions(+), 156 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34ab8ab550d..c404e32e923 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -443,6 +443,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.9.3" @@ -468,6 +474,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + [[package]] name = "bech32" version = "0.8.1" @@ -526,6 +538,27 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitcoin" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42b2a9a8e3c7544f5ce2b475f2f56580a3102b37e0ee001558ad4faedcf56cf4" +dependencies = [ + "bech32", + "bitcoin_hashes", + "secp256k1", + "serde 1.0.145", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006cc91e1a1d99819bc5b8214be3555c1f0611b169f527a1fdc54ed1f2b745b0" +dependencies = [ + "serde 1.0.145", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -730,6 +763,12 @@ dependencies = [ "syn", ] +[[package]] +name = "bytecount" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" + [[package]] name = "byteorder" version = "1.4.3" @@ -769,6 +808,37 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" +[[package]] +name = "camino" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +dependencies = [ + "serde 1.0.145", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde 1.0.145", +] + +[[package]] +name = "cargo_metadata" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.14", + "serde 1.0.145", + "serde_json", +] + [[package]] name = "cc" version = "1.0.73" @@ -960,12 +1030,29 @@ dependencies = [ "windows", ] +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "contracts" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d1429e3bd78171c65aa010eabcdf8f863ba3254728dbfb0ad4b1545beac15c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -1060,6 +1147,16 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "crossbeam-channel" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +dependencies = [ + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + [[package]] name = "crossbeam-channel" version = "0.5.6" @@ -1077,10 +1174,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch", + "crossbeam-epoch 0.9.11", "crossbeam-utils 0.8.12", ] +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg 1.1.0", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "lazy_static", + "maybe-uninit", + "memoffset 0.5.6", + "scopeguard", +] + [[package]] name = "crossbeam-epoch" version = "0.9.11" @@ -1090,7 +1202,7 @@ dependencies = [ "autocfg 1.1.0", "cfg-if 1.0.0", "crossbeam-utils 0.8.12", - "memoffset", + "memoffset 0.6.5", "scopeguard", ] @@ -1120,6 +1232,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array 0.14.6", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1140,6 +1264,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.6", + "subtle", +] + [[package]] name = "ct-codecs" version = "1.1.1" @@ -1281,6 +1415,15 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1344,6 +1487,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi 0.3.9", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -1382,6 +1546,18 @@ dependencies = [ "memmap2", ] +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + [[package]] name = "ed25519" version = "1.5.2" @@ -1429,6 +1605,24 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "ff", + "generic-array 0.14.6", + "group", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "encoding_rs" version = "0.8.31" @@ -1479,6 +1673,15 @@ dependencies = [ "syn", ] +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check 0.9.4", +] + [[package]] name = "escargot" version = "0.5.7" @@ -1590,6 +1793,16 @@ dependencies = [ "serde_bytes", ] +[[package]] +name = "ff" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "file-lock" version = "2.1.6" @@ -1845,8 +2058,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", + "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", ] [[package]] @@ -1910,6 +2125,17 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "group-threshold-cryptography" version = "0.1.0" @@ -1973,6 +2199,12 @@ dependencies = [ "tracing 0.1.37", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "hashbrown" version = "0.11.2" @@ -1991,6 +2223,15 @@ dependencies = [ "ahash", ] +[[package]] +name = "hdpath" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dafb09e5d85df264339ad786a147d9de1da13687a3697c52244297e5e7c32d9c" +dependencies = [ + "byteorder", +] + [[package]] name = "hdrhistogram" version = "7.5.2" @@ -2056,7 +2297,17 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" dependencies = [ - "crypto-mac", + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", "digest 0.9.0", ] @@ -2068,7 +2319,7 @@ checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", "generic-array 0.14.6", - "hmac", + "hmac 0.8.1", ] [[package]] @@ -2105,6 +2356,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde 1.0.145", +] + [[package]] name = "hyper" version = "0.10.16" @@ -2312,6 +2579,61 @@ dependencies = [ "prost-types", "serde 1.0.145", "tendermint-proto 0.23.6", + "tonic", +] + +[[package]] +name = "ibc-relayer" +version = "0.14.0" +source = "git+https://github.com/heliaxdev/ibc-rs.git?rev=f4703dfe2c1f25cc431279ab74f10f3e0f6827e2#f4703dfe2c1f25cc431279ab74f10f3e0f6827e2" +dependencies = [ + "anyhow", + "async-stream", + "bech32", + "bitcoin", + "bytes 1.2.1", + "crossbeam-channel 0.5.6", + "dirs-next", + "flex-error", + "futures 0.3.25", + "hdpath", + "hex", + "http", + "humantime", + "humantime-serde", + "ibc 0.14.0 (git+https://github.com/heliaxdev/ibc-rs.git?rev=f4703dfe2c1f25cc431279ab74f10f3e0f6827e2)", + "ibc-proto 0.17.1 (git+https://github.com/heliaxdev/ibc-rs.git?rev=f4703dfe2c1f25cc431279ab74f10f3e0f6827e2)", + "itertools", + "k256", + "moka", + "nanoid", + "num-bigint", + "num-rational", + "prost", + "prost-types", + "regex", + "retry", + "ripemd160", + "semver 1.0.14", + "serde 1.0.145", + "serde_derive", + "serde_json", + "sha2 0.10.6", + "signature", + "subtle-encoding", + "tendermint 0.23.6", + "tendermint-light-client", + "tendermint-light-client-verifier 0.23.6", + "tendermint-proto 0.23.6", + "tendermint-rpc 0.23.6", + "thiserror", + "tiny-bip39", + "tiny-keccak", + "tokio", + "toml", + "tonic", + "tracing 0.1.37", + "uint", ] [[package]] @@ -2454,6 +2776,19 @@ dependencies = [ "serde_json", ] +[[package]] +name = "k256" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "sec1", + "sha2 0.9.9", +] + [[package]] name = "keccak" version = "0.1.2" @@ -2778,6 +3113,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg 1.1.0", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -2894,7 +3238,29 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "975de676448231fcde04b9149d2543077e166b78fc29eae5aa219e7928410da2" dependencies = [ - "uuid", + "uuid 0.8.2", +] + +[[package]] +name = "moka" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "975fa04238144061e7f8df9746b2e9cd93ef85881da5548d842a7c6a4b614415" +dependencies = [ + "crossbeam-channel 0.5.6", + "crossbeam-epoch 0.8.2", + "crossbeam-utils 0.8.12", + "num_cpus", + "once_cell", + "parking_lot 0.12.1", + "quanta", + "scheduled-thread-pool", + "skeptic", + "smallvec 1.10.0", + "tagptr", + "thiserror", + "triomphe", + "uuid 1.2.1", ] [[package]] @@ -3098,6 +3464,9 @@ dependencies = [ "eyre", "file-serve", "fs_extra", + "ibc 0.14.0 (git+https://github.com/heliaxdev/ibc-rs.git?rev=f4703dfe2c1f25cc431279ab74f10f3e0f6827e2)", + "ibc-proto 0.17.1 (git+https://github.com/heliaxdev/ibc-rs.git?rev=f4703dfe2c1f25cc431279ab74f10f3e0f6827e2)", + "ibc-relayer", "itertools", "namada", "namada_apps", @@ -3110,7 +3479,12 @@ dependencies = [ "serde_json", "sha2 0.9.9", "tempfile", + "tendermint 0.23.6", + "tendermint-config 0.23.6", + "tendermint-proto 0.23.6", + "tendermint-rpc 0.23.6", "test-log", + "tokio", "toml", "tracing 0.1.37", "tracing-subscriber 0.3.16", @@ -3148,6 +3522,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "nanoid" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" +dependencies = [ + "rand 0.8.5", +] + [[package]] name = "native-tls" version = "0.2.10" @@ -3187,7 +3570,7 @@ dependencies = [ "cc", "cfg-if 1.0.0", "libc", - "memoffset", + "memoffset 0.6.5", ] [[package]] @@ -3200,7 +3583,7 @@ dependencies = [ "cc", "cfg-if 1.0.0", "libc", - "memoffset", + "memoffset 0.6.5", ] [[package]] @@ -3277,6 +3660,7 @@ dependencies = [ "autocfg 1.1.0", "num-integer", "num-traits 0.2.15", + "serde 1.0.145", ] [[package]] @@ -3330,6 +3714,7 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.15", + "serde 1.0.145", ] [[package]] @@ -3559,6 +3944,15 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +[[package]] +name = "pbkdf2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +dependencies = [ + "crypto-mac 0.8.0", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -3655,6 +4049,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "pkg-config" version = "0.3.25" @@ -3863,6 +4268,17 @@ dependencies = [ "nix 0.21.2", ] +[[package]] +name = "pulldown-cmark" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34f197a544b0c9ab3ae46c359a7ec9cbbb5c7bf97054266fecb7ead794a181d6" +dependencies = [ + "bitflags", + "memchr", + "unicase 2.6.0", +] + [[package]] name = "pwasm-utils" version = "0.18.2" @@ -3874,6 +4290,22 @@ dependencies = [ "parity-wasm", ] +[[package]] +name = "quanta" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e31331286705f455e56cca62e0e717158474ff02b7936c1fa596d983f4ae27" +dependencies = [ + "crossbeam-utils 0.8.12", + "libc", + "mach", + "once_cell", + "raw-cpuid", + "wasi 0.10.0+wasi-snapshot-preview1", + "web-sys", + "winapi 0.3.9", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -4081,6 +4513,15 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "raw-cpuid" +version = "10.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6823ea29436221176fe662da99998ad3b4db2c7f31e7b6f5fe43adccd6320bb" +dependencies = [ + "bitflags", +] + [[package]] name = "rayon" version = "1.5.1" @@ -4099,7 +4540,7 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" dependencies = [ - "crossbeam-channel", + "crossbeam-channel 0.5.6", "crossbeam-deque", "crossbeam-utils 0.8.12", "num_cpus", @@ -4129,6 +4570,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.7", + "redox_syscall 0.2.16", + "thiserror", +] + [[package]] name = "regalloc" version = "0.0.31" @@ -4233,6 +4685,23 @@ dependencies = [ "winreg", ] +[[package]] +name = "retry" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac95c60a949a63fd2822f4964939662d8f2c16c4fa0624fd954bc6e703b9a3f6" + +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac 0.11.0", + "zeroize", +] + [[package]] name = "ring" version = "0.16.20" @@ -4481,6 +4950,15 @@ dependencies = [ "windows-sys 0.36.1", ] +[[package]] +name = "scheduled-thread-pool" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977a7519bff143a44f842fd07e80ad1329295bd71686457f18e496736f4bf9bf" +dependencies = [ + "parking_lot 0.12.1", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -4509,6 +4987,38 @@ version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array 0.14.6", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" +dependencies = [ + "secp256k1-sys", + "serde 1.0.145", +] + +[[package]] +name = "secp256k1-sys" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "152e20a0fd0519390fc43ab404663af8a0b794273d2a91d60ad4a39f13ffe110" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "2.3.1" @@ -4550,6 +5060,15 @@ dependencies = [ "semver-parser 0.10.2", ] +[[package]] +name = "semver" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +dependencies = [ + "serde 1.0.145", +] + [[package]] name = "semver-parser" version = "0.7.0" @@ -4601,6 +5120,16 @@ dependencies = [ "serde 1.0.145", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde 1.0.145", +] + [[package]] name = "serde_derive" version = "1.0.145" @@ -4767,9 +5296,13 @@ dependencies = [ [[package]] name = "signature" -version = "1.6.4" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "digest 0.9.0", + "rand_core 0.6.4", +] [[package]] name = "simple-error" @@ -4777,6 +5310,21 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc47a29ce97772ca5c927f75bac34866b16d64e07f330c3248e2d7226623901b" +[[package]] +name = "skeptic" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8" +dependencies = [ + "bytecount", + "cargo_metadata", + "error-chain", + "glob", + "pulldown-cmark", + "tempfile", + "walkdir", +] + [[package]] name = "slab" version = "0.4.7" @@ -4835,6 +5383,16 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -4924,6 +5482,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "tar" version = "0.4.38" @@ -4994,10 +5558,12 @@ dependencies = [ "ed25519-dalek", "flex-error", "futures 0.3.25", + "k256", "num-traits 0.2.15", "once_cell", "prost", "prost-types", + "ripemd160", "serde 1.0.145", "serde_bytes", "serde_json", @@ -5037,6 +5603,27 @@ dependencies = [ "url 2.3.1", ] +[[package]] +name = "tendermint-light-client" +version = "0.23.6" +source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=87be41b8c9cc2850830f4d8028c1fe1bd9f96284#87be41b8c9cc2850830f4d8028c1fe1bd9f96284" +dependencies = [ + "contracts", + "crossbeam-channel 0.4.4", + "derive_more", + "flex-error", + "futures 0.3.25", + "serde 1.0.145", + "serde_cbor", + "serde_derive", + "static_assertions", + "tendermint 0.23.6", + "tendermint-light-client-verifier 0.23.6", + "tendermint-rpc 0.23.6", + "time 0.3.15", + "tokio", +] + [[package]] name = "tendermint-light-client-verifier" version = "0.23.5" @@ -5125,7 +5712,7 @@ dependencies = [ "tokio", "tracing 0.1.37", "url 2.3.1", - "uuid", + "uuid 0.8.2", "walkdir", ] @@ -5158,7 +5745,7 @@ dependencies = [ "tokio", "tracing 0.1.37", "url 2.3.1", - "uuid", + "uuid 0.8.2", "walkdir", ] @@ -5296,6 +5883,34 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +[[package]] +name = "tiny-bip39" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +dependencies = [ + "anyhow", + "hmac 0.8.1", + "once_cell", + "pbkdf2", + "rand 0.7.3", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tiny_http" version = "0.11.0" @@ -5554,7 +6169,9 @@ dependencies = [ "pin-project", "prost", "prost-derive", + "rustls-native-certs", "tokio", + "tokio-rustls", "tokio-stream", "tokio-util 0.6.10", "tower", @@ -5806,6 +6423,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" +[[package]] +name = "triomphe" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1ee9bd9239c339d714d657fac840c6d2a4f9c45f4f9ec7b0975113458be78db" + [[package]] name = "try-lock" version = "0.2.3" @@ -5849,6 +6472,18 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +[[package]] +name = "uint" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicase" version = "1.4.2" @@ -5955,6 +6590,15 @@ dependencies = [ "getrandom 0.2.7", ] +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +dependencies = [ + "getrandom 0.2.7", +] + [[package]] name = "valuable" version = "0.1.0" @@ -6338,7 +6982,7 @@ dependencies = [ "indexmap", "libc", "loupe", - "memoffset", + "memoffset 0.6.5", "more-asserts", "region", "rkyv", diff --git a/Cargo.toml b/Cargo.toml index 4d635125501..424124b5877 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,11 +40,13 @@ tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-testgen = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} +tendermint-light-client = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-light-client-verifier = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} # patched to a commit on the `eth-bridge-integration` branch of our fork ibc = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} ibc-proto = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} +ibc-relayer = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} # patched to a commit on the `eth-bridge-integration` branch of our fork tower-abci = {git = "https://github.com/heliaxdev/tower-abci.git", rev = "fcc0014d0bda707109901abfa1b2f782d242f082"} diff --git a/tests/Cargo.toml b/tests/Cargo.toml index e586c79e26d..2aa8070a838 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -17,14 +17,18 @@ namada_vp_prelude = {path = "../vp_prelude"} namada_tx_prelude = {path = "../tx_prelude"} chrono = {version = "0.4.22", default-features = false, features = ["clock", "std"]} concat-idents = "1.1.2" +ibc = {version = "0.14.0", default-features = false} +ibc-proto = {version = "0.17.1", default-features = false} +ibc-relayer = {version = "0.14.0", default-features = false} prost = "0.9.0" -ibc-relayer = {git = "https://github.com/heliaxdev/ibc-rs", rev = "9fcc1c8c19db6af50806ffe5b2f6c214adcbfd5d", default-features = false} serde_json = {version = "1.0.65"} sha2 = "0.9.3" test-log = {version = "0.2.7", default-features = false, features = ["trace"]} tempfile = "3.2.0" -tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} -tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs", rev = "95c52476bc37927218374f94ac8e2a19bd35bec9"} +tendermint = "0.23.6" +tendermint-config = "0.23.6" +tendermint-proto = "0.23.6" +tendermint-rpc = {version = "0.23.6", features = ["http-client"]} tokio = {version = "1.8.2", features = ["full"]} tracing = "0.1.30" tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]} diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index b34b6d08099..149eba81e39 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -15,75 +15,73 @@ use core::time::Duration; use color_eyre::eyre::Result; use eyre::eyre; -use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo}; -use ibc_relayer::config::{AddressType, ChainConfig, GasPrice, PacketFilter}; -use ibc_relayer::keyring::Store; -use ibc_relayer::light_client::tendermint::LightClient as TmLightClient; -use ibc_relayer::light_client::{LightClient, Verified}; -use namada::ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; -use namada::ibc::clients::ics07_tendermint::client_state::{ +use ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; +use ibc::clients::ics07_tendermint::client_state::{ AllowUpdate, ClientState as TmClientState, }; -use namada::ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState; -use namada::ibc::core::ics02_client::client_consensus::{ +use ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState; +use ibc::core::ics02_client::client_consensus::{ AnyConsensusState, ConsensusState, }; -use namada::ibc::core::ics02_client::client_state::{ - AnyClientState, ClientState, -}; -use namada::ibc::core::ics02_client::header::Header; -use namada::ibc::core::ics02_client::height::Height; -use namada::ibc::core::ics02_client::msgs::create_client::MsgCreateAnyClient; -use namada::ibc::core::ics02_client::msgs::update_client::MsgUpdateAnyClient; -use namada::ibc::core::ics02_client::trust_threshold::TrustThreshold; -use namada::ibc::core::ics03_connection::connection::Counterparty as ConnCounterparty; -use namada::ibc::core::ics03_connection::msgs::conn_open_ack::MsgConnectionOpenAck; -use namada::ibc::core::ics03_connection::msgs::conn_open_confirm::MsgConnectionOpenConfirm; -use namada::ibc::core::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit; -use namada::ibc::core::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry; -use namada::ibc::core::ics03_connection::version::Version as ConnVersion; -use namada::ibc::core::ics04_channel::channel::{ +use ibc::core::ics02_client::client_state::{AnyClientState, ClientState}; +use ibc::core::ics02_client::header::Header; +use ibc::core::ics02_client::height::Height; +use ibc::core::ics02_client::msgs::create_client::MsgCreateAnyClient; +use ibc::core::ics02_client::msgs::update_client::MsgUpdateAnyClient; +use ibc::core::ics02_client::trust_threshold::TrustThreshold; +use ibc::core::ics03_connection::connection::Counterparty as ConnCounterparty; +use ibc::core::ics03_connection::msgs::conn_open_ack::MsgConnectionOpenAck; +use ibc::core::ics03_connection::msgs::conn_open_confirm::MsgConnectionOpenConfirm; +use ibc::core::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit; +use ibc::core::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry; +use ibc::core::ics03_connection::version::Version as ConnVersion; +use ibc::core::ics04_channel::channel::{ ChannelEnd, Counterparty as ChanCounterparty, Order as ChanOrder, State as ChanState, }; -use namada::ibc::core::ics04_channel::msgs::acknowledgement::MsgAcknowledgement; -use namada::ibc::core::ics04_channel::msgs::chan_close_confirm::MsgChannelCloseConfirm; -use namada::ibc::core::ics04_channel::msgs::chan_close_init::MsgChannelCloseInit; -use namada::ibc::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenAck; -use namada::ibc::core::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm; -use namada::ibc::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; -use namada::ibc::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; -use namada::ibc::core::ics04_channel::msgs::recv_packet::MsgRecvPacket; -use namada::ibc::core::ics04_channel::msgs::timeout::MsgTimeout; -use namada::ibc::core::ics04_channel::msgs::timeout_on_close::MsgTimeoutOnClose; -use namada::ibc::core::ics04_channel::packet::Packet; -use namada::ibc::core::ics04_channel::Version as ChanVersion; -use namada::ibc::core::ics23_commitment::commitment::CommitmentProofBytes; -use namada::ibc::core::ics23_commitment::merkle::convert_tm_to_ics_merkle_proof; -use namada::ibc::core::ics24_host::identifier::{ +use ibc::core::ics04_channel::msgs::acknowledgement::MsgAcknowledgement; +use ibc::core::ics04_channel::msgs::chan_close_confirm::MsgChannelCloseConfirm; +use ibc::core::ics04_channel::msgs::chan_close_init::MsgChannelCloseInit; +use ibc::core::ics04_channel::msgs::chan_open_ack::MsgChannelOpenAck; +use ibc::core::ics04_channel::msgs::chan_open_confirm::MsgChannelOpenConfirm; +use ibc::core::ics04_channel::msgs::chan_open_init::MsgChannelOpenInit; +use ibc::core::ics04_channel::msgs::chan_open_try::MsgChannelOpenTry; +use ibc::core::ics04_channel::msgs::recv_packet::MsgRecvPacket; +use ibc::core::ics04_channel::msgs::timeout::MsgTimeout; +use ibc::core::ics04_channel::msgs::timeout_on_close::MsgTimeoutOnClose; +use ibc::core::ics04_channel::packet::Packet; +use ibc::core::ics04_channel::Version as ChanVersion; +use ibc::core::ics23_commitment::commitment::CommitmentProofBytes; +use ibc::core::ics23_commitment::merkle::convert_tm_to_ics_merkle_proof; +use ibc::core::ics24_host::identifier::{ ChainId, ClientId, ConnectionId, PortChannelId, PortId, }; -use namada::ibc::events::{from_tx_response_event, IbcEvent}; -use namada::ibc::proofs::{ConsensusProof, Proofs}; -use namada::ibc::signer::Signer; -use namada::ibc::timestamp::Timestamp; -use namada::ibc::tx_msg::Msg; -use namada::ibc_proto::cosmos::base::v1beta1::Coin; +use ibc::events::{from_tx_response_event, IbcEvent}; +use ibc::proofs::{ConsensusProof, Proofs}; +use ibc::signer::Signer; +use ibc::timestamp::Timestamp; +use ibc::tx_msg::Msg; +use ibc_proto::cosmos::base::v1beta1::Coin; +use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo}; +use ibc_relayer::config::{AddressType, ChainConfig, GasPrice, PacketFilter}; +use ibc_relayer::keyring::Store; +use ibc_relayer::light_client::tendermint::LightClient as TmLightClient; +use ibc_relayer::light_client::{LightClient, Verified}; use namada::ledger::ibc::handler::{commitment_prefix, port_channel_id}; use namada::ledger::ibc::storage::*; use namada::ledger::storage::ics23_specs::ibc_proof_specs; use namada::ledger::storage::Sha256Hasher; -use namada::tendermint::block::Header as TmHeader; -use namada::tendermint::merkle::proof::Proof as TmProof; -use namada::tendermint::trust_threshold::TrustThresholdFraction; -use namada::tendermint_proto::Protobuf; use namada::types::address::{Address, InternalAddress}; use namada::types::key::PublicKey; use namada::types::storage::{BlockHeight, Key}; use namada_apps::client::rpc::query_storage_value_bytes; use namada_apps::client::utils::id_from_pk; use setup::constants::*; +use tendermint::block::Header as TmHeader; +use tendermint::merkle::proof::Proof as TmProof; +use tendermint::trust_threshold::TrustThresholdFraction; use tendermint_config::net::Address as TendermintAddress; +use tendermint_proto::Protobuf; use tendermint_rpc::{Client, HttpClient, Url}; use tokio::runtime::Runtime; @@ -1244,7 +1242,6 @@ fn check_balances( test_a: &Test, test_b: &Test, ) -> Result<()> { - let sender = find_address(test_a, ALBERT)?; let token = find_address(test_a, XAN)?; // Check the balances on Chain A @@ -1253,7 +1250,7 @@ fn check_balances( vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; // Check the source balance - let expected = format!(": 900000, owned by {}", sender); + let expected = ": 900000, owned by albert".to_string(); client.exp_string(&expected)?; // Check the escrowed balance let key_prefix = ibc_account_prefix( @@ -1355,7 +1352,6 @@ fn check_balances_after_back( test_a: &Test, test_b: &Test, ) -> Result<()> { - let sender = find_address(test_a, ALBERT)?; let token = find_address(test_b, XAN)?; // Check the balances on Chain A @@ -1364,7 +1360,7 @@ fn check_balances_after_back( vec!["balance", "--token", XAN, "--ledger-address", &rpc_a]; let mut client = run!(test_a, Bin::Client, query_args, Some(40))?; // Check the source balance - let expected = format!(": 950000, owned by {}", sender); + let expected = ": 950000, owned by albert".to_string(); client.exp_string(&expected)?; // Check the escrowed balance let key_prefix = ibc_account_prefix( diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index f9030a471a9..18cdaea41dd 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -23,7 +23,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom", + "getrandom 0.2.7", "once_cell", "version_check", ] @@ -146,7 +146,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -161,6 +161,27 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-trait" version = "0.1.58" @@ -172,6 +193,22 @@ dependencies = [ "syn", ] +[[package]] +name = "async-tungstenite" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e00550829ef8e2c4115250d0ee43305649b0fa95f78a32ce5b07da0b73d95c5c" +dependencies = [ + "futures-io", + "futures-util", + "log", + "pin-project-lite", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki-roots", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -193,12 +230,24 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + [[package]] name = "bech32" version = "0.8.1" @@ -220,6 +269,27 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitcoin" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42b2a9a8e3c7544f5ce2b475f2f56580a3102b37e0ee001558ad4faedcf56cf4" +dependencies = [ + "bech32", + "bitcoin_hashes", + "secp256k1", + "serde", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006cc91e1a1d99819bc5b8214be3555c1f0611b169f527a1fdc54ed1f2b745b0" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -333,6 +403,12 @@ dependencies = [ "syn", ] +[[package]] +name = "bytecount" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" + [[package]] name = "byteorder" version = "1.4.3" @@ -345,6 +421,37 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +[[package]] +name = "camino" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.14", + "serde", + "serde_json", +] + [[package]] name = "cc" version = "1.0.73" @@ -400,12 +507,39 @@ dependencies = [ "syn", ] +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "contracts" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d1429e3bd78171c65aa010eabcdf8f863ba3254728dbfb0ad4b1545beac15c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -490,6 +624,16 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "crossbeam-channel" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +dependencies = [ + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + [[package]] name = "crossbeam-channel" version = "0.5.6" @@ -497,7 +641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils", + "crossbeam-utils 0.8.12", ] [[package]] @@ -507,8 +651,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", + "crossbeam-epoch 0.9.11", + "crossbeam-utils 0.8.12", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "lazy_static", + "maybe-uninit", + "memoffset 0.5.6", + "scopeguard", ] [[package]] @@ -519,11 +678,22 @@ checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" dependencies = [ "autocfg", "cfg-if 1.0.0", - "crossbeam-utils", - "memoffset", + "crossbeam-utils 0.8.12", + "memoffset 0.6.5", "scopeguard", ] +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "lazy_static", +] + [[package]] name = "crossbeam-utils" version = "0.8.12" @@ -539,6 +709,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -549,6 +731,35 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "ct-logs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" +dependencies = [ + "sct", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -659,6 +870,15 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid", +] + [[package]] name = "derivative" version = "2.2.0" @@ -701,6 +921,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dynasm" version = "1.2.3" @@ -727,6 +968,18 @@ dependencies = [ "memmap2", ] +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + [[package]] name = "ed25519" version = "1.5.2" @@ -769,6 +1022,24 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "ff", + "generic-array", + "group", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "enum-iterator" version = "0.7.0" @@ -810,6 +1081,15 @@ dependencies = [ "syn", ] +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + [[package]] name = "eyre" version = "0.6.8" @@ -848,6 +1128,16 @@ dependencies = [ "serde_bytes", ] +[[package]] +name = "ff" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -870,6 +1160,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures" version = "0.3.24" @@ -878,6 +1177,7 @@ checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" dependencies = [ "futures-channel", "futures-core", + "futures-executor", "futures-io", "futures-sink", "futures-task", @@ -900,12 +1200,34 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +[[package]] +name = "futures-executor" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +[[package]] +name = "futures-macro" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.24" @@ -924,11 +1246,16 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -941,6 +1268,19 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + [[package]] name = "getrandom" version = "0.2.7" @@ -949,7 +1289,7 @@ checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -969,6 +1309,23 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "gumdrop" version = "0.8.1" @@ -990,23 +1347,82 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.11.2" +name = "h2" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util 0.7.4", + "tracing", +] + +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", ] +[[package]] +name = "hdpath" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dafb09e5d85df264339ad786a147d9de1da13687a3697c52244297e5e7c32d9c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "headers" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" +dependencies = [ + "base64", + "bitflags", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + [[package]] name = "heck" version = "0.3.3" @@ -1031,6 +1447,149 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + +[[package]] +name = "hyper" +version = "0.14.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-proxy" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca815a891b24fdfb243fa3239c86154392b0953ee584aa1a2a1f66d20cbe75cc" +dependencies = [ + "bytes", + "futures", + "headers", + "http", + "hyper", + "hyper-rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "tower-service", + "webpki", +] + +[[package]] +name = "hyper-rustls" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +dependencies = [ + "ct-logs", + "futures-util", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "webpki", + "webpki-roots", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "iana-time-zone" version = "0.1.51" @@ -1093,6 +1652,61 @@ dependencies = [ "prost-types", "serde", "tendermint-proto", + "tonic", +] + +[[package]] +name = "ibc-relayer" +version = "0.14.0" +source = "git+https://github.com/heliaxdev/ibc-rs.git?rev=f4703dfe2c1f25cc431279ab74f10f3e0f6827e2#f4703dfe2c1f25cc431279ab74f10f3e0f6827e2" +dependencies = [ + "anyhow", + "async-stream", + "bech32", + "bitcoin", + "bytes", + "crossbeam-channel 0.5.6", + "dirs-next", + "flex-error", + "futures", + "hdpath", + "hex", + "http", + "humantime", + "humantime-serde", + "ibc", + "ibc-proto", + "itertools", + "k256", + "moka", + "nanoid", + "num-bigint", + "num-rational", + "prost", + "prost-types", + "regex", + "retry", + "ripemd160", + "semver 1.0.14", + "serde", + "serde_derive", + "serde_json", + "sha2 0.10.6", + "signature", + "subtle-encoding", + "tendermint", + "tendermint-light-client", + "tendermint-light-client-verifier", + "tendermint-proto", + "tendermint-rpc", + "thiserror", + "tiny-bip39", + "tiny-keccak", + "tokio", + "toml", + "tonic", + "tracing", + "uint", ] [[package]] @@ -1117,6 +1731,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indenter" version = "0.3.3" @@ -1134,6 +1758,15 @@ dependencies = [ "serde", ] +[[package]] +name = "input_buffer" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" +dependencies = [ + "bytes", +] + [[package]] name = "instant" version = "0.1.12" @@ -1167,6 +1800,19 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k256" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "sec1", + "sha2 0.9.9", +] + [[package]] name = "keccak" version = "0.1.2" @@ -1212,7 +1858,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand", + "rand 0.8.5", "serde", "sha2 0.9.9", ] @@ -1252,6 +1898,16 @@ dependencies = [ "cc", ] +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -1300,6 +1956,12 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + [[package]] name = "memchr" version = "2.5.0" @@ -1315,6 +1977,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -1330,6 +2001,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + [[package]] name = "miniz_oxide" version = "0.5.4" @@ -1339,6 +2016,40 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.36.1", +] + +[[package]] +name = "moka" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "975fa04238144061e7f8df9746b2e9cd93ef85881da5548d842a7c6a4b614415" +dependencies = [ + "crossbeam-channel 0.5.6", + "crossbeam-epoch 0.8.2", + "crossbeam-utils 0.8.12", + "num_cpus", + "once_cell", + "parking_lot", + "quanta", + "scheduled-thread-pool", + "skeptic", + "smallvec", + "tagptr", + "thiserror", + "triomphe", + "uuid 1.2.1", +] + [[package]] name = "more-asserts" version = "0.2.2" @@ -1377,7 +2088,7 @@ dependencies = [ "prost", "prost-types", "pwasm-utils", - "rand", + "rand 0.8.5", "rand_core 0.6.4", "rust_decimal", "serde", @@ -1425,6 +2136,9 @@ dependencies = [ "chrono", "concat-idents", "derivative", + "ibc", + "ibc-proto", + "ibc-relayer", "namada", "namada_tx_prelude", "namada_vp_prelude", @@ -1432,7 +2146,12 @@ dependencies = [ "serde_json", "sha2 0.9.9", "tempfile", + "tendermint", + "tendermint-config", + "tendermint-proto", + "tendermint-rpc", "test-log", + "tokio", "tracing", "tracing-subscriber", ] @@ -1474,7 +2193,7 @@ name = "namada_wasm" version = "0.8.1" dependencies = [ "borsh", - "getrandom", + "getrandom 0.2.7", "namada", "namada_tests", "namada_tx_prelude", @@ -1487,6 +2206,15 @@ dependencies = [ "wee_alloc", ] +[[package]] +name = "nanoid" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" +dependencies = [ + "rand 0.8.5", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -1496,6 +2224,7 @@ dependencies = [ "autocfg", "num-integer", "num-traits", + "serde", ] [[package]] @@ -1519,6 +2248,19 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", + "serde", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -1580,6 +2322,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + [[package]] name = "parity-wasm" version = "0.42.2" @@ -1587,19 +2335,84 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" [[package]] -name = "paste" -version = "1.0.9" +name = "parking_lot" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] [[package]] -name = "pest" -version = "2.4.0" +name = "parking_lot_core" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" +checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" dependencies = [ - "thiserror", - "ucd-trie", + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.42.0", +] + +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + +[[package]] +name = "pbkdf2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +dependencies = [ + "crypto-mac 0.8.0", +] + +[[package]] +name = "peg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166a" +dependencies = [ + "peg-macros", + "peg-runtime", +] + +[[package]] +name = "peg-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c" +dependencies = [ + "peg-runtime", + "proc-macro2", + "quote", +] + +[[package]] +name = "peg-runtime" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pest" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" +dependencies = [ + "thiserror", + "ucd-trie", ] [[package]] @@ -1612,6 +2425,26 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pin-project" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1624,6 +2457,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "ppv-lite86" version = "0.2.16" @@ -1683,8 +2527,8 @@ dependencies = [ "lazy_static", "num-traits", "quick-error 2.0.1", - "rand", - "rand_chacha", + "rand 0.8.5", + "rand_chacha 0.3.1", "rand_xorshift", "regex-syntax", "rusty-fork", @@ -1764,6 +2608,17 @@ dependencies = [ "syn", ] +[[package]] +name = "pulldown-cmark" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "pwasm-utils" version = "0.18.2" @@ -1775,6 +2630,22 @@ dependencies = [ "parity-wasm", ] +[[package]] +name = "quanta" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e31331286705f455e56cca62e0e717158474ff02b7936c1fa596d983f4ae27" +dependencies = [ + "crossbeam-utils 0.8.12", + "libc", + "mach", + "once_cell", + "raw-cpuid", + "wasi 0.10.2+wasi-snapshot-preview1", + "web-sys", + "winapi", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -1796,6 +2667,19 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -1803,10 +2687,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[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.1" @@ -1822,6 +2716,9 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] [[package]] name = "rand_core" @@ -1829,7 +2726,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.7", +] + +[[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]] @@ -1841,6 +2747,15 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "raw-cpuid" +version = "10.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6823ea29436221176fe662da99998ad3b4db2c7f31e7b6f5fe43adccd6320bb" +dependencies = [ + "bitflags", +] + [[package]] name = "rayon" version = "1.5.3" @@ -1859,9 +2774,9 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" dependencies = [ - "crossbeam-channel", + "crossbeam-channel 0.5.6", "crossbeam-deque", - "crossbeam-utils", + "crossbeam-utils 0.8.12", "num_cpus", ] @@ -1874,6 +2789,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.7", + "redox_syscall", + "thiserror", +] + [[package]] name = "regalloc" version = "0.0.31" @@ -1941,6 +2867,38 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "retry" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac95c60a949a63fd2822f4964939662d8f2c16c4fa0624fd954bc6e703b9a3f6" + +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac 0.11.0", + "zeroize", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "ripemd160" version = "0.9.1" @@ -2006,7 +2964,32 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ - "semver", + "semver 0.11.0", +] + +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-native-certs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +dependencies = [ + "openssl-probe", + "rustls", + "schannel", + "security-framework", ] [[package]] @@ -2080,6 +3063,34 @@ dependencies = [ "safe-regex-compiler", ] +[[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 = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys 0.36.1", +] + +[[package]] +name = "scheduled-thread-pool" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977a7519bff143a44f842fd07e80ad1329295bd71686457f18e496736f4bf9bf" +dependencies = [ + "parking_lot", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -2092,12 +3103,77 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "seahash" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" +dependencies = [ + "secp256k1-sys", + "serde", +] + +[[package]] +name = "secp256k1-sys" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "152e20a0fd0519390fc43ab404663af8a0b794273d2a91d60ad4a39f13ffe110" +dependencies = [ + "cc", +] + +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.11.0" @@ -2107,6 +3183,15 @@ dependencies = [ "semver-parser", ] +[[package]] +name = "semver" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +dependencies = [ + "serde", +] + [[package]] name = "semver-parser" version = "0.10.2" @@ -2134,6 +3219,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.145" @@ -2167,6 +3262,30 @@ dependencies = [ "syn", ] +[[package]] +name = "sha-1" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.5", +] + [[package]] name = "sha2" version = "0.9.9" @@ -2213,23 +3332,70 @@ dependencies = [ ] [[package]] -name = "signature" -version = "1.6.4" +name = "signal-hook-registry" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] [[package]] -name = "simple-error" -version = "0.2.3" +name = "signature" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "digest 0.9.0", + "rand_core 0.6.4", +] + +[[package]] +name = "simple-error" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc47a29ce97772ca5c927f75bac34866b16d64e07f330c3248e2d7226623901b" +[[package]] +name = "skeptic" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8" +dependencies = [ + "bytecount", + "cargo_metadata", + "error-chain", + "glob", + "pulldown-cmark", + "tempfile", + "walkdir", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "sp-std" version = "3.0.0" @@ -2247,12 +3413,34 @@ dependencies = [ "sha2 0.9.9", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "subtle" version = "2.4.1" @@ -2297,6 +3485,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "target-lexicon" version = "0.12.4" @@ -2328,10 +3522,12 @@ dependencies = [ "ed25519-dalek", "flex-error", "futures", + "k256", "num-traits", "once_cell", "prost", "prost-types", + "ripemd160", "serde", "serde_bytes", "serde_json", @@ -2345,6 +3541,40 @@ dependencies = [ "zeroize", ] +[[package]] +name = "tendermint-config" +version = "0.23.6" +source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=87be41b8c9cc2850830f4d8028c1fe1bd9f96284#87be41b8c9cc2850830f4d8028c1fe1bd9f96284" +dependencies = [ + "flex-error", + "serde", + "serde_json", + "tendermint", + "toml", + "url", +] + +[[package]] +name = "tendermint-light-client" +version = "0.23.6" +source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=87be41b8c9cc2850830f4d8028c1fe1bd9f96284#87be41b8c9cc2850830f4d8028c1fe1bd9f96284" +dependencies = [ + "contracts", + "crossbeam-channel 0.4.4", + "derive_more", + "flex-error", + "futures", + "serde", + "serde_cbor", + "serde_derive", + "static_assertions", + "tendermint", + "tendermint-light-client-verifier", + "tendermint-rpc", + "time", + "tokio", +] + [[package]] name = "tendermint-light-client-verifier" version = "0.23.6" @@ -2374,6 +3604,39 @@ dependencies = [ "time", ] +[[package]] +name = "tendermint-rpc" +version = "0.23.6" +source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=87be41b8c9cc2850830f4d8028c1fe1bd9f96284#87be41b8c9cc2850830f4d8028c1fe1bd9f96284" +dependencies = [ + "async-trait", + "async-tungstenite", + "bytes", + "flex-error", + "futures", + "getrandom 0.2.7", + "http", + "hyper", + "hyper-proxy", + "hyper-rustls", + "peg", + "pin-project", + "serde", + "serde_bytes", + "serde_json", + "subtle-encoding", + "tendermint", + "tendermint-config", + "tendermint-proto", + "thiserror", + "time", + "tokio", + "tracing", + "url", + "uuid 0.8.2", + "walkdir", +] + [[package]] name = "tendermint-testgen" version = "0.23.6" @@ -2455,6 +3718,140 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +[[package]] +name = "tiny-bip39" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +dependencies = [ + "anyhow", + "hmac 0.8.1", + "once_cell", + "pbkdf2", + "rand 0.7.3", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +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.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.9" @@ -2464,6 +3861,39 @@ dependencies = [ "serde", ] +[[package]] +name = "tonic" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a" +dependencies = [ + "async-stream", + "async-trait", + "base64", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "prost-derive", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "tokio-stream", + "tokio-util 0.6.10", + "tower", + "tower-layer", + "tower-service", + "tracing", + "tracing-futures", +] + [[package]] name = "tonic-build" version = "0.6.2" @@ -2476,6 +3906,38 @@ dependencies = [ "syn", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project", + "pin-project-lite", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util 0.7.4", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -2509,6 +3971,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tracing-subscriber" version = "0.3.16" @@ -2524,12 +3996,43 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "triomphe" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1ee9bd9239c339d714d657fac840c6d2a4f9c45f4f9ec7b0975113458be78db" + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "tungstenite" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "input_buffer", + "log", + "rand 0.8.5", + "sha-1", + "url", + "utf-8", +] + [[package]] name = "tx_template" version = "0.8.1" dependencies = [ "borsh", - "getrandom", + "getrandom 0.2.7", "namada_tests", "namada_tx_prelude", "wee_alloc", @@ -2547,12 +4050,48 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +[[package]] +name = "uint" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + [[package]] name = "unicode-ident" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.10.0" @@ -2571,6 +4110,44 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +dependencies = [ + "getrandom 0.2.7", +] + [[package]] name = "version_check" version = "0.9.4" @@ -2582,7 +4159,7 @@ name = "vp_template" version = "0.8.1" dependencies = [ "borsh", - "getrandom", + "getrandom 0.2.7", "namada_tests", "namada_vp_prelude", "wee_alloc", @@ -2597,6 +4174,39 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +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 = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2880,7 +4490,7 @@ dependencies = [ "indexmap", "libc", "loupe", - "memoffset", + "memoffset 0.6.5", "more-asserts", "region", "rkyv", @@ -2923,6 +4533,35 @@ dependencies = [ "wast", ] +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +dependencies = [ + "webpki", +] + [[package]] name = "wee_alloc" version = "0.4.5" @@ -2977,6 +4616,106 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + [[package]] name = "zeroize" version = "1.5.7" diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index d6f164a445e..9b3f4d54efa 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -15,13 +15,17 @@ borsh-derive-internal = {git = "https://github.com/heliaxdev/borsh-rs.git", rev borsh-schema-derive-internal = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} # patched to a commit on the `eth-bridge-integration` branch of our fork tendermint = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} +tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} +tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-testgen = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} +tendermint-light-client = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-light-client-verifier = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} # patched to a commit on the `eth-bridge-integration` branch of our fork ibc = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} ibc-proto = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} +ibc-relayer = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} [profile.release] # smaller and faster wasm (https://rustwasm.github.io/book/reference/code-size.html#compiling-with-link-time-optimizations-lto) @@ -29,4 +33,4 @@ lto = true # simply terminate on panics, no unwinding panic = "abort" # tell llvm to optimize for size (https://rustwasm.github.io/book/reference/code-size.html#tell-llvm-to-optimize-for-size-instead-of-speed) -opt-level = 'z' \ No newline at end of file +opt-level = 'z' diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index b82f3b3d599..f3b65ed82b3 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -23,7 +23,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom", + "getrandom 0.2.7", "once_cell", "version_check", ] @@ -146,7 +146,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits", - "rand", + "rand 0.8.5", ] [[package]] @@ -161,6 +161,27 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "async-trait" version = "0.1.58" @@ -172,6 +193,22 @@ dependencies = [ "syn", ] +[[package]] +name = "async-tungstenite" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e00550829ef8e2c4115250d0ee43305649b0fa95f78a32ce5b07da0b73d95c5c" +dependencies = [ + "futures-io", + "futures-util", + "log", + "pin-project-lite", + "tokio", + "tokio-rustls", + "tungstenite", + "webpki-roots", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -193,12 +230,24 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64ct" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b645a089122eccb6111b4f81cbc1a49f5900ac4666bb93ac027feaecf15607bf" + [[package]] name = "bech32" version = "0.8.1" @@ -220,6 +269,27 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitcoin" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42b2a9a8e3c7544f5ce2b475f2f56580a3102b37e0ee001558ad4faedcf56cf4" +dependencies = [ + "bech32", + "bitcoin_hashes", + "secp256k1", + "serde", +] + +[[package]] +name = "bitcoin_hashes" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006cc91e1a1d99819bc5b8214be3555c1f0611b169f527a1fdc54ed1f2b745b0" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -333,6 +403,12 @@ dependencies = [ "syn", ] +[[package]] +name = "bytecount" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c676a478f63e9fa2dd5368a42f28bba0d6c560b775f38583c8bbaa7fcd67c9c" + [[package]] name = "byteorder" version = "1.4.3" @@ -345,6 +421,37 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +[[package]] +name = "camino" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ad0e1e3e88dd237a156ab9f571021b8a158caa0ae44b1968a241efb5144c1e" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.14", + "serde", + "serde_json", +] + [[package]] name = "cc" version = "1.0.73" @@ -400,12 +507,39 @@ dependencies = [ "syn", ] +[[package]] +name = "const-oid" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4c78c047431fee22c1a7bb92e00ad095a02a983affe4d8a72e2a2c62c1b94f3" + [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +[[package]] +name = "contracts" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d1429e3bd78171c65aa010eabcdf8f863ba3254728dbfb0ad4b1545beac15c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.3" @@ -490,6 +624,16 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "crossbeam-channel" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +dependencies = [ + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + [[package]] name = "crossbeam-channel" version = "0.5.6" @@ -497,7 +641,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" dependencies = [ "cfg-if 1.0.0", - "crossbeam-utils", + "crossbeam-utils 0.8.12", ] [[package]] @@ -507,8 +651,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch", - "crossbeam-utils", + "crossbeam-epoch 0.9.11", + "crossbeam-utils 0.8.12", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "crossbeam-utils 0.7.2", + "lazy_static", + "maybe-uninit", + "memoffset 0.5.6", + "scopeguard", ] [[package]] @@ -519,11 +678,22 @@ checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348" dependencies = [ "autocfg", "cfg-if 1.0.0", - "crossbeam-utils", - "memoffset", + "crossbeam-utils 0.8.12", + "memoffset 0.6.5", "scopeguard", ] +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "lazy_static", +] + [[package]] name = "crossbeam-utils" version = "0.8.12" @@ -539,6 +709,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c6a1d5fa1de37e071642dfa44ec552ca5b299adb128fab16138e24b548fd21" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -549,6 +731,35 @@ dependencies = [ "typenum", ] +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "ct-logs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" +dependencies = [ + "sct", +] + [[package]] name = "curve25519-dalek" version = "3.2.0" @@ -659,6 +870,15 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" +[[package]] +name = "der" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" +dependencies = [ + "const-oid", +] + [[package]] name = "derivative" version = "2.2.0" @@ -701,6 +921,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dynasm" version = "1.2.3" @@ -727,6 +968,18 @@ dependencies = [ "memmap2", ] +[[package]] +name = "ecdsa" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d69ae62e0ce582d56380743515fefaf1a8c70cec685d9677636d7e30ae9dc9" +dependencies = [ + "der", + "elliptic-curve", + "rfc6979", + "signature", +] + [[package]] name = "ed25519" version = "1.5.2" @@ -769,6 +1022,24 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "elliptic-curve" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b477563c2bfed38a3b7a60964c49e058b2510ad3f12ba3483fd8f62c2306d6" +dependencies = [ + "base16ct", + "crypto-bigint", + "der", + "ff", + "generic-array", + "group", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + [[package]] name = "enum-iterator" version = "0.7.0" @@ -810,6 +1081,15 @@ dependencies = [ "syn", ] +[[package]] +name = "error-chain" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" +dependencies = [ + "version_check", +] + [[package]] name = "eyre" version = "0.6.8" @@ -848,6 +1128,16 @@ dependencies = [ "serde_bytes", ] +[[package]] +name = "ff" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "131655483be284720a17d74ff97592b8e76576dc25563148601df2d7c9080924" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -870,6 +1160,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures" version = "0.3.24" @@ -878,6 +1177,7 @@ checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" dependencies = [ "futures-channel", "futures-core", + "futures-executor", "futures-io", "futures-sink", "futures-task", @@ -900,12 +1200,34 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" +[[package]] +name = "futures-executor" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + [[package]] name = "futures-io" version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" +[[package]] +name = "futures-macro" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.24" @@ -924,11 +1246,16 @@ version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] @@ -941,6 +1268,19 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "js-sys", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + [[package]] name = "getrandom" version = "0.2.7" @@ -949,7 +1289,7 @@ checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", ] [[package]] @@ -969,6 +1309,23 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "group" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5ac374b108929de78460075f3dc439fa66df9d8fc77e8f12caa5165fcf0c89" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "gumdrop" version = "0.8.1" @@ -990,23 +1347,82 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.11.2" +name = "h2" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" dependencies = [ - "ahash", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util 0.7.4", + "tracing", +] + +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ "ahash", ] +[[package]] +name = "hdpath" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dafb09e5d85df264339ad786a147d9de1da13687a3697c52244297e5e7c32d9c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "headers" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" +dependencies = [ + "base64", + "bitflags", + "bytes", + "headers-core", + "http", + "httpdate", + "mime", + "sha1", +] + +[[package]] +name = "headers-core" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" +dependencies = [ + "http", +] + [[package]] name = "heck" version = "0.3.3" @@ -1031,6 +1447,149 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + +[[package]] +name = "hyper" +version = "0.14.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-proxy" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca815a891b24fdfb243fa3239c86154392b0953ee584aa1a2a1f66d20cbe75cc" +dependencies = [ + "bytes", + "futures", + "headers", + "http", + "hyper", + "hyper-rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "tower-service", + "webpki", +] + +[[package]] +name = "hyper-rustls" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +dependencies = [ + "ct-logs", + "futures-util", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "webpki", + "webpki-roots", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + [[package]] name = "iana-time-zone" version = "0.1.51" @@ -1093,6 +1652,61 @@ dependencies = [ "prost-types", "serde", "tendermint-proto", + "tonic", +] + +[[package]] +name = "ibc-relayer" +version = "0.14.0" +source = "git+https://github.com/heliaxdev/ibc-rs.git?rev=f4703dfe2c1f25cc431279ab74f10f3e0f6827e2#f4703dfe2c1f25cc431279ab74f10f3e0f6827e2" +dependencies = [ + "anyhow", + "async-stream", + "bech32", + "bitcoin", + "bytes", + "crossbeam-channel 0.5.6", + "dirs-next", + "flex-error", + "futures", + "hdpath", + "hex", + "http", + "humantime", + "humantime-serde", + "ibc", + "ibc-proto", + "itertools", + "k256", + "moka", + "nanoid", + "num-bigint", + "num-rational", + "prost", + "prost-types", + "regex", + "retry", + "ripemd160", + "semver 1.0.14", + "serde", + "serde_derive", + "serde_json", + "sha2 0.10.6", + "signature", + "subtle-encoding", + "tendermint", + "tendermint-light-client", + "tendermint-light-client-verifier", + "tendermint-proto", + "tendermint-rpc", + "thiserror", + "tiny-bip39", + "tiny-keccak", + "tokio", + "toml", + "tonic", + "tracing", + "uint", ] [[package]] @@ -1117,6 +1731,16 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "indenter" version = "0.3.3" @@ -1134,6 +1758,15 @@ dependencies = [ "serde", ] +[[package]] +name = "input_buffer" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f97967975f448f1a7ddb12b0bc41069d09ed6a1c161a92687e057325db35d413" +dependencies = [ + "bytes", +] + [[package]] name = "instant" version = "0.1.12" @@ -1167,6 +1800,19 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "k256" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19c3a5e0a0b8450278feda242592512e09f61c72e018b8cd5c859482802daf2d" +dependencies = [ + "cfg-if 1.0.0", + "ecdsa", + "elliptic-curve", + "sec1", + "sha2 0.9.9", +] + [[package]] name = "keccak" version = "0.1.2" @@ -1212,7 +1858,7 @@ dependencies = [ "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", - "rand", + "rand 0.8.5", "serde", "sha2 0.9.9", ] @@ -1252,6 +1898,16 @@ dependencies = [ "cc", ] +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -1300,6 +1956,12 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + [[package]] name = "memchr" version = "2.5.0" @@ -1315,6 +1977,15 @@ dependencies = [ "libc", ] +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -1330,6 +2001,12 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + [[package]] name = "miniz_oxide" version = "0.5.4" @@ -1339,6 +2016,40 @@ dependencies = [ "adler", ] +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.36.1", +] + +[[package]] +name = "moka" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "975fa04238144061e7f8df9746b2e9cd93ef85881da5548d842a7c6a4b614415" +dependencies = [ + "crossbeam-channel 0.5.6", + "crossbeam-epoch 0.8.2", + "crossbeam-utils 0.8.12", + "num_cpus", + "once_cell", + "parking_lot", + "quanta", + "scheduled-thread-pool", + "skeptic", + "smallvec", + "tagptr", + "thiserror", + "triomphe", + "uuid 1.2.1", +] + [[package]] name = "more-asserts" version = "0.2.2" @@ -1377,7 +2088,7 @@ dependencies = [ "prost", "prost-types", "pwasm-utils", - "rand", + "rand 0.8.5", "rand_core 0.6.4", "rust_decimal", "serde", @@ -1425,6 +2136,9 @@ dependencies = [ "chrono", "concat-idents", "derivative", + "ibc", + "ibc-proto", + "ibc-relayer", "namada", "namada_tx_prelude", "namada_vp_prelude", @@ -1432,7 +2146,12 @@ dependencies = [ "serde_json", "sha2 0.9.9", "tempfile", + "tendermint", + "tendermint-config", + "tendermint-proto", + "tendermint-rpc", "test-log", + "tokio", "tracing", "tracing-subscriber", ] @@ -1474,13 +2193,22 @@ name = "namada_wasm_for_tests" version = "0.8.1" dependencies = [ "borsh", - "getrandom", + "getrandom 0.2.7", "namada_tests", "namada_tx_prelude", "namada_vp_prelude", "wee_alloc", ] +[[package]] +name = "nanoid" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ffa00dec017b5b1a8b7cf5e2c008bfda1aa7e0697ac1508b491fdf2622fb4d8" +dependencies = [ + "rand 0.8.5", +] + [[package]] name = "num-bigint" version = "0.4.3" @@ -1490,6 +2218,7 @@ dependencies = [ "autocfg", "num-integer", "num-traits", + "serde", ] [[package]] @@ -1513,6 +2242,19 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", + "serde", +] + [[package]] name = "num-traits" version = "0.2.15" @@ -1574,6 +2316,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + [[package]] name = "parity-wasm" version = "0.42.2" @@ -1581,19 +2329,84 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be5e13c266502aadf83426d87d81a0f5d1ef45b8027f5a471c360abfe4bfae92" [[package]] -name = "paste" -version = "1.0.9" +name = "parking_lot" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] [[package]] -name = "pest" -version = "2.4.0" +name = "parking_lot_core" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" +checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" dependencies = [ - "thiserror", - "ucd-trie", + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.42.0", +] + +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + +[[package]] +name = "pbkdf2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" +dependencies = [ + "crypto-mac 0.8.0", +] + +[[package]] +name = "peg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c0b841ea54f523f7aa556956fbd293bcbe06f2e67d2eb732b7278aaf1d166a" +dependencies = [ + "peg-macros", + "peg-runtime", +] + +[[package]] +name = "peg-macros" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aa52829b8decbef693af90202711348ab001456803ba2a98eb4ec8fb70844c" +dependencies = [ + "peg-runtime", + "proc-macro2", + "quote", +] + +[[package]] +name = "peg-runtime" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pest" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc7bc69c062e492337d74d59b120c274fd3d261b6bf6d3207d499b4b379c41a" +dependencies = [ + "thiserror", + "ucd-trie", ] [[package]] @@ -1606,6 +2419,26 @@ dependencies = [ "indexmap", ] +[[package]] +name = "pin-project" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.2.9" @@ -1618,6 +2451,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs8" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" +dependencies = [ + "der", + "spki", + "zeroize", +] + [[package]] name = "ppv-lite86" version = "0.2.16" @@ -1677,8 +2521,8 @@ dependencies = [ "lazy_static", "num-traits", "quick-error 2.0.1", - "rand", - "rand_chacha", + "rand 0.8.5", + "rand_chacha 0.3.1", "rand_xorshift", "regex-syntax", "rusty-fork", @@ -1758,6 +2602,17 @@ dependencies = [ "syn", ] +[[package]] +name = "pulldown-cmark" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "pwasm-utils" version = "0.18.2" @@ -1769,6 +2624,22 @@ dependencies = [ "parity-wasm", ] +[[package]] +name = "quanta" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e31331286705f455e56cca62e0e717158474ff02b7936c1fa596d983f4ae27" +dependencies = [ + "crossbeam-utils 0.8.12", + "libc", + "mach", + "once_cell", + "raw-cpuid", + "wasi 0.10.2+wasi-snapshot-preview1", + "web-sys", + "winapi", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -1790,6 +2661,19 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + [[package]] name = "rand" version = "0.8.5" @@ -1797,10 +2681,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", + "rand_chacha 0.3.1", "rand_core 0.6.4", ] +[[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.1" @@ -1816,6 +2710,9 @@ name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] [[package]] name = "rand_core" @@ -1823,7 +2720,16 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom", + "getrandom 0.2.7", +] + +[[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]] @@ -1835,6 +2741,15 @@ dependencies = [ "rand_core 0.6.4", ] +[[package]] +name = "raw-cpuid" +version = "10.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6823ea29436221176fe662da99998ad3b4db2c7f31e7b6f5fe43adccd6320bb" +dependencies = [ + "bitflags", +] + [[package]] name = "rayon" version = "1.5.3" @@ -1853,9 +2768,9 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" dependencies = [ - "crossbeam-channel", + "crossbeam-channel 0.5.6", "crossbeam-deque", - "crossbeam-utils", + "crossbeam-utils 0.8.12", "num_cpus", ] @@ -1868,6 +2783,17 @@ dependencies = [ "bitflags", ] +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom 0.2.7", + "redox_syscall", + "thiserror", +] + [[package]] name = "regalloc" version = "0.0.31" @@ -1935,6 +2861,38 @@ dependencies = [ "bytecheck", ] +[[package]] +name = "retry" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac95c60a949a63fd2822f4964939662d8f2c16c4fa0624fd954bc6e703b9a3f6" + +[[package]] +name = "rfc6979" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ef608575f6392792f9ecf7890c00086591d29a83910939d430753f7c050525" +dependencies = [ + "crypto-bigint", + "hmac 0.11.0", + "zeroize", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + [[package]] name = "ripemd160" version = "0.9.1" @@ -2000,7 +2958,32 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" dependencies = [ - "semver", + "semver 0.11.0", +] + +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-native-certs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +dependencies = [ + "openssl-probe", + "rustls", + "schannel", + "security-framework", ] [[package]] @@ -2074,6 +3057,34 @@ dependencies = [ "safe-regex-compiler", ] +[[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 = "schannel" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" +dependencies = [ + "lazy_static", + "windows-sys 0.36.1", +] + +[[package]] +name = "scheduled-thread-pool" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977a7519bff143a44f842fd07e80ad1329295bd71686457f18e496736f4bf9bf" +dependencies = [ + "parking_lot", +] + [[package]] name = "scopeguard" version = "1.1.0" @@ -2086,12 +3097,77 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring", + "untrusted", +] + [[package]] name = "seahash" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" +[[package]] +name = "sec1" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08da66b8b0965a5555b6bd6639e68ccba85e1e2506f5fbb089e93f8a04e1a2d1" +dependencies = [ + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" +dependencies = [ + "secp256k1-sys", + "serde", +] + +[[package]] +name = "secp256k1-sys" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "152e20a0fd0519390fc43ab404663af8a0b794273d2a91d60ad4a39f13ffe110" +dependencies = [ + "cc", +] + +[[package]] +name = "security-framework" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bc1bb97804af6631813c55739f771071e0f2ed33ee20b68c86ec505d906356c" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "semver" version = "0.11.0" @@ -2101,6 +3177,15 @@ dependencies = [ "semver-parser", ] +[[package]] +name = "semver" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" +dependencies = [ + "serde", +] + [[package]] name = "semver-parser" version = "0.10.2" @@ -2128,6 +3213,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.145" @@ -2161,6 +3256,30 @@ dependencies = [ "syn", ] +[[package]] +name = "sha-1" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha1" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +dependencies = [ + "cfg-if 1.0.0", + "cpufeatures", + "digest 0.10.5", +] + [[package]] name = "sha2" version = "0.9.9" @@ -2207,23 +3326,70 @@ dependencies = [ ] [[package]] -name = "signature" -version = "1.6.4" +name = "signal-hook-registry" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] [[package]] -name = "simple-error" -version = "0.2.3" +name = "signature" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02658e48d89f2bec991f9a78e69cfa4c316f8d6a6c4ec12fae1aeb263d486788" +dependencies = [ + "digest 0.9.0", + "rand_core 0.6.4", +] + +[[package]] +name = "simple-error" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc47a29ce97772ca5c927f75bac34866b16d64e07f330c3248e2d7226623901b" +[[package]] +name = "skeptic" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8" +dependencies = [ + "bytecount", + "cargo_metadata", + "error-chain", + "glob", + "pulldown-cmark", + "tempfile", + "walkdir", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + [[package]] name = "smallvec" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "sp-std" version = "3.0.0" @@ -2241,12 +3407,34 @@ dependencies = [ "sha2 0.9.9", ] +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" +dependencies = [ + "base64ct", + "der", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "subtle" version = "2.4.1" @@ -2291,6 +3479,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + [[package]] name = "target-lexicon" version = "0.12.4" @@ -2322,10 +3516,12 @@ dependencies = [ "ed25519-dalek", "flex-error", "futures", + "k256", "num-traits", "once_cell", "prost", "prost-types", + "ripemd160", "serde", "serde_bytes", "serde_json", @@ -2339,6 +3535,40 @@ dependencies = [ "zeroize", ] +[[package]] +name = "tendermint-config" +version = "0.23.6" +source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=87be41b8c9cc2850830f4d8028c1fe1bd9f96284#87be41b8c9cc2850830f4d8028c1fe1bd9f96284" +dependencies = [ + "flex-error", + "serde", + "serde_json", + "tendermint", + "toml", + "url", +] + +[[package]] +name = "tendermint-light-client" +version = "0.23.6" +source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=87be41b8c9cc2850830f4d8028c1fe1bd9f96284#87be41b8c9cc2850830f4d8028c1fe1bd9f96284" +dependencies = [ + "contracts", + "crossbeam-channel 0.4.4", + "derive_more", + "flex-error", + "futures", + "serde", + "serde_cbor", + "serde_derive", + "static_assertions", + "tendermint", + "tendermint-light-client-verifier", + "tendermint-rpc", + "time", + "tokio", +] + [[package]] name = "tendermint-light-client-verifier" version = "0.23.6" @@ -2368,6 +3598,39 @@ dependencies = [ "time", ] +[[package]] +name = "tendermint-rpc" +version = "0.23.6" +source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=87be41b8c9cc2850830f4d8028c1fe1bd9f96284#87be41b8c9cc2850830f4d8028c1fe1bd9f96284" +dependencies = [ + "async-trait", + "async-tungstenite", + "bytes", + "flex-error", + "futures", + "getrandom 0.2.7", + "http", + "hyper", + "hyper-proxy", + "hyper-rustls", + "peg", + "pin-project", + "serde", + "serde_bytes", + "serde_json", + "subtle-encoding", + "tendermint", + "tendermint-config", + "tendermint-proto", + "thiserror", + "time", + "tokio", + "tracing", + "url", + "uuid 0.8.2", + "walkdir", +] + [[package]] name = "tendermint-testgen" version = "0.23.6" @@ -2449,6 +3712,140 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" +[[package]] +name = "tiny-bip39" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" +dependencies = [ + "anyhow", + "hmac 0.8.1", + "once_cell", + "pbkdf2", + "rand 0.7.3", + "rustc-hash", + "sha2 0.9.9", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +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.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "winapi", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-rustls" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-stream" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + [[package]] name = "toml" version = "0.5.9" @@ -2458,6 +3855,39 @@ dependencies = [ "serde", ] +[[package]] +name = "tonic" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff08f4649d10a70ffa3522ca559031285d8e421d727ac85c60825761818f5d0a" +dependencies = [ + "async-stream", + "async-trait", + "base64", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "prost-derive", + "rustls-native-certs", + "tokio", + "tokio-rustls", + "tokio-stream", + "tokio-util 0.6.10", + "tower", + "tower-layer", + "tower-service", + "tracing", + "tracing-futures", +] + [[package]] name = "tonic-build" version = "0.6.2" @@ -2470,6 +3900,38 @@ dependencies = [ "syn", ] +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap", + "pin-project", + "pin-project-lite", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util 0.7.4", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -2503,6 +3965,16 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tracing-subscriber" version = "0.3.16" @@ -2518,6 +3990,37 @@ dependencies = [ "tracing-core", ] +[[package]] +name = "triomphe" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1ee9bd9239c339d714d657fac840c6d2a4f9c45f4f9ec7b0975113458be78db" + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "tungstenite" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ada8297e8d70872fa9a551d93250a9f407beb9f37ef86494eb20012a2ff7c24" +dependencies = [ + "base64", + "byteorder", + "bytes", + "http", + "httparse", + "input_buffer", + "log", + "rand 0.8.5", + "sha-1", + "url", + "utf-8", +] + [[package]] name = "typenum" version = "1.15.0" @@ -2530,12 +4033,48 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +[[package]] +name = "uint" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + [[package]] name = "unicode-ident" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.10.0" @@ -2554,6 +4093,44 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +dependencies = [ + "getrandom 0.2.7", +] + [[package]] name = "version_check" version = "0.9.4" @@ -2569,6 +4146,39 @@ dependencies = [ "libc", ] +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +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 = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -2852,7 +4462,7 @@ dependencies = [ "indexmap", "libc", "loupe", - "memoffset", + "memoffset 0.6.5", "more-asserts", "region", "rkyv", @@ -2895,6 +4505,35 @@ dependencies = [ "wast", ] +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" +dependencies = [ + "webpki", +] + [[package]] name = "wee_alloc" version = "0.4.5" @@ -2949,6 +4588,106 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.0", + "windows_i686_gnu 0.42.0", + "windows_i686_msvc 0.42.0", + "windows_x86_64_gnu 0.42.0", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" + [[package]] name = "zeroize" version = "1.5.7" diff --git a/wasm_for_tests/wasm_source/Cargo.toml b/wasm_for_tests/wasm_source/Cargo.toml index 8d9f4f4dc94..98ff1dd5bbe 100644 --- a/wasm_for_tests/wasm_source/Cargo.toml +++ b/wasm_for_tests/wasm_source/Cargo.toml @@ -39,13 +39,18 @@ borsh-derive-internal = {git = "https://github.com/heliaxdev/borsh-rs.git", rev borsh-schema-derive-internal = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"} # patched to a commit on the `eth-bridge-integration` branch of our fork tendermint = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} +tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} +tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-testgen = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} +tendermint-light-client = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} tendermint-light-client-verifier = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "87be41b8c9cc2850830f4d8028c1fe1bd9f96284"} # patched to a commit on the `eth-bridge-integration` branch of our fork ibc = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} ibc-proto = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} +ibc-relayer = {git = "https://github.com/heliaxdev/ibc-rs.git", rev = "f4703dfe2c1f25cc431279ab74f10f3e0f6827e2"} + [dev-dependencies] namada_tests = {path = "../../tests"} From 570cab2d20c867b903efbd76cdcbf9b90f351731 Mon Sep 17 00:00:00 2001 From: yito88 Date: Fri, 21 Oct 2022 16:07:16 +0200 Subject: [PATCH 34/36] rename local variables --- apps/src/lib/client/rpc.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index 4b3ae40afec..bc9f6e75ffd 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -1295,16 +1295,18 @@ pub async fn query_storage_value( where T: BorshDeserialize, { - let (value, _proof) = + let (bytes, _proof) = query_storage_value_bytes(client, key, None, false).await; - match value { - Some(v) => match T::try_from_slice(&v[..]) { - Ok(value) => return Some(value), - Err(err) => eprintln!("Error decoding the value: {}", err), + match bytes { + Some(b) => match T::try_from_slice(&b[..]) { + Ok(value) => Some(value), + Err(err) => { + eprintln!("Error decoding the value: {}", err); + cli::safe_exit(1) + } }, - None => return None, + None => None, } - cli::safe_exit(1) } /// Query a storage value and the proof without decoding. From 55ec24c0a89493e70d7f34c9b1b88404634604ad Mon Sep 17 00:00:00 2001 From: yito88 Date: Tue, 25 Oct 2022 16:35:41 +0200 Subject: [PATCH 35/36] use ibc-transfer cmd --- tests/src/e2e/ibc_tests.rs | 209 +++++++++++++++++++++---------------- 1 file changed, 118 insertions(+), 91 deletions(-) diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 149eba81e39..25222205244 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -15,7 +15,6 @@ use core::time::Duration; use color_eyre::eyre::Result; use eyre::eyre; -use ibc::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer; use ibc::clients::ics07_tendermint::client_state::{ AllowUpdate, ClientState as TmClientState, }; @@ -59,9 +58,7 @@ use ibc::core::ics24_host::identifier::{ use ibc::events::{from_tx_response_event, IbcEvent}; use ibc::proofs::{ConsensusProof, Proofs}; use ibc::signer::Signer; -use ibc::timestamp::Timestamp; use ibc::tx_msg::Msg; -use ibc_proto::cosmos::base::v1beta1::Coin; use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo}; use ibc_relayer::config::{AddressType, ChainConfig, GasPrice, PacketFilter}; use ibc_relayer::keyring::Store; @@ -73,7 +70,8 @@ use namada::ledger::storage::ics23_specs::ibc_proof_specs; use namada::ledger::storage::Sha256Hasher; use namada::types::address::{Address, InternalAddress}; use namada::types::key::PublicKey; -use namada::types::storage::{BlockHeight, Key}; +use namada::types::storage::{BlockHeight, Key, RESERVED_ADDRESS_PREFIX}; +use namada::types::token::Amount; use namada_apps::client::rpc::query_storage_value_bytes; use namada_apps::client::utils::id_from_pk; use setup::constants::*; @@ -86,7 +84,7 @@ use tendermint_rpc::{Client, HttpClient, Url}; use tokio::runtime::Runtime; use crate::e2e::helpers::{find_address, get_actor_rpc, get_validator_pk}; -use crate::e2e::setup::{self, sleep, Bin, Test, Who}; +use crate::e2e::setup::{self, sleep, AnomaCmd, Bin, Test, Who}; use crate::{run, run_as}; #[test] @@ -689,25 +687,18 @@ fn transfer_token( client_id_b: &ClientId, port_channel_id_a: &PortChannelId, ) -> Result<()> { - let xan = find_address(test_a, XAN)?; - let sender = find_address(test_a, ALBERT)?; - let receiver = find_address(test_b, BERTHA)?; - - let token = Some(Coin { - denom: xan.to_string(), - amount: "100000".to_string(), - }); - let msg = MsgTransfer { - source_port: port_channel_id_a.port_id.clone(), - source_channel: port_channel_id_a.channel_id, - token, - sender: Signer::new(sender.to_string()), - receiver: Signer::new(receiver.to_string()), - timeout_height: Height::new(100, 100), - timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), - }; // Send a token from Chain A - let height = submit_ibc_tx(test_a, msg, ALBERT)?; + let receiver = find_address(test_b, BERTHA)?; + let height = transfer( + test_a, + ALBERT, + &receiver, + XAN, + &Amount::from(100000_f64), + port_channel_id_a, + None, + None, + )?; let packet = match get_event(test_a, height)? { Some(IbcEvent::SendPacket(event)) => event.packet, _ => return Err(eyre!("Transaction failed")), @@ -801,8 +792,7 @@ fn transfer_back( client_id_b: &ClientId, port_channel_id_b: &PortChannelId, ) -> Result<()> { - let xan = find_address(test_b, XAN)?; - let sender = find_address(test_b, BERTHA)?; + let xan = find_address(test_b, XAN)?.to_string(); let receiver = find_address(test_a, ALBERT)?; // Chain A was the source for the sent token @@ -812,21 +802,22 @@ fn transfer_back( ); let hash = calc_hash(&denom_raw); let ibc_token = Address::Internal(InternalAddress::IbcToken(hash)); - let token = Some(Coin { - denom: format!("{}/{}", MULTITOKEN_STORAGE_KEY, ibc_token), - amount: "50000".to_string(), - }); - let msg = MsgTransfer { - source_port: port_channel_id_b.port_id.clone(), - source_channel: port_channel_id_b.channel_id, - token, - sender: Signer::new(sender.to_string()), - receiver: Signer::new(receiver.to_string()), - timeout_height: Height::new(100, 100), - timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), - }; + // Need the address prefix for ibc-transfer command + let sub_prefix = format!( + "{}/{}{}", + MULTITOKEN_STORAGE_KEY, RESERVED_ADDRESS_PREFIX, ibc_token + ); // Send a token from Chain B - let height = submit_ibc_tx(test_b, msg, BERTHA)?; + let height = transfer( + test_b, + BERTHA, + &receiver, + XAN, + &Amount::from(50000_f64), + port_channel_id_b, + Some(sub_prefix), + None, + )?; let packet = match get_event(test_b, height)? { Some(IbcEvent::SendPacket(event)) => event.packet, _ => return Err(eyre!("Transaction failed")), @@ -873,25 +864,19 @@ fn transfer_timeout( client_id_a: &ClientId, port_channel_id_a: &PortChannelId, ) -> Result<()> { - let xan = find_address(test_a, XAN)?; - let sender = find_address(test_a, ALBERT)?; let receiver = find_address(test_b, BERTHA)?; - let token = Some(Coin { - denom: xan.to_string(), - amount: "100000".to_string(), - }); - let msg = MsgTransfer { - source_port: port_channel_id_a.port_id.clone(), - source_channel: port_channel_id_a.channel_id, - token, - sender: Signer::new(sender.to_string()), - receiver: Signer::new(receiver.to_string()), - timeout_height: Height::new(0, 1000), - timeout_timestamp: (Timestamp::now() + Duration::new(5, 0)).unwrap(), - }; // Send a token from Chain A - let height = submit_ibc_tx(test_a, msg, ALBERT)?; + let height = transfer( + test_a, + ALBERT, + &receiver, + XAN, + &Amount::from(100000_f64), + port_channel_id_a, + None, + Some(Duration::new(5, 0)), + )?; let packet = match get_event(test_a, height)? { Some(IbcEvent::SendPacket(event)) => event.packet, _ => return Err(eyre!("Transaction failed")), @@ -924,25 +909,19 @@ fn transfer_timeout_on_close( port_channel_id_a: &PortChannelId, port_channel_id_b: &PortChannelId, ) -> Result<()> { - let xan = find_address(test_b, XAN)?; - let sender = find_address(test_b, BERTHA)?; let receiver = find_address(test_a, ALBERT)?; - let token = Some(Coin { - denom: xan.to_string(), - amount: "100000".to_string(), - }); - let msg = MsgTransfer { - source_port: port_channel_id_b.port_id.clone(), - source_channel: port_channel_id_b.channel_id, - token, - sender: Signer::new(sender.to_string()), - receiver: Signer::new(receiver.to_string()), - timeout_height: Height::new(0, 1000), - timeout_timestamp: (Timestamp::now() + Duration::new(1000, 0)).unwrap(), - }; // Send a token from Chain B - let height = submit_ibc_tx(test_b, msg, BERTHA)?; + let height = transfer( + test_b, + BERTHA, + &receiver, + XAN, + &Amount::from(100000_f64), + port_channel_id_b, + None, + None, + )?; let packet = match get_event(test_b, height)? { Some(IbcEvent::SendPacket(event)) => event.packet, _ => return Err(eyre!("Transaction failed")), @@ -980,25 +959,18 @@ fn try_transfer_on_close( test_b: &Test, port_channel_id_a: &PortChannelId, ) -> Result<()> { - let xan = find_address(test_a, XAN)?; - let sender = find_address(test_a, ALBERT)?; let receiver = find_address(test_b, BERTHA)?; - - let token = Some(Coin { - denom: xan.to_string(), - amount: "100000".to_string(), - }); - let msg = MsgTransfer { - source_port: port_channel_id_a.port_id.clone(), - source_channel: port_channel_id_a.channel_id, - token, - sender: Signer::new(sender.to_string()), - receiver: Signer::new(receiver.to_string()), - timeout_height: Height::new(100, 100), - timeout_timestamp: (Timestamp::now() + Duration::new(30, 0)).unwrap(), - }; // Send a token from Chain A - match submit_ibc_tx(test_a, msg, ALBERT) { + match transfer( + test_a, + ALBERT, + &receiver, + XAN, + &Amount::from(100000_f64), + port_channel_id_a, + None, + None, + ) { Ok(_) => Err(eyre!( "Sending a token succeeded in spite of closing the channel" )), @@ -1069,7 +1041,7 @@ fn submit_ibc_tx( signer: &str, ) -> Result { let data_path = test.test_dir.path().join("tx.data"); - let data = make_ibc_data(message.clone()); + let data = make_ibc_data(message); std::fs::write(&data_path, data).expect("writing data failed"); let code_path = wasm_abs_path(TX_IBC_WASM); @@ -1099,6 +1071,62 @@ fn submit_ibc_tx( Some(40) )?; client.exp_string("Transaction applied")?; + check_tx_height(test, &mut client) +} + +#[allow(clippy::too_many_arguments)] +fn transfer( + test: &Test, + sender: impl AsRef, + receiver: &Address, + token: impl AsRef, + amount: &Amount, + port_channel_id: &PortChannelId, + sub_prefix: Option, + timeout_sec: Option, +) -> Result { + let rpc = get_actor_rpc(test, &Who::Validator(0)); + + let receiver = receiver.to_string(); + let amount = amount.to_string(); + let port_id = port_channel_id.port_id.to_string(); + let channel_id = port_channel_id.channel_id.to_string(); + let mut tx_args = vec![ + "ibc-transfer", + "--source", + sender.as_ref(), + "--receiver", + &receiver, + "--signer", + sender.as_ref(), + "--token", + token.as_ref(), + "--amount", + &amount, + "--channel-id", + &channel_id, + "--port-id", + &port_id, + "--ledger-address", + &rpc, + ]; + let sp = sub_prefix.clone().unwrap_or_default(); + if sub_prefix.is_some() { + tx_args.push("--sub-prefix"); + tx_args.push(&sp); + } + let timeout = timeout_sec.unwrap_or_default().as_secs().to_string(); + if timeout_sec.is_some() { + tx_args.push("--timeout-sec-offset"); + tx_args.push(&timeout); + } + + let mut client = run!(test, Bin::Client, tx_args, Some(40))?; + client.exp_string("Transaction applied")?; + check_tx_height(test, &mut client) +} + +fn check_tx_height(test: &Test, client: &mut AnomaCmd) -> Result { let (unread, matched) = client.exp_regex("\"height\": .*,")?; let height_str = matched .trim() @@ -1119,8 +1147,7 @@ fn submit_ibc_tx( .replace(',', ""); if code != "0" { return Err(eyre!( - "The transaction failed: message {:?}, unread {}", - message, + "The IBC transfer transaction failed: unread {}", unread )); } From 6bedc9a86961c23cde6f4c967dc9170a3fc49bf6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 26 Oct 2022 09:14:30 +0000 Subject: [PATCH 36/36] [ci] wasm checksums update --- wasm/checksums.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/wasm/checksums.json b/wasm/checksums.json index 1ccbd3337b6..1b7a96a5d36 100644 --- a/wasm/checksums.json +++ b/wasm/checksums.json @@ -1,18 +1,18 @@ { - "tx_bond.wasm": "tx_bond.f833134dc15fac84ac119cc2a0c3d2c88209b79b63c2f0b15ea33e5b99160b0e.wasm", - "tx_ibc.wasm": "tx_ibc.8507c8ffcbd5a255519334ff577a39fbbb2c8359a3d85fa23618238ee97b9ab6.wasm", - "tx_init_account.wasm": "tx_init_account.013bee129d49eccff3de87abb298d7b46d22c672e62b6b16873d79f710faca92.wasm", - "tx_init_nft.wasm": "tx_init_nft.a83c0e86e820ab9c70e71138c933a932e859ea30eb5dbf6d11ae7cb119661925.wasm", - "tx_init_proposal.wasm": "tx_init_proposal.88a015ccde639325248f72186a7432d243c513986416da231ec15e3184b56142.wasm", - "tx_init_validator.wasm": "tx_init_validator.8f8c4c5069e8ef22f72a48d17bc03b4481e4b0894d988ddd066126cf1b44c40c.wasm", - "tx_mint_nft.wasm": "tx_mint_nft.38cc8e543e1e005be911d072a4221bebf7fcd0c6bbcfd941258399b970b19033.wasm", - "tx_transfer.wasm": "tx_transfer.d250ad6caed9d17f7e9b4e5e2b7c79a5e3d3632295ad867e2fc2fd7df158b744.wasm", - "tx_unbond.wasm": "tx_unbond.d93cec9e697b210c09cbc2989c28939b2d582a4fc549fa45f89f8f281e9115b3.wasm", - "tx_update_vp.wasm": "tx_update_vp.0f94999e28ff58be950529d269b0af6513249e5983f1225c7b3c9f9906249685.wasm", - "tx_vote_proposal.wasm": "tx_vote_proposal.dedc8d4e562b1e872e66137f2998acbbe21d73a50de97ada8c54f2e03f45cde8.wasm", - "tx_withdraw.wasm": "tx_withdraw.26f778dd5fb8f6980a2254eb81638eb9ebe5d9eeb8d981bdc7dc18c9481ac5eb.wasm", - "vp_nft.wasm": "vp_nft.d08b3c11a5261353b033ff23c8cca4e9f0c24cfef1c269690b358a4fd273ae21.wasm", - "vp_testnet_faucet.wasm": "vp_testnet_faucet.aaf916c3a9acfadc0596f5e6a73d3a61da3fce46d9424ef18904137abe8e244b.wasm", - "vp_token.wasm": "vp_token.163b42f81217ede30c6eeb1133204d4a9f6e188e1042a08044a0b023345c76f7.wasm", - "vp_user.wasm": "vp_user.4caacbd3871d568f2d846a02262e4be88f7ca76a75deb6895cb9ba4bfddb2c35.wasm" + "tx_bond.wasm": "tx_bond.ad65c08f6271c49032ce850a08ff4a8d5e70d3e6d975488a3f736e29b8058bbd.wasm", + "tx_ibc.wasm": "tx_ibc.816cdbe97b03a7c5e43dce435bb807a829a789fe30d9e697f82a06e1e8cbdc04.wasm", + "tx_init_account.wasm": "tx_init_account.927c09343efbaa03eda278a8022ca733dfb06882c57af0aded3f45d4adea2028.wasm", + "tx_init_nft.wasm": "tx_init_nft.529740634a1eb071221bf48a2fc26e785a170e9bdfd60ef92bf0427c51a1ee6b.wasm", + "tx_init_proposal.wasm": "tx_init_proposal.8116c64b5c60698d4414748f1231341c0656ce1cf36073ae2e81d6c53b46a39e.wasm", + "tx_init_validator.wasm": "tx_init_validator.83a1e32872254a2f082621f18a567e039afc896d98b7e1fb61c0ceb6c3e82eed.wasm", + "tx_mint_nft.wasm": "tx_mint_nft.bc71196d7cd472a0bd1c506de69b104726a27500e13b99869abd0938946a4cd6.wasm", + "tx_transfer.wasm": "tx_transfer.df032ea20af5b360e8bc061c4ea96db3ebbf271c4bf77967b11ef721fbdd9831.wasm", + "tx_unbond.wasm": "tx_unbond.de8584a9edb22352693a0ba676f59c5a5504b8150f159299982f79f764c1387b.wasm", + "tx_update_vp.wasm": "tx_update_vp.8520fee0dc4b7e1996c3c8eb9dc6ec633311eb6501ad3ae9767fe3277c97ed04.wasm", + "tx_vote_proposal.wasm": "tx_vote_proposal.473fbfcffbd136135a54780770dbb7ae9adeb606b68c0d5c61526dad586f2fa1.wasm", + "tx_withdraw.wasm": "tx_withdraw.21760498f5a2306df71a2e5118e69458bcaea2285126ab37c269d7f1353ea6a5.wasm", + "vp_nft.wasm": "vp_nft.194b5d910ff01eef45d1099c0d86ec094e3fb9c528d8567fc3cb28db9114402c.wasm", + "vp_testnet_faucet.wasm": "vp_testnet_faucet.212b294a5d14d5dbe5548a89ce94063b42219b5c8e00e95755762b0b2b52d31f.wasm", + "vp_token.wasm": "vp_token.9462c685d177e4b74b004a115b33d6abd77847d4de264e533cac74b2b2ea875c.wasm", + "vp_user.wasm": "vp_user.ef037d2d7252b44accaa7212cea703b343f49fbfcd3aa426c1a74fb3b34b7650.wasm" } \ No newline at end of file