Skip to content

Commit f9ab405

Browse files
chore: upgrade to Rust 2024 edition (#727)
1 parent 3c5f411 commit f9ab405

Some content is hidden

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

62 files changed

+150
-148
lines changed

.github/workflows/lint.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,8 @@ jobs:
9494
runs-on: ubuntu-latest
9595
steps:
9696
- uses: actions/checkout@main
97-
- name: Install cargo-machete
98-
uses: clechasseur/rs-cargo@v2
99-
with:
100-
command: install
101-
args: cargo-machete@0.7.0
102-
- name: Machete
103-
uses: clechasseur/rs-cargo@v2
104-
with:
105-
command: machete
97+
- name: machete
98+
uses: bnjbvr/cargo-machete@main
10699

107100
proto:
108101
name: proto check

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
- [BREAKING] Update `GetBlockInputs` RPC (#709).
2222
- [BREAKING] `CheckNullifiersByPrefix` now takes a starting block number (#707).
2323
- [BREAKING] Removed nullifiers from `SyncState` endpoint (#708).
24+
- [BREAKING] Updated to Rust Edition 2024 (#727).
25+
- [BREAKING] MSRV bumped to 1.85 (#727).
2426

2527
### Enhancements
2628

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ resolver = "2"
1515

1616
[workspace.package]
1717
authors = ["Miden contributors"]
18-
edition = "2021"
18+
edition = "2024"
1919
exclude = [".github/"]
2020
homepage = "https://polygon.technology/polygon-miden"
2121
license = "MIT"
2222
readme = "README.md"
2323
repository = "https://github.com/0xPolygonMiden/miden-node"
24-
rust-version = "1.84"
24+
rust-version = "1.85"
2525
version = "0.8.0"
2626

2727
[workspace.dependencies]

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/0xPolygonMiden/miden-node/blob/main/LICENSE)
44
[![test](https://github.com/0xPolygonMiden/miden-node/actions/workflows/test.yml/badge.svg)](https://github.com/0xPolygonMiden/miden-node/actions/workflows/test.yml)
5-
[![RUST_VERSION](https://img.shields.io/badge/rustc-1.84+-lightgray.svg)](https://www.rust-lang.org/tools/install)
5+
[![RUST_VERSION](https://img.shields.io/badge/rustc-1.85+-lightgray.svg)](https://www.rust-lang.org/tools/install)
66
[![crates.io](https://img.shields.io/crates/v/miden-node)](https://crates.io/crates/miden-node)
77

88
This repository holds the Miden node; that is, the software which processes transactions and creates blocks for the
@@ -48,7 +48,7 @@ source.
4848
### Debian package
4949

5050
Debian packages are available and are the fastest way to install the node on a Debian-based system. Both `amd64` and
51-
`arm64` packages are available.
51+
`arm64` packages are available.
5252

5353
These packages can be found under our [releases](https://github.com/0xPolygonMiden/miden-node/releases) page along with
5454
a checksum.
@@ -73,7 +73,7 @@ sudo dpkg -i $package_name.deb
7373
7474
### Install using `cargo`
7575
76-
Install Rust version **1.84** or greater using the official Rust installation
76+
Install Rust version **1.85** or greater using the official Rust installation
7777
[instructions](https://www.rust-lang.org/tools/install).
7878
7979
Depending on the platform, you may need to install additional libraries. For example, on Ubuntu 22.04 the following

bin/faucet/src/client.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use miden_node_proto::generated::{
99
rpc::api_client::ApiClient,
1010
};
1111
use miden_objects::{
12+
Felt,
1213
account::{Account, AccountFile, AccountId, AuthSecretKey},
1314
asset::FungibleAsset,
1415
block::{BlockHeader, BlockNumber},
@@ -20,17 +21,16 @@ use miden_objects::{
2021
transaction::{ChainMmr, ExecutedTransaction, TransactionArgs, TransactionScript},
2122
utils::Deserializable,
2223
vm::AdviceMap,
23-
Felt,
2424
};
2525
use miden_tx::{
26-
auth::BasicAuthenticator, utils::Serializable, LocalTransactionProver, ProvingOptions,
27-
TransactionExecutor, TransactionProver,
26+
LocalTransactionProver, ProvingOptions, TransactionExecutor, TransactionProver,
27+
auth::BasicAuthenticator, utils::Serializable,
2828
};
2929
use rand::{random, rngs::StdRng};
3030
use tonic::transport::Channel;
3131
use tracing::info;
3232

33-
use crate::{config::FaucetConfig, errors::ClientError, store::FaucetDataStore, COMPONENT};
33+
use crate::{COMPONENT, config::FaucetConfig, errors::ClientError, store::FaucetDataStore};
3434

3535
pub const DISTRIBUTE_FUNGIBLE_ASSET_SCRIPT: &str =
3636
include_str!("transaction_scripts/distribute_fungible_asset.masm");

bin/faucet/src/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::Debug;
22

33
use axum::{
4-
http::{header, StatusCode},
4+
http::{StatusCode, header},
55
response::{IntoResponse, Response},
66
};
77
use miden_objects::AccountIdError;

bin/faucet/src/handlers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use anyhow::Context;
22
use axum::{
3+
Json,
34
extract::State,
45
http::{Response, StatusCode},
56
response::IntoResponse,
6-
Json,
77
};
88
use http::header;
99
use http_body_util::Full;
@@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
1616
use tonic::body;
1717
use tracing::info;
1818

19-
use crate::{errors::HandlerError, state::FaucetState, COMPONENT};
19+
use crate::{COMPONENT, errors::HandlerError, state::FaucetState};
2020

2121
#[derive(Deserialize)]
2222
pub struct FaucetRequest {

bin/faucet/src/main.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ use std::path::PathBuf;
1212

1313
use anyhow::Context;
1414
use axum::{
15-
routing::{get, post},
1615
Router,
16+
routing::{get, post},
1717
};
1818
use clap::{Parser, Subcommand};
1919
use client::initialize_faucet_client;
2020
use handlers::{get_background, get_favicon, get_index_css, get_index_html, get_index_js};
2121
use http::HeaderValue;
22-
use miden_lib::{account::faucets::create_basic_fungible_faucet, AuthScheme};
22+
use miden_lib::{AuthScheme, account::faucets::create_basic_fungible_faucet};
2323
use miden_node_utils::{
2424
config::load_config, crypto::get_rpo_random_coin, logging::OpenTelemetry, version::LongVersion,
2525
};
2626
use miden_objects::{
27+
Felt,
2728
account::{AccountFile, AccountStorageMode, AuthSecretKey},
2829
asset::TokenSymbol,
2930
crypto::dsa::rpo_falcon512::SecretKey,
30-
Felt,
3131
};
3232
use rand::{Rng, SeedableRng};
3333
use rand_chacha::ChaCha20Rng;
@@ -38,7 +38,7 @@ use tower_http::{cors::CorsLayer, set_header::SetResponseHeaderLayer, trace::Tra
3838
use tracing::info;
3939

4040
use crate::{
41-
config::{FaucetConfig, DEFAULT_FAUCET_ACCOUNT_PATH},
41+
config::{DEFAULT_FAUCET_ACCOUNT_PATH, FaucetConfig},
4242
handlers::{get_metadata, get_tokens},
4343
};
4444

@@ -170,7 +170,7 @@ async fn run_faucet_command(cli: Cli) -> anyhow::Result<()> {
170170
let secret = SecretKey::with_rng(&mut get_rpo_random_coin(&mut rng));
171171

172172
let (account, account_seed) = create_basic_fungible_faucet(
173-
rng.gen(),
173+
rng.r#gen(),
174174
(&root_block_header).try_into().context("failed to create anchor block")?,
175175
TokenSymbol::try_from(token_symbol.as_str())
176176
.context("failed to parse token symbol")?,
@@ -249,10 +249,10 @@ mod test {
249249
};
250250

251251
use fantoccini::ClientBuilder;
252-
use serde_json::{json, Map};
252+
use serde_json::{Map, json};
253253
use url::Url;
254254

255-
use crate::{config::FaucetConfig, run_faucet_command, stub_rpc_api::serve_stub, Cli};
255+
use crate::{Cli, config::FaucetConfig, run_faucet_command, stub_rpc_api::serve_stub};
256256

257257
/// This test starts a stub node, a faucet connected to the stub node, and a chromedriver
258258
/// to test the faucet website. It then loads the website and checks that all the requests

bin/faucet/src/state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use static_files::Resource;
55
use tokio::sync::Mutex;
66
use tracing::info;
77

8-
use crate::{client::FaucetClient, config::FaucetConfig, static_resources, COMPONENT};
8+
use crate::{COMPONENT, client::FaucetClient, config::FaucetConfig, static_resources};
99

1010
// FAUCET STATE
1111
// ================================================================================================

bin/faucet/src/store.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::sync::Mutex;
22

33
use miden_objects::{
4+
Word,
45
account::{Account, AccountId},
56
block::{BlockHeader, BlockNumber},
67
note::NoteId,
78
transaction::{ChainMmr, InputNotes, TransactionInputs},
8-
Word,
99
};
1010
use miden_tx::{DataStore, DataStoreError};
1111

bin/node/src/commands/genesis/mod.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ use std::{
33
path::{Path, PathBuf},
44
};
55

6-
use anyhow::{anyhow, bail, Context, Result};
6+
use anyhow::{Context, Result, anyhow, bail};
77
pub use inputs::{AccountInput, AuthSchemeInput, GenesisInput};
8-
use miden_lib::{account::faucets::create_basic_fungible_faucet, AuthScheme};
8+
use miden_lib::{AuthScheme, account::faucets::create_basic_fungible_faucet};
99
use miden_node_store::genesis::GenesisState;
1010
use miden_node_utils::{config::load_config, crypto::get_rpo_random_coin};
1111
use miden_objects::{
12+
Felt, ONE,
1213
account::{Account, AccountFile, AccountIdAnchor, AuthSecretKey},
1314
asset::TokenSymbol,
1415
crypto::{dsa::rpo_falcon512::SecretKey, utils::Serializable},
15-
Felt, ONE,
1616
};
1717
use rand::{Rng, SeedableRng};
1818
use rand_chacha::ChaCha20Rng;
@@ -45,7 +45,10 @@ pub fn make_genesis(inputs_path: &PathBuf, output_path: &PathBuf, force: bool) -
4545
if !force {
4646
if let Ok(file_exists) = output_path.try_exists() {
4747
if file_exists {
48-
return Err(anyhow!("Failed to generate new genesis file {} because it already exists. Use the --force flag to overwrite.", output_path.display()));
48+
return Err(anyhow!(
49+
"Failed to generate new genesis file {} because it already exists. Use the --force flag to overwrite.",
50+
output_path.display()
51+
));
4952
}
5053
} else {
5154
return Err(anyhow!("Failed to open {} file.", output_path.display()));
@@ -118,7 +121,7 @@ fn create_accounts(
118121

119122
let storage_mode = inputs.storage_mode.as_str().try_into()?;
120123
let (account, account_seed) = create_basic_fungible_faucet(
121-
rng.gen(),
124+
rng.r#gen(),
122125
AccountIdAnchor::PRE_GENESIS,
123126
TokenSymbol::try_from(inputs.token_symbol.as_str())?,
124127
inputs.decimals,
@@ -142,7 +145,10 @@ fn create_accounts(
142145
let path = accounts_path.as_ref().join(format!("{name}.mac"));
143146

144147
if !force && matches!(path.try_exists(), Ok(true)) {
145-
bail!("Failed to generate account file {} because it already exists. Use the --force flag to overwrite.", path.display());
148+
bail!(
149+
"Failed to generate account file {} because it already exists. Use the --force flag to overwrite.",
150+
path.display()
151+
);
146152
}
147153

148154
account_data.account.set_nonce(ONE)?;

bin/node/src/commands/init.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{fs::File, io::Write, path::Path};
22

3-
use anyhow::{anyhow, Result};
3+
use anyhow::{Result, anyhow};
44

55
use crate::{commands::genesis::GenesisInput, config::NodeConfig};
66

bin/node/src/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ mod tests {
7979

8080
use super::NodeConfig;
8181
use crate::{
82-
config::{NormalizedBlockProducerConfig, NormalizedRpcConfig},
8382
NODE_CONFIG_FILE_PATH,
83+
config::{NormalizedBlockProducerConfig, NormalizedRpcConfig},
8484
};
8585

8686
#[test]

bin/node/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use std::path::PathBuf;
66

7-
use anyhow::{anyhow, Context};
7+
use anyhow::{Context, anyhow};
88
use clap::{Parser, Subcommand};
99
use commands::{init::init_config_files, start::start_node};
1010
use miden_node_block_producer::server::BlockProducer;

crates/block-producer/src/batch_builder/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ use std::{num::NonZeroUsize, ops::Range, time::Duration};
33
use miden_node_proto::domain::batch::BatchInputs;
44
use miden_node_utils::formatting::format_array;
55
use miden_objects::{
6-
batch::{BatchId, ProposedBatch, ProvenBatch},
76
MIN_PROOF_SECURITY_LEVEL,
7+
batch::{BatchId, ProposedBatch, ProvenBatch},
88
};
99
use miden_tx_batch_prover::LocalBatchProver;
1010
use rand::Rng;
1111
use tokio::{task::JoinSet, time};
12-
use tracing::{debug, info, instrument, Span};
12+
use tracing::{Span, debug, info, instrument};
1313

1414
use crate::{
15-
domain::transaction::AuthenticatedTransaction, errors::BuildBatchError, mempool::SharedMempool,
16-
store::StoreClient, COMPONENT, SERVER_BUILD_BATCH_FREQUENCY,
15+
COMPONENT, SERVER_BUILD_BATCH_FREQUENCY, domain::transaction::AuthenticatedTransaction,
16+
errors::BuildBatchError, mempool::SharedMempool, store::StoreClient,
1717
};
1818

1919
// BATCH BUILDER
@@ -212,7 +212,7 @@ impl WorkerPool {
212212
// Randomly fail batches at the configured rate.
213213
//
214214
// Note: Rng::gen rolls between [0, 1.0) for f32, so this works as expected.
215-
let failed = rand::thread_rng().gen::<f32>() < self.failure_rate;
215+
let failed = rand::thread_rng().r#gen::<f32>() < self.failure_rate;
216216
let store = self.store.clone();
217217

218218
async move {

crates/block-producer/src/block_builder/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ use futures::FutureExt;
44
use miden_block_prover::LocalBlockProver;
55
use miden_node_utils::tracing::OpenTelemetrySpanExt;
66
use miden_objects::{
7+
MIN_PROOF_SECURITY_LEVEL,
78
batch::ProvenBatch,
89
block::{BlockInputs, BlockNumber, ProposedBlock, ProvenBlock},
910
note::NoteHeader,
10-
MIN_PROOF_SECURITY_LEVEL,
1111
};
1212
use rand::Rng;
1313
use tokio::time::Duration;
14-
use tracing::{instrument, Span};
14+
use tracing::{Span, instrument};
1515

1616
use crate::{
17-
errors::BuildBlockError, mempool::SharedMempool, store::StoreClient, COMPONENT,
18-
SERVER_BLOCK_FREQUENCY,
17+
COMPONENT, SERVER_BLOCK_FREQUENCY, errors::BuildBlockError, mempool::SharedMempool,
18+
store::StoreClient,
1919
};
2020

2121
// BLOCK BUILDER
@@ -234,7 +234,7 @@ impl BlockBuilder {
234234

235235
#[instrument(target = COMPONENT, name = "block_builder.inject_failure", skip_all, err)]
236236
fn inject_failure<T>(&self, value: T) -> Result<T, BuildBlockError> {
237-
let roll = rand::thread_rng().gen::<f64>();
237+
let roll = rand::thread_rng().r#gen::<f64>();
238238

239239
Span::current().set_attribute("failure_rate", self.failure_rate);
240240
Span::current().set_attribute("dice_roll", roll);

crates/block-producer/src/domain/transaction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::{collections::BTreeSet, sync::Arc};
22

33
use miden_objects::{
4+
Digest,
45
account::AccountId,
56
block::BlockNumber,
67
note::{NoteId, Nullifier},
78
transaction::{ProvenTransaction, TransactionId, TxAccountUpdate},
8-
Digest,
99
};
1010

1111
use crate::{errors::VerifyTxError, store::TransactionInputs};

crates/block-producer/src/errors.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use miden_block_prover::ProvenBlockError;
22
use miden_node_proto::errors::ConversionError;
33
use miden_node_utils::formatting::format_opt;
44
use miden_objects::{
5+
Digest, ProposedBatchError, ProposedBlockError,
56
block::BlockNumber,
67
note::{NoteId, Nullifier},
78
transaction::TransactionId,
8-
Digest, ProposedBatchError, ProposedBlockError,
99
};
1010
use miden_tx_batch_prover::errors::ProvenBatchError;
1111
use thiserror::Error;
@@ -80,7 +80,9 @@ pub enum AddTransactionError {
8080
#[error("transaction verification failed")]
8181
VerificationFailed(#[from] VerifyTxError),
8282

83-
#[error("transaction input data from block {input_block} is rejected as stale because it is older than the limit of {stale_limit}")]
83+
#[error(
84+
"transaction input data from block {input_block} is rejected as stale because it is older than the limit of {stale_limit}"
85+
)]
8486
StaleInputs {
8587
input_block: BlockNumber,
8688
stale_limit: BlockNumber,

crates/block-producer/src/mempool/batch_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use miden_objects::{
77
};
88

99
use super::{
10-
graph::{DependencyGraph, GraphError},
1110
BlockBudget, BudgetStatus,
11+
graph::{DependencyGraph, GraphError},
1212
};
1313

1414
// BATCH GRAPH

0 commit comments

Comments
 (0)