Skip to content

Commit

Permalink
witness: store local consensus state during initialization for witnes…
Browse files Browse the repository at this point in the history
…s feature (#400)

When establishing the connection, we need to store the consensus state
on chain before the client is stored since the consensus state would be
required during `OpenTry` or `OpenAck` based on order of how the
connection is established. So storing the consensus state during
`initialize` method so that when the client is created, it can use the
stored consensus state.

---------

Co-authored-by: Michal Nazarewicz <[email protected]>
  • Loading branch information
dhruvja and mina86 authored Oct 18, 2024
1 parent 9ef816d commit 0bc98fe
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions solana/solana-ibc/programs/solana-ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ pub mod solana_ibc {
&ctx.accounts.trie,
&ctx.accounts.sender,
)?;
#[cfg(feature = "witness")]
{
let storage = &mut ctx.accounts.storage;
let clock = Clock::get()?;
let slot = clock.slot;
let timestamp = clock.unix_timestamp as u64;
storage
.add_local_consensus_state(slot, timestamp, *provable.hash())
.unwrap();
}
ctx.accounts.chain.initialise(
&mut provable,
config,
Expand Down

0 comments on commit 0bc98fe

Please sign in to comment.