Skip to content

Commit

Permalink
chore(*): apply rustfmt (#2837)
Browse files Browse the repository at this point in the history
* chore(*): apply rustfmt

* missed fmts

* undo external-crates

* style_edition = "2024"
  • Loading branch information
thibault-martinez authored Oct 1, 2024
1 parent c2d6c2b commit a403cf3
Show file tree
Hide file tree
Showing 837 changed files with 4,975 additions and 6,121 deletions.
2 changes: 1 addition & 1 deletion consensus/config/src/test_committee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::net::{TcpListener, TcpStream};

use iota_network_stack::Multiaddr;
use rand::{rngs::StdRng, SeedableRng as _};
use rand::{SeedableRng as _, rngs::StdRng};

use crate::{
Authority, AuthorityKeyPair, Committee, Epoch, NetworkKeyPair, ProtocolKeyPair, Stake,
Expand Down
2 changes: 1 addition & 1 deletion consensus/config/tests/committee_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use consensus_config::{
};
use insta::assert_yaml_snapshot;
use iota_network_stack::Multiaddr;
use rand::{rngs::StdRng, SeedableRng as _};
use rand::{SeedableRng as _, rngs::StdRng};

// Committee is not sent over network or stored on disk itself, but some of its
// fields are. So this test can still be useful to detect accidental format
Expand Down
12 changes: 6 additions & 6 deletions consensus/core/src/authority_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use prometheus::Registry;
use tracing::{info, warn};

use crate::{
CommitConsumer,
authority_service::AuthorityService,
block_manager::BlockManager,
block_verifier::SignedBlockVerifier,
Expand All @@ -26,14 +27,13 @@ use crate::{
leader_timeout::{LeaderTimeoutTask, LeaderTimeoutTaskHandle},
metrics::initialise_metrics,
network::{
anemo_network::AnemoManager, tonic_network::TonicManager, NetworkClient as _,
NetworkManager,
NetworkClient as _, NetworkManager, anemo_network::AnemoManager,
tonic_network::TonicManager,
},
storage::rocksdb_store::RocksDBStore,
subscriber::Subscriber,
synchronizer::{Synchronizer, SynchronizerHandle},
transaction::{TransactionClient, TransactionConsumer, TransactionVerifier},
CommitConsumer,
};

/// ConsensusAuthority is used by Iota to manage the lifetime of AuthorityNode.
Expand Down Expand Up @@ -396,8 +396,8 @@ mod tests {
time::Duration,
};

use consensus_config::{local_committee_and_keys, Parameters};
use iota_metrics::monitored_mpsc::{unbounded_channel, UnboundedReceiver};
use consensus_config::{Parameters, local_committee_and_keys};
use iota_metrics::monitored_mpsc::{UnboundedReceiver, unbounded_channel};
use iota_protocol_config::ProtocolConfig;
use prometheus::Registry;
use rstest::rstest;
Expand All @@ -407,9 +407,9 @@ mod tests {

use super::*;
use crate::{
CommittedSubDag,
block::{BlockAPI as _, GENESIS_ROUND},
transaction::NoopTransactionVerifier,
CommittedSubDag,
};

#[rstest]
Expand Down
8 changes: 4 additions & 4 deletions consensus/core/src/authority_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ use std::{pin::Pin, sync::Arc, time::Duration};
use async_trait::async_trait;
use bytes::Bytes;
use consensus_config::AuthorityIndex;
use futures::{ready, stream, task, Stream, StreamExt};
use futures::{Stream, StreamExt, ready, stream, task};
use iota_macros::fail_point_async;
use parking_lot::RwLock;
use tokio::{sync::broadcast, time::sleep};
use tokio_util::sync::ReusableBoxFuture;
use tracing::{debug, info, trace, warn};

use crate::{
block::{BlockAPI as _, BlockRef, SignedBlock, VerifiedBlock, GENESIS_ROUND},
CommitIndex, Round,
block::{BlockAPI as _, BlockRef, GENESIS_ROUND, SignedBlock, VerifiedBlock},
block_verifier::BlockVerifier,
commit::{CommitAPI as _, CommitRange, TrustedCommit},
commit_vote_monitor::CommitVoteMonitor,
Expand All @@ -27,7 +28,6 @@ use crate::{
stake_aggregator::{QuorumThreshold, StakeAggregator},
storage::Store,
synchronizer::SynchronizerHandle,
CommitIndex, Round,
};

pub(crate) const COMMIT_LAG_MULTIPLIER: u32 = 5;
Expand Down Expand Up @@ -578,6 +578,7 @@ mod tests {
use tokio::{sync::broadcast, time::sleep};

use crate::{
Round,
authority_service::AuthorityService,
block::{BlockAPI, BlockRef, SignedBlock, TestBlock, VerifiedBlock},
commit::CommitRange,
Expand All @@ -590,7 +591,6 @@ mod tests {
storage::mem_store::MemStore,
synchronizer::Synchronizer,
test_dag_builder::DagBuilder,
Round,
};

struct FakeCoreThreadDispatcher {
Expand Down
2 changes: 1 addition & 1 deletion consensus/core/src/base_committer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use parking_lot::RwLock;

use crate::{
block::{BlockAPI, BlockRef, Round, Slot, VerifiedBlock},
commit::{LeaderStatus, WaveNumber, DEFAULT_WAVE_LENGTH, MINIMUM_WAVE_LENGTH},
commit::{DEFAULT_WAVE_LENGTH, LeaderStatus, MINIMUM_WAVE_LENGTH, WaveNumber},
context::Context,
dag_state::DagState,
leader_schedule::LeaderSchedule,
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::{

use bytes::Bytes;
use consensus_config::{
AuthorityIndex, DefaultHashFunction, Epoch, ProtocolKeyPair, ProtocolKeySignature,
ProtocolPublicKey, DIGEST_LENGTH,
AuthorityIndex, DIGEST_LENGTH, DefaultHashFunction, Epoch, ProtocolKeyPair,
ProtocolKeySignature, ProtocolPublicKey,
};
use enum_dispatch::enum_dispatch;
use fastcrypto::hash::{Digest, HashFunction};
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/block_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use parking_lot::RwLock;
use tracing::{debug, trace, warn};

use crate::{
Round,
block::{BlockAPI, BlockRef, VerifiedBlock},
block_verifier::BlockVerifier,
context::Context,
dag_state::DagState,
Round,
};

struct SuspendedBlock {
Expand Down Expand Up @@ -428,7 +428,7 @@ mod tests {

use consensus_config::AuthorityIndex;
use parking_lot::RwLock;
use rand::{prelude::StdRng, seq::SliceRandom, SeedableRng};
use rand::{SeedableRng, prelude::StdRng, seq::SliceRandom};

use crate::{
block::{BlockAPI, BlockRef, SignedBlock, VerifiedBlock},
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/block_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use std::{collections::BTreeSet, sync::Arc};

use crate::{
block::{
genesis_blocks, BlockAPI, BlockRef, BlockTimestampMs, SignedBlock, VerifiedBlock,
GENESIS_ROUND,
BlockAPI, BlockRef, BlockTimestampMs, GENESIS_ROUND, SignedBlock, VerifiedBlock,
genesis_blocks,
},
context::Context,
error::{ConsensusError, ConsensusResult},
Expand Down
6 changes: 3 additions & 3 deletions consensus/core/src/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use std::{
};

use consensus_config::AuthorityIndex;
use futures::{stream::FuturesUnordered, StreamExt as _};
use futures::{StreamExt as _, stream::FuturesUnordered};
use tokio::{
sync::broadcast,
task::JoinSet,
time::{error::Elapsed, sleep_until, timeout, Instant},
time::{Instant, error::Elapsed, sleep_until, timeout},
};
use tracing::{trace, warn};

Expand Down Expand Up @@ -201,11 +201,11 @@ mod test {

use super::*;
use crate::{
Round,
block::{BlockRef, TestBlock},
commit::CommitRange,
core::CoreSignals,
network::BlockStream,
Round,
};

struct FakeNetworkClient {
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
};

use bytes::Bytes;
use consensus_config::{AuthorityIndex, DefaultHashFunction, DIGEST_LENGTH};
use consensus_config::{AuthorityIndex, DIGEST_LENGTH, DefaultHashFunction};
use enum_dispatch::enum_dispatch;
use fastcrypto::hash::{Digest, HashFunction as _};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -602,7 +602,7 @@ mod tests {
use crate::{
block::TestBlock,
context::Context,
storage::{mem_store::MemStore, WriteBatch},
storage::{WriteBatch, mem_store::MemStore},
};

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion consensus/core/src/commit_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

use std::sync::{atomic::AtomicU32, Arc};
use std::sync::{Arc, atomic::AtomicU32};

use iota_metrics::monitored_mpsc::UnboundedSender;

Expand Down
6 changes: 3 additions & 3 deletions consensus/core/src/commit_observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use tokio::time::Instant;
use tracing::{debug, info};

use crate::{
CommitConsumer, CommittedSubDag,
block::{BlockAPI, VerifiedBlock},
commit::{load_committed_subdag_from_store, CommitAPI, CommitIndex},
commit::{CommitAPI, CommitIndex, load_committed_subdag_from_store},
context::Context,
dag_state::DagState,
error::{ConsensusError, ConsensusResult},
leader_schedule::LeaderSchedule,
linearizer::Linearizer,
storage::Store,
CommitConsumer, CommittedSubDag,
};

/// Role of CommitObserver
Expand Down Expand Up @@ -218,7 +218,7 @@ impl CommitObserver {

#[cfg(test)]
mod tests {
use iota_metrics::monitored_mpsc::{unbounded_channel, UnboundedReceiver};
use iota_metrics::monitored_mpsc::{UnboundedReceiver, unbounded_channel};
use parking_lot::RwLock;

use super::*;
Expand Down
8 changes: 4 additions & 4 deletions consensus/core/src/commit_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ use std::{

use bytes::Bytes;
use consensus_config::AuthorityIndex;
use futures::{stream::FuturesOrdered, StreamExt as _};
use futures::{StreamExt as _, stream::FuturesOrdered};
use iota_metrics::spawn_logged_monitored_task;
use itertools::Itertools as _;
use parking_lot::{Mutex, RwLock};
use rand::prelude::SliceRandom as _;
use tokio::{
sync::oneshot,
task::{JoinHandle, JoinSet},
time::{sleep, Instant, MissedTickBehavior},
time::{Instant, MissedTickBehavior, sleep},
};
use tracing::{debug, info, warn};

use crate::{
CommitConsumerMonitor, CommitIndex,
block::{BlockAPI, BlockRef, SignedBlock, VerifiedBlock},
block_verifier::BlockVerifier,
commit::{Commit, CommitAPI as _, CommitDigest, CommitRange, CommitRef, TrustedCommit},
Expand All @@ -60,7 +61,6 @@ use crate::{
error::{ConsensusError, ConsensusResult},
network::NetworkClient,
stake_aggregator::{QuorumThreshold, StakeAggregator},
CommitConsumerMonitor, CommitIndex,
};

// Handle to stop the CommitSyncer loop.
Expand Down Expand Up @@ -764,6 +764,7 @@ mod tests {
use parking_lot::RwLock;

use crate::{
CommitConsumerMonitor, CommitDigest, CommitRef, Round,
block::{BlockRef, TestBlock, VerifiedBlock},
block_verifier::NoopBlockVerifier,
commit::CommitRange,
Expand All @@ -775,7 +776,6 @@ mod tests {
error::ConsensusResult,
network::{BlockStream, NetworkClient},
storage::mem_store::MemStore,
CommitConsumerMonitor, CommitDigest, CommitRef, Round,
};

#[derive(Default)]
Expand Down
2 changes: 1 addition & 1 deletion consensus/core/src/commit_vote_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use std::sync::Arc;
use parking_lot::Mutex;

use crate::{
CommitIndex,
block::{BlockAPI as _, VerifiedBlock},
commit::GENESIS_COMMIT_INDEX,
context::Context,
CommitIndex,
};

/// Monitors the progress of consensus commits across the network.
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/core_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{collections::BTreeSet, fmt::Debug, sync::Arc};

use async_trait::async_trait;
use iota_metrics::{
monitored_mpsc::{channel, Receiver, Sender, WeakSender},
monitored_mpsc::{Receiver, Sender, WeakSender, channel},
monitored_scope, spawn_logged_monitored_task,
};
use parking_lot::Mutex;
Expand Down Expand Up @@ -307,6 +307,7 @@ mod test {

use super::*;
use crate::{
CommitConsumer,
block_manager::BlockManager,
block_verifier::NoopBlockVerifier,
commit_observer::CommitObserver,
Expand All @@ -316,7 +317,6 @@ mod test {
leader_schedule::LeaderSchedule,
storage::mem_store::MemStore,
transaction::{TransactionClient, TransactionConsumer},
CommitConsumer,
};

#[tokio::test]
Expand Down
13 changes: 7 additions & 6 deletions consensus/core/src/dag_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use tracing::{debug, error};

use crate::{
block::{
genesis_blocks, BlockAPI, BlockDigest, BlockRef, BlockTimestampMs, Round, Slot,
VerifiedBlock, GENESIS_ROUND,
BlockAPI, BlockDigest, BlockRef, BlockTimestampMs, GENESIS_ROUND, Round, Slot,
VerifiedBlock, genesis_blocks,
},
commit::{
load_committed_subdag_from_store, CommitAPI as _, CommitDigest, CommitIndex, CommitInfo,
CommitRef, CommitVote, CommittedSubDag, TrustedCommit, GENESIS_COMMIT_INDEX,
CommitAPI as _, CommitDigest, CommitIndex, CommitInfo, CommitRef, CommitVote,
CommittedSubDag, GENESIS_COMMIT_INDEX, TrustedCommit, load_committed_subdag_from_store,
},
context::Context,
leader_scoring::ReputationScores,
Expand Down Expand Up @@ -897,7 +897,7 @@ mod test {
use super::*;
use crate::{
block::{BlockDigest, BlockRef, BlockTimestampMs, TestBlock, VerifiedBlock},
storage::{mem_store::MemStore, WriteBatch},
storage::{WriteBatch, mem_store::MemStore},
test_dag_builder::DagBuilder,
};

Expand Down Expand Up @@ -1160,7 +1160,8 @@ mod test {
round_11[2].reference(),
round_11[5].reference(),
];
expected_refs.sort(); // we need to sort as blocks with same author and round of round 11 (position 1 & 2) might not be in right lexicographical order.
expected_refs.sort(); // we need to sort as blocks with same author and round of round 11 (position 1
// & 2) might not be in right lexicographical order.
assert_eq!(
ancestors_refs, expected_refs,
"Expected round 11 ancestors: {:?}. Got: {:?}",
Expand Down
6 changes: 3 additions & 3 deletions consensus/core/src/leader_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ use std::{

use consensus_config::{AuthorityIndex, Stake};
use parking_lot::RwLock;
use rand::{prelude::SliceRandom, rngs::StdRng, SeedableRng};
use rand::{SeedableRng, prelude::SliceRandom, rngs::StdRng};

use crate::{
CommitIndex, Round,
commit::CommitRange,
context::Context,
dag_state::DagState,
Expand All @@ -21,7 +22,6 @@ use crate::{
CertificateScoringStrategy, CertifiedVoteScoringStrategyV1, CertifiedVoteScoringStrategyV2,
ScoringStrategy, VoteScoringStrategy,
},
CommitIndex, Round,
};

/// The `LeaderSchedule` is responsible for producing the leader schedule across
Expand Down Expand Up @@ -481,7 +481,7 @@ mod tests {
use crate::{
block::{BlockAPI as _, BlockDigest, BlockRef, BlockTimestampMs, TestBlock, VerifiedBlock},
commit::{CommitDigest, CommitInfo, CommitRef, CommittedSubDag, TrustedCommit},
storage::{mem_store::MemStore, Store, WriteBatch},
storage::{Store, WriteBatch, mem_store::MemStore},
test_dag_builder::DagBuilder,
};

Expand Down
Loading

0 comments on commit a403cf3

Please sign in to comment.