Skip to content

Commit 37482d9

Browse files
authored
Update code base to Rust edition 2024 (#2086)
* Update Cargo.toml * Run rustfmt * Fix all compilation errors in library * Fix all other compilation errors * Fix all warnings * Future is now in prelude * No need for manual noop waker anymore * Update Rust version in CI * Remove all unnecessary ` + '_` * More removal * Fix errors regarding noop waker * Remove many more unnecessary `<'_>` * Rustfmt
1 parent fc0dedc commit 37482d9

File tree

133 files changed

+1260
-1233
lines changed

Some content is hidden

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

133 files changed

+1260
-1233
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
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.82
33+
image: rust:1.85
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.82
42+
image: rust:1.85
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.82
53+
image: rust:1.85
5454
steps:
5555
- uses: actions/checkout@v4
5656
- run: rustup target add wasm32-unknown-unknown
@@ -67,7 +67,7 @@ jobs:
6767
check-features:
6868
runs-on: ubuntu-latest
6969
container:
70-
image: rust:1.82
70+
image: rust:1.85
7171
steps:
7272
- uses: actions/checkout@v4
7373
- uses: Swatinem/rust-cache@v2
@@ -101,7 +101,7 @@ jobs:
101101
check-no-std:
102102
runs-on: ubuntu-latest
103103
container:
104-
image: rust:1.82
104+
image: rust:1.85
105105
steps:
106106
- uses: actions/checkout@v4
107107
- run: rustup target add thumbv7m-none-eabi
@@ -113,7 +113,7 @@ jobs:
113113
check-rustdoc-links:
114114
runs-on: ubuntu-latest
115115
container:
116-
image: rust:1.82
116+
image: rust:1.85
117117
steps:
118118
- uses: actions/checkout@v4
119119
- uses: Swatinem/rust-cache@v2
@@ -122,7 +122,7 @@ jobs:
122122
fmt:
123123
runs-on: ubuntu-latest
124124
container:
125-
image: rust:1.82
125+
image: rust:1.85
126126
steps:
127127
# Checks `rustfmt` formatting
128128
- uses: actions/checkout@v4
@@ -136,7 +136,7 @@ jobs:
136136
clippy:
137137
runs-on: ubuntu-latest
138138
container:
139-
image: rust:1.82
139+
image: rust:1.85
140140
steps:
141141
- uses: actions/checkout@v4
142142
# Since build artifacts are specific to a nightly version, we pin the specific nightly
@@ -177,7 +177,7 @@ jobs:
177177
wasm-node-versions-match:
178178
runs-on: ubuntu-latest
179179
container:
180-
image: rust:1.82
180+
image: rust:1.85
181181
steps:
182182
- uses: actions/checkout@v4
183183
- run: apt-get update && apt install -y jq

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
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.82
59+
image: rust:1.85
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.82
86+
image: rust:1.85
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.82
107+
image: rust:1.85
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.82
177+
image: rust:1.85
178178
steps:
179179
- uses: actions/checkout@v4
180180
- run: rustup target add wasm32-unknown-unknown
@@ -218,7 +218,7 @@ jobs:
218218
- uses: actions-rs/toolchain@v1
219219
with:
220220
# Ideally we don't want to install any toolchain, but the GH action doesn't support this.
221-
toolchain: 1.82
221+
toolchain: 1.85
222222
profile: minimal
223223
- uses: Swatinem/rust-cache@v2
224224
- id: compute-tag # Compute the tag that we might push.
@@ -245,7 +245,7 @@ jobs:
245245
crates-io-publish:
246246
runs-on: ubuntu-latest
247247
container:
248-
image: rust:1.82
248+
image: rust:1.85
249249
steps:
250250
- uses: actions/checkout@v4
251251
- run: cargo publish --dry-run --locked

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

Lines changed: 1 addition & 1 deletion
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.82
12+
image: rust:1.85
1313
steps:
1414
- uses: actions/checkout@v4
1515
# Note: `cargo update --workspace` doesn't seem to have any effect.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ members = [
1111
[workspace.package]
1212
authors = ["Parity Technologies <admin@parity.io>", "Pierre Krieger <pierre.krieger1708@gmail.com>"]
1313
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
14-
edition = "2021"
14+
edition = "2024"
1515
repository = "https://github.com/smol-dot/smoldot"
1616
include = ["**/*.rs"] # Only Rust files are included, as anything else might be a test fixture.
1717

full-node/bin/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
use smoldot::{
3333
identity::seed_phrase,
3434
libp2p::{
35-
multiaddr::{Multiaddr, Protocol},
3635
PeerId,
36+
multiaddr::{Multiaddr, Protocol},
3737
},
3838
};
3939
use std::{io, net::SocketAddr, path::PathBuf};

full-node/src/consensus_service.rs

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
// TODO: doc
2525
// TODO: re-review this once finished
2626

27-
use crate::{database_thread, jaeger_service, network_service, LogCallback, LogLevel};
27+
use crate::{LogCallback, LogLevel, database_thread, jaeger_service, network_service};
2828

2929
use futures_channel::{mpsc, oneshot};
3030
use futures_lite::FutureExt as _;
3131
use futures_util::{
32-
future,
32+
SinkExt as _, StreamExt as _, future,
3333
stream::{self, FuturesUnordered},
34-
SinkExt as _, StreamExt as _,
3534
};
3635
use hashbrown::HashSet;
3736
use rand::seq::IteratorRandom;
@@ -52,9 +51,7 @@ use smoldot::{
5251
use std::{
5352
array,
5453
borrow::Cow,
55-
cmp,
56-
future::Future,
57-
iter,
54+
cmp, iter,
5855
num::NonZero,
5956
pin::Pin,
6057
sync::Arc,
@@ -227,7 +224,7 @@ impl ConsensusService {
227224
match database.to_chain_information(&finalized_block_hash) {
228225
Ok(info) => info,
229226
Err(full_sqlite::StorageAccessError::Corrupted(err)) => {
230-
return Err(InitError::DatabaseCorruption(err))
227+
return Err(InitError::DatabaseCorruption(err));
231228
}
232229
Err(full_sqlite::StorageAccessError::IncompleteStorage)
233230
| Err(full_sqlite::StorageAccessError::UnknownBlock) => unreachable!(),
@@ -240,7 +237,7 @@ impl ConsensusService {
240237
Ok(Some((code, _))) => code,
241238
Ok(None) => return Err(InitError::FinalizedCodeMissing),
242239
Err(full_sqlite::StorageAccessError::Corrupted(err)) => {
243-
return Err(InitError::DatabaseCorruption(err))
240+
return Err(InitError::DatabaseCorruption(err));
244241
}
245242
Err(full_sqlite::StorageAccessError::IncompleteStorage)
246243
| Err(full_sqlite::StorageAccessError::UnknownBlock) => unreachable!(),
@@ -253,7 +250,7 @@ impl ConsensusService {
253250
Ok(Some((hp, _))) => Some(hp),
254251
Ok(None) => None,
255252
Err(full_sqlite::StorageAccessError::Corrupted(err)) => {
256-
return Err(InitError::DatabaseCorruption(err))
253+
return Err(InitError::DatabaseCorruption(err));
257254
}
258255
Err(full_sqlite::StorageAccessError::IncompleteStorage)
259256
| Err(full_sqlite::StorageAccessError::UnknownBlock) => unreachable!(),
@@ -1138,23 +1135,25 @@ impl SyncBackground {
11381135
request: all::DesiredRequest::StorageGetMerkleProof {
11391136
block_hash: missing_item.hash,
11401137
state_trie_root: [0; 32], // TODO: wrong, but field value unused so it's fine temporarily
1141-
keys: vec![trie::nibbles_to_bytes_suffix_extend(
1142-
missing_item
1143-
.trie_node_key_nibbles
1144-
.into_iter()
1145-
// In order to download more than one item at a time,
1146-
// we add some randomly-generated nibbles to the
1147-
// requested key. The request will target the missing
1148-
// key plus a few other random keys.
1149-
.chain((0..32).map(|_| {
1150-
rand::Rng::gen_range(
1151-
&mut rand::thread_rng(),
1152-
0..16,
1153-
)
1154-
}))
1155-
.map(|n| trie::Nibble::try_from(n).unwrap()),
1156-
)
1157-
.collect::<Vec<_>>()],
1138+
keys: vec![
1139+
trie::nibbles_to_bytes_suffix_extend(
1140+
missing_item
1141+
.trie_node_key_nibbles
1142+
.into_iter()
1143+
// In order to download more than one item at a time,
1144+
// we add some randomly-generated nibbles to the
1145+
// requested key. The request will target the missing
1146+
// key plus a few other random keys.
1147+
.chain((0..32).map(|_| {
1148+
rand::Rng::gen_range(
1149+
&mut rand::thread_rng(),
1150+
0..16,
1151+
)
1152+
}))
1153+
.map(|n| trie::Nibble::try_from(n).unwrap()),
1154+
)
1155+
.collect::<Vec<_>>(),
1156+
],
11581157
},
11591158
database_catch_up_type: DbCatchUpType::Database,
11601159
};
@@ -3042,12 +3041,12 @@ pub async fn execute_block_and_insert(
30423041
Err(RuntimeCallError::RuntimeStartError(error)) => {
30433042
return Err(ExecuteBlockError::VerificationFailure(
30443043
ExecuteBlockVerificationFailureError::RuntimeStartError(error),
3045-
))
3044+
));
30463045
}
30473046
Err(RuntimeCallError::RuntimeExecutionError(error)) => {
30483047
return Err(ExecuteBlockError::InvalidBlock(
30493048
ExecuteBlockInvalidBlockError::RuntimeExecutionError(error),
3050-
))
3049+
));
30513050
}
30523051
Err(RuntimeCallError::DatabaseParentAccess(error)) => {
30533052
return Err(ExecuteBlockError::VerificationFailure(
@@ -3058,17 +3057,17 @@ pub async fn execute_block_and_insert(
30583057
parameter: call_parameter.to_owned(),
30593058
},
30603059
},
3061-
))
3060+
));
30623061
}
30633062
Err(RuntimeCallError::ForbiddenHostFunction) => {
30643063
return Err(ExecuteBlockError::VerificationFailure(
30653064
ExecuteBlockVerificationFailureError::ForbiddenHostFunction,
3066-
))
3065+
));
30673066
}
30683067
Err(RuntimeCallError::DatabaseInvalidStateTrieVersion) => {
30693068
return Err(ExecuteBlockError::VerificationFailure(
30703069
ExecuteBlockVerificationFailureError::DatabaseInvalidStateTrieVersion,
3071-
))
3070+
));
30723071
}
30733072
}
30743073
}
@@ -3086,7 +3085,7 @@ pub async fn execute_block_and_insert(
30863085
Some(None) => {
30873086
return Err(ExecuteBlockError::InvalidBlock(
30883087
ExecuteBlockInvalidBlockError::EmptyCode,
3089-
))
3088+
));
30903089
}
30913090
None => {
30923091
let parent_block_hash = *parent_block_hash;
@@ -3104,7 +3103,7 @@ pub async fn execute_block_and_insert(
31043103
Ok(None) => {
31053104
return Err(ExecuteBlockError::VerificationFailure(
31063105
ExecuteBlockVerificationFailureError::ParentCodeEmptyInDatabase,
3107-
))
3106+
));
31083107
}
31093108
Err(error) => return Err(ExecuteBlockError::VerificationFailure(
31103109
ExecuteBlockVerificationFailureError::DatabaseParentAccess {

full-node/src/jaeger_service.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636

3737
use smol::{future, net::UdpSocket};
3838
use smoldot::libp2p::PeerId;
39-
use std::{
40-
convert::TryFrom as _, future::Future, io, net::SocketAddr, num::NonZero, pin::Pin, sync::Arc,
41-
};
39+
use std::{convert::TryFrom as _, io, net::SocketAddr, num::NonZero, pin::Pin, sync::Arc};
4240

4341
/// Configuration for a [`JaegerService`].
4442
pub struct Config<'a> {

full-node/src/json_rpc_service.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

18-
use crate::{consensus_service, database_thread, network_service, LogCallback, LogLevel};
18+
use crate::{LogCallback, LogLevel, consensus_service, database_thread, network_service};
1919
use futures_channel::oneshot;
2020
use futures_util::FutureExt;
2121
use smol::{
@@ -24,14 +24,13 @@ use smol::{
2424
};
2525
use smoldot::json_rpc::{methods, service};
2626
use std::{
27-
future::Future,
2827
io, mem,
2928
net::SocketAddr,
3029
num::NonZero,
3130
pin::Pin,
3231
sync::{
33-
atomic::{AtomicU32, Ordering},
3432
Arc,
33+
atomic::{AtomicU32, Ordering},
3534
},
3635
time::Duration,
3736
};
@@ -125,7 +124,7 @@ impl JsonRpcService {
125124
return Err(InitError::ListenError {
126125
bind_address: *addr,
127126
error,
128-
})
127+
});
129128
}
130129
};
131130

@@ -135,7 +134,7 @@ impl JsonRpcService {
135134
return Err(InitError::ListenError {
136135
bind_address: *addr,
137136
error,
138-
})
137+
});
139138
}
140139
},
141140
None => (None, None),

full-node/src/json_rpc_service/chain_head_subscriptions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use smoldot::{
2525
json_rpc::{methods, service},
2626
};
2727
use std::{
28-
future::Future,
2928
num::NonZero,
3029
pin::{self, Pin},
3130
sync::Arc,

full-node/src/json_rpc_service/legacy_api_subscriptions.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use hashbrown::HashMap;
1919
use smol::stream::StreamExt as _;
2020
use smoldot::{
2121
chain::fork_tree,
22-
executor::{host::HostVmPrototype, CoreVersion},
22+
executor::{CoreVersion, host::HostVmPrototype},
2323
trie,
2424
};
2525
use std::{collections::BTreeSet, iter, mem, num::NonZero, ops, pin::Pin, sync::Arc};
@@ -662,11 +662,8 @@ impl SubscribeStorage {
662662

663663
/// Returns the next storage change notification.
664664
pub async fn next_storage_update(
665-
&'_ mut self,
666-
) -> (
667-
[u8; 32],
668-
impl Iterator<Item = (Vec<u8>, Option<Vec<u8>>)> + '_,
669-
) {
665+
&mut self,
666+
) -> ([u8; 32], impl Iterator<Item = (Vec<u8>, Option<Vec<u8>>)>) {
670667
'main_subscription: loop {
671668
// Get the active consensus service subscription, or subscribe if necessary.
672669
let subscription = match &mut self.subscription {

0 commit comments

Comments
 (0)