Skip to content

Commit

Permalink
Remove store_update_{height,time} from ExecutionContext
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Jun 8, 2023
1 parent ce012c6 commit 282424f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 53 deletions.
20 changes: 0 additions & 20 deletions crates/ibc/src/core/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,26 +252,6 @@ pub trait ExecutionContext: ValidationContext {
/// Should never fail.
fn increase_client_counter(&mut self);

/// Called upon successful client update.
/// Implementations are expected to use this to record the specified time as the time at which
/// this update (or header) was processed.
fn store_update_time(
&mut self,
client_id: ClientId,
height: Height,
timestamp: Timestamp,
) -> Result<(), ContextError>;

/// Called upon successful client update.
/// Implementations are expected to use this to record the specified height as the height at
/// at which this update (or header) was processed.
fn store_update_height(
&mut self,
client_id: ClientId,
height: Height,
host_height: Height,
) -> Result<(), ContextError>;

/// Stores the given connection_end at path
fn store_connection(
&mut self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ mod tests {
use crate::core::ics04_channel::commitment::PacketCommitment;
use crate::core::ics04_channel::handler::timeout_on_close::validate;
use crate::core::timestamp::Timestamp;
use crate::core::ExecutionContext;
use crate::mock::context::MockContext;
use crate::prelude::*;
use crate::Height;
Expand Down
64 changes: 32 additions & 32 deletions crates/ibc/src/mock/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,34 @@ impl MockContext {
pub fn ibc_store_share(&self) -> Arc<Mutex<MockIbcStore>> {
self.ibc_store.clone()
}

pub fn store_update_time(
&mut self,
client_id: ClientId,
height: Height,
timestamp: Timestamp,
) -> Result<(), ContextError> {
let _ = self
.ibc_store
.lock()
.client_processed_times
.insert((client_id, height), timestamp);
Ok(())
}

pub fn store_update_height(
&mut self,
client_id: ClientId,
height: Height,
host_height: Height,
) -> Result<(), ContextError> {
let _ = self
.ibc_store
.lock()
.client_processed_heights
.insert((client_id, height), host_height);
Ok(())
}
}

type PortChannelIdMap<V> = BTreeMap<PortId, BTreeMap<ChannelId, V>>;
Expand Down Expand Up @@ -894,7 +922,7 @@ impl MockClientExecutionContext for MockContext {
height: Height,
timestamp: Timestamp,
) -> Result<(), ContextError> {
ExecutionContext::store_update_time(self, client_id, height, timestamp)
self.store_update_time(client_id, height, timestamp)
}

fn store_update_height(
Expand All @@ -903,7 +931,7 @@ impl MockClientExecutionContext for MockContext {
height: Height,
host_height: Height,
) -> Result<(), ContextError> {
ExecutionContext::store_update_height(self, client_id, height, host_height)
self.store_update_height(client_id, height, host_height)
}

fn store_client_state(
Expand All @@ -930,7 +958,7 @@ impl TmClientExecutionContext for MockContext {
height: Height,
timestamp: Timestamp,
) -> Result<(), ContextError> {
<Self as ExecutionContext>::store_update_time(self, client_id, height, timestamp)
self.store_update_time(client_id, height, timestamp)
}

fn store_update_height(
Expand All @@ -939,7 +967,7 @@ impl TmClientExecutionContext for MockContext {
height: Height,
host_height: Height,
) -> Result<(), ContextError> {
<Self as ExecutionContext>::store_update_height(self, client_id, height, host_height)
self.store_update_height(client_id, height, host_height)
}

fn store_client_state(
Expand Down Expand Up @@ -1365,34 +1393,6 @@ impl ExecutionContext for MockContext {
self.ibc_store.lock().client_ids_counter += 1
}

fn store_update_time(
&mut self,
client_id: ClientId,
height: Height,
timestamp: Timestamp,
) -> Result<(), ContextError> {
let _ = self
.ibc_store
.lock()
.client_processed_times
.insert((client_id, height), timestamp);
Ok(())
}

fn store_update_height(
&mut self,
client_id: ClientId,
height: Height,
host_height: Height,
) -> Result<(), ContextError> {
let _ = self
.ibc_store
.lock()
.client_processed_heights
.insert((client_id, height), host_height);
Ok(())
}

fn store_connection(
&mut self,
connection_path: &ConnectionPath,
Expand Down

0 comments on commit 282424f

Please sign in to comment.