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

Fix query client consensus command #287

Merged
merged 3 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Review comments
  • Loading branch information
ancazamfir committed Oct 7, 2020
commit aa09adf68ee716fb14441ae3d6b87ea2ae6b50b9
56 changes: 41 additions & 15 deletions modules/src/ics24_host/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,28 @@ pub const IBC_QUERY_PATH: &str = "store/ibc/key";
pub enum Path {
ClientType(ClientId),
ClientState(ClientId),
ClientConsensusState(ClientId, u64, u64),
ClientConsensusState {
client_id: ClientId,
epoch: u64,
height: u64,
},
ClientConnections(ClientId),
Connections(ConnectionId),
Ports(PortId),
ChannelEnds(PortId, ChannelId),
SeqSends(PortId, ChannelId),
SeqRecvs(PortId, ChannelId),
SeqAcks(PortId, ChannelId),
Commitments(PortId, ChannelId, u64),
Acks(PortId, ChannelId, u64),
Commitments {
port_id: PortId,
channel_id: ChannelId,
sequence: u64,
},
Acks {
port_id: PortId,
channel_id: ChannelId,
sequence: u64,
},
}

impl Path {
Expand All @@ -44,14 +56,20 @@ impl Path {
impl Display for Path {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match &self {
Path::ClientType(id) => write!(f, "clients/{}/clientType", id),
Path::ClientState(id) => write!(f, "clients/{}/clientState", id),
Path::ClientConsensusState(id, epoch, height) => {
write!(f, "clients/{}/consensusState/{}-{}", id, epoch, height)
}
Path::ClientConnections(id) => write!(f, "clients/{}/connections", id),
Path::Connections(id) => write!(f, "connections/{}", id),
Path::Ports(id) => write!(f, "ports/{}", id),
Path::ClientType(client_id) => write!(f, "clients/{}/clientType", client_id),
Path::ClientState(client_id) => write!(f, "clients/{}/clientState", client_id),
Path::ClientConsensusState {
client_id,
epoch,
height,
} => write!(
f,
"clients/{}/consensusState/{}-{}",
client_id, epoch, height
),
Path::ClientConnections(client_id) => write!(f, "clients/{}/connections", client_id),
Path::Connections(connection_id) => write!(f, "connections/{}", connection_id),
Path::Ports(port_id) => write!(f, "ports/{}", port_id),
Path::ChannelEnds(port_id, channel_id) => {
write!(f, "channelEnds/ports/{}/channels/{}", port_id, channel_id)
}
Expand All @@ -70,15 +88,23 @@ impl Display for Path {
"seqAcks/ports/{}/channels/{}/nextSequenceAck",
port_id, channel_id
),
Path::Commitments(port_id, channel_id, seq) => write!(
Path::Commitments {
port_id,
channel_id,
sequence,
} => write!(
f,
"commitments/ports/{}/channels/{}/packets/{}",
port_id, channel_id, seq
port_id, channel_id, sequence
),
Path::Acks(port_id, channel_id, seq) => write!(
Path::Acks {
port_id,
channel_id,
sequence,
} => write!(
f,
"acks/ports/{}/channels/{}/acknowledgements/{}",
port_id, channel_id, seq
port_id, channel_id, sequence
),
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/src/mock_client/client_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl ClientDef for MockClient {
) -> Result<(), Box<dyn std::error::Error>> {
let client_prefixed_path =
// TODO - will pick epoch from new type Height
Path::ClientConsensusState(client_id.clone(), 0, height.value()).to_string();
Path::ClientConsensusState{client_id: client_id.clone(), epoch: 0, height: height.value()}.to_string();

let _path = apply_prefix(prefix, client_prefixed_path)?;

Expand Down
6 changes: 5 additions & 1 deletion relayer-cli/src/commands/query/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ impl Runnable for QueryClientConsensusCmd {
let chain = CosmosSDKChain::from_config(chain_config).unwrap();
let res: Result<AnyConsensusState, Error> = chain
.query(
ClientConsensusState(opts.client_id, opts.consensus_epoch, opts.consensus_height),
ClientConsensusState {
client_id: opts.client_id,
epoch: opts.consensus_epoch,
height: opts.consensus_height,
},
opts.height,
opts.proof,
)
Expand Down