Skip to content

Commit a6c2b5b

Browse files
authored
Update to Rust v1.77 (#1744)
* Update to Rust v1.77 * Silence the new warnings
1 parent 94ba730 commit a6c2b5b

File tree

10 files changed

+59
-53
lines changed

10 files changed

+59
-53
lines changed

.github/workflows/ci.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
test-64bits:
3131
runs-on: ubuntu-latest
3232
container:
33-
image: rust:1.76
33+
image: rust:1.77
3434
steps:
3535
- uses: actions/checkout@v4
3636
- uses: Swatinem/rust-cache@v2
@@ -39,7 +39,7 @@ jobs:
3939
test-32bits:
4040
runs-on: ubuntu-latest
4141
container:
42-
image: rust:1.76
42+
image: rust:1.77
4343
steps:
4444
- run: apt-get update && apt install -y libc6-dev-i386
4545
- uses: actions/checkout@v4
@@ -50,7 +50,7 @@ jobs:
5050
wasm-node-check:
5151
runs-on: ubuntu-latest
5252
container:
53-
image: rust:1.76
53+
image: rust:1.77
5454
steps:
5555
- uses: actions/checkout@v4
5656
- run: rustup target add wasm32-unknown-unknown
@@ -66,7 +66,7 @@ jobs:
6666
check-features:
6767
runs-on: ubuntu-latest
6868
container:
69-
image: rust:1.76
69+
image: rust:1.77
7070
steps:
7171
- uses: actions/checkout@v4
7272
- uses: Swatinem/rust-cache@v2
@@ -100,7 +100,7 @@ jobs:
100100
check-no-std:
101101
runs-on: ubuntu-latest
102102
container:
103-
image: rust:1.76
103+
image: rust:1.77
104104
steps:
105105
- uses: actions/checkout@v4
106106
- run: rustup target add thumbv7m-none-eabi
@@ -112,7 +112,7 @@ jobs:
112112
check-rustdoc-links:
113113
runs-on: ubuntu-latest
114114
container:
115-
image: rust:1.76
115+
image: rust:1.77
116116
steps:
117117
- uses: actions/checkout@v4
118118
- uses: Swatinem/rust-cache@v2
@@ -121,7 +121,7 @@ jobs:
121121
fmt:
122122
runs-on: ubuntu-latest
123123
container:
124-
image: rust:1.76
124+
image: rust:1.77
125125
steps:
126126
# Checks `rustfmt` formatting
127127
- uses: actions/checkout@v4
@@ -135,7 +135,7 @@ jobs:
135135
clippy:
136136
runs-on: ubuntu-latest
137137
container:
138-
image: rust:1.76
138+
image: rust:1.77
139139
steps:
140140
- uses: actions/checkout@v4
141141
# Since build artifacts are specific to a nightly version, we pin the specific nightly
@@ -176,7 +176,7 @@ jobs:
176176
wasm-node-versions-match:
177177
runs-on: ubuntu-latest
178178
container:
179-
image: rust:1.76
179+
image: rust:1.77
180180
steps:
181181
- uses: actions/checkout@v4
182182
- run: apt-get update && apt install -y jq

.github/workflows/deploy.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
build-js-doc:
5757
runs-on: ubuntu-latest
5858
container:
59-
image: rust:1.76
59+
image: rust:1.77
6060
steps:
6161
- uses: actions/checkout@v4
6262
with:
@@ -83,7 +83,7 @@ jobs:
8383
build-rust-doc:
8484
runs-on: ubuntu-latest
8585
container:
86-
image: rust:1.76
86+
image: rust:1.77
8787
steps:
8888
- uses: actions/checkout@v4
8989
with:
@@ -104,7 +104,7 @@ jobs:
104104
build-tests-coverage:
105105
runs-on: ubuntu-latest
106106
container:
107-
image: rust:1.76
107+
image: rust:1.77
108108
steps:
109109
- run: apt update && apt install -y jq
110110
- run: rustup component add llvm-tools-preview
@@ -174,7 +174,7 @@ jobs:
174174
npm-publish:
175175
runs-on: ubuntu-latest
176176
container:
177-
image: rust:1.76
177+
image: rust:1.77
178178
steps:
179179
- uses: actions/checkout@v4
180180
- run: rustup target add wasm32-unknown-unknown
@@ -217,7 +217,7 @@ jobs:
217217
- uses: actions-rs/toolchain@v1
218218
with:
219219
# Ideally we don't want to install any toolchain, but the GH action doesn't support this.
220-
toolchain: 1.76
220+
toolchain: 1.77
221221
profile: minimal
222222
- uses: Swatinem/rust-cache@v2
223223
- id: compute-tag # Compute the tag that we might push.
@@ -244,7 +244,7 @@ jobs:
244244
crates-io-publish:
245245
runs-on: ubuntu-latest
246246
container:
247-
image: rust:1.76
247+
image: rust:1.77
248248
steps:
249249
- uses: actions/checkout@v4
250250
- run: cargo publish --dry-run --locked

.github/workflows/periodic-cargo-update.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
cargo-update:
1010
runs-on: ubuntu-latest
1111
container:
12-
image: rust:1.76
12+
image: rust:1.77
1313
steps:
1414
- uses: actions/checkout@v4
1515
# Note: `cargo update --workspace` doesn't seem to have any effect.

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/chain_spec/light_sync_state.rs

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ fn gap_epochs<'a, E: nom::error::ParseError<&'a [u8]>>(
147147
}
148148

149149
#[derive(Debug)]
150+
#[allow(dead_code)] // Necessary to silence warnings about unused fields.
150151
pub(super) enum PersistedEpochHeader {
151152
Genesis(EpochHeader, EpochHeader),
152153
Regular(EpochHeader),
@@ -192,6 +193,7 @@ fn epoch_header<'a, E: nom::error::ParseError<&'a [u8]>>(
192193
}
193194

194195
#[derive(Debug)]
196+
#[allow(dead_code)] // Necessary to silence warnings about unused fields.
195197
pub(super) enum PersistedEpoch {
196198
Genesis(BabeEpoch, BabeEpoch),
197199
Regular(BabeEpoch),

lib/src/json_rpc/parse.rs

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub fn parse_request(request_json: &str) -> Result<Request, ParseError> {
2525

2626
if let Some(id) = &serde_request.id {
2727
// Because of https://github.com/serde-rs/json/issues/742, we can't use ̀`&str`.
28+
#[allow(dead_code)] // Necessary to silence warnings about unused fields.
2829
#[derive(serde::Deserialize)]
2930
#[serde(deny_unknown_fields)]
3031
#[serde(untagged)]
@@ -55,6 +56,7 @@ pub fn parse_response(response_json: &str) -> Result<Response, ParseError> {
5556
result,
5657
}) => {
5758
// Because of https://github.com/serde-rs/json/issues/742, we can't use ̀`&str`.
59+
#[allow(dead_code)] // Necessary to silence warnings about unused fields.
5860
#[derive(serde::Deserialize)]
5961
#[serde(deny_unknown_fields)]
6062
#[serde(untagged)]
@@ -86,6 +88,7 @@ pub fn parse_response(response_json: &str) -> Result<Response, ParseError> {
8688
},
8789
}) if id.get() != "null" => {
8890
// Because of https://github.com/serde-rs/json/issues/742, we can't use ̀`&str`.
91+
#[allow(dead_code)] // Necessary to silence warnings about unused fields.
8992
#[derive(serde::Deserialize)]
9093
#[serde(deny_unknown_fields)]
9194
#[serde(untagged)]

light-base/src/platform.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
use alloc::borrow::Cow;
19-
use core::{fmt, future::Future, ops, panic::UnwindSafe, pin::Pin, str, time::Duration};
19+
use core::{
20+
fmt,
21+
future::Future,
22+
net::{IpAddr, Ipv4Addr, Ipv6Addr},
23+
ops,
24+
panic::UnwindSafe,
25+
pin::Pin,
26+
str,
27+
time::Duration,
28+
};
2029
use futures_util::future;
2130

2231
pub use smoldot::libp2p::read_write;
@@ -372,12 +381,12 @@ impl<'a> From<&'a Address<'a>> for ConnectionType {
372381
Address::WebSocketIp {
373382
ip: IpAddr::V4(ip), ..
374383
} => ConnectionType::WebSocketIpv4 {
375-
remote_is_localhost: no_std_net::Ipv4Addr::from(*ip).is_loopback(),
384+
remote_is_localhost: Ipv4Addr::from(*ip).is_loopback(),
376385
},
377386
Address::WebSocketIp {
378387
ip: IpAddr::V6(ip), ..
379388
} => ConnectionType::WebSocketIpv6 {
380-
remote_is_localhost: no_std_net::Ipv6Addr::from(*ip).is_loopback(),
389+
remote_is_localhost: Ipv6Addr::from(*ip).is_loopback(),
381390
},
382391
Address::WebSocketDns {
383392
hostname, secure, ..
@@ -475,17 +484,6 @@ pub enum MultiStreamAddress<'a> {
475484
},
476485
}
477486

478-
/// Either an IPv4 or IPv6 address.
479-
///
480-
/// > **Note**: This enum is the same as `std::net::IpAddr`, but is copy-pasted here in order to
481-
/// > be no-std-compatible.
482-
// TODO: replace this with `core::net::IpAddr` once it's stable: https://github.com/rust-lang/rust/issues/108443
483-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
484-
pub enum IpAddr {
485-
V4([u8; 4]),
486-
V6([u8; 16]),
487-
}
488-
489487
// TODO: find a way to keep this private somehow?
490488
#[macro_export]
491489
macro_rules! log_inner {

light-base/src/platform/address_parse.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717

1818
use smoldot::libp2p::multiaddr::{Multiaddr, Protocol};
1919

20-
use super::{Address, ConnectionType, IpAddr, MultiStreamAddress};
21-
use core::str;
20+
use super::{Address, ConnectionType, MultiStreamAddress};
21+
use core::{
22+
net::{IpAddr, Ipv4Addr, Ipv6Addr},
23+
str,
24+
};
2225

2326
pub enum AddressOrMultiStreamAddress<'a> {
2427
Address(Address<'a>),
@@ -50,13 +53,13 @@ pub fn multiaddr_to_address(multiaddr: &Multiaddr) -> Result<AddressOrMultiStrea
5053
Ok(match (proto1, proto2, proto3, proto4) {
5154
(Protocol::Ip4(ip), Protocol::Tcp(port), None, None) => {
5255
AddressOrMultiStreamAddress::Address(Address::TcpIp {
53-
ip: IpAddr::V4(ip),
56+
ip: IpAddr::V4(Ipv4Addr::from(ip)),
5457
port,
5558
})
5659
}
5760
(Protocol::Ip6(ip), Protocol::Tcp(port), None, None) => {
5861
AddressOrMultiStreamAddress::Address(Address::TcpIp {
59-
ip: IpAddr::V6(ip),
62+
ip: IpAddr::V6(Ipv6Addr::from(ip)),
6063
port,
6164
})
6265
}
@@ -71,13 +74,13 @@ pub fn multiaddr_to_address(multiaddr: &Multiaddr) -> Result<AddressOrMultiStrea
7174
}),
7275
(Protocol::Ip4(ip), Protocol::Tcp(port), Some(Protocol::Ws), None) => {
7376
AddressOrMultiStreamAddress::Address(Address::WebSocketIp {
74-
ip: IpAddr::V4(ip),
77+
ip: IpAddr::V4(Ipv4Addr::from(ip)),
7578
port,
7679
})
7780
}
7881
(Protocol::Ip6(ip), Protocol::Tcp(port), Some(Protocol::Ws), None) => {
7982
AddressOrMultiStreamAddress::Address(Address::WebSocketIp {
80-
ip: IpAddr::V6(ip),
83+
ip: IpAddr::V6(Ipv6Addr::from(ip)),
8184
port,
8285
})
8386
}
@@ -121,7 +124,7 @@ pub fn multiaddr_to_address(multiaddr: &Multiaddr) -> Result<AddressOrMultiStrea
121124
return Err(Error::InvalidMultihashLength);
122125
};
123126
AddressOrMultiStreamAddress::MultiStreamAddress(MultiStreamAddress::WebRtc {
124-
ip: IpAddr::V4(ip),
127+
ip: IpAddr::V4(Ipv4Addr::from(ip)),
125128
port,
126129
remote_certificate_sha256,
127130
})
@@ -140,7 +143,7 @@ pub fn multiaddr_to_address(multiaddr: &Multiaddr) -> Result<AddressOrMultiStrea
140143
return Err(Error::InvalidMultihashLength);
141144
};
142145
AddressOrMultiStreamAddress::MultiStreamAddress(MultiStreamAddress::WebRtc {
143-
ip: IpAddr::V6(ip),
146+
ip: IpAddr::V6(Ipv6Addr::from(ip)),
144147
port,
145148
remote_certificate_sha256,
146149
})

wasm-node/rust/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ futures-lite = { version = "2.3.0", default-features = false, features = ["alloc
2727
futures-util = { version = "0.3.27", default-features = false }
2828
hashbrown = { version = "0.14.0", default-features = false }
2929
nom = { version = "7.1.3", default-features = false }
30-
no-std-net = { version = "0.6.0", default-features = false }
3130
pin-project = "1.1.5"
3231
slab = { version = "0.4.8", default-features = false }
3332
smoldot = { version = "0.17.0", path = "../../lib", default-features = false }

wasm-node/rust/src/platform.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ use alloc::{
3232
use async_lock::Mutex;
3333
use core::{
3434
fmt::{self, Write as _},
35-
future, iter, mem, ops, pin, str,
35+
future, iter, mem,
36+
net::{IpAddr, Ipv4Addr, Ipv6Addr},
37+
ops, pin, str,
3638
sync::atomic::{AtomicU32, AtomicU64, Ordering},
3739
task,
3840
time::Duration,
@@ -314,36 +316,36 @@ impl smoldot_light::platform::PlatformRef for PlatformRef {
314316

315317
let encoded_address: Vec<u8> = match address {
316318
smoldot_light::platform::Address::TcpIp {
317-
ip: smoldot_light::platform::IpAddr::V4(ip),
319+
ip: IpAddr::V4(ip),
318320
port,
319321
} => iter::once(0u8)
320322
.chain(port.to_be_bytes())
321-
.chain(no_std_net::Ipv4Addr::from(ip).to_string().bytes())
323+
.chain(Ipv4Addr::from(ip).to_string().bytes())
322324
.collect(),
323325
smoldot_light::platform::Address::TcpIp {
324-
ip: smoldot_light::platform::IpAddr::V6(ip),
326+
ip: IpAddr::V6(ip),
325327
port,
326328
} => iter::once(1u8)
327329
.chain(port.to_be_bytes())
328-
.chain(no_std_net::Ipv6Addr::from(ip).to_string().bytes())
330+
.chain(Ipv6Addr::from(ip).to_string().bytes())
329331
.collect(),
330332
smoldot_light::platform::Address::TcpDns { hostname, port } => iter::once(2u8)
331333
.chain(port.to_be_bytes())
332334
.chain(hostname.as_bytes().iter().copied())
333335
.collect(),
334336
smoldot_light::platform::Address::WebSocketIp {
335-
ip: smoldot_light::platform::IpAddr::V4(ip),
337+
ip: IpAddr::V4(ip),
336338
port,
337339
} => iter::once(4u8)
338340
.chain(port.to_be_bytes())
339-
.chain(no_std_net::Ipv4Addr::from(ip).to_string().bytes())
341+
.chain(Ipv4Addr::from(ip).to_string().bytes())
340342
.collect(),
341343
smoldot_light::platform::Address::WebSocketIp {
342-
ip: smoldot_light::platform::IpAddr::V6(ip),
344+
ip: IpAddr::V6(ip),
343345
port,
344346
} => iter::once(5u8)
345347
.chain(port.to_be_bytes())
346-
.chain(no_std_net::Ipv6Addr::from(ip).to_string().bytes())
348+
.chain(Ipv6Addr::from(ip).to_string().bytes())
347349
.collect(),
348350
smoldot_light::platform::Address::WebSocketDns {
349351
hostname,
@@ -423,22 +425,22 @@ impl smoldot_light::platform::PlatformRef for PlatformRef {
423425

424426
let encoded_address: Vec<u8> = match address {
425427
smoldot_light::platform::MultiStreamAddress::WebRtc {
426-
ip: smoldot_light::platform::IpAddr::V4(ip),
428+
ip: IpAddr::V4(ip),
427429
port,
428430
remote_certificate_sha256,
429431
} => iter::once(16u8)
430432
.chain(port.to_be_bytes())
431433
.chain(remote_certificate_sha256.iter().copied())
432-
.chain(no_std_net::Ipv4Addr::from(ip).to_string().bytes())
434+
.chain(Ipv4Addr::from(ip).to_string().bytes())
433435
.collect(),
434436
smoldot_light::platform::MultiStreamAddress::WebRtc {
435-
ip: smoldot_light::platform::IpAddr::V6(ip),
437+
ip: IpAddr::V6(ip),
436438
port,
437439
remote_certificate_sha256,
438440
} => iter::once(17u8)
439441
.chain(port.to_be_bytes())
440442
.chain(remote_certificate_sha256.iter().copied())
441-
.chain(no_std_net::Ipv6Addr::from(ip).to_string().bytes())
443+
.chain(Ipv6Addr::from(ip).to_string().bytes())
442444
.collect(),
443445
};
444446

0 commit comments

Comments
 (0)