diff --git a/evm-tests/test/uid.precompile.lookup.test.ts b/evm-tests/test/uid.precompile.lookup.test.ts index 6e702d612e..f6e22ce032 100644 --- a/evm-tests/test/uid.precompile.lookup.test.ts +++ b/evm-tests/test/uid.precompile.lookup.test.ts @@ -55,12 +55,11 @@ describe("Test the UID Lookup precompile", () => { const signature = await evmWallet.signMessage(concatenatedArray); const associateEvmKeyTx = api.tx.SubtensorModule.associate_evm_key({ netuid: netuid, - hotkey: convertPublicKeyToSs58(hotkey.publicKey), evm_key: convertToFixedSizeBinary(evmWallet.address, 20), block_number: BigInt(blockNumber), signature: convertToFixedSizeBinary(signature, 65) }); - const signer = getSignerFromKeypair(coldkey); + const signer = getSignerFromKeypair(hotkey); await waitForTransactionCompletion(api, associateEvmKeyTx, signer) .then(() => { }) .catch((error) => { console.log(`transaction error ${error}`) }); diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 30fc44fc72..64ed5f723a 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2001,12 +2001,11 @@ mod dispatches { pub fn associate_evm_key( origin: T::RuntimeOrigin, netuid: NetUid, - hotkey: T::AccountId, evm_key: H160, block_number: u64, signature: Signature, ) -> DispatchResult { - Self::do_associate_evm_key(origin, netuid, hotkey, evm_key, block_number, signature) + Self::do_associate_evm_key(origin, netuid, evm_key, block_number, signature) } /// Recycles alpha from a cold/hot key pair, reducing AlphaOut on a subnet diff --git a/pallets/subtensor/src/tests/evm.rs b/pallets/subtensor/src/tests/evm.rs index 95d0c4e6db..a65e69c207 100644 --- a/pallets/subtensor/src/tests/evm.rs +++ b/pallets/subtensor/src/tests/evm.rs @@ -58,9 +58,8 @@ fn test_associate_evm_key_success() { let signature = sign_evm_message(&pair, message); assert_ok!(SubtensorModule::associate_evm_key( - RuntimeOrigin::signed(coldkey), + RuntimeOrigin::signed(hotkey), netuid, - hotkey, evm_key, block_number, signature, @@ -105,9 +104,8 @@ fn test_associate_evm_key_different_block_number_success() { let signature = sign_evm_message(&pair, message); assert_ok!(SubtensorModule::associate_evm_key( - RuntimeOrigin::signed(coldkey), + RuntimeOrigin::signed(hotkey), netuid, - hotkey, evm_key, block_number, signature, @@ -125,43 +123,6 @@ fn test_associate_evm_key_different_block_number_success() { }); } -#[test] -fn test_associate_evm_key_coldkey_does_not_own_hotkey() { - new_test_ext(1).execute_with(|| { - let netuid = NetUid::from(1); - - let tempo: u16 = 2; - let modality: u16 = 2; - - add_network(netuid, tempo, modality); - - let coldkey = U256::from(1); - let hotkey = U256::from(2); - - let pair = ecdsa::Pair::generate().0; - let public = pair.public(); - let evm_key = public_to_evm_key(&public); - let block_number = frame_system::Pallet::::block_number(); - let hashed_block_number = keccak_256(block_number.encode().as_ref()); - let hotkey_bytes = hotkey.encode(); - - let message = [hotkey_bytes.as_ref(), hashed_block_number.as_ref()].concat(); - let signature = sign_evm_message(&pair, message); - - assert_err!( - SubtensorModule::associate_evm_key( - RuntimeOrigin::signed(coldkey), - netuid, - hotkey, - evm_key, - block_number, - signature, - ), - Error::::NonAssociatedColdKey - ); - }); -} - #[test] fn test_associate_evm_key_hotkey_not_registered_in_subnet() { new_test_ext(1).execute_with(|| { @@ -188,9 +149,8 @@ fn test_associate_evm_key_hotkey_not_registered_in_subnet() { assert_err!( SubtensorModule::associate_evm_key( - RuntimeOrigin::signed(coldkey), + RuntimeOrigin::signed(hotkey), netuid, - hotkey, evm_key, block_number, signature, @@ -229,9 +189,8 @@ fn test_associate_evm_key_using_wrong_hash_function() { assert_err!( SubtensorModule::associate_evm_key( - RuntimeOrigin::signed(coldkey), + RuntimeOrigin::signed(hotkey), netuid, - hotkey, evm_key, block_number, signature, diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 5d4f1ad493..ba6214968d 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -44,17 +44,11 @@ impl Pallet { pub fn do_associate_evm_key( origin: T::RuntimeOrigin, netuid: NetUid, - hotkey: T::AccountId, evm_key: H160, block_number: u64, mut signature: Signature, ) -> dispatch::DispatchResult { - let coldkey = ensure_signed(origin)?; - - ensure!( - Self::get_owning_coldkey_for_hotkey(&hotkey) == coldkey, - Error::::NonAssociatedColdKey - ); + let hotkey = ensure_signed(origin)?; // Normalize the v value to 0 or 1 if signature.0[64] >= 27 { diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 53cb669a04..0da1ead25c 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -215,7 +215,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 278, + spec_version: 279, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,