Skip to content
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

test: tendermint client update when client expires or validator set has changed #921

Merged
merged 26 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1d78333
add client expiry test
rnbguy Oct 13, 2023
90b006d
tm hostblock supports trusted next validator set
rnbguy Oct 13, 2023
6039366
fix validator change update test
rnbguy Oct 13, 2023
a2163f1
fix incorrect validator updates at each block
rnbguy Oct 13, 2023
7dfc285
add sad client update for validator change
rnbguy Oct 13, 2023
78f5eda
cargo fmt
rnbguy Oct 13, 2023
89ffdbf
catch up with main branch changes
rnbguy Oct 16, 2023
2d90996
update MockContextConfig with validator set history
rnbguy Oct 16, 2023
ef774cc
refactor tests with updated MockContextConfig
rnbguy Oct 16, 2023
2750e90
rm duplicate def of `on`
rnbguy Oct 16, 2023
25b9b4d
add todo for max_history_size and validator_set_history
rnbguy Oct 16, 2023
f05537a
consistent variable naming in tests
rnbguy Oct 17, 2023
e827067
bump typed-builder version
rnbguy Oct 17, 2023
bf55a97
rm redundant builder arguments
rnbguy Oct 17, 2023
87196d3
replace todo with panic
rnbguy Oct 17, 2023
122a570
mv Tendermint ClientStateConfig under ics07
rnbguy Oct 17, 2023
7f7f79f
use ctx_a with ctx_b instead of only ctx
rnbguy Oct 17, 2023
eb8798c
use client_id consistently
rnbguy Oct 17, 2023
6b47dc7
use mocks feature directly in dev-deps
rnbguy Oct 17, 2023
f7cc801
include trusting_period and max_clock_drift in mock light client config
rnbguy Oct 18, 2023
0d2d642
revert advance chain height with timestamp
rnbguy Oct 18, 2023
3020a41
update client expiry test
rnbguy Oct 18, 2023
1d3bba8
add test to check max_clock_drift
rnbguy Oct 18, 2023
554ac48
rm TODO comments in favor of gh issue
rnbguy Oct 18, 2023
0da962b
revert ctx_a renaming
rnbguy Oct 18, 2023
57180f9
add changelog entry
rnbguy Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add test for expired client status.
([\#538](https://github.com/cosmos/ibc-rs/issues/538))
2 changes: 0 additions & 2 deletions .github/workflows/cw-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
paths:
- .github/workflows/cw-check.yml
- ci/cw-check/**

on:
push:
tags:
- v[0-9]+.*
Expand Down
6 changes: 3 additions & 3 deletions crates/ibc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ schema = ["dep:schemars", "serde", "std"]

# This feature grants access to development-time mocking libraries, such as `MockContext` or `MockHeader`.
# Depends on the `testgen` suite for generating Tendermint light blocks.
mocks = ["tendermint-testgen", "tendermint/clock", "parking_lot"]
mocks = ["tendermint-testgen", "tendermint/clock", "parking_lot", "typed-builder"]

[dependencies]
# Proto definitions for all IBC-related interfaces, e.g., connections or channels.
Expand All @@ -73,6 +73,7 @@ scale-info = { version = "2.1.2", default-features = false, features = ["derive"
## for borsh encode or decode
borsh = {version = "0.10", default-features = false, optional = true }
parking_lot = { version = "0.12.1", default-features = false, optional = true }
typed-builder = { version = "0.17.0", optional = true }

ibc-derive = { version ="0.3.0", path = "../ibc-derive" }

Expand Down Expand Up @@ -102,5 +103,4 @@ rstest = "0.18.1"
tracing-subscriber = { version = "0.3.14", features = ["fmt", "env-filter", "json"]}
test-log = { version = "0.2.10", features = ["trace"] }
tendermint-rpc = { version = "0.34", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "0.34" } # Needed for generating (synthetic) light blocks.
parking_lot = { version = "0.12.1" }
ibc = { path = ".", features = ["mocks"] }
41 changes: 40 additions & 1 deletion crates/ibc/src/clients/ics07_tendermint/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,8 @@ pub mod test_util {
use tendermint::block::Header;

use crate::clients::ics07_tendermint::client_state::{AllowUpdate, ClientState};
use crate::clients::ics07_tendermint::error::Error;
use crate::clients::ics07_tendermint::error::{Error as ClientError, Error};
use crate::clients::ics07_tendermint::trust_threshold::TrustThreshold;
use crate::core::ics02_client::height::Height;
use crate::core::ics23_commitment::specs::ProofSpecs;
use crate::core::ics24_host::identifier::ChainId;
Expand Down Expand Up @@ -1180,4 +1181,42 @@ pub mod test_util {
allow_update_after_misbehaviour: false,
}
}

#[derive(typed_builder::TypedBuilder, Debug)]
pub struct ClientStateConfig {
pub chain_id: ChainId,
#[builder(default)]
pub trust_level: TrustThreshold,
#[builder(default = Duration::from_secs(64000))]
pub trusting_period: Duration,
#[builder(default = Duration::from_secs(128000))]
pub unbonding_period: Duration,
#[builder(default = Duration::from_millis(3000))]
max_clock_drift: Duration,
pub latest_height: Height,
#[builder(default)]
pub proof_specs: ProofSpecs,
#[builder(default)]
pub upgrade_path: Vec<String>,
#[builder(default = AllowUpdate { after_expiry: false, after_misbehaviour: false })]
allow_update: AllowUpdate,
}

impl TryFrom<ClientStateConfig> for ClientState {
type Error = ClientError;

fn try_from(config: ClientStateConfig) -> Result<Self, Self::Error> {
ClientState::new(
config.chain_id,
config.trust_level,
config.trusting_period,
config.unbonding_period,
config.max_clock_drift,
config.latest_height,
config.proof_specs,
config.upgrade_path,
config.allow_update,
)
}
}
}
3 changes: 2 additions & 1 deletion crates/ibc/src/clients/ics07_tendermint/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,14 @@ pub mod test_util {
fn from(light_block: SyntheticTmBlock) -> Self {
let SyntheticTmBlock {
trusted_height,
trusted_next_validators,
light_block,
} = light_block;
Self {
signed_header: light_block.signed_header,
validator_set: light_block.validators,
trusted_height,
trusted_next_validator_set: light_block.next_validators,
trusted_next_validator_set: trusted_next_validators,
}
}
}
Expand Down
Loading