Skip to content

Commit

Permalink
Update to tendermint-rs v0.21.0 (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
romac authored Jul 21, 2021
1 parent d139f47 commit a0d9d4b
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 49 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ subtle-encoding = "0.5"
sha2 = { version = "0.9.3", optional = true }

[dependencies.tendermint]
version = "=0.20.0"
version = "=0.21.0"

[dependencies.tendermint-proto]
version = "=0.20.0"
version = "=0.21.0"

[dependencies.tendermint-testgen]
version = "=0.20.0"
version = "=0.21.0"
optional = true

[dev-dependencies]
env_logger = "0.9.0"
tracing-subscriber = "0.2.19"
test-env-log = { version = "0.2.7", features = ["trace"] }
modelator = { git = "https://github.com/informalsystems/modelator", rev = "99f656fa8b3cf46a2aa0b6513e4e140d1778c4bd" }
tendermint-rpc = { version = "=0.20.0", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "=0.20.0" } # Needed for generating (synthetic) light blocks.
tendermint-rpc = { version = "=0.21.0", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "=0.21.0" } # Needed for generating (synthetic) light blocks.
sha2 = { version = "0.9.3" }

[[test]]
Expand Down
5 changes: 1 addition & 4 deletions modules/src/ics02_client/handler/create_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,7 @@ mod tests {

let tm_client_state = AnyClientState::Tendermint(ClientState {
chain_id: tm_header.chain_id.clone().into(),
trust_level: TrustThreshold {
numerator: 1,
denominator: 3,
},
trust_level: TrustThreshold::ONE_THIRD,
trusting_period: Duration::from_secs(64000),
unbonding_period: Duration::from_secs(128000),
max_clock_drift: Duration::from_millis(3000),
Expand Down
20 changes: 6 additions & 14 deletions modules/src/ics07_tendermint/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ impl ClientState {
/// Resets all fields except the blockchain-specific ones.
pub fn zero_custom_fields(mut client_state: Self) -> Self {
client_state.trusting_period = ZERO_DURATION;
client_state.trust_level = TrustThresholdFraction {
numerator: 0,
denominator: 0,
};
client_state.trust_level = TrustThresholdFraction::default();
client_state.allow_update.after_expiry = false;
client_state.allow_update.after_misbehaviour = false;
client_state.frozen_height = Height::zero();
Expand Down Expand Up @@ -173,10 +170,8 @@ impl TryFrom<RawClientState> for ClientState {
Ok(Self {
chain_id: ChainId::from_str(raw.chain_id.as_str())
.map_err(|_| Kind::InvalidRawClientState.context("Invalid chain identifier"))?,
trust_level: TrustThreshold {
numerator: trust_level.numerator,
denominator: trust_level.denominator,
},
trust_level: TrustThreshold::new(trust_level.numerator, trust_level.denominator)
.map_err(|e| Kind::InvalidTrustThreshold.context(e))?,
trusting_period: raw
.trusting_period
.ok_or_else(|| Kind::InvalidRawClientState.context("missing trusting period"))?
Expand Down Expand Up @@ -216,8 +211,8 @@ impl From<ClientState> for RawClientState {
RawClientState {
chain_id: value.chain_id.to_string(),
trust_level: Some(Fraction {
numerator: value.trust_level.numerator,
denominator: value.trust_level.denominator,
numerator: value.trust_level.numerator(),
denominator: value.trust_level.denominator(),
}),
trusting_period: Some(value.trusting_period.into()),
unbonding_period: Some(value.unbonding_period.into()),
Expand Down Expand Up @@ -279,10 +274,7 @@ mod tests {
// Define a "default" set of parameters to reuse throughout these tests.
let default_params: ClientStateParams = ClientStateParams {
id: ChainId::default(),
trust_level: TrustThreshold {
numerator: 1,
denominator: 3,
},
trust_level: TrustThreshold::ONE_THIRD,
trusting_period: Duration::new(64000, 0),
unbonding_period: Duration::new(128000, 0),
max_clock_drift: Duration::new(3, 0),
Expand Down
3 changes: 3 additions & 0 deletions modules/src/ics07_tendermint/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pub enum Kind {
#[error("invalid trusting period")]
InvalidTrustingPeriod,

#[error("invalid client state trust threshold")]
InvalidTrustThreshold,

#[error("invalid unbonding period")]
InvalidUnboundingPeriod,

Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics07_tendermint/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ pub mod test_util {
281_815_u64.try_into().unwrap(),
);

let vs = ValidatorSet::new(vec![v1], Some(v1));
let vs = ValidatorSet::new(vec![v1.clone()], Some(v1));

Header {
signed_header: shdr,
Expand Down
3 changes: 2 additions & 1 deletion modules/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ pub fn default_consensus_params() -> consensus::Params {
consensus::Params {
block: block::Size {
max_bytes: 22020096,
max_gas: -1, // Tendetmint-go also has TimeIotaMs: 1000, // 1s
max_gas: -1,
time_iota_ms: 1000,
},
evidence: evidence::Params {
max_age_num_blocks: 100000,
Expand Down
2 changes: 1 addition & 1 deletion proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ thiserror = "1.0"
tonic = "0.4"

[dependencies.tendermint-proto]
version = "=0.20.0"
version = "=0.21.0"
8 changes: 4 additions & 4 deletions relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ atty = "0.2.14"
signal-hook = "0.3.9"

[dependencies.tendermint-proto]
version = "=0.20.0"
version = "=0.21.0"

[dependencies.tendermint]
version = "=0.20.0"
version = "=0.21.0"

[dependencies.tendermint-rpc]
version = "=0.20.0"
version = "=0.21.0"
features = ["http-client", "websocket-client"]

[dependencies.tendermint-light-client]
version = "=0.20.0"
version = "=0.21.0"
features = ["unstable"]

[dependencies.abscissa_core]
Expand Down
6 changes: 3 additions & 3 deletions relayer-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ pub fn validate_config(config: &Config) -> Result<(), Error> {
/// b) greater or equal to 1/3
/// c) strictly less than 1
fn validate_trust_threshold(id: &ChainId, trust_threshold: TrustThreshold) -> Result<(), Error> {
if trust_threshold.denominator == 0 {
if trust_threshold.denominator() == 0 {
return Err(Error::InvalidTrustThreshold(
trust_threshold,
id.clone(),
"trust threshold denominator cannot be zero".to_string(),
));
}

if trust_threshold.numerator * 3 < trust_threshold.denominator {
if trust_threshold.numerator() * 3 < trust_threshold.denominator() {
return Err(Error::InvalidTrustThreshold(
trust_threshold,
id.clone(),
"trust threshold cannot be < 1/3".to_string(),
));
}

if trust_threshold.numerator >= trust_threshold.denominator {
if trust_threshold.numerator() >= trust_threshold.denominator() {
return Err(Error::InvalidTrustThreshold(
trust_threshold,
id.clone(),
Expand Down
10 changes: 5 additions & 5 deletions relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ fraction = {version = "0.8.0", default-features = false }
semver = "1.0"

[dependencies.tendermint]
version = "=0.20.0"
version = "=0.21.0"

[dependencies.tendermint-rpc]
version = "=0.20.0"
version = "=0.21.0"
features = ["http-client", "websocket-client"]

[dependencies.tendermint-light-client]
version = "=0.20.0"
version = "=0.21.0"
features = ["unstable"]

[dependencies.tendermint-proto]
version = "=0.20.0"
version = "=0.21.0"

[dev-dependencies]
ibc = { version = "0.6.0", path = "../modules", features = ["mocks"] }
Expand All @@ -79,4 +79,4 @@ tracing-subscriber = "0.2.19"
test-env-log = { version = "0.2.7", features = ["trace"] }

# Needed for generating (synthetic) light blocks.
tendermint-testgen = { version = "=0.20.0" }
tendermint-testgen = { version = "=0.21.0" }
3 changes: 2 additions & 1 deletion relayer/src/supervisor/client_state_filter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use anomaly::BoxError;
use tendermint_light_client::types::TrustThreshold;
use tracing::{debug, trace};

use ibc::ics02_client::client_state::{AnyClientState, ClientState};
Expand Down Expand Up @@ -129,7 +130,7 @@ impl FilterPolicy {
}

let permission = match state.trust_threshold() {
Some(trust) if trust.numerator == 1 && trust.denominator == 3 => Permission::Allow,
Some(trust) if trust == TrustThreshold::ONE_THIRD => Permission::Allow,
Some(_) => {
trace!(
"[client filter] client {} on chain {} has a trust threshold different than 1/3",
Expand Down

0 comments on commit a0d9d4b

Please sign in to comment.