-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Organize host chain methods under a new HostChainContext
trait
#386
Conversation
validate
method for client state interfacevalidate
method on client state interface
Codecov ReportBase: 55.63% // Head: 55.94% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #386 +/- ##
==========================================
+ Coverage 55.63% 55.94% +0.31%
==========================================
Files 122 122
Lines 16996 17103 +107
==========================================
+ Hits 9455 9568 +113
+ Misses 7541 7535 -6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
validate
method on client state interfaceHostChainContext
trait
What do you mean by "chain-specific arguments and returns"? As designed, |
counterparty_client_state: Any, | ||
) -> Result<(), HostError> | ||
where | ||
Ctx: HostChainContext, |
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.
ValidateSelfClientContext
is designed to ask for an implementation of all the methods that it needs in its implementation; some only implementable by Tendermint hosts (such as unbonding_period()
). I believe this is the root cause for why you had to change the signature to Option<Duration>
; not all hosts can implement it.
This is why I don't think it is appropriate for ValidationContext
to have HostChainContext
as a supertrait. Hypothetically, say we also provided the implementation of validate_self_client()
for NEAR hosts; would we need to have that Context
be a supertrait of ValidationContext
as well, requiring all hosts to implement NEAR-specific methods (and have the signature return an Option
for those too)?
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 understand your concern, but rather than the unbonding_period()
method, which I also found it there to be a wart, other methods should be available by any chain
let host_height = self.host_height()?; | ||
let host_consensus_state = self.host_consensus_state(&host_height)?; | ||
Ok(host_consensus_state.timestamp()) |
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 think we can assume that this will work for all hosts. Basecoin-rs is an example: we added pending_host_consensus_state()
because host_consensus_state()
was not quite right. I think it should simply be made abstract; each host can implement it however they see fit. We should do it in a separate PR though to keep PRs as self-contained as possible.
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.
Actually, moving the host_timestamp()
methods brought a need to handle them here. but, sure alright.
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.
what do you mean by "moving the host_timestamp()
methods brought a need to handle them here"?
For a clearer picture of where it's instantiated, consider the below grouping:
|
The idea had the aim of demonstrating how it could make implementation smoother, but looking at your comment, if it's not going to make it easier for us, then it wouldn't work for that purpose. |
Closing as discussed in sync meeting. |
Closes: #384 , #418
Description
Following the discussion around client state validation methods that check parameters (fields) of the client state implementation. After a bit of thought, I came up with an idea (around
validate_self_client
) of combining all host-related methods under a single chain called "HostChainContext" and separating related host errors under the "HostError" enum, plus added some docstrings.These methods do not have chain-specific arguments and returns, so ideally, any chain should be able to provide them.
There just remains one small cavity. Having the "unbonding_period" method in it, which looks more of Tendermint chains. Couldn't find a better way at the moment, and I addressed it by changing the return type into the
Option<Duration>
Note: The change in this PR is also connected to #418. That should have been handled here, hopefully.
PR author checklist:
unclog
.docs/
).Reviewer checklist:
Files changed
in the GitHub PR explorer.