Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Tracks ibc-rs changes up to v0.48.1 #144

Merged
merged 11 commits into from
Nov 27, 2023
914 changes: 565 additions & 349 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ base64 = { version = "0.21", default-features = false, features = ["alloc"] }
displaydoc = { version = "0.2", default-features = false }
derive_more = { version = "0.99.17", default-features = false, features = ["from", "into", "display"] }
ed25519 = { version = "2.1.0", default-features = false }
ibc = "0.47.0"
ibc-query = "0.47.0"
ibc = { git = "https://github.com/cosmos/ibc-rs", rev = "dd1b7ad", default-features = false }
ibc-query = { git = "https://github.com/cosmos/ibc-rs", rev = "dd1b7ad", default-features = false }
ibc-proto = { version = "0.38.0", default-features = false }
ics23 = { version = "0.11", default-features = false }
prost = { version = "0.12", default-features = false }
Expand All @@ -25,7 +25,3 @@ tendermint-abci = "0.34"
tendermint-proto = "0.34"
tendermint-rpc = "0.34"
tracing = "0.1.26"

[patch.crates-io]
ibc = { git = "https://github.com/cosmos/ibc-rs" , rev = "527bb14" }
ibc-query = { git = "https://github.com/cosmos/ibc-rs" , rev = "527bb14" }
2 changes: 1 addition & 1 deletion crates/app/src/abci/v0_37/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use basecoin_store::utils::SharedRwExt;
use cosmrs::tx::SignerInfo;
use cosmrs::tx::SignerPublicKey;
use cosmrs::Tx;
use ibc::proto::Any;
use ibc::primitives::proto::Any;
use prost::Message;
use serde_json::Value;
use std::fmt::{Debug, Write};
Expand Down
4 changes: 2 additions & 2 deletions crates/app/src/modules/gov/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use basecoin_store::impls::SharedStore;
use basecoin_store::types::{Height, Path, ProtobufStore, TypedStore};
use basecoin_store::utils::{SharedRw, SharedRwExt};

use ibc::hosts::tendermint::upgrade_proposal::upgrade_client_proposal_handler;
use ibc::hosts::tendermint::upgrade_proposal::UpgradeProposal;
use ibc::cosmos_host::upgrade_proposal::upgrade_client_proposal_handler;
use ibc::cosmos_host::upgrade_proposal::UpgradeProposal;
use ibc_proto::cosmos::gov::v1beta1::query_server::QueryServer;
use ibc_proto::google::protobuf::Any;
use ibc_proto::Protobuf;
Expand Down
34 changes: 19 additions & 15 deletions crates/app/src/modules/ibc/client_contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ use super::impls::{AnyConsensusState, IbcContext};
use basecoin_store::context::Store;
use basecoin_store::types::Height;

use ibc::clients::ics07_tendermint::client_state::ClientState as TmClientState;
use ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState;
use ibc::clients::ics07_tendermint::{CommonContext, ValidationContext as TmValidationContext};
use ibc::core::ics02_client::error::ClientError;
use ibc::core::ics02_client::{ClientExecutionContext, ClientValidationContext};
use ibc::core::ics24_host::identifier::ClientId;
use ibc::core::ics24_host::path::{ClientConsensusStatePath, ClientStatePath, Path};
use ibc::core::timestamp::Timestamp;
use ibc::core::{ContextError, ValidationContext};
use ibc::Height as IbcHeight;
use ibc::clients::tendermint::client_state::ClientState as TmClientState;
use ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusState;
use ibc::clients::tendermint::context::{CommonContext, ValidationContext as TmValidationContext};
use ibc::core::client::context::{ClientExecutionContext, ClientValidationContext};
use ibc::core::client::types::error::ClientError;
use ibc::core::client::types::Height as IbcHeight;
use ibc::core::handler::types::error::ContextError;
use ibc::core::host::types::identifiers::ClientId;
use ibc::core::host::types::path::{ClientConsensusStatePath, ClientStatePath, Path};
use ibc::core::host::ValidationContext;
use ibc::primitives::Timestamp;

use std::fmt::Debug;

Expand Down Expand Up @@ -198,7 +199,10 @@ where
}
})
.map(|consensus_path| {
let height = IbcHeight::new(consensus_path.epoch, consensus_path.height)?;
let height = IbcHeight::new(
consensus_path.revision_number,
consensus_path.revision_height,
)?;
Ok(height)
})
.collect()
Expand All @@ -212,7 +216,7 @@ where
fn next_consensus_state(
&self,
client_id: &ClientId,
height: &ibc::Height,
height: &IbcHeight,
) -> Result<Option<Self::AnyConsensusState>, ContextError> {
let path = format!("clients/{client_id}/consensusStates")
.try_into()
Expand All @@ -221,7 +225,7 @@ where
let keys = self.store.get_keys(&path);
let found_path = keys.into_iter().find_map(|path| {
if let Ok(Path::ClientConsensusState(path)) = Path::try_from(path) {
if height > &ibc::Height::new(path.epoch, path.height).unwrap() {
if height > &IbcHeight::new(path.revision_number, path.revision_height).unwrap() {
return Some(path);
}
}
Expand All @@ -246,7 +250,7 @@ where
fn prev_consensus_state(
&self,
client_id: &ClientId,
height: &ibc::Height,
height: &IbcHeight,
) -> Result<Option<Self::AnyConsensusState>, ContextError> {
let path = format!("clients/{client_id}/consensusStates")
.try_into()
Expand All @@ -255,7 +259,7 @@ where
let keys = self.store.get_keys(&path);
let pos = keys.iter().position(|path| {
if let Ok(Path::ClientConsensusState(path)) = Path::try_from(path.clone()) {
height >= &ibc::Height::new(path.epoch, path.height).unwrap()
height >= &IbcHeight::new(path.revision_number, path.revision_height).unwrap()
} else {
false
}
Expand Down
5 changes: 3 additions & 2 deletions crates/app/src/modules/ibc/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use ibc::core::handler::types::error::ContextError;

pub use crate::types::error::Error as AppError;
use ibc::core::RouterError;

pub type Error = RouterError;
pub type Error = ContextError;

impl From<Error> for AppError {
fn from(e: Error) -> Self {
Expand Down
71 changes: 43 additions & 28 deletions crates/app/src/modules/ibc/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,45 @@ use basecoin_store::{
};
use cosmrs::AccountId;
use derive_more::{From, TryInto};
use ibc::apps::transfer::handler::send_transfer;
use ibc::clients::tendermint::client_state::ClientState as TmClientState;
use ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusState;
use ibc::clients::tendermint::types::ConsensusState as ConsensusStateType;
use ibc::core::client::context::consensus_state::ConsensusState;
use ibc::core::client::types::Height as IbcHeight;
use ibc::core::commitment_types::commitment::{CommitmentPrefix, CommitmentRoot};
use ibc::core::entrypoint::dispatch;
use ibc::core::handler::types::error::ContextError;
use ibc::core::handler::types::events::IbcEvent;
use ibc::core::handler::types::msgs::MsgEnvelope;
use ibc::core::host::types::identifiers::Sequence;
use ibc::core::host::{ExecutionContext, ValidationContext};
use ibc::cosmos_host::IBC_QUERY_PATH;
use ibc::primitives::{Signer, Timestamp};
use ibc::{
applications::transfer::{msgs::transfer::MsgTransfer, send_transfer},
clients::ics07_tendermint::{
client_state::ClientState as TmClientState,
consensus_state::ConsensusState as TmConsensusState,
},
apps::transfer::types::msgs::transfer::MsgTransfer,
core::{
dispatch,
events::IbcEvent,
ics02_client::{consensus_state::ConsensusState, error::ClientError},
ics03_connection::{
connection::{ConnectionEnd, IdentifiedConnectionEnd},
error::ConnectionError,
version::Version as ConnectionVersion,
},
ics04_channel::{
channel::types::{
channel::{ChannelEnd, IdentifiedChannelEnd},
commitment::{AcknowledgementCommitment, PacketCommitment},
error::{ChannelError, PacketError},
packet::{PacketState, Receipt, Sequence},
packet::{PacketState, Receipt},
},
client::types::error::ClientError,
connection::types::{
error::ConnectionError,
version::Version as ConnectionVersion,
{ConnectionEnd, IdentifiedConnectionEnd},
},
ics23_commitment::commitment::{CommitmentPrefix, CommitmentRoot},
ics24_host::{
identifier::{ClientId, ConnectionId},
host::types::{
identifiers::{ClientId, ConnectionId},
path::{
AckPath, ChannelEndPath, ClientConnectionPath, ClientConsensusStatePath,
ClientStatePath, CommitmentPath, ConnectionPath, Path as IbcPath, ReceiptPath,
SeqAckPath, SeqRecvPath, SeqSendPath,
},
},
timestamp::Timestamp,
ContextError, ExecutionContext, MsgEnvelope, ValidationContext,
},
hosts::tendermint::IBC_QUERY_PATH,
Height as IbcHeight, Signer,
};
use ibc_proto::{
google::protobuf::Any,
Expand Down Expand Up @@ -260,7 +264,7 @@ where
}

fn begin_block(&mut self, header: &Header) -> Vec<Event> {
let consensus_state = TmConsensusState::new(
let consensus_state = ConsensusStateType::new(
CommitmentRoot::from_bytes(header.app_hash.as_ref()),
header.time,
header.next_validators_hash,
Expand All @@ -270,7 +274,7 @@ where
.consensus_states
.write()
.expect("lock is poisoined")
.insert(header.height.value(), consensus_state);
.insert(header.height.value(), consensus_state.into());

vec![]
}
Expand Down Expand Up @@ -405,8 +409,11 @@ where
&self,
client_cons_state_path: &ClientConsensusStatePath,
) -> Result<Self::AnyConsensusState, ContextError> {
let height = IbcHeight::new(client_cons_state_path.epoch, client_cons_state_path.height)
.map_err(|_| ClientError::InvalidHeight)?;
let height = IbcHeight::new(
client_cons_state_path.revision_number,
client_cons_state_path.revision_height,
)
.map_err(|_| ClientError::InvalidHeight)?;
let consensus_state = self
.consensus_state_store
.get(Height::Pending, client_cons_state_path)
Expand Down Expand Up @@ -668,7 +675,10 @@ where
}
})
.map(|consensus_path| {
let height = IbcHeight::new(consensus_path.epoch, consensus_path.height)?;
let height = IbcHeight::new(
consensus_path.revision_number,
consensus_path.revision_height,
)?;
let client_state = self
.consensus_state_store
.get(Height::Pending, &consensus_path)
Expand Down Expand Up @@ -704,7 +714,12 @@ where
None
}
})
.map(|consensus_path| Ok(IbcHeight::new(consensus_path.epoch, consensus_path.height)?))
.map(|consensus_path| {
Ok(IbcHeight::new(
consensus_path.revision_number,
consensus_path.revision_height,
)?)
})
.collect::<Result<Vec<_>, _>>()
}

Expand Down
9 changes: 5 additions & 4 deletions crates/app/src/modules/ibc/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ use crate::modules::bank::impls::BankBalanceKeeper;
use crate::modules::ibc::transfer::IbcTransferModule;

use basecoin_store::context::Store;
use ibc::applications::transfer::MODULE_ID_STR as IBC_TRANSFER_MODULE_ID;
use ibc::core::ics24_host::identifier::PortId;
use ibc::core::router::{Module as IbcModule, ModuleId, Router};
use ibc::core::RouterError;
use ibc::apps::transfer::types::MODULE_ID_STR as IBC_TRANSFER_MODULE_ID;
use ibc::core::router::module::Module as IbcModule;
use ibc::core::router::router::Router;
use ibc::core::router::types::error::RouterError;
use ibc::core::{host::types::identifiers::PortId, router::types::module::ModuleId};

use std::{borrow::Borrow, collections::BTreeMap, fmt::Debug};

Expand Down
40 changes: 19 additions & 21 deletions crates/app/src/modules/ibc/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@ use crate::modules::auth::account::ACCOUNT_PREFIX;
use crate::modules::bank::context::BankKeeper;
use crate::modules::bank::util::{Coin, Denom};

use ibc::applications::transfer::context::cosmos_adr028_escrow_address;
use ibc::applications::transfer::context::TokenTransferExecutionContext;
use ibc::applications::transfer::context::TokenTransferValidationContext;
use ibc::applications::transfer::context::{
use ibc::apps::transfer::context::TokenTransferExecutionContext;
use ibc::apps::transfer::context::TokenTransferValidationContext;
use ibc::apps::transfer::module::{
on_acknowledgement_packet_validate, on_chan_open_ack_validate, on_chan_open_confirm_validate,
on_chan_open_init_execute, on_chan_open_init_validate, on_chan_open_try_execute,
on_chan_open_try_validate, on_recv_packet_execute, on_timeout_packet_execute,
on_timeout_packet_validate,
};
use ibc::applications::transfer::error::TokenTransferError;
use ibc::applications::transfer::PrefixedCoin;
use ibc::applications::transfer::VERSION;
use ibc::core::events::IbcEvent;
use ibc::core::ics04_channel::acknowledgement::Acknowledgement;
use ibc::core::ics04_channel::channel::Counterparty;
use ibc::core::ics04_channel::channel::Order;
use ibc::core::ics04_channel::error::ChannelError;
use ibc::core::ics04_channel::error::PacketError;
use ibc::core::ics04_channel::packet::Packet;
use ibc::core::ics04_channel::Version as ChannelVersion;
use ibc::core::ics24_host::identifier::ChannelId;
use ibc::core::ics24_host::identifier::ConnectionId;
use ibc::core::ics24_host::identifier::PortId;
use ibc::core::router::Module as IbcModule;
use ibc::core::router::ModuleExtras;
use ibc::Signer;
use ibc::apps::transfer::types::error::TokenTransferError;
use ibc::apps::transfer::types::{PrefixedCoin, VERSION};
use ibc::core::channel::types::acknowledgement::Acknowledgement;
use ibc::core::channel::types::channel::{Counterparty, Order};
use ibc::core::channel::types::error::ChannelError;
use ibc::core::channel::types::error::PacketError;
use ibc::core::channel::types::packet::Packet;
use ibc::core::channel::types::Version as ChannelVersion;
use ibc::core::handler::types::events::IbcEvent;
use ibc::core::host::types::identifiers::ChannelId;
use ibc::core::host::types::identifiers::ConnectionId;
use ibc::core::host::types::identifiers::PortId;
use ibc::core::router::module::Module as IbcModule;
use ibc::core::router::types::module::ModuleExtras;
use ibc::cosmos_host::utils::cosmos_adr028_escrow_address;
use ibc::primitives::Signer;

use core::fmt::Debug;
use cosmrs::AccountId;
Expand Down
26 changes: 13 additions & 13 deletions crates/app/src/modules/upgrade/impls.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use ibc::core::client::types::error::UpgradeClientError;
use ibc::core::commitment_types::commitment::CommitmentRoot;
use ibc::core::host::types::path::UpgradeClientPath;
use ibc::cosmos_host::SDK_UPGRADE_QUERY_PATH;
use prost::Message;
use std::fmt::Debug;
use tracing::debug;
Expand All @@ -12,16 +16,12 @@ use cosmrs::AccountId;
use ibc_proto::cosmos::upgrade::v1beta1::query_server::QueryServer;
use ibc_proto::google::protobuf::Any;

use ibc::clients::ics07_tendermint::{
client_state::ClientState as TmClientState, consensus_state::ConsensusState as TmConsensusState,
};
use ibc::core::ics02_client::error::UpgradeClientError;
use ibc::core::ics23_commitment::commitment::CommitmentRoot;
use ibc::core::ics24_host::path::UpgradeClientPath;
use ibc::hosts::tendermint::upgrade_proposal::UpgradeExecutionContext;
use ibc::hosts::tendermint::upgrade_proposal::UpgradeValidationContext;
use ibc::hosts::tendermint::upgrade_proposal::{Plan, UpgradeChain};
use ibc::hosts::tendermint::SDK_UPGRADE_QUERY_PATH;
use ibc::clients::tendermint::client_state::ClientState as TmClientState;
use ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusState;
use ibc::clients::tendermint::types::ConsensusState as ConsensusStateType;
use ibc::cosmos_host::upgrade_proposal::UpgradeExecutionContext;
use ibc::cosmos_host::upgrade_proposal::UpgradeValidationContext;
use ibc::cosmos_host::upgrade_proposal::{Plan, UpgradeChain};
use tendermint::abci::Event;

use tendermint::merkle::proof::ProofOp;
Expand Down Expand Up @@ -159,7 +159,7 @@ where
// so that IBC clients can use the last NextValidatorsHash as a trusted kernel for verifying
// headers on the next version of the chain.
if host_height == plan.height.checked_sub(1).unwrap() {
let upgraded_consensus_state = TmConsensusState {
let upgraded_consensus_state = ConsensusStateType {
timestamp: header.time,
root: CommitmentRoot::from(vec![]),
next_validators_hash: header.next_validators_hash,
Expand All @@ -170,7 +170,7 @@ where

self.store_upgraded_consensus_state(
upgraded_cons_state_path,
upgraded_consensus_state.into(),
TmConsensusState::from(upgraded_consensus_state).into(),
)
.unwrap();

Expand Down Expand Up @@ -326,7 +326,7 @@ where
fn store_upgraded_consensus_state(
&mut self,
upgrade_path: UpgradeClientPath,
consensus_state: Self::AnyConsensusState,
consensus_state: AnyConsensusState,
) -> Result<(), UpgradeClientError> {
let tm_consensus_state: TmConsensusState =
consensus_state
Expand Down
2 changes: 1 addition & 1 deletion crates/app/src/modules/upgrade/query.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ibc::hosts::tendermint::upgrade_proposal::Plan;
use ibc::cosmos_host::upgrade_proposal::Plan;
use ibc_proto::cosmos::upgrade::v1beta1::Plan as RawPlan;
use ibc_proto::Protobuf;
use tendermint_rpc::{Client, HttpClient};
Expand Down
4 changes: 2 additions & 2 deletions crates/app/src/modules/upgrade/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use basecoin_store::types::Height;
use basecoin_store::types::ProtobufStore;
use basecoin_store::types::TypedStore;

use ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState;
use ibc::core::ics24_host::path::UpgradeClientPath;
use ibc::clients::tendermint::types::ConsensusState as TmConsensusState;
use ibc::core::host::types::path::UpgradeClientPath;

use ibc_proto::cosmos::upgrade::v1beta1::query_server::Query as UpgradeQuery;
use ibc_proto::cosmos::upgrade::v1beta1::QueryAppliedPlanRequest;
Expand Down
Loading