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

chore: bump Rust 2024 edition #727

Merged
merged 4 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 2 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Install cargo-machete
uses: clechasseur/rs-cargo@v2
with:
command: install
args: cargo-machete@0.7.0
- name: Machete
uses: clechasseur/rs-cargo@v2
with:
command: machete
- name: machete
uses: bnjbvr/cargo-machete@main

proto:
name: proto check
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- [BREAKING] Update `GetBlockInputs` RPC (#709).
- [BREAKING] `CheckNullifiersByPrefix` now takes a starting block number (#707).
- [BREAKING] Removed nullifiers from `SyncState` endpoint (#708).
- [BREAKING] Updated to Rust Edition 2024 (#727).
- [BREAKING] MSRV bumped to 1.85 (#727).

### Enhancements

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ resolver = "2"

[workspace.package]
authors = ["Miden contributors"]
edition = "2021"
edition = "2024"
exclude = [".github/"]
homepage = "https://polygon.technology/polygon-miden"
license = "MIT"
readme = "README.md"
repository = "https://github.com/0xPolygonMiden/miden-node"
rust-version = "1.84"
rust-version = "1.85"
version = "0.8.0"

[workspace.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

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

These packages can be found under our [releases](https://github.com/0xPolygonMiden/miden-node/releases) page along with
a checksum.
Expand All @@ -73,7 +73,7 @@ sudo dpkg -i $package_name.deb

### Install using `cargo`

Install Rust version **1.84** or greater using the official Rust installation
Install Rust version **1.85** or greater using the official Rust installation
[instructions](https://www.rust-lang.org/tools/install).

Depending on the platform, you may need to install additional libraries. For example, on Ubuntu 22.04 the following
Expand Down
8 changes: 4 additions & 4 deletions bin/faucet/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use miden_node_proto::generated::{
rpc::api_client::ApiClient,
};
use miden_objects::{
Felt,
account::{Account, AccountFile, AccountId, AuthSecretKey},
asset::FungibleAsset,
block::{BlockHeader, BlockNumber},
Expand All @@ -20,17 +21,16 @@ use miden_objects::{
transaction::{ChainMmr, ExecutedTransaction, TransactionArgs, TransactionScript},
utils::Deserializable,
vm::AdviceMap,
Felt,
};
use miden_tx::{
auth::BasicAuthenticator, utils::Serializable, LocalTransactionProver, ProvingOptions,
TransactionExecutor, TransactionProver,
LocalTransactionProver, ProvingOptions, TransactionExecutor, TransactionProver,
auth::BasicAuthenticator, utils::Serializable,
};
use rand::{random, rngs::StdRng};
use tonic::transport::Channel;
use tracing::info;

use crate::{config::FaucetConfig, errors::ClientError, store::FaucetDataStore, COMPONENT};
use crate::{COMPONENT, config::FaucetConfig, errors::ClientError, store::FaucetDataStore};

pub const DISTRIBUTE_FUNGIBLE_ASSET_SCRIPT: &str =
include_str!("transaction_scripts/distribute_fungible_asset.masm");
Expand Down
2 changes: 1 addition & 1 deletion bin/faucet/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::Debug;

use axum::{
http::{header, StatusCode},
http::{StatusCode, header},
response::{IntoResponse, Response},
};
use miden_objects::AccountIdError;
Expand Down
4 changes: 2 additions & 2 deletions bin/faucet/src/handlers.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::Context;
use axum::{
Json,
extract::State,
http::{Response, StatusCode},
response::IntoResponse,
Json,
};
use http::header;
use http_body_util::Full;
Expand All @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize};
use tonic::body;
use tracing::info;

use crate::{errors::HandlerError, state::FaucetState, COMPONENT};
use crate::{COMPONENT, errors::HandlerError, state::FaucetState};

#[derive(Deserialize)]
pub struct FaucetRequest {
Expand Down
14 changes: 7 additions & 7 deletions bin/faucet/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ use std::path::PathBuf;

use anyhow::Context;
use axum::{
routing::{get, post},
Router,
routing::{get, post},
};
use clap::{Parser, Subcommand};
use client::initialize_faucet_client;
use handlers::{get_background, get_favicon, get_index_css, get_index_html, get_index_js};
use http::HeaderValue;
use miden_lib::{account::faucets::create_basic_fungible_faucet, AuthScheme};
use miden_lib::{AuthScheme, account::faucets::create_basic_fungible_faucet};
use miden_node_utils::{
config::load_config, crypto::get_rpo_random_coin, logging::OpenTelemetry, version::LongVersion,
};
use miden_objects::{
Felt,
account::{AccountFile, AccountStorageMode, AuthSecretKey},
asset::TokenSymbol,
crypto::dsa::rpo_falcon512::SecretKey,
Felt,
};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha20Rng;
Expand All @@ -38,7 +38,7 @@ use tower_http::{cors::CorsLayer, set_header::SetResponseHeaderLayer, trace::Tra
use tracing::info;

use crate::{
config::{FaucetConfig, DEFAULT_FAUCET_ACCOUNT_PATH},
config::{DEFAULT_FAUCET_ACCOUNT_PATH, FaucetConfig},
handlers::{get_metadata, get_tokens},
};

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

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

use fantoccini::ClientBuilder;
use serde_json::{json, Map};
use serde_json::{Map, json};
use url::Url;

use crate::{config::FaucetConfig, run_faucet_command, stub_rpc_api::serve_stub, Cli};
use crate::{Cli, config::FaucetConfig, run_faucet_command, stub_rpc_api::serve_stub};

/// This test starts a stub node, a faucet connected to the stub node, and a chromedriver
/// to test the faucet website. It then loads the website and checks that all the requests
Expand Down
2 changes: 1 addition & 1 deletion bin/faucet/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use static_files::Resource;
use tokio::sync::Mutex;
use tracing::info;

use crate::{client::FaucetClient, config::FaucetConfig, static_resources, COMPONENT};
use crate::{COMPONENT, client::FaucetClient, config::FaucetConfig, static_resources};

// FAUCET STATE
// ================================================================================================
Expand Down
2 changes: 1 addition & 1 deletion bin/faucet/src/store.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::sync::Mutex;

use miden_objects::{
Word,
account::{Account, AccountId},
block::{BlockHeader, BlockNumber},
note::NoteId,
transaction::{ChainMmr, InputNotes, TransactionInputs},
Word,
};
use miden_tx::{DataStore, DataStoreError};

Expand Down
18 changes: 12 additions & 6 deletions bin/node/src/commands/genesis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ use std::{
path::{Path, PathBuf},
};

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{Context, Result, anyhow, bail};
pub use inputs::{AccountInput, AuthSchemeInput, GenesisInput};
use miden_lib::{account::faucets::create_basic_fungible_faucet, AuthScheme};
use miden_lib::{AuthScheme, account::faucets::create_basic_fungible_faucet};
use miden_node_store::genesis::GenesisState;
use miden_node_utils::{config::load_config, crypto::get_rpo_random_coin};
use miden_objects::{
Felt, ONE,
account::{Account, AccountFile, AccountIdAnchor, AuthSecretKey},
asset::TokenSymbol,
crypto::{dsa::rpo_falcon512::SecretKey, utils::Serializable},
Felt, ONE,
};
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha20Rng;
Expand Down Expand Up @@ -45,7 +45,10 @@ pub fn make_genesis(inputs_path: &PathBuf, output_path: &PathBuf, force: bool) -
if !force {
if let Ok(file_exists) = output_path.try_exists() {
if file_exists {
return Err(anyhow!("Failed to generate new genesis file {} because it already exists. Use the --force flag to overwrite.", output_path.display()));
return Err(anyhow!(
"Failed to generate new genesis file {} because it already exists. Use the --force flag to overwrite.",
output_path.display()
));
}
} else {
return Err(anyhow!("Failed to open {} file.", output_path.display()));
Expand Down Expand Up @@ -118,7 +121,7 @@ fn create_accounts(

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

if !force && matches!(path.try_exists(), Ok(true)) {
bail!("Failed to generate account file {} because it already exists. Use the --force flag to overwrite.", path.display());
bail!(
"Failed to generate account file {} because it already exists. Use the --force flag to overwrite.",
path.display()
);
}

account_data.account.set_nonce(ONE)?;
Expand Down
2 changes: 1 addition & 1 deletion bin/node/src/commands/init.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{fs::File, io::Write, path::Path};

use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};

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

Expand Down
2 changes: 1 addition & 1 deletion bin/node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ mod tests {

use super::NodeConfig;
use crate::{
config::{NormalizedBlockProducerConfig, NormalizedRpcConfig},
NODE_CONFIG_FILE_PATH,
config::{NormalizedBlockProducerConfig, NormalizedRpcConfig},
};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion bin/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use std::path::PathBuf;

use anyhow::{anyhow, Context};
use anyhow::{Context, anyhow};
use clap::{Parser, Subcommand};
use commands::{init::init_config_files, start::start_node};
use miden_node_block_producer::server::BlockProducer;
Expand Down
10 changes: 5 additions & 5 deletions crates/block-producer/src/batch_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ use std::{num::NonZeroUsize, ops::Range, time::Duration};
use miden_node_proto::domain::batch::BatchInputs;
use miden_node_utils::formatting::format_array;
use miden_objects::{
batch::{BatchId, ProposedBatch, ProvenBatch},
MIN_PROOF_SECURITY_LEVEL,
batch::{BatchId, ProposedBatch, ProvenBatch},
};
use miden_tx_batch_prover::LocalBatchProver;
use rand::Rng;
use tokio::{task::JoinSet, time};
use tracing::{debug, info, instrument, Span};
use tracing::{Span, debug, info, instrument};

use crate::{
domain::transaction::AuthenticatedTransaction, errors::BuildBatchError, mempool::SharedMempool,
store::StoreClient, COMPONENT, SERVER_BUILD_BATCH_FREQUENCY,
COMPONENT, SERVER_BUILD_BATCH_FREQUENCY, domain::transaction::AuthenticatedTransaction,
errors::BuildBatchError, mempool::SharedMempool, store::StoreClient,
};

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

async move {
Expand Down
10 changes: 5 additions & 5 deletions crates/block-producer/src/block_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ use futures::FutureExt;
use miden_block_prover::LocalBlockProver;
use miden_node_utils::tracing::OpenTelemetrySpanExt;
use miden_objects::{
MIN_PROOF_SECURITY_LEVEL,
batch::ProvenBatch,
block::{BlockInputs, BlockNumber, ProposedBlock, ProvenBlock},
note::NoteHeader,
MIN_PROOF_SECURITY_LEVEL,
};
use rand::Rng;
use tokio::time::Duration;
use tracing::{instrument, Span};
use tracing::{Span, instrument};

use crate::{
errors::BuildBlockError, mempool::SharedMempool, store::StoreClient, COMPONENT,
SERVER_BLOCK_FREQUENCY,
COMPONENT, SERVER_BLOCK_FREQUENCY, errors::BuildBlockError, mempool::SharedMempool,
store::StoreClient,
};

// BLOCK BUILDER
Expand Down Expand Up @@ -234,7 +234,7 @@ impl BlockBuilder {

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

Span::current().set_attribute("failure_rate", self.failure_rate);
Span::current().set_attribute("dice_roll", roll);
Expand Down
2 changes: 1 addition & 1 deletion crates/block-producer/src/domain/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::{collections::BTreeSet, sync::Arc};

use miden_objects::{
Digest,
account::AccountId,
block::BlockNumber,
note::{NoteId, Nullifier},
transaction::{ProvenTransaction, TransactionId, TxAccountUpdate},
Digest,
};

use crate::{errors::VerifyTxError, store::TransactionInputs};
Expand Down
6 changes: 4 additions & 2 deletions crates/block-producer/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use miden_block_prover::ProvenBlockError;
use miden_node_proto::errors::ConversionError;
use miden_node_utils::formatting::format_opt;
use miden_objects::{
Digest, ProposedBatchError, ProposedBlockError,
block::BlockNumber,
note::{NoteId, Nullifier},
transaction::TransactionId,
Digest, ProposedBatchError, ProposedBlockError,
};
use miden_tx_batch_prover::errors::ProvenBatchError;
use thiserror::Error;
Expand Down Expand Up @@ -80,7 +80,9 @@ pub enum AddTransactionError {
#[error("transaction verification failed")]
VerificationFailed(#[from] VerifyTxError),

#[error("transaction input data from block {input_block} is rejected as stale because it is older than the limit of {stale_limit}")]
#[error(
"transaction input data from block {input_block} is rejected as stale because it is older than the limit of {stale_limit}"
)]
StaleInputs {
input_block: BlockNumber,
stale_limit: BlockNumber,
Expand Down
2 changes: 1 addition & 1 deletion crates/block-producer/src/mempool/batch_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use miden_objects::{
};

use super::{
graph::{DependencyGraph, GraphError},
BlockBudget, BudgetStatus,
graph::{DependencyGraph, GraphError},
};

// BATCH GRAPH
Expand Down
Loading
Loading