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

Release v0.48.0: addendum #982

Merged
merged 3 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 21 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
[workspace]
resolver = "2"
# members sorted by publishing order to `crates.io`
members = [
"ibc",
"ibc-data-types",
"ibc-primitives",
"ibc-core",
"ibc-clients",
"ibc-apps",
"ibc-testkit",
"ibc-query",
"ibc-derive",
"ibc-core/ics02-client",
"ibc-primitives",
"ibc-core/ics24-host/types",
"ibc-core/ics26-routing/types",
"ibc-core/ics23-commitment/types",
"ibc-core/ics02-client/types",
"ibc-core/ics03-connection",
"ibc-core/ics03-connection/types",
"ibc-core/ics04-channel",
"ibc-core/ics04-channel/types",
"ibc-core/ics23-commitment/types",
"ibc-core/ics24-host",
"ibc-core/ics24-host/types",
"ibc-core/ics24-host/cosmos",
"ibc-core/ics25-handler",
"ibc-core/ics25-handler/types",
"ibc-core/ics02-client/context",
"ibc-core/ics24-host",
"ibc-core/ics26-routing",
"ibc-core/ics26-routing/types",
"ibc-clients/ics07-tendermint",
"ibc-core/ics02-client",
"ibc-core/ics03-connection",
"ibc-core/ics04-channel",
"ibc-core/ics25-handler",
"ibc-core",
"ibc-clients/ics07-tendermint/types",
"ibc-apps/ics20-transfer",
"ibc-clients/ics07-tendermint",
"ibc-clients",
"ibc-core/ics24-host/cosmos",
"ibc-apps/ics20-transfer/types",
"ibc-apps/ics20-transfer",
"ibc-apps",
"ibc-data-types",
"ibc",
"ibc-query",
"ibc-testkit",
]
exclude = [
"ci/cw-check",
Expand Down
5 changes: 2 additions & 3 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

## Releases

Our release process is as follows:
Expand Down Expand Up @@ -33,8 +32,8 @@ Our release process is as follows:
work. Fix any potential issues here and push them to the release PR.
7. Mark the PR as **Ready for Review** and incorporate feedback on the release.
8. Once approved, merge the PR, and pull the `main` branch.
9. Run `cargo publish -p <PACKAGE_NAME>` for each package separately to publish
the crates.
9. Publish each package to crates.io by running `cargo publish -p <PACKAGE_NAME>`
in the order specified in the workspace `Cargo.toml`.
10. Create a signed tag and push it to GitHub: `git tag -s -a vX.Y.Z`. In the
tag message, write the version and the link to the corresponding section of
the changelog.
Expand Down
2 changes: 0 additions & 2 deletions ci/cw-check/Cargo.lock

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

2 changes: 0 additions & 2 deletions ci/no-std-check/Cargo.lock

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

3 changes: 0 additions & 3 deletions ibc-apps/ics20-transfer/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ parity-scale-codec = { workspace = true , optional = true }
scale-info = { workspace = true , optional = true }

[dev-dependencies]
ibc-testkit = { workspace = true }
serde_json = { workspace = true }
rstest = { workspace = true }

Expand All @@ -50,13 +49,11 @@ std = [
"primitive-types/std",
"ibc-core/std",
"ibc-proto/std",
"ibc-testkit/std",
]
serde = [
"dep:serde",
"ibc-core/serde",
"ibc-proto/serde",
"ibc-testkit/serde"
]
schema = [
"dep:schemars",
Expand Down
5 changes: 3 additions & 2 deletions ibc-apps/ics20-transfer/types/src/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ impl From<PacketData> for RawPacketData {

#[cfg(test)]
mod tests {
use ibc_testkit::utils::core::signer::dummy_bech32_account;
use primitive_types::U256;

use super::*;
use crate::BaseCoin;

impl PacketData {
pub fn new_dummy() -> Self {
let address: Signer = dummy_bech32_account().into();
let address: Signer = "cosmos1wxeyh7zgn4tctjzs0vtqpc6p5cxq5t2muzl7ng"
.to_string()
.into();

Self {
token: BaseCoin {
Expand Down
15 changes: 14 additions & 1 deletion ibc-clients/ics07-tendermint/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,14 +503,27 @@ mod tests {
use core::time::Duration;

use ibc_client_tendermint_types::{
AllowUpdate, ClientState as ClientStateType, ClientStateParams, TrustThreshold,
AllowUpdate, ClientState as ClientStateType, TrustThreshold,
};
use ibc_core_client::types::Height;
use ibc_core_commitment_types::specs::ProofSpecs;
use ibc_core_host::types::identifiers::ChainId;

use super::*;

#[derive(Clone, Debug, PartialEq)]
pub struct ClientStateParams {
pub id: ChainId,
pub trust_level: TrustThreshold,
pub trusting_period: Duration,
pub unbonding_period: Duration,
pub max_clock_drift: Duration,
pub latest_height: Height,
pub proof_specs: ProofSpecs,
pub upgrade_path: Vec<String>,
pub allow_update: AllowUpdate,
}

#[test]
fn client_state_verify_height() {
// Define a "default" set of parameters to reuse throughout these tests.
Expand Down
10 changes: 0 additions & 10 deletions ibc-clients/ics07-tendermint/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ prost = { workspace = true }
serde = { workspace = true, optional = true }

# ibc dependencies
ibc-core-client-context = { workspace = true }
ibc-core-client-types = { workspace = true }
ibc-core-commitment-types = { workspace = true }
ibc-core-handler-types = { workspace = true }
ibc-core-host-types = { workspace = true }
ibc-primitives = { workspace = true }
ibc-proto = { workspace = true }
Expand All @@ -44,7 +42,6 @@ parity-scale-codec = { workspace = true, optional = true }
scale-info = { workspace = true, optional = true }

[dev-dependencies]
ibc-testkit = { workspace = true }
serde_json = { workspace = true }
tendermint-rpc = { workspace = true }

Expand All @@ -56,29 +53,24 @@ std = [
"prost/std",
"serde/std",
"serde_json/std",
"ibc-core-client-context/std",
"ibc-core-client-types/std",
"ibc-core-commitment-types/std",
"ibc-core-handler-types/std",
"ibc-core-host-types/std",
"ibc-primitives/std",
"ibc-proto/std",
"tendermint/std",
]
serde = [
"dep:serde",
"ibc-core-client-context/serde",
"ibc-core-client-types/serde",
"ibc-core-commitment-types/serde",
"ibc-core-handler-types/serde",
"ibc-core-host-types/serde",
"ibc-primitives/serde",
"ibc-proto/serde",
]
schema = [
"ibc-core-client-types/schema",
"ibc-core-commitment-types/schema",
"ibc-core-handler-types/schema",
"ibc-core-host-types/schema",
"ibc-primitives/schema",
"ibc-proto/json-schema",
Expand All @@ -89,7 +81,6 @@ borsh = [
"dep:borsh",
"ibc-core-client-types/borsh",
"ibc-core-commitment-types/borsh",
"ibc-core-handler-types/borsh",
"ibc-core-host-types/borsh",
"ibc-primitives/borsh",
"ibc-proto/borsh",
Expand All @@ -99,7 +90,6 @@ parity-scale-codec = [
"dep:scale-info",
"ibc-core-client-types/parity-scale-codec",
"ibc-core-commitment-types/parity-scale-codec",
"ibc-core-handler-types/parity-scale-codec",
"ibc-core-host-types/parity-scale-codec",
"ibc-primitives/parity-scale-codec",
"ibc-proto/parity-scale-codec",
Expand Down
136 changes: 15 additions & 121 deletions ibc-clients/ics07-tendermint/types/src/client_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Implements the core [`ClientState`](crate::core::ics02_client::client_state::ClientState) trait
//! for the Tendermint light client.
//! Contains the implementation of the Tendermint `ClientState` domain type.

use core::cmp::max;
use core::convert::{TryFrom, TryInto};
Expand Down Expand Up @@ -35,23 +34,7 @@ pub struct AllowUpdate {
pub after_misbehaviour: bool,
}

/// Parameters needed when initializing a new `ClientState`. This type
/// exists mainly as a convenience for providing default values in
/// testing scenarios.
#[derive(Clone, Debug, PartialEq)]
pub struct ClientStateParams {
pub id: ChainId,
pub trust_level: TrustThreshold,
pub trusting_period: Duration,
pub unbonding_period: Duration,
pub max_clock_drift: Duration,
pub latest_height: Height,
pub proof_specs: ProofSpecs,
pub upgrade_path: Vec<String>,
pub allow_update: AllowUpdate,
}

/// Contains the core implementation of the Tendermint light client
/// Defines data structure for Tendermint client state.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct ClientState {
Expand Down Expand Up @@ -439,66 +422,23 @@ pub(crate) mod serde_tests {

#[cfg(test)]
mod tests {
use core::str::FromStr;
use core::time::Duration;

use ibc_core_client_types::Height;
use ibc_core_commitment_types::specs::ProofSpecs;
use ibc_proto::google::protobuf::Any;
use ibc_proto::ibc::core::client::v1::Height as RawHeight;
use ibc_proto::ibc::lightclients::tendermint::v1::{ClientState as RawTmClientState, Fraction};
use ibc_proto::ics23::ProofSpec as Ics23ProofSpec;
use ibc_testkit::utils::clients::tendermint::dummy_tendermint_header;
use tendermint::block::Header;
use ibc_core_commitment_types::proto::ics23::ProofSpec as Ics23ProofSpec;

use super::*;
use crate::client_state::{AllowUpdate, ClientState};
use crate::error::Error;

impl ClientState {
pub fn new_dummy_from_raw(frozen_height: RawHeight) -> Result<Self, Error> {
Self::try_from(get_dummy_raw_tm_client_state(frozen_height))
}

pub fn new_dummy_from_header(tm_header: Header) -> Self {
let chain_id = ChainId::from_str(tm_header.chain_id.as_str()).expect("Never fails");
Self::new(
chain_id.clone(),
Default::default(),
Duration::from_secs(64000),
Duration::from_secs(128000),
Duration::from_millis(3000),
Height::new(chain_id.revision_number(), u64::from(tm_header.height))
.expect("Never fails"),
Default::default(),
Default::default(),
AllowUpdate {
after_expiry: false,
after_misbehaviour: false,
},
)
.expect("Never fails")
}
}

pub fn get_dummy_raw_tm_client_state(frozen_height: RawHeight) -> RawTmClientState {
#[allow(deprecated)]
RawTmClientState {
chain_id: ChainId::new("ibc-0").expect("Never fails").to_string(),
trust_level: Some(Fraction {
numerator: 1,
denominator: 3,
}),
trusting_period: Some(Duration::from_secs(64000).into()),
unbonding_period: Some(Duration::from_secs(128000).into()),
max_clock_drift: Some(Duration::from_millis(3000).into()),
latest_height: Some(Height::new(0, 10).expect("Never fails").into()),
proof_specs: ProofSpecs::default().into(),
upgrade_path: Default::default(),
frozen_height: Some(frozen_height),
allow_update_after_expiry: false,
allow_update_after_misbehaviour: false,
}
#[derive(Clone, Debug, PartialEq)]
pub struct ClientStateParams {
pub id: ChainId,
pub trust_level: TrustThreshold,
pub trusting_period: Duration,
pub unbonding_period: Duration,
pub max_clock_drift: Duration,
pub latest_height: Height,
pub proof_specs: ProofSpecs,
pub upgrade_path: Vec<String>,
pub allow_update: AllowUpdate,
}

#[test]
Expand Down Expand Up @@ -644,7 +584,7 @@ mod tests {
for test in tests {
let p = test.params.clone();

let cs_result = ClientState::new(
let cs_result: Result<ClientState, Error> = ClientState::new(
p.id,
p.trust_level,
p.trusting_period,
Expand All @@ -666,50 +606,4 @@ mod tests {
);
}
}

#[test]
fn tm_client_state_conversions_healthy() {
// check client state creation path from a proto type
let tm_client_state_from_raw = ClientState::new_dummy_from_raw(RawHeight {
revision_number: 0,
revision_height: 0,
});
assert!(tm_client_state_from_raw.is_ok());

let any_from_tm_client_state = Any::from(
tm_client_state_from_raw
.as_ref()
.expect("Never fails")
.clone(),
);
let tm_client_state_from_any = ClientState::try_from(any_from_tm_client_state);
assert!(tm_client_state_from_any.is_ok());
assert_eq!(
tm_client_state_from_raw.expect("Never fails"),
tm_client_state_from_any.expect("Never fails")
);

// check client state creation path from a tendermint header
let tm_header = dummy_tendermint_header();
let tm_client_state_from_header = ClientState::new_dummy_from_header(tm_header);
let any_from_header = Any::from(tm_client_state_from_header.clone());
let tm_client_state_from_any = ClientState::try_from(any_from_header);
assert!(tm_client_state_from_any.is_ok());
assert_eq!(
tm_client_state_from_header,
tm_client_state_from_any.expect("Never fails")
);
}

#[test]
fn tm_client_state_malformed_with_frozen_height() {
let tm_client_state_from_raw = ClientState::new_dummy_from_raw(RawHeight {
revision_number: 0,
revision_height: 10,
});
match tm_client_state_from_raw {
Err(Error::FrozenHeightNotAllowed) => {}
_ => panic!("Expected to fail with FrozenHeightNotAllowed error"),
}
}
}
Loading
Loading