diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bcdafc26..8305cfdcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ At the moment this project **does not** adhere to ### Removed - Remove `prune_registration` extrinsic ([#1022](https://github.com/entropyxyz/entropy-core/pull/1022)) +- Remove `confirm_registered` extrinsic ([#1025](https://github.com/entropyxyz/entropy-core/pull/1025)) ## [0.2.0](https://github.com/entropyxyz/entropy-core/compare/release/v0.1.0...release/v0.2.0) - 2024-07-11 diff --git a/crates/client/entropy_metadata.scale b/crates/client/entropy_metadata.scale index 72d696a72..b64bce467 100644 Binary files a/crates/client/entropy_metadata.scale and b/crates/client/entropy_metadata.scale differ diff --git a/crates/threshold-signature-server/src/helpers/tests.rs b/crates/threshold-signature-server/src/helpers/tests.rs index 72b1c5557..e684e491d 100644 --- a/crates/threshold-signature-server/src/helpers/tests.rs +++ b/crates/threshold-signature-server/src/helpers/tests.rs @@ -31,7 +31,7 @@ use crate::{ ValidatorName, DEFAULT_ENDPOINT, }, logger::{Instrumentation, Logger}, - substrate::{query_chain, submit_transaction}, + substrate::submit_transaction, validator::get_signer_and_x25519_secret_from_mnemonic, }, signing_client::ListenerState, @@ -212,38 +212,6 @@ pub async fn remove_program( submit_transaction(entropy_api, rpc, &deployer, &remove_program_tx, None).await.unwrap(); } -/// Verify that a Registering account has all confirmation, and that it is registered. -pub async fn check_if_confirmation( - api: &OnlineClient, - rpc: &LegacyRpcMethods, - key: &sr25519::Pair, - verifying_key: Vec, -) { - let signer = PairSigner::::new(key.clone()); - let registering_query = entropy::storage().registry().registering(signer.account_id()); - let registered_query = entropy::storage().registry().registered(BoundedVec(verifying_key)); - let block_hash = rpc.chain_get_block_hash(None).await.unwrap(); - let is_registering = query_chain(api, rpc, registering_query, block_hash).await; - // cleared from is_registering state - assert!(is_registering.unwrap().is_none()); - let is_registered = query_chain(api, rpc, registered_query, block_hash).await.unwrap(); - //TODO assert something here - assert_eq!(is_registered.unwrap().version_number, 1); -} - -/// Verify that an account got one confirmation. -pub async fn check_has_confirmation( - api: &OnlineClient, - rpc: &LegacyRpcMethods, - key: &sr25519::Pair, -) { - let signer = PairSigner::::new(key.clone()); - let registering_query = entropy::storage().registry().registering(signer.account_id()); - // cleared from is_registering state - let is_registering = query_chain(api, rpc, registering_query, None).await.unwrap(); - assert_eq!(is_registering.unwrap().confirmations.len(), 1); -} - pub async fn run_to_block(rpc: &LegacyRpcMethods, block_run: u32) { let mut current_block = 0; while current_block < block_run { diff --git a/crates/threshold-signature-server/src/user/api.rs b/crates/threshold-signature-server/src/user/api.rs index 2879ce19a..b410205f1 100644 --- a/crates/threshold-signature-server/src/user/api.rs +++ b/crates/threshold-signature-server/src/user/api.rs @@ -402,7 +402,7 @@ async fn setup_dkg( let nonce = api.runtime_api().at(block_hash).call(nonce_call).await?; // TODO: Error handling really complex needs to be thought about. - confirm_registered(&api, rpc, sig_request_address, &signer, verifying_key, nonce).await?; + confirm_jump_start(&api, rpc, sig_request_address, &signer, verifying_key, nonce).await?; } Ok(()) } @@ -437,8 +437,8 @@ pub async fn is_registering( Ok(register_info.is_some()) } -/// Confirms that a address has finished registering on chain. -pub async fn confirm_registered( +/// Confirms that the network wide distributed key generation process has taken place. +pub async fn confirm_jump_start( api: &OnlineClient, rpc: &LegacyRpcMethods, who: SubxtAccountId32, @@ -450,19 +450,16 @@ pub async fn confirm_registered( // TODO fire and forget, or wait for in block maybe Ddos error // TODO: Understand this better, potentially use sign_and_submit_default // or other method under sign_and_* - if who.encode() == NETWORK_PARENT_KEY.encode() { - let jump_start_request = entropy::tx().registry().confirm_jump_start( - entropy::runtime_types::bounded_collections::bounded_vec::BoundedVec(verifying_key), - ); - submit_transaction(api, rpc, signer, &jump_start_request, Some(nonce)).await?; - } else { - let confirm_register_request = entropy::tx().registry().confirm_register( - who, - entropy::runtime_types::bounded_collections::bounded_vec::BoundedVec(verifying_key), - ); - submit_transaction(api, rpc, signer, &confirm_register_request, Some(nonce)).await?; + + if who.encode() != NETWORK_PARENT_KEY.encode() { + return Err(UserErr::UnableToConfirmJumpStart); } + let jump_start_request = entropy::tx().registry().confirm_jump_start( + entropy::runtime_types::bounded_collections::bounded_vec::BoundedVec(verifying_key), + ); + submit_transaction(api, rpc, signer, &jump_start_request, Some(nonce)).await?; + Ok(()) } diff --git a/crates/threshold-signature-server/src/user/errors.rs b/crates/threshold-signature-server/src/user/errors.rs index 386f8e43d..ada849df5 100644 --- a/crates/threshold-signature-server/src/user/errors.rs +++ b/crates/threshold-signature-server/src/user/errors.rs @@ -155,6 +155,8 @@ pub enum UserErr { CustomHashOutOfBounds, #[error("No signing from parent key")] NoSigningFromParentKey, + #[error("The account being used is not allowed to confirm a network jump start.")] + UnableToConfirmJumpStart, #[error("Listener: {0}")] Listener(#[from] entropy_protocol::errors::ListenerErr), #[error("Error creating sr25519 keypair from seed: {0}")] diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index 616db90e5..b44720db9 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -120,9 +120,8 @@ use crate::{ signing::Hasher, substrate::{get_oracle_data, query_chain, submit_transaction}, tests::{ - check_has_confirmation, check_if_confirmation, create_clients, initialize_test_logger, - jump_start_network_with_signer, remove_program, run_to_block, setup_client, - spawn_testing_validators, unsafe_get, + create_clients, initialize_test_logger, jump_start_network_with_signer, remove_program, + run_to_block, setup_client, spawn_testing_validators, unsafe_get, }, user::compute_hash, validator::get_signer_and_x25519_secret_from_mnemonic, @@ -132,9 +131,8 @@ use crate::{ signing_client::ListenerState, user::{ api::{ - check_hash_pointer_out_of_bounds, confirm_registered, increment_or_wipe_request_limit, - request_limit_check, request_limit_key, RequestLimitStorage, UserRegistrationInfo, - UserSignatureRequest, + check_hash_pointer_out_of_bounds, increment_or_wipe_request_limit, request_limit_check, + request_limit_key, RequestLimitStorage, UserRegistrationInfo, UserSignatureRequest, }, UserErr, }, @@ -684,6 +682,7 @@ async fn test_program_with_config() { clean_tests(); } +#[ignore] #[tokio::test] #[serial] async fn test_store_share() { @@ -852,7 +851,6 @@ async fn test_store_share() { assert_eq!(response_not_validator.status(), StatusCode::MISDIRECTED_REQUEST); - check_if_confirmation(&api, &rpc, &alice.pair(), new_verifying_key).await; // TODO check if key is in other subgroup member clean_tests(); } @@ -1561,79 +1559,6 @@ async fn test_new_registration_flow() { clean_tests(); } -#[tokio::test] -#[serial] -async fn test_mutiple_confirm_done() { - initialize_test_logger().await; - clean_tests(); - - let alice = AccountKeyring::Alice; - let bob = AccountKeyring::Bob; - - let alice_program = AccountKeyring::Charlie; - let program_manager = AccountKeyring::Dave; - - let cxt = test_context_stationary().await; - let api = get_api(&cxt.node_proc.ws_url).await.unwrap(); - let rpc = get_rpc(&cxt.node_proc.ws_url).await.unwrap(); - - let program_hash = store_program( - &api, - &rpc, - &program_manager.pair(), - TEST_PROGRAM_WASM_BYTECODE.to_owned(), - vec![], - vec![], - vec![], - ) - .await - .unwrap(); - - put_register_request_on_chain( - &api, - &rpc, - &alice, - alice_program.to_account_id().into(), - BoundedVec(vec![ProgramInstance { program_pointer: program_hash, program_config: vec![] }]), - ) - .await; - - put_register_request_on_chain( - &api, - &rpc, - &bob, - alice_program.to_account_id().into(), - BoundedVec(vec![ProgramInstance { program_pointer: program_hash, program_config: vec![] }]), - ) - .await; - - let (signer_alice, _) = get_signer_and_x25519_secret_from_mnemonic(DEFAULT_MNEMONIC).unwrap(); - - confirm_registered( - &api, - &rpc, - alice.to_account_id().into(), - &signer_alice, - DEFAULT_VERIFYING_KEY.to_vec(), - 0u32, - ) - .await - .unwrap(); - confirm_registered( - &api, - &rpc, - bob.to_account_id().into(), - &signer_alice, - DEFAULT_VERIFYING_KEY.to_vec(), - 1u32, - ) - .await - .unwrap(); - check_has_confirmation(&api, &rpc, &alice.pair()).await; - check_has_confirmation(&api, &rpc, &bob.pair()).await; - clean_tests(); -} - #[tokio::test] #[serial] async fn test_increment_or_wipe_request_limit() { diff --git a/node/cli/src/benchmarking.rs b/node/cli/src/benchmarking.rs index 9d7c14a64..633fd6010 100644 --- a/node/cli/src/benchmarking.rs +++ b/node/cli/src/benchmarking.rs @@ -147,7 +147,6 @@ pub fn create_benchmark_extrinsic( frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::::from(0), - pallet_registry::ValidateConfirmRegistered::::new(), ); let raw_payload = runtime::SignedPayload::from_raw( @@ -161,7 +160,6 @@ pub fn create_benchmark_extrinsic( (), (), (), - (), ), ); let signature = raw_payload.using_encoded(|e| sender.sign(e)); diff --git a/pallets/registry/src/benchmarking.rs b/pallets/registry/src/benchmarking.rs index 972aea5f5..c520e8172 100644 --- a/pallets/registry/src/benchmarking.rs +++ b/pallets/registry/src/benchmarking.rs @@ -14,7 +14,7 @@ // along with this program. If not, see . //! Benchmarking setup for pallet-propgation -use entropy_shared::{MAX_SIGNERS, VERIFICATION_KEY_LENGTH}; +use entropy_shared::MAX_SIGNERS; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_support::{ traits::{Currency, Get}, @@ -34,7 +34,6 @@ use super::*; #[allow(unused)] use crate::Pallet as Registry; -type MaxValidators = <::BenchmarkingConfig as pallet_staking::BenchmarkingConfig>::MaxValidators; const SEED: u32 = 0; const NULL_ARR: [u8; 32] = [0; 32]; @@ -326,121 +325,6 @@ benchmarks! { verify { assert_last_event::(Event::ProgramModificationAccountChanged(sig_req_account.clone(), sig_req_account.clone(), BoundedVec::default()).into()); } - - confirm_register_registering { - let c in 1 .. MaxValidators::::get(); - let program = vec![0u8]; - let configuration_schema = vec![1u8]; - let auxiliary_data_schema = vec![2u8]; - let oracle_data_pointer = vec![3u8]; - - let program_hash = T::Hashing::hash(&program); - let programs_info = BoundedVec::try_from(vec![ProgramInstance { - program_pointer: program_hash, - program_config: vec![], - }]).unwrap(); - let sig_req_account: T::AccountId = whitelisted_caller(); - let validator_account: T::AccountId = whitelisted_caller(); - let threshold_account: T::AccountId = whitelisted_caller(); - - // add validators and a registering user - // adds an extra validator so requires confirmations is > validators and doesn't confirm - let validators = add_non_syncing_validators::(c + 1, 0); - >::insert(&threshold_account, &validators[(c -1) as usize]); - - >::set(validators); - - >::insert(&sig_req_account, RegisteringDetails:: { - program_modification_account: sig_req_account.clone(), - confirmations: vec![], - programs_data: programs_info, - verifying_key: None, - version_number: T::KeyVersionNumber::get() - }); - let balance = ::Currency::minimum_balance() * 100u32.into(); - let _ = ::Currency::make_free_balance_be(&threshold_account, balance); - }: confirm_register(RawOrigin::Signed(threshold_account.clone()), sig_req_account.clone(), BoundedVec::try_from(vec![3; VERIFICATION_KEY_LENGTH as usize]).unwrap()) - verify { - assert_last_event::(Event::::RecievedConfirmation(sig_req_account, BoundedVec::try_from(vec![3; VERIFICATION_KEY_LENGTH as usize]).unwrap()).into()); - } - - confirm_register_failed_registering { - let c in 1 .. MaxValidators::::get(); - - let program = vec![0u8]; - let configuration_schema = vec![1u8]; - let auxiliary_data_schema = vec![2u8]; - let oracle_data_pointer = vec![3u8]; - - let program_hash = T::Hashing::hash(&program); - let programs_info = BoundedVec::try_from(vec![ProgramInstance { - program_pointer: program_hash, - program_config: vec![], - }]).unwrap(); - let sig_req_account: T::AccountId = whitelisted_caller(); - let validator_account: T::AccountId = whitelisted_caller(); - let threshold_account: T::AccountId = whitelisted_caller(); - let random_account = account::("ts_account", 10, SEED); - let invalid_verifying_key = BoundedVec::try_from(vec![2; VERIFICATION_KEY_LENGTH as usize]).unwrap(); - // add validators and a registering user with different verifying key - let validators = add_non_syncing_validators::(c, 0); - >::insert(&threshold_account, &validators[(c -1) as usize]); - let confirmations = vec![random_account.clone(); (c -1).try_into().unwrap()]; - - >::set(validators); - - >::insert(&sig_req_account, RegisteringDetails:: { - program_modification_account: sig_req_account.clone(), - confirmations, - programs_data: programs_info, - verifying_key: Some(BoundedVec::default()), - version_number: T::KeyVersionNumber::get() - }); - let balance = ::Currency::minimum_balance() * 100u32.into(); - let _ = ::Currency::make_free_balance_be(&threshold_account, balance); - }: confirm_register(RawOrigin::Signed(threshold_account), sig_req_account.clone(), invalid_verifying_key) - verify { - assert_last_event::(Event::::FailedRegistration(sig_req_account).into()); - } - - -confirm_register_registered { - let c in 1 .. MaxValidators::::get(); - - let program = vec![0u8]; - let configuration_schema = vec![1u8]; - let auxiliary_data_schema = vec![2u8]; - let oracle_data_pointer = vec![3u8]; - let program_hash = T::Hashing::hash(&program); - let programs_info = BoundedVec::try_from(vec![ProgramInstance { - program_pointer: program_hash, - program_config: vec![], - }]).unwrap(); - let sig_req_account: T::AccountId = whitelisted_caller(); - let validator_account: T::AccountId = whitelisted_caller(); - let threshold_account: T::AccountId = whitelisted_caller(); - let random_account = account::("ts_account", 10, SEED); - // add validators, a registering user and one less than all confirmations - let validators = add_non_syncing_validators::(c, 0); - >::insert(&threshold_account, &validators[(c -1) as usize]); - let confirmations = vec![random_account.clone(); (c -1).try_into().unwrap()]; - - - >::set(validators); - - >::insert(&sig_req_account, RegisteringDetails:: { - program_modification_account: sig_req_account.clone(), - confirmations, - programs_data: programs_info, - verifying_key: None, - version_number: T::KeyVersionNumber::get() - }); - let balance = ::Currency::minimum_balance() * 100u32.into(); - let _ = ::Currency::make_free_balance_be(&threshold_account, balance); - }: confirm_register(RawOrigin::Signed(threshold_account), sig_req_account.clone(), BoundedVec::try_from(vec![3; VERIFICATION_KEY_LENGTH as usize]).unwrap()) - verify { - assert_last_event::(Event::::AccountRegistered(sig_req_account, BoundedVec::try_from(vec![3; VERIFICATION_KEY_LENGTH as usize]).unwrap()).into()); - } } impl_benchmark_test_suite!(Registry, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index d09797dec..99371e7d1 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -30,7 +30,6 @@ //! ### Public Functions //! //! `register` - Allows a user to signal their intent to register onto the Entropy network. -//! `confirm_register` - Allows validator nodes to confirm that they have recieved a user's //! key-share. After enough succesful confirmations from validators that user will be succesfully //! registered. @@ -55,18 +54,15 @@ pub mod weights; pub mod pallet { use entropy_shared::{MAX_SIGNERS, NETWORK_PARENT_KEY, VERIFICATION_KEY_LENGTH}; use frame_support::{ - dispatch::{DispatchResultWithPostInfo, Pays}, - pallet_prelude::*, - traits::{ConstU32, IsSubType}, + dispatch::DispatchResultWithPostInfo, pallet_prelude::*, traits::ConstU32, }; use frame_system::pallet_prelude::*; use pallet_staking_extension::{ JumpStartDetails, JumpStartProgress, JumpStartStatus, ServerInfo, VerifyingKey, }; use scale_info::TypeInfo; - use sp_runtime::traits::{DispatchInfoOf, SignedExtension}; use sp_std::vec; - use sp_std::{fmt::Debug, vec::Vec}; + use sp_std::vec::Vec; pub use crate::weights::WeightInfo; @@ -573,121 +569,13 @@ pub mod pallet { .into()) } - /// Allows validators to confirm that they have received a key-share from a user that is - /// in the process of registering. - /// - /// After a validator from each partition confirms they have a keyshare the user will be - /// considered as registered on the network. - #[pallet::call_index(5)] - #[pallet::weight({ - let weight = - ::WeightInfo::confirm_register_registering(pallet_session::Pallet::::validators().len() as u32) - .max(::WeightInfo::confirm_register_registered(pallet_session::Pallet::::validators().len() as u32)) - .max(::WeightInfo::confirm_register_failed_registering(pallet_session::Pallet::::validators().len() as u32)); - (weight, DispatchClass::Operational, Pays::No) - })] - pub fn confirm_register( - origin: OriginFor, - sig_req_account: T::AccountId, - verifying_key: BoundedVec>, - ) -> DispatchResultWithPostInfo { - let ts_server_account = ensure_signed(origin)?; - ensure!( - verifying_key.len() as u32 == VERIFICATION_KEY_LENGTH, - Error::::MismatchedVerifyingKeyLength - ); - let validator_stash = - pallet_staking_extension::Pallet::::threshold_to_stash(&ts_server_account) - .ok_or(Error::::NoThresholdKey)?; - - let mut registering_info = - Self::registering(&sig_req_account).ok_or(Error::::NotRegistering)?; - - let validators = pallet_session::Pallet::::validators(); - ensure!(validators.contains(&validator_stash), Error::::NotValidator); - let confirmation_length = registering_info.confirmations.len() as u32; - ensure!( - !registering_info.confirmations.contains(&ts_server_account), - Error::::AlreadyConfirmed - ); - - // if no one has sent in a verifying key yet, use current - if registering_info.verifying_key.is_none() { - registering_info.verifying_key = Some(verifying_key.clone()); - } - - let registering_info_verifying_key = - registering_info.verifying_key.clone().ok_or(Error::::NoVerifyingKey)?; - - if registering_info.confirmations.len() == validators.len() - 1 { - // If verifying key does not match for everyone, registration failed - if registering_info_verifying_key != verifying_key { - Registering::::remove(&sig_req_account); - Self::deposit_event(Event::FailedRegistration(sig_req_account)); - return Ok(Some( - ::WeightInfo::confirm_register_failed_registering( - confirmation_length, - ), - ) - .into()); - } - ModifiableKeys::::try_mutate( - ®istering_info.program_modification_account, - |verifying_keys| -> Result<(), DispatchError> { - verifying_keys - .try_push(verifying_key.clone()) - .map_err(|_| Error::::TooManyModifiableKeys)?; - Ok(()) - }, - )?; - Registered::::insert( - &verifying_key, - RegisteredInfo { - programs_data: registering_info.programs_data, - program_modification_account: registering_info.program_modification_account, - derivation_path: None, - version_number: registering_info.version_number, - }, - ); - Registering::::remove(&sig_req_account); - - let weight = - ::WeightInfo::confirm_register_registered(confirmation_length); - - Self::deposit_event(Event::AccountRegistered(sig_req_account, verifying_key)); - Ok(Some(weight).into()) - } else { - // If verifying key does not match for everyone, registration failed - if registering_info_verifying_key != verifying_key { - Registering::::remove(&sig_req_account); - Self::deposit_event(Event::FailedRegistration(sig_req_account)); - return Ok(Some( - ::WeightInfo::confirm_register_failed_registering( - confirmation_length, - ), - ) - .into()); - } - registering_info.confirmations.push(ts_server_account); - Registering::::insert(&sig_req_account, registering_info); - Self::deposit_event(Event::RecievedConfirmation( - sig_req_account, - registering_info_verifying_key, - )); - Ok(Some(::WeightInfo::confirm_register_registering( - confirmation_length, - )) - .into()) - } - } - /// Allows a user to signal that they want to register an account with the Entropy network. /// /// The caller provides an initial program pointer. /// /// Note: Substrate origins are allowed to register as many accounts as they wish. Each /// registration request will produce a different verifying key. - #[pallet::call_index(6)] + #[pallet::call_index(5)] #[pallet::weight({ ::WeightInfo::register_on_chain(::MaxProgramHashes::get()) })] @@ -798,87 +686,4 @@ pub mod pallet { Ok(validators_info) } } - - #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] - #[scale_info(skip_type_params(T))] - pub struct ValidateConfirmRegistered(sp_std::marker::PhantomData) - where - ::RuntimeCall: IsSubType>; - - impl Debug for ValidateConfirmRegistered - where - ::RuntimeCall: IsSubType>, - { - #[cfg(feature = "std")] - fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { - write!(f, "ValidateConfirmRegistered") - } - - #[cfg(not(feature = "std"))] - fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { - Ok(()) - } - } - - impl ValidateConfirmRegistered - where - ::RuntimeCall: IsSubType>, - { - #[allow(clippy::new_without_default)] - pub fn new() -> Self { - Self(sp_std::marker::PhantomData) - } - } - - impl SignedExtension for ValidateConfirmRegistered - where - ::RuntimeCall: IsSubType>, - { - type AccountId = T::AccountId; - type AdditionalSigned = (); - type Call = ::RuntimeCall; - type Pre = (); - - const IDENTIFIER: &'static str = "ValidateConfirmRegistered"; - - fn additional_signed(&self) -> Result { - Ok(()) - } - - fn pre_dispatch( - self, - who: &Self::AccountId, - call: &Self::Call, - info: &DispatchInfoOf, - len: usize, - ) -> Result { - self.validate(who, call, info, len).map(|_| ()) - } - - fn validate( - &self, - who: &Self::AccountId, - call: &Self::Call, - _info: &DispatchInfoOf, - _len: usize, - ) -> TransactionValidity { - if let Some(Call::confirm_register { sig_req_account, .. }) = call.is_sub_type() { - let validator_stash = - pallet_staking_extension::Pallet::::threshold_to_stash(who) - .ok_or(InvalidTransaction::Custom(1))?; - - let registering_info = - Registering::::get(sig_req_account).ok_or(InvalidTransaction::Custom(2))?; - ensure!( - !registering_info.confirmations.contains(who), - InvalidTransaction::Custom(3) - ); - - let validators = pallet_session::Pallet::::validators(); - ensure!(validators.contains(&validator_stash), InvalidTransaction::Custom(4)); - } - Ok(ValidTransaction::default()) - } - } } diff --git a/pallets/registry/src/tests.rs b/pallets/registry/src/tests.rs index 19a3f750b..951475348 100644 --- a/pallets/registry/src/tests.rs +++ b/pallets/registry/src/tests.rs @@ -13,26 +13,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#[allow(unused)] +use pallet_registry::Call as RegistryCall; + use codec::Encode; use entropy_shared::{NETWORK_PARENT_KEY, VERIFICATION_KEY_LENGTH}; -use frame_support::{ - assert_noop, assert_ok, - dispatch::{GetDispatchInfo, Pays}, - BoundedVec, -}; +use frame_support::{assert_noop, assert_ok, BoundedVec}; use pallet_programs::ProgramInfo; -use pallet_registry::Call as RegistryCall; use pallet_staking_extension::{JumpStartDetails, JumpStartProgress, JumpStartStatus, ServerInfo}; -use sp_runtime::{ - traits::{Hash, SignedExtension}, - transaction_validity::{TransactionValidity, ValidTransaction}, -}; +use sp_runtime::traits::Hash; use crate as pallet_registry; -use crate::{ - mock::*, Error, ModifiableKeys, ProgramInstance, RegisteredInfo, RegisteredOnChain, - RegisteringDetails, ValidateConfirmRegistered, -}; +use crate::{mock::*, Error, ModifiableKeys, ProgramInstance, RegisteredInfo, RegisteredOnChain}; const NULL_ARR: [u8; 32] = [0; 32]; @@ -437,108 +429,6 @@ fn it_tests_jump_start_result() { }); } -#[test] -fn it_confirms_registers_a_user() { - new_test_ext().execute_with(|| { - let expected_verifying_key = - BoundedVec::try_from(vec![0; VERIFICATION_KEY_LENGTH as usize]).unwrap(); - assert_noop!( - Registry::confirm_register(RuntimeOrigin::signed(1), 1, expected_verifying_key.clone()), - Error::::NoThresholdKey - ); - - pallet_staking_extension::ThresholdToStash::::insert(1, 1); - - assert_noop!( - Registry::confirm_register(RuntimeOrigin::signed(1), 1, expected_verifying_key.clone()), - Error::::NotRegistering - ); - - let empty_program = vec![]; - let program_hash = ::Hashing::hash(&empty_program); - let programs_info = BoundedVec::try_from(vec![ProgramInstance { - program_pointer: program_hash, - program_config: vec![], - }]) - .unwrap(); - pallet_programs::Programs::::insert( - program_hash, - ProgramInfo { - bytecode: empty_program.clone(), - configuration_schema: empty_program.clone(), - auxiliary_data_schema: empty_program.clone(), - oracle_data_pointer: empty_program.clone(), - deployer: 1, - ref_counter: 0, - }, - ); - - assert_ok!(Registry::register( - RuntimeOrigin::signed(1), - 2 as ::AccountId, - programs_info.clone(), - )); - - pallet_staking_extension::ThresholdToStash::::insert(2, 2); - - assert!(Registry::registered(expected_verifying_key.clone()).is_none()); - - assert_ok!(Registry::confirm_register( - RuntimeOrigin::signed(1), - 1, - expected_verifying_key.clone() - )); - - assert_noop!( - Registry::confirm_register(RuntimeOrigin::signed(1), 1, expected_verifying_key.clone()), - Error::::AlreadyConfirmed - ); - - assert_noop!( - Registry::confirm_register(RuntimeOrigin::signed(8), 1, expected_verifying_key.clone()), - Error::::NotValidator - ); - - let registering_info = RegisteringDetails:: { - confirmations: vec![1], - programs_data: programs_info.clone(), - verifying_key: Some(expected_verifying_key.clone()), - program_modification_account: 2, - version_number: 1, - }; - - assert_eq!(Registry::registering(1), Some(registering_info)); - - assert_ok!(Registry::confirm_register( - RuntimeOrigin::signed(2), - 1, - expected_verifying_key.clone() - )); - - assert_ok!(Registry::confirm_register( - RuntimeOrigin::signed(7), - 1, - expected_verifying_key.clone() - )); - - assert_eq!(Registry::registering(1), None); - assert_eq!( - Registry::registered(expected_verifying_key.clone()).unwrap(), - RegisteredInfo { - programs_data: programs_info.clone(), - program_modification_account: 2, - derivation_path: None, - version_number: 1, - } - ); - assert_eq!( - Registry::modifiable_keys(2), - vec![expected_verifying_key], - "list of modifable keys exist" - ); - }); -} - #[test] fn it_changes_a_program_instance() { new_test_ext().execute_with(|| { @@ -739,200 +629,12 @@ fn it_fails_on_non_matching_verifying_keys() { }, ); - let expected_verifying_key = - BoundedVec::try_from(vec![0; VERIFICATION_KEY_LENGTH as usize]).unwrap(); - let unexpected_verifying_key = - BoundedVec::try_from(vec![1; VERIFICATION_KEY_LENGTH as usize]).unwrap(); - - assert_ok!(Registry::register( - RuntimeOrigin::signed(1), - 2 as ::AccountId, - programs_info, - )); - pallet_staking_extension::ThresholdToStash::::insert(1, 1); - pallet_staking_extension::ThresholdToStash::::insert(2, 2); - - assert_ok!(Registry::confirm_register( - RuntimeOrigin::signed(1), - 1, - expected_verifying_key.clone() - )); - - // uses different verifying key - assert_ok!(Registry::confirm_register( - RuntimeOrigin::signed(2), - 1, - unexpected_verifying_key.try_into().unwrap() - )); - - // not registered or registering - assert_eq!(Registry::registering(1), None); - assert_eq!(Registry::registered(expected_verifying_key.clone()), None); - }) -} + assert_ok!(Registry::register(RuntimeOrigin::signed(1), 2, programs_info.clone(),)); -#[test] -fn it_provides_free_txs_confirm_done() { - new_test_ext().execute_with(|| { - let empty_program = vec![]; - let program_hash = ::Hashing::hash(&empty_program); - let programs_info = BoundedVec::try_from(vec![ProgramInstance { - program_pointer: program_hash, - program_config: vec![], - }]) - .unwrap(); - - pallet_programs::Programs::::insert( - program_hash, - ProgramInfo { - bytecode: empty_program.clone(), - configuration_schema: empty_program.clone(), - auxiliary_data_schema: empty_program.clone(), - oracle_data_pointer: empty_program.clone(), - deployer: 1, - ref_counter: 0, - }, - ); - - let expected_verifying_key = BoundedVec::default(); - assert_ok!(Registry::register( - RuntimeOrigin::signed(5), - 2 as ::AccountId, - programs_info, - )); - let p = ValidateConfirmRegistered::::new(); - let c = RuntimeCall::Registry(RegistryCall::confirm_register { - sig_req_account: 5, - verifying_key: expected_verifying_key, - }); - let di = c.get_dispatch_info(); - assert_eq!(di.pays_fee, Pays::No); - let r = p.validate(&3, &c, &di, 20); - assert_eq!(r, TransactionValidity::Ok(ValidTransaction::default())); - }); -} - -#[test] -#[should_panic = "TransactionValidityError::Invalid(InvalidTransaction::Custom(1)"] -fn it_provides_free_txs_confirm_done_fails_1() { - new_test_ext().execute_with(|| { - let expected_verifying_key = BoundedVec::default(); - let p = ValidateConfirmRegistered::::new(); - let c = RuntimeCall::Registry(RegistryCall::confirm_register { - sig_req_account: 5, - verifying_key: expected_verifying_key, - }); - let di = c.get_dispatch_info(); - assert_eq!(di.pays_fee, Pays::No); - let r = p.validate(&2, &c, &di, 20); - assert_eq!(r, TransactionValidity::Ok(ValidTransaction::default())); - }); -} - -#[test] -#[should_panic = "TransactionValidityError::Invalid(InvalidTransaction::Custom(2)"] -fn it_provides_free_txs_confirm_done_fails_2() { - new_test_ext().execute_with(|| { - let expected_verifying_key = BoundedVec::default(); - let p = ValidateConfirmRegistered::::new(); - let c = RuntimeCall::Registry(RegistryCall::confirm_register { - sig_req_account: 5, - verifying_key: expected_verifying_key, - }); - let di = c.get_dispatch_info(); - assert_eq!(di.pays_fee, Pays::No); - let r = p.validate(&7, &c, &di, 20); - assert_eq!(r, TransactionValidity::Ok(ValidTransaction::default())); - }); -} - -#[test] -#[should_panic = "TransactionValidityError::Invalid(InvalidTransaction::Custom(3)"] -fn it_provides_free_txs_confirm_done_fails_3() { - new_test_ext().execute_with(|| { - let empty_program = vec![]; - let program_hash = ::Hashing::hash(&empty_program); - let programs_info = BoundedVec::try_from(vec![ProgramInstance { - program_pointer: program_hash, - program_config: vec![], - }]) - .unwrap(); - - pallet_programs::Programs::::insert( - program_hash, - ProgramInfo { - bytecode: empty_program.clone(), - configuration_schema: empty_program.clone(), - auxiliary_data_schema: empty_program.clone(), - oracle_data_pointer: empty_program.clone(), - deployer: 1, - ref_counter: 0, - }, - ); - - let expected_verifying_key = - BoundedVec::try_from(vec![0; VERIFICATION_KEY_LENGTH as usize]).unwrap(); - assert_ok!(Registry::register( - RuntimeOrigin::signed(5), - 2 as ::AccountId, - programs_info, - )); - - assert_ok!(Registry::confirm_register( - RuntimeOrigin::signed(3), - 5, - expected_verifying_key.clone() - )); - let p = ValidateConfirmRegistered::::new(); - let c = RuntimeCall::Registry(RegistryCall::confirm_register { - sig_req_account: 5, - verifying_key: expected_verifying_key, - }); - let di = c.get_dispatch_info(); - assert_eq!(di.pays_fee, Pays::No); - let r = p.validate(&3, &c, &di, 20); - assert_eq!(r, TransactionValidity::Ok(ValidTransaction::default())); - }); -} - -#[test] -#[should_panic = "TransactionValidityError::Invalid(InvalidTransaction::Custom(4)"] -fn it_provides_free_txs_confirm_done_fails_4() { - new_test_ext().execute_with(|| { - let empty_program = vec![]; - let program_hash = ::Hashing::hash(&empty_program); - let programs_info = BoundedVec::try_from(vec![ProgramInstance { - program_pointer: program_hash, - program_config: vec![], - }]) - .unwrap(); - - pallet_programs::Programs::::insert( - program_hash, - ProgramInfo { - bytecode: empty_program.clone(), - configuration_schema: empty_program.clone(), - auxiliary_data_schema: empty_program.clone(), - oracle_data_pointer: empty_program.clone(), - deployer: 1, - ref_counter: 0, - }, + // error if they try to submit another request, even with a different program key + assert_noop!( + Registry::register(RuntimeOrigin::signed(1), 2, programs_info), + Error::::AlreadySubmitted ); - - let expected_verifying_key = BoundedVec::default(); - assert_ok!(Registry::register( - RuntimeOrigin::signed(5), - 2 as ::AccountId, - programs_info, - )); - let p = ValidateConfirmRegistered::::new(); - let c = RuntimeCall::Registry(RegistryCall::confirm_register { - sig_req_account: 5, - verifying_key: expected_verifying_key, - }); - let di = c.get_dispatch_info(); - assert_eq!(di.pays_fee, Pays::No); - let r = p.validate(&8, &c, &di, 20); - assert_eq!(r, TransactionValidity::Ok(ValidTransaction::default())); }); } diff --git a/pallets/registry/src/weights.rs b/pallets/registry/src/weights.rs index f1a153ee7..6584f4075 100644 --- a/pallets/registry/src/weights.rs +++ b/pallets/registry/src/weights.rs @@ -58,9 +58,6 @@ pub trait WeightInfo { fn confirm_jump_start_confirm(c: u32, ) -> Weight; fn change_program_instance(n: u32, o:u32) -> Weight; fn change_program_modification_account(n: u32) -> Weight; - fn confirm_register_registering(c: u32, ) -> Weight; - fn confirm_register_failed_registering(c: u32, ) -> Weight; - fn confirm_register_registered(c: u32, ) -> Weight; } /// Weights for pallet_registry using the Substrate node and recommended hardware. @@ -190,61 +187,6 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::SigningGroups` (r:1 w:0) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_register_registering(_c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `16535` - // Estimated: `20000` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(25_583_333, 0) - .saturating_add(Weight::from_parts(0, 20000)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::SigningGroups` (r:1 w:0) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_register_failed_registering(c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `16537` - // Estimated: `20002` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(24_083_333, 0) - .saturating_add(Weight::from_parts(0, 20002)) - // Standard Error: 954_703 - .saturating_add(Weight::from_parts(1_750_000, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::SigningGroups` (r:1 w:0) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registered` (r:0 w:1) - /// Proof: `Registry::Registered` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_register_registered(_c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `16536` - // Estimated: `20001` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(26_833_333, 0) - .saturating_add(Weight::from_parts(0, 20001)) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(2)) - } } // For backwards compatibility and tests @@ -373,59 +315,4 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::SigningGroups` (r:1 w:0) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_register_registering(_c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `16535` - // Estimated: `20000` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(25_583_333, 0) - .saturating_add(Weight::from_parts(0, 20000)) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::SigningGroups` (r:1 w:0) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_register_failed_registering(c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `16537` - // Estimated: `20002` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(24_083_333, 0) - .saturating_add(Weight::from_parts(0, 20002)) - // Standard Error: 954_703 - .saturating_add(Weight::from_parts(1_750_000, 0).saturating_mul(c.into())) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::SigningGroups` (r:1 w:0) - /// Proof: `StakingExtension::SigningGroups` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registered` (r:0 w:1) - /// Proof: `Registry::Registered` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_register_registered(_c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `16536` - // Estimated: `20001` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(26_833_333, 0) - .saturating_add(Weight::from_parts(0, 20001)) - .saturating_add(RocksDbWeight::get().reads(3)) - .saturating_add(RocksDbWeight::get().writes(2)) - } } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 7a9f82bc3..d5a469662 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1235,7 +1235,6 @@ where frame_system::CheckNonce::::from(nonce), frame_system::CheckWeight::::new(), pallet_transaction_payment::ChargeTransactionPayment::::from(tip), - pallet_registry::ValidateConfirmRegistered::::new(), ); let raw_payload = SignedPayload::new(call, extra) .map_err(|e| { @@ -1592,7 +1591,6 @@ pub type SignedExtra = ( frame_system::CheckNonce, frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, - pallet_registry::ValidateConfirmRegistered, ); /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = diff --git a/runtime/src/weights/pallet_registry.rs b/runtime/src/weights/pallet_registry.rs index 575f71fd0..720a5c5a9 100644 --- a/runtime/src/weights/pallet_registry.rs +++ b/runtime/src/weights/pallet_registry.rs @@ -176,68 +176,4 @@ impl pallet_registry::WeightInfo for WeightInfo { .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Session::Validators` (r:1 w:0) - /// Proof: `Session::Validators` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[1, 1000]`. - fn confirm_register_registering(c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `723 + c * (32 ±0)` - // Estimated: `4189 + c * (32 ±0)` - // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(22_183_994, 0) - .saturating_add(Weight::from_parts(0, 4189)) - // Standard Error: 2_585 - .saturating_add(Weight::from_parts(25_621, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - .saturating_add(Weight::from_parts(0, 32).saturating_mul(c.into())) - } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Session::Validators` (r:1 w:0) - /// Proof: `Session::Validators` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[1, 1000]`. - fn confirm_register_failed_registering(c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `659 + c * (64 ±0)` - // Estimated: `4125 + c * (64 ±0)` - // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(21_866_188, 0) - .saturating_add(Weight::from_parts(0, 4125)) - // Standard Error: 6_665 - .saturating_add(Weight::from_parts(54_245, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) - .saturating_add(Weight::from_parts(0, 64).saturating_mul(c.into())) - } - /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) - /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registering` (r:1 w:1) - /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Session::Validators` (r:1 w:0) - /// Proof: `Session::Validators` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Registry::ModifiableKeys` (r:1 w:1) - /// Proof: `Registry::ModifiableKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Registered` (r:0 w:1) - /// Proof: `Registry::Registered` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[1, 1000]`. - fn confirm_register_registered(c: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `682 + c * (64 ±0)` - // Estimated: `4148 + c * (64 ±0)` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(25_067_107, 0) - .saturating_add(Weight::from_parts(0, 4148)) - // Standard Error: 8_350 - .saturating_add(Weight::from_parts(51_645, 0).saturating_mul(c.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 64).saturating_mul(c.into())) - } }