Skip to content

Commit

Permalink
add revision number check for witness feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvja committed Oct 18, 2024
1 parent 5e04f57 commit ec57402
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions solana/solana-ibc/programs/solana-ibc/src/validation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@ impl ibc::ValidationContext for IbcStorage<'_, '_> {
) -> Result<Self::AnyConsensusState> {
let store = self.borrow();
#[cfg(feature = "witness")]
let state = store
.private
.local_consensus_state
.iter()
.find(|cs| cs.0 == height.revision_height())
.map(|(_slot, timestamp, trie_root)| {
let state = cf_solana::ConsensusState {
trie_root: ibc::CommitmentRoot::from_bytes(
trie_root.as_slice(),
),
timestamp_sec: NonZeroU64::new(*timestamp).unwrap(),
};
AnyConsensusState::Rollup(state)
});
let state = (height.revision_number() == 1).then(|| {
store
.private
.local_consensus_state
.iter()
.find(|cs| cs.0 == height.revision_height())
.map(|(_slot, timestamp, trie_root)| {
let state = cf_solana::ConsensusState {
trie_root: ibc::CommitmentRoot::from_bytes(
trie_root.as_slice(),
),
timestamp_sec: NonZeroU64::new(*timestamp).unwrap(),
};
AnyConsensusState::Rollup(state)
})
});
#[cfg(not(feature = "witness"))]
let state = (height.revision_number() == 1)
.then(|| {
Expand Down

0 comments on commit ec57402

Please sign in to comment.