diff --git a/ibc-clients/ics07-tendermint/src/client_state.rs b/ibc-clients/ics07-tendermint/src/client_state.rs index 1bffd8f99..e6cd47364 100644 --- a/ibc-clients/ics07-tendermint/src/client_state.rs +++ b/ibc-clients/ics07-tendermint/src/client_state.rs @@ -336,7 +336,12 @@ where ), tm_consensus_state.into(), )?; - ctx.store_update_meta(client_id, self.latest_height(), host_timestamp, host_height)?; + ctx.store_update_meta( + client_id.clone(), + self.latest_height(), + host_timestamp, + host_height, + )?; Ok(()) } @@ -386,7 +391,12 @@ where ClientStatePath::new(client_id), ClientState::from(new_client_state).into(), )?; - ctx.store_update_meta(client_id, header_height, host_timestamp, host_height)?; + ctx.store_update_meta( + client_id.clone(), + header_height, + host_timestamp, + host_height, + )?; } Ok(vec![header_height]) @@ -481,7 +491,12 @@ where ), TmConsensusState::from(new_consensus_state).into(), )?; - ctx.store_update_meta(client_id, latest_height, host_timestamp, host_height)?; + ctx.store_update_meta( + client_id.clone(), + latest_height, + host_timestamp, + host_height, + )?; Ok(latest_height) } diff --git a/ibc-clients/ics07-tendermint/src/client_state/update_client.rs b/ibc-clients/ics07-tendermint/src/client_state/update_client.rs index 599fc1ca5..f412e6242 100644 --- a/ibc-clients/ics07-tendermint/src/client_state/update_client.rs +++ b/ibc-clients/ics07-tendermint/src/client_state/update_client.rs @@ -220,7 +220,7 @@ impl ClientState { break; } ctx.delete_consensus_state(client_consensus_state_path)?; - ctx.delete_update_meta(client_id, height)?; + ctx.delete_update_meta(client_id.clone(), height)?; } Ok(()) diff --git a/ibc-core/ics02-client/context/src/context.rs b/ibc-core/ics02-client/context/src/context.rs index b181c388b..a09673bb7 100644 --- a/ibc-core/ics02-client/context/src/context.rs +++ b/ibc-core/ics02-client/context/src/context.rs @@ -17,7 +17,7 @@ pub trait ClientValidationContext { fn update_meta( &self, client_id: &ClientId, - height: Height, + height: &Height, ) -> Result<(Timestamp, Height), ContextError>; } @@ -60,7 +60,7 @@ pub trait ClientExecutionContext: Sized { /// and height as the time at which this update (or header) was processed. fn store_update_meta( &mut self, - client_id: &ClientId, + client_id: ClientId, height: Height, host_timestamp: Timestamp, host_height: Height, @@ -75,7 +75,7 @@ pub trait ClientExecutionContext: Sized { /// Note that this timestamp is determined by the host. fn delete_update_meta( &mut self, - client_id: &ClientId, + client_id: ClientId, height: Height, ) -> Result<(), ContextError>; } diff --git a/ibc-core/ics03-connection/src/delay.rs b/ibc-core/ics03-connection/src/delay.rs index 04fcc550f..feecf23fb 100644 --- a/ibc-core/ics03-connection/src/delay.rs +++ b/ibc-core/ics03-connection/src/delay.rs @@ -21,7 +21,7 @@ where let client_id = connection_end.client_id(); let last_client_update = ctx .get_client_validation_context() - .update_meta(client_id, packet_proof_height)?; + .update_meta(client_id, &packet_proof_height)?; // Fetch the connection delay time and height periods. let conn_delay_time_period = connection_end.delay_period(); diff --git a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs index 1d47277b6..4c74b7c2d 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs @@ -351,7 +351,7 @@ where )?; ctx.store_client_state(ClientStatePath::new(client_id), new_client_state.into())?; ctx.store_update_meta( - client_id, + client_id.clone(), header_height, ctx.host_timestamp()?, ctx.host_height()?, @@ -399,7 +399,12 @@ where let host_timestamp = ctx.host_timestamp()?; let host_height = ctx.host_height()?; - ctx.store_update_meta(client_id, latest_height, host_timestamp, host_height)?; + ctx.store_update_meta( + client_id.clone(), + latest_height, + host_timestamp, + host_height, + )?; Ok(latest_height) } diff --git a/ibc-testkit/src/testapp/ibc/core/client_ctx.rs b/ibc-testkit/src/testapp/ibc/core/client_ctx.rs index 5280270f9..227c647af 100644 --- a/ibc-testkit/src/testapp/ibc/core/client_ctx.rs +++ b/ibc-testkit/src/testapp/ibc/core/client_ctx.rs @@ -159,9 +159,9 @@ impl ClientValidationContext for MockContext { fn update_meta( &self, client_id: &ClientId, - height: Height, + height: &Height, ) -> Result<(Timestamp, Height), ContextError> { - let key = (client_id.clone(), height); + let key = (client_id.clone(), *height); (|| { let ibc_store = self.ibc_store.lock(); let time = ibc_store.client_processed_times.get(&key)?; @@ -170,7 +170,7 @@ impl ClientValidationContext for MockContext { })() .ok_or(ClientError::UpdateMetaDataNotFound { client_id: key.0, - height, + height: key.1, }) .map_err(ContextError::from) } @@ -256,7 +256,7 @@ impl ClientExecutionContext for MockContext { fn delete_update_meta( &mut self, - client_id: &ClientId, + client_id: ClientId, height: Height, ) -> Result<(), ContextError> { let key = (client_id.clone(), height); @@ -268,7 +268,7 @@ impl ClientExecutionContext for MockContext { fn store_update_meta( &mut self, - client_id: &ClientId, + client_id: ClientId, height: Height, host_timestamp: Timestamp, host_height: Height, @@ -279,7 +279,7 @@ impl ClientExecutionContext for MockContext { .insert((client_id.clone(), height), host_timestamp); ibc_store .client_processed_heights - .insert((client_id.clone(), height), host_height); + .insert((client_id, height), host_height); Ok(()) } } diff --git a/ibc-testkit/tests/core/ics02_client/update_client.rs b/ibc-testkit/tests/core/ics02_client/update_client.rs index 287ea58ec..4cac3e1e8 100644 --- a/ibc-testkit/tests/core/ics02_client/update_client.rs +++ b/ibc-testkit/tests/core/ics02_client/update_client.rs @@ -147,7 +147,7 @@ fn test_consensus_state_pruning() { expired_height.revision_number(), expired_height.revision_height(), ); - assert!(ctx.update_meta(&client_id, expired_height).is_err()); + assert!(ctx.update_meta(&client_id, &expired_height).is_err()); assert!(ctx.consensus_state(&client_cons_state_path).is_err()); // Check that latest valid consensus state exists. @@ -158,7 +158,7 @@ fn test_consensus_state_pruning() { earliest_valid_height.revision_height(), ); - assert!(ctx.update_meta(&client_id, earliest_valid_height).is_ok()); + assert!(ctx.update_meta(&client_id, &earliest_valid_height).is_ok()); assert!(ctx.consensus_state(&client_cons_state_path).is_ok()); let end_host_timestamp = ctx.host_timestamp().unwrap(); diff --git a/ibc-testkit/tests/core/ics04_channel/acknowledgement.rs b/ibc-testkit/tests/core/ics04_channel/acknowledgement.rs index ead20652a..056936fd1 100644 --- a/ibc-testkit/tests/core/ics04_channel/acknowledgement.rs +++ b/ibc-testkit/tests/core/ics04_channel/acknowledgement.rs @@ -175,7 +175,7 @@ fn ack_success_happy_path(fixture: Fixture) { ); ctx.get_client_execution_context() .store_update_meta( - &ClientId::default(), + ClientId::default(), client_height, Timestamp::from_nanoseconds(1000).unwrap(), Height::new(0, 4).unwrap(), diff --git a/ibc-testkit/tests/core/ics04_channel/recv_packet.rs b/ibc-testkit/tests/core/ics04_channel/recv_packet.rs index ee4844767..773390f17 100644 --- a/ibc-testkit/tests/core/ics04_channel/recv_packet.rs +++ b/ibc-testkit/tests/core/ics04_channel/recv_packet.rs @@ -141,7 +141,7 @@ fn recv_packet_validate_happy_path(fixture: Fixture) { context .get_client_execution_context() .store_update_meta( - &ClientId::default(), + ClientId::default(), client_height, Timestamp::from_nanoseconds(1000).unwrap(), Height::new(0, 5).unwrap(), diff --git a/ibc-testkit/tests/core/ics04_channel/timeout.rs b/ibc-testkit/tests/core/ics04_channel/timeout.rs index f3f7cd109..55d964b68 100644 --- a/ibc-testkit/tests/core/ics04_channel/timeout.rs +++ b/ibc-testkit/tests/core/ics04_channel/timeout.rs @@ -204,7 +204,7 @@ fn timeout_fail_proof_timeout_not_reached(fixture: Fixture) { ); ctx.store_update_meta( - &ClientId::default(), + ClientId::default(), client_height, Timestamp::from_nanoseconds(5).unwrap(), Height::new(0, 4).unwrap(), @@ -286,7 +286,7 @@ fn timeout_unordered_channel_validate(fixture: Fixture) { ctx.get_client_execution_context() .store_update_meta( - &ClientId::default(), + ClientId::default(), client_height, Timestamp::from_nanoseconds(1000).unwrap(), Height::new(0, 5).unwrap(), @@ -335,7 +335,7 @@ fn timeout_ordered_channel_validate(fixture: Fixture) { ); ctx.store_update_meta( - &ClientId::default(), + ClientId::default(), client_height, Timestamp::from_nanoseconds(1000).unwrap(), Height::new(0, 4).unwrap(), diff --git a/ibc-testkit/tests/core/ics04_channel/timeout_on_close.rs b/ibc-testkit/tests/core/ics04_channel/timeout_on_close.rs index 23fcdf4e2..c0321e8b1 100644 --- a/ibc-testkit/tests/core/ics04_channel/timeout_on_close.rs +++ b/ibc-testkit/tests/core/ics04_channel/timeout_on_close.rs @@ -152,7 +152,7 @@ fn timeout_on_close_success_happy_path(fixture: Fixture) { context .get_client_execution_context() .store_update_meta( - &ClientId::default(), + ClientId::default(), Height::new(0, 2).unwrap(), Timestamp::from_nanoseconds(5000).unwrap(), Height::new(0, 5).unwrap(),