1
1
use ibc_client_tendermint_types:: {
2
2
ClientState as ClientStateType , ConsensusState as ConsensusStateType , Header as TmHeader ,
3
3
} ;
4
- use ibc_core_client:: context:: client_state:: ClientStateExecution ;
5
- use ibc_core_client:: context:: ClientExecutionContext ;
4
+ use ibc_core_client:: context:: prelude:: * ;
6
5
use ibc_core_client:: types:: error:: ClientError ;
7
6
use ibc_core_client:: types:: Height ;
8
7
use ibc_core_host:: types:: identifiers:: ClientId ;
9
8
use ibc_core_host:: types:: path:: { ClientConsensusStatePath , ClientStatePath } ;
10
- use ibc_core_host:: ExecutionContext ;
11
9
use ibc_primitives:: prelude:: * ;
12
10
use ibc_primitives:: proto:: Any ;
13
11
14
12
use super :: ClientState ;
15
- use crate :: consensus_state:: ConsensusState as TmConsensusState ;
16
- use crate :: context:: { CommonContext , ExecutionContext as TmExecutionContext } ;
13
+ use crate :: context:: {
14
+ ConsensusStateConverter , ExecutionContext as TmExecutionContext ,
15
+ ValidationContext as TmValidationContext ,
16
+ } ;
17
17
18
18
impl < E > ClientStateExecution < E > for ClientState
19
19
where
20
- E : TmExecutionContext + ExecutionContext ,
21
- < E as ClientExecutionContext > :: AnyClientState : From < ClientStateType > ,
22
- < E as ClientExecutionContext > :: AnyConsensusState : From < ConsensusStateType > ,
20
+ E : TmExecutionContext ,
21
+ E :: ClientStateRef : From < ClientStateType > ,
22
+ E :: ConsensusStateRef : ConsensusStateConverter ,
23
23
{
24
24
fn initialise (
25
25
& self ,
@@ -77,12 +77,12 @@ pub fn initialise<E>(
77
77
consensus_state : Any ,
78
78
) -> Result < ( ) , ClientError >
79
79
where
80
- E : TmExecutionContext + ExecutionContext ,
81
- < E as ClientExecutionContext > :: AnyClientState : From < ClientStateType > ,
82
- < E as ClientExecutionContext > :: AnyConsensusState : From < ConsensusStateType > ,
80
+ E : TmExecutionContext ,
81
+ E :: ClientStateRef : From < ClientStateType > ,
82
+ E :: ConsensusStateRef : ConsensusStateConverter ,
83
83
{
84
- let host_timestamp = CommonContext :: host_timestamp ( ctx) ?;
85
- let host_height = CommonContext :: host_height ( ctx) ?;
84
+ let host_timestamp = TmValidationContext :: host_timestamp ( ctx) ?;
85
+ let host_height = TmValidationContext :: host_height ( ctx) ?;
86
86
87
87
let tm_consensus_state = ConsensusStateType :: try_from ( consensus_state) ?;
88
88
@@ -122,9 +122,9 @@ pub fn update_state<E>(
122
122
header : Any ,
123
123
) -> Result < Vec < Height > , ClientError >
124
124
where
125
- E : TmExecutionContext + ExecutionContext ,
126
- < E as ClientExecutionContext > :: AnyClientState : From < ClientStateType > ,
127
- < E as ClientExecutionContext > :: AnyConsensusState : From < ConsensusStateType > ,
125
+ E : TmExecutionContext ,
126
+ E :: ClientStateRef : From < ClientStateType > ,
127
+ E :: ConsensusStateRef : ConsensusStateConverter ,
128
128
{
129
129
let header = TmHeader :: try_from ( header) ?;
130
130
let header_height = header. height ( ) ;
@@ -138,7 +138,7 @@ where
138
138
header_height. revision_height ( ) ,
139
139
) ;
140
140
141
- CommonContext :: consensus_state ( ctx , & path_at_header_height) . ok ( )
141
+ ctx . consensus_state ( & path_at_header_height) . ok ( )
142
142
} ;
143
143
144
144
if maybe_existing_consensus_state. is_some ( ) {
@@ -147,8 +147,8 @@ where
147
147
//
148
148
// Do nothing.
149
149
} else {
150
- let host_timestamp = CommonContext :: host_timestamp ( ctx) ?;
151
- let host_height = CommonContext :: host_height ( ctx) ?;
150
+ let host_timestamp = TmValidationContext :: host_timestamp ( ctx) ?;
151
+ let host_height = TmValidationContext :: host_height ( ctx) ?;
152
152
153
153
let new_consensus_state = ConsensusStateType :: from ( header. clone ( ) ) ;
154
154
let new_client_state = client_state. clone ( ) . with_header ( header) ?;
@@ -189,9 +189,9 @@ pub fn update_on_misbehaviour<E>(
189
189
_client_message : Any ,
190
190
) -> Result < ( ) , ClientError >
191
191
where
192
- E : TmExecutionContext + ExecutionContext ,
193
- < E as ClientExecutionContext > :: AnyClientState : From < ClientStateType > ,
194
- < E as ClientExecutionContext > :: AnyConsensusState : From < ConsensusStateType > ,
192
+ E : TmExecutionContext ,
193
+ E :: ClientStateRef : From < ClientStateType > ,
194
+ E :: ConsensusStateRef : ConsensusStateConverter ,
195
195
{
196
196
// NOTE: frozen height is set to `Height {revision_height: 0,
197
197
// revision_number: 1}` and it is the same for all misbehaviour. This
@@ -221,12 +221,12 @@ pub fn update_on_upgrade<E>(
221
221
upgraded_consensus_state : Any ,
222
222
) -> Result < Height , ClientError >
223
223
where
224
- E : TmExecutionContext + ExecutionContext ,
225
- < E as ClientExecutionContext > :: AnyClientState : From < ClientStateType > ,
226
- < E as ClientExecutionContext > :: AnyConsensusState : From < ConsensusStateType > ,
224
+ E : TmExecutionContext ,
225
+ E :: ClientStateRef : From < ClientStateType > ,
226
+ E :: ConsensusStateRef : ConsensusStateConverter ,
227
227
{
228
228
let mut upgraded_tm_client_state = ClientState :: try_from ( upgraded_client_state) ?;
229
- let upgraded_tm_cons_state = TmConsensusState :: try_from ( upgraded_consensus_state) ?;
229
+ let upgraded_tm_cons_state = ConsensusStateType :: try_from ( upgraded_consensus_state) ?;
230
230
231
231
upgraded_tm_client_state. 0 . zero_custom_fields ( ) ;
232
232
@@ -263,12 +263,12 @@ where
263
263
let new_consensus_state = ConsensusStateType :: new (
264
264
sentinel_root. into ( ) ,
265
265
upgraded_tm_cons_state. timestamp ( ) ,
266
- upgraded_tm_cons_state. next_validators_hash ( ) ,
266
+ upgraded_tm_cons_state. next_validators_hash ,
267
267
) ;
268
268
269
269
let latest_height = new_client_state. latest_height ;
270
- let host_timestamp = CommonContext :: host_timestamp ( ctx) ?;
271
- let host_height = CommonContext :: host_height ( ctx) ?;
270
+ let host_timestamp = TmValidationContext :: host_timestamp ( ctx) ?;
271
+ let host_height = TmValidationContext :: host_height ( ctx) ?;
272
272
273
273
ctx. store_client_state (
274
274
ClientStatePath :: new ( client_id. clone ( ) ) ,
@@ -301,7 +301,9 @@ pub fn prune_oldest_consensus_state<E>(
301
301
client_id : & ClientId ,
302
302
) -> Result < ( ) , ClientError >
303
303
where
304
- E : ClientExecutionContext + CommonContext ,
304
+ E : ClientExecutionContext + TmValidationContext ,
305
+ E :: ClientStateRef : From < ClientStateType > ,
306
+ E :: ConsensusStateRef : ConsensusStateConverter ,
305
307
{
306
308
let mut heights = ctx. consensus_state_heights ( client_id) ?;
307
309
@@ -313,12 +315,8 @@ where
313
315
height. revision_number ( ) ,
314
316
height. revision_height ( ) ,
315
317
) ;
316
- let consensus_state = CommonContext :: consensus_state ( ctx, & client_consensus_state_path) ?;
317
- let tm_consensus_state = consensus_state
318
- . try_into ( )
319
- . map_err ( |err| ClientError :: Other {
320
- description : err. to_string ( ) ,
321
- } ) ?;
318
+ let consensus_state = ctx. consensus_state ( & client_consensus_state_path) ?;
319
+ let tm_consensus_state = consensus_state. try_into ( ) ?;
322
320
323
321
let host_timestamp =
324
322
ctx. host_timestamp ( ) ?
0 commit comments