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

fix: bump MSRV to 1.71.1 #1119

Merged
merged 35 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
dfaa738
bump msrv to 1.71.1
rnbguy Mar 9, 2024
513594c
add ci check
rnbguy Mar 9, 2024
bbe76bf
rm windows
rnbguy Mar 9, 2024
e022acf
refactor msrv check
rnbguy Mar 9, 2024
28947f6
use cargo-msrv
rnbguy Mar 9, 2024
44c64d0
add names to steps
rnbguy Mar 9, 2024
cd44a48
apply clippy suggestions
rnbguy Mar 9, 2024
b640135
rm redundant import
rnbguy Mar 9, 2024
568a5a2
clippy::use_self
rnbguy Mar 10, 2024
f5c12ff
clippy::cast_lossless
rnbguy Mar 10, 2024
0544df3
clippy::match_same_arms
rnbguy Mar 10, 2024
0a1a708
apply clippy suggestions
rnbguy Mar 10, 2024
aff9942
reuse old var
rnbguy Mar 10, 2024
fcda368
refactor old code
rnbguy Mar 10, 2024
38b5371
badge for license, version, downloads
rnbguy Mar 10, 2024
665fc15
rm broken tokei loc badge
rnbguy Mar 10, 2024
e065529
add changelog
rnbguy Mar 11, 2024
2084711
clippy::derive_partial_eq_without_eq
rnbguy Mar 11, 2024
ac7c4ab
clippy::string_lit_as_bytes
rnbguy Mar 11, 2024
cb32ce8
clippy::empty_line_after_doc_comments
rnbguy Mar 11, 2024
604c69e
clippy::cloned_instead_of_copied
rnbguy Mar 11, 2024
8587c28
clippy::unreadable_literal
rnbguy Mar 11, 2024
8ba7ad1
clippy::single_match_else
rnbguy Mar 11, 2024
e1c14a1
expect over unwrap
rnbguy Mar 11, 2024
91d2c68
use let-else
rnbguy Mar 11, 2024
5b221d4
use ok_or_else
rnbguy Mar 11, 2024
0f8001d
propagate None
rnbguy Mar 11, 2024
6acf412
clippy::match_same_arms
rnbguy Mar 11, 2024
b50d08b
return precise error
rnbguy Mar 11, 2024
4b0f27f
rm downcast in favor of let-else
rnbguy Mar 11, 2024
1e90a9b
chore: add unclog for 1101 + move 1118 under breaking-changes
Farhad-Shabani Mar 11, 2024
c7beb71
add msrv in clippy config
rnbguy Mar 12, 2024
332c5de
update changelog
rnbguy Mar 12, 2024
d435bda
use into over from
rnbguy Mar 12, 2024
6161f2c
clippy::redundant_closure_for_method_calls
rnbguy Mar 12, 2024
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/breaking-changes/1118-bump-msrv.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ibc] Increase minimum supported Rust version to 1.71.1
([\#1118](https://github.com/cosmos/ibc-rs/issues/1118))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [ibc-primitives] use `let-else` over `downcast!()` and remove `utils/macros`
module as a result ([\#1118](https://github.com/cosmos/ibc-rs/issues/1118))
Farhad-Shabani marked this conversation as resolved.
Show resolved Hide resolved
45 changes: 45 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,48 @@ jobs:
with:
command: test
args: --no-default-features --no-fail-fast --no-run

test-msrv:
Farhad-Shabani marked this conversation as resolved.
Show resolved Hide resolved
timeout-minutes: 30
env:
CARGO_MSRV_VERSION: 0.16.0-beta.20
MSRV: 1.71.1
strategy:
matrix:
param:
[
{ os: ubuntu-latest, system: unknown-linux-gnu },
{ os: macos-latest, system: apple-darwin },
]
runs-on: ${{ matrix.param.os }}
steps:
- uses: actions/checkout@v2

- name: Download cargo-msrv
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: foresterre/cargo-msrv
version: "tags/v${{ env.CARGO_MSRV_VERSION }}"
file: "cargo-msrv-x86_64-${{ matrix.param.system }}-v${{ env.CARGO_MSRV_VERSION }}.tgz"

- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.MSRV }}
override: true
- uses: Swatinem/rust-cache@v1

- name: Install cargo-msrv
run: |
tar -xzf "cargo-msrv-x86_64-${{ matrix.param.system }}-v${{ env.CARGO_MSRV_VERSION }}.tgz"
mv "cargo-msrv-x86_64-${{ matrix.param.system }}-v${{ env.CARGO_MSRV_VERSION }}/cargo-msrv" ~/.cargo/bin
cargo msrv --version

- name: Calculate MSRV
run: cargo msrv --output-format minimal --min 1.64.0

- name: Build with MSRV
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.MSRV }}
command: build
args: --all-features
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exclude = [
version = "0.50.0"
license = "Apache-2.0"
edition = "2021"
rust-version = "1.64"
rust-version = "1.71.1"
readme = "README.md"
repository = "https://github.com/cosmos/ibc-rs"
authors = ["Informal Systems <hello@informal.systems>"]
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
[![Build Status][build-image]][build-link]
[![Code Coverage][codecov-image]][codecov-link]
[![Apache 2.0 Licensed][license-image]][license-link]
![Rust Stable][rustc-image]
![Rust 1.64+][rustc-version]
![Lines of Code][loc-image]
![Version][crates-io-version]
![Downloads][crates-io-downloads]
![Rust Stable][msrv-image]

</div>
</div>
Expand Down Expand Up @@ -94,11 +94,11 @@ specific language governing permissions and limitations under the License.
[build-link]: https://github.com/cosmos/ibc-rs/actions?query=workflow%3ARust
[codecov-image]: https://codecov.io/gh/cosmos/ibc-rs/branch/main/graph/badge.svg?token=wUm2aLCOu
[codecov-link]: https://codecov.io/gh/cosmos/ibc-rs
[loc-image]: https://tokei.rs/b1/github/cosmos/ibc-rs
[license-image]: https://img.shields.io/badge/license-Apache2.0-blue.svg
[license-image]: https://img.shields.io/crates/l/ibc
[license-link]: https://github.com/cosmos/ibc-rs/blob/main/LICENSE
[rustc-image]: https://img.shields.io/badge/rustc-stable-blue.svg
[rustc-version]: https://img.shields.io/badge/rustc-1.60+-blue.svg
[crates-io-version]: https://img.shields.io/crates/v/ibc.svg
[crates-io-downloads]: https://img.shields.io/crates/d/ibc.svg
[msrv-image]: https://img.shields.io/crates/msrv/ibc

[//]: # (general links)
[ibc]: https://github.com/cosmos/ibc
Expand Down
59 changes: 24 additions & 35 deletions ibc-apps/ics20-transfer/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,10 @@
ctx_b: &mut impl TokenTransferExecutionContext,
packet: &Packet,
) -> (ModuleExtras, Acknowledgement) {
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
Ok(data) => data,
Err(_) => {
let ack =
AcknowledgementStatus::error(TokenTransferError::PacketDataDeserialization.into());
return (ModuleExtras::empty(), ack.into());
}
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
let ack =
AcknowledgementStatus::error(TokenTransferError::PacketDataDeserialization.into());
return (ModuleExtras::empty(), ack.into());

Check warning on line 176 in ibc-apps/ics20-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/module.rs#L173-L176

Added lines #L173 - L176 were not covered by tests
};

let (mut extras, ack) = match process_recv_packet_execute(ctx_b, packet, data.clone()) {
Expand Down Expand Up @@ -225,26 +222,21 @@
acknowledgement: &Acknowledgement,
_relayer: &Signer,
) -> (ModuleExtras, Result<(), TokenTransferError>) {
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
Ok(data) => data,
Err(_) => {
return (
ModuleExtras::empty(),
Err(TokenTransferError::PacketDataDeserialization),
);
}
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
return (
ModuleExtras::empty(),
Err(TokenTransferError::PacketDataDeserialization),
);

Check warning on line 229 in ibc-apps/ics20-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/module.rs#L225-L229

Added lines #L225 - L229 were not covered by tests
};

let acknowledgement =
match serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref()) {
Ok(ack) => ack,
Err(_) => {
return (
ModuleExtras::empty(),
Err(TokenTransferError::AckDeserialization),
);
}
};
let Ok(acknowledgement) =
serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref())

Check warning on line 233 in ibc-apps/ics20-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/module.rs#L232-L233

Added lines #L232 - L233 were not covered by tests
else {
return (
ModuleExtras::empty(),
Err(TokenTransferError::AckDeserialization),
);

Check warning on line 238 in ibc-apps/ics20-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/module.rs#L235-L238

Added lines #L235 - L238 were not covered by tests
};

if !acknowledgement.is_successful() {
if let Err(err) = refund_packet_token_execute(ctx, packet, &data) {
Expand Down Expand Up @@ -290,14 +282,11 @@
packet: &Packet,
_relayer: &Signer,
) -> (ModuleExtras, Result<(), TokenTransferError>) {
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
Ok(data) => data,
Err(_) => {
return (
ModuleExtras::empty(),
Err(TokenTransferError::PacketDataDeserialization),
);
}
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
return (
ModuleExtras::empty(),
Err(TokenTransferError::PacketDataDeserialization),
);

Check warning on line 289 in ibc-apps/ics20-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/src/module.rs#L285-L289

Added lines #L285 - L289 were not covered by tests
};

if let Err(err) = refund_packet_token_execute(ctx, packet, &data) {
Expand Down Expand Up @@ -347,7 +336,7 @@
// Check that it's the same output as ibc-go
// Note: this also implicitly checks that the ack bytes are non-empty,
// which would make the conversion to `Acknowledgement` panic
assert_eq!(ack_success, r#"{"result":"AQ=="}"#.as_bytes());
assert_eq!(ack_success, br#"{"result":"AQ=="}"#);
}

#[test]
Expand All @@ -361,7 +350,7 @@
// which would make the conversion to `Acknowledgement` panic
assert_eq!(
ack_error,
r#"{"error":"failed to deserialize packet data"}"#.as_bytes()
br#"{"error":"failed to deserialize packet data"}"#
);
}

Expand Down
8 changes: 4 additions & 4 deletions ibc-apps/ics20-transfer/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match &self {
Self::ContextError(e) => Some(e),
Self::InvalidIdentifier(e) => Some(e),
Self::InvalidTracePortId {
Self::InvalidIdentifier(e)

Check warning on line 87 in ibc-apps/ics20-transfer/types/src/error.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics20-transfer/types/src/error.rs#L87

Added line #L87 was not covered by tests
| Self::InvalidTracePortId {
validation_error: e,
..
} => Some(e),
Self::InvalidTraceChannelId {
}
| Self::InvalidTraceChannelId {
validation_error: e,
..
} => Some(e),
Expand Down
58 changes: 23 additions & 35 deletions ibc-apps/ics721-nft-transfer/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,9 @@
ctx_b: &mut impl NftTransferExecutionContext,
packet: &Packet,
) -> (ModuleExtras, Acknowledgement) {
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
Ok(data) => data,
Err(_) => {
let ack =
AcknowledgementStatus::error(NftTransferError::PacketDataDeserialization.into());
return (ModuleExtras::empty(), ack.into());
}
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
let ack = AcknowledgementStatus::error(NftTransferError::PacketDataDeserialization.into());
return (ModuleExtras::empty(), ack.into());

Check warning on line 177 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L175-L177

Added lines #L175 - L177 were not covered by tests
};

let (mut extras, ack) = match process_recv_packet_execute(ctx_b, packet, data.clone()) {
Expand Down Expand Up @@ -227,26 +223,21 @@
acknowledgement: &Acknowledgement,
_relayer: &Signer,
) -> (ModuleExtras, Result<(), NftTransferError>) {
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
Ok(data) => data,
Err(_) => {
return (
ModuleExtras::empty(),
Err(NftTransferError::PacketDataDeserialization),
);
}
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
return (
ModuleExtras::empty(),
Err(NftTransferError::PacketDataDeserialization),
);

Check warning on line 230 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L226-L230

Added lines #L226 - L230 were not covered by tests
};

let acknowledgement =
match serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref()) {
Ok(ack) => ack,
Err(_) => {
return (
ModuleExtras::empty(),
Err(NftTransferError::AckDeserialization),
);
}
};
let Ok(acknowledgement) =
serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref())

Check warning on line 234 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L233-L234

Added lines #L233 - L234 were not covered by tests
else {
return (
ModuleExtras::empty(),
Err(NftTransferError::AckDeserialization),
);

Check warning on line 239 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L236-L239

Added lines #L236 - L239 were not covered by tests
};

if !acknowledgement.is_successful() {
if let Err(err) = refund_packet_nft_execute(ctx, packet, &data) {
Expand Down Expand Up @@ -289,14 +280,11 @@
packet: &Packet,
_relayer: &Signer,
) -> (ModuleExtras, Result<(), NftTransferError>) {
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
Ok(data) => data,
Err(_) => {
return (
ModuleExtras::empty(),
Err(NftTransferError::PacketDataDeserialization),
);
}
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
return (
ModuleExtras::empty(),
Err(NftTransferError::PacketDataDeserialization),
);

Check warning on line 287 in ibc-apps/ics721-nft-transfer/src/module.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/src/module.rs#L283-L287

Added lines #L283 - L287 were not covered by tests
};

if let Err(err) = refund_packet_nft_execute(ctx, packet, &data) {
Expand Down Expand Up @@ -346,7 +334,7 @@
// Check that it's the same output as ibc-go
// Note: this also implicitly checks that the ack bytes are non-empty,
// which would make the conversion to `Acknowledgement` panic
assert_eq!(ack_success, r#"{"result":"AQ=="}"#.as_bytes());
assert_eq!(ack_success, br#"{"result":"AQ=="}"#);
}

#[test]
Expand All @@ -359,7 +347,7 @@
// which would make the conversion to `Acknowledgement` panic
assert_eq!(
ack_error,
r#"{"error":"failed to deserialize packet data"}"#.as_bytes()
br#"{"error":"failed to deserialize packet data"}"#
);
}

Expand Down
2 changes: 1 addition & 1 deletion ibc-apps/ics721-nft-transfer/types/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl borsh::BorshSerialize for DataValue {
Some(mime) => mime.to_string(),
None => String::default(),
};
borsh::BorshSerialize::serialize(&mime.to_string(), writer)?;
borsh::BorshSerialize::serialize(&mime, writer)?;
Ok(())
}
}
Expand Down
8 changes: 4 additions & 4 deletions ibc-apps/ics721-nft-transfer/types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,16 @@
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match &self {
Self::ContextError(e) => Some(e),
Self::InvalidIdentifier(e) => Some(e),
Self::InvalidUri {
validation_error: e,
..
} => Some(e),
Self::InvalidTracePortId {
Self::InvalidIdentifier(e)

Check warning on line 104 in ibc-apps/ics721-nft-transfer/types/src/error.rs

View check run for this annotation

Codecov / codecov/patch

ibc-apps/ics721-nft-transfer/types/src/error.rs#L104

Added line #L104 was not covered by tests
| Self::InvalidTracePortId {
validation_error: e,
..
} => Some(e),
Self::InvalidTraceChannelId {
}
| Self::InvalidTraceChannelId {
validation_error: e,
..
} => Some(e),
Expand Down
3 changes: 1 addition & 2 deletions ibc-clients/ics07-tendermint/src/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ mod tests {
use ibc_core_client::types::Height;
use ibc_core_commitment_types::specs::ProofSpecs;
use ibc_core_host::types::identifiers::ChainId;
use tests::common::validate_proof_height;

use super::*;

Expand All @@ -109,7 +108,7 @@ mod tests {
id: ChainId::new("ibc-1").unwrap(),
trust_level: TrustThreshold::ONE_THIRD,
trusting_period: Duration::new(64000, 0),
unbonding_period: Duration::new(128000, 0),
unbonding_period: Duration::new(128_000, 0),
max_clock_drift: Duration::new(3, 0),
latest_height: Height::new(1, 10).expect("Never fails"),
proof_specs: ProofSpecs::default(),
Expand Down
2 changes: 1 addition & 1 deletion ibc-clients/ics07-tendermint/src/client_state/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
// this consensus state should not be used for packet verification as
// the root is empty. The next consensus state submitted using update
// will be usable for packet-verification.
let sentinel_root = "sentinel_root".as_bytes().to_vec();
let sentinel_root = b"sentinel_root".to_vec();

Check warning on line 262 in ibc-clients/ics07-tendermint/src/client_state/execution.rs

View check run for this annotation

Codecov / codecov/patch

ibc-clients/ics07-tendermint/src/client_state/execution.rs#L262

Added line #L262 was not covered by tests
let new_consensus_state = ConsensusStateType::new(
sentinel_root.into(),
upgraded_tm_cons_state.timestamp(),
Expand Down
Loading
Loading