-
Notifications
You must be signed in to change notification settings - Fork 329
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
Use custom options of the create client
command
#2004
Merged
Merged
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
3883068
Rework of CreateParams -> ClientOptions
mzabaluev db563e4
Split CreateOptions and ClientSettings
mzabaluev abbd4dc
Update docs in relayer/src/chain/client.rs
mzabaluev 25665be
Improve help for --clock-drift
mzabaluev 22a77c1
Merge branch 'mikhail/create-client-options' of github.com:informalsy…
mzabaluev b661a55
Rework ClientSettings
mzabaluev 2acb458
Merge branch 'master' into mikhail/create-client-options
mzabaluev 08748ee
Builder pattern for foreign client tests
mzabaluev f18a9c1
Add client setting overrides to the test framework
mzabaluev e4ba706
Draft test for custom client settings
mzabaluev db8f60f
Fix clippy lints
mzabaluev 5745837
Merge branch 'master' into mikhail/create-client-options
mzabaluev df321e6
Post-merge fixes
mzabaluev a75d880
client_settings test: query state of the client
mzabaluev f8f7d92
Make client_settings test work
mzabaluev fe2fe9f
Merge branch 'master' into mikhail/create-client-options
mzabaluev 9d4b8cf
Clean up client_settings test
mzabaluev 658ee0d
Add a test for default client settings
mzabaluev a2d6688
Use the IBC TrustThreshold type in client settings
mzabaluev 29e891c
Merge branch 'master' into mikhail/create-client-options
mzabaluev 67ffff4
Warn when client clock drift exceeds max_block_time
mzabaluev 7e45352
Changelog entry for #2004
mzabaluev 4c76c3a
Simplify overrides for ClientSettingsTest
mzabaluev f068c16
integration-test: Remove an unused structure
mzabaluev 9df0cba
relayer: Sanitize imports in mod chain
mzabaluev 009d1dd
Split client command options from client settings
mzabaluev d4ed916
Rename ClientSettings::Cosmos -> Tendermint
mzabaluev 75d60a7
Fix clippy lint
mzabaluev 5c3bef4
Merge branch 'master' into mikhail/create-client-options
mzabaluev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//! Data structures and logic to set up IBC client's parameters. | ||
|
||
use crate::chain::cosmos; | ||
use crate::config::ChainConfig; | ||
|
||
/// Client parameters for the `build_create_client` operation. | ||
/// | ||
/// The parameters are specialized for each supported chain type. | ||
#[derive(Clone, Debug)] | ||
pub enum ClientSettings { | ||
Cosmos(cosmos::client::Settings), | ||
} | ||
|
||
impl ClientSettings { | ||
/// Fills in some settings if they have not been specified, | ||
/// using the configuration of the source and the destination chain. | ||
pub fn fill_in_from_chain_configs( | ||
&mut self, | ||
src_chain_config: &ChainConfig, | ||
dst_chain_config: &ChainConfig, | ||
) { | ||
use ClientSettings::*; | ||
|
||
match self { | ||
Cosmos(config) => config.fill_in_from_chain_configs(src_chain_config, dst_chain_config), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//! Cosmos-specific client settings. | ||
|
||
use core::time::Duration; | ||
|
||
use tendermint_light_client_verifier::types::TrustThreshold; | ||
|
||
use crate::config::ChainConfig; | ||
|
||
/// Cosmos-specific client parameters for the `build_create_client` operation. | ||
/// If set, the options override the defaults taken from the source chain configuration. | ||
#[derive(Clone, Debug, Default)] | ||
pub struct Settings { | ||
pub max_clock_drift: Option<Duration>, | ||
pub trusting_period: Option<Duration>, | ||
pub trust_threshold: Option<TrustThreshold>, | ||
} | ||
|
||
impl Settings { | ||
pub fn fill_in_from_chain_configs( | ||
&mut self, | ||
src_chain_config: &ChainConfig, | ||
dst_chain_config: &ChainConfig, | ||
) { | ||
if self.max_clock_drift.is_none() { | ||
self.max_clock_drift = Some(calculate_client_state_drift( | ||
&src_chain_config, | ||
&dst_chain_config, | ||
)); | ||
} | ||
} | ||
} | ||
|
||
/// The client state clock drift must account for destination | ||
/// chain block frequency and clock drift on source and dest. | ||
/// https://github.com/informalsystems/ibc-rs/issues/1445 | ||
fn calculate_client_state_drift( | ||
src_chain_config: &ChainConfig, | ||
dst_chain_config: &ChainConfig, | ||
) -> Duration { | ||
src_chain_config.clock_drift + dst_chain_config.clock_drift + dst_chain_config.max_block_time | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Neat!
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'm not sure if
Cosmos
orTendermint
is the right name to use here.AnyClientState
usesTendermint
, maybe we should use it here too for consistency?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 is a very good point.
Tendermint
is more appropriate thanCosmos
.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.
OTOH the module hierarchy under
chain
usescosmos
. This is a relayer API anyway, so we don't have to be super-diligent.