Skip to content

Commit

Permalink
trim left zero from expected value
Browse files Browse the repository at this point in the history
Signed-off-by: yoshidan <[email protected]>
  • Loading branch information
yoshidan committed Feb 27, 2024
1 parent 4e408c5 commit 69dd94b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/ibc/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl<const SYNC_COMMITTEE_SIZE: usize, const EXECUTION_PAYLOAD_TREE_DEPTH: usize
.verify_membership(
H256::from_slice(root.as_bytes()),
key.as_bytes(),
rlp::encode(&value).as_ref(),
rlp::encode(&trim_left_zero(&value)).as_ref(),
proof.clone(),
)
.map_err(|e| ClientError::ClientSpecific {
Expand Down Expand Up @@ -824,6 +824,17 @@ fn maybe_consensus_state(
}
}

fn trim_left_zero(value: &[u8]) -> &[u8] {
let mut pos = 0;
for v in value {
if *v != 0 {
break;
}
pos += 1;
}
&value[pos..]
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 69dd94b

Please sign in to comment.