diff --git a/CHANGELOG.md b/CHANGELOG.md index eba38865d..c8b4f72c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ At the moment this project **does not** adhere to - Jumpstart network ([#918](https://github.com/entropyxyz/entropy-core/pull/918)) - Add Signer groups and rotation ([#938](https://github.com/entropyxyz/entropy-core/pull/938)) - Split jumpstart and register flows ([#952](https://github.com/entropyxyz/entropy-core/pull/952)) +- New on-chain registration flow ([#955](https://github.com/entropyxyz/entropy-core/pull/955)) - Reshare confirmation ([#965](https://github.com/entropyxyz/entropy-core/pull/965)) - Set inital signers ([#971](https://github.com/entropyxyz/entropy-core/pull/971)) - Add parent key threshold dynamically ([#974](https://github.com/entropyxyz/entropy-core/pull/974)) diff --git a/Cargo.lock b/Cargo.lock index 933418350..afd253433 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -792,6 +792,15 @@ dependencies = [ "serde", ] +[[package]] +name = "bincode" +version = "2.0.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f11ea1a0346b94ef188834a65c068a03aec181c94896d481d7a0a40d85b0ce95" +dependencies = [ + "serde", +] + [[package]] name = "bindgen" version = "0.65.1" @@ -813,6 +822,22 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "bip32" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa13fae8b6255872fd86f7faf4b41168661d7d78609f7bfe6771b85c6739a15b" +dependencies = [ + "bs58 0.5.1", + "hmac 0.12.1", + "k256", + "rand_core 0.6.4", + "ripemd", + "sha2 0.10.8", + "subtle 2.5.0", + "zeroize", +] + [[package]] name = "bip39" version = "2.0.0" @@ -1006,6 +1031,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ + "sha2 0.10.8", "tinyvec", ] @@ -2469,7 +2495,7 @@ dependencies = [ "sp-core 31.0.0", "sp-keyring 34.0.0", "subxt", - "synedrion", + "synedrion 0.1.0 (git+https://github.com/entropyxyz/synedrion?rev=3be1339c21384a8e60a1534f1d3bfdd022662e63)", "thiserror", "tokio", "tracing", @@ -2484,7 +2510,7 @@ dependencies = [ "entropy-shared", "entropy-testing-utils", "entropy-tss", - "synedrion", + "synedrion 0.1.0 (git+https://github.com/entropyxyz/synedrion?rev=3be1339c21384a8e60a1534f1d3bfdd022662e63)", "tokio", ] @@ -2492,7 +2518,7 @@ dependencies = [ name = "entropy-kvdb" version = "0.2.0" dependencies = [ - "bincode", + "bincode 1.3.3", "chacha20poly1305 0.9.1", "entropy-protocol", "hex", @@ -2503,7 +2529,7 @@ dependencies = [ "serial_test", "sled", "sp-core 31.0.0", - "synedrion", + "synedrion 0.1.0 (git+https://github.com/entropyxyz/synedrion?rev=3be1339c21384a8e60a1534f1d3bfdd022662e63)", "thiserror", "tokio", "tracing", @@ -2541,7 +2567,7 @@ dependencies = [ "async-trait", "axum", "base64 0.22.1", - "bincode", + "bincode 1.3.3", "blake2 0.10.6", "entropy-shared", "futures", @@ -2563,7 +2589,7 @@ dependencies = [ "sp-core 31.0.0", "sp-keyring 34.0.0", "subxt", - "synedrion", + "synedrion 0.1.0 (git+https://github.com/entropyxyz/synedrion?rev=3be1339c21384a8e60a1534f1d3bfdd022662e63)", "thiserror", "tokio", "tokio-tungstenite 0.23.1", @@ -2681,7 +2707,7 @@ name = "entropy-test-cli" version = "0.2.0" dependencies = [ "anyhow", - "bincode", + "bincode 1.3.3", "clap", "colored", "entropy-client", @@ -2712,7 +2738,7 @@ dependencies = [ "sp-core 31.0.0", "sp-keyring 34.0.0", "subxt", - "synedrion", + "synedrion 0.1.0 (git+https://github.com/entropyxyz/synedrion?rev=3be1339c21384a8e60a1534f1d3bfdd022662e63)", "tokio", "tracing", "tracing-subscriber 0.3.18", @@ -2726,7 +2752,7 @@ dependencies = [ "axum", "backoff", "base64 0.22.1", - "bincode", + "bincode 1.3.3", "bip39", "blake2 0.10.6", "blake3", @@ -2767,7 +2793,7 @@ dependencies = [ "strum 0.26.3", "subxt", "subxt-signer", - "synedrion", + "synedrion 0.1.0 (git+https://github.com/entropyxyz/synedrion?rev=3be1339c21384a8e60a1534f1d3bfdd022662e63)", "thiserror", "tokio", "tokio-tungstenite 0.23.1", @@ -7169,6 +7195,7 @@ dependencies = [ name = "pallet-registry" version = "0.2.0" dependencies = [ + "bip32", "entropy-shared", "frame-benchmarking", "frame-election-provider-support", @@ -7193,6 +7220,7 @@ dependencies = [ "sp-runtime 32.0.0", "sp-staking 27.0.0", "sp-std 14.0.0", + "synedrion 0.1.0 (git+https://github.com/entropyxyz/synedrion/?rev=1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa)", ] [[package]] @@ -11313,6 +11341,16 @@ dependencies = [ "zeroize", ] +[[package]] +name = "secrecy" +version = "0.9.0-pre.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e480ff13eb421e9c0201c7d8e17fe61ad336a38701989e91f8d0523001cd2fa" +dependencies = [ + "serde", + "zeroize", +] + [[package]] name = "security-framework" version = "2.10.0" @@ -12246,7 +12284,7 @@ dependencies = [ "scale-info", "schnorrkel", "secp256k1", - "secrecy", + "secrecy 0.8.0", "serde", "sp-crypto-hashing", "sp-debug-derive", @@ -12293,7 +12331,7 @@ dependencies = [ "scale-info", "schnorrkel", "secp256k1", - "secrecy", + "secrecy 0.8.0", "serde", "sp-crypto-hashing", "sp-debug-derive", @@ -12340,7 +12378,7 @@ dependencies = [ "scale-info", "schnorrkel", "secp256k1", - "secrecy", + "secrecy 0.8.0", "serde", "sp-crypto-hashing", "sp-debug-derive", @@ -13883,7 +13921,7 @@ dependencies = [ "regex", "schnorrkel", "secp256k1", - "secrecy", + "secrecy 0.8.0", "sha2 0.10.8", "sp-crypto-hashing", "subxt", @@ -13938,13 +13976,37 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +[[package]] +name = "synedrion" +version = "0.1.0" +source = "git+https://github.com/entropyxyz/synedrion/?rev=1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa#1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa" +dependencies = [ + "base64 0.21.7", + "bincode 2.0.0-rc.3", + "bip32", + "crypto-bigint", + "crypto-primes", + "digest 0.10.7", + "displaydoc", + "hashing-serializer", + "hex", + "k256", + "rand_core 0.6.4", + "secrecy 0.9.0-pre.0", + "serde", + "sha2 0.10.8", + "sha3", + "signature", + "zeroize", +] + [[package]] name = "synedrion" version = "0.1.0" source = "git+https://github.com/entropyxyz/synedrion?rev=3be1339c21384a8e60a1534f1d3bfdd022662e63#3be1339c21384a8e60a1534f1d3bfdd022662e63" dependencies = [ "base64 0.21.7", - "bincode", + "bincode 1.3.3", "crypto-bigint", "crypto-primes", "digest 0.10.7", @@ -13953,7 +14015,7 @@ dependencies = [ "hex", "k256", "rand_core 0.6.4", - "secrecy", + "secrecy 0.8.0", "serde", "sha2 0.10.8", "sha3", @@ -15288,7 +15350,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f907fdead3153cb9bfb7a93bbd5b62629472dc06dee83605358c64c52ed3dda9" dependencies = [ "anyhow", - "bincode", + "bincode 1.3.3", "cfg-if", "indexmap 1.9.3", "libc", @@ -15317,7 +15379,7 @@ checksum = "c4e87029cc5760db9a3774aff4708596fe90c20ed2baeef97212e98b812fd0fc" dependencies = [ "anyhow", "async-trait", - "bincode", + "bincode 1.3.3", "bumpalo", "cfg-if", "encoding_rs", @@ -15374,7 +15436,7 @@ checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", "base64 0.21.7", - "bincode", + "bincode 1.3.3", "directories-next", "file-per-thread-logger 0.1.6", "log", @@ -15394,7 +15456,7 @@ checksum = "31561fbbaa86d3c042696940bc9601146bf4aaec39ae725c86b5f1358d8d7023" dependencies = [ "anyhow", "base64 0.21.7", - "bincode", + "bincode 1.3.3", "directories-next", "file-per-thread-logger 0.2.0", "log", @@ -15567,7 +15629,7 @@ checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" dependencies = [ "addr2line 0.19.0", "anyhow", - "bincode", + "bincode 1.3.3", "cfg-if", "cpp_demangle", "gimli 0.27.3", @@ -15591,7 +15653,7 @@ checksum = "cce606b392c321d7272928003543447119ef937a9c3ebfce5c4bb0bf6b0f5bac" dependencies = [ "addr2line 0.20.0", "anyhow", - "bincode", + "bincode 1.3.3", "cfg-if", "cpp_demangle", "gimli 0.27.3", diff --git a/pallets/registry/Cargo.toml b/pallets/registry/Cargo.toml index f942b0586..d8825e2a8 100644 --- a/pallets/registry/Cargo.toml +++ b/pallets/registry/Cargo.toml @@ -12,9 +12,11 @@ publish =false targets=['x86_64-unknown-linux-gnu'] [dependencies] +bip32 ={ version="0.5.2", default-features=false, features=["alloc"] } codec ={ package="parity-scale-codec", version="3.6.3", default-features=false, features=["derive"] } -scale-info={ version="2.11", default-features=false, features=["derive"] } log ={ version="0.4.22", default-features=false } +scale-info={ version="2.11", default-features=false, features=["derive"] } +synedrion ={ git="https://github.com/entropyxyz/synedrion/", rev="1d210d149dfeb0dca1dd41d7fac4d0bf03c686fa", default-features=false } frame-benchmarking={ version="29.0.0", default-features=false, optional=true } frame-support ={ version="29.0.0", default-features=false } diff --git a/pallets/registry/src/benchmarking.rs b/pallets/registry/src/benchmarking.rs index cce775989..30112df7d 100644 --- a/pallets/registry/src/benchmarking.rs +++ b/pallets/registry/src/benchmarking.rs @@ -165,6 +165,92 @@ benchmarks! { assert!(Registering::::contains_key(sig_req_account)); } + register_on_chain { + let p in 1 .. T::MaxProgramHashes::get(); + + let program_modification_account: T::AccountId = whitelisted_caller(); + let signature_request_account: T::AccountId = whitelisted_caller(); + + 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![], + }; + p as usize + ]) + .unwrap(); + + Programs::::insert( + program_hash, + ProgramInfo { + bytecode: program, + configuration_schema, + auxiliary_data_schema, + oracle_data_pointer, + deployer: program_modification_account.clone(), + ref_counter: 0, + }, + ); + + let network_verifying_key = entropy_shared::DAVE_VERIFYING_KEY; + >::put(JumpStartDetails { + jump_start_status: JumpStartStatus::Done, + confirmations: vec![], + verifying_key: Some(BoundedVec::try_from(network_verifying_key.to_vec()).unwrap()), + parent_key_threshold: 0, + }); + + + let balance = + ::Currency::minimum_balance() * 100u32.into(); + let _ = ::Currency::make_free_balance_be( + &signature_request_account, + balance, + ); + }: _( + RawOrigin::Signed(signature_request_account.clone()), + program_modification_account, + programs_info + ) + verify { + use core::str::FromStr; + use synedrion::DeriveChildKey; + + let network_verifying_key = + synedrion::ecdsa::VerifyingKey::try_from(network_verifying_key.as_slice()).unwrap(); + + // We substract one from the count since this gets incremented after a succesful registration, + // and we're interested in the account we just registered. + let count = >::count() - 1; + let derivation_path = + bip32::DerivationPath::from_str(&scale_info::prelude::format!("m/0/{}", count)).unwrap(); + + let expected_verifying_key = network_verifying_key + .derive_verifying_key_bip32(&derivation_path) + .unwrap(); + let expected_verifying_key = BoundedVec::try_from( + expected_verifying_key + .to_encoded_point(true) + .as_bytes() + .to_vec(), + ) + .unwrap(); + + assert_last_event::( + Event::::AccountRegistered( + signature_request_account, + expected_verifying_key.clone() + ).into(), + ); + + assert!(RegisteredOnChain::::contains_key(expected_verifying_key)); + } + prune_registration { let p in 1 .. T::MaxProgramHashes::get(); let program_modification_account: T::AccountId = whitelisted_caller(); diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index 6ffbcb780..3dc5f8f06 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -132,13 +132,23 @@ pub mod pallet { #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { - for account_info in &self.registered_accounts { - assert!(account_info.1.len() as u32 == VERIFICATION_KEY_LENGTH); + for (account_id, verifying_key) in &self.registered_accounts { + assert!(verifying_key.len() as u32 == VERIFICATION_KEY_LENGTH); + Registered::::insert( - account_info.1.clone(), + verifying_key.clone(), + RegisteredInfo { + programs_data: BoundedVec::default(), + program_modification_account: account_id.clone(), + version_number: T::KeyVersionNumber::get(), + }, + ); + + RegisteredOnChain::::insert( + verifying_key.clone(), RegisteredInfo { programs_data: BoundedVec::default(), - program_modification_account: account_info.0.clone(), + program_modification_account: account_id.clone(), version_number: T::KeyVersionNumber::get(), }, ); @@ -174,6 +184,16 @@ pub mod pallet { pub type Registered = StorageMap<_, Blake2_128Concat, VerifyingKey, RegisteredInfo, OptionQuery>; + /// An item tracking all the users registered on the Entropy network. + /// + /// Notice that the registration state does not depend on any Substrate account being + /// registered, but rather a _verifying key_, which represents the user beyond the scope of the + /// Entropy network itself (e.g it can be an account on Bitcoin or Ethereum). + #[pallet::storage] + #[pallet::getter(fn registered_on_chain)] + pub type RegisteredOnChain = + CountedStorageMap<_, Blake2_128Concat, VerifyingKey, RegisteredInfo, OptionQuery>; + /// Mapping of program_modification accounts to verifying keys they can control #[pallet::storage] #[pallet::getter(fn modifiable_keys)] @@ -235,7 +255,10 @@ pub mod pallet { NotValidator, JumpStartProgressNotReady, JumpStartNotInProgress, + JumpStartNotCompleted, NoRegisteringFromParentKey, + InvalidBip32DerivationPath, + Bip32AccountDerivationFailed, } /// Allows anyone to create a parent key for the network if the network is read and a parent key @@ -382,9 +405,9 @@ pub mod pallet { programs_data: BoundedVec, T::MaxProgramHashes>, ) -> DispatchResultWithPostInfo { let sig_req_account = ensure_signed(origin)?; - let encoded_sig_req_account = sig_req_account.encode(); + ensure!( - encoded_sig_req_account != NETWORK_PARENT_KEY.encode(), + sig_req_account.encode() != NETWORK_PARENT_KEY.encode(), Error::::NoRegisteringFromParentKey ); ensure!( @@ -409,7 +432,7 @@ pub mod pallet { } Dkg::::try_mutate(block_number, |messages| -> Result<_, DispatchError> { - messages.push(encoded_sig_req_account); + messages.push(sig_req_account.encode()); Ok(()) })?; @@ -675,6 +698,105 @@ pub mod pallet { .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(7)] + #[pallet::weight({ + ::WeightInfo::register_on_chain(::MaxProgramHashes::get()) + })] + pub fn register_on_chain( + origin: OriginFor, + program_modification_account: T::AccountId, + programs_data: BoundedVec, T::MaxProgramHashes>, + ) -> DispatchResultWithPostInfo { + use core::str::FromStr; + use synedrion::{ecdsa::VerifyingKey as SynedrionVerifyingKey, DeriveChildKey}; + + let signature_request_account = ensure_signed(origin)?; + + ensure!( + signature_request_account.encode() != NETWORK_PARENT_KEY.encode(), + Error::::NoRegisteringFromParentKey + ); + + let num_programs = programs_data.len(); + ensure!(num_programs != 0, Error::::NoProgramSet); + + // Change program ref counter + for program_instance in &programs_data { + pallet_programs::Programs::::try_mutate( + program_instance.program_pointer, + |maybe_program_info| { + if let Some(program_info) = maybe_program_info { + program_info.ref_counter = program_info.ref_counter.saturating_add(1); + Ok(()) + } else { + Err(Error::::NoProgramSet) + } + }, + )?; + } + + let network_verifying_key = + if let Some(key) = >::get().verifying_key { + SynedrionVerifyingKey::try_from(key.as_slice()) + .expect("The network verifying key must be valid.") + } else { + return Err(Error::::JumpStartNotCompleted.into()); + }; + + // TODO (#984): For a `CountedStorageMap` there is the possibility that the counter + // can decrease as storage entries are removed from the map. In our case we don't ever + // remove entries from the `RegisteredOnChain` map so the counter should never + // decrease. If it does we will end up with the same verifying key for different + // accounts, which would be bad. + // + // For a V1 of this flow it's fine, but we'll need to think about a better solution + // down the line. + let count = RegisteredOnChain::::count(); + let path = + bip32::DerivationPath::from_str(&scale_info::prelude::format!("m/0/{}", count)) + .map_err(|_| Error::::InvalidBip32DerivationPath)?; + let child_verifying_key = network_verifying_key + .derive_verifying_key_bip32(&path) + .map_err(|_| Error::::Bip32AccountDerivationFailed)?; + + let child_verifying_key = BoundedVec::try_from( + child_verifying_key.to_encoded_point(true).as_bytes().to_vec(), + ) + .expect("Synedrion must have returned a valid verifying key."); + + RegisteredOnChain::::insert( + child_verifying_key.clone(), + RegisteredInfo { + programs_data, + program_modification_account: program_modification_account.clone(), + version_number: T::KeyVersionNumber::get(), + }, + ); + + ModifiableKeys::::try_mutate( + program_modification_account, + |verifying_keys| -> Result<(), DispatchError> { + verifying_keys + .try_push(child_verifying_key.clone()) + .map_err(|_| Error::::TooManyModifiableKeys)?; + Ok(()) + }, + )?; + + Self::deposit_event(Event::AccountRegistered( + signature_request_account, + child_verifying_key, + )); + + Ok(Some(::WeightInfo::register(num_programs as u32)).into()) + } } impl Pallet { diff --git a/pallets/registry/src/tests.rs b/pallets/registry/src/tests.rs index f9944f08e..6313cfc3d 100644 --- a/pallets/registry/src/tests.rs +++ b/pallets/registry/src/tests.rs @@ -23,7 +23,7 @@ use frame_support::{ }; use pallet_programs::ProgramInfo; use pallet_registry::Call as RegistryCall; -use pallet_staking_extension::{JumpStartDetails, JumpStartStatus, ServerInfo}; +use pallet_staking_extension::{JumpStartDetails, JumpStartProgress, JumpStartStatus, ServerInfo}; use sp_runtime::{ traits::{Hash, SignedExtension}, transaction_validity::{TransactionValidity, ValidTransaction}, @@ -37,6 +37,31 @@ use crate::{ const NULL_ARR: [u8; 32] = [0; 32]; +fn setup_programs( +) -> BoundedVec, ::MaxProgramHashes> { + let alice = 1u64; + 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: alice, + ref_counter: 0, + }, + ); + + programs_info +} + #[test] fn it_tests_get_validators_info() { new_test_ext().execute_with(|| { @@ -52,6 +77,187 @@ fn it_tests_get_validators_info() { }); } +#[test] +fn it_registers_a_user_on_chain() { + new_test_ext().execute_with(|| { + use synedrion::{ecdsa::VerifyingKey as SynedrionVerifyingKey, DeriveChildKey}; + + let (alice, bob, _charlie) = (1u64, 2, 3); + + // Setup: Ensure programs exist and a valid verifying key is available + let programs_info = setup_programs(); + + let network_verifying_key = entropy_shared::DAVE_VERIFYING_KEY; + pallet_staking_extension::JumpStartProgress::::set(JumpStartDetails { + jump_start_status: JumpStartStatus::Done, + confirmations: vec![], + verifying_key: Some(BoundedVec::try_from(network_verifying_key.to_vec()).unwrap()), + parent_key_threshold: 0, + }); + + // Test: Run through registration + assert_ok!(Registry::register_on_chain( + RuntimeOrigin::signed(alice), + bob, + programs_info.clone(), + )); + + // Validate: Our expected verifying key is registered correctly + let network_verifying_key = + SynedrionVerifyingKey::try_from(network_verifying_key.as_slice()).unwrap(); + + let derivation_path = "m/0/0".parse().unwrap(); + let expected_verifying_key = + network_verifying_key.derive_verifying_key_bip32(&derivation_path).unwrap(); + let expected_verifying_key = + BoundedVec::try_from(expected_verifying_key.to_encoded_point(true).as_bytes().to_vec()) + .unwrap(); + + let registered_info = Registry::registered_on_chain(expected_verifying_key.clone()); + assert!(registered_info.is_some()); + assert_eq!(registered_info.unwrap().program_modification_account, bob); + }); +} + +#[test] +fn it_registers_different_users_with_the_same_sig_req_account() { + new_test_ext().execute_with(|| { + use synedrion::{ecdsa::VerifyingKey as SynedrionVerifyingKey, DeriveChildKey}; + + let (alice, bob, _charlie) = (1u64, 2, 3); + + // Setup: Ensure programs exist and a valid verifying key is available + let programs_info = setup_programs(); + + let network_verifying_key = entropy_shared::DAVE_VERIFYING_KEY; + JumpStartProgress::::set(JumpStartDetails { + jump_start_status: JumpStartStatus::Done, + confirmations: vec![], + verifying_key: Some(BoundedVec::try_from(network_verifying_key.to_vec()).unwrap()), + parent_key_threshold: 0, + }); + + // Test: Run through registration twice using the same signature request account. We should + // get different verifying keys. + assert_ok!(Registry::register_on_chain( + RuntimeOrigin::signed(alice), + bob, + programs_info.clone(), + )); + + assert_ok!(Registry::register_on_chain( + RuntimeOrigin::signed(alice), + bob, + programs_info.clone(), + )); + + // Validate: We expect two different verifying keys to be registered + let network_verifying_key = + SynedrionVerifyingKey::try_from(network_verifying_key.as_slice()).unwrap(); + + let derivation_path = "m/0/0".parse().unwrap(); + let first_expected_verifying_key = + network_verifying_key.derive_verifying_key_bip32(&derivation_path).unwrap(); + let first_expected_verifying_key = BoundedVec::try_from( + first_expected_verifying_key.to_encoded_point(true).as_bytes().to_vec(), + ) + .unwrap(); + + let derivation_path = "m/0/1".parse().unwrap(); + let second_expected_verifying_key = + network_verifying_key.derive_verifying_key_bip32(&derivation_path).unwrap(); + let second_expected_verifying_key = BoundedVec::try_from( + second_expected_verifying_key.to_encoded_point(true).as_bytes().to_vec(), + ) + .unwrap(); + + // Knowing that the two keys are indeed different, we still expect both registration + // requests to have succeeded. + assert!(first_expected_verifying_key != second_expected_verifying_key); + assert!(Registry::registered_on_chain(first_expected_verifying_key).is_some()); + assert!(Registry::registered_on_chain(second_expected_verifying_key).is_some()); + }); +} + +#[test] +fn it_fails_registration_if_no_program_is_set() { + new_test_ext().execute_with(|| { + let (alice, bob) = (1u64, 2); + + // Note that we also don't write any programs into storage here. + let programs_info = BoundedVec::try_from(vec![]).unwrap(); + + // Test: Run through registration, this should fail + assert_noop!( + Registry::register_on_chain(RuntimeOrigin::signed(alice), bob, programs_info,), + Error::::NoProgramSet + ); + }) +} + +#[test] +fn it_fails_registration_if_no_jump_start_has_happened() { + new_test_ext().execute_with(|| { + let (alice, bob) = (1u64, 2); + + // Setup: Ensure programs exist + let programs_info = setup_programs(); + + // This should be the default status, but let's be explicit about it anyways + pallet_staking_extension::JumpStartProgress::::set(JumpStartDetails { + jump_start_status: JumpStartStatus::Ready, + confirmations: vec![], + verifying_key: None, + parent_key_threshold: 0, + }); + + // Test: Run through registration, this should fail + assert_noop!( + Registry::register_on_chain(RuntimeOrigin::signed(alice), bob, programs_info,), + Error::::JumpStartNotCompleted + ); + }) +} + +#[test] +fn it_fails_registration_with_too_many_modifiable_keys() { + new_test_ext().execute_with(|| { + let (alice, bob) = (1u64, 2); + + // Setup: Ensure programs exist and a valid verifying key is available + let programs_info = setup_programs(); + + let network_verifying_key = entropy_shared::DAVE_VERIFYING_KEY; + pallet_staking_extension::JumpStartProgress::::set(JumpStartDetails { + jump_start_status: JumpStartStatus::Done, + confirmations: vec![], + verifying_key: Some(BoundedVec::try_from(network_verifying_key.to_vec()).unwrap()), + parent_key_threshold: 0, + }); + + // Now we prep our state to make sure that the limit of verifying keys for an account is hit + let mut managed_verifying_keys = vec![]; + for _ in 0..pallet_registry::MAX_MODIFIABLE_KEYS { + managed_verifying_keys + .push(BoundedVec::try_from(entropy_shared::DAVE_VERIFYING_KEY.to_vec()).unwrap()); + } + + let modifiable_keys = BoundedVec::try_from(managed_verifying_keys).unwrap(); + pallet_registry::ModifiableKeys::::insert(bob, &modifiable_keys); + + // Test: Run through registration, this should fail + assert_noop!( + Registry::register_on_chain(RuntimeOrigin::signed(alice), bob, programs_info,), + Error::::TooManyModifiableKeys + ); + }) +} + +#[test] +fn it_fails_registration_if_parent_key_matches_derived_key() { + new_test_ext().execute_with(|| {}) +} + #[test] fn it_registers_a_user() { new_test_ext().execute_with(|| { @@ -97,7 +303,7 @@ fn it_jumps_the_network() { jump_start_status: JumpStartStatus::Ready, confirmations: vec![], verifying_key: None, - parent_key_threshold: 0 + parent_key_threshold: 0, }, "Checks default status of jump start detail" ); @@ -113,7 +319,7 @@ fn it_jumps_the_network() { jump_start_status: JumpStartStatus::InProgress(0), confirmations: vec![], verifying_key: None, - parent_key_threshold: 2 + parent_key_threshold: 2, }, "Checks that jump start is in progress" ); @@ -132,7 +338,7 @@ fn it_jumps_the_network() { jump_start_status: JumpStartStatus::InProgress(100), confirmations: vec![], verifying_key: None, - parent_key_threshold: 2 + parent_key_threshold: 2, }, "ensures jump start is called again if too many blocks passed" ); @@ -173,7 +379,7 @@ fn it_tests_jump_start_result() { jump_start_status: JumpStartStatus::InProgress(0), confirmations: vec![1], verifying_key: Some(expected_verifying_key.clone()), - parent_key_threshold: 2 + parent_key_threshold: 2, }, "Jump start recieves a confirmation" ); @@ -205,7 +411,7 @@ fn it_tests_jump_start_result() { jump_start_status: JumpStartStatus::Done, confirmations: vec![], verifying_key: Some(expected_verifying_key), - parent_key_threshold: 2 + parent_key_threshold: 2, }, "Jump start in done status after all confirmations" ); diff --git a/pallets/registry/src/weights.rs b/pallets/registry/src/weights.rs index d3d5eb3a0..c05652709 100644 --- a/pallets/registry/src/weights.rs +++ b/pallets/registry/src/weights.rs @@ -52,6 +52,7 @@ use core::marker::PhantomData; /// Weight functions needed for pallet_registry. pub trait WeightInfo { fn register(p: u32) -> Weight; + fn register_on_chain(_p: u32) -> Weight; fn jump_start_network() -> Weight; fn prune_registration(p: u32) -> Weight; fn confirm_jump_start_done(c: u32, ) -> Weight; @@ -135,6 +136,27 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `Programs::Programs` (r:1 w:1) + /// Proof: `Programs::Programs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Registry::JumpStartProgress` (r:1 w:0) + /// Proof: `Registry::JumpStartProgress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Registry::CounterForRegisteredOnChain` (r:1 w:1) + /// Proof: `Registry::CounterForRegisteredOnChain` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Registry::RegisteredOnChain` (r:1 w:1) + /// Proof: `Registry::RegisteredOnChain` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Registry::ModifiableKeys` (r:1 w:1) + /// Proof: `Registry::ModifiableKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[1, 5]`. + fn register_on_chain(_p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `4028` + // Minimum execution time: 525_000_000 picoseconds. + Weight::from_parts(540_700_000, 0) + .saturating_add(Weight::from_parts(0, 4028)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } /// Storage: `Registry::Registering` (r:1 w:1) /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Programs::Programs` (r:1 w:1) @@ -312,6 +334,27 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(3)) } + /// Storage: `Programs::Programs` (r:1 w:1) + /// Proof: `Programs::Programs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Registry::JumpStartProgress` (r:1 w:0) + /// Proof: `Registry::JumpStartProgress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Registry::CounterForRegisteredOnChain` (r:1 w:1) + /// Proof: `Registry::CounterForRegisteredOnChain` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Registry::RegisteredOnChain` (r:1 w:1) + /// Proof: `Registry::RegisteredOnChain` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Registry::ModifiableKeys` (r:1 w:1) + /// Proof: `Registry::ModifiableKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[1, 5]`. + fn register_on_chain(_p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `4028` + // Minimum execution time: 525_000_000 picoseconds. + Weight::from_parts(540_700_000, 0) + .saturating_add(Weight::from_parts(0, 4028)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(4)) + } /// Storage: `Registry::Registering` (r:1 w:1) /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Programs::Programs` (r:1 w:1) diff --git a/runtime/src/weights/pallet_registry.rs b/runtime/src/weights/pallet_registry.rs index fdfafcc0d..d8d11c546 100644 --- a/runtime/src/weights/pallet_registry.rs +++ b/runtime/src/weights/pallet_registry.rs @@ -16,9 +16,9 @@ //! Autogenerated weights for `pallet_registry` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 33.0.0 -//! DATE: 2024-07-02, STEPS: `5`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-08-02, STEPS: `5`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Jesses-MacBook-Pro.local`, CPU: `` +//! HOSTNAME: `hcastano`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 // Executed Command: @@ -47,49 +47,53 @@ pub struct WeightInfo(PhantomData); impl pallet_registry::WeightInfo for WeightInfo { /// Storage: `Registry::JumpStartProgress` (r:1 w:1) /// Proof: `Registry::JumpStartProgress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `Registry::Dkg` (r:1 w:1) - /// Proof: `Registry::Dkg` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Registry::JumpstartDkg` (r:1 w:1) + /// Proof: `Registry::JumpstartDkg` (`max_values`: None, `max_size`: None, mode: `Measured`) fn jump_start_network() -> Weight { // Proof Size summary in bytes: - // Measured: `80` - // Estimated: `3545` - // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(10_000_000, 0) - .saturating_add(Weight::from_parts(0, 3545)) + // Measured: `140` + // Estimated: `3605` + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(28_000_000, 0) + .saturating_add(Weight::from_parts(0, 3605)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::ValidatorToSubgroup` (r:1 w:0) - /// Proof: `StakingExtension::ValidatorToSubgroup` (`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::JumpStartProgress` (r:1 w:1) /// Proof: `Registry::JumpStartProgress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_jump_start_done(_c: u32, ) -> Weight { + /// Storage: `StakingExtension::Signers` (r:0 w:1) + /// Proof: `StakingExtension::Signers` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 3]`. + fn confirm_jump_start_done(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1314` - // Estimated: `4779` - // Minimum execution time: 16_000_000 picoseconds. - Weight::from_parts(17_000_000, 0) - .saturating_add(Weight::from_parts(0, 4779)) + // Measured: `793` + // Estimated: `4258` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(17_600_000, 0) + .saturating_add(Weight::from_parts(0, 4258)) + // Standard Error: 916_515 + .saturating_add(Weight::from_parts(1_600_000, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().writes(1)) + .saturating_add(T::DbWeight::get().writes(2)) } /// Storage: `StakingExtension::ThresholdToStash` (r:1 w:0) /// Proof: `StakingExtension::ThresholdToStash` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `StakingExtension::ValidatorToSubgroup` (r:1 w:0) - /// Proof: `StakingExtension::ValidatorToSubgroup` (`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::JumpStartProgress` (r:1 w:1) /// Proof: `Registry::JumpStartProgress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. + /// The range of component `c` is `[0, 3]`. fn confirm_jump_start_confirm(_c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1313` - // Estimated: `4778` - // Minimum execution time: 16_000_000 picoseconds. - Weight::from_parts(16_916_666, 0) - .saturating_add(Weight::from_parts(0, 4778)) + // Measured: `693` + // Estimated: `4158` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_200_000, 0) + .saturating_add(Weight::from_parts(0, 4158)) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -102,28 +106,51 @@ impl pallet_registry::WeightInfo for WeightInfo { /// The range of component `p` is `[1, 5]`. fn register(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `358` - // Estimated: `3823` - // Minimum execution time: 16_000_000 picoseconds. - Weight::from_parts(17_750_000, 0) - .saturating_add(Weight::from_parts(0, 3823)) - // Standard Error: 1_234_022 - .saturating_add(Weight::from_parts(1_650_000, 0).saturating_mul(p.into())) + // Measured: `393` + // Estimated: `3858` + // Minimum execution time: 20_000_000 picoseconds. + Weight::from_parts(18_500_000, 0) + .saturating_add(Weight::from_parts(0, 3858)) + // Standard Error: 362_284 + .saturating_add(Weight::from_parts(2_500_000, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } + /// Storage: `Programs::Programs` (r:1 w:1) + /// Proof: `Programs::Programs` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Registry::JumpStartProgress` (r:1 w:0) + /// Proof: `Registry::JumpStartProgress` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `Registry::CounterForRegisteredOnChain` (r:1 w:1) + /// Proof: `Registry::CounterForRegisteredOnChain` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Registry::RegisteredOnChain` (r:1 w:1) + /// Proof: `Registry::RegisteredOnChain` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `Registry::ModifiableKeys` (r:1 w:1) + /// Proof: `Registry::ModifiableKeys` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[1, 5]`. + fn register_on_chain(_p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `4028` + // Minimum execution time: 525_000_000 picoseconds. + Weight::from_parts(540_700_000, 0) + .saturating_add(Weight::from_parts(0, 4028)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } /// Storage: `Registry::Registering` (r:1 w:1) /// Proof: `Registry::Registering` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Programs::Programs` (r:1 w:1) /// Proof: `Programs::Programs` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `p` is `[1, 5]`. - fn prune_registration(_p: u32, ) -> Weight { + fn prune_registration(p: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `480` - // Estimated: `3945` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(14_400_000, 0) - .saturating_add(Weight::from_parts(0, 3945)) + // Measured: `540` + // Estimated: `4005` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_300_000, 0) + .saturating_add(Weight::from_parts(0, 4005)) + // Standard Error: 117_260 + .saturating_add(Weight::from_parts(100_000, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } @@ -135,15 +162,15 @@ impl pallet_registry::WeightInfo for WeightInfo { /// The range of component `o` is `[1, 5]`. fn change_program_instance(n: u32, o: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `614 + o * (33 ±0)` - // Estimated: `6554 + o * (33 ±0)` - // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(16_750_000, 0) - .saturating_add(Weight::from_parts(0, 6554)) - // Standard Error: 526_434 - .saturating_add(Weight::from_parts(2_204_761, 0).saturating_mul(n.into())) - // Standard Error: 526_434 - .saturating_add(Weight::from_parts(2_088_095, 0).saturating_mul(o.into())) + // Measured: `674 + o * (33 ±0)` + // Estimated: `6614 + o * (33 ±0)` + // Minimum execution time: 34_000_000 picoseconds. + Weight::from_parts(27_500_000, 0) + .saturating_add(Weight::from_parts(0, 6614)) + // Standard Error: 377_136 + .saturating_add(Weight::from_parts(2_126_190, 0).saturating_mul(n.into())) + // Standard Error: 377_136 + .saturating_add(Weight::from_parts(1_059_523, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) .saturating_add(Weight::from_parts(0, 33).saturating_mul(o.into())) @@ -155,13 +182,13 @@ impl pallet_registry::WeightInfo for WeightInfo { /// The range of component `n` is `[1, 25]`. fn change_program_modification_account(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `328 + n * (1 ±0)` - // Estimated: `3793 + n * (1 ±0)` - // Minimum execution time: 13_000_000 picoseconds. - Weight::from_parts(14_041_666, 0) - .saturating_add(Weight::from_parts(0, 3793)) - // Standard Error: 23_385 - .saturating_add(Weight::from_parts(58_333, 0).saturating_mul(n.into())) + // Measured: `388 + n * (1 ±0)` + // Estimated: `3853 + n * (1 ±0)` + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(16_808_333, 0) + .saturating_add(Weight::from_parts(0, 3853)) + // Standard Error: 26_187 + .saturating_add(Weight::from_parts(91_666, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into())) @@ -170,57 +197,64 @@ impl pallet_registry::WeightInfo for WeightInfo { /// 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::ValidatorToSubgroup` (r:1 w:0) - /// Proof: `StakingExtension::ValidatorToSubgroup` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. - fn confirm_register_registering(_c: u32, ) -> Weight { + /// 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: `1410` - // Estimated: `4875` - // Minimum execution time: 19_000_000 picoseconds. - Weight::from_parts(20_416_666, 0) - .saturating_add(Weight::from_parts(0, 4875)) + // 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: `StakingExtension::ValidatorToSubgroup` (r:1 w:0) - /// Proof: `StakingExtension::ValidatorToSubgroup` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// The range of component `c` is `[0, 2]`. + /// 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: `1412` - // Estimated: `4877` - // Minimum execution time: 19_000_000 picoseconds. - Weight::from_parts(19_083_333, 0) - .saturating_add(Weight::from_parts(0, 4877)) - // Standard Error: 260_208 - .saturating_add(Weight::from_parts(250_000, 0).saturating_mul(c.into())) + // 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: `StakingExtension::ValidatorToSubgroup` (r:1 w:0) - /// Proof: `StakingExtension::ValidatorToSubgroup` (`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 `[0, 2]`. - fn confirm_register_registered(_c: u32, ) -> Weight { + /// The range of component `c` is `[1, 1000]`. + fn confirm_register_registered(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1436` - // Estimated: `4901` - // Minimum execution time: 25_000_000 picoseconds. - Weight::from_parts(26_916_666, 0) - .saturating_add(Weight::from_parts(0, 4901)) + // 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())) } }