-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor: Decouple *Client
types from Any*
types
#60
Conversation
# Conflicts: # modules/src/core/ics04_channel/handler/verify.rs
*Client
types from Any*
types*Client
types from Any*
types
// Upgrade the client state | ||
self.latest_height = upgrade_height; | ||
self.unbonding_period = upgrade_options.unbonding_period; | ||
self.chain_id = chain_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does chain id change every time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. @Wizdave97 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it could, if the chain updates it's consensus mechanism or has a fork maybe.
Can you provide a high level description of the refactor? @vmarkushin |
Before i review vlad, can you delete the |
f7acdb9
to
bba9089
Compare
The final step for this pr will be to remove the |
9025718
to
72923bc
Compare
|
||
fn update_state_on_misbehaviour( | ||
&self, | ||
client_state: Self::ClientState, | ||
header: Self::Header, | ||
) -> Result<Self::ClientState, Error>; | ||
|
||
fn check_for_misbehaviour( | ||
fn check_for_misbehaviour<Ctx: ReaderContext>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is meant to be used when handling misbehaviour messages, we should refactor it to accept take header_1 && header_2, not just one header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think this necessary, because of how 02-client uses it:
ibc-rs/modules/src/core/ics02_client/handler/update_client.rs
Lines 85 to 107 in 04bdb0d
let found_misbehaviour = client_def | |
.check_for_misbehaviour(ctx, client_id.clone(), client_state.clone(), header.clone()) | |
.map_err(|e| Error::header_verification_failure(e.to_string()))?; | |
let event_attributes = Attributes { | |
client_id: client_id.clone(), | |
height: ctx.host_height(), | |
client_type, | |
consensus_height: client_state.latest_height(), | |
}; | |
if found_misbehaviour { | |
let client_state = client_def.update_state_on_misbehaviour(client_state, header)?; | |
let result = ClientResult::Update(Result { | |
client_id, | |
client_state, | |
consensus_state: None, | |
processed_time: ctx.host_timestamp(), | |
processed_height: ctx.host_height(), | |
}); | |
output.emit(IbcEvent::ClientMisbehaviour(event_attributes.into())); | |
return Ok(output.with_result(result)); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it seems client message should actually be an enum of either Header
or Misbehaviour
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it means it shouldn't be ClientDef::verify_header
but instead, it should be ClientDef::verify_client_message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wizdave97 can you make the necessary refactor on this PR?
The basic reason for this refactor is to be able to separate different IBC clients (Beefy, Near, etc.) from the
ibc-rs
crate itself. This wasn't possible due to the usage ofAny*
(AnyClient
,AnyConsensusState
, etc.) types highly coupled to the particular client implementation, so in order to do this one would need to abstract the clients on some global definition of theAny*
types. This is done by introducingAnyHeader
,AnyClientState
, etc. types in theClientKeeper
trait and passing it as a genericCtx
to most of the IBC and clients' functions.