Skip to content

Commit

Permalink
cf-solana: get timestamp in ns for cf-solana (#397)
Browse files Browse the repository at this point in the history
in the `consensus_has_expired` method, the consensus timestamp is
fetched in seconds but added to a trusting period which is in
nanoseconds creating a mismatch. So fixing this bug by fetching the
consensus timestamp in nanoseconds.
  • Loading branch information
dhruvja authored Oct 16, 2024
1 parent 4c5428d commit ab6ad71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions common/cf-solana/src/client/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use alloc::string::ToString;
use alloc::vec::Vec;
use core::num::NonZeroU64;

use ibc_core_client_context::consensus_state::ConsensusState as _;

use crate::proto::Any;
use crate::{
proof, ClientMessage, ClientState, ConsensusState, Header, Misbehaviour,
Expand Down Expand Up @@ -489,8 +491,8 @@ impl ClientState {
host_timestamp: ibc::Timestamp,
) -> bool {
let expiry_ns = consensus
.timestamp_sec
.get()
.timestamp()
.nanoseconds()
.saturating_add(self.trusting_period_ns);
ibc::Timestamp::from_nanoseconds(expiry_ns).unwrap() <= host_timestamp
}
Expand Down

0 comments on commit ab6ad71

Please sign in to comment.