Skip to content

Commit

Permalink
solana-ibc: update for_client_state documentation (#124)
Browse files Browse the repository at this point in the history
Documentation of the for_client_state method disagreed with the code.
Update it to reflect reality.  While at it update what’s hashed to
match borsh serialisation.
  • Loading branch information
mina86 authored Nov 24, 2023
1 parent f0027e1 commit 31ab994
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ impl ClientExecutionContext for IbcStorage<'_, '_> {
let mut store = self.borrow_mut();
let mut client = store.private.client_mut(&path.0, true)?;
let serialised = client.client_state.set(&state)?;
let client_id = path.0.as_bytes();
let hash = CryptoHash::digestv(&[
path.0.as_bytes(),
&[0],
&(client_id.len() as u32).to_le_bytes()[..],
client_id,
serialised.as_bytes(),
]);
let key = TrieKey::for_client_state(client.index);
Expand Down
4 changes: 2 additions & 2 deletions solana/solana-ibc/programs/solana-ibc/src/storage/trie_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ impl TrieKey {
/// Constructs a new key for a client state path for client with given
/// counter.
///
/// The hash stored under the key is `hash(borsh(client_id.as_str()) ||
/// borsh(client_state))`.
/// The hash stored under the key is `hash(borsh((client_id.as_str(),
/// client_state)))`.
pub fn for_client_state(client: ids::ClientIdx) -> Self {
new_key_impl!(Tag::ClientState, client)
}
Expand Down

0 comments on commit 31ab994

Please sign in to comment.