From 8e3f494714c1c03dd33a02f953a657e624fc05bf Mon Sep 17 00:00:00 2001 From: 0xrust Date: Mon, 11 Jul 2022 17:39:32 +0300 Subject: [PATCH] fixed warnings, typos, ordering --- Cargo.lock | 8 +- integration-tests/src/mock.rs | 44 +-- integration-tests/src/vesting.rs | 2 +- node/Cargo.toml | 4 +- node/src/chain_spec/frost.rs | 2 +- node/src/service/arctic.rs | 286 +----------------- node/src/service/frost.rs | 2 +- pallets/airdrop/Cargo.toml | 2 +- pallets/airdrop/src/benchmarking.rs | 14 +- pallets/airdrop/src/exchange_accounts.rs | 19 +- pallets/airdrop/src/lib.rs | 49 +-- pallets/airdrop/src/tests/mock.rs | 20 +- pallets/airdrop/src/tests/mod.rs | 6 +- pallets/airdrop/src/tests/user_claim.rs | 2 +- .../airdrop/src/tests/utility_functions.rs | 57 ++-- pallets/airdrop/src/types.rs | 14 +- pallets/airdrop/src/utils.rs | 16 +- pallets/airdrop/src/vested_transfer.rs | 26 +- pallets/airdrop/src/weights.rs | 26 +- runtime/arctic/Cargo.toml | 2 +- runtime/arctic/src/impls.rs | 6 +- runtime/arctic/src/lib.rs | 212 ++++++------- runtime/frost/Cargo.toml | 2 +- runtime/frost/src/impls.rs | 6 +- runtime/frost/src/lib.rs | 221 +++++++------- 25 files changed, 383 insertions(+), 665 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 128ab3d1..a0b8c5b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "arctic-runtime" -version = "0.4.42" +version = "0.4.43" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -3078,7 +3078,7 @@ dependencies = [ [[package]] name = "frost-runtime" -version = "0.4.42" +version = "0.4.43" dependencies = [ "fp-rpc", "fp-self-contained", @@ -3658,7 +3658,7 @@ dependencies = [ [[package]] name = "ice-node" -version = "0.4.44" +version = "0.4.45" dependencies = [ "arctic-runtime", "async-trait", @@ -5677,7 +5677,7 @@ dependencies = [ [[package]] name = "pallet-airdrop" -version = "0.4.3" +version = "0.4.4" dependencies = [ "fp-evm", "frame-benchmarking", diff --git a/integration-tests/src/mock.rs b/integration-tests/src/mock.rs index 10f05d2f..32c444c8 100644 --- a/integration-tests/src/mock.rs +++ b/integration-tests/src/mock.rs @@ -35,42 +35,42 @@ parameter_types! { } impl frame_system::Config for Test { - type AccountData = pallet_balances::AccountData; - type AccountId = u64; type BaseCallFilter = frame_support::traits::Everything; - type BlockHashCount = ConstU64<250>; - type BlockLength = (); - type BlockNumber = u64; type BlockWeights = (); + type BlockLength = (); + type Origin = Origin; type Call = Call; - type DbWeight = (); - type Event = Event; + type Index = u64; + type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; - type Header = Header; - type Index = u64; + type AccountId = u64; type Lookup = IdentityLookup; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; - type Origin = Origin; + type Header = Header; + type Event = Event; + type BlockHashCount = ConstU64<250>; + type DbWeight = (); + type Version = (); type PalletInfo = PalletInfo; - type SS58Prefix = (); + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = (); type SystemWeightInfo = (); - type Version = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = ConstU32<16>; } impl pallet_balances::Config for Test { - type AccountStore = System; type Balance = u64; type DustRemoval = (); type Event = Event; type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); type MaxLocks = ConstU32<10>; type MaxReserves = (); type ReserveIdentifier = [u8; 8]; - type WeightInfo = (); } parameter_types! { pub const MinVestedTransfer: u64 = 256 * 2; @@ -78,12 +78,12 @@ parameter_types! { } impl pallet_vesting::Config for Test { - type BlockNumberToBalance = Identity; - type Currency = Balances; type Event = Event; - const MAX_VESTING_SCHEDULES: u32 = 3; + type Currency = Balances; + type BlockNumberToBalance = Identity; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = (); + const MAX_VESTING_SCHEDULES: u32 = 3; } /// Balance of an account. @@ -105,6 +105,7 @@ impl pallet_assets::Config for Test { type Currency = Balances; type ForceOrigin = frame_system::EnsureRoot; type AssetDeposit = AssetDeposit; + type AssetAccountDeposit = (); type MetadataDepositBase = MetadataDepositBase; type MetadataDepositPerByte = MetaDataDepositPerByte; type ApprovalDeposit = ApprovalDeposit; @@ -112,7 +113,6 @@ impl pallet_assets::Config for Test { type Freezer = (); type Extra = (); type WeightInfo = (); - type AssetAccountDeposit = (); } pub struct ExtBuilder { diff --git a/integration-tests/src/vesting.rs b/integration-tests/src/vesting.rs index 1ccf4085..92e47517 100644 --- a/integration-tests/src/vesting.rs +++ b/integration-tests/src/vesting.rs @@ -12,7 +12,7 @@ const ED: u64 = 256; fn vest_and_assert_no_vesting(account: u64) where u64: EncodeLike<::AccountId>, - T: pallet_vesting::Config, + T: Config, { // Its ok for this to fail because the user may already have no schedules. let _result = Vesting::vest(Some(account).into()); diff --git a/node/Cargo.toml b/node/Cargo.toml index 01e18226..3db2ffd0 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -7,7 +7,7 @@ homepage = 'https://substrate.dev' license = 'Apache-2.0' name = 'ice-node' repository = 'https://github.com/web3labs/ice-substrate' -version = '0.4.44' +version = '0.4.45' publish = false [package.metadata.docs.rs] @@ -138,9 +138,7 @@ try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "p [build-dependencies] -sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", optional = true } sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24", optional = true } -polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.24", optional = true } build-script-utils = { package = "substrate-build-script-utils", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.24" } [features] diff --git a/node/src/chain_spec/frost.rs b/node/src/chain_spec/frost.rs index 2a8eb3e5..d6a6a57e 100644 --- a/node/src/chain_spec/frost.rs +++ b/node/src/chain_spec/frost.rs @@ -52,7 +52,7 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { } const AIRDROP_MERKLE_ROOT: [u8; 32] = - hex_literal::hex!("990e01e3959627d2ddd94927e1c605a422b62dc3b8c8b98d713ae6833c3ef122"); + hex!("990e01e3959627d2ddd94927e1c605a422b62dc3b8c8b98d713ae6833c3ef122"); /// Initialize frost testnet configuration pub fn testnet_config() -> Result { diff --git a/node/src/service/arctic.rs b/node/src/service/arctic.rs index 1786274a..7cc7afc7 100644 --- a/node/src/service/arctic.rs +++ b/node/src/service/arctic.rs @@ -18,7 +18,6 @@ use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface; use fc_consensus::FrontierBlockImport; use fc_rpc_core::types::{FeeHistoryCache, FilterPool}; use futures::StreamExt; -use pallet_contracts_rpc::ContractsApiServer; use polkadot_service::CollatorPair; use sc_client_api::{BlockchainEvents, ExecutorProvider}; use sc_consensus::import_queue::BasicQueue; @@ -131,7 +130,7 @@ where }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( + let executor = NativeElseWasmExecutor::::new( config.wasm_method, config.default_heap_pages, config.max_runtime_instances, @@ -485,289 +484,6 @@ where Ok((task_manager, client)) } -/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. -/// -/// This is the actual implementation that is abstract over the executor and the runtime api. -/// -/// NOTE: for runtimes that supports pallet_contracts_rpc -#[sc_tracing::logging::prefix_logs_with("Parachain")] -async fn start_contracts_node_impl( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - id: ParaId, - build_import_queue: BIQ, - build_consensus: BIC, -) -> sc_service::error::Result<( - TaskManager, - Arc>>, -)> -where - RuntimeApi: ConstructRuntimeApi>> - + Send - + Sync - + 'static, - RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue - + sp_api::Metadata - + sp_session::SessionKeys - + sp_api::ApiExt< - Block, - StateBackend = sc_client_api::StateBackendFor, Block>, - > + sp_offchain::OffchainWorkerApi - + sp_block_builder::BlockBuilder - + substrate_frame_rpc_system::AccountNonceApi - + pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi - + fp_rpc::EthereumRuntimeRPCApi - + fp_rpc::ConvertTransactionRuntimeApi - + pallet_contracts_rpc::ContractsRuntimeApi - + cumulus_primitives_core::CollectCollationInfo, - sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, - Executor: sc_executor::NativeExecutionDispatch + 'static, - BIQ: FnOnce( - Arc>>, - FrontierBlockImport< - Block, - Arc>>, - TFullClient>, - >, - &Configuration, - Option, - &TaskManager, - ) -> Result< - sc_consensus::DefaultImportQueue< - Block, - TFullClient>, - >, - sc_service::Error, - >, - BIC: FnOnce( - Arc>>, - Option<&Registry>, - Option, - &TaskManager, - Arc, - Arc< - sc_transaction_pool::FullPool< - Block, - TFullClient>, - >, - >, - Arc>, - SyncCryptoStorePtr, - bool, - ) -> Result>, sc_service::Error>, -{ - if matches!(parachain_config.role, Role::Light) { - return Err("Light client not supported!".into()); - } - - let parachain_config = prepare_node_config(parachain_config); - let params = new_partial::(¶chain_config, build_import_queue)?; - let (mut telemetry, telemetry_worker_handle, frontier_backend) = params.other; - - let client = params.client.clone(); - let backend = params.backend.clone(); - - let mut task_manager = params.task_manager; - let (relay_chain_interface, collator_key) = build_relay_chain_interface( - polkadot_config, - ¶chain_config, - telemetry_worker_handle, - &mut task_manager, - collator_options.clone(), - ) - .await - .map_err(|e| match e { - RelayChainError::ServiceError(polkadot_service::Error::Sub(x)) => x, - s => format!("{}", s).into(), - })?; - let block_announce_validator = BlockAnnounceValidator::new(relay_chain_interface.clone(), id); - - let force_authoring = parachain_config.force_authoring; - let is_authority = parachain_config.role.is_authority(); - let prometheus_registry = parachain_config.prometheus_registry().cloned(); - let transaction_pool = params.transaction_pool.clone(); - let import_queue = cumulus_client_service::SharedImportQueue::new(params.import_queue); - let (network, system_rpc_tx, start_network) = - sc_service::build_network(sc_service::BuildNetworkParams { - config: ¶chain_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - spawn_handle: task_manager.spawn_handle(), - import_queue: import_queue.clone(), - block_announce_validator_builder: Some(Box::new(|_| { - Box::new(block_announce_validator) - })), - warp_sync: None, - })?; - - let filter_pool: FilterPool = Arc::new(std::sync::Mutex::new(BTreeMap::new())); - let fee_history_cache: FeeHistoryCache = Arc::new(std::sync::Mutex::new(BTreeMap::new())); - let overrides = crate::rpc::overrides_handle(client.clone()); - - // Frontier offchain DB task. Essential. - // Maps emulated ethereum data to substrate native data. - task_manager.spawn_essential_handle().spawn( - "frontier-mapping-sync-worker", - Some("frontier"), - fc_mapping_sync::MappingSyncWorker::new( - client.import_notification_stream(), - Duration::new(6, 0), - client.clone(), - backend.clone(), - frontier_backend.clone(), - 3, - 0, - fc_mapping_sync::SyncStrategy::Parachain, - ) - .for_each(|()| futures::future::ready(())), - ); - - // Frontier `EthFilterApi` maintenance. Manages the pool of user-created Filters. - // Each filter is allowed to stay in the pool for 100 blocks. - const FILTER_RETAIN_THRESHOLD: u64 = 100; - task_manager.spawn_essential_handle().spawn( - "frontier-filter-pool", - Some("frontier"), - fc_rpc::EthTask::filter_pool_task( - client.clone(), - filter_pool.clone(), - FILTER_RETAIN_THRESHOLD, - ), - ); - - task_manager.spawn_essential_handle().spawn( - "frontier-schema-cache-task", - Some("frontier"), - fc_rpc::EthTask::ethereum_schema_cache_task(client.clone(), frontier_backend.clone()), - ); - - const FEE_HISTORY_LIMIT: u64 = 2048; - task_manager.spawn_essential_handle().spawn( - "frontier-fee-history", - Some("frontier"), - fc_rpc::EthTask::fee_history_task( - client.clone(), - overrides.clone(), - fee_history_cache.clone(), - FEE_HISTORY_LIMIT, - ), - ); - - let block_data_cache = Arc::new(fc_rpc::EthBlockDataCacheTask::new( - task_manager.spawn_handle(), - overrides.clone(), - 50, - 50, - prometheus_registry.clone(), - )); - - let rpc_extensions_builder = { - let client = client.clone(); - let network = network.clone(); - let transaction_pool = transaction_pool.clone(); - - Box::new(move |deny_unsafe, subscription| { - let deps = crate::rpc::FullDeps { - client: client.clone(), - pool: transaction_pool.clone(), - graph: transaction_pool.pool().clone(), - network: network.clone(), - is_authority, - deny_unsafe, - frontier_backend: frontier_backend.clone(), - filter_pool: filter_pool.clone(), - fee_history_limit: FEE_HISTORY_LIMIT, - fee_history_cache: fee_history_cache.clone(), - block_data_cache: block_data_cache.clone(), - overrides: overrides.clone(), - }; - - let mut io = crate::rpc::create_full(deps, subscription)?; - - // This node support WASM contracts - io.merge(pallet_contracts_rpc::Contracts::new(Arc::clone(&client)).into_rpc()) - .map_err(|_| { - sc_service::Error::Other( - "Failed to register pallet-contracts RPC methods.".into(), - ) - })?; - - Ok(io) - }) - }; - - // Spawn basic services. - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - rpc_builder: rpc_extensions_builder, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - task_manager: &mut task_manager, - config: parachain_config, - keystore: params.keystore_container.sync_keystore(), - backend: backend.clone(), - network: network.clone(), - system_rpc_tx, - telemetry: telemetry.as_mut(), - })?; - - let announce_block = { - let network = network.clone(); - Arc::new(move |hash, data| network.announce_block(hash, data)) - }; - - let relay_chain_slot_duration = Duration::from_secs(6); - - if is_authority { - let parachain_consensus = build_consensus( - client.clone(), - prometheus_registry.as_ref(), - telemetry.as_ref().map(|t| t.handle()), - &task_manager, - relay_chain_interface.clone(), - transaction_pool, - network, - params.keystore_container.sync_keystore(), - force_authoring, - )?; - - let spawner = task_manager.spawn_handle(); - - let params = StartCollatorParams { - para_id: id, - block_status: client.clone(), - announce_block, - client: client.clone(), - task_manager: &mut task_manager, - relay_chain_interface: relay_chain_interface.clone(), - spawner, - parachain_consensus, - import_queue, - collator_key: collator_key.expect("Command line arguments do not allow this. qed"), - relay_chain_slot_duration, - }; - - start_collator(params).await?; - } else { - let params = StartFullNodeParams { - client: client.clone(), - announce_block, - task_manager: &mut task_manager, - para_id: id, - relay_chain_interface, - relay_chain_slot_duration, - import_queue, - collator_options, - }; - - start_full_node(params)?; - } - - start_network.start_network(); - - Ok((task_manager, client)) -} - /// Build the import queue. pub fn build_import_queue( client: Arc>>, diff --git a/node/src/service/frost.rs b/node/src/service/frost.rs index 245f0a56..1e783518 100644 --- a/node/src/service/frost.rs +++ b/node/src/service/frost.rs @@ -88,7 +88,7 @@ pub fn new_partial( }) .transpose()?; - let executor = sc_executor::NativeElseWasmExecutor::::new( + let executor = NativeElseWasmExecutor::::new( config.wasm_method, config.default_heap_pages, config.max_runtime_instances, diff --git a/pallets/airdrop/Cargo.toml b/pallets/airdrop/Cargo.toml index b1bf2bbc..900e869c 100644 --- a/pallets/airdrop/Cargo.toml +++ b/pallets/airdrop/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-airdrop" -version = "0.4.3" +version = "0.4.4" edition = "2021" description = "Handle intiial airdropping" authors = ["ICONOSphere "] diff --git a/pallets/airdrop/src/benchmarking.rs b/pallets/airdrop/src/benchmarking.rs index 116e503a..2d2af2cc 100644 --- a/pallets/airdrop/src/benchmarking.rs +++ b/pallets/airdrop/src/benchmarking.rs @@ -48,9 +48,7 @@ where B: Get, { fn from(sample: BenchmarkSample<'a>) -> Self { - let proff_size = B::get(); - - // assert_eq!(sample.merkle_proofs.len(), proff_size as usize); + // assert_eq!(sample.merkle_proofs.len(), proof_size as usize); let amount = sample.amount; let defi_user = sample.defi_user; let ice_address = hex::decode(sample.ice_address).unwrap().try_into().unwrap(); @@ -71,9 +69,9 @@ where let merkle_proofs = sample .merkle_proofs .iter() - .map(|proff| { - let proff = hex::decode(proff).unwrap(); - proff.try_into().unwrap() + .map(|proof| { + let proof = hex::decode(proof).unwrap(); + proof.try_into().unwrap() }) .collect::>() .try_into() @@ -93,7 +91,7 @@ where } } -pub const benchmark_samples: [BenchmarkSample; 4] = [ +pub const BENCHMARK_SAMPLES: [BenchmarkSample; 4] = [ BenchmarkSample{ icon_address : "3d16047c23cc3e27e807f6cfc55fb8d950555690", icon_signature : "a9b435d7720228efd12327a3551ffab56e737be8071673cfdad59f25a9d20f425b99874ac4c17b29063160d247c95cc0a71b3647e58b5dfb67c1839943920b9700", @@ -184,7 +182,7 @@ pub const benchmark_samples: [BenchmarkSample; 4] = [ } ]; -const creditor_key: sp_core::sr25519::Public = sr25519::Public([1; 32]); +const CREDITOR_KEY: sr25519::Public = sr25519::Public([1; 32]); fn assert_last_event(generic_event: ::Event) { frame_system::Pallet::::assert_last_event(generic_event.into()); diff --git a/pallets/airdrop/src/exchange_accounts.rs b/pallets/airdrop/src/exchange_accounts.rs index ac0909a0..92566740 100644 --- a/pallets/airdrop/src/exchange_accounts.rs +++ b/pallets/airdrop/src/exchange_accounts.rs @@ -21,15 +21,16 @@ pub(crate) const EXCHANGE_ACCOUNTS: &[([u8; 20], u128)] = &[ ), ]; +use crate::{types, Config}; use sp_runtime::traits::Convert; use sp_std::vec::Vec; -use crate::{Config, types}; pub(crate) fn get_exchange_account() -> Vec<(types::IconAddress, types::BalanceOf)> { - EXCHANGE_ACCOUNTS - .iter() - .map(|(address, balance)|{ - let address = *address; - let balance: crate::types::BalanceOf = T::BalanceTypeConversion::convert(*balance); - (address, balance) - }).collect() -} \ No newline at end of file + EXCHANGE_ACCOUNTS + .iter() + .map(|(address, balance)| { + let address = *address; + let balance: types::BalanceOf = T::BalanceTypeConversion::convert(*balance); + (address, balance) + }) + .collect() +} diff --git a/pallets/airdrop/src/lib.rs b/pallets/airdrop/src/lib.rs index d5a724e2..de8aeb24 100644 --- a/pallets/airdrop/src/lib.rs +++ b/pallets/airdrop/src/lib.rs @@ -1,6 +1,5 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::large_enum_variant)] - #![cfg_attr(not(feature = "std"), no_std)] #[cfg(test)] @@ -9,13 +8,13 @@ pub mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -/// All the types, traits defination and alises are inside this +/// All the types, traits definition and aliases are inside this pub mod types; /// All independent utilities function are inside here pub mod utils; -// Weight Information related to this palet +// Weight Information related to this pallet pub mod weights; pub mod merkle; @@ -37,7 +36,7 @@ pub use pallet::*; #[frame_support::pallet] pub mod pallet { use super::{error, info}; - use super::{types, utils, weights, exchange_accounts}; + use super::{exchange_accounts, types, utils, weights}; use hex_literal::hex; use sp_runtime::traits::Convert; @@ -58,7 +57,7 @@ pub mod pallet { /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] pub trait Config: frame_system::Config + pallet_vesting::Config { - /// Because this pallet emits events, it depends on the runtime's definition of an event. + /// Because this pallet emits events, it depends on the runtime definition of an event. type Event: From> + IsType<::Event>; type Currency: Currency> @@ -76,7 +75,7 @@ pub mod pallet { + Convert, types::BalanceOf> + Convert, types::VestingBalanceOf>; - type MerkelProofValidator: types::MerkelProofValidator; + type MerkelProofValidator: MerkelProofValidator; type MaxProofSize: Get; @@ -96,7 +95,7 @@ pub mod pallet { /// PartialClaimRequest have been ok for given icon address ClaimPartialSuccess(types::IconAddress), - /// Value of ServerAccount sotrage have been changed + /// Value of ServerAccount storage have been changed // Return old value and new one ServerAccountChanged { old_account: Option>, @@ -115,7 +114,7 @@ pub mod pallet { new_root: [u8; 32], }, - /// Creditor balance is runnning low + /// Creditor balance is running low CreditorBalanceLow, } @@ -165,7 +164,7 @@ pub mod pallet { /// Claim has already been made so can't be made again at this time ClaimAlreadyMade, - /// Coversion between partially-compatible type failed + /// Conversion between partially-compatible type failed FailedConversion, /// Creditor account do not have enough USABLE balance to @@ -184,7 +183,7 @@ pub mod pallet { /// Given proof set was invalid to expected tree root InvalidMerkleProof, - /// Provided proof size excced the maximum limit + /// Provided proof size exceed the maximum limit ProofTooLarge, /// This icon address have already been mapped to another ice address @@ -194,7 +193,7 @@ pub mod pallet { IceAddressInUse, // Airdrop pallet expect AccountId32 as AccountId - // and all signature verification as well as Markle proff + // and all signature verification as well as Marble proof // have been constructed with this assumption /// Unexpected format of AccountId IncompatibleAccountId, @@ -211,7 +210,7 @@ pub mod pallet { /// Invalid signature provided InvalidIceSignature, - /// Couldnot get embedded ice address from message + /// Couldn't get embedded ice address from message FailedExtractingIceAddress, /// Given message payload is invalid or is in unexpected format @@ -247,13 +246,13 @@ pub mod pallet { // Make sure only root or server account call call this Self::ensure_root_or_server(origin).map_err(|_| Error::::DeniedOperation)?; - // Make sure node is accepting new claimrequest + // Make sure node is accepting new claim-request Self::ensure_user_claim_switch()?; // Verify the integrity of message Self::validate_message_payload(&message, &ice_address).map_err(|e| { info!( - "claim request by: {icon_address:?}. Rejected at: validate_message_paload(). Error: {e:?}" + "claim request by: {icon_address:?}. Rejected at: validate_message_payload(). Error: {e:?}" ); e })?; @@ -262,7 +261,7 @@ pub mod pallet { Self::validate_merkle_proof(&icon_address, total_amount, defi_user, proofs).map_err( |e| { info!( - "claim request by: {icon_address:?}. Rejected at: validate_merkle_proff()" + "claim request by: {icon_address:?}. Rejected at: validate_merkle_proof()" ); e }, @@ -295,13 +294,13 @@ pub mod pallet { // Make sure this user is eligible for claim. Self::ensure_claimable(&snapshot).map_err(|e| { - info!("claim requet by: {icon_address:?}. Rejected at: ensure_claimable(). Snapshot: {snapshot:?}."); + info!("claim request by: {icon_address:?}. Rejected at: ensure_claimable(). Snapshot: {snapshot:?}."); e })?; // We also make sure creditor have enough fund to complete this airdrop Self::validate_creditor_fund(total_amount).map_err(|e| { - error!("claim requet by: {icon_address:?}. Rejected at: validate_creditor_fund(). Amount: {total_amount:?}"); + error!("claim request by: {icon_address:?}. Rejected at: validate_creditor_fund(). Amount: {total_amount:?}"); e })?; @@ -350,7 +349,9 @@ pub mod pallet { let mut snapshot = Self::insert_or_get_snapshot(&icon_address, &ice_address, defi_user, total_amount) .map_err(|e| { - error!("Exhange for: {icon_address:?}. Failed at: insert_or_get_snapshot."); + error!( + "Exchange for: {icon_address:?}. Failed at: insert_or_get_snapshot." + ); e })?; @@ -486,7 +487,7 @@ pub mod pallet { amount: types::BalanceOf, ) -> Result, DispatchError> { let ice_account = - Self::to_account_id(ice_address.to_vec().try_into().map_err(|_| { + Self::convert_to_account_id(ice_address.to_vec().try_into().map_err(|_| { error!( "received ice_address: {ice_address:?} cannot be converted into [u8; 32]" ); @@ -549,9 +550,9 @@ pub mod pallet { pub fn validate_creditor_fund(required_amount: types::BalanceOf) -> DispatchResult { let creditor_balance = ::Currency::free_balance(&Self::get_creditor_account()?); - let exestensial_deposit = ::Currency::minimum_balance(); + let existential_deposit = ::Currency::minimum_balance(); - if creditor_balance > required_amount + exestensial_deposit { + if creditor_balance > required_amount + existential_deposit { Ok(()) } else { Self::deposit_event(Event::::CreditorBalanceLow); @@ -643,7 +644,9 @@ pub mod pallet { Ok(()) } - pub fn to_account_id(ice_bytes: [u8; 32]) -> Result, Error> { + pub fn convert_to_account_id( + ice_bytes: [u8; 32], + ) -> Result, Error> { ::AccountId::decode(&mut &ice_bytes[..]) .map_err(|_e| Error::::InvalidIceAddress) } @@ -655,7 +658,7 @@ pub mod pallet { use types::DoTransfer; #[cfg(not(feature = "no-vesting"))] - type TransferType = super::vested_transfer::DoVestdTransfer; + type TransferType = super::vested_transfer::DoVestedTransfer; #[cfg(feature = "no-vesting")] type TransferType = super::non_vested_transfer::AllInstantTransfer; diff --git a/pallets/airdrop/src/tests/mock.rs b/pallets/airdrop/src/tests/mock.rs index 84b4b520..d8ab82cb 100644 --- a/pallets/airdrop/src/tests/mock.rs +++ b/pallets/airdrop/src/tests/mock.rs @@ -20,9 +20,9 @@ pub struct TestValidator(PhantomData); impl types::MerkelProofValidator for TestValidator { fn validate( - _root_hash: pallet_airdrop::types::MerkleHash, - _leaf_hash: pallet_airdrop::types::MerkleHash, - _proofs: pallet_airdrop::types::MerkleProofs, + _root_hash: types::MerkleHash, + _leaf_hash: types::MerkleHash, + _proofs: types::MerkleProofs, ) -> bool { return true; } @@ -50,7 +50,6 @@ impl system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type BlockWeights = (); type BlockLength = (); - type DbWeight = (); type Origin = Origin; type Call = Call; type Index = Index; @@ -62,6 +61,7 @@ impl system::Config for Test { type Header = Header; type Event = Event; type BlockHashCount = BlockHashCount; + type DbWeight = (); type Version = (); type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -70,7 +70,7 @@ impl system::Config for Test { type SystemWeightInfo = (); type SS58Prefix = SS58Prefix; type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { @@ -82,8 +82,8 @@ parameter_types! { impl pallet_airdrop::Config for Test { type Event = Event; type Currency = Balances; - type BalanceTypeConversion = sp_runtime::traits::ConvertInto; type AirdropWeightInfo = pallet_airdrop::weights::AirDropWeightInfo; + type BalanceTypeConversion = sp_runtime::traits::ConvertInto; type MerkelProofValidator = TestValidator; type MaxProofSize = ConstU32<10>; @@ -95,15 +95,15 @@ impl pallet_airdrop::Config for Test { } impl pallet_balances::Config for Test { - type MaxLocks = MaxLocks; - type MaxReserves = (); - type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; type DustRemoval = (); + type Event = Event; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type MaxLocks = MaxLocks; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; } impl pallet_vesting::Config for Test { diff --git a/pallets/airdrop/src/tests/mod.rs b/pallets/airdrop/src/tests/mod.rs index b4bed1d0..d577549c 100644 --- a/pallets/airdrop/src/tests/mod.rs +++ b/pallets/airdrop/src/tests/mod.rs @@ -7,7 +7,7 @@ mod utility_functions; pub mod prelude { pub use super::{ force_get_creditor_account, get_last_event, minimal_test_ext, mock, run_to_block, samples, - set_creditor_balance, tranfer_to_creditor, + set_creditor_balance, transfer_to_creditor, }; pub use crate as pallet_airdrop; pub use crate::tests; @@ -177,9 +177,9 @@ pub fn to_test_case( (hash_bytes, proofs) } -pub fn tranfer_to_creditor(sponser: &types::AccountIdOf, amount: types::BalanceOf) { +pub fn transfer_to_creditor(sponsor: &types::AccountIdOf, amount: types::BalanceOf) { assert_ok!(::Currency::transfer( - Origin::signed(sponser.clone()), + Origin::signed(sponsor.clone()), force_get_creditor_account::(), amount, )); diff --git a/pallets/airdrop/src/tests/user_claim.rs b/pallets/airdrop/src/tests/user_claim.rs index e0a56eca..6efa1acd 100644 --- a/pallets/airdrop/src/tests/user_claim.rs +++ b/pallets/airdrop/src/tests/user_claim.rs @@ -304,7 +304,7 @@ fn partail_transfer_can_reclaim() { #[cfg(not(feature = "no-vesting"))] let (instant_amount, vesting_amount) = { let (raw_instant, raw_vesting) = - utils::get_splitted_amounts::(case.amount, get_per(case.defi_user)).unwrap(); + utils::get_split_amounts::(case.amount, get_per(case.defi_user)).unwrap(); let (schedule, rem) = utils::new_vesting_with_deadline::< Test, { crate::vested_transfer::VESTING_APPLICABLE_FROM }, diff --git a/pallets/airdrop/src/tests/utility_functions.rs b/pallets/airdrop/src/tests/utility_functions.rs index 2738e9f9..48fbcfc9 100644 --- a/pallets/airdrop/src/tests/utility_functions.rs +++ b/pallets/airdrop/src/tests/utility_functions.rs @@ -62,47 +62,47 @@ fn ensure_root_or_server() { } #[test] -fn get_vesting_amounts_splitted() { +fn get_vesting_amounts_split() { minimal_test_ext().execute_with(|| { use sp_runtime::ArithmeticError; - let get_splitted_amounts: _ = utils::get_splitted_amounts::; + let get_split_amounts: _ = utils::get_split_amounts::; let defi_instant = utils::get_instant_percentage::(true); let non_defi_instant = utils::get_instant_percentage::(false); assert_err!( - get_splitted_amounts(types::ServerBalance::max_value(), defi_instant), + get_split_amounts(types::ServerBalance::max_value(), defi_instant), ArithmeticError::Overflow ); assert_eq!( Ok((0_u32.into(), 0_u32.into())), - get_splitted_amounts(0_u32.into(), defi_instant) + get_split_amounts(0_u32.into(), defi_instant) ); assert_eq!( Ok((900_u32.into(), 2100_u32.into())), - get_splitted_amounts(3_000_u32.into(), non_defi_instant) + get_split_amounts(3_000_u32.into(), non_defi_instant) ); assert_eq!( Ok((1200_u32.into(), 1800_u32.into())), - get_splitted_amounts(3_000_u32.into(), defi_instant) + get_split_amounts(3_000_u32.into(), defi_instant) ); assert_eq!( Ok((0_u32.into(), 1_u32.into())), - get_splitted_amounts(1_u32.into(), non_defi_instant) + get_split_amounts(1_u32.into(), non_defi_instant) ); assert_eq!( Ok((0_u32.into(), 1_u32.into())), - get_splitted_amounts(1_u32.into(), defi_instant) + get_split_amounts(1_u32.into(), defi_instant) ); assert_eq!( Ok((2932538_u32.into(), 6842591_u32.into())), - get_splitted_amounts(9775129_u32.into(), non_defi_instant) + get_split_amounts(9775129_u32.into(), non_defi_instant) ); assert_eq!( Ok((3910051_u32.into(), 5865078_u32.into())), - get_splitted_amounts(9775129_u32.into(), defi_instant) + get_split_amounts(9775129_u32.into(), defi_instant) ); }); } @@ -135,11 +135,11 @@ fn cook_vesting_schedule() { } { - let (schedule, remainer) = + let (schedule, remained) = utils::new_vesting_with_deadline::(12u32.into(), 10u32.into()); let primary = schedule.unwrap(); - assert_eq!(remainer, 2u32.into()); + assert_eq!(remained, 2u32.into()); assert_eq!(primary.locked(), 10u32.into()); assert_eq!(primary.per_block(), 2u32.into()); @@ -150,11 +150,11 @@ fn cook_vesting_schedule() { } { - let (schedule, remainer) = + let (schedule, remained) = utils::new_vesting_with_deadline::(16u32.into(), 10u32.into()); let schedule = schedule.unwrap(); - assert_eq!(remainer, 6u32.into()); + assert_eq!(remained, 6u32.into()); assert_eq!(schedule.locked(), 10u32.into()); assert_eq!(schedule.per_block(), 1u32.into()); @@ -165,11 +165,11 @@ fn cook_vesting_schedule() { } { - let (schedule, remainer) = + let (schedule, remained) = utils::new_vesting_with_deadline::(3336553u32.into(), 10_000u32.into()); let schedule = schedule.unwrap(); - assert_eq!(remainer, 6553u32.into()); + assert_eq!(remained, 6553u32.into()); assert_eq!(schedule.locked(), 3330000u32.into()); assert_eq!(schedule.per_block(), 333u32.into()); @@ -211,7 +211,7 @@ fn making_vesting_transfer() { // Ensure all amount is being transferred assert_eq!(9775129_u128, Currency::free_balance(&claimer)); - // Make sure user is getting atleast of instant amount + // Make sure user is getting at least of instant amount // might get more due to vesting remainder assert!(Currency::usable_balance(&claimer) >= 2932538_u32.into()); @@ -233,11 +233,11 @@ fn making_vesting_transfer() { assert_ok!(AirdropModule::do_transfer(&mut snapshot, &icon_address)); - // Ensure amount only accounting to vesting is transfererd + // Ensure amount only accounting to vesting is transferred let expected_transfer = { let vesting_amount: types::VestingBalanceOf = - utils::get_splitted_amounts::(amount, get_per(defi_user)) + utils::get_split_amounts::(amount, get_per(defi_user)) .unwrap() .1; let schedule = utils::new_vesting_with_deadline::( @@ -273,7 +273,7 @@ fn making_vesting_transfer() { // Ensure amount only accounting to instant is transferred let expected_transfer = { let (instant_amount, vesting_amount) = - utils::get_splitted_amounts::(amount, get_per(defi_user)).unwrap(); + utils::get_split_amounts::(amount, get_per(defi_user)).unwrap(); let remainder = utils::new_vesting_with_deadline::( vesting_amount, 5256000u32.into(), @@ -305,7 +305,7 @@ fn making_vesting_transfer() { assert_ok!(AirdropModule::do_transfer(&mut snapshot, &icon_address)); - // Ensure amount only accounting to instant is transfererd + // Ensure amount only accounting to instant is transferred assert_eq!(0_u128, Currency::free_balance(&claimer)); // Ensure flag is updates @@ -325,7 +325,7 @@ fn test_extract_address() { #[test] fn respect_airdrop_state() { - // First verify thet initially everything is allowed + // First verify that initially everything is allowed assert_eq!( types::AirdropState::default(), types::AirdropState { @@ -411,9 +411,10 @@ fn validate_creditor_fund() { use frame_support::traits::Currency; minimal_test_ext().execute_with(|| { - let exestinsial_balance = ::Currency::minimum_balance(); - let donator = samples::ACCOUNT_ID[1]; - let _put_fund = ::Currency::deposit_creating(&donator, u64::MAX.into()); + let existential_balance = ::Currency::minimum_balance(); + let donor = samples::ACCOUNT_ID[1]; + let _put_fund = + ::Currency::deposit_creating(&donor, u64::MAX.into()); // When creditor balance is empty. { @@ -425,16 +426,16 @@ fn validate_creditor_fund() { // When creditor balance is exactly same as exestinsial balance { - tranfer_to_creditor(&donator, exestinsial_balance); + transfer_to_creditor(&donor, existential_balance); assert_err!( - AirdropModule::validate_creditor_fund(exestinsial_balance.try_into().unwrap()), + AirdropModule::validate_creditor_fund(existential_balance.try_into().unwrap()), PalletError::InsufficientCreditorBalance, ); } // When all of creditor balance is required { - tranfer_to_creditor(&donator, u32::MAX.into()); + transfer_to_creditor(&donor, u32::MAX.into()); let required_balance = ::Currency::free_balance( &force_get_creditor_account::(), ); diff --git a/pallets/airdrop/src/types.rs b/pallets/airdrop/src/types.rs index f2ade6fe..c8314238 100644 --- a/pallets/airdrop/src/types.rs +++ b/pallets/airdrop/src/types.rs @@ -61,7 +61,7 @@ pub type MerkleProofs = BoundedVec::MaxProofSize>; /// pub type VestingInfoOf = pallet_vesting::VestingInfo, BlockNumberOf>; -/// type that represnt the error that can occur while validation the signature +/// type that represent the error that can occur while validation the signature #[derive(Eq, PartialEq, Debug)] pub enum SignatureValidationError { InvalidIconAddress, @@ -77,21 +77,21 @@ pub struct SnapshotInfo { /// Icon address of this snapshot pub ice_address: AccountIdOf, - /// Total airdroppable-amount this icon_address hold + /// Total air-droppable-amount this icon_address hold pub amount: BalanceOf, - /// Indicator wather this icon_address holder is defi-user + /// Indicator weather this icon_address holder is defi-user pub defi_user: bool, - /// indicator wather the user have claimmed the balance + /// indicator weather the user have claimed the balance /// which will be given through instant transfer pub done_instant: bool, - /// Indicator weather vesting schedult have been applied + /// Indicator weather vesting schedule have been applied /// to this user pub done_vesting: bool, - // blocknumber that started vesting + // block number that started vesting pub vesting_block_number: Option>, // block number when instant amount was given @@ -183,7 +183,7 @@ pub trait MerkelProofValidator { } /// Trait to commit behaviour of do_transfer function -/// this trait now can me implmeneted according to +/// this trait now can me implemented according to /// the node behaviour eg: vesting manner and direct manner pub trait DoTransfer { fn do_transfer(snapshot: &mut SnapshotInfo) -> DispatchResult; diff --git a/pallets/airdrop/src/utils.rs b/pallets/airdrop/src/utils.rs index 47d3a5ce..da4002a1 100644 --- a/pallets/airdrop/src/utils.rs +++ b/pallets/airdrop/src/utils.rs @@ -10,9 +10,9 @@ use sp_runtime::{ }; use sp_std::vec::Vec; -/// Reuturns an optional vesting schedule which when applied release given amount +/// Returns an optional vesting schedule which when applied release given amount /// which will be complete in given block. If -/// Also return amount which is remaineder if amount can't be perfectly divided +/// Also return amount which is remainder if amount can't be perfectly divided /// in per block basis pub fn new_vesting_with_deadline( amount: types::VestingBalanceOf, @@ -31,8 +31,8 @@ where let idol_transfer_multiple = transfer_over * MIN_AMOUNT_PER_BLOCK.into(); - let remainding_amount = amount % idol_transfer_multiple; - let primary_transfer_amount = amount.saturating_sub(remainding_amount); + let remaining_amount = amount % idol_transfer_multiple; + let primary_transfer_amount = amount.saturating_sub(remaining_amount); let per_block = primary_transfer_amount .checked_div(&idol_transfer_multiple) @@ -46,7 +46,7 @@ where )); } - (vesting, remainding_amount) + (vesting, remaining_amount) } pub fn get_instant_percentage(is_defi_user: bool) -> u8 { @@ -57,7 +57,7 @@ pub fn get_instant_percentage(is_defi_user: bool) -> u8 { } } -pub fn get_splitted_amounts( +pub fn get_split_amounts( total_amount: types::BalanceOf, instant_percentage: u8, ) -> Result<(types::BalanceOf, types::VestingBalanceOf), DispatchError> { @@ -110,7 +110,7 @@ pub fn recover_address( .chain(sig_r) .chain(sig_s) .cloned() - .collect::>() + .collect::>() }; let (_exit_status, recovered_pub_key) = ECRecoverPublicKey::execute(&formatted_signature, COST) @@ -173,7 +173,7 @@ impl Get for PanicOnNoCreditor { panic!( "No creditor account configured.\ This call was expected to return default value,\ - which will inturn produce undesired behaviour as\ + which will in turn produce undesired behaviour as \ using default AccountId as creditor is not unexpected" ); } diff --git a/pallets/airdrop/src/vested_transfer.rs b/pallets/airdrop/src/vested_transfer.rs index d5c46a28..5afccdbf 100644 --- a/pallets/airdrop/src/vested_transfer.rs +++ b/pallets/airdrop/src/vested_transfer.rs @@ -5,13 +5,13 @@ use frame_support::pallet_prelude::*; use frame_support::traits::{Currency, ExistenceRequirement}; use sp_runtime::traits::{CheckedAdd, Convert}; -// TODO: put more relaible value +// TODO: put more reliable value pub const BLOCKS_IN_YEAR: u32 = 5_256_000u32; // Block number after which enable to do vesting pub const VESTING_APPLICABLE_FROM: u32 = 1u32; -pub struct DoVestdTransfer; -impl types::DoTransfer for DoVestdTransfer { +pub struct DoVestedTransfer; +impl types::DoTransfer for DoVestedTransfer { fn do_transfer(snapshot: &mut types::SnapshotInfo) -> DispatchResult { let vesting_should_end_in = ::AIRDROP_VARIABLES.vesting_period; let defi_user = snapshot.defi_user; @@ -22,27 +22,27 @@ impl types::DoTransfer for DoVestdTransfer { let instant_percentage = utils::get_instant_percentage::(defi_user); let (mut instant_amount, vesting_amount) = - utils::get_splitted_amounts::(total_amount, instant_percentage).map_err(|e |{ - error!("At: get_splitted_amount. amount: {total_amount:?}. Instant percentage: {instant_percentage}. Reason: {e:?}"); + utils::get_split_amounts::(total_amount, instant_percentage).map_err(|e |{ + error!("At: get_split_amount. amount: {total_amount:?}. Instant percentage: {instant_percentage}. Reason: {e:?}"); e })?; - let (transfer_shcedule, remainding_amount) = utils::new_vesting_with_deadline::< + let (transfer_schedule, remaining_amount) = utils::new_vesting_with_deadline::< T, VESTING_APPLICABLE_FROM, >(vesting_amount, vesting_should_end_in.into()); // Amount to be transferred is: - // x% of totoal amount - // + remainding amount which was not perfectly divisible + // x% of total amount + // + remaining amount which was not perfectly divisible instant_amount = { - let remainding_amount = , types::BalanceOf, - >>::convert(remainding_amount); + >>::convert(remaining_amount); instant_amount - .checked_add(&remainding_amount) + .checked_add(&remaining_amount) .ok_or(sp_runtime::ArithmeticError::Overflow)? }; @@ -52,7 +52,7 @@ impl types::DoTransfer for DoVestdTransfer { let claimer_origin = ::unlookup(claimer.clone()); - match transfer_shcedule { + match transfer_schedule { // Apply vesting Some(schedule) if !snapshot.done_vesting => { let vest_res = pallet_vesting::Pallet::::vested_transfer( @@ -72,7 +72,7 @@ impl types::DoTransfer for DoVestdTransfer { } // log error Err(err) => { - error!("Error while aplying vesting. For: {claimer:?}. Reason: {err:?}"); + error!("Error while applying vesting. For: {claimer:?}. Reason: {err:?}"); } } } diff --git a/pallets/airdrop/src/weights.rs b/pallets/airdrop/src/weights.rs index 91c0af11..707cc99b 100644 --- a/pallets/airdrop/src/weights.rs +++ b/pallets/airdrop/src/weights.rs @@ -4,18 +4,17 @@ use frame_support::{traits::Get, weights::Weight}; use sp_std::marker::PhantomData; pub trait WeightInfo { - fn set_airdrop_server_account() -> Weight; fn dispatch_user_claim() -> Weight; fn dispatch_exchange_claim() -> Weight; fn update_airdrop_state() -> Weight; - fn change_merkle_root()->Weight; + fn change_merkle_root() -> Weight; } /// Weight functions for `pallet_airdrop`. pub struct AirDropWeightInfo(PhantomData); -impl WeightInfo for AirDropWeightInfo{ +impl WeightInfo for AirDropWeightInfo { // Storage: Airdrop ServerAccount (r:1 w:1) // Storage: System Number (r:1 w:0) // Storage: System ExecutionPhase (r:1 w:0) @@ -26,16 +25,6 @@ impl WeightInfo for AirDropWeightInfo{ .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Airdrop AirdropChainState (r:1 w:1) - // Storage: System Number (r:1 w:0) - // Storage: System ExecutionPhase (r:1 w:0) - // Storage: System EventCount (r:1 w:1) - // Storage: System Events (r:1 w:1) - fn update_airdrop_state() -> Weight { - (20_384_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } // Storage: Airdrop AirdropChainState (r:1 w:0) // Storage: Airdrop MerkleRoot (r:1 w:0) // Storage: Airdrop IconSnapshotMap (r:1 w:1) @@ -73,6 +62,16 @@ impl WeightInfo for AirDropWeightInfo{ .saturating_add(T::DbWeight::get().reads(14 as Weight)) .saturating_add(T::DbWeight::get().writes(8 as Weight)) } + // Storage: Airdrop AirdropChainState (r:1 w:1) + // Storage: System Number (r:1 w:0) + // Storage: System ExecutionPhase (r:1 w:0) + // Storage: System EventCount (r:1 w:1) + // Storage: System Events (r:1 w:1) + fn update_airdrop_state() -> Weight { + (20_384_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } // Storage: Airdrop MerkleRoot (r:1 w:1) // Storage: System Number (r:1 w:0) // Storage: System ExecutionPhase (r:1 w:0) @@ -84,4 +83,3 @@ impl WeightInfo for AirDropWeightInfo{ .saturating_add(T::DbWeight::get().writes(3 as Weight)) } } - diff --git a/runtime/arctic/Cargo.toml b/runtime/arctic/Cargo.toml index 37f8af7f..7bbc5428 100644 --- a/runtime/arctic/Cargo.toml +++ b/runtime/arctic/Cargo.toml @@ -7,7 +7,7 @@ homepage = 'https://substrate.dev' license = 'Apache-2.0' name = 'arctic-runtime' repository = 'https://github.com/web3labs/ice-substrate/' -version = '0.4.42' +version = '0.4.43' publish = false [package.metadata.docs.rs] diff --git a/runtime/arctic/src/impls.rs b/runtime/arctic/src/impls.rs index 36187267..0a664794 100644 --- a/runtime/arctic/src/impls.rs +++ b/runtime/arctic/src/impls.rs @@ -47,7 +47,7 @@ mod tests { #[test] fn currency_units() { println!( - "DOLLARS 10e18 == {} plank // CENTS == {} plank // MLLICENTS == {} plank", + "DOLLARS 10e18 == {} plank // CENTS == {} plank // MILLICENTS == {} plank", DOLLARS.separated_string(), CENTS.separated_string(), MILLICENTS.separated_string() @@ -321,8 +321,8 @@ mod tests { 4294967295, RuntimeBlockWeights::get().max_block / 2, RuntimeBlockWeights::get().max_block, - Weight::max_value() / 2, - Weight::max_value(), + Weight::MAX / 2, + Weight::MAX, ] .into_iter() .for_each(|i| { diff --git a/runtime/arctic/src/lib.rs b/runtime/arctic/src/lib.rs index c1517db6..352d82af 100644 --- a/runtime/arctic/src/lib.rs +++ b/runtime/arctic/src/lib.rs @@ -119,7 +119,7 @@ pub type Balance = u128; pub type Index = u32; /// A hash of some data used by the chain. -pub type Hash = sp_core::H256; +pub type Hash = H256; /// Digest item type. // pub type DigestItem = generic::DigestItem; @@ -208,12 +208,10 @@ impl frame_system::Config for Runtime { /// The maximum length of a block (in bytes). type BlockLength = RuntimeBlockLength; - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; + /// The ubiquitous origin type. + type Origin = Origin; /// The aggregated dispatch type that is available for extrinsics. type Call = Call; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. @@ -222,12 +220,14 @@ impl frame_system::Config for Runtime { type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = AccountIdLookup; /// The header type. type Header = generic::Header; /// The ubiquitous event type. type Event = Event; - /// The ubiquitous origin type. - type Origin = Origin; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = BlockHashCount; /// The weight of database operations that the runtime can invoke. @@ -238,19 +238,19 @@ impl frame_system::Config for Runtime { /// /// This type is being generated by `construct_runtime!`. type PalletInfo = PalletInfo; + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; /// What to do if a new account is created. type OnNewAccount = (); /// What to do if an account is fully reaped from the system. type OnKilledAccount = (); - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = (); /// This is used as an identifier of the chain. 42 is the generic substrate prefix. type SS58Prefix = SS58Prefix; type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { @@ -262,9 +262,9 @@ impl cumulus_pallet_parachain_system::Config for Runtime { type Event = Event; type OnSystemEvent = (); type SelfParaId = parachain_info::Pallet; + type OutboundXcmpMessageSource = XcmpQueue; type DmpMessageHandler = DmpQueue; type ReservedDmpWeight = ReservedDmpWeight; - type OutboundXcmpMessageSource = XcmpQueue; type XcmpMessageHandler = XcmpQueue; type ReservedXcmpWeight = ReservedXcmpWeight; } @@ -312,8 +312,8 @@ impl pallet_session::Config for Runtime { impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; - type DisabledValidators = (); type MaxAuthorities = MaxAuthorities; + type DisabledValidators = (); } parameter_types! { @@ -326,7 +326,7 @@ parameter_types! { } // We allow root only to execute privileged collator selection operations. -pub type CollatorSelectionUpdateOrigin = frame_system::EnsureRoot; +pub type CollatorSelectionUpdateOrigin = EnsureRoot; impl pallet_collator_selection::Config for Runtime { type Event = Event; @@ -376,19 +376,19 @@ impl pallet_contracts::Config for Runtime { /// change because that would break already deployed contracts. The `Call` structure itself /// is not allowed to change the indices of existing pallets, too. type CallFilter = frame_support::traits::Nothing; - type DepositPerItem = DepositPerItem; - type DepositPerByte = DepositPerByte; type WeightPrice = pallet_transaction_payment::Pallet; type WeightInfo = pallet_contracts::weights::SubstrateWeight; type ChainExtension = (); + type Schedule = Schedule; + type CallStack = [pallet_contracts::Frame; 31]; type DeletionQueueDepth = DeletionQueueDepth; type DeletionWeightLimit = DeletionWeightLimit; - type Schedule = Schedule; + type DepositPerByte = DepositPerByte; type ContractAccessWeight = pallet_contracts::DefaultContractAccessWeight; + type DepositPerItem = DepositPerItem; + type AddressGenerator = pallet_contracts::DefaultAddressGenerator; type MaxCodeLen = ConstU32<{ 128 * 1024 }>; type RelaxedMaxCodeLen = ConstU32<{ 256 * 1024 }>; - type CallStack = [pallet_contracts::Frame; 31]; - type AddressGenerator = pallet_contracts::DefaultAddressGenerator; } parameter_types! { @@ -398,12 +398,12 @@ parameter_types! { impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); #[cfg(feature = "aura")] type OnTimestampSet = Aura; #[cfg(feature = "manual-seal")] type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; + type WeightInfo = (); } parameter_types! { @@ -425,17 +425,17 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; - type MaxReserves = (); - type ReserveIdentifier = [u8; 8]; /// The type for recording an account's balance. type Balance = Balance; + type DustRemoval = (); /// The ubiquitous event type. type Event = Event; - type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type MaxLocks = MaxLocks; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; } parameter_types! { @@ -452,9 +452,9 @@ impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = constants::fee::WeightToFee; + type LengthToFee = ConstantMultiplier; type FeeMultiplierUpdate = TargetedFeeAdjustment; - type LengthToFee = ConstantMultiplier; } impl pallet_sudo::Config for Runtime { @@ -505,11 +505,11 @@ impl pallet_evm::Config for Runtime { type AddressMapping = HashedAddressMapping; type Currency = Balances; type Event = Event; - type Runner = pallet_evm::runner::stack::Runner; type PrecompilesType = FrontierPrecompiles; type PrecompilesValue = PrecompilesValue; type ChainId = ChainId; type BlockGasLimit = BlockGasLimit; + type Runner = pallet_evm::runner::stack::Runner; type OnChargeTransaction = (); type FindAuthor = FindAuthorTruncated; } @@ -536,11 +536,11 @@ impl pallet_assets::Config for Runtime { type Balance = Balance; type AssetId = AssetId; type Currency = Balances; - type ForceOrigin = frame_system::EnsureRoot; + type ForceOrigin = EnsureRoot; type AssetDeposit = AssetDeposit; + type AssetAccountDeposit = AssetAccountDeposit; type MetadataDepositBase = MetadataDepositBase; type MetadataDepositPerByte = MetadataDepositPerByte; - type AssetAccountDeposit = AssetAccountDeposit; type ApprovalDeposit = ApprovalDeposit; type StringLimit = AssetsStringLimit; type Freezer = (); @@ -620,14 +620,14 @@ impl pallet_treasury::Config for Runtime { type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = (); type SpendPeriod = SpendPeriod; type Burn = Burn; type PalletId = TreasuryPalletId; type BurnDestination = (); - type SpendFunds = (); type WeightInfo = pallet_treasury::weights::SubstrateWeight; + type SpendFunds = (); type MaxApprovals = MaxApprovals; - type ProposalBondMaximum = (); } pub struct Beneficiary(); @@ -643,15 +643,15 @@ parameter_types! { impl pallet_simple_inflation::Config for Runtime { type Currency = Balances; - type Beneficiary = Beneficiary; type IssuingAmount = IssuingAmount; + type Beneficiary = Beneficiary; } impl pallet_fees_split::Config for Runtime {} impl pallet_utility::Config for Runtime { - type Call = Call; type Event = Event; + type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -664,14 +664,14 @@ parameter_types! { } impl pallet_scheduler::Config for Runtime { - type Call = Call; type Event = Event; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type MaximumWeight = MaximumSchedulerWeight; type Origin = Origin; - type OriginPrivilegeCmp = EqualPrivilegeOnly; type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = (); type PreimageProvider = Preimage; type NoPreimagePostponement = NoPreimagePostponement; @@ -684,8 +684,8 @@ parameter_types! { } impl pallet_preimage::Config for Runtime { - type WeightInfo = pallet_preimage::weights::SubstrateWeight; type Event = Event; + type WeightInfo = pallet_preimage::weights::SubstrateWeight; type Currency = Balances; type ManagerOrigin = EnsureRoot; type MaxSize = PreimageMaxSize; @@ -797,18 +797,18 @@ impl InstanceFilter for ProxyType { } impl pallet_proxy::Config for Runtime { - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; + type Event = Event; type Call = Call; - type CallHasher = BlakeTwo256; type Currency = Balances; - type Event = Event; - type MaxPending = MaxPending; - type MaxProxies = MaxProxies; + type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; type ProxyDepositFactor = ProxyDepositFactor; - type ProxyType = ProxyType; + type MaxProxies = MaxProxies; type WeightInfo = (); + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; } parameter_types! { @@ -820,11 +820,11 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { + type Event = Event; type Call = Call; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; - type Event = Event; type MaxSignatories = MaxSignatories; type WeightInfo = (); } @@ -874,10 +874,10 @@ impl pallet_bounties::Config for Runtime { type BountyDepositBase = BountyDepositBase; type BountyDepositPayoutDelay = BountyDepositPayoutDelay; type BountyUpdatePeriod = BountyUpdatePeriod; - type BountyValueMinimum = BountyValueMinimum; type CuratorDepositMultiplier = CuratorDepositMultiplier; - type CuratorDepositMin = CuratorDepositMin; type CuratorDepositMax = CuratorDepositMax; + type CuratorDepositMin = CuratorDepositMin; + type BountyValueMinimum = BountyValueMinimum; type DataDepositPerByte = DataDepositPerByte; type Event = Event; type MaximumReasonLength = MaximumReasonLength; @@ -886,9 +886,9 @@ impl pallet_bounties::Config for Runtime { } impl pallet_tips::Config for Runtime { - type DataDepositPerByte = DataDepositPerByte; type Event = Event; type MaximumReasonLength = MaximumReasonLength; + type DataDepositPerByte = DataDepositPerByte; type TipCountdown = TipCountdown; type TipFindersFee = TipFindersFee; type TipReportDepositBase = TipReportDepositBase; @@ -913,46 +913,46 @@ parameter_types! { const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); impl pallet_elections_phragmen::Config for Runtime { - type CandidacyBond = CandidacyBond; - type ChangeMembers = Council; + type Event = Event; + type PalletId = PhragmenElectionPalletId; type Currency = Balances; + type ChangeMembers = Council; + type InitializeMembers = Council; type CurrencyToVote = frame_support::traits::U128CurrencyToVote; + type CandidacyBond = CandidacyBond; + type VotingBondBase = VotingBondBase; + type VotingBondFactor = VotingBondFactor; + type LoserCandidate = Treasury; + type KickedMember = Treasury; type DesiredMembers = DesiredMembers; type DesiredRunnersUp = DesiredRunnersUp; - type Event = Event; - type InitializeMembers = Council; - type KickedMember = Treasury; - type LoserCandidate = Treasury; - type PalletId = PhragmenElectionPalletId; type TermDuration = TermDuration; - type VotingBondBase = VotingBondBase; - type VotingBondFactor = VotingBondFactor; type WeightInfo = (); } impl pallet_membership::Config for Runtime { - type AddOrigin = MoreThanHalfCouncil; type Event = Event; - type MaxMembers = CouncilMaxMembers; - type MembershipChanged = Council; - type MembershipInitialized = Council; - type PrimeOrigin = MoreThanHalfCouncil; + type AddOrigin = MoreThanHalfCouncil; type RemoveOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = Council; + type MembershipChanged = Council; + type MaxMembers = CouncilMaxMembers; type WeightInfo = (); } impl pallet_membership::Config for Runtime { - type AddOrigin = MoreThanHalfCouncil; type Event = Event; - type MaxMembers = TechnicalMaxMembers; - type MembershipChanged = TechnicalCommittee; - type MembershipInitialized = TechnicalCommittee; - type PrimeOrigin = MoreThanHalfCouncil; + type AddOrigin = MoreThanHalfCouncil; type RemoveOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = TechnicalCommittee; + type MembershipChanged = TechnicalCommittee; + type MaxMembers = TechnicalMaxMembers; type WeightInfo = (); } @@ -969,54 +969,55 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type BlacklistOrigin = EnsureRoot; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EnsureOneOf< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, - >; - // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = - pallet_collective::EnsureProportionAtLeast; - type CooloffPeriod = CooloffPeriod; + type Proposal = Call; + type Event = Event; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; - type Event = Event; + type LaunchPeriod = LaunchPeriod; + // Same as EnactmentPeriod + type VotingPeriod = VotingPeriod; + type VoteLockingPeriod = EnactmentPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = + pallet_collective::EnsureProportionAtLeast; + /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = + pallet_collective::EnsureProportionAtLeast; /// A unanimous council can have the next scheduled referendum be a straight default-carries /// (NTB) vote. type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast; - /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = - pallet_collective::EnsureProportionAtLeast; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = - pallet_collective::EnsureProportionAtLeast; /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote /// be tabled immediately and with a shorter voting/enactment period. type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - type InstantAllowed = InstantAllowed; type InstantOrigin = pallet_collective::EnsureProportionAtLeast; - type LaunchPeriod = LaunchPeriod; - type MaxProposals = MaxProposals; - type MaxVotes = MaxVotes; - type MinimumDeposit = MinimumDeposit; - type OperationalPreimageOrigin = pallet_collective::EnsureMember; - type PalletsOrigin = OriginCaller; - type PreimageByteDeposit = PreimageByteDeposit; - type Proposal = Call; - type Scheduler = Scheduler; - type Slash = Treasury; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = + pallet_collective::EnsureProportionAtLeast; + type BlacklistOrigin = EnsureRoot; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EnsureOneOf< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; // Any single technical committee member may veto a coming council proposal, however they can // only do it once and it lasts only for the cool-off period. type VetoOrigin = pallet_collective::EnsureMember; - type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod - type VotingPeriod = VotingPeriod; + type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type OperationalPreimageOrigin = pallet_collective::EnsureMember; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; type WeightInfo = (); + type MaxProposals = MaxProposals; } parameter_types! { @@ -1031,7 +1032,7 @@ impl pallet_indices::Config for Runtime { type WeightInfo = (); } -frame_support::parameter_types! { +parameter_types! { pub BoundDivision: U256 = U256::from(1024); } @@ -1039,7 +1040,7 @@ impl pallet_dynamic_fee::Config for Runtime { type MinGasPriceBoundDivisor = BoundDivision; } -frame_support::parameter_types! { +parameter_types! { pub IsActive: bool = true; pub DefaultBaseFeePerGas: U256 = U256::from(1_000_000_000); } @@ -1072,13 +1073,14 @@ const VESTED_AIRDROP_BEHAVIOUR: pallet_airdrop::AirdropBehaviour = non_defi_instant_percentage: 20, vesting_period: 7776000, }; + impl pallet_airdrop::Config for Runtime { type Event = Event; type Currency = Balances; - type BalanceTypeConversion = sp_runtime::traits::ConvertInto; type AirdropWeightInfo = pallet_airdrop::weights::AirDropWeightInfo; + type BalanceTypeConversion = ConvertInto; type MerkelProofValidator = pallet_airdrop::merkle::AirdropMerkleValidator; - type MaxProofSize = frame_support::traits::ConstU32<21>; + type MaxProofSize = ConstU32<21>; const AIRDROP_VARIABLES: pallet_airdrop::AirdropBehaviour = VESTED_AIRDROP_BEHAVIOUR; } diff --git a/runtime/frost/Cargo.toml b/runtime/frost/Cargo.toml index df8bf76f..bfec7fda 100644 --- a/runtime/frost/Cargo.toml +++ b/runtime/frost/Cargo.toml @@ -7,7 +7,7 @@ homepage = 'https://substrate.dev' license = 'Apache-2.0' name = 'frost-runtime' repository = 'https://github.com/web3labs/ice-substrate/' -version = '0.4.42' +version = '0.4.43' publish = false [package.metadata.docs.rs] diff --git a/runtime/frost/src/impls.rs b/runtime/frost/src/impls.rs index 6ebfb124..21790630 100644 --- a/runtime/frost/src/impls.rs +++ b/runtime/frost/src/impls.rs @@ -48,7 +48,7 @@ mod tests { #[test] fn currency_units() { println!( - "DOLLARS 10e18 == {} plank // CENTS == {} plank // MLLICENTS == {} plank", + "DOLLARS 10e18 == {} plank // CENTS == {} plank // MILLICENTS == {} plank", DOLLARS.separated_string(), CENTS.separated_string(), MILLICENTS.separated_string() @@ -321,8 +321,8 @@ mod tests { 4294967295, RuntimeBlockWeights::get().max_block / 2, RuntimeBlockWeights::get().max_block, - Weight::max_value() / 2, - Weight::max_value(), + Weight::MAX / 2, + Weight::MAX, ] .into_iter() .for_each(|i| { diff --git a/runtime/frost/src/lib.rs b/runtime/frost/src/lib.rs index 3ae78b5f..3053f9dd 100644 --- a/runtime/frost/src/lib.rs +++ b/runtime/frost/src/lib.rs @@ -106,7 +106,7 @@ pub type Balance = u128; pub type Index = u32; /// A hash of some data used by the chain. -pub type Hash = sp_core::H256; +pub type Hash = H256; /// Digest item type. // pub type DigestItem = generic::DigestItem; @@ -198,12 +198,10 @@ impl frame_system::Config for Runtime { /// The maximum length of a block (in bytes). type BlockLength = RuntimeBlockLength; - /// The identifier used to distinguish between accounts. - type AccountId = AccountId; + /// The ubiquitous origin type. + type Origin = Origin; /// The aggregated dispatch type that is available for extrinsics. type Call = Call; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. @@ -212,12 +210,14 @@ impl frame_system::Config for Runtime { type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = AccountIdLookup; /// The header type. type Header = generic::Header; /// The ubiquitous event type. type Event = Event; - /// The ubiquitous origin type. - type Origin = Origin; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). type BlockHashCount = BlockHashCount; /// The weight of database operations that the runtime can invoke. @@ -228,19 +228,19 @@ impl frame_system::Config for Runtime { /// /// This type is being generated by `construct_runtime!`. type PalletInfo = PalletInfo; + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; /// What to do if a new account is created. type OnNewAccount = (); /// What to do if an account is fully reaped from the system. type OnKilledAccount = (); - /// The data to be stored in an account. - type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. type SystemWeightInfo = (); /// This is used as an identifier of the chain. 42 is the generic substrate prefix. type SS58Prefix = SS58Prefix; /// The set code logic, just the default since we're not a parachain. type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; + type MaxConsumers = ConstU32<16>; } parameter_types! { @@ -249,16 +249,14 @@ parameter_types! { impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; - type DisabledValidators = (); type MaxAuthorities = MaxAuthorities; + type DisabledValidators = (); } impl pallet_grandpa::Config for Runtime { type Event = Event; type Call = Call; - type KeyOwnerProofSystem = (); - type KeyOwnerProof = >::Proof; @@ -267,6 +265,8 @@ impl pallet_grandpa::Config for Runtime { GrandpaId, )>>::IdentificationTuple; + type KeyOwnerProofSystem = (); + type HandleEquivocation = (); type WeightInfo = (); @@ -306,19 +306,19 @@ impl pallet_contracts::Config for Runtime { /// change because that would break already deployed contracts. The `Call` structure itself /// is not allowed to change the indices of existing pallets, too. type CallFilter = frame_support::traits::Nothing; - type DepositPerItem = DepositPerItem; - type DepositPerByte = DepositPerByte; type WeightPrice = pallet_transaction_payment::Pallet; type WeightInfo = pallet_contracts::weights::SubstrateWeight; type ChainExtension = (); + type Schedule = Schedule; + type CallStack = [pallet_contracts::Frame; 31]; type DeletionQueueDepth = DeletionQueueDepth; type DeletionWeightLimit = DeletionWeightLimit; - type Schedule = Schedule; + type DepositPerByte = DepositPerByte; type ContractAccessWeight = pallet_contracts::DefaultContractAccessWeight; + type DepositPerItem = DepositPerItem; + type AddressGenerator = pallet_contracts::DefaultAddressGenerator; type MaxCodeLen = ConstU32<{ 128 * 1024 }>; type RelaxedMaxCodeLen = ConstU32<{ 256 * 1024 }>; - type CallStack = [pallet_contracts::Frame; 31]; - type AddressGenerator = pallet_contracts::DefaultAddressGenerator; } parameter_types! { @@ -328,12 +328,12 @@ parameter_types! { impl pallet_timestamp::Config for Runtime { /// A timestamp: milliseconds since the unix epoch. type Moment = u64; - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); #[cfg(feature = "aura")] type OnTimestampSet = (Aura,); #[cfg(feature = "manual-seal")] type OnTimestampSet = (); + type MinimumPeriod = MinimumPeriod; + type WeightInfo = (); } parameter_types! { @@ -344,17 +344,17 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; - type MaxReserves = (); - type ReserveIdentifier = [u8; 8]; /// The type for recording an account's balance. type Balance = Balance; + type DustRemoval = (); /// The ubiquitous event type. type Event = Event; - type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); + type MaxLocks = MaxLocks; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; } parameter_types! { @@ -394,9 +394,9 @@ impl pallet_transaction_payment::Config for Runtime { type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = constants::fee::WeightToFee; + type LengthToFee = ConstantMultiplier; type FeeMultiplierUpdate = TargetedFeeAdjustment; - type LengthToFee = ConstantMultiplier; } impl pallet_sudo::Config for Runtime { @@ -447,11 +447,11 @@ impl pallet_evm::Config for Runtime { type AddressMapping = HashedAddressMapping; type Currency = Balances; type Event = Event; - type Runner = pallet_evm::runner::stack::Runner; type PrecompilesType = FrontierPrecompiles; type PrecompilesValue = PrecompilesValue; type ChainId = ChainId; type BlockGasLimit = BlockGasLimit; + type Runner = pallet_evm::runner::stack::Runner; type OnChargeTransaction = (); type FindAuthor = FindAuthorTruncated; } @@ -477,8 +477,9 @@ impl pallet_assets::Config for Runtime { type Balance = Balance; type AssetId = u32; type Currency = Balances; - type ForceOrigin = frame_system::EnsureRoot; + type ForceOrigin = EnsureRoot; type AssetDeposit = AssetDeposit; + type AssetAccountDeposit = AssetAccountDeposit; type MetadataDepositBase = MetadataDepositBase; type MetadataDepositPerByte = MetadataDepositPerByte; type ApprovalDeposit = ApprovalDeposit; @@ -486,7 +487,6 @@ impl pallet_assets::Config for Runtime { type Freezer = (); type Extra = (); type WeightInfo = pallet_assets::weights::SubstrateWeight; - type AssetAccountDeposit = AssetAccountDeposit; } parameter_types! { @@ -543,14 +543,14 @@ impl pallet_treasury::Config for Runtime { type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = (); type SpendPeriod = SpendPeriod; type Burn = Burn; type PalletId = TreasuryPalletId; type BurnDestination = (); - type SpendFunds = (); type WeightInfo = pallet_treasury::weights::SubstrateWeight; + type SpendFunds = (); type MaxApprovals = MaxApprovals; - type ProposalBondMaximum = (); } pub struct Beneficiary(); @@ -566,8 +566,8 @@ parameter_types! { impl pallet_simple_inflation::Config for Runtime { type Currency = Balances; - type Beneficiary = Beneficiary; type IssuingAmount = IssuingAmount; + type Beneficiary = Beneficiary; } impl pallet_fees_split::Config for Runtime {} @@ -581,16 +581,16 @@ const VESTED_AIRDROP_BEHAVIOUR: pallet_airdrop::AirdropBehaviour = impl pallet_airdrop::Config for Runtime { type Event = Event; type Currency = Balances; - type BalanceTypeConversion = sp_runtime::traits::ConvertInto; type AirdropWeightInfo = pallet_airdrop::weights::AirDropWeightInfo; + type BalanceTypeConversion = ConvertInto; type MerkelProofValidator = pallet_airdrop::merkle::AirdropMerkleValidator; - type MaxProofSize = frame_support::traits::ConstU32<21>; + type MaxProofSize = ConstU32<21>; const AIRDROP_VARIABLES: pallet_airdrop::AirdropBehaviour = VESTED_AIRDROP_BEHAVIOUR; } impl pallet_utility::Config for Runtime { - type Call = Call; type Event = Event; + type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -603,14 +603,14 @@ parameter_types! { } impl pallet_scheduler::Config for Runtime { - type Call = Call; type Event = Event; - type MaxScheduledPerBlock = MaxScheduledPerBlock; - type MaximumWeight = MaximumSchedulerWeight; type Origin = Origin; - type OriginPrivilegeCmp = EqualPrivilegeOnly; type PalletsOrigin = OriginCaller; + type Call = Call; + type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; + type OriginPrivilegeCmp = EqualPrivilegeOnly; + type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = (); type PreimageProvider = Preimage; type NoPreimagePostponement = NoPreimagePostponement; @@ -623,8 +623,8 @@ parameter_types! { } impl pallet_preimage::Config for Runtime { - type WeightInfo = pallet_preimage::weights::SubstrateWeight; type Event = Event; + type WeightInfo = pallet_preimage::weights::SubstrateWeight; type Currency = Balances; type ManagerOrigin = EnsureRoot; type MaxSize = PreimageMaxSize; @@ -736,18 +736,18 @@ impl InstanceFilter for ProxyType { } impl pallet_proxy::Config for Runtime { - type AnnouncementDepositBase = AnnouncementDepositBase; - type AnnouncementDepositFactor = AnnouncementDepositFactor; + type Event = Event; type Call = Call; - type CallHasher = BlakeTwo256; type Currency = Balances; - type Event = Event; - type MaxPending = MaxPending; - type MaxProxies = MaxProxies; + type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; type ProxyDepositFactor = ProxyDepositFactor; - type ProxyType = ProxyType; + type MaxProxies = MaxProxies; type WeightInfo = (); + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; } parameter_types! { @@ -759,11 +759,11 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { + type Event = Event; type Call = Call; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; - type Event = Event; type MaxSignatories = MaxSignatories; type WeightInfo = (); } @@ -813,10 +813,10 @@ impl pallet_bounties::Config for Runtime { type BountyDepositBase = BountyDepositBase; type BountyDepositPayoutDelay = BountyDepositPayoutDelay; type BountyUpdatePeriod = BountyUpdatePeriod; - type BountyValueMinimum = BountyValueMinimum; type CuratorDepositMultiplier = CuratorDepositMultiplier; - type CuratorDepositMin = CuratorDepositMin; type CuratorDepositMax = CuratorDepositMax; + type CuratorDepositMin = CuratorDepositMin; + type BountyValueMinimum = BountyValueMinimum; type DataDepositPerByte = DataDepositPerByte; type Event = Event; type MaximumReasonLength = MaximumReasonLength; @@ -825,9 +825,9 @@ impl pallet_bounties::Config for Runtime { } impl pallet_tips::Config for Runtime { - type DataDepositPerByte = DataDepositPerByte; type Event = Event; type MaximumReasonLength = MaximumReasonLength; + type DataDepositPerByte = DataDepositPerByte; type TipCountdown = TipCountdown; type TipFindersFee = TipFindersFee; type TipReportDepositBase = TipReportDepositBase; @@ -852,20 +852,20 @@ parameter_types! { const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); impl pallet_elections_phragmen::Config for Runtime { - type CandidacyBond = CandidacyBond; - type ChangeMembers = Council; + type Event = Event; + type PalletId = PhragmenElectionPalletId; type Currency = Balances; + type ChangeMembers = Council; + type InitializeMembers = Council; type CurrencyToVote = frame_support::traits::U128CurrencyToVote; + type CandidacyBond = CandidacyBond; + type VotingBondBase = VotingBondBase; + type VotingBondFactor = VotingBondFactor; + type LoserCandidate = Treasury; + type KickedMember = Treasury; type DesiredMembers = DesiredMembers; type DesiredRunnersUp = DesiredRunnersUp; - type Event = Event; - type InitializeMembers = Council; - type KickedMember = Treasury; - type LoserCandidate = Treasury; - type PalletId = PhragmenElectionPalletId; type TermDuration = TermDuration; - type VotingBondBase = VotingBondBase; - type VotingBondFactor = VotingBondFactor; type WeightInfo = (); } @@ -876,39 +876,39 @@ parameter_types! { } impl pallet_membership::Config for Runtime { - type AddOrigin = MoreThanHalfCouncil; type Event = Event; - type MaxMembers = CouncilMaxMembers; - type MembershipChanged = Council; - type MembershipInitialized = Council; - type PrimeOrigin = MoreThanHalfCouncil; + type AddOrigin = MoreThanHalfCouncil; type RemoveOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = Council; + type MembershipChanged = Council; + type MaxMembers = CouncilMaxMembers; type WeightInfo = (); } impl pallet_membership::Config for Runtime { - type AddOrigin = MoreThanHalfCouncil; type Event = Event; - type MaxMembers = TechnicalMaxMembers; - type MembershipChanged = TechnicalCommittee; - type MembershipInitialized = TechnicalCommittee; - type PrimeOrigin = MoreThanHalfCouncil; + type AddOrigin = MoreThanHalfCouncil; type RemoveOrigin = MoreThanHalfCouncil; - type ResetOrigin = MoreThanHalfCouncil; type SwapOrigin = MoreThanHalfCouncil; + type ResetOrigin = MoreThanHalfCouncil; + type PrimeOrigin = MoreThanHalfCouncil; + type MembershipInitialized = TechnicalCommittee; + type MembershipChanged = TechnicalCommittee; + type MaxMembers = TechnicalMaxMembers; type WeightInfo = (); } impl pallet_collective::Config for Runtime { - type DefaultVote = pallet_collective::PrimeDefaultVote; - type Event = Event; - type MaxMembers = TechnicalMaxMembers; - type MaxProposals = TechnicalMaxProposals; - type MotionDuration = TechnicalMotionDuration; type Origin = Origin; type Proposal = Call; + type Event = Event; + type MotionDuration = TechnicalMotionDuration; + type MaxProposals = TechnicalMaxProposals; + type MaxMembers = TechnicalMaxMembers; + type DefaultVote = pallet_collective::PrimeDefaultVote; type WeightInfo = (); } parameter_types! { @@ -924,54 +924,55 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type BlacklistOrigin = EnsureRoot; - // To cancel a proposal before it has been passed, the technical committee must be unanimous or - // Root must agree. - type CancelProposalOrigin = EnsureOneOf< - EnsureRoot, - pallet_collective::EnsureProportionAtLeast, - >; - // To cancel a proposal which has been passed, 2/3 of the council must agree to it. - type CancellationOrigin = - pallet_collective::EnsureProportionAtLeast; - type CooloffPeriod = CooloffPeriod; + type Proposal = Call; + type Event = Event; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; - type Event = Event; + type LaunchPeriod = LaunchPeriod; + // Same as EnactmentPeriod + type VotingPeriod = VotingPeriod; + type VoteLockingPeriod = EnactmentPeriod; + type MinimumDeposit = MinimumDeposit; + /// A straight majority of the council can decide what their next motion is. + type ExternalOrigin = + pallet_collective::EnsureProportionAtLeast; + /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. + type ExternalMajorityOrigin = + pallet_collective::EnsureProportionAtLeast; /// A unanimous council can have the next scheduled referendum be a straight default-carries /// (NTB) vote. type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast; - /// A super-majority can have the next scheduled referendum be a straight majority-carries vote. - type ExternalMajorityOrigin = - pallet_collective::EnsureProportionAtLeast; - /// A straight majority of the council can decide what their next motion is. - type ExternalOrigin = - pallet_collective::EnsureProportionAtLeast; /// Two thirds of the technical committee can have an ExternalMajority/ExternalDefault vote /// be tabled immediately and with a shorter voting/enactment period. type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast; - type FastTrackVotingPeriod = FastTrackVotingPeriod; - type InstantAllowed = InstantAllowed; type InstantOrigin = pallet_collective::EnsureProportionAtLeast; - type LaunchPeriod = LaunchPeriod; - type MaxProposals = MaxProposals; - type MaxVotes = MaxVotes; - type MinimumDeposit = MinimumDeposit; - type OperationalPreimageOrigin = pallet_collective::EnsureMember; - type PalletsOrigin = OriginCaller; - type PreimageByteDeposit = PreimageByteDeposit; - type Proposal = Call; - type Scheduler = Scheduler; - type Slash = Treasury; + type InstantAllowed = InstantAllowed; + type FastTrackVotingPeriod = FastTrackVotingPeriod; + // To cancel a proposal which has been passed, 2/3 of the council must agree to it. + type CancellationOrigin = + pallet_collective::EnsureProportionAtLeast; + type BlacklistOrigin = EnsureRoot; + // To cancel a proposal before it has been passed, the technical committee must be unanimous or + // Root must agree. + type CancelProposalOrigin = EnsureOneOf< + EnsureRoot, + pallet_collective::EnsureProportionAtLeast, + >; // Any single technical committee member may veto a coming council proposal, however they can // only do it once and it lasts only for the cool-off period. type VetoOrigin = pallet_collective::EnsureMember; - type VoteLockingPeriod = EnactmentPeriod; // Same as EnactmentPeriod - type VotingPeriod = VotingPeriod; + type CooloffPeriod = CooloffPeriod; + type PreimageByteDeposit = PreimageByteDeposit; + type OperationalPreimageOrigin = pallet_collective::EnsureMember; + type Slash = Treasury; + type Scheduler = Scheduler; + type PalletsOrigin = OriginCaller; + type MaxVotes = MaxVotes; type WeightInfo = (); + type MaxProposals = MaxProposals; } parameter_types! { @@ -986,7 +987,7 @@ impl pallet_indices::Config for Runtime { type WeightInfo = (); } -frame_support::parameter_types! { +parameter_types! { pub BoundDivision: U256 = U256::from(1024); } @@ -994,7 +995,7 @@ impl pallet_dynamic_fee::Config for Runtime { type MinGasPriceBoundDivisor = BoundDivision; } -frame_support::parameter_types! { +parameter_types! { pub IsActive: bool = true; pub DefaultBaseFeePerGas: U256 = U256::from(1_000_000_000); }