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

Handler for channel open init #452

Merged
merged 35 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
79caad1
handler for channel open init
cezarad Dec 17, 2020
b177fe5
formated
cezarad Dec 17, 2020
3cd7b8f
Update modules/src/ics04_channel/handler/chan_open_init.rs
cezarad Dec 21, 2020
d2e1dff
Update modules/src/ics04_channel/handler/chan_open_init.rs
cezarad Dec 21, 2020
4beb025
Update modules/src/ics04_channel/context.rs
cezarad Dec 21, 2020
0a7aa38
chan open init Romains comments
cezarad Dec 21, 2020
af514ec
added port verification
cezarad Jan 7, 2021
5a62fd5
Merge branch 'master' into Cezara
cezarad Jan 7, 2021
1054aee
chan open init
cezarad Jan 7, 2021
d899101
chan open init
cezarad Jan 7, 2021
08b54fb
minor fmt
cezarad Jan 8, 2021
0f5f16d
chan open init
cezarad Jan 8, 2021
17fe71f
Update modules/src/ics04_channel/channel.rs
cezarad Jan 12, 2021
791f5a1
Update modules/src/ics04_channel/channel.rs
cezarad Jan 12, 2021
bffcb1a
Update modules/src/ics04_channel/context.rs
cezarad Jan 12, 2021
8580c2c
Update modules/src/ics04_channel/context.rs
cezarad Jan 12, 2021
b2f8105
Update error.rs
cezarad Jan 12, 2021
f57b658
Update modules/src/ics04_channel/error.rs
cezarad Jan 12, 2021
e0afeb1
Update modules/src/ics04_channel/channel.rs
cezarad Jan 14, 2021
823eb49
Update modules/src/ics04_channel/context.rs
cezarad Jan 14, 2021
0f37d37
Update context.rs
cezarad Jan 14, 2021
3e40a36
minor
cezarad Jan 14, 2021
cbcaa41
minor
cezarad Jan 14, 2021
e4876e1
test for port
cezarad Jan 14, 2021
2448106
connetion features
cezarad Jan 15, 2021
24a3ae8
connetion features
cezarad Jan 15, 2021
839f675
connetion features
cezarad Jan 15, 2021
a9611fa
review comments
cezarad Jan 15, 2021
ea84402
Merge branch 'master' into Cezara
cezarad Jan 15, 2021
053f0e0
Small refactor to improve readability
romac Jan 15, 2021
1426985
Cleanup ics05_port::capabilities
romac Jan 15, 2021
2d7bc35
Replace panic! with unwrap and avoid some clones in mock context
romac Jan 15, 2021
107236e
Avoid clones in MockContext::add_port
romac Jan 15, 2021
768dfd6
Only clone the channel id
romac Jan 15, 2021
05017f5
Fix a couple comments
romac Jan 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chan open init Romains comments
  • Loading branch information
cezarad committed Dec 21, 2020
commit 0a7aa38394c65a26f75db88384ffeb8da9e478f1
18 changes: 1 addition & 17 deletions modules/src/ics03_connection/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use ibc_proto::ibc::core::connection::v1::{
use tendermint_proto::Protobuf;

use crate::ics03_connection::error::{Error, Kind};
//use crate::ics03_connection::version::default_version_string;
use crate::ics03_connection::version::validate_versions;
use crate::ics03_connection::version::default_version_string;
use crate::ics23_commitment::commitment::CommitmentPrefix;
use crate::ics24_host::error::ValidationError;
use crate::ics24_host::identifier::{ClientId, ConnectionId};
Expand Down Expand Up @@ -52,7 +52,6 @@ impl From<ConnectionEnd> for RawConnectionEnd {
}
}


impl ConnectionEnd {
pub fn new(
state: State,
Expand All @@ -68,21 +67,6 @@ impl ConnectionEnd {
})
}

pub fn test_channel_new(
client_id: ClientId,
counterparty: Counterparty,
) -> Result<Self, Error> {

ConnectionEnd::new(
State::Init,
client_id,
counterparty,
vec![default_version_string()],
)
}



/// Getter for the state of this connection end.
pub fn state(&self) -> &State {
&self.state
Expand Down
18 changes: 17 additions & 1 deletion modules/src/ics03_connection/msgs/conn_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,13 @@ impl From<MsgConnectionOpenInit> for RawMsgConnectionOpenInit {
pub mod test_util {
use ibc_proto::ibc::core::connection::v1::MsgConnectionOpenInit as RawMsgConnectionOpenInit;

use crate::ics03_connection::msgs::test_util::get_dummy_counterparty;
use crate::ics03_connection::connection::{ConnectionEnd, Counterparty, State};
use crate::ics03_connection::error::Error;
use crate::ics03_connection::version::default_version_string;
use crate::test_utils::get_dummy_bech32_account;
use crate::{
ics03_connection::msgs::test_util::get_dummy_counterparty, ics24_host::identifier::ClientId,
};

/// Returns a dummy message, for testing only.
/// Other unit tests may import this if they depend on a MsgConnectionOpenInit.
Expand All @@ -129,6 +133,18 @@ pub mod test_util {
signer: get_dummy_bech32_account(),
}
}

pub fn make_default_connection_end_for_client(
client_id: ClientId,
counterparty: Counterparty,
) -> Result<ConnectionEnd, Error> {
return ConnectionEnd::new(
State::Init,
client_id,
counterparty,
vec![default_version_string()],
);
}
}

#[cfg(test)]
Expand Down
4 changes: 0 additions & 4 deletions modules/src/ics04_channel/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ pub mod test_util {

use ibc_proto::ibc::core::channel::v1::Channel as RawChannel;
use ibc_proto::ibc::core::channel::v1::Counterparty as RawCounterparty;
// use crate::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit;
// use
//crate::ics03_connection::msgs::conn_open_init::test_util::get_dummy_msg_conn_open_init;

/// Returns a dummy `RawCounterparty`, for testing only!
pub fn get_dummy_raw_counterparty() -> RawCounterparty {
Expand Down Expand Up @@ -316,7 +313,6 @@ pub mod test_util {
}
}
}
//MsgConnectionOpenInit::try_from(get_dummy_msg_conn_open_init()).unwrap().connection_id()

#[cfg(test)]
mod tests {
Expand Down
3 changes: 0 additions & 3 deletions modules/src/ics04_channel/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
//! the interface that any host chain must implement to be able to process any `ChannelMsg`.
//! TODO make "ADR 004: IBC protocol implementation" for more details.
//!
//use crate::ics02_client::client_def::{AnyClientState, AnyConsensusState};
use crate::ics03_connection::connection::ConnectionEnd;
use crate::ics04_channel::channel::{ChannelEnd, State};
use crate::ics04_channel::error::Error;
use crate::ics04_channel::handler::ChannelResult;
use crate::ics04_channel::version::{get_compatible_versions, pick_version};
//use crate::ics23_commitment::commitment::CommitmentPrefix;
use crate::ics24_host::identifier::{ChannelId, ConnectionId, PortId};
//use crate::Height;

/// A context supplying all the necessary read-only dependencies for processing any `ConnectionMsg`.
pub trait ChannelReader {
Expand Down
5 changes: 1 addition & 4 deletions modules/src/ics04_channel/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ use thiserror::Error;

pub type Error = anomaly::Error<Kind>;

use crate::ics24_host::identifier::{ConnectionId,ChannelId};
use crate::ics24_host::identifier::{ChannelId, ConnectionId};

#[derive(Clone, Debug, Error)]
pub enum Kind {
#[error("not implemented yet")]
Niy,

#[error("channel state unknown")]
UnknownState,

Expand Down
5 changes: 3 additions & 2 deletions modules/src/ics04_channel/handler/chan_open_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ mod tests {

use crate::handler::EventType;

use crate::ics03_connection::connection::ConnectionEnd;
use crate::ics03_connection::msgs::conn_open_init::test_util::get_dummy_msg_conn_open_init;
use crate::ics03_connection::msgs::conn_open_init::test_util::make_default_connection_end_for_client;

use crate::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit;

use crate::ics04_channel::channel::{ChannelEnd, State};
Expand Down Expand Up @@ -103,7 +104,7 @@ mod tests {
let msg_conn_init =
MsgConnectionOpenInit::try_from(get_dummy_msg_conn_open_init()).unwrap();

let init_conn_end = &ConnectionEnd::test_channel_new(
let init_conn_end = make_default_connection_end_for_client(
msg_conn_init.client_id().clone(),
msg_conn_init.counterparty().clone(),
)
Expand Down