Skip to content

Commit caee889

Browse files
fix: be consistent with where arguments own and where they borrow (#1072)
1 parent 0c1e8a9 commit caee889

File tree

11 files changed

+44
-24
lines changed

11 files changed

+44
-24
lines changed

ibc-clients/ics07-tendermint/src/client_state.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,12 @@ where
336336
),
337337
tm_consensus_state.into(),
338338
)?;
339-
ctx.store_update_meta(client_id, self.latest_height(), host_timestamp, host_height)?;
339+
ctx.store_update_meta(
340+
client_id.clone(),
341+
self.latest_height(),
342+
host_timestamp,
343+
host_height,
344+
)?;
340345

341346
Ok(())
342347
}
@@ -386,7 +391,12 @@ where
386391
ClientStatePath::new(client_id),
387392
ClientState::from(new_client_state).into(),
388393
)?;
389-
ctx.store_update_meta(client_id, header_height, host_timestamp, host_height)?;
394+
ctx.store_update_meta(
395+
client_id.clone(),
396+
header_height,
397+
host_timestamp,
398+
host_height,
399+
)?;
390400
}
391401

392402
Ok(vec![header_height])
@@ -481,7 +491,12 @@ where
481491
),
482492
TmConsensusState::from(new_consensus_state).into(),
483493
)?;
484-
ctx.store_update_meta(client_id, latest_height, host_timestamp, host_height)?;
494+
ctx.store_update_meta(
495+
client_id.clone(),
496+
latest_height,
497+
host_timestamp,
498+
host_height,
499+
)?;
485500

486501
Ok(latest_height)
487502
}

ibc-clients/ics07-tendermint/src/client_state/update_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl ClientState {
220220
break;
221221
}
222222
ctx.delete_consensus_state(client_consensus_state_path)?;
223-
ctx.delete_update_meta(client_id, height)?;
223+
ctx.delete_update_meta(client_id.clone(), height)?;
224224
}
225225

226226
Ok(())

ibc-core/ics02-client/context/src/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub trait ClientValidationContext {
1717
fn update_meta(
1818
&self,
1919
client_id: &ClientId,
20-
height: Height,
20+
height: &Height,
2121
) -> Result<(Timestamp, Height), ContextError>;
2222
}
2323

@@ -60,7 +60,7 @@ pub trait ClientExecutionContext: Sized {
6060
/// and height as the time at which this update (or header) was processed.
6161
fn store_update_meta(
6262
&mut self,
63-
client_id: &ClientId,
63+
client_id: ClientId,
6464
height: Height,
6565
host_timestamp: Timestamp,
6666
host_height: Height,
@@ -75,7 +75,7 @@ pub trait ClientExecutionContext: Sized {
7575
/// Note that this timestamp is determined by the host.
7676
fn delete_update_meta(
7777
&mut self,
78-
client_id: &ClientId,
78+
client_id: ClientId,
7979
height: Height,
8080
) -> Result<(), ContextError>;
8181
}

ibc-core/ics03-connection/src/delay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
let client_id = connection_end.client_id();
2222
let last_client_update = ctx
2323
.get_client_validation_context()
24-
.update_meta(client_id, packet_proof_height)?;
24+
.update_meta(client_id, &packet_proof_height)?;
2525

2626
// Fetch the connection delay time and height periods.
2727
let conn_delay_time_period = connection_end.delay_period();

ibc-testkit/src/testapp/ibc/clients/mock/client_state.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ where
351351
)?;
352352
ctx.store_client_state(ClientStatePath::new(client_id), new_client_state.into())?;
353353
ctx.store_update_meta(
354-
client_id,
354+
client_id.clone(),
355355
header_height,
356356
ctx.host_timestamp()?,
357357
ctx.host_height()?,
@@ -399,7 +399,12 @@ where
399399
let host_timestamp = ctx.host_timestamp()?;
400400
let host_height = ctx.host_height()?;
401401

402-
ctx.store_update_meta(client_id, latest_height, host_timestamp, host_height)?;
402+
ctx.store_update_meta(
403+
client_id.clone(),
404+
latest_height,
405+
host_timestamp,
406+
host_height,
407+
)?;
403408

404409
Ok(latest_height)
405410
}

ibc-testkit/src/testapp/ibc/core/client_ctx.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ impl ClientValidationContext for MockContext {
159159
fn update_meta(
160160
&self,
161161
client_id: &ClientId,
162-
height: Height,
162+
height: &Height,
163163
) -> Result<(Timestamp, Height), ContextError> {
164-
let key = (client_id.clone(), height);
164+
let key = (client_id.clone(), *height);
165165
(|| {
166166
let ibc_store = self.ibc_store.lock();
167167
let time = ibc_store.client_processed_times.get(&key)?;
@@ -170,7 +170,7 @@ impl ClientValidationContext for MockContext {
170170
})()
171171
.ok_or(ClientError::UpdateMetaDataNotFound {
172172
client_id: key.0,
173-
height,
173+
height: key.1,
174174
})
175175
.map_err(ContextError::from)
176176
}
@@ -256,7 +256,7 @@ impl ClientExecutionContext for MockContext {
256256

257257
fn delete_update_meta(
258258
&mut self,
259-
client_id: &ClientId,
259+
client_id: ClientId,
260260
height: Height,
261261
) -> Result<(), ContextError> {
262262
let key = (client_id.clone(), height);
@@ -268,7 +268,7 @@ impl ClientExecutionContext for MockContext {
268268

269269
fn store_update_meta(
270270
&mut self,
271-
client_id: &ClientId,
271+
client_id: ClientId,
272272
height: Height,
273273
host_timestamp: Timestamp,
274274
host_height: Height,
@@ -279,7 +279,7 @@ impl ClientExecutionContext for MockContext {
279279
.insert((client_id.clone(), height), host_timestamp);
280280
ibc_store
281281
.client_processed_heights
282-
.insert((client_id.clone(), height), host_height);
282+
.insert((client_id, height), host_height);
283283
Ok(())
284284
}
285285
}

ibc-testkit/tests/core/ics02_client/update_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn test_consensus_state_pruning() {
147147
expired_height.revision_number(),
148148
expired_height.revision_height(),
149149
);
150-
assert!(ctx.update_meta(&client_id, expired_height).is_err());
150+
assert!(ctx.update_meta(&client_id, &expired_height).is_err());
151151
assert!(ctx.consensus_state(&client_cons_state_path).is_err());
152152

153153
// Check that latest valid consensus state exists.
@@ -158,7 +158,7 @@ fn test_consensus_state_pruning() {
158158
earliest_valid_height.revision_height(),
159159
);
160160

161-
assert!(ctx.update_meta(&client_id, earliest_valid_height).is_ok());
161+
assert!(ctx.update_meta(&client_id, &earliest_valid_height).is_ok());
162162
assert!(ctx.consensus_state(&client_cons_state_path).is_ok());
163163

164164
let end_host_timestamp = ctx.host_timestamp().unwrap();

ibc-testkit/tests/core/ics04_channel/acknowledgement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn ack_success_happy_path(fixture: Fixture) {
175175
);
176176
ctx.get_client_execution_context()
177177
.store_update_meta(
178-
&ClientId::default(),
178+
ClientId::default(),
179179
client_height,
180180
Timestamp::from_nanoseconds(1000).unwrap(),
181181
Height::new(0, 4).unwrap(),

ibc-testkit/tests/core/ics04_channel/recv_packet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn recv_packet_validate_happy_path(fixture: Fixture) {
141141
context
142142
.get_client_execution_context()
143143
.store_update_meta(
144-
&ClientId::default(),
144+
ClientId::default(),
145145
client_height,
146146
Timestamp::from_nanoseconds(1000).unwrap(),
147147
Height::new(0, 5).unwrap(),

ibc-testkit/tests/core/ics04_channel/timeout.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn timeout_fail_proof_timeout_not_reached(fixture: Fixture) {
204204
);
205205

206206
ctx.store_update_meta(
207-
&ClientId::default(),
207+
ClientId::default(),
208208
client_height,
209209
Timestamp::from_nanoseconds(5).unwrap(),
210210
Height::new(0, 4).unwrap(),
@@ -286,7 +286,7 @@ fn timeout_unordered_channel_validate(fixture: Fixture) {
286286

287287
ctx.get_client_execution_context()
288288
.store_update_meta(
289-
&ClientId::default(),
289+
ClientId::default(),
290290
client_height,
291291
Timestamp::from_nanoseconds(1000).unwrap(),
292292
Height::new(0, 5).unwrap(),
@@ -335,7 +335,7 @@ fn timeout_ordered_channel_validate(fixture: Fixture) {
335335
);
336336

337337
ctx.store_update_meta(
338-
&ClientId::default(),
338+
ClientId::default(),
339339
client_height,
340340
Timestamp::from_nanoseconds(1000).unwrap(),
341341
Height::new(0, 4).unwrap(),

ibc-testkit/tests/core/ics04_channel/timeout_on_close.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ fn timeout_on_close_success_happy_path(fixture: Fixture) {
152152
context
153153
.get_client_execution_context()
154154
.store_update_meta(
155-
&ClientId::default(),
155+
ClientId::default(),
156156
Height::new(0, 2).unwrap(),
157157
Timestamp::from_nanoseconds(5000).unwrap(),
158158
Height::new(0, 5).unwrap(),

0 commit comments

Comments
 (0)