Skip to content

Commit

Permalink
solana-trie: add support for witness account
Browse files Browse the repository at this point in the history
Witness of the trie is an account which stores the trie’s hash.  Using
Solana’s account delta hash this allows us to construct a proof of the
root.
  • Loading branch information
mina86 committed Sep 5, 2024
1 parent 50ba984 commit 298e4bb
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 134 deletions.
11 changes: 5 additions & 6 deletions common/cf-solana/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ impl Header {
/// trie and Solana block timestamp in seconds.
///
/// Returns None if the witness account data has unexpected format
/// (e.g. it’s not 40-byte long). See `WitnessedData` in
/// `solana-witnessed-trie`.
// TODO(mina86): Ideally we would use wittrie::api::WitnessedData here but
// wittrie depends on Solana and we don’t want to introduce required Solana
// dependencies here. Moving WitnessData to a crate in common/ is an option
// but for the time being we’re duplicating the logic here.
/// (e.g. it’s not 40-byte long). See `witness::Data` in solana-trie.
// TODO(mina86): Ideally we would use solana_trie::witness::Data here but
// solana_trie depends on Solana and we don’t want to introduce required
// Solana dependencies here. Moving witness::Data to a crate in common/ is
// an option but for the time being we’re duplicating the logic here.
pub fn decode_witness(&self) -> Option<(&CryptoHash, NonZeroU64)> {
let data =
self.witness_proof.account_hash_data.data().try_into().ok()?;
Expand Down
2 changes: 1 addition & 1 deletion solana/solana-ibc/programs/solana-ibc/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ impl PrivateStorage {

/// Provable storage, i.e. the trie, held in an account.
pub type TrieAccount<'a, 'b> =
solana_trie::TrieAccount<solana_trie::ResizableAccount<'a, 'b>>;
solana_trie::TrieAccount<'a, solana_trie::ResizableAccount<'a, 'b>>;

/// Checks contents of given unchecked account and returns a trie if it’s valid.
///
Expand Down
Loading

0 comments on commit 298e4bb

Please sign in to comment.