From 340518fc15b627b1178f3c4ba178eaa3d1a54acf Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 16:37:26 -0500 Subject: [PATCH 1/9] change to program deploy key --- crates/test-cli/src/main.rs | 2 +- crates/testing-utils/src/test_client/mod.rs | 10 +++--- .../entropy_metadata.scale | Bin 193522 -> 193522 bytes .../src/helpers/tests.rs | 10 +++--- .../src/user/tests.rs | 8 ++--- .../tests/protocol_wasm.rs | 4 +-- pallets/programs/src/benchmarking.rs | 20 +++++------ pallets/programs/src/lib.rs | 31 +++++++++--------- pallets/programs/src/tests.rs | 6 ++-- pallets/propagation/src/tests.rs | 2 +- pallets/relayer/src/benchmarking.rs | 26 +++++++-------- pallets/relayer/src/lib.rs | 14 ++++---- pallets/relayer/src/tests.rs | 28 ++++++++-------- 13 files changed, 81 insertions(+), 80 deletions(-) diff --git a/crates/test-cli/src/main.rs b/crates/test-cli/src/main.rs index 3a7d2f00c..ec9b0fa6a 100644 --- a/crates/test-cli/src/main.rs +++ b/crates/test-cli/src/main.rs @@ -368,7 +368,7 @@ async fn run_command() -> anyhow::Result { println!( "{} {} {:>11} {:>14} {}", hash, - program_info.program_modification_account, + program_info.program_deploy_key, program_info.ref_counter, program_info.bytecode.len(), !program_info.configuration_interface.is_empty(), diff --git a/crates/testing-utils/src/test_client/mod.rs b/crates/testing-utils/src/test_client/mod.rs index 9eb2ea54c..3239f415e 100644 --- a/crates/testing-utils/src/test_client/mod.rs +++ b/crates/testing-utils/src/test_client/mod.rs @@ -248,7 +248,7 @@ pub async fn sign( skip_all, fields( signature_request_account, - program_modification_account = ?program_modification_keypair.public(), + program_deploy_key = ?program_modification_keypair.public(), ) )] pub async fn store_program( @@ -258,12 +258,12 @@ pub async fn store_program( configuration_interface: Vec, ) -> anyhow::Result<::Hash> { let update_program_tx = entropy::tx().programs().set_program(program, configuration_interface); - let program_modification_account = + let program_deploy_key = PairSigner::::new(program_modification_keypair.clone()); let in_block = api .tx() - .sign_and_submit_then_watch_default(&update_program_tx, &program_modification_account) + .sign_and_submit_then_watch_default(&update_program_tx, &program_deploy_key) .await? .wait_for_in_block() .await? @@ -357,7 +357,7 @@ pub async fn put_register_request_on_chain( api: &OnlineClient, rpc: &LegacyRpcMethods, signature_request_keypair: sr25519::Pair, - program_modification_account: SubxtAccountId32, + program_deploy_key: SubxtAccountId32, key_visibility: KeyVisibility, program_instance: BoundedVec, ) -> anyhow::Result<()> { @@ -368,7 +368,7 @@ pub async fn put_register_request_on_chain( PairSigner::::new(signature_request_keypair); let registering_tx = entropy::tx().relayer().register( - program_modification_account, + program_deploy_key, Static(key_visibility), program_instance, ); diff --git a/crates/threshold-signature-server/entropy_metadata.scale b/crates/threshold-signature-server/entropy_metadata.scale index 74bae0350185d8aa1161be6deeb7ad16202126fa..84ceef319cf7fd864ec4b3199b6a296f9058cf70 100644 GIT binary patch delta 289 zcmezLocq&r?hP!x!X5=h`RPT8x$!Bf1v&YZ@!6@BlNEb^;t;pkoZqLg2%F^gH3p2& zr(>1baDwp}BUYKsrx@R3m1*C9hH?A;Gfd1J*&HVnf=lv?Qi~NzGEx, rpc: &LegacyRpcMethods, - program_modification_account: &sr25519::Pair, + program_deploy_key: &sr25519::Pair, program_hash: ::Hash, ) { // update/set their programs let remove_program_tx = entropy::tx().programs().remove_program(program_hash); - let account_id32: AccountId32 = program_modification_account.public().into(); + let account_id32: AccountId32 = program_deploy_key.public().into(); let account_id: ::AccountId = account_id32.into(); - let program_modification_account = - PairSigner::::new(program_modification_account.clone()); + let program_deploy_key = + PairSigner::::new(program_deploy_key.clone()); let block_hash = rpc.chain_get_block_hash(None).await.unwrap().unwrap(); let nonce_call = entropy::apis().account_nonce_api().account_nonce(account_id.clone()); @@ -203,7 +203,7 @@ pub async fn remove_program( .create_partial_signed_with_nonce(&remove_program_tx, nonce.into(), Default::default()) .unwrap(); let signer_payload = partial_tx.signer_payload(); - let signature = program_modification_account.sign(&signer_payload); + let signature = program_deploy_key.sign(&signer_payload); let tx = partial_tx.sign_with_address_and_signature(&account_id.into(), &signature); tx.submit_and_watch() diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index 2047bb9d3..e36f9f58e 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -787,7 +787,7 @@ async fn test_recover_key() { pub async fn put_register_request_on_chain( api: &OnlineClient, sig_req_keyring: &Sr25519Keyring, - program_modification_account: subxtAccountId32, + program_deploy_key: subxtAccountId32, key_visibility: KeyVisibility, program_instance: BoundedVec, ) { @@ -795,7 +795,7 @@ pub async fn put_register_request_on_chain( PairSigner::::new(sig_req_keyring.pair()); let registering_tx = entropy::tx().relayer().register( - program_modification_account, + program_deploy_key, Static(key_visibility), program_instance, ); @@ -1105,7 +1105,7 @@ async fn test_register_with_private_key_visibility() { clean_tests(); let one = AccountKeyring::One; - let program_modification_account = AccountKeyring::Charlie; + let program_deploy_key = AccountKeyring::Charlie; let program_manager = AccountKeyring::Dave; let (validator_ips, _validator_ids, _users_keyshare_option) = @@ -1127,7 +1127,7 @@ async fn test_register_with_private_key_visibility() { put_register_request_on_chain( &api, &one, - program_modification_account.to_account_id().into(), + program_deploy_key.to_account_id().into(), KeyVisibility::Private(x25519_public_key), BoundedVec(vec![ProgramInstance { program_pointer: program_hash, program_config: vec![] }]), ) diff --git a/crates/threshold-signature-server/tests/protocol_wasm.rs b/crates/threshold-signature-server/tests/protocol_wasm.rs index d04aa1e46..3e97f3ea7 100644 --- a/crates/threshold-signature-server/tests/protocol_wasm.rs +++ b/crates/threshold-signature-server/tests/protocol_wasm.rs @@ -203,7 +203,7 @@ async fn test_wasm_register_with_private_key_visibility() { clean_tests(); let one = AccountKeyring::One; - let program_modification_account = AccountKeyring::Charlie; + let program_deploy_key = AccountKeyring::Charlie; let dave = AccountKeyring::Dave; let (validator_ips, _validator_ids, _users_keyshare_option) = @@ -225,7 +225,7 @@ async fn test_wasm_register_with_private_key_visibility() { &api, &rpc, one.pair(), - program_modification_account.to_account_id().into(), + program_deploy_key.to_account_id().into(), KeyVisibility::Private(x25519_public_key), BoundedVec(vec![ProgramInstance { program_pointer, program_config: vec![] }]), ) diff --git a/pallets/programs/src/benchmarking.rs b/pallets/programs/src/benchmarking.rs index fe34213dd..07c909696 100644 --- a/pallets/programs/src/benchmarking.rs +++ b/pallets/programs/src/benchmarking.rs @@ -48,17 +48,17 @@ benchmarks! { hash_input.extend(&configuration_interface); let program_hash = T::Hashing::hash(&hash_input); - let program_modification_account: T::AccountId = whitelisted_caller(); + let program_deploy_key: T::AccountId = whitelisted_caller(); let sig_req_account: T::AccountId = whitelisted_caller(); let value = CurrencyOf::::minimum_balance().saturating_mul(1_000_000_000u32.into()); - let _ = CurrencyOf::::make_free_balance_be(&program_modification_account, value); + let _ = CurrencyOf::::make_free_balance_be(&program_deploy_key, value); - }: _(RawOrigin::Signed(program_modification_account.clone()), program.clone(), configuration_interface.clone()) + }: _(RawOrigin::Signed(program_deploy_key.clone()), program.clone(), configuration_interface.clone()) verify { assert_last_event::( Event::::ProgramCreated { - program_modification_account, + program_deploy_key, program_hash, configuration_interface }.into() @@ -76,23 +76,23 @@ benchmarks! { let program_hash = T::Hashing::hash(&hash_input); let random_program = vec![11]; let random_hash = T::Hashing::hash(&random_program); - let program_modification_account: T::AccountId = whitelisted_caller(); + let program_deploy_key: T::AccountId = whitelisted_caller(); let value = CurrencyOf::::minimum_balance().saturating_mul(1_000_000_000u32.into()); - let _ = CurrencyOf::::make_free_balance_be(&program_modification_account, value); - >::insert(program_hash.clone(), ProgramInfo {bytecode: program, configuration_interface, program_modification_account: program_modification_account.clone(), ref_counter: 0u128}); + let _ = CurrencyOf::::make_free_balance_be(&program_deploy_key, value); + >::insert(program_hash.clone(), ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: 0u128}); let mut program_hashes = vec![random_hash.clone(); p as usize]; // remove one to make room for the targetted removal program hash program_hashes.pop(); program_hashes.push(program_hash); let bounded_program_hashes: BoundedVec = BoundedVec::try_from(program_hashes).unwrap(); - >::insert(program_modification_account.clone(), bounded_program_hashes); - }: _(RawOrigin::Signed(program_modification_account.clone()), program_hash.clone()) + >::insert(program_deploy_key.clone(), bounded_program_hashes); + }: _(RawOrigin::Signed(program_deploy_key.clone()), program_hash.clone()) verify { assert_last_event::( Event::::ProgramRemoved { - program_modification_account, + program_deploy_key, old_program_hash: program_hash }.into() ); diff --git a/pallets/programs/src/lib.rs b/pallets/programs/src/lib.rs index 1b869e308..759da20c8 100644 --- a/pallets/programs/src/lib.rs +++ b/pallets/programs/src/lib.rs @@ -90,7 +90,7 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(_); - /// Information on the program, the bytecode and the account allowed to modify it + /// Information on the program #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct ProgramInfo { /// The bytecode of the program. @@ -98,12 +98,13 @@ pub mod pallet { /// The type definition of the program pub configuration_interface: Vec, /// Owners of the program - pub program_modification_account: AccountId, + pub program_deploy_key: AccountId, /// Accounts that use this program pub ref_counter: u128, } - /// Stores the program bytecode for a given signature-request account. + /// Stores the program info for a given program hash. + /// A program hash is a combination of the bytecode and configuration_interface #[pallet::storage] #[pallet::getter(fn programs)] pub type Programs = @@ -126,7 +127,7 @@ pub mod pallet { /// The bytecode of a program was created. ProgramCreated { /// The program modification account which updated the program. - program_modification_account: T::AccountId, + program_deploy_key: T::AccountId, /// The new program hash. program_hash: T::Hash, @@ -137,7 +138,7 @@ pub mod pallet { /// The bytecode of a program was removed. ProgramRemoved { /// The program modification account which removed the program. - program_modification_account: T::AccountId, + program_deploy_key: T::AccountId, /// The hash of the removed program. old_program_hash: T::Hash, @@ -172,7 +173,7 @@ pub mod pallet { new_program: Vec, configuration_interface: Vec, ) -> DispatchResult { - let program_modification_account = ensure_signed(origin)?; + let program_deploy_key = ensure_signed(origin)?; let mut hash_input = vec![]; hash_input.extend(&new_program); hash_input.extend(&configuration_interface); @@ -184,19 +185,19 @@ pub mod pallet { ); ensure!(!Programs::::contains_key(program_hash), Error::::ProgramAlreadySet); - Self::reserve_program_deposit(&program_modification_account, new_program_length)?; + Self::reserve_program_deposit(&program_deploy_key, new_program_length)?; Programs::::insert( program_hash, &ProgramInfo { bytecode: new_program.clone(), configuration_interface: configuration_interface.clone(), - program_modification_account: program_modification_account.clone(), + program_deploy_key: program_deploy_key.clone(), ref_counter: 0u128, }, ); OwnedPrograms::::try_mutate( - &program_modification_account, + &program_deploy_key, |owned_programs| -> Result<(), DispatchError> { owned_programs .try_push(program_hash) @@ -205,7 +206,7 @@ pub mod pallet { }, )?; Self::deposit_event(Event::ProgramCreated { - program_modification_account, + program_deploy_key, program_hash, configuration_interface, }); @@ -221,21 +222,21 @@ pub mod pallet { origin: OriginFor, program_hash: T::Hash, ) -> DispatchResultWithPostInfo { - let program_modification_account = ensure_signed(origin)?; + let program_deploy_key = ensure_signed(origin)?; let old_program_info = Self::programs(program_hash).ok_or(Error::::NoProgramDefined)?; ensure!( - old_program_info.program_modification_account == program_modification_account, + old_program_info.program_deploy_key == program_deploy_key, Error::::NotAuthorized ); ensure!(old_program_info.ref_counter == 0, Error::::ProgramInUse); Self::unreserve_program_deposit( - &old_program_info.program_modification_account, + &old_program_info.program_deploy_key, old_program_info.bytecode.len() + old_program_info.configuration_interface.len(), ); let mut owned_programs_length = 0; OwnedPrograms::::try_mutate( - &program_modification_account, + &program_deploy_key, |owned_programs| -> Result<(), DispatchError> { owned_programs_length = owned_programs.len(); let pos = owned_programs @@ -248,7 +249,7 @@ pub mod pallet { )?; Programs::::remove(program_hash); Self::deposit_event(Event::ProgramRemoved { - program_modification_account, + program_deploy_key, old_program_hash: program_hash, }); Ok(Some(::WeightInfo::remove_program(owned_programs_length as u32)).into()) diff --git a/pallets/programs/src/tests.rs b/pallets/programs/src/tests.rs index f85c7d1d4..0f7b9df30 100644 --- a/pallets/programs/src/tests.rs +++ b/pallets/programs/src/tests.rs @@ -54,7 +54,7 @@ fn set_program() { let program_result = ProgramInfo { bytecode: program.clone(), configuration_interface: configuration_interface.clone(), - program_modification_account: PROGRAM_MODIFICATION_ACCOUNT, + program_deploy_key: PROGRAM_MODIFICATION_ACCOUNT, ref_counter: 0u128, }; assert_eq!( @@ -139,7 +139,7 @@ fn remove_program() { "Program bytecode gets set" ); assert_eq!( - ProgramsPallet::programs(program_hash).unwrap().program_modification_account, + ProgramsPallet::programs(program_hash).unwrap().program_deploy_key, PROGRAM_MODIFICATION_ACCOUNT, "Program modification account gets set" ); @@ -178,7 +178,7 @@ fn remove_program_fails_ref_count() { ProgramInfo { bytecode: program, configuration_interface, - program_modification_account: PROGRAM_MODIFICATION_ACCOUNT, + program_deploy_key: PROGRAM_MODIFICATION_ACCOUNT, ref_counter: 1u128, }, ); diff --git a/pallets/propagation/src/tests.rs b/pallets/propagation/src/tests.rs index 50b115a78..c50b32b75 100644 --- a/pallets/propagation/src/tests.rs +++ b/pallets/propagation/src/tests.rs @@ -82,7 +82,7 @@ fn knows_how_to_mock_several_http_calls() { ProgramInfo { bytecode: vec![], configuration_interface: vec![], - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); diff --git a/pallets/relayer/src/benchmarking.rs b/pallets/relayer/src/benchmarking.rs index 409bf4bb1..fc558d8a9 100644 --- a/pallets/relayer/src/benchmarking.rs +++ b/pallets/relayer/src/benchmarking.rs @@ -80,12 +80,12 @@ benchmarks! { }; p as usize]) .unwrap(); - let program_modification_account: T::AccountId = whitelisted_caller(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_modification_account: program_modification_account.clone(), ref_counter: 0}); + let program_deploy_key: T::AccountId = whitelisted_caller(); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: 0}); 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()), program_modification_account, KeyVisibility::Public, programs_info) + }: _(RawOrigin::Signed(sig_req_account.clone()), program_deploy_key, KeyVisibility::Public, programs_info) verify { assert_last_event::(Event::SignalRegister(sig_req_account.clone()).into()); assert!(Registering::::contains_key(sig_req_account)); @@ -93,7 +93,7 @@ benchmarks! { prune_registration { let p in 1 .. T::MaxProgramHashes::get(); - let program_modification_account: T::AccountId = whitelisted_caller(); + let program_deploy_key: T::AccountId = whitelisted_caller(); let program = vec![0u8]; let configuration_interface = vec![1u8]; let program_hash = T::Hashing::hash(&program); @@ -101,12 +101,12 @@ benchmarks! { program_pointer: program_hash, program_config: vec![], }]).unwrap(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_modification_account: program_modification_account.clone(), ref_counter: 1}); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: 1}); 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); >::insert(&sig_req_account, RegisteringDetails:: { - program_modification_account: sig_req_account.clone(), + program_deploy_key: sig_req_account.clone(), confirmations: vec![], programs_data: programs_info, key_visibility: KeyVisibility::Public, @@ -121,7 +121,7 @@ benchmarks! { let n in 1 .. T::MaxProgramHashes::get(); let o in 1 .. T::MaxProgramHashes::get(); - let program_modification_account: T::AccountId = whitelisted_caller(); + let program_deploy_key: T::AccountId = whitelisted_caller(); let program = vec![0u8]; let configuration_interface = vec![1u8]; let program_hash = T::Hashing::hash(&program); @@ -138,14 +138,14 @@ benchmarks! { }; n as usize]) .unwrap(); let sig_req_account: T::AccountId = whitelisted_caller(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface: configuration_interface.clone(), program_modification_account: program_modification_account.clone(), ref_counter: 0}); - Programs::::insert(new_program_hash, ProgramInfo {bytecode: new_program, configuration_interface, program_modification_account: program_modification_account.clone(), ref_counter: o as u128}); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface: configuration_interface.clone(), program_deploy_key: program_deploy_key.clone(), ref_counter: 0}); + Programs::::insert(new_program_hash, ProgramInfo {bytecode: new_program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: o as u128}); let balance = ::Currency::minimum_balance() * 100u32.into(); let _ = ::Currency::make_free_balance_be(&sig_req_account, balance); >::insert( &sig_req_account, RegisteredInfo { - program_modification_account: sig_req_account.clone(), + program_deploy_key: sig_req_account.clone(), programs_data: programs_info, verifying_key: BoundedVec::default(), key_visibility: KeyVisibility::Public, @@ -177,7 +177,7 @@ benchmarks! { } >::insert(&sig_req_account, RegisteringDetails:: { - program_modification_account: sig_req_account.clone(), + program_deploy_key: sig_req_account.clone(), confirmations: vec![], programs_data: programs_info, key_visibility: KeyVisibility::Public, @@ -213,7 +213,7 @@ benchmarks! { let adjusted_sig_size = SIG_PARTIES - 1; let confirmation: Vec = (1u8..=adjusted_sig_size.try_into().unwrap()).collect(); >::insert(&sig_req_account, RegisteringDetails:: { - program_modification_account: sig_req_account.clone(), + program_deploy_key: sig_req_account.clone(), confirmations: confirmation, programs_data: programs_info, key_visibility: KeyVisibility::Public, @@ -248,7 +248,7 @@ confirm_register_registered { let adjusted_sig_size = SIG_PARTIES - 1; let confirmation: Vec = (1u8..=adjusted_sig_size.try_into().unwrap()).collect(); >::insert(&sig_req_account, RegisteringDetails:: { - program_modification_account: sig_req_account.clone(), + program_deploy_key: sig_req_account.clone(), confirmations: confirmation, programs_data: programs_info, key_visibility: KeyVisibility::Public, diff --git a/pallets/relayer/src/lib.rs b/pallets/relayer/src/lib.rs index 2e72ad77e..4222d60d5 100644 --- a/pallets/relayer/src/lib.rs +++ b/pallets/relayer/src/lib.rs @@ -99,7 +99,7 @@ pub mod pallet { #[derive(Clone, Encode, Decode, Eq, PartialEqNoBound, RuntimeDebug, TypeInfo)] #[scale_info(skip_type_params(T))] pub struct RegisteringDetails { - pub program_modification_account: T::AccountId, + pub program_deploy_key: T::AccountId, pub confirmations: Vec, pub programs_data: BoundedVec, T::MaxProgramHashes>, pub key_visibility: KeyVisibility, @@ -113,7 +113,7 @@ pub mod pallet { // TODO better type pub verifying_key: BoundedVec>, pub programs_data: BoundedVec, T::MaxProgramHashes>, - pub program_modification_account: T::AccountId, + pub program_deploy_key: T::AccountId, } #[pallet::genesis_config] @@ -140,7 +140,7 @@ pub mod pallet { key_visibility, verifying_key: BoundedVec::default(), programs_data: BoundedVec::default(), - program_modification_account: account_info.0.clone(), + program_deploy_key: account_info.0.clone(), }, ); } @@ -222,7 +222,7 @@ pub mod pallet { })] pub fn register( origin: OriginFor, - program_modification_account: T::AccountId, + program_deploy_key: T::AccountId, key_visibility: KeyVisibility, programs_data: BoundedVec, T::MaxProgramHashes>, ) -> DispatchResultWithPostInfo { @@ -260,7 +260,7 @@ pub mod pallet { Registering::::insert( &sig_req_account, RegisteringDetails:: { - program_modification_account, + program_deploy_key, confirmations: vec![], programs_data: programs_data.clone(), key_visibility, @@ -327,7 +327,7 @@ pub mod pallet { Registered::::try_mutate(&sig_request_account, |maybe_registered_details| { if let Some(registerd_details) = maybe_registered_details { ensure!( - who == registerd_details.program_modification_account, + who == registerd_details.program_deploy_key, Error::::NotAuthorized ); // decrement ref counter of not used programs @@ -422,7 +422,7 @@ pub mod pallet { key_visibility: registering_info.key_visibility, verifying_key, programs_data: registering_info.programs_data, - program_modification_account: registering_info.program_modification_account, + program_deploy_key: registering_info.program_deploy_key, }, ); Registering::::remove(&sig_req_account); diff --git a/pallets/relayer/src/tests.rs b/pallets/relayer/src/tests.rs index 573782e88..74ec17be6 100644 --- a/pallets/relayer/src/tests.rs +++ b/pallets/relayer/src/tests.rs @@ -83,7 +83,7 @@ fn it_registers_a_user() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); @@ -131,7 +131,7 @@ fn it_confirms_registers_a_user() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); @@ -179,7 +179,7 @@ fn it_confirms_registers_a_user() { programs_data: programs_info.clone(), key_visibility: KeyVisibility::Private([0; 32]), verifying_key: Some(expected_verifying_key.clone()), - program_modification_account: 2, + program_deploy_key: 2, }; assert_eq!(Relayer::registering(1), Some(registering_info)); @@ -198,7 +198,7 @@ fn it_confirms_registers_a_user() { key_visibility: KeyVisibility::Private([0; 32]), verifying_key: expected_verifying_key, programs_data: programs_info.clone(), - program_modification_account: 2 + program_deploy_key: 2 } ); }); @@ -220,7 +220,7 @@ fn it_changes_a_program_pointer() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 1, }, ); @@ -238,7 +238,7 @@ fn it_changes_a_program_pointer() { ProgramInfo { bytecode: new_program, configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 1, }, ); @@ -249,7 +249,7 @@ fn it_changes_a_program_pointer() { key_visibility: KeyVisibility::Public, verifying_key: expected_verifying_key, programs_data: programs_info, - program_modification_account: 2, + program_deploy_key: 2, }; Registered::::insert(1, ®istered_info); @@ -317,7 +317,7 @@ fn it_fails_on_non_matching_verifying_keys() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); @@ -370,7 +370,7 @@ fn it_doesnt_allow_double_registering() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); @@ -450,7 +450,7 @@ fn it_tests_prune_registration() { ProgramInfo { bytecode: inital_program.clone(), configuration_interface: inital_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 1, }, ); @@ -494,7 +494,7 @@ fn it_provides_free_txs_confirm_done() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); @@ -573,7 +573,7 @@ fn it_provides_free_txs_confirm_done_fails_3() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); @@ -622,7 +622,7 @@ fn it_provides_free_txs_confirm_done_fails_4() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); @@ -664,7 +664,7 @@ fn it_provides_free_txs_confirm_done_fails_5() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_modification_account: 1, + program_deploy_key: 1, ref_counter: 0, }, ); From c543d7eea053feb56db5b2373b80b5e76f0ef600 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 16:39:53 -0500 Subject: [PATCH 2/9] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc7bc5750..b0db0f1ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ At the moment this project **does not** adhere to `dev` instead of `local`. - A user now needs to add a program config, which gets packaged with their program pointer to create program info. This changes both register and change_program_info (previously change_program_pointer). As well set_program now also takes program_type_definition. ([#593](https://github.com/entropyxyz/entropy-core/pull/593)) - Changed program_type_definition to configuration_interface. ([#597](https://github.com/entropyxyz/entropy-core/pull/597)) +- Changed program_modification_account to program_deploy_key. ([#604](https://github.com/entropyxyz/entropy-core/pull/604)) ### Added - Test CLI which calls the same code as in integration tests ([#417](https://github.com/entropyxyz/entropy-core/pull/417)) @@ -50,6 +51,7 @@ At the moment this project **does not** adhere to - Additive aux data ([#577](https://github.com/entropyxyz/entropy-core/pull/577)) - Refactor Rust-based chain specs ([#592](https://github.com/entropyxyz/entropy-core/pull/592)) - Fix test CLI for additive program pointers and update / refactor tests ([#591](https://github.com/entropyxyz/entropy-core/pull/591)) +- Change to program deploy key ([#604](https://github.com/entropyxyz/entropy-core/pull/604)) ### Fixed - Fix inconsistency between interactive and file based passwords ([#589](https://github.com/entropyxyz/entropy-core/pull/589)) From ac425ca2590d7c6708802bb71b61594dabb55d15 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 17:33:11 -0500 Subject: [PATCH 3/9] rollback a little --- .../entropy_metadata.scale | Bin 193522 -> 193552 bytes .../src/user/tests.rs | 4 ++-- pallets/relayer/src/lib.rs | 14 +++++++------- pallets/relayer/src/tests.rs | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/threshold-signature-server/entropy_metadata.scale b/crates/threshold-signature-server/entropy_metadata.scale index 84ceef319cf7fd864ec4b3199b6a296f9058cf70..b682250c43fc4ba46d89db5fa539b1c711863d52 100644 GIT binary patch delta 114 zcmezLoO{9x?uIRl)dpe(1x5MkMTxobx%nxXX_?81C7Jno@skzAB(~2tV7xXRpMseu V7_TzoRv_L!@f73siKmznH35OlE#v?I delta 45 wcmbR6g8S2R?uIRl)drIV`joaWH(dh}FLC6yx@Fr, sig_req_keyring: &Sr25519Keyring, - program_deploy_key: subxtAccountId32, + program_modification_account: subxtAccountId32, key_visibility: KeyVisibility, program_instance: BoundedVec, ) { @@ -795,7 +795,7 @@ pub async fn put_register_request_on_chain( PairSigner::::new(sig_req_keyring.pair()); let registering_tx = entropy::tx().relayer().register( - program_deploy_key, + program_modification_account, Static(key_visibility), program_instance, ); diff --git a/pallets/relayer/src/lib.rs b/pallets/relayer/src/lib.rs index 4222d60d5..2e72ad77e 100644 --- a/pallets/relayer/src/lib.rs +++ b/pallets/relayer/src/lib.rs @@ -99,7 +99,7 @@ pub mod pallet { #[derive(Clone, Encode, Decode, Eq, PartialEqNoBound, RuntimeDebug, TypeInfo)] #[scale_info(skip_type_params(T))] pub struct RegisteringDetails { - pub program_deploy_key: T::AccountId, + pub program_modification_account: T::AccountId, pub confirmations: Vec, pub programs_data: BoundedVec, T::MaxProgramHashes>, pub key_visibility: KeyVisibility, @@ -113,7 +113,7 @@ pub mod pallet { // TODO better type pub verifying_key: BoundedVec>, pub programs_data: BoundedVec, T::MaxProgramHashes>, - pub program_deploy_key: T::AccountId, + pub program_modification_account: T::AccountId, } #[pallet::genesis_config] @@ -140,7 +140,7 @@ pub mod pallet { key_visibility, verifying_key: BoundedVec::default(), programs_data: BoundedVec::default(), - program_deploy_key: account_info.0.clone(), + program_modification_account: account_info.0.clone(), }, ); } @@ -222,7 +222,7 @@ pub mod pallet { })] pub fn register( origin: OriginFor, - program_deploy_key: T::AccountId, + program_modification_account: T::AccountId, key_visibility: KeyVisibility, programs_data: BoundedVec, T::MaxProgramHashes>, ) -> DispatchResultWithPostInfo { @@ -260,7 +260,7 @@ pub mod pallet { Registering::::insert( &sig_req_account, RegisteringDetails:: { - program_deploy_key, + program_modification_account, confirmations: vec![], programs_data: programs_data.clone(), key_visibility, @@ -327,7 +327,7 @@ pub mod pallet { Registered::::try_mutate(&sig_request_account, |maybe_registered_details| { if let Some(registerd_details) = maybe_registered_details { ensure!( - who == registerd_details.program_deploy_key, + who == registerd_details.program_modification_account, Error::::NotAuthorized ); // decrement ref counter of not used programs @@ -422,7 +422,7 @@ pub mod pallet { key_visibility: registering_info.key_visibility, verifying_key, programs_data: registering_info.programs_data, - program_deploy_key: registering_info.program_deploy_key, + program_modification_account: registering_info.program_modification_account, }, ); Registering::::remove(&sig_req_account); diff --git a/pallets/relayer/src/tests.rs b/pallets/relayer/src/tests.rs index 74ec17be6..fde835a7d 100644 --- a/pallets/relayer/src/tests.rs +++ b/pallets/relayer/src/tests.rs @@ -179,7 +179,7 @@ fn it_confirms_registers_a_user() { programs_data: programs_info.clone(), key_visibility: KeyVisibility::Private([0; 32]), verifying_key: Some(expected_verifying_key.clone()), - program_deploy_key: 2, + program_modification_account: 2, }; assert_eq!(Relayer::registering(1), Some(registering_info)); @@ -198,7 +198,7 @@ fn it_confirms_registers_a_user() { key_visibility: KeyVisibility::Private([0; 32]), verifying_key: expected_verifying_key, programs_data: programs_info.clone(), - program_deploy_key: 2 + program_modification_account: 2 } ); }); @@ -249,7 +249,7 @@ fn it_changes_a_program_pointer() { key_visibility: KeyVisibility::Public, verifying_key: expected_verifying_key, programs_data: programs_info, - program_deploy_key: 2, + program_modification_account: 2, }; Registered::::insert(1, ®istered_info); From 94fec8c925dec15fc828455199ad793905dafebb Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 17:35:54 -0500 Subject: [PATCH 4/9] clean --- crates/testing-utils/src/test_client/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/testing-utils/src/test_client/mod.rs b/crates/testing-utils/src/test_client/mod.rs index 3239f415e..30677dc24 100644 --- a/crates/testing-utils/src/test_client/mod.rs +++ b/crates/testing-utils/src/test_client/mod.rs @@ -248,18 +248,18 @@ pub async fn sign( skip_all, fields( signature_request_account, - program_deploy_key = ?program_modification_keypair.public(), + program_deploy_key = ?program_deploy_keypair.public(), ) )] pub async fn store_program( api: &OnlineClient, - program_modification_keypair: &sr25519::Pair, + program_deploy_keypair: &sr25519::Pair, program: Vec, configuration_interface: Vec, ) -> anyhow::Result<::Hash> { let update_program_tx = entropy::tx().programs().set_program(program, configuration_interface); let program_deploy_key = - PairSigner::::new(program_modification_keypair.clone()); + PairSigner::::new(program_deploy_keypair.clone()); let in_block = api .tx() @@ -279,7 +279,7 @@ pub async fn update_programs( entropy_api: &OnlineClient, rpc: &LegacyRpcMethods, signature_request_account: &sr25519::Pair, - pointer_modification_account: &sr25519::Pair, + program_deploy_key: &sr25519::Pair, program_instance: BoundedVec, ) -> anyhow::Result<()> { let block_hash = @@ -289,14 +289,14 @@ pub async fn update_programs( .relayer() .change_program_instance(signature_request_account.public().into(), program_instance); - let account_id32: AccountId32 = pointer_modification_account.public().into(); + let account_id32: AccountId32 = program_deploy_key.public().into(); let account_id: ::AccountId = account_id32.into(); let nonce_call = entropy::apis().account_nonce_api().account_nonce(account_id.clone()); let nonce = entropy_api.runtime_api().at(block_hash).call(nonce_call).await?; - let pointer_modification_account = - PairSigner::::new(pointer_modification_account.clone()); + let program_deploy_key = + PairSigner::::new(program_deploy_key.clone()); let partial_tx = entropy_api.tx().create_partial_signed_with_nonce( &update_pointer_tx, @@ -304,7 +304,7 @@ pub async fn update_programs( Default::default(), )?; let signer_payload = partial_tx.signer_payload(); - let signature = pointer_modification_account.sign(&signer_payload); + let signature = program_deploy_key.sign(&signer_payload); let tx = partial_tx.sign_with_address_and_signature(&account_id.into(), &signature); From b59a7340cadb7ffebdd9580b67a80d7c63840f1c Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 17:38:12 -0500 Subject: [PATCH 5/9] clean --- crates/threshold-signature-server/src/user/tests.rs | 4 ++-- crates/threshold-signature-server/tests/protocol_wasm.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index d1e45ac3f..2047bb9d3 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -1105,7 +1105,7 @@ async fn test_register_with_private_key_visibility() { clean_tests(); let one = AccountKeyring::One; - let program_deploy_key = AccountKeyring::Charlie; + let program_modification_account = AccountKeyring::Charlie; let program_manager = AccountKeyring::Dave; let (validator_ips, _validator_ids, _users_keyshare_option) = @@ -1127,7 +1127,7 @@ async fn test_register_with_private_key_visibility() { put_register_request_on_chain( &api, &one, - program_deploy_key.to_account_id().into(), + program_modification_account.to_account_id().into(), KeyVisibility::Private(x25519_public_key), BoundedVec(vec![ProgramInstance { program_pointer: program_hash, program_config: vec![] }]), ) diff --git a/crates/threshold-signature-server/tests/protocol_wasm.rs b/crates/threshold-signature-server/tests/protocol_wasm.rs index 3e97f3ea7..d04aa1e46 100644 --- a/crates/threshold-signature-server/tests/protocol_wasm.rs +++ b/crates/threshold-signature-server/tests/protocol_wasm.rs @@ -203,7 +203,7 @@ async fn test_wasm_register_with_private_key_visibility() { clean_tests(); let one = AccountKeyring::One; - let program_deploy_key = AccountKeyring::Charlie; + let program_modification_account = AccountKeyring::Charlie; let dave = AccountKeyring::Dave; let (validator_ips, _validator_ids, _users_keyshare_option) = @@ -225,7 +225,7 @@ async fn test_wasm_register_with_private_key_visibility() { &api, &rpc, one.pair(), - program_deploy_key.to_account_id().into(), + program_modification_account.to_account_id().into(), KeyVisibility::Private(x25519_public_key), BoundedVec(vec![ProgramInstance { program_pointer, program_config: vec![] }]), ) From 683910a1b976d80aa4facc042f49a1978db91be3 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 17:39:01 -0500 Subject: [PATCH 6/9] clean --- pallets/programs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/programs/src/lib.rs b/pallets/programs/src/lib.rs index 759da20c8..1538dd142 100644 --- a/pallets/programs/src/lib.rs +++ b/pallets/programs/src/lib.rs @@ -97,7 +97,7 @@ pub mod pallet { pub bytecode: Vec, /// The type definition of the program pub configuration_interface: Vec, - /// Owners of the program + /// Owner of the program pub program_deploy_key: AccountId, /// Accounts that use this program pub ref_counter: u128, From 0e5ea0655df5447b16ef644fbacb68323f426f4d Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 18:24:26 -0500 Subject: [PATCH 7/9] fix benchmark --- pallets/relayer/src/benchmarking.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pallets/relayer/src/benchmarking.rs b/pallets/relayer/src/benchmarking.rs index fc558d8a9..271b2d750 100644 --- a/pallets/relayer/src/benchmarking.rs +++ b/pallets/relayer/src/benchmarking.rs @@ -80,12 +80,12 @@ benchmarks! { }; p as usize]) .unwrap(); - let program_deploy_key: T::AccountId = whitelisted_caller(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: 0}); + let program_modification_account: T::AccountId = whitelisted_caller(); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_modification_account.clone(), ref_counter: 0}); 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()), program_deploy_key, KeyVisibility::Public, programs_info) + }: _(RawOrigin::Signed(sig_req_account.clone()), program_modification_account, KeyVisibility::Public, programs_info) verify { assert_last_event::(Event::SignalRegister(sig_req_account.clone()).into()); assert!(Registering::::contains_key(sig_req_account)); @@ -93,7 +93,7 @@ benchmarks! { prune_registration { let p in 1 .. T::MaxProgramHashes::get(); - let program_deploy_key: T::AccountId = whitelisted_caller(); + let program_modification_account: T::AccountId = whitelisted_caller(); let program = vec![0u8]; let configuration_interface = vec![1u8]; let program_hash = T::Hashing::hash(&program); @@ -101,12 +101,12 @@ benchmarks! { program_pointer: program_hash, program_config: vec![], }]).unwrap(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: 1}); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_modification_account.clone(), ref_counter: 1}); 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); >::insert(&sig_req_account, RegisteringDetails:: { - program_deploy_key: sig_req_account.clone(), + program_modification_account: sig_req_account.clone(), confirmations: vec![], programs_data: programs_info, key_visibility: KeyVisibility::Public, @@ -121,7 +121,7 @@ benchmarks! { let n in 1 .. T::MaxProgramHashes::get(); let o in 1 .. T::MaxProgramHashes::get(); - let program_deploy_key: T::AccountId = whitelisted_caller(); + let program_modification_account: T::AccountId = whitelisted_caller(); let program = vec![0u8]; let configuration_interface = vec![1u8]; let program_hash = T::Hashing::hash(&program); @@ -138,14 +138,14 @@ benchmarks! { }; n as usize]) .unwrap(); let sig_req_account: T::AccountId = whitelisted_caller(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface: configuration_interface.clone(), program_deploy_key: program_deploy_key.clone(), ref_counter: 0}); - Programs::::insert(new_program_hash, ProgramInfo {bytecode: new_program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: o as u128}); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface: configuration_interface.clone(), program_deploy_key: program_modification_account.clone(), ref_counter: 0}); + Programs::::insert(new_program_hash, ProgramInfo {bytecode: new_program, configuration_interface, program_deploy_key: program_modification_account.clone(), ref_counter: o as u128}); let balance = ::Currency::minimum_balance() * 100u32.into(); let _ = ::Currency::make_free_balance_be(&sig_req_account, balance); >::insert( &sig_req_account, RegisteredInfo { - program_deploy_key: sig_req_account.clone(), + program_modification_account: sig_req_account.clone(), programs_data: programs_info, verifying_key: BoundedVec::default(), key_visibility: KeyVisibility::Public, @@ -177,7 +177,7 @@ benchmarks! { } >::insert(&sig_req_account, RegisteringDetails:: { - program_deploy_key: sig_req_account.clone(), + program_modification_account: sig_req_account.clone(), confirmations: vec![], programs_data: programs_info, key_visibility: KeyVisibility::Public, @@ -213,7 +213,7 @@ benchmarks! { let adjusted_sig_size = SIG_PARTIES - 1; let confirmation: Vec = (1u8..=adjusted_sig_size.try_into().unwrap()).collect(); >::insert(&sig_req_account, RegisteringDetails:: { - program_deploy_key: sig_req_account.clone(), + program_modification_account: sig_req_account.clone(), confirmations: confirmation, programs_data: programs_info, key_visibility: KeyVisibility::Public, @@ -248,7 +248,7 @@ confirm_register_registered { let adjusted_sig_size = SIG_PARTIES - 1; let confirmation: Vec = (1u8..=adjusted_sig_size.try_into().unwrap()).collect(); >::insert(&sig_req_account, RegisteringDetails:: { - program_deploy_key: sig_req_account.clone(), + program_modification_account: sig_req_account.clone(), confirmations: confirmation, programs_data: programs_info, key_visibility: KeyVisibility::Public, From 11541afefee8687c777f8e2e058946a4cafdac19 Mon Sep 17 00:00:00 2001 From: JesseAbram <33698952+JesseAbram@users.noreply.github.com> Date: Tue, 23 Jan 2024 15:50:18 -0800 Subject: [PATCH 8/9] Update pallets/programs/src/lib.rs Co-authored-by: Hernando Castano --- pallets/programs/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/programs/src/lib.rs b/pallets/programs/src/lib.rs index 1538dd142..4e3e15249 100644 --- a/pallets/programs/src/lib.rs +++ b/pallets/programs/src/lib.rs @@ -97,7 +97,7 @@ pub mod pallet { pub bytecode: Vec, /// The type definition of the program pub configuration_interface: Vec, - /// Owner of the program + /// Deployer of the program pub program_deploy_key: AccountId, /// Accounts that use this program pub ref_counter: u128, From 647919cd8187e9063a1ceecc616aa61bb06235f8 Mon Sep 17 00:00:00 2001 From: Jesse Abramowitz Date: Tue, 23 Jan 2024 19:03:18 -0500 Subject: [PATCH 9/9] clean --- CHANGELOG.md | 4 +- crates/test-cli/src/main.rs | 2 +- crates/testing-utils/src/test_client/mod.rs | 27 ++++------ .../entropy_metadata.scale | Bin 193552 -> 193522 bytes .../src/helpers/tests.rs | 9 ++-- pallets/programs/src/benchmarking.rs | 20 +++---- pallets/programs/src/lib.rs | 49 ++++++++---------- pallets/programs/src/tests.rs | 6 +-- pallets/propagation/src/tests.rs | 2 +- pallets/relayer/src/benchmarking.rs | 8 +-- pallets/relayer/src/tests.rs | 22 ++++---- 11 files changed, 68 insertions(+), 81 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0db0f1ae..f966aa509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ At the moment this project **does not** adhere to `dev` instead of `local`. - A user now needs to add a program config, which gets packaged with their program pointer to create program info. This changes both register and change_program_info (previously change_program_pointer). As well set_program now also takes program_type_definition. ([#593](https://github.com/entropyxyz/entropy-core/pull/593)) - Changed program_type_definition to configuration_interface. ([#597](https://github.com/entropyxyz/entropy-core/pull/597)) -- Changed program_modification_account to program_deploy_key. ([#604](https://github.com/entropyxyz/entropy-core/pull/604)) +- Changed program_modification_account in programs_info of programs pallet to deployer. ([#604](https://github.com/entropyxyz/entropy-core/pull/604)) ### Added - Test CLI which calls the same code as in integration tests ([#417](https://github.com/entropyxyz/entropy-core/pull/417)) @@ -51,7 +51,7 @@ At the moment this project **does not** adhere to - Additive aux data ([#577](https://github.com/entropyxyz/entropy-core/pull/577)) - Refactor Rust-based chain specs ([#592](https://github.com/entropyxyz/entropy-core/pull/592)) - Fix test CLI for additive program pointers and update / refactor tests ([#591](https://github.com/entropyxyz/entropy-core/pull/591)) -- Change to program deploy key ([#604](https://github.com/entropyxyz/entropy-core/pull/604)) +- Change `program_modification_account` to `program_deploy_key` ([#604](https://github.com/entropyxyz/entropy-core/pull/604)) ### Fixed - Fix inconsistency between interactive and file based passwords ([#589](https://github.com/entropyxyz/entropy-core/pull/589)) diff --git a/crates/test-cli/src/main.rs b/crates/test-cli/src/main.rs index ec9b0fa6a..ab9caee86 100644 --- a/crates/test-cli/src/main.rs +++ b/crates/test-cli/src/main.rs @@ -368,7 +368,7 @@ async fn run_command() -> anyhow::Result { println!( "{} {} {:>11} {:>14} {}", hash, - program_info.program_deploy_key, + program_info.deployer, program_info.ref_counter, program_info.bytecode.len(), !program_info.configuration_interface.is_empty(), diff --git a/crates/testing-utils/src/test_client/mod.rs b/crates/testing-utils/src/test_client/mod.rs index 30677dc24..1ac677e03 100644 --- a/crates/testing-utils/src/test_client/mod.rs +++ b/crates/testing-utils/src/test_client/mod.rs @@ -248,22 +248,21 @@ pub async fn sign( skip_all, fields( signature_request_account, - program_deploy_key = ?program_deploy_keypair.public(), + deployer = ?deployerpair.public(), ) )] pub async fn store_program( api: &OnlineClient, - program_deploy_keypair: &sr25519::Pair, + deployerpair: &sr25519::Pair, program: Vec, configuration_interface: Vec, ) -> anyhow::Result<::Hash> { let update_program_tx = entropy::tx().programs().set_program(program, configuration_interface); - let program_deploy_key = - PairSigner::::new(program_deploy_keypair.clone()); + let deployer = PairSigner::::new(deployerpair.clone()); let in_block = api .tx() - .sign_and_submit_then_watch_default(&update_program_tx, &program_deploy_key) + .sign_and_submit_then_watch_default(&update_program_tx, &deployer) .await? .wait_for_in_block() .await? @@ -279,7 +278,7 @@ pub async fn update_programs( entropy_api: &OnlineClient, rpc: &LegacyRpcMethods, signature_request_account: &sr25519::Pair, - program_deploy_key: &sr25519::Pair, + deployer: &sr25519::Pair, program_instance: BoundedVec, ) -> anyhow::Result<()> { let block_hash = @@ -289,14 +288,13 @@ pub async fn update_programs( .relayer() .change_program_instance(signature_request_account.public().into(), program_instance); - let account_id32: AccountId32 = program_deploy_key.public().into(); + let account_id32: AccountId32 = deployer.public().into(); let account_id: ::AccountId = account_id32.into(); let nonce_call = entropy::apis().account_nonce_api().account_nonce(account_id.clone()); let nonce = entropy_api.runtime_api().at(block_hash).call(nonce_call).await?; - let program_deploy_key = - PairSigner::::new(program_deploy_key.clone()); + let deployer = PairSigner::::new(deployer.clone()); let partial_tx = entropy_api.tx().create_partial_signed_with_nonce( &update_pointer_tx, @@ -304,7 +302,7 @@ pub async fn update_programs( Default::default(), )?; let signer_payload = partial_tx.signer_payload(); - let signature = program_deploy_key.sign(&signer_payload); + let signature = deployer.sign(&signer_payload); let tx = partial_tx.sign_with_address_and_signature(&account_id.into(), &signature); @@ -357,7 +355,7 @@ pub async fn put_register_request_on_chain( api: &OnlineClient, rpc: &LegacyRpcMethods, signature_request_keypair: sr25519::Pair, - program_deploy_key: SubxtAccountId32, + deployer: SubxtAccountId32, key_visibility: KeyVisibility, program_instance: BoundedVec, ) -> anyhow::Result<()> { @@ -367,11 +365,8 @@ pub async fn put_register_request_on_chain( let signature_request_pair_signer = PairSigner::::new(signature_request_keypair); - let registering_tx = entropy::tx().relayer().register( - program_deploy_key, - Static(key_visibility), - program_instance, - ); + let registering_tx = + entropy::tx().relayer().register(deployer, Static(key_visibility), program_instance); let block_hash = rpc.chain_get_block_hash(None).await?.ok_or_else(|| anyhow!("Error getting block hash"))?; diff --git a/crates/threshold-signature-server/entropy_metadata.scale b/crates/threshold-signature-server/entropy_metadata.scale index b682250c43fc4ba46d89db5fa539b1c711863d52..002e2b79fb3e7dadeca46a4d9da73051d4f4026c 100644 GIT binary patch delta 66 zcmbR6g8S2R?hP!xoC+za1v&YZsYR2;dw-(vESjVHwnz6d8rva++ZUc;+`jM(Q@%O? Do533% delta 96 zcmezLoO{9x?hP!x!X5=h`RPT8x$!Bf1v&YZ@!6@Blll8BCcE|?#3t9w-?yE=k1^X0 Qn`C?Q8OH6+XPENU0h*2{e*gdg diff --git a/crates/threshold-signature-server/src/helpers/tests.rs b/crates/threshold-signature-server/src/helpers/tests.rs index 3bbb1c456..9e06218f2 100644 --- a/crates/threshold-signature-server/src/helpers/tests.rs +++ b/crates/threshold-signature-server/src/helpers/tests.rs @@ -184,16 +184,15 @@ pub async fn spawn_testing_validators( pub async fn remove_program( entropy_api: &OnlineClient, rpc: &LegacyRpcMethods, - program_deploy_key: &sr25519::Pair, + deployer: &sr25519::Pair, program_hash: ::Hash, ) { // update/set their programs let remove_program_tx = entropy::tx().programs().remove_program(program_hash); - let account_id32: AccountId32 = program_deploy_key.public().into(); + let account_id32: AccountId32 = deployer.public().into(); let account_id: ::AccountId = account_id32.into(); - let program_deploy_key = - PairSigner::::new(program_deploy_key.clone()); + let deployer = PairSigner::::new(deployer.clone()); let block_hash = rpc.chain_get_block_hash(None).await.unwrap().unwrap(); let nonce_call = entropy::apis().account_nonce_api().account_nonce(account_id.clone()); @@ -203,7 +202,7 @@ pub async fn remove_program( .create_partial_signed_with_nonce(&remove_program_tx, nonce.into(), Default::default()) .unwrap(); let signer_payload = partial_tx.signer_payload(); - let signature = program_deploy_key.sign(&signer_payload); + let signature = deployer.sign(&signer_payload); let tx = partial_tx.sign_with_address_and_signature(&account_id.into(), &signature); tx.submit_and_watch() diff --git a/pallets/programs/src/benchmarking.rs b/pallets/programs/src/benchmarking.rs index 07c909696..89bee7e99 100644 --- a/pallets/programs/src/benchmarking.rs +++ b/pallets/programs/src/benchmarking.rs @@ -48,17 +48,17 @@ benchmarks! { hash_input.extend(&configuration_interface); let program_hash = T::Hashing::hash(&hash_input); - let program_deploy_key: T::AccountId = whitelisted_caller(); + let deployer: T::AccountId = whitelisted_caller(); let sig_req_account: T::AccountId = whitelisted_caller(); let value = CurrencyOf::::minimum_balance().saturating_mul(1_000_000_000u32.into()); - let _ = CurrencyOf::::make_free_balance_be(&program_deploy_key, value); + let _ = CurrencyOf::::make_free_balance_be(&deployer, value); - }: _(RawOrigin::Signed(program_deploy_key.clone()), program.clone(), configuration_interface.clone()) + }: _(RawOrigin::Signed(deployer.clone()), program.clone(), configuration_interface.clone()) verify { assert_last_event::( Event::::ProgramCreated { - program_deploy_key, + deployer, program_hash, configuration_interface }.into() @@ -76,23 +76,23 @@ benchmarks! { let program_hash = T::Hashing::hash(&hash_input); let random_program = vec![11]; let random_hash = T::Hashing::hash(&random_program); - let program_deploy_key: T::AccountId = whitelisted_caller(); + let deployer: T::AccountId = whitelisted_caller(); let value = CurrencyOf::::minimum_balance().saturating_mul(1_000_000_000u32.into()); - let _ = CurrencyOf::::make_free_balance_be(&program_deploy_key, value); - >::insert(program_hash.clone(), ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_deploy_key.clone(), ref_counter: 0u128}); + let _ = CurrencyOf::::make_free_balance_be(&deployer, value); + >::insert(program_hash.clone(), ProgramInfo {bytecode: program, configuration_interface, deployer: deployer.clone(), ref_counter: 0u128}); let mut program_hashes = vec![random_hash.clone(); p as usize]; // remove one to make room for the targetted removal program hash program_hashes.pop(); program_hashes.push(program_hash); let bounded_program_hashes: BoundedVec = BoundedVec::try_from(program_hashes).unwrap(); - >::insert(program_deploy_key.clone(), bounded_program_hashes); - }: _(RawOrigin::Signed(program_deploy_key.clone()), program_hash.clone()) + >::insert(deployer.clone(), bounded_program_hashes); + }: _(RawOrigin::Signed(deployer.clone()), program_hash.clone()) verify { assert_last_event::( Event::::ProgramRemoved { - program_deploy_key, + deployer, old_program_hash: program_hash }.into() ); diff --git a/pallets/programs/src/lib.rs b/pallets/programs/src/lib.rs index 4e3e15249..4ff648dae 100644 --- a/pallets/programs/src/lib.rs +++ b/pallets/programs/src/lib.rs @@ -17,8 +17,7 @@ //! //! ## Overview //! -//! This pallet stores the WebAssembly (Wasm) program bytecode on-chain and allows users to change -//! it as required. +//! This pallet stores the WebAssembly (Wasm) program bytecode on-chain at the hash of the program code and interface //! //! A program is a piece of logic which is run by the network when a signing operation is requested. //! The succesful execution of a program indicates to validators on the network that they should @@ -32,8 +31,8 @@ //! //! #### Public //! -//! `update_program` - Allows a program-modification account to change the program associated with -//! a particular signature-request account. +//! `set_program` - Allows a deployer account to create a program. +//! `remove_program` - Allows a deployer to remove a program if not in use. #![cfg_attr(not(feature = "std"), no_std)] pub use pallet::*; @@ -98,7 +97,7 @@ pub mod pallet { /// The type definition of the program pub configuration_interface: Vec, /// Deployer of the program - pub program_deploy_key: AccountId, + pub deployer: AccountId, /// Accounts that use this program pub ref_counter: u128, } @@ -126,8 +125,8 @@ pub mod pallet { pub enum Event { /// The bytecode of a program was created. ProgramCreated { - /// The program modification account which updated the program. - program_deploy_key: T::AccountId, + /// The deployer account which created the program. + deployer: T::AccountId, /// The new program hash. program_hash: T::Hash, @@ -137,8 +136,8 @@ pub mod pallet { }, /// The bytecode of a program was removed. ProgramRemoved { - /// The program modification account which removed the program. - program_deploy_key: T::AccountId, + /// The depoyer account which removed the program. + deployer: T::AccountId, /// The hash of the removed program. old_program_hash: T::Hash, @@ -163,9 +162,9 @@ pub mod pallet { #[pallet::call] impl Pallet { - /// Sets the program and uses hash as key. + /// Sets the program and uses hash of program and configuration_interface as key. /// - /// Note that the caller becomes the program-modification account. + /// Note that the caller becomes the deployer account. #[pallet::call_index(0)] #[pallet::weight({::WeightInfo::set_program()})] pub fn set_program( @@ -173,7 +172,7 @@ pub mod pallet { new_program: Vec, configuration_interface: Vec, ) -> DispatchResult { - let program_deploy_key = ensure_signed(origin)?; + let deployer = ensure_signed(origin)?; let mut hash_input = vec![]; hash_input.extend(&new_program); hash_input.extend(&configuration_interface); @@ -185,19 +184,19 @@ pub mod pallet { ); ensure!(!Programs::::contains_key(program_hash), Error::::ProgramAlreadySet); - Self::reserve_program_deposit(&program_deploy_key, new_program_length)?; + Self::reserve_program_deposit(&deployer, new_program_length)?; Programs::::insert( program_hash, &ProgramInfo { bytecode: new_program.clone(), configuration_interface: configuration_interface.clone(), - program_deploy_key: program_deploy_key.clone(), + deployer: deployer.clone(), ref_counter: 0u128, }, ); OwnedPrograms::::try_mutate( - &program_deploy_key, + &deployer, |owned_programs| -> Result<(), DispatchError> { owned_programs .try_push(program_hash) @@ -206,7 +205,7 @@ pub mod pallet { }, )?; Self::deposit_event(Event::ProgramCreated { - program_deploy_key, + deployer, program_hash, configuration_interface, }); @@ -215,28 +214,25 @@ pub mod pallet { /// Removes a program at a specific hash /// - /// Caller must be the program modification account for said program. + /// Caller must be the deployer account for said program. #[pallet::call_index(1)] #[pallet::weight({::WeightInfo::remove_program( ::MaxOwnedPrograms::get())})] pub fn remove_program( origin: OriginFor, program_hash: T::Hash, ) -> DispatchResultWithPostInfo { - let program_deploy_key = ensure_signed(origin)?; + let deployer = ensure_signed(origin)?; let old_program_info = Self::programs(program_hash).ok_or(Error::::NoProgramDefined)?; - ensure!( - old_program_info.program_deploy_key == program_deploy_key, - Error::::NotAuthorized - ); + ensure!(old_program_info.deployer == deployer, Error::::NotAuthorized); ensure!(old_program_info.ref_counter == 0, Error::::ProgramInUse); Self::unreserve_program_deposit( - &old_program_info.program_deploy_key, + &old_program_info.deployer, old_program_info.bytecode.len() + old_program_info.configuration_interface.len(), ); let mut owned_programs_length = 0; OwnedPrograms::::try_mutate( - &program_deploy_key, + &deployer, |owned_programs| -> Result<(), DispatchError> { owned_programs_length = owned_programs.len(); let pos = owned_programs @@ -248,10 +244,7 @@ pub mod pallet { }, )?; Programs::::remove(program_hash); - Self::deposit_event(Event::ProgramRemoved { - program_deploy_key, - old_program_hash: program_hash, - }); + Self::deposit_event(Event::ProgramRemoved { deployer, old_program_hash: program_hash }); Ok(Some(::WeightInfo::remove_program(owned_programs_length as u32)).into()) } } diff --git a/pallets/programs/src/tests.rs b/pallets/programs/src/tests.rs index 0f7b9df30..1bd959a54 100644 --- a/pallets/programs/src/tests.rs +++ b/pallets/programs/src/tests.rs @@ -54,7 +54,7 @@ fn set_program() { let program_result = ProgramInfo { bytecode: program.clone(), configuration_interface: configuration_interface.clone(), - program_deploy_key: PROGRAM_MODIFICATION_ACCOUNT, + deployer: PROGRAM_MODIFICATION_ACCOUNT, ref_counter: 0u128, }; assert_eq!( @@ -139,7 +139,7 @@ fn remove_program() { "Program bytecode gets set" ); assert_eq!( - ProgramsPallet::programs(program_hash).unwrap().program_deploy_key, + ProgramsPallet::programs(program_hash).unwrap().deployer, PROGRAM_MODIFICATION_ACCOUNT, "Program modification account gets set" ); @@ -178,7 +178,7 @@ fn remove_program_fails_ref_count() { ProgramInfo { bytecode: program, configuration_interface, - program_deploy_key: PROGRAM_MODIFICATION_ACCOUNT, + deployer: PROGRAM_MODIFICATION_ACCOUNT, ref_counter: 1u128, }, ); diff --git a/pallets/propagation/src/tests.rs b/pallets/propagation/src/tests.rs index c50b32b75..27dc03781 100644 --- a/pallets/propagation/src/tests.rs +++ b/pallets/propagation/src/tests.rs @@ -82,7 +82,7 @@ fn knows_how_to_mock_several_http_calls() { ProgramInfo { bytecode: vec![], configuration_interface: vec![], - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); diff --git a/pallets/relayer/src/benchmarking.rs b/pallets/relayer/src/benchmarking.rs index 271b2d750..bdbb9c8b1 100644 --- a/pallets/relayer/src/benchmarking.rs +++ b/pallets/relayer/src/benchmarking.rs @@ -81,7 +81,7 @@ benchmarks! { .unwrap(); let program_modification_account: T::AccountId = whitelisted_caller(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_modification_account.clone(), ref_counter: 0}); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, deployer: program_modification_account.clone(), ref_counter: 0}); 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); @@ -101,7 +101,7 @@ benchmarks! { program_pointer: program_hash, program_config: vec![], }]).unwrap(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, program_deploy_key: program_modification_account.clone(), ref_counter: 1}); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface, deployer: program_modification_account.clone(), ref_counter: 1}); 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); @@ -138,8 +138,8 @@ benchmarks! { }; n as usize]) .unwrap(); let sig_req_account: T::AccountId = whitelisted_caller(); - Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface: configuration_interface.clone(), program_deploy_key: program_modification_account.clone(), ref_counter: 0}); - Programs::::insert(new_program_hash, ProgramInfo {bytecode: new_program, configuration_interface, program_deploy_key: program_modification_account.clone(), ref_counter: o as u128}); + Programs::::insert(program_hash, ProgramInfo {bytecode: program, configuration_interface: configuration_interface.clone(), deployer: program_modification_account.clone(), ref_counter: 0}); + Programs::::insert(new_program_hash, ProgramInfo {bytecode: new_program, configuration_interface, deployer: program_modification_account.clone(), ref_counter: o as u128}); let balance = ::Currency::minimum_balance() * 100u32.into(); let _ = ::Currency::make_free_balance_be(&sig_req_account, balance); >::insert( diff --git a/pallets/relayer/src/tests.rs b/pallets/relayer/src/tests.rs index fde835a7d..6e9906d2a 100644 --- a/pallets/relayer/src/tests.rs +++ b/pallets/relayer/src/tests.rs @@ -83,7 +83,7 @@ fn it_registers_a_user() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); @@ -131,7 +131,7 @@ fn it_confirms_registers_a_user() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); @@ -220,7 +220,7 @@ fn it_changes_a_program_pointer() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 1, }, ); @@ -238,7 +238,7 @@ fn it_changes_a_program_pointer() { ProgramInfo { bytecode: new_program, configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 1, }, ); @@ -317,7 +317,7 @@ fn it_fails_on_non_matching_verifying_keys() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); @@ -370,7 +370,7 @@ fn it_doesnt_allow_double_registering() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); @@ -450,7 +450,7 @@ fn it_tests_prune_registration() { ProgramInfo { bytecode: inital_program.clone(), configuration_interface: inital_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 1, }, ); @@ -494,7 +494,7 @@ fn it_provides_free_txs_confirm_done() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); @@ -573,7 +573,7 @@ fn it_provides_free_txs_confirm_done_fails_3() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); @@ -622,7 +622,7 @@ fn it_provides_free_txs_confirm_done_fails_4() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, ); @@ -664,7 +664,7 @@ fn it_provides_free_txs_confirm_done_fails_5() { ProgramInfo { bytecode: empty_program.clone(), configuration_interface: empty_program.clone(), - program_deploy_key: 1, + deployer: 1, ref_counter: 0, }, );