Skip to content

Commit b2c2529

Browse files
fix: bump MSRV to 1.71.1 (informalsystems#1119)
* bump msrv to 1.71.1 * add ci check * rm windows * refactor msrv check * use cargo-msrv * add names to steps * apply clippy suggestions * rm redundant import * clippy::use_self * clippy::cast_lossless * clippy::match_same_arms * apply clippy suggestions * reuse old var * refactor old code * badge for license, version, downloads * rm broken tokei loc badge * add changelog * clippy::derive_partial_eq_without_eq * clippy::string_lit_as_bytes * clippy::empty_line_after_doc_comments * clippy::cloned_instead_of_copied * clippy::unreadable_literal * clippy::single_match_else * expect over unwrap * use let-else * use ok_or_else * propagate None * clippy::match_same_arms * return precise error * rm downcast in favor of let-else * chore: add unclog for 1101 + move 1118 under breaking-changes * add msrv in clippy config * update changelog * use into over from * clippy::redundant_closure_for_method_calls --------- Co-authored-by: Farhad Shabani <[email protected]>
1 parent e1f19af commit b2c2529

File tree

58 files changed

+348
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+348
-514
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [ibc] Increase minimum supported Rust version to 1.71.1
2+
([\#1118](https://github.com/cosmos/ibc-rs/issues/1118))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [ibc-primitives] Use `let-else` over `downcast!()` and remove `utils/macros`
2+
module as a result ([\#1118](https://github.com/cosmos/ibc-rs/issues/1118))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [ibc-core] Remove unnecessary shadowing with same value
2+
([\#1120](https://github.com/cosmos/ibc-rs/issues/1120))

.github/workflows/rust.yml

+45
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,48 @@ jobs:
157157
with:
158158
command: test
159159
args: --no-default-features --no-fail-fast --no-run
160+
161+
test-msrv:
162+
timeout-minutes: 30
163+
env:
164+
CARGO_MSRV_VERSION: 0.16.0-beta.20
165+
MSRV: 1.71.1
166+
strategy:
167+
matrix:
168+
param:
169+
[
170+
{ os: ubuntu-latest, system: unknown-linux-gnu },
171+
{ os: macos-latest, system: apple-darwin },
172+
]
173+
runs-on: ${{ matrix.param.os }}
174+
steps:
175+
- uses: actions/checkout@v2
176+
177+
- name: Download cargo-msrv
178+
uses: dsaltares/fetch-gh-release-asset@master
179+
with:
180+
repo: foresterre/cargo-msrv
181+
version: "tags/v${{ env.CARGO_MSRV_VERSION }}"
182+
file: "cargo-msrv-x86_64-${{ matrix.param.system }}-v${{ env.CARGO_MSRV_VERSION }}.tgz"
183+
184+
- uses: actions-rs/toolchain@v1
185+
with:
186+
toolchain: ${{ env.MSRV }}
187+
override: true
188+
- uses: Swatinem/rust-cache@v1
189+
190+
- name: Install cargo-msrv
191+
run: |
192+
tar -xzf "cargo-msrv-x86_64-${{ matrix.param.system }}-v${{ env.CARGO_MSRV_VERSION }}.tgz"
193+
mv "cargo-msrv-x86_64-${{ matrix.param.system }}-v${{ env.CARGO_MSRV_VERSION }}/cargo-msrv" ~/.cargo/bin
194+
cargo msrv --version
195+
196+
- name: Calculate MSRV
197+
run: cargo msrv --output-format minimal --min 1.64.0
198+
199+
- name: Build with MSRV
200+
uses: actions-rs/cargo@v1
201+
with:
202+
toolchain: ${{ env.MSRV }}
203+
command: build
204+
args: --all-features

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ exclude = [
4343
version = "0.50.0"
4444
license = "Apache-2.0"
4545
edition = "2021"
46-
rust-version = "1.64"
46+
rust-version = "1.71.1"
4747
readme = "README.md"
4848
repository = "https://github.com/cosmos/ibc-rs"
4949
authors = ["Informal Systems <[email protected]>"]

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
[![Build Status][build-image]][build-link]
1717
[![Code Coverage][codecov-image]][codecov-link]
1818
[![Apache 2.0 Licensed][license-image]][license-link]
19-
![Rust Stable][rustc-image]
20-
![Rust 1.64+][rustc-version]
21-
![Lines of Code][loc-image]
19+
![Version][crates-io-version]
20+
![Downloads][crates-io-downloads]
21+
![Rust Stable][msrv-image]
2222

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

103103
[//]: # (general links)
104104
[ibc]: https://github.com/cosmos/ibc

clippy.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ disallowed-types = [
77
disallowed-methods = [
88
"std::time::Duration::as_secs_f64",
99
]
10+
msrv = "1.71.1"

ibc-apps/ics20-transfer/src/module.rs

+24-35
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,10 @@ pub fn on_recv_packet_execute(
170170
ctx_b: &mut impl TokenTransferExecutionContext,
171171
packet: &Packet,
172172
) -> (ModuleExtras, Acknowledgement) {
173-
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
174-
Ok(data) => data,
175-
Err(_) => {
176-
let ack =
177-
AcknowledgementStatus::error(TokenTransferError::PacketDataDeserialization.into());
178-
return (ModuleExtras::empty(), ack.into());
179-
}
173+
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
174+
let ack =
175+
AcknowledgementStatus::error(TokenTransferError::PacketDataDeserialization.into());
176+
return (ModuleExtras::empty(), ack.into());
180177
};
181178

182179
let (mut extras, ack) = match process_recv_packet_execute(ctx_b, packet, data.clone()) {
@@ -225,26 +222,21 @@ pub fn on_acknowledgement_packet_execute(
225222
acknowledgement: &Acknowledgement,
226223
_relayer: &Signer,
227224
) -> (ModuleExtras, Result<(), TokenTransferError>) {
228-
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
229-
Ok(data) => data,
230-
Err(_) => {
231-
return (
232-
ModuleExtras::empty(),
233-
Err(TokenTransferError::PacketDataDeserialization),
234-
);
235-
}
225+
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
226+
return (
227+
ModuleExtras::empty(),
228+
Err(TokenTransferError::PacketDataDeserialization),
229+
);
236230
};
237231

238-
let acknowledgement =
239-
match serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref()) {
240-
Ok(ack) => ack,
241-
Err(_) => {
242-
return (
243-
ModuleExtras::empty(),
244-
Err(TokenTransferError::AckDeserialization),
245-
);
246-
}
247-
};
232+
let Ok(acknowledgement) =
233+
serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref())
234+
else {
235+
return (
236+
ModuleExtras::empty(),
237+
Err(TokenTransferError::AckDeserialization),
238+
);
239+
};
248240

249241
if !acknowledgement.is_successful() {
250242
if let Err(err) = refund_packet_token_execute(ctx, packet, &data) {
@@ -290,14 +282,11 @@ pub fn on_timeout_packet_execute(
290282
packet: &Packet,
291283
_relayer: &Signer,
292284
) -> (ModuleExtras, Result<(), TokenTransferError>) {
293-
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
294-
Ok(data) => data,
295-
Err(_) => {
296-
return (
297-
ModuleExtras::empty(),
298-
Err(TokenTransferError::PacketDataDeserialization),
299-
);
300-
}
285+
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
286+
return (
287+
ModuleExtras::empty(),
288+
Err(TokenTransferError::PacketDataDeserialization),
289+
);
301290
};
302291

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

353342
#[test]
@@ -361,7 +350,7 @@ mod test {
361350
// which would make the conversion to `Acknowledgement` panic
362351
assert_eq!(
363352
ack_error,
364-
r#"{"error":"failed to deserialize packet data"}"#.as_bytes()
353+
br#"{"error":"failed to deserialize packet data"}"#
365354
);
366355
}
367356

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ impl std::error::Error for TokenTransferError {
8484
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
8585
match &self {
8686
Self::ContextError(e) => Some(e),
87-
Self::InvalidIdentifier(e) => Some(e),
88-
Self::InvalidTracePortId {
87+
Self::InvalidIdentifier(e)
88+
| Self::InvalidTracePortId {
8989
validation_error: e,
9090
..
91-
} => Some(e),
92-
Self::InvalidTraceChannelId {
91+
}
92+
| Self::InvalidTraceChannelId {
9393
validation_error: e,
9494
..
9595
} => Some(e),

ibc-apps/ics721-nft-transfer/src/module.rs

+23-35
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,9 @@ pub fn on_recv_packet_execute(
172172
ctx_b: &mut impl NftTransferExecutionContext,
173173
packet: &Packet,
174174
) -> (ModuleExtras, Acknowledgement) {
175-
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
176-
Ok(data) => data,
177-
Err(_) => {
178-
let ack =
179-
AcknowledgementStatus::error(NftTransferError::PacketDataDeserialization.into());
180-
return (ModuleExtras::empty(), ack.into());
181-
}
175+
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
176+
let ack = AcknowledgementStatus::error(NftTransferError::PacketDataDeserialization.into());
177+
return (ModuleExtras::empty(), ack.into());
182178
};
183179

184180
let (mut extras, ack) = match process_recv_packet_execute(ctx_b, packet, data.clone()) {
@@ -227,26 +223,21 @@ pub fn on_acknowledgement_packet_execute(
227223
acknowledgement: &Acknowledgement,
228224
_relayer: &Signer,
229225
) -> (ModuleExtras, Result<(), NftTransferError>) {
230-
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
231-
Ok(data) => data,
232-
Err(_) => {
233-
return (
234-
ModuleExtras::empty(),
235-
Err(NftTransferError::PacketDataDeserialization),
236-
);
237-
}
226+
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
227+
return (
228+
ModuleExtras::empty(),
229+
Err(NftTransferError::PacketDataDeserialization),
230+
);
238231
};
239232

240-
let acknowledgement =
241-
match serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref()) {
242-
Ok(ack) => ack,
243-
Err(_) => {
244-
return (
245-
ModuleExtras::empty(),
246-
Err(NftTransferError::AckDeserialization),
247-
);
248-
}
249-
};
233+
let Ok(acknowledgement) =
234+
serde_json::from_slice::<AcknowledgementStatus>(acknowledgement.as_ref())
235+
else {
236+
return (
237+
ModuleExtras::empty(),
238+
Err(NftTransferError::AckDeserialization),
239+
);
240+
};
250241

251242
if !acknowledgement.is_successful() {
252243
if let Err(err) = refund_packet_nft_execute(ctx, packet, &data) {
@@ -289,14 +280,11 @@ pub fn on_timeout_packet_execute(
289280
packet: &Packet,
290281
_relayer: &Signer,
291282
) -> (ModuleExtras, Result<(), NftTransferError>) {
292-
let data = match serde_json::from_slice::<PacketData>(&packet.data) {
293-
Ok(data) => data,
294-
Err(_) => {
295-
return (
296-
ModuleExtras::empty(),
297-
Err(NftTransferError::PacketDataDeserialization),
298-
);
299-
}
283+
let Ok(data) = serde_json::from_slice::<PacketData>(&packet.data) else {
284+
return (
285+
ModuleExtras::empty(),
286+
Err(NftTransferError::PacketDataDeserialization),
287+
);
300288
};
301289

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

352340
#[test]
@@ -359,7 +347,7 @@ mod test {
359347
// which would make the conversion to `Acknowledgement` panic
360348
assert_eq!(
361349
ack_error,
362-
r#"{"error":"failed to deserialize packet data"}"#.as_bytes()
350+
br#"{"error":"failed to deserialize packet data"}"#
363351
);
364352
}
365353

ibc-apps/ics721-nft-transfer/types/src/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl borsh::BorshSerialize for DataValue {
161161
Some(mime) => mime.to_string(),
162162
None => String::default(),
163163
};
164-
borsh::BorshSerialize::serialize(&mime.to_string(), writer)?;
164+
borsh::BorshSerialize::serialize(&mime, writer)?;
165165
Ok(())
166166
}
167167
}

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ impl std::error::Error for NftTransferError {
9797
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
9898
match &self {
9999
Self::ContextError(e) => Some(e),
100-
Self::InvalidIdentifier(e) => Some(e),
101100
Self::InvalidUri {
102101
validation_error: e,
103102
..
104103
} => Some(e),
105-
Self::InvalidTracePortId {
104+
Self::InvalidIdentifier(e)
105+
| Self::InvalidTracePortId {
106106
validation_error: e,
107107
..
108-
} => Some(e),
109-
Self::InvalidTraceChannelId {
108+
}
109+
| Self::InvalidTraceChannelId {
110110
validation_error: e,
111111
..
112112
} => Some(e),

ibc-clients/ics07-tendermint/src/client_state.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ mod tests {
8585
use ibc_core_client::types::Height;
8686
use ibc_core_commitment_types::specs::ProofSpecs;
8787
use ibc_core_host::types::identifiers::ChainId;
88-
use tests::common::validate_proof_height;
8988

9089
use super::*;
9190

@@ -109,7 +108,7 @@ mod tests {
109108
id: ChainId::new("ibc-1").unwrap(),
110109
trust_level: TrustThreshold::ONE_THIRD,
111110
trusting_period: Duration::new(64000, 0),
112-
unbonding_period: Duration::new(128000, 0),
111+
unbonding_period: Duration::new(128_000, 0),
113112
max_clock_drift: Duration::new(3, 0),
114113
latest_height: Height::new(1, 10).expect("Never fails"),
115114
proof_specs: ProofSpecs::default(),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ where
259259
// this consensus state should not be used for packet verification as
260260
// the root is empty. The next consensus state submitted using update
261261
// will be usable for packet-verification.
262-
let sentinel_root = "sentinel_root".as_bytes().to_vec();
262+
let sentinel_root = b"sentinel_root".to_vec();
263263
let new_consensus_state = ConsensusStateType::new(
264264
sentinel_root.into(),
265265
upgraded_tm_cons_state.timestamp(),

0 commit comments

Comments
 (0)