diff --git a/CHANGELOG.md b/CHANGELOG.md index e4db0e246..3695cfa8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ At the moment this project **does not** adhere to ## [Unreleased](https://github.com/entropyxyz/entropy-core/compare/release/v0.2.0...master) +### Added +- Jumpstart network ([#918](https://github.com/entropyxyz/entropy-core/pull/918)) + ## [0.2.0](https://github.com/entropyxyz/entropy-core/compare/release/v0.1.0...release/v0.2.0) - 2024-07-11 ### Breaking Changes diff --git a/crates/client/entropy_metadata.scale b/crates/client/entropy_metadata.scale index dd72dae04..c5d046759 100644 Binary files a/crates/client/entropy_metadata.scale and b/crates/client/entropy_metadata.scale differ diff --git a/crates/shared/src/constants.rs b/crates/shared/src/constants.rs index 02720885b..49f4d7290 100644 --- a/crates/shared/src/constants.rs +++ b/crates/shared/src/constants.rs @@ -25,6 +25,8 @@ lazy_static! { pub static ref DEVICE_KEY_CONFIG_TYPE: Vec = vec![123, 34, 36, 115, 99, 104, 101, 109, 97, 34, 58, 34, 104, 116, 116, 112, 58, 47, 47, 106, 115, 111, 110, 45, 115, 99, 104, 101, 109, 97, 46, 111, 114, 103, 47, 100, 114, 97, 102, 116, 45, 48, 55, 47, 115, 99, 104, 101, 109, 97, 35, 34, 44, 34, 116, 105, 116, 108, 101, 34, 58, 34, 85, 115, 101, 114, 67, 111, 110, 102, 105, 103, 34, 44, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 74, 83, 79, 78, 45, 100, 101, 115, 101, 114, 105, 97, 108, 105, 122, 97, 98, 108, 101, 32, 115, 116, 114, 117, 99, 116, 32, 116, 104, 97, 116, 32, 119, 105, 108, 108, 32, 98, 101, 32, 117, 115, 101, 100, 32, 116, 111, 32, 100, 101, 114, 105, 118, 101, 32, 116, 104, 101, 32, 112, 114, 111, 103, 114, 97, 109, 45, 74, 83, 79, 78, 32, 105, 110, 116, 101, 114, 102, 97, 99, 101, 46, 32, 78, 111, 116, 101, 32, 104, 111, 119, 32, 116, 104, 105, 115, 32, 117, 115, 101, 115, 32, 74, 83, 79, 78, 45, 110, 97, 116, 105, 118, 101, 32, 116, 121, 112, 101, 115, 32, 111, 110, 108, 121, 46, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 111, 98, 106, 101, 99, 116, 34, 44, 34, 112, 114, 111, 112, 101, 114, 116, 105, 101, 115, 34, 58, 123, 34, 101, 99, 100, 115, 97, 95, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 115, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 98, 97, 115, 101, 54, 52, 45, 101, 110, 99, 111, 100, 101, 100, 32, 99, 111, 109, 112, 114, 101, 115, 115, 101, 100, 32, 112, 111, 105, 110, 116, 32, 40, 51, 51, 45, 98, 121, 116, 101, 41, 32, 69, 67, 68, 83, 65, 32, 112, 117, 98, 108, 105, 99, 32, 107, 101, 121, 115, 44, 32, 40, 101, 103, 46, 32, 92, 34, 65, 53, 55, 50, 100, 113, 111, 117, 101, 53, 79, 121, 119, 89, 47, 52, 56, 100, 116, 121, 116, 81, 105, 109, 76, 57, 87, 79, 48, 100, 112, 83, 79, 98, 97, 70, 98, 65, 120, 111, 69, 87, 87, 57, 92, 34, 41, 34, 44, 34, 116, 121, 112, 101, 34, 58, 91, 34, 97, 114, 114, 97, 121, 34, 44, 34, 110, 117, 108, 108, 34, 93, 44, 34, 105, 116, 101, 109, 115, 34, 58, 123, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 125, 44, 34, 101, 100, 50, 53, 53, 49, 57, 95, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 115, 34, 58, 123, 34, 116, 121, 112, 101, 34, 58, 91, 34, 97, 114, 114, 97, 121, 34, 44, 34, 110, 117, 108, 108, 34, 93, 44, 34, 105, 116, 101, 109, 115, 34, 58, 123, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 125, 44, 34, 115, 114, 50, 53, 53, 49, 57, 95, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 115, 34, 58, 123, 34, 116, 121, 112, 101, 34, 58, 91, 34, 97, 114, 114, 97, 121, 34, 44, 34, 110, 117, 108, 108, 34, 93, 44, 34, 105, 116, 101, 109, 115, 34, 58, 123, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 125, 125, 125]; // Device key aux data struct seralized by generate types in programs repo pub static ref DEVICE_KEY_AUX_DATA_TYPE: Vec = vec![123, 34, 36, 115, 99, 104, 101, 109, 97, 34, 58, 34, 104, 116, 116, 112, 58, 47, 47, 106, 115, 111, 110, 45, 115, 99, 104, 101, 109, 97, 46, 111, 114, 103, 47, 100, 114, 97, 102, 116, 45, 48, 55, 47, 115, 99, 104, 101, 109, 97, 35, 34, 44, 34, 116, 105, 116, 108, 101, 34, 58, 34, 65, 117, 120, 68, 97, 116, 97, 34, 44, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 74, 83, 79, 78, 32, 114, 101, 112, 114, 101, 115, 101, 110, 116, 97, 116, 105, 111, 110, 32, 111, 102, 32, 116, 104, 101, 32, 97, 117, 120, 105, 108, 105, 97, 114, 121, 32, 100, 97, 116, 97, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 111, 98, 106, 101, 99, 116, 34, 44, 34, 114, 101, 113, 117, 105, 114, 101, 100, 34, 58, 91, 34, 99, 111, 110, 116, 101, 120, 116, 34, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 34, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 95, 116, 121, 112, 101, 34, 44, 34, 115, 105, 103, 110, 97, 116, 117, 114, 101, 34, 93, 44, 34, 112, 114, 111, 112, 101, 114, 116, 105, 101, 115, 34, 58, 123, 34, 99, 111, 110, 116, 101, 120, 116, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 84, 104, 101, 32, 99, 111, 110, 116, 101, 120, 116, 32, 102, 111, 114, 32, 116, 104, 101, 32, 115, 105, 103, 110, 97, 116, 117, 114, 101, 32, 111, 110, 108, 121, 32, 110, 101, 101, 100, 101, 100, 32, 105, 110, 32, 115, 114, 50, 53, 53, 49, 57, 32, 115, 105, 103, 110, 97, 116, 117, 114, 101, 32, 116, 121, 112, 101, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 98, 97, 115, 101, 54, 52, 45, 101, 110, 99, 111, 100, 101, 100, 32, 112, 117, 98, 108, 105, 99, 32, 107, 101, 121, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 44, 34, 112, 117, 98, 108, 105, 99, 95, 107, 101, 121, 95, 116, 121, 112, 101, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 92, 34, 101, 99, 100, 115, 97, 92, 34, 44, 32, 92, 34, 101, 100, 50, 53, 53, 49, 57, 92, 34, 44, 32, 92, 34, 115, 114, 50, 53, 53, 49, 57, 92, 34, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 44, 34, 115, 105, 103, 110, 97, 116, 117, 114, 101, 34, 58, 123, 34, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 34, 58, 34, 98, 97, 115, 101, 54, 52, 45, 101, 110, 99, 111, 100, 101, 100, 32, 115, 105, 103, 110, 97, 116, 117, 114, 101, 34, 44, 34, 116, 121, 112, 101, 34, 58, 34, 115, 116, 114, 105, 110, 103, 34, 125, 125, 125]; + // Network parent key + pub static ref NETWORK_PARENT_KEY: H256 = H256::zero(); } pub const SIGNING_PARTY_SIZE: usize = 2; diff --git a/crates/threshold-signature-server/src/user/api.rs b/crates/threshold-signature-server/src/user/api.rs index 9f3f6fb0f..2a459935c 100644 --- a/crates/threshold-signature-server/src/user/api.rs +++ b/crates/threshold-signature-server/src/user/api.rs @@ -36,7 +36,8 @@ use entropy_programs_runtime::{Config as ProgramConfig, Runtime, SignatureReques use entropy_protocol::ValidatorInfo; use entropy_protocol::{KeyParams, SigningSessionInfo}; use entropy_shared::{ - types::KeyVisibility, HashingAlgorithm, OcwMessageDkg, X25519PublicKey, SIGNING_PARTY_SIZE, + types::KeyVisibility, HashingAlgorithm, OcwMessageDkg, X25519PublicKey, NETWORK_PARENT_KEY, + SIGNING_PARTY_SIZE, }; use futures::{ channel::mpsc, @@ -46,7 +47,7 @@ use futures::{ use num::{bigint::BigInt, FromPrimitive, Num, ToPrimitive}; use parity_scale_codec::{Decode, DecodeAll, Encode}; use serde::{Deserialize, Serialize}; -use sp_core::crypto::AccountId32; +use sp_core::{crypto::AccountId32, H256}; use subxt::{ backend::legacy::LegacyRpcMethods, ext::sp_core::{crypto::Ss58Codec, sr25519, sr25519::Signature, Pair}, @@ -142,6 +143,11 @@ pub async fn sign_tx( .number; check_stale(user_sig_req.block_number, block_number).await?; + // Probably impossible but block signing from parent key anyways + if user_sig_req.signature_verifying_key == NETWORK_PARENT_KEY.encode() { + return Err(UserErr::NoSigningFromParentKey); + } + let user_details = get_registered_details(&api, &rpc, user_sig_req.signature_verifying_key.clone()).await?; check_hash_pointer_out_of_bounds(&user_sig_req.hash, user_details.programs_data.0.len())?; @@ -307,7 +313,6 @@ async fn setup_dkg( app_state: AppState, ) -> Result<(), UserErr> { tracing::debug!("Preparing to execute DKG"); - let subgroup = get_subgroup(&api, rpc, signer.account_id()).await?; let stash_address = get_stash_address(&api, rpc, signer.account_id()).await?; let mut addresses_in_subgroup = return_all_addresses_of_subgroup(&api, rpc, subgroup).await?; @@ -325,8 +330,13 @@ async fn setup_dkg( .try_into() .map_err(|_| UserErr::AddressConversionError("Invalid Length".to_string()))?; let sig_request_address = SubxtAccountId32(*address_slice); - let user_details = - get_registering_user_details(&api, &sig_request_address.clone(), rpc).await?; + let key_visibility = if sig_request_account == NETWORK_PARENT_KEY.encode() { + KeyVisibility::Public + } else { + let user_details = + get_registering_user_details(&api, &sig_request_address.clone(), rpc).await?; + user_details.key_visibility.0 + }; let key_share = do_dkg( &data.validators_info, @@ -334,12 +344,18 @@ async fn setup_dkg( x25519_secret_key, &app_state.listener_state, sig_request_address.clone(), - *user_details.key_visibility, + key_visibility, data.block_number, ) .await?; let verifying_key = key_share.verifying_key().to_encoded_point(true).as_bytes().to_vec(); - let string_verifying_key = hex::encode(verifying_key.clone()).to_string(); + let string_verifying_key = if sig_request_account == NETWORK_PARENT_KEY.encode() { + hex::encode(*NETWORK_PARENT_KEY) + } else { + hex::encode(verifying_key.clone()) + } + .to_string(); + let serialized_key_share = key_serialize(&key_share) .map_err(|_| UserErr::KvSerialize("Kv Serialize Error".to_string()))?; @@ -505,12 +521,19 @@ 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_* - let registration_tx = entropy::tx().registry().confirm_register( - who, - subgroup, - entropy::runtime_types::bounded_collections::bounded_vec::BoundedVec(verifying_key), - ); - submit_transaction(api, rpc, signer, ®istration_tx, Some(nonce)).await?; + + if who.encode() == NETWORK_PARENT_KEY.encode() { + let jump_start_request = entropy::tx().registry().confirm_jump_start(subgroup); + submit_transaction(api, rpc, signer, &jump_start_request, Some(nonce)).await?; + } else { + let confirm_register_request = entropy::tx().registry().confirm_register( + who, + subgroup, + entropy::runtime_types::bounded_collections::bounded_vec::BoundedVec(verifying_key), + ); + submit_transaction(api, rpc, signer, &confirm_register_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 8ad8cc04b..b8ea253ee 100644 --- a/crates/threshold-signature-server/src/user/errors.rs +++ b/crates/threshold-signature-server/src/user/errors.rs @@ -151,6 +151,8 @@ pub enum UserErr { EncryptionOrAuthentication(#[from] EncryptedSignedMessageErr), #[error("Custom hash choice out of bounds")] CustomHashOutOfBounds, + #[error("No signing from parent key")] + NoSigningFromParentKey, #[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 b35ced20f..1df50cdee 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -35,6 +35,7 @@ use entropy_protocol::{ use entropy_shared::{ HashingAlgorithm, KeyVisibility, OcwMessageDkg, DAVE_VERIFYING_KEY, DEFAULT_VERIFYING_KEY, DEFAULT_VERIFYING_KEY_NOT_REGISTERED, DEVICE_KEY_HASH, EVE_VERIFYING_KEY, FERDIE_VERIFYING_KEY, + NETWORK_PARENT_KEY, }; use entropy_testing_utils::{ chain_api::{ @@ -362,6 +363,18 @@ async fn test_sign_tx_no_chain() { for res in test_user_custom_hash_out_of_bounds { assert_eq!(res.unwrap().text().await.unwrap(), "Custom hash choice out of bounds"); } + + generic_msg.block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number; + generic_msg.signature_verifying_key = NETWORK_PARENT_KEY.0.to_vec(); + let test_user_sign_with_parent_key = submit_transaction_requests( + vec![validator_ips_and_keys[1].clone()], + generic_msg.clone(), + one, + ) + .await; + for res in test_user_sign_with_parent_key { + assert_eq!(res.unwrap().text().await.unwrap(), "No signing from parent key"); + } clean_tests(); } @@ -774,6 +787,81 @@ async fn test_store_share() { clean_tests(); } +#[tokio::test] +#[serial] +async fn test_jumpstart_network() { + initialize_test_logger().await; + clean_tests(); + + let alice = AccountKeyring::Alice; + + let cxt = test_context_stationary().await; + let (_validator_ips, _validator_ids, _) = + spawn_testing_validators(Some(DEFAULT_VERIFYING_KEY.to_vec()), false, false).await; + let api = get_api(&cxt.node_proc.ws_url).await.unwrap(); + let rpc = get_rpc(&cxt.node_proc.ws_url).await.unwrap(); + + let client = reqwest::Client::new(); + + let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 1; + let validators_info = vec![ + entropy_shared::ValidatorInfo { + ip_address: b"127.0.0.1:3001".to_vec(), + x25519_public_key: X25519_PUBLIC_KEYS[0], + tss_account: TSS_ACCOUNTS[0].clone().encode(), + }, + entropy_shared::ValidatorInfo { + ip_address: b"127.0.0.1:3002".to_vec(), + x25519_public_key: X25519_PUBLIC_KEYS[1], + tss_account: TSS_ACCOUNTS[1].clone().encode(), + }, + ]; + let onchain_user_request = OcwMessageDkg { + sig_request_accounts: vec![H256::zero().encode()], + block_number, + validators_info, + }; + + put_jumpstart_request_on_chain(&api, &rpc, &alice).await; + + run_to_block(&rpc, block_number + 1).await; + + // succeeds + let user_registration_response = client + .post("http://127.0.0.1:3002/user/new") + .body(onchain_user_request.clone().encode()) + .send() + .await + .unwrap(); + + assert_eq!(user_registration_response.text().await.unwrap(), ""); + // wait for jump start event check that key exists in kvdb + for _ in 0..45 { + std::thread::sleep(std::time::Duration::from_millis(1000)); + let block_hash = rpc.chain_get_block_hash(None).await.unwrap(); + let events = EventsClient::new(api.clone()).at(block_hash.unwrap()).await.unwrap(); + let jump_start_event = events.find::(); + for _event in jump_start_event.flatten() { + break; + } + } + + let get_query = UnsafeQuery::new(hex::encode(H256::zero()), [].to_vec()).to_json(); + // check get key before registration to see if key gets replaced + let response_key = client + .post("http://127.0.0.1:3001/unsafe/get") + .header("Content-Type", "application/json") + .body(get_query.clone()) + .send() + .await + .unwrap(); + // check to make sure keyshare is correct + let key_share: Option> = + entropy_kvdb::kv_manager::helpers::deserialize(&response_key.bytes().await.unwrap()); + assert_eq!(key_share.is_some(), true); + clean_tests(); +} + #[tokio::test] #[serial] async fn test_return_addresses_of_subgroup() { @@ -1053,6 +1141,18 @@ pub async fn put_register_request_on_chain( submit_transaction(api, rpc, &sig_req_account, ®istering_tx, None).await.unwrap(); } +pub async fn put_jumpstart_request_on_chain( + api: &OnlineClient, + rpc: &LegacyRpcMethods, + sig_req_keyring: &Sr25519Keyring, +) { + let sig_req_account = + PairSigner::::new(sig_req_keyring.pair()); + + let registering_tx = entropy::tx().registry().jump_start_network(); + submit_transaction(api, rpc, &sig_req_account, ®istering_tx, None).await.unwrap(); +} + #[tokio::test] #[serial] async fn test_sign_tx_user_participates() { diff --git a/pallets/registry/src/benchmarking.rs b/pallets/registry/src/benchmarking.rs index a11ca989f..2654d8afb 100644 --- a/pallets/registry/src/benchmarking.rs +++ b/pallets/registry/src/benchmarking.rs @@ -70,6 +70,67 @@ pub fn add_non_syncing_validators( } benchmarks! { + jump_start_network { + + let sig_req_account: T::AccountId = whitelisted_caller(); + let balance = ::Currency::minimum_balance() * 100u32.into(); + let _ = ::Currency::make_free_balance_be(&sig_req_account, balance); + + }: _(RawOrigin::Signed(sig_req_account.clone())) + verify { + assert_last_event::(Event::StartedNetworkJumpStart().into()); + } + + confirm_jump_start_done { + let c in 0 .. SIG_PARTIES as u32; + let sig_req_account: T::AccountId = whitelisted_caller(); + let validator_account: T::AccountId = whitelisted_caller(); + let threshold_account: T::AccountId = whitelisted_caller(); + + let sig_party_size = MaxValidators::::get() / SIG_PARTIES as u32; + // add validators and a registering user + for i in 0..SIG_PARTIES { + let validators = add_non_syncing_validators::(sig_party_size, 0, i as u8); + >::insert(&threshold_account, &validators[i]); + } + >::put(JumpStartDetails { + jump_start_status: JumpStartStatus::InProgress(0), + confirmations: vec![1], + }); + + + let balance = ::Currency::minimum_balance() * 100u32.into(); + let _ = ::Currency::make_free_balance_be(&threshold_account, balance); + }: confirm_jump_start(RawOrigin::Signed(threshold_account), 0) + verify { + assert_last_event::(Event::::FinishedNetworkJumpStart().into()); + } + + confirm_jump_start_confirm { + let c in 0 .. SIG_PARTIES as u32; + let sig_req_account: T::AccountId = whitelisted_caller(); + let validator_account: T::AccountId = whitelisted_caller(); + let threshold_account: T::AccountId = whitelisted_caller(); + + let sig_party_size = MaxValidators::::get() / SIG_PARTIES as u32; + // add validators and a registering user + for i in 0..SIG_PARTIES { + let validators = add_non_syncing_validators::(sig_party_size, 0, i as u8); + >::insert(&threshold_account, &validators[i]); + } + >::put(JumpStartDetails { + jump_start_status: JumpStartStatus::InProgress(0), + confirmations: vec![], + }); + + + let balance = ::Currency::minimum_balance() * 100u32.into(); + let _ = ::Currency::make_free_balance_be(&threshold_account, balance); + }: confirm_jump_start(RawOrigin::Signed(threshold_account), 0) + verify { + assert_last_event::(Event::::JumpStartConfirmation(0).into()); + } + register { let p in 1 .. T::MaxProgramHashes::get(); let program = vec![0u8]; diff --git a/pallets/registry/src/lib.rs b/pallets/registry/src/lib.rs index 89d731860..25e127e1b 100644 --- a/pallets/registry/src/lib.rs +++ b/pallets/registry/src/lib.rs @@ -53,7 +53,9 @@ pub mod weights; #[frame_support::pallet] pub mod pallet { - use entropy_shared::{KeyVisibility, SIGNING_PARTY_SIZE, VERIFICATION_KEY_LENGTH}; + use entropy_shared::{ + KeyVisibility, NETWORK_PARENT_KEY, SIGNING_PARTY_SIZE, VERIFICATION_KEY_LENGTH, + }; use frame_support::{ dispatch::{DispatchResultWithPostInfo, Pays}, pallet_prelude::*, @@ -71,6 +73,9 @@ pub mod pallet { /// Max modifiable keys allowed for a program modification account pub const MAX_MODIFIABLE_KEYS: u32 = 25; + /// Blocks to wait until we agree jump start network failed and to allow a retry + pub const BLOCKS_TO_RESTART_JUMP_START: u32 = 50; + /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] pub trait Config: @@ -120,6 +125,13 @@ pub mod pallet { pub program_modification_account: T::AccountId, pub version_number: u8, } + /// Details of status of jump starting the network + #[derive(Clone, Encode, Decode, Eq, PartialEqNoBound, RuntimeDebug, TypeInfo, Default)] + #[scale_info(skip_type_params(T))] + pub struct JumpStartDetails { + pub jump_start_status: JumpStartStatus, + pub confirmations: Vec, + } #[pallet::genesis_config] #[derive(frame_support::DefaultNoBound)] @@ -128,6 +140,17 @@ pub mod pallet { pub registered_accounts: Vec<(T::AccountId, u8, Option<[u8; 32]>, VerifyingKey)>, } + #[derive( + Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen, Default, + )] + pub enum JumpStartStatus { + #[default] + Ready, + // u32 is block number process was started, after X blocks we assume failed and retry + InProgress(u32), + Done, + } + #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig { fn build(&self) { @@ -182,11 +205,22 @@ pub mod pallet { ValueQuery, >; + /// A concept of what progress status the jumpstart is + #[pallet::storage] + #[pallet::getter(fn jump_start_progress)] + pub type JumpStartProgress = StorageValue<_, JumpStartDetails, ValueQuery>; + // Pallets use events to inform users when important changes are made. // https://substrate.dev/docs/en/knowledgebase/runtime/events #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { + /// The network has been jump started. + StartedNetworkJumpStart(), + /// The network has been jump started successfully. + FinishedNetworkJumpStart(), + /// The network has had a jump start confirmation. [signing_subgroup] + JumpStartConfirmation(u8), /// An account has signaled to be registered. [signature request account] SignalRegister(T::AccountId), /// An account has been registered. [who, signing_group, verifying_key] @@ -225,10 +259,109 @@ pub mod pallet { NoProgramSet, TooManyModifiableKeys, MismatchedVerifyingKeyLength, + JumpStartProgressNotReady, + JumpStartNotInProgress, + NoRegisteringFromParentKey, } + /// Allows anyone to create a parent key for the network if the network is read and a parent key + /// does not exist #[pallet::call] impl Pallet { + #[pallet::call_index(0)] + #[pallet::weight({ + ::WeightInfo::jump_start_network() + })] + pub fn jump_start_network(origin: OriginFor) -> DispatchResult { + let _who = ensure_signed(origin)?; + let current_block_number = >::block_number(); + let converted_block_number: u32 = + BlockNumberFor::::try_into(current_block_number).unwrap_or_default(); + + // make sure jumpstart is ready, or in progress but X amount of time has passed + match JumpStartProgress::::get().jump_start_status { + JumpStartStatus::Ready => (), + JumpStartStatus::InProgress(started_block_number) => { + if converted_block_number.saturating_sub(started_block_number) + < BLOCKS_TO_RESTART_JUMP_START + { + return Err(Error::::JumpStartProgressNotReady.into()); + }; + }, + _ => return Err(Error::::JumpStartProgressNotReady.into()), + }; + // TODO (#923): Add checks for network state. + Dkg::::try_mutate(current_block_number, |messages| -> Result<_, DispatchError> { + messages.push(NETWORK_PARENT_KEY.clone().encode()); + Ok(()) + })?; + JumpStartProgress::::put(JumpStartDetails { + jump_start_status: JumpStartStatus::InProgress(converted_block_number), + confirmations: vec![], + }); + Self::deposit_event(Event::StartedNetworkJumpStart()); + Ok(()) + } + + /// Allows validators to signal a successful network jumpstart + #[pallet::call_index(1)] + #[pallet::weight({ + ::WeightInfo::confirm_jump_start_confirm(SIGNING_PARTY_SIZE as u32) + .max(::WeightInfo::confirm_jump_start_done(SIGNING_PARTY_SIZE as u32)) + })] + pub fn confirm_jump_start( + origin: OriginFor, + signing_subgroup: u8, + ) -> DispatchResultWithPostInfo { + // check is validator + let ts_server_account = ensure_signed(origin)?; + let validator_stash = + pallet_staking_extension::Pallet::::threshold_to_stash(&ts_server_account) + .ok_or(Error::::NoThresholdKey)?; + let validator_subgroup = + pallet_staking_extension::Pallet::::validator_to_subgroup(&validator_stash) + .ok_or(Error::::SigningGroupError)?; + ensure!(validator_subgroup == signing_subgroup, Error::::NotInSigningGroup); + let mut jump_start_info = JumpStartProgress::::get(); + // check in progress + ensure!( + matches!(jump_start_info.jump_start_status, JumpStartStatus::InProgress(_)), + Error::::JumpStartNotInProgress + ); + + ensure!( + !jump_start_info.confirmations.contains(&signing_subgroup), + Error::::AlreadyConfirmed + ); + let confirmation_length = jump_start_info.confirmations.len() as u32; + + // TODO (#927): Add another check, such as a signature or a verifying key comparison, to + // ensure that registration was indeed successful. + // + // If it fails we'll need to allow another jumpstart. + if jump_start_info.confirmations.len() == T::SigningPartySize::get() - 1 { + // registration finished, lock call + JumpStartProgress::::put(JumpStartDetails { + jump_start_status: JumpStartStatus::Done, + confirmations: vec![], + }); + Self::deposit_event(Event::FinishedNetworkJumpStart()); + return Ok(Some(::WeightInfo::confirm_jump_start_done( + confirmation_length, + )) + .into()); + } else { + // Add confirmation wait for next one + jump_start_info.confirmations.push(signing_subgroup); + JumpStartProgress::::put(jump_start_info); + Self::deposit_event(Event::JumpStartConfirmation(signing_subgroup)); + return Ok(Some(::WeightInfo::confirm_jump_start_confirm( + 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. @@ -236,7 +369,7 @@ pub mod pallet { /// Note that a user needs to be confirmed by validators through the /// [`Self::confirm_register`] extrinsic before they can be considered as registered on the /// network. - #[pallet::call_index(0)] + #[pallet::call_index(2)] #[pallet::weight({ ::WeightInfo::register( ::MaxProgramHashes::get()) })] @@ -247,7 +380,11 @@ 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(), + Error::::NoRegisteringFromParentKey + ); ensure!( !Registering::::contains_key(&sig_req_account), Error::::AlreadySubmitted @@ -270,7 +407,7 @@ pub mod pallet { } Dkg::::try_mutate(block_number, |messages| -> Result<_, DispatchError> { - messages.push(sig_req_account.clone().encode()); + messages.push(encoded_sig_req_account); Ok(()) })?; @@ -292,7 +429,7 @@ pub mod pallet { } /// Allows a user to remove themselves from registering state if it has been longer than prune block - #[pallet::call_index(1)] + #[pallet::call_index(3)] #[pallet::weight({ ::WeightInfo::prune_registration(::MaxProgramHashes::get()) })] @@ -316,7 +453,7 @@ pub mod pallet { } /// Allows a user's program modification account to change their program pointer - #[pallet::call_index(2)] + #[pallet::call_index(4)] #[pallet::weight({ ::WeightInfo::change_program_instance(::MaxProgramHashes::get(), ::MaxProgramHashes::get()) })] @@ -377,7 +514,7 @@ pub mod pallet { } /// Allows a user's program modification account to change itself. - #[pallet::call_index(3)] + #[pallet::call_index(5)] #[pallet::weight({ ::WeightInfo::change_program_modification_account(MAX_MODIFIABLE_KEYS) })] @@ -436,7 +573,7 @@ pub mod pallet { /// /// After a validator from each partition confirms they have a keyshare the user will be /// considered as registered on the network. - #[pallet::call_index(4)] + #[pallet::call_index(6)] #[pallet::weight({ let weight = ::WeightInfo::confirm_register_registering(SIGNING_PARTY_SIZE as u32) diff --git a/pallets/registry/src/tests.rs b/pallets/registry/src/tests.rs index 45602c655..a3ad523a2 100644 --- a/pallets/registry/src/tests.rs +++ b/pallets/registry/src/tests.rs @@ -23,6 +23,7 @@ use frame_support::{ }; use pallet_programs::ProgramInfo; use pallet_registry::Call as RegistryCall; +use sp_core::H256; use sp_runtime::{ traits::{Hash, SignedExtension}, transaction_validity::{TransactionValidity, ValidTransaction}, @@ -30,8 +31,8 @@ use sp_runtime::{ use crate as pallet_registry; use crate::{ - mock::*, Error, ModifiableKeys, ProgramInstance, Registered, RegisteredInfo, - RegisteringDetails, ValidateConfirmRegistered, + mock::*, Error, JumpStartDetails, JumpStartStatus, ModifiableKeys, ProgramInstance, Registered, + RegisteredInfo, RegisteringDetails, ValidateConfirmRegistered, }; #[test] @@ -141,6 +142,92 @@ fn it_registers_a_user() { }); } +#[test] +fn it_jumps_the_network() { + new_test_ext().execute_with(|| { + assert_eq!( + Registry::jump_start_progress(), + JumpStartDetails { jump_start_status: JumpStartStatus::Ready, confirmations: vec![] }, + "Checks default status of jump start detail" + ); + assert_ok!(Registry::jump_start_network(RuntimeOrigin::signed(1))); + assert_eq!( + Registry::dkg(0), + vec![H256::zero().encode()], + "ensures a dkg message for the jump start network is prepped" + ); + assert_eq!( + Registry::jump_start_progress(), + JumpStartDetails { + jump_start_status: JumpStartStatus::InProgress(0), + confirmations: vec![] + }, + "Checks that jump start is in progress" + ); + + assert_noop!( + Registry::jump_start_network(RuntimeOrigin::signed(1)), + Error::::JumpStartProgressNotReady + ); + + System::set_block_number(100); + + assert_ok!(Registry::jump_start_network(RuntimeOrigin::signed(1))); + assert_eq!( + Registry::jump_start_progress(), + JumpStartDetails { + jump_start_status: JumpStartStatus::InProgress(100), + confirmations: vec![] + }, + "ensures jump start is called again if too many blocks passed" + ); + }); +} + +#[test] +fn it_tests_jump_start_result() { + new_test_ext().execute_with(|| { + assert_noop!( + Registry::confirm_jump_start(RuntimeOrigin::signed(1), 0,), + Error::::NoThresholdKey + ); + pallet_staking_extension::ThresholdToStash::::insert(1, 1); + assert_noop!( + Registry::confirm_jump_start(RuntimeOrigin::signed(1), 3,), + Error::::NotInSigningGroup + ); + + assert_noop!( + Registry::confirm_jump_start(RuntimeOrigin::signed(1), 0,), + Error::::JumpStartNotInProgress + ); + // trigger jump start + assert_ok!(Registry::jump_start_network(RuntimeOrigin::signed(1))); + + assert_ok!(Registry::confirm_jump_start(RuntimeOrigin::signed(1), 0,)); + assert_eq!( + Registry::jump_start_progress(), + JumpStartDetails { + jump_start_status: JumpStartStatus::InProgress(0), + confirmations: vec![0] + }, + "Jump start recieves a confirmation" + ); + assert_noop!( + Registry::confirm_jump_start(RuntimeOrigin::signed(1), 0,), + Error::::AlreadyConfirmed + ); + + pallet_staking_extension::ThresholdToStash::::insert(2, 2); + assert_ok!(Registry::confirm_jump_start(RuntimeOrigin::signed(2), 1,)); + assert_eq!( + Registry::jump_start_progress(), + JumpStartDetails { jump_start_status: JumpStartStatus::Done, confirmations: vec![] }, + "Jump start in done status after all confirmations" + ); + }); +} + #[test] fn it_confirms_registers_a_user() { new_test_ext().execute_with(|| { diff --git a/pallets/registry/src/weights.rs b/pallets/registry/src/weights.rs index d938ce141..d3d5eb3a0 100644 --- a/pallets/registry/src/weights.rs +++ b/pallets/registry/src/weights.rs @@ -52,7 +52,10 @@ use core::marker::PhantomData; /// Weight functions needed for pallet_registry. pub trait WeightInfo { fn register(p: u32) -> Weight; + fn jump_start_network() -> Weight; fn prune_registration(p: u32) -> Weight; + fn confirm_jump_start_done(c: u32, ) -> Weight; + 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; @@ -63,6 +66,54 @@ pub trait WeightInfo { /// Weights for pallet_registry using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + /// 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`) + 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)) + .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: `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 { + // 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)) + .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: `StakingExtension::ValidatorToSubgroup` (r:1 w:0) + /// Proof: `StakingExtension::ValidatorToSubgroup` (`max_values`: None, `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_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)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// Storage: `Registry::Registered` (r:1 w:0) /// Proof: `Registry::Registered` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Registry::Registering` (r:1 w:1) @@ -192,6 +243,54 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { + /// 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`) + 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)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::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: `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 { + // 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)) + .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: `StakingExtension::ValidatorToSubgroup` (r:1 w:0) + /// Proof: `StakingExtension::ValidatorToSubgroup` (`max_values`: None, `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_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)) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(1)) + } /// Storage: `Registry::Registered` (r:1 w:0) /// Proof: `Registry::Registered` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `Registry::Registering` (r:1 w:1) diff --git a/runtime/src/weights/pallet_registry.rs b/runtime/src/weights/pallet_registry.rs index 7dcaff50b..fdfafcc0d 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-06-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-07-02, STEPS: `5`, REPEAT: `2`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `ip-172-31-30-92`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! HOSTNAME: `Jesses-MacBook-Pro.local`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: 1024 // Executed Command: @@ -27,14 +27,11 @@ // pallet // --chain // dev -// --wasm-execution=compiled // --pallet=pallet_registry // --extrinsic=* -// --steps=50 -// --repeat=20 +// --steps=5 +// --repeat=2 // --header=.maintain/AGPL-3.0-header.txt -// --template -// .maintain/frame-weight-template.hbs // --output=./runtime/src/weights/ #![cfg_attr(rustfmt, rustfmt_skip)] @@ -48,6 +45,54 @@ use core::marker::PhantomData; /// Weight functions for `pallet_registry`. 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`) + 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)) + .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: `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 { + // 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)) + .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: `StakingExtension::ValidatorToSubgroup` (r:1 w:0) + /// Proof: `StakingExtension::ValidatorToSubgroup` (`max_values`: None, `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_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)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } /// 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) @@ -59,11 +104,11 @@ impl pallet_registry::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `358` // Estimated: `3823` - // Minimum execution time: 29_930_000 picoseconds. - Weight::from_parts(28_365_544, 0) + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(17_750_000, 0) .saturating_add(Weight::from_parts(0, 3823)) - // Standard Error: 19_514 - .saturating_add(Weight::from_parts(3_396_308, 0).saturating_mul(p.into())) + // Standard Error: 1_234_022 + .saturating_add(Weight::from_parts(1_650_000, 0).saturating_mul(p.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -76,8 +121,8 @@ impl pallet_registry::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `480` // Estimated: `3945` - // Minimum execution time: 24_789_000 picoseconds. - Weight::from_parts(26_434_446, 0) + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(14_400_000, 0) .saturating_add(Weight::from_parts(0, 3945)) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) @@ -92,13 +137,13 @@ impl pallet_registry::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `614 + o * (33 ±0)` // Estimated: `6554 + o * (33 ±0)` - // Minimum execution time: 46_291_000 picoseconds. - Weight::from_parts(30_446_027, 0) + // Minimum execution time: 28_000_000 picoseconds. + Weight::from_parts(16_750_000, 0) .saturating_add(Weight::from_parts(0, 6554)) - // Standard Error: 15_100 - .saturating_add(Weight::from_parts(3_152_333, 0).saturating_mul(n.into())) - // Standard Error: 15_100 - .saturating_add(Weight::from_parts(3_119_817, 0).saturating_mul(o.into())) + // 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())) .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())) @@ -112,11 +157,11 @@ impl pallet_registry::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `328 + n * (1 ±0)` // Estimated: `3793 + n * (1 ±0)` - // Minimum execution time: 24_730_000 picoseconds. - Weight::from_parts(25_894_755, 0) + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(14_041_666, 0) .saturating_add(Weight::from_parts(0, 3793)) - // Standard Error: 2_341 - .saturating_add(Weight::from_parts(124_314, 0).saturating_mul(n.into())) + // Standard Error: 23_385 + .saturating_add(Weight::from_parts(58_333, 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())) @@ -128,15 +173,13 @@ impl pallet_registry::WeightInfo for WeightInfo { /// 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 { + fn confirm_register_registering(_c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1410` // Estimated: `4875` - // Minimum execution time: 54_176_000 picoseconds. - Weight::from_parts(64_871_111, 0) + // Minimum execution time: 19_000_000 picoseconds. + Weight::from_parts(20_416_666, 0) .saturating_add(Weight::from_parts(0, 4875)) - // Standard Error: 139_174 - .saturating_add(Weight::from_parts(79_239, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -147,13 +190,15 @@ impl pallet_registry::WeightInfo for WeightInfo { /// 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_failed_registering(_c: u32, ) -> Weight { + fn confirm_register_failed_registering(c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1412` // Estimated: `4877` - // Minimum execution time: 44_489_000 picoseconds. - Weight::from_parts(55_668_233, 0) + // 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())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -168,16 +213,14 @@ impl pallet_registry::WeightInfo for WeightInfo { /// 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 { + fn confirm_register_registered(_c: u32, ) -> Weight { // Proof Size summary in bytes: // Measured: `1436` // Estimated: `4901` - // Minimum execution time: 58_863_000 picoseconds. - Weight::from_parts(72_236_977, 0) + // Minimum execution time: 25_000_000 picoseconds. + Weight::from_parts(26_916_666, 0) .saturating_add(Weight::from_parts(0, 4901)) - // Standard Error: 195_299 - .saturating_add(Weight::from_parts(756_574, 0).saturating_mul(c.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } -} \ No newline at end of file +}