Skip to content

Commit 1709ae5

Browse files
committed
fix: updated cargo fmt
1 parent 1496e18 commit 1709ae5

45 files changed

Lines changed: 327 additions & 321 deletions

File tree

Some content is hidden

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

core/application/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::Path;
22
use std::time::SystemTime;
33

4-
use anyhow::{Context, Result, anyhow};
4+
use anyhow::{anyhow, Context, Result};
55
use atomo::{AtomoBuilder, DefaultSerdeBackend};
66
use atomo_rocks::{Cache as RocksCache, Env as RocksEnv, Options};
77
use lightning_interfaces::types::Genesis;

core/application/src/state/context.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use std::hash::Hash;
44

55
use atomo::{KeyIterator, SerdeBackend, StorageBackend, TableRef as AtomoTableRef, TableSelector};
66
use fxhash::FxHashMap;
7-
use serde::Serialize;
87
use serde::de::DeserializeOwned;
8+
use serde::Serialize;
99

1010
pub trait Backend {
1111
type Ref<K: Eq + Hash + Send + Serialize + DeserializeOwned
@@ -59,11 +59,11 @@ pub struct AtomoTable<
5959
>(RefCell<AtomoTableRef<'selector, K, V, B, S>>);
6060

6161
impl<
62-
K: Hash + Eq + Serialize + DeserializeOwned + Any,
63-
V: Serialize + DeserializeOwned + Any + Clone,
64-
B: StorageBackend,
65-
S: SerdeBackend,
66-
> TableRef<K, V> for AtomoTable<'_, K, V, B, S>
62+
K: Hash + Eq + Serialize + DeserializeOwned + Any,
63+
V: Serialize + DeserializeOwned + Any + Clone,
64+
B: StorageBackend,
65+
S: SerdeBackend,
66+
> TableRef<K, V> for AtomoTable<'_, K, V, B, S>
6767
{
6868
fn set(&self, key: K, value: V) {
6969
self.0.borrow_mut().insert(key, value);

core/application/src/state/executor.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ops::DerefMut;
55
use std::time::Duration;
66

77
use ethers::abi::AbiDecode;
8-
use ethers::types::{H160, Transaction as EthersTransaction};
8+
use ethers::types::{Transaction as EthersTransaction, H160};
99
use fleek_crypto::{
1010
ClientPublicKey,
1111
ConsensusPublicKey,
@@ -15,7 +15,6 @@ use fleek_crypto::{
1515
};
1616
use hp_fixed::unsigned::HpUfixed;
1717
use lazy_static::lazy_static;
18-
use lightning_interfaces::ToDigest;
1918
use lightning_interfaces::types::{
2019
AccountInfo,
2120
Blake3Hash,
@@ -28,9 +27,6 @@ use lightning_interfaces::types::{
2827
Epoch,
2928
ExecutionData,
3029
ExecutionError,
31-
MAX_MEASUREMENTS_PER_TX,
32-
MAX_MEASUREMENTS_SUBMIT,
33-
MAX_UPDATES_CONTENT_REGISTRY,
3430
Metadata,
3531
MintInfo,
3632
NodeIndex,
@@ -59,7 +55,11 @@ use lightning_interfaces::types::{
5955
UpdateRequest,
6056
Value,
6157
WithdrawInfo,
58+
MAX_MEASUREMENTS_PER_TX,
59+
MAX_MEASUREMENTS_SUBMIT,
60+
MAX_UPDATES_CONTENT_REGISTRY,
6261
};
62+
use lightning_interfaces::ToDigest;
6363
use lightning_utils::eth::fleek_contract::FleekContractCalls;
6464
use lightning_utils::eth::{
6565
ApproveClientKeyCall,
@@ -522,12 +522,15 @@ impl<B: Backend> StateExecutor<B> {
522522
return TransactionResponse::Revert(ExecutionError::InsufficientBalance);
523523
}
524524
account.flk_balance -= amount.clone();
525-
self.withdraws.set(withdraw_id, WithdrawInfo {
526-
epoch: 0,
527-
token: Tokens::FLK,
528-
receiver,
529-
amount,
530-
});
525+
self.withdraws.set(
526+
withdraw_id,
527+
WithdrawInfo {
528+
epoch: 0,
529+
token: Tokens::FLK,
530+
receiver,
531+
amount,
532+
},
533+
);
531534
self.metadata
532535
.set(Metadata::WithdrawId, Value::WithdrawId(withdraw_id + 1));
533536
},
@@ -538,12 +541,15 @@ impl<B: Backend> StateExecutor<B> {
538541
return TransactionResponse::Revert(ExecutionError::InsufficientBalance);
539542
}
540543
account.stables_balance -= amount.clone();
541-
self.withdraws.set(withdraw_id, WithdrawInfo {
542-
epoch: 0,
543-
token: Tokens::USDC,
544-
receiver,
545-
amount: amount.convert_precision::<18>(),
546-
});
544+
self.withdraws.set(
545+
withdraw_id,
546+
WithdrawInfo {
547+
epoch: 0,
548+
token: Tokens::USDC,
549+
receiver,
550+
amount: amount.convert_precision::<18>(),
551+
},
552+
);
547553
self.metadata
548554
.set(Metadata::WithdrawId, Value::WithdrawId(withdraw_id + 1));
549555
},

core/application/src/tests/committee_beacon.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,9 +1991,9 @@ async fn test_committee_beacon_node_can_reveal_after_committing_and_becoming_ina
19911991

19921992
// Execute opt-out transaction from 1 of the nodes.
19931993
let resp = network
1994-
.execute(vec![
1995-
network.node(0).build_transaction(UpdateMethod::OptOut {}),
1996-
])
1994+
.execute(vec![network
1995+
.node(0)
1996+
.build_transaction(UpdateMethod::OptOut {})])
19971997
.await
19981998
.unwrap();
19991999
assert_eq!(resp.block_number, 3);
@@ -2475,9 +2475,9 @@ async fn test_committee_beacon_non_committee_node_participation() {
24752475
// Note that we remove the non-participating committee node, otherwise the reveal transaction
24762476
// from the removed node would be rejected.
24772477
let resp = network
2478-
.execute(vec![
2479-
network.node(3).build_transaction(UpdateMethod::OptOut {}),
2480-
])
2478+
.execute(vec![network
2479+
.node(3)
2480+
.build_transaction(UpdateMethod::OptOut {})])
24812481
.await
24822482
.unwrap();
24832483
assert_eq!(resp.block_number, 5);

core/application/src/tests/epoch_change.rs

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,11 @@ async fn test_epoch_change_with_all_committee_nodes() {
148148

149149
// Check that the ready-to-change set for the next epoch is empty.
150150
for node in network.nodes() {
151-
assert!(
152-
node.app_query()
153-
.get_committee_info(&(epoch + 1), |c| c.ready_to_change)
154-
.unwrap_or_default()
155-
.is_empty()
156-
);
151+
assert!(node
152+
.app_query()
153+
.get_committee_info(&(epoch + 1), |c| c.ready_to_change)
154+
.unwrap_or_default()
155+
.is_empty());
157156
}
158157

159158
// Shutdown the network.
@@ -318,12 +317,11 @@ async fn test_epoch_change_with_some_non_committee_nodes() {
318317

319318
// Check that the ready-to-change set for the next epoch is empty.
320319
for node in network.nodes() {
321-
assert!(
322-
node.app_query()
323-
.get_committee_info(&(epoch + 1), |c| c.ready_to_change)
324-
.unwrap_or_default()
325-
.is_empty()
326-
);
320+
assert!(node
321+
.app_query()
322+
.get_committee_info(&(epoch + 1), |c| c.ready_to_change)
323+
.unwrap_or_default()
324+
.is_empty());
327325
}
328326

329327
// Shutdown the network.
@@ -353,23 +351,19 @@ async fn test_change_epoch_with_only_locked_stake() {
353351

354352
// Execute epoch change transaction from the node with only locked stake.
355353
let resp = network
356-
.execute(vec![
357-
network
358-
.node(0)
359-
.build_transaction(UpdateMethod::ChangeEpoch { epoch }),
360-
])
354+
.execute(vec![network
355+
.node(0)
356+
.build_transaction(UpdateMethod::ChangeEpoch { epoch })])
361357
.await
362358
.unwrap();
363359
assert_eq!(resp.block_number, 1);
364360
assert!(!resp.change_epoch);
365361

366362
// Execute epoch change transaction from the node with unlocked stake.
367363
let resp = network
368-
.execute(vec![
369-
network
370-
.node(1)
371-
.build_transaction(UpdateMethod::ChangeEpoch { epoch }),
372-
])
364+
.execute(vec![network
365+
.node(1)
366+
.build_transaction(UpdateMethod::ChangeEpoch { epoch })])
373367
.await
374368
.unwrap();
375369
assert_eq!(resp.block_number, 2);
@@ -395,20 +389,18 @@ async fn test_change_epoch_reverts_if_node_opted_out() {
395389

396390
// Execute opt-out transaction from the first node.
397391
let resp = network
398-
.execute(vec![
399-
network.node(0).build_transaction(UpdateMethod::OptOut {}),
400-
])
392+
.execute(vec![network
393+
.node(0)
394+
.build_transaction(UpdateMethod::OptOut {})])
401395
.await
402396
.unwrap();
403397
assert_eq!(resp.block_number, 1);
404398

405399
// Execute epoch change transaction from the node and check that it reverts.
406400
let resp = network
407-
.maybe_execute(vec![
408-
network
409-
.node(0)
410-
.build_transaction(UpdateMethod::ChangeEpoch { epoch }),
411-
])
401+
.maybe_execute(vec![network
402+
.node(0)
403+
.build_transaction(UpdateMethod::ChangeEpoch { epoch })])
412404
.await
413405
.unwrap();
414406
assert_eq!(resp.block_number, 2);

core/application/src/tests/participation.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,16 @@ async fn test_uptime_participation() {
6464
)
6565
.await
6666
.unwrap();
67-
assert!(
68-
!node
69-
.app_query()
70-
.get_content_registry(&peer1.index())
71-
.unwrap_or_default()
72-
.is_empty()
73-
);
74-
assert!(
75-
!node
76-
.app_query()
77-
.get_content_registry(&peer2.index())
78-
.unwrap_or_default()
79-
.is_empty()
80-
);
67+
assert!(!node
68+
.app_query()
69+
.get_content_registry(&peer1.index())
70+
.unwrap_or_default()
71+
.is_empty());
72+
assert!(!node
73+
.app_query()
74+
.get_content_registry(&peer2.index())
75+
.unwrap_or_default()
76+
.is_empty());
8177

8278
// Submit reputation measurements from node 0, for peer 1 and 2.
8379
let measurements: BTreeMap<u32, lightning_interfaces::types::ReputationMeasurements> =

core/application/src/tests/reputation.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,14 @@ async fn test_rep_scores() {
152152
network.change_epoch_and_wait_for_complete().await.unwrap();
153153

154154
// Check the reputation scores.
155-
assert!(
156-
node.app_query()
157-
.get_reputation_score(&peer1.index())
158-
.is_some()
159-
);
160-
assert!(
161-
node.app_query()
162-
.get_reputation_score(&peer2.index())
163-
.is_some()
164-
);
155+
assert!(node
156+
.app_query()
157+
.get_reputation_score(&peer1.index())
158+
.is_some());
159+
assert!(node
160+
.app_query()
161+
.get_reputation_score(&peer2.index())
162+
.is_some());
165163

166164
// Shutdown the network.
167165
network.shutdown().await;

core/application/src/tests/staking.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ async fn test_stake() {
7474
.unwrap();
7575
assert_eq!(node_registry_changes.len(), 1);
7676
assert_eq!(node_registry_changes.get(&0).unwrap().len(), committee_size);
77-
assert!(
78-
node_registry_changes
79-
.get(&0)
80-
.unwrap()
81-
.iter()
82-
.all(|(_, change)| { matches!(change, NodeRegistryChange::New) })
83-
);
77+
assert!(node_registry_changes
78+
.get(&0)
79+
.unwrap()
80+
.iter()
81+
.all(|(_, change)| { matches!(change, NodeRegistryChange::New) }));
8482

8583
let owner_secret_key = AccountOwnerSecretKey::generate();
8684
let peer_pub_key = NodeSecretKey::generate().to_pk();

core/blockstore-server/src/blockstore_server.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ use std::borrow::Cow;
55
use std::collections::{HashMap, VecDeque};
66
use std::mem;
77
use std::net::SocketAddr;
8-
use std::sync::Arc;
98
use std::sync::atomic::{AtomicUsize, Ordering};
9+
use std::sync::Arc;
1010
use std::time::{Duration, Instant};
1111

1212
use affair::{Socket, Task};
13-
use anyhow::{Result, anyhow};
13+
use anyhow::{anyhow, Result};
1414
use b3fs::entry::{BorrowedEntry, InlineVec, OwnedEntry, OwnedLink};
1515
use bytes::{Buf, BufMut, Bytes, BytesMut};
1616
use lightning_interfaces::prelude::*;
@@ -30,7 +30,7 @@ use lightning_interfaces::{
3030
};
3131
use lightning_metrics::increment_counter;
3232
use serde::{Deserialize, Serialize};
33-
use tokio::sync::{RwLock, broadcast, mpsc};
33+
use tokio::sync::{broadcast, mpsc, RwLock};
3434
use tokio::task::JoinSet;
3535
use tokio::time::timeout;
3636
use tokio_stream::StreamExt;

0 commit comments

Comments
 (0)