Skip to content

Commit 37d54d4

Browse files
authored
Restructure modules to align with ibc-go's structure (#1459)
* Move ics modules into Client, Applications, and Core modules * Fix broken imports in tests * Fix some more broken imports in tests * Fix broken imports in `telemetry`, `relayer`, and `relayer-cli` * Run cargo fmt * Fix more broken links * Add changelog entry * Update modules/lib.rs to reflect new directory structure * Remove conflict marker in gitignore * Flesh out lib.rs documentation
1 parent a5c4cc2 commit 37d54d4

File tree

202 files changed

+1217
-1143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+1217
-1143
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Restructure the layout of the `ibc` crate to match `ibc-go`'s [layout][ibc-go-layout] ([#1436][issue-1436]).
2+
3+
[issue-1436]: https://github.com/informalsystems/ibc-rs/issues/1436
4+
[ibc-go-layout]: https://github.com/cosmos/ibc-go#contents

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ __pycache__/
2525
.modelator
2626
mc.log
2727

28-
# Ignore OSX .DS_Store files
28+
# Ignore OSX .DS_Store file
2929
.DS_Store

modules/src/application/ics20_fungible_token_transfer/context.rs modules/src/applications/ics20_fungible_token_transfer/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ics04_channel::context::{ChannelKeeper, ChannelReader};
1+
use crate::core::ics04_channel::context::{ChannelKeeper, ChannelReader};
22

33
/// Captures all the dependencies which the ICS20 module requires to be able to dispatch and
44
/// process IBC messages.

modules/src/application/ics20_fungible_token_transfer/error.rs modules/src/applications/ics20_fungible_token_transfer/error.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use crate::ics04_channel::error as channel_error;
2-
use crate::ics24_host::error::ValidationError;
3-
use crate::ics24_host::identifier::{ChannelId, PortId};
1+
use crate::core::ics04_channel::error as channel_error;
2+
use crate::core::ics24_host::error::ValidationError;
3+
use crate::core::ics24_host::identifier::{ChannelId, PortId};
44
use crate::prelude::*;
55
use flex_error::define_error;
66

modules/src/application/ics20_fungible_token_transfer/msgs/transfer.rs modules/src/applications/ics20_fungible_token_transfer/msgs/transfer.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ use tendermint_proto::Protobuf;
66

77
use ibc_proto::ibc::apps::transfer::v1::MsgTransfer as RawMsgTransfer;
88

9-
use crate::application::ics20_fungible_token_transfer::error::Error;
10-
use crate::ics02_client::height::Height;
11-
use crate::ics24_host::identifier::{ChannelId, PortId};
9+
use crate::applications::ics20_fungible_token_transfer::error::Error;
10+
use crate::core::ics02_client::height::Height;
11+
use crate::core::ics24_host::identifier::{ChannelId, PortId};
1212
use crate::signer::Signer;
1313
use crate::timestamp::Timestamp;
1414
use crate::tx_msg::Msg;
1515

1616
pub const TYPE_URL: &str = "/ibc.applications.transfer.v1.MsgTransfer";
1717

18-
///
1918
/// Message definition for the "packet receiving" datagram.
20-
///
2119
#[derive(Clone, Debug, PartialEq)]
2220
pub struct MsgTransfer {
2321
/// the port on which the packet will be sent
@@ -105,7 +103,7 @@ pub mod test_util {
105103
use std::time::Duration;
106104

107105
use crate::{
108-
ics24_host::identifier::{ChannelId, PortId},
106+
core::ics24_host::identifier::{ChannelId, PortId},
109107
test_utils::get_dummy_account_id,
110108
timestamp::Timestamp,
111109
Height,

modules/src/application/ics20_fungible_token_transfer/relay_application_logic/send_transfer.rs modules/src/applications/ics20_fungible_token_transfer/relay_application_logic/send_transfer.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use crate::application::ics20_fungible_token_transfer::context::Ics20Context;
2-
use crate::application::ics20_fungible_token_transfer::error::Error;
3-
use crate::application::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer;
1+
use crate::applications::ics20_fungible_token_transfer::context::Ics20Context;
2+
use crate::applications::ics20_fungible_token_transfer::error::Error;
3+
use crate::applications::ics20_fungible_token_transfer::msgs::transfer::MsgTransfer;
4+
use crate::core::ics04_channel::handler::send_packet::send_packet;
5+
use crate::core::ics04_channel::packet::Packet;
6+
use crate::core::ics04_channel::packet::PacketResult;
47
use crate::handler::HandlerOutput;
5-
use crate::ics04_channel::handler::send_packet::send_packet;
6-
use crate::ics04_channel::packet::Packet;
7-
use crate::ics04_channel::packet::PacketResult;
88
use crate::prelude::*;
99

1010
pub(crate) fn send_transfer<Ctx>(
File renamed without changes.

modules/src/ics07_tendermint/client_def.rs modules/src/clients/ics07_tendermint/client_def.rs

+18-16
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@ use tendermint::Time;
55
use tendermint_light_client::components::verifier::{ProdVerifier, Verdict, Verifier};
66
use tendermint_light_client::types::{TrustedBlockState, UntrustedBlockState};
77

8-
use crate::ics02_client::client_consensus::AnyConsensusState;
9-
use crate::ics02_client::client_def::ClientDef;
10-
use crate::ics02_client::client_state::AnyClientState;
11-
use crate::ics02_client::client_type::ClientType;
12-
use crate::ics02_client::context::ClientReader;
13-
use crate::ics02_client::error::Error as Ics02Error;
14-
use crate::ics03_connection::connection::ConnectionEnd;
15-
use crate::ics04_channel::channel::ChannelEnd;
16-
use crate::ics04_channel::packet::Sequence;
17-
use crate::ics07_tendermint::client_state::ClientState;
18-
use crate::ics07_tendermint::consensus_state::ConsensusState;
19-
use crate::ics07_tendermint::error::Error;
20-
use crate::ics07_tendermint::header::Header;
8+
use crate::clients::ics07_tendermint::client_state::ClientState;
9+
use crate::clients::ics07_tendermint::consensus_state::ConsensusState;
10+
use crate::clients::ics07_tendermint::error::Error;
11+
use crate::clients::ics07_tendermint::header::Header;
12+
use crate::core::ics02_client::client_consensus::AnyConsensusState;
13+
use crate::core::ics02_client::client_def::ClientDef;
14+
use crate::core::ics02_client::client_state::AnyClientState;
15+
use crate::core::ics02_client::client_type::ClientType;
16+
use crate::core::ics02_client::context::ClientReader;
17+
use crate::core::ics02_client::error::Error as Ics02Error;
18+
use crate::core::ics03_connection::connection::ConnectionEnd;
19+
use crate::core::ics04_channel::channel::ChannelEnd;
20+
use crate::core::ics04_channel::packet::Sequence;
2121

22-
use crate::ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes, CommitmentRoot};
23-
use crate::ics24_host::identifier::ConnectionId;
24-
use crate::ics24_host::identifier::{ChannelId, ClientId, PortId};
22+
use crate::core::ics23_commitment::commitment::{
23+
CommitmentPrefix, CommitmentProofBytes, CommitmentRoot,
24+
};
25+
use crate::core::ics24_host::identifier::ConnectionId;
26+
use crate::core::ics24_host::identifier::{ChannelId, ClientId, PortId};
2527
use crate::prelude::*;
2628
use crate::Height;
2729

modules/src/ics07_tendermint/client_state.rs modules/src/clients/ics07_tendermint/client_state.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use tendermint_proto::Protobuf;
99

1010
use ibc_proto::ibc::lightclients::tendermint::v1::ClientState as RawClientState;
1111

12-
use crate::ics02_client::client_state::AnyClientState;
13-
use crate::ics02_client::client_type::ClientType;
14-
use crate::ics02_client::error::Error as Ics02Error;
15-
use crate::ics02_client::trust_threshold::TrustThreshold;
16-
use crate::ics07_tendermint::error::Error;
17-
use crate::ics07_tendermint::header::Header;
18-
use crate::ics23_commitment::specs::ProofSpecs;
19-
use crate::ics24_host::identifier::ChainId;
12+
use crate::clients::ics07_tendermint::error::Error;
13+
use crate::clients::ics07_tendermint::header::Header;
14+
use crate::core::ics02_client::client_state::AnyClientState;
15+
use crate::core::ics02_client::client_type::ClientType;
16+
use crate::core::ics02_client::error::Error as Ics02Error;
17+
use crate::core::ics02_client::trust_threshold::TrustThreshold;
18+
use crate::core::ics23_commitment::specs::ProofSpecs;
19+
use crate::core::ics24_host::identifier::ChainId;
2020
use crate::timestamp::ZERO_DURATION;
2121
use crate::Height;
2222

@@ -163,7 +163,7 @@ impl ClientState {
163163
}
164164
}
165165

166-
impl crate::ics02_client::client_state::ClientState for ClientState {
166+
impl crate::core::ics02_client::client_state::ClientState for ClientState {
167167
fn chain_id(&self) -> ChainId {
168168
self.chain_id.clone()
169169
}
@@ -260,24 +260,25 @@ mod tests {
260260

261261
use tendermint_rpc::endpoint::abci_query::AbciQuery;
262262

263-
use crate::ics02_client::trust_threshold::TrustThreshold;
264-
use crate::ics07_tendermint::client_state::{AllowUpdate, ClientState};
265-
use crate::ics24_host::identifier::ChainId;
263+
use crate::clients::ics07_tendermint::client_state::{AllowUpdate, ClientState};
264+
use crate::core::ics02_client::trust_threshold::TrustThreshold;
265+
use crate::core::ics24_host::identifier::ChainId;
266266
use crate::test::test_serialization_roundtrip;
267267
use crate::timestamp::ZERO_DURATION;
268268
use crate::Height;
269269

270270
#[test]
271271
fn serialization_roundtrip_no_proof() {
272-
let json_data = include_str!("../../tests/support/query/serialization/client_state.json");
272+
let json_data =
273+
include_str!("../../../tests/support/query/serialization/client_state.json");
273274
println!("json_data: {:?}", json_data);
274275
test_serialization_roundtrip::<AbciQuery>(json_data);
275276
}
276277

277278
#[test]
278279
fn serialization_roundtrip_with_proof() {
279280
let json_data =
280-
include_str!("../../tests/support/query/serialization/client_state_proof.json");
281+
include_str!("../../../tests/support/query/serialization/client_state_proof.json");
281282
println!("json_data: {:?}", json_data);
282283
test_serialization_roundtrip::<AbciQuery>(json_data);
283284
}
@@ -396,10 +397,10 @@ pub mod test_util {
396397

397398
use tendermint::block::Header;
398399

399-
use crate::ics02_client::client_state::AnyClientState;
400-
use crate::ics02_client::height::Height;
401-
use crate::ics07_tendermint::client_state::{AllowUpdate, ClientState};
402-
use crate::ics24_host::identifier::ChainId;
400+
use crate::clients::ics07_tendermint::client_state::{AllowUpdate, ClientState};
401+
use crate::core::ics02_client::client_state::AnyClientState;
402+
use crate::core::ics02_client::height::Height;
403+
use crate::core::ics24_host::identifier::ChainId;
403404

404405
pub fn get_dummy_tendermint_client_state(tm_header: Header) -> AnyClientState {
405406
AnyClientState::Tendermint(

modules/src/ics07_tendermint/consensus_state.rs modules/src/clients/ics07_tendermint/consensus_state.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use tendermint_proto::Protobuf;
88

99
use ibc_proto::ibc::lightclients::tendermint::v1::ConsensusState as RawConsensusState;
1010

11-
use crate::ics02_client::client_consensus::AnyConsensusState;
12-
use crate::ics02_client::client_type::ClientType;
13-
use crate::ics07_tendermint::error::Error;
14-
use crate::ics07_tendermint::header::Header;
15-
use crate::ics23_commitment::commitment::CommitmentRoot;
11+
use crate::clients::ics07_tendermint::error::Error;
12+
use crate::clients::ics07_tendermint::header::Header;
13+
use crate::core::ics02_client::client_consensus::AnyConsensusState;
14+
use crate::core::ics02_client::client_type::ClientType;
15+
use crate::core::ics23_commitment::commitment::CommitmentRoot;
1616

1717
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
1818
pub struct ConsensusState {
@@ -31,7 +31,7 @@ impl ConsensusState {
3131
}
3232
}
3333

34-
impl crate::ics02_client::client_consensus::ConsensusState for ConsensusState {
34+
impl crate::core::ics02_client::client_consensus::ConsensusState for ConsensusState {
3535
type Error = Infallible;
3636

3737
fn client_type(&self) -> ClientType {
@@ -122,15 +122,15 @@ mod tests {
122122
#[test]
123123
fn serialization_roundtrip_no_proof() {
124124
let json_data =
125-
include_str!("../../tests/support/query/serialization/consensus_state.json");
125+
include_str!("../../../tests/support/query/serialization/consensus_state.json");
126126
println!("json_data: {:?}", json_data);
127127
test_serialization_roundtrip::<AbciQuery>(json_data);
128128
}
129129

130130
#[test]
131131
fn serialization_roundtrip_with_proof() {
132132
let json_data =
133-
include_str!("../../tests/support/query/serialization/consensus_state_proof.json");
133+
include_str!("../../../tests/support/query/serialization/consensus_state_proof.json");
134134
println!("json_data: {:?}", json_data);
135135
test_serialization_roundtrip::<AbciQuery>(json_data);
136136
}

modules/src/ics07_tendermint/error.rs modules/src/clients/ics07_tendermint/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::prelude::*;
22

33
use flex_error::{define_error, TraceError};
44

5-
use crate::ics24_host::error::ValidationError;
5+
use crate::core::ics24_host::error::ValidationError;
66
use crate::Height;
77
use tendermint::account::Id;
88
use tendermint::hash::Hash;

modules/src/ics07_tendermint/header.rs modules/src/clients/ics07_tendermint/header.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use crate::timestamp::Timestamp;
1313

1414
use ibc_proto::ibc::lightclients::tendermint::v1::Header as RawHeader;
1515

16-
use crate::ics02_client::client_type::ClientType;
17-
use crate::ics02_client::header::AnyHeader;
18-
use crate::ics07_tendermint::error::Error;
19-
use crate::ics24_host::identifier::ChainId;
16+
use crate::clients::ics07_tendermint::error::Error;
17+
use crate::core::ics02_client::client_type::ClientType;
18+
use crate::core::ics02_client::header::AnyHeader;
19+
use crate::core::ics24_host::identifier::ChainId;
2020
use crate::Height;
2121
use core::cmp::Ordering;
2222

@@ -73,7 +73,7 @@ pub fn headers_compatible(header: &SignedHeader, other: &SignedHeader) -> bool {
7373
}
7474
}
7575

76-
impl crate::ics02_client::header::Header for Header {
76+
impl crate::core::ics02_client::header::Header for Header {
7777
fn client_type(&self) -> ClientType {
7878
ClientType::Tendermint
7979
}
@@ -156,13 +156,15 @@ pub mod test_util {
156156
use tendermint::validator::Set as ValidatorSet;
157157
use tendermint::PublicKey;
158158

159-
use crate::ics07_tendermint::header::Header;
159+
use crate::clients::ics07_tendermint::header::Header;
160160
use crate::Height;
161161

162162
pub fn get_dummy_tendermint_header() -> tendermint::block::Header {
163-
serde_json::from_str::<SignedHeader>(include_str!("../../tests/support/signed_header.json"))
164-
.unwrap()
165-
.header
163+
serde_json::from_str::<SignedHeader>(include_str!(
164+
"../../../tests/support/signed_header.json"
165+
))
166+
.unwrap()
167+
.header
166168
}
167169

168170
// TODO: This should be replaced with a ::default() or ::produce().
@@ -182,7 +184,7 @@ pub mod test_util {
182184
pub fn get_dummy_ics07_header() -> Header {
183185
// Build a SignedHeader from a JSON file.
184186
let shdr = serde_json::from_str::<SignedHeader>(include_str!(
185-
"../../tests/support/signed_header.json"
187+
"../../../tests/support/signed_header.json"
186188
))
187189
.unwrap();
188190

modules/src/ics07_tendermint/misbehaviour.rs modules/src/clients/ics07_tendermint/misbehaviour.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use tendermint_proto::Protobuf;
44

55
use ibc_proto::ibc::lightclients::tendermint::v1::Misbehaviour as RawMisbehaviour;
66

7-
use crate::ics02_client::misbehaviour::AnyMisbehaviour;
8-
use crate::ics07_tendermint::error::Error;
9-
use crate::ics07_tendermint::header::Header;
10-
use crate::ics24_host::identifier::ClientId;
7+
use crate::clients::ics07_tendermint::error::Error;
8+
use crate::clients::ics07_tendermint::header::Header;
9+
use crate::core::ics02_client::misbehaviour::AnyMisbehaviour;
10+
use crate::core::ics24_host::identifier::ClientId;
1111
use crate::Height;
1212

1313
#[derive(Clone, Debug, PartialEq)]
@@ -17,7 +17,7 @@ pub struct Misbehaviour {
1717
pub header2: Header,
1818
}
1919

20-
impl crate::ics02_client::misbehaviour::Misbehaviour for Misbehaviour {
20+
impl crate::core::ics02_client::misbehaviour::Misbehaviour for Misbehaviour {
2121
fn client_id(&self) -> &ClientId {
2222
&self.client_id
2323
}

modules/src/clients/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod ics07_tendermint;

modules/src/ics02_client/client_consensus.rs modules/src/core/ics02_client/client_consensus.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ use prost_types::Any;
88
use serde::Serialize;
99
use tendermint_proto::Protobuf;
1010

11+
use crate::clients::ics07_tendermint::consensus_state;
12+
use crate::core::ics02_client::client_type::ClientType;
13+
use crate::core::ics02_client::error::Error;
14+
use crate::core::ics02_client::height::Height;
15+
use crate::core::ics23_commitment::commitment::CommitmentRoot;
16+
use crate::core::ics24_host::identifier::ClientId;
1117
use crate::events::WithBlockDataType;
12-
use crate::ics02_client::client_type::ClientType;
13-
use crate::ics02_client::error::Error;
14-
use crate::ics02_client::height::Height;
15-
use crate::ics07_tendermint::consensus_state;
16-
use crate::ics23_commitment::commitment::CommitmentRoot;
17-
use crate::ics24_host::identifier::ClientId;
1818
use crate::timestamp::Timestamp;
1919

2020
#[cfg(any(test, feature = "mocks"))]

modules/src/ics02_client/client_def.rs modules/src/core/ics02_client/client_def.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
use ibc_proto::ibc::core::commitment::v1::MerkleProof;
22

3+
use crate::clients::ics07_tendermint::client_def::TendermintClient;
4+
use crate::core::ics02_client::client_consensus::{AnyConsensusState, ConsensusState};
5+
use crate::core::ics02_client::client_state::{AnyClientState, ClientState};
6+
use crate::core::ics02_client::client_type::ClientType;
7+
use crate::core::ics02_client::context::ClientReader;
8+
use crate::core::ics02_client::error::Error;
9+
use crate::core::ics02_client::header::{AnyHeader, Header};
10+
use crate::core::ics03_connection::connection::ConnectionEnd;
11+
use crate::core::ics04_channel::channel::ChannelEnd;
12+
use crate::core::ics04_channel::packet::Sequence;
13+
use crate::core::ics23_commitment::commitment::{
14+
CommitmentPrefix, CommitmentProofBytes, CommitmentRoot,
15+
};
16+
use crate::core::ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId};
317
use crate::downcast;
4-
use crate::ics02_client::client_consensus::{AnyConsensusState, ConsensusState};
5-
use crate::ics02_client::client_state::{AnyClientState, ClientState};
6-
use crate::ics02_client::client_type::ClientType;
7-
use crate::ics02_client::context::ClientReader;
8-
use crate::ics02_client::error::Error;
9-
use crate::ics02_client::header::{AnyHeader, Header};
10-
use crate::ics03_connection::connection::ConnectionEnd;
11-
use crate::ics04_channel::channel::ChannelEnd;
12-
use crate::ics04_channel::packet::Sequence;
13-
use crate::ics07_tendermint::client_def::TendermintClient;
14-
use crate::ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes, CommitmentRoot};
15-
use crate::ics24_host::identifier::{ChannelId, ClientId, ConnectionId, PortId};
1618
use crate::prelude::*;
1719
use crate::Height;
1820

0 commit comments

Comments
 (0)