Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdean-digicatapult committed Oct 3, 2023
1 parent 687633a commit 9583113
Show file tree
Hide file tree
Showing 31 changed files with 596 additions and 641 deletions.
22 changes: 11 additions & 11 deletions node/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{sync::Arc, time::Duration};
///
/// Note: Should only be used for benchmarking.
pub struct RemarkBuilder {
client: Arc<FullClient>
client: Arc<FullClient>,
}

impl RemarkBuilder {
Expand All @@ -40,7 +40,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
self.client.as_ref(),
acc,
SystemCall::remark { remark: vec![] }.into(),
nonce
nonce,
)
.into();

Expand All @@ -54,7 +54,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
pub struct TransferKeepAliveBuilder {
client: Arc<FullClient>,
dest: AccountId,
value: Balance
value: Balance,
}

impl TransferKeepAliveBuilder {
Expand All @@ -80,10 +80,10 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
acc,
BalancesCall::transfer_keep_alive {
dest: self.dest.clone().into(),
value: self.value.into()
value: self.value.into(),
}
.into(),
nonce
nonce,
)
.into();

Expand All @@ -98,7 +98,7 @@ pub fn create_benchmark_extrinsic(
client: &FullClient,
sender: sp_core::sr25519::Pair,
call: runtime::RuntimeCall,
nonce: u32
nonce: u32,
) -> runtime::UncheckedExtrinsic {
let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed");
let best_hash = client.chain_info().best_hash;
Expand All @@ -115,11 +115,11 @@ pub fn create_benchmark_extrinsic(
frame_system::CheckGenesis::<runtime::Runtime>::new(),
frame_system::CheckEra::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
period,
best_block.saturated_into()
best_block.saturated_into(),
)),
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
frame_system::CheckWeight::<runtime::Runtime>::new(),
pallet_transaction_payment_free::ChargeTransactionPayment::<runtime::Runtime>::from(0)
pallet_transaction_payment_free::ChargeTransactionPayment::<runtime::Runtime>::from(0),
);

let raw_payload = runtime::SignedPayload::from_raw(
Expand All @@ -133,16 +133,16 @@ pub fn create_benchmark_extrinsic(
best_hash,
(),
(),
()
)
(),
),
);
let signature = raw_payload.using_encoded(|e| sender.sign(e));

runtime::UncheckedExtrinsic::new_signed(
call.clone(),
sp_runtime::AccountId32::from(sender.public()).into(),
runtime::Signature::Sr25519(signature.clone()),
extra.clone()
extra.clone(),
)
}

Expand Down
56 changes: 28 additions & 28 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use dscp_node_runtime::{
types::{BooleanExpressionSymbol, Restriction},
AccountId, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig, MembershipConfig, NodeAuthorizationConfig,
ProcessValidationConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY
ProcessValidationConfig, Signature, SudoConfig, SystemConfig, WASM_BINARY,
};
use sc_service::ChainType;
use sp_consensus_babe::AuthorityId as BabeId;
Expand All @@ -10,7 +10,7 @@ use sp_core::OpaquePeerId; // A struct wraps Vec<u8>, represents as our `PeerId`
use sp_core::{sr25519, Pair, Public};
use sp_runtime::{
bounded_vec,
traits::{IdentifyAccount, Verify}
traits::{IdentifyAccount, Verify},
};
const DEFAULT_PROTOCOL_ID: &str = "dscp";

Expand All @@ -32,7 +32,7 @@ type AccountPublic = <Signature as Verify>::Signer;
/// Generate an account ID from seed.
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
Expand Down Expand Up @@ -75,12 +75,12 @@ pub fn development_config() -> Result<ChainSpec, String> {
OpaquePeerId(
bs58::decode("12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp")
.into_vec()
.unwrap()
.unwrap(),
),
get_account_id_from_seed::<sr25519::Public>("Alice")
)]
get_account_id_from_seed::<sr25519::Public>("Alice"),
)],
},
true
true,
)
},
// Bootnodes
Expand All @@ -94,7 +94,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
// Properties
None,
// Extensions
None
None,
))
}

Expand Down Expand Up @@ -143,40 +143,40 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
OpaquePeerId(
bs58::decode("12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp")
.into_vec()
.unwrap()
.unwrap(),
),
get_account_id_from_seed::<sr25519::Public>("Alice")
get_account_id_from_seed::<sr25519::Public>("Alice"),
),
(
// 0000000000000000000000000000000000000000000000000000000000000002
OpaquePeerId(
bs58::decode("12D3KooWHdiAxVd8uMQR1hGWXccidmfCwLqcMpGwR6QcTP6QRMuD")
.into_vec()
.unwrap()
.unwrap(),
),
get_account_id_from_seed::<sr25519::Public>("Bob")
get_account_id_from_seed::<sr25519::Public>("Bob"),
),
(
// 0000000000000000000000000000000000000000000000000000000000000003
OpaquePeerId(
bs58::decode("12D3KooWSCufgHzV4fCwRijfH2k3abrpAJxTKxEvN1FDuRXA2U9x")
.into_vec()
.unwrap()
.unwrap(),
),
get_account_id_from_seed::<sr25519::Public>("Charlie")
get_account_id_from_seed::<sr25519::Public>("Charlie"),
),
(
// 0000000000000000000000000000000000000000000000000000000000000004
OpaquePeerId(
bs58::decode("12D3KooWSsChzF81YDUKpe9Uk5AHV5oqAaXAcWNSPYgoLauUk4st")
.into_vec()
.unwrap()
.unwrap(),
),
get_account_id_from_seed::<sr25519::Public>("Eve")
get_account_id_from_seed::<sr25519::Public>("Eve"),
),
]
],
},
true
true,
)
},
// Bootnodes
Expand All @@ -190,7 +190,7 @@ pub fn local_testnet_config() -> Result<ChainSpec, String> {
// Properties
None,
// Extensions
None
None,
))
}

Expand All @@ -202,27 +202,27 @@ fn testnet_genesis(
endowed_accounts: Vec<AccountId>,
technical_committee_accounts: Vec<AccountId>,
node_authorization_config: NodeAuthorizationConfig,
_enable_println: bool
_enable_println: bool,
) -> GenesisConfig {
GenesisConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec()
code: wasm_binary.to_vec(),
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect()
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
},
babe: BabeConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone(), 1)).collect(),
epoch_config: Some(dscp_node_runtime::BABE_GENESIS_EPOCH_CONFIG)
epoch_config: Some(dscp_node_runtime::BABE_GENESIS_EPOCH_CONFIG),
},
grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect()
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
},
sudo: SudoConfig {
// Assign network admin rights.
key: Some(root_key)
key: Some(root_key),
},
node_authorization: node_authorization_config,
membership: MembershipConfig {
Expand All @@ -233,8 +233,8 @@ fn testnet_genesis(
process_validation: ProcessValidationConfig {
processes: vec![(
"default".as_bytes().to_vec().try_into().unwrap(),
bounded_vec![BooleanExpressionSymbol::Restriction(Restriction::None)]
)]
}
bounded_vec![BooleanExpressionSymbol::Restriction(Restriction::None)],
)],
},
}
}
12 changes: 6 additions & 6 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct BabeDeps {
/// A handle to the BABE worker for issuing requests.
pub babe_worker_handle: BabeWorkerHandle<Block>,
/// The keystore that manages the keys of the node.
pub keystore: KeystorePtr
pub keystore: KeystorePtr,
}

/// Full client dependencies.
Expand All @@ -32,12 +32,12 @@ pub struct FullDeps<C, P, SC> {
/// Whether to deny unsafe calls
pub deny_unsafe: DenyUnsafe,
/// BABE specific dependencies.
pub babe: BabeDeps
pub babe: BabeDeps,
}

/// Instantiate all full RPC extensions.
pub fn create_full<C, P, SC>(
deps: FullDeps<C, P, SC>
deps: FullDeps<C, P, SC>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
where
C: ProvideRuntimeApi<Block>,
Expand All @@ -48,7 +48,7 @@ where
C::Api: BabeApi<Block>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
SC: SelectChain<Block> + 'static
SC: SelectChain<Block> + 'static,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
Expand All @@ -60,12 +60,12 @@ where
pool,
select_chain,
deny_unsafe,
babe
babe,
} = deps;

let BabeDeps {
keystore,
babe_worker_handle
babe_worker_handle,
} = babe;

module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
Expand Down
Loading

0 comments on commit 9583113

Please sign in to comment.