Skip to content

Commit 52cc5fd

Browse files
author
Park Juhyung
committed
Use Vec<u8> type for received proofs
Since only the light client know the encoding of the proof, we should not decode the proof in other places.
1 parent b67da38 commit 52cc5fd

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

core/src/ibc/connection_03/manager.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ impl<'a> Manager<'a> {
6767
counterparty_prefix: CommitmentPrefix,
6868
counterparty_client_identifier: Identifier,
6969
client_identifier: Identifier,
70-
proof_init: CommitmentProof,
71-
proof_consensus: CommitmentProof,
70+
proof_init: Vec<u8>,
71+
proof_consensus: Vec<u8>,
7272
proof_height: u64,
7373
consensus_height: u64,
7474
) -> Result<(), String> {
@@ -135,13 +135,19 @@ impl<'a> Manager<'a> {
135135
&mut self,
136136
connection: &ConnectionEnd,
137137
proof_height: u64,
138-
proof: CommitmentProof,
138+
proof: Vec<u8>,
139139
connection_identifier: Identifier,
140140
connection_end: &ConnectionEnd,
141141
) -> bool {
142+
let proof_dec: CommitmentProof = if let Ok(proof) = rlp::decode(&proof) {
143+
proof
144+
} else {
145+
return false
146+
};
147+
142148
// check values in the connection_end
143149
let path = format!("connections/{}", connection_identifier);
144-
self.client_verify_membership(proof_height, proof, path, &rlp::encode(connection_end))
150+
self.client_verify_membership(proof_height, proof_dec, path, &rlp::encode(connection_end))
145151
}
146152

147153
fn client_verify_membership(

core/src/ibc/transaction_handler/mod.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ mod datagrams;
1818

1919
use self::datagrams::Datagram;
2020
use crate::ibc;
21-
use crate::ibc::commitment_23::types::{CommitmentPrefix, CommitmentProof};
21+
use crate::ibc::commitment_23::types::CommitmentPrefix;
2222
use ckey::{Address, Public};
2323
use cstate::{StateResult, TopLevelState};
2424
use ctypes::errors::RuntimeError;
@@ -80,13 +80,6 @@ pub fn execute(
8080
} => {
8181
let mut connection_manager = ibc_connection::Manager::new(&mut context);
8282

83-
let proof_init_dec: CommitmentProof = rlp::Rlp::new(&proof_init)
84-
.as_val()
85-
.map_err(|err| RuntimeError::IBC(format!("ConnOpenTry failed to decode proof_init {}", err)))?;
86-
let proof_consensus_dec: CommitmentProof = rlp::Rlp::new(&proof_consensus)
87-
.as_val()
88-
.map_err(|err| RuntimeError::IBC(format!("ConnOpenTry failed to decode consensus_init {}", err)))?;
89-
9083
connection_manager
9184
.handle_open_try(
9285
desired_identifier,
@@ -96,8 +89,8 @@ pub fn execute(
9689
},
9790
counterparty_client_identifier,
9891
client_identifier,
99-
proof_init_dec,
100-
proof_consensus_dec,
92+
proof_init,
93+
proof_consensus,
10194
proof_height,
10295
consensus_height,
10396
)

0 commit comments

Comments
 (0)