Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
8822d27
build: change unused to unused_assignments, remove large enum exceptions
iostat Dec 18, 2025
8403a8d
tools/bootstrap-sandbox: remove unused Error enum
iostat Dec 18, 2025
d49da27
cli: remove unused import
iostat Dec 18, 2025
c5b4a2a
node: address unused_mut in scan_state_summary
iostat Dec 18, 2025
02c5285
ledger: ignore large_enum_variants in tests::ExternalSnarkWorkerRequest
iostat Dec 18, 2025
f50f4e9
p2p/webrtc: address large_enum_variant in PeerCmdAll
iostat Dec 18, 2025
ba9151c
ledger: address large_enum_variant by boxing TxWitness in snark_work
iostat Dec 18, 2025
3b0a2e3
node: allow large_enum_variant for EventSourceAction as it extends Event
iostat Dec 18, 2025
7292ed2
ledger: Allow large_enum_variant in LedgerRequest as it's storing pro…
iostat Dec 18, 2025
1d42af3
node: box large_enum_variant (6kb!) in RpcSnarkerJobSpecResponse::Ok
iostat Dec 18, 2025
301308f
node: allow large_enum_variant in state::P2p as it's a redux state
iostat Dec 18, 2025
ac0b3c8
p2p: box large_enum_variant P2pPeerStatusReady
iostat Dec 18, 2025
8d814e1
node: box large_enum_variant TransitionFrontierGenesisAction::LedgerL…
iostat Dec 18, 2025
b6478e1
p2p: allow large_enum_variant P2pChannelsStreamingRpcState as the hap…
iostat Dec 18, 2025
0f85bf3
node,p2p: box large_enum_variant P2pChannelEvent::Received
iostat Dec 18, 2025
5d23d02
node: expect a clippy::result_large_err which is ok in this particula…
iostat Dec 18, 2025
db82285
changelog: add entry for #1968
iostat Dec 18, 2025
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Docker compose files**: replace old environment by local in
docker-compose.block-producer.yml
([#1916](https://github.com/o1-labs/mina-rust/pull/1916)
- **CI**: Remove clippy exceptions for large enum/err variants added
as part of the Rust 1.92 upgrade
[#1968](https://github.com/o1-labs/mina-rust/pull/1968)

### Changes

Expand Down
8 changes: 2 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,12 @@ format-md: ## Format all markdown and MDX files to wrap at 80 characters
.PHONY: lint
lint: ## Run linter (clippy)
cargo clippy --all-targets -- -D warnings \
--allow clippy::large_enum_variant \
--allow clippy::result-large-err \
--allow unused
--allow unused_assignments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no... for the whole thing!?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I actually don't know the difference between unused_assignments vs unused)


.PHONY: lint-beta
lint-beta: ## Run linter (clippy) using beta Rust
cargo +beta clippy --all-targets -- -D warnings \
--allow clippy::large_enum_variant \
--allow clippy::result-large-err \
--allow unused
--allow unused_assignments

.PHONY: lint-bash
lint-bash: ## Check all shell scripts using shellcheck
Expand Down
1 change: 0 additions & 1 deletion crates/cli/src/commands/misc.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use libp2p_identity::PeerId;
use mina_node_account::AccountPublicKey;
use node::{account::AccountSecretKey, p2p::identity::SecretKey};
use std::{fs::File, io::Write};

Expand Down
1 change: 1 addition & 0 deletions crates/ledger/src/proofs/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4397,6 +4397,7 @@ pub(super) mod tests {

/// External worker input.
#[derive(Debug, BinProtRead, BinProtWrite)]
#[expect(clippy::large_enum_variant, reason = "This enum is only used in tests")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put this behind a feature flag if it's only used in tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to change in this PR, but can you create an issue before resolving the comment?

pub enum ExternalSnarkWorkerRequest {
/// Queries worker for readiness, expected reply is `true`.
AwaitReadiness,
Expand Down
10 changes: 8 additions & 2 deletions crates/ledger/src/scan_state/scan_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2142,7 +2142,10 @@ impl ScanState {
}
};

Ok(snark_work::spec::Work::Transition((statement, witness)))
Ok(snark_work::spec::Work::Transition((
statement,
Box::new(witness),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious to hear your opinion on this, but when it comes to wrapper types like this, I prefer to use witness.into(). That way, changes are minimized if we decide to have any other wrapper or anything like that.

(not a change for this PR, just interested in your thoughts)

)))
}
Extracted::Second(s) => {
let merged = s.0.statement().merge(&s.1.statement())?;
Expand Down Expand Up @@ -2196,7 +2199,10 @@ impl ScanState {
}
};

Some(snark_work::spec::Work::Transition((statement, witness)))
Some(snark_work::spec::Work::Transition((
statement,
Box::new(witness),
)))
}
Extracted::Second(s) => {
let merged = s.0.statement().merge(&s.1.statement()).unwrap();
Expand Down
3 changes: 2 additions & 1 deletion crates/ledger/src/scan_state/snark_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub mod spec {
};

pub enum Work {
Transition((Box<Statement<()>>, TransactionWitness)),
Transition((Box<Statement<()>>, Box<TransactionWitness>)),
Merge(Box<(Statement<()>, Box<(LedgerProof, LedgerProof)>)>),
}
}
Expand All @@ -30,6 +30,7 @@ mod tests {

/// External worker input.
#[derive(Debug, BinProtRead, BinProtWrite)]
#[expect(clippy::large_enum_variant, reason = "This enum is only used in tests")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment

pub enum ExternalSnarkWorkerRequest {
/// Queries worker for readiness, expected reply is `true`.
AwaitReadiness,
Expand Down
1 change: 1 addition & 0 deletions crates/node/src/event_source/event_source_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
pub type EventSourceActionWithMeta = redux::ActionWithMeta<EventSourceAction>;

#[derive(Serialize, Deserialize, Debug, Clone)]
#[expect(clippy::large_enum_variant, reason = "This enum extends super::Event")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 I'm not sure if I agree with this one. This should almost certainly be boxed, no?

Also... a nit... but... I would say "wraps," not "extends"

pub enum EventSourceAction {
/// Notify state machine that the new events might be received/available,
/// so trigger processing of those events.
Expand Down
9 changes: 4 additions & 5 deletions crates/node/src/event_source/event_source_effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ pub fn event_source_effects<S: Service>(store: &mut Store<S>, action: EventSourc
store.dispatch(P2pDisconnectionAction::Init { peer_id, reason });
}
Ok(message) => {
store.dispatch(P2pChannelsMessageReceivedAction {
peer_id,
message: Box::new(message),
});
store.dispatch(P2pChannelsMessageReceivedAction { peer_id, message });
}
},
P2pChannelEvent::Closed(peer_id, chan_id) => {
Expand Down Expand Up @@ -489,7 +486,9 @@ pub fn event_source_effects<S: Service>(store: &mut Store<S>, action: EventSourc
Event::GenesisLoad(res) => match res {
Err(err) => todo!("error while trying to load genesis config/ledger. - {err}"),
Ok(data) => {
store.dispatch(TransitionFrontierGenesisAction::LedgerLoadSuccess { data });
store.dispatch(TransitionFrontierGenesisAction::LedgerLoadSuccess {
data: Box::new(data),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is one of those places where I would use Into::into, just because it means this code doesn't change if the size of data changes

});
}
},
},
Expand Down
26 changes: 18 additions & 8 deletions crates/node/src/ledger/ledger_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,48 @@ use std::collections::BTreeMap;
/// can't be expressed in the Rust type system at the moment. For this
/// reason this type is private while functions wrapping the whole call
/// to the service are exposed as the service's methods.
#[allow(dead_code)] // TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😳

#[expect(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect?

clippy::large_enum_variant,
reason = "This is storing large messages, but size difference is only 2x between largest and second-largest variants"
)]
pub(super) enum LedgerRequest {
Write(LedgerWriteRequest),
Read(LedgerReadId, LedgerReadRequest),
/// expected response: `LedgerHash`
AccountsSet {
snarked_ledger_hash: LedgerHash,
parent: LedgerAddress,
accounts: Vec<MinaBaseAccountBinableArgStableV2>,
}, // expected response: LedgerHash
},
/// expected response: `Vec<Account>`
AccountsGet {
ledger_hash: LedgerHash,
account_ids: Vec<AccountId>,
}, // expected response: Vec<Account>
},
/// expected response: `ChildHashes`
ChildHashesGet {
snarked_ledger_hash: LedgerHash,
parent: LedgerAddress,
}, // expected response: ChildHashes
},
/// expected response: `Success`
ComputeSnarkedLedgerHashes {
snarked_ledger_hash: LedgerHash,
}, // expected response: Success
},
/// expected response: `SnarkedLedgerContentsCopied`
CopySnarkedLedgerContentsForSync {
origin_snarked_ledger_hash: Vec<LedgerHash>,
target_snarked_ledger_hash: LedgerHash,
overwrite: bool,
}, // expected response: SnarkedLedgerContentsCopied
},
/// expected response: `ProducersWithDelegatesMap`
GetProducersWithDelegates {
ledger_hash: LedgerHash,
filter: fn(&CompressedPubKey) -> bool,
}, // expected response: ProducersWithDelegatesMap
},
/// expected response: `LedgerMask`
GetMask {
ledger_hash: LedgerHash,
}, // expected response: LedgerMask
},
InsertGenesisLedger {
mask: Mask,
},
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/ledger/ledger_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ impl LedgerCtx {
.view()
.map(|jobs| {
let jobs = jobs.collect::<Vec<JobValueWithIndex<'_>>>();
let mut iter = jobs.iter().peekable();
let iter = jobs.iter().peekable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

let mut res = Vec::with_capacity(jobs.len());

for job in iter {
Expand Down
4 changes: 4 additions & 0 deletions crates/node/src/recorder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl RecordedActionWithMeta<'_> {
postcard::from_bytes(encoded)
}

#[expect(
clippy::result_large_err,
reason = "The error variant is the same Self which is moved in; shouldn't blow up the stack"
)]
pub fn as_action_with_meta(self) -> Result<ActionWithMeta, Self> {
if let Some(action) = self.action {
let action = action.into_owned();
Expand Down
2 changes: 1 addition & 1 deletion crates/node/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ pub enum RpcSnarkerJobCommitResponse {
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(tag = "kind")]
pub enum RpcSnarkerJobSpecResponse {
Ok(SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse),
Ok(Box<SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse>),
Err(SnarkWorkSpecError),
JobNotFound,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/node/src/rpc_effectful/rpc_effectful_effects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,14 @@ pub fn rpc_effects<S: Service>(store: &mut Store<S>, action: ActionWithMeta<RpcE
let fee = config.fee.clone();
let input = match input {
Ok(instances) => RpcSnarkerJobSpecResponse::Ok(
mina_p2p_messages::v2::SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse(Some((
Box::new(mina_p2p_messages::v2::SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponse(Some((
mina_p2p_messages::v2::SnarkWorkerWorkerRpcsVersionedGetWorkV2TResponseA0 {
instances,
fee,
},
public_key,
)))
),
)),
Err(err) => RpcSnarkerJobSpecResponse::Err(err),
};

Expand Down
4 changes: 4 additions & 0 deletions crates/node/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ impl State {

#[serde_with::serde_as]
#[derive(Debug, Clone, Serialize, Deserialize, MallocSizeOf)]
#[expect(
clippy::large_enum_variant,
reason = "Doesn't make sense moving redux state onto heap"
)]
pub enum P2p {
Pending(#[ignore_malloc_size_of = "constant"] P2pConfig),
Ready(P2pState),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum TransitionFrontierGenesisAction {
LedgerLoadInit,
LedgerLoadPending,
LedgerLoadSuccess {
data: GenesisConfigLoaded,
data: Box<GenesisConfigLoaded>,
},
Produce,
ProveInit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl TransitionFrontierGenesisState {
TransitionFrontierGenesisAction::LedgerLoadSuccess { data } => {
*state = Self::LedgerLoadSuccess {
time: meta.time(),
data: data.clone(),
data: *data.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really!? Clone::clone should always return an owned type, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nvm... data is &Box

};

// Dispatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ use super::{
};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[expect(
clippy::large_enum_variant,
reason = "Happy-path variant is the redux state"
)]
pub enum P2pChannelsStreamingRpcState {
Disabled,
Enabled,
Expand Down
4 changes: 2 additions & 2 deletions crates/p2p/src/p2p_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub enum P2pConnectionEvent {
pub enum P2pChannelEvent {
Opened(PeerId, ChannelId, Result<(), String>),
Sent(PeerId, ChannelId, MsgId, Result<(), String>),
Received(PeerId, Result<ChannelMsg, String>),
Received(PeerId, Result<Box<ChannelMsg>, String>),
Closed(PeerId, ChannelId),
}

Expand Down Expand Up @@ -155,7 +155,7 @@ impl fmt::Display for P2pChannelEvent {
Err(_) => return write!(f, "Err"),
Ok(msg) => {
write!(f, "{:?}, ", msg.channel_id())?;
msg
msg.as_ref()
}
};

Expand Down
2 changes: 1 addition & 1 deletion crates/p2p/src/p2p_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ pub enum P2pPeerStatus {
time: redux::Timestamp,
},

Ready(P2pPeerStatusReady),
Ready(Box<P2pPeerStatusReady>),
}

impl P2pPeerStatus {
Expand Down
4 changes: 2 additions & 2 deletions crates/p2p/src/peer/p2p_peer_reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ impl P2pPeerState {
let Some(peer) = p2p_state.peers.get_mut(&peer_id) else {
return Ok(());
};
peer.status = P2pPeerStatus::Ready(P2pPeerStatusReady::new(
peer.status = P2pPeerStatus::Ready(Box::new(P2pPeerStatusReady::new(
incoming,
meta.time(),
&p2p_state.config.enabled_channels,
));
)));

if !peer.is_libp2p {
let (dispatcher, state) = state_context.into_dispatcher_and_state();
Expand Down
Loading
Loading