diff --git a/Cargo.lock b/Cargo.lock index 0d0487707a..2743813538 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7259,7 +7259,6 @@ dependencies = [ "pallet-balances", "pallet-crowdloan", "pallet-drand", - "pallet-evm", "pallet-evm-chain-id", "pallet-grandpa", "pallet-preimage", @@ -7762,7 +7761,6 @@ dependencies = [ "pallet-collective", "pallet-crowdloan", "pallet-drand", - "pallet-evm", "pallet-membership", "pallet-preimage", "pallet-proxy 38.0.0", diff --git a/evm-tests/src/contracts/pureProxy.ts b/evm-tests/src/contracts/pureProxy.ts deleted file mode 100644 index 8223e98a78..0000000000 --- a/evm-tests/src/contracts/pureProxy.ts +++ /dev/null @@ -1,37 +0,0 @@ -export const IPURE_PROXY_ADDRESS = "0x000000000000000000000000000000000000080a"; - -export const IPureProxyABI = [ - { - "inputs": [], - "name": "createPureProxy", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "getPureProxy", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint8[]", - "name": "call", - "type": "uint8[]" - } - ], - "name": "pureProxyCall", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } -]; \ No newline at end of file diff --git a/evm-tests/src/subtensor.ts b/evm-tests/src/subtensor.ts index 235bcab8c0..a2e5d49083 100644 --- a/evm-tests/src/subtensor.ts +++ b/evm-tests/src/subtensor.ts @@ -353,16 +353,6 @@ export async function setMaxChildkeyTake(api: TypedApi, take: num await waitForTransactionWithRetry(api, tx, alice) } -// use the alice as wrong mapped account to send extrinsic -export async function setPureProxyAccount(api: TypedApi, address: string, account: string) { - const alice = getAliceSigner() - const call = api.tx.SubtensorModule.set_pure_proxy_account({ - address: ethAddressToH160(address), - account - }) - await waitForTransactionWithRetry(api, call, alice) -} - // Swap coldkey to contract address export async function swapColdkey( api: TypedApi, diff --git a/evm-tests/test/pure-proxy.precompile.test.ts b/evm-tests/test/pure-proxy.precompile.test.ts deleted file mode 100644 index 351750faa2..0000000000 --- a/evm-tests/test/pure-proxy.precompile.test.ts +++ /dev/null @@ -1,130 +0,0 @@ -import * as assert from "assert"; - -import { getAliceSigner, getDevnetApi } from "../src/substrate" -import { generateRandomEthersWallet, generateRandomEthWallet } from "../src/utils"; -import { devnet, MultiAddress } from "@polkadot-api/descriptors" -import { hexToU8a } from "@polkadot/util"; -import { PolkadotSigner, TypedApi } from "polkadot-api"; -import { convertPublicKeyToSs58 } from "../src/address-utils" -import { IPureProxyABI, IPURE_PROXY_ADDRESS } from "../src/contracts/pureProxy" -import { keccak256, ethers } from 'ethers'; -import { forceSetBalanceToEthAddress, forceSetBalanceToSs58Address, setPureProxyAccount } from "../src/subtensor"; -import { Signer } from "@polkadot/api/types"; - -function getPureProxyAccount(address: string) { - - const prefix = new TextEncoder().encode("pureproxy:") - - const addressH160 = hexToU8a(address) - - const data = new Uint8Array([...prefix, ...addressH160]); - - return keccak256(data) -} - -async function getTransferCallCode(api: TypedApi, signer: PolkadotSigner) { - const transferAmount = BigInt(1000000000); - - const unsignedTx = api.tx.Balances.transfer_keep_alive({ - dest: MultiAddress.Id(convertPublicKeyToSs58(signer.publicKey)), - value: transferAmount, - }); - const encodedCallDataBytes = await unsignedTx.getEncodedData(); - - // encoded call should be 0x050300d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d02286bee - // const transferCall = encodedCallDataBytes - - const data = encodedCallDataBytes.asBytes() - - return [...data] -} - -describe("Test pure proxy precompile", () => { - const evmWallet = generateRandomEthersWallet(); - const evmWallet2 = generateRandomEthersWallet(); - - let api: TypedApi - - let alice: PolkadotSigner; - - before(async () => { - api = await getDevnetApi() - alice = await getAliceSigner(); - - await forceSetBalanceToEthAddress(api, evmWallet.address) - await forceSetBalanceToEthAddress(api, evmWallet2.address) - - }) - - it("Call createPureProxy, then use proxy to call transfer", async () => { - const contract = new ethers.Contract(IPURE_PROXY_ADDRESS, IPureProxyABI, evmWallet) - - const tx = await contract.createPureProxy() - await tx.wait() - const proxyAddress = await contract.getPureProxy(); - - const expected = getPureProxyAccount(evmWallet.address) - assert.equal(proxyAddress, expected, "the proxy account not the same as expected") - - const ss58Address = convertPublicKeyToSs58(proxyAddress) - - await forceSetBalanceToSs58Address(api, ss58Address) - - const callCode = await getTransferCallCode(api, alice) - const tx2 = await contract.pureProxyCall(callCode) - await tx2.wait() - - }) - - it("Call createPureProxy, edge cases", async () => { - const contract = new ethers.Contract(IPURE_PROXY_ADDRESS, IPureProxyABI, evmWallet2) - const proxyAddressBeforeCreate = await contract.getPureProxy(); - console.log(proxyAddressBeforeCreate) - assert.equal(proxyAddressBeforeCreate, "0x0000000000000000000000000000000000000000000000000000000000000000", "proxy should be undefined before set") - - // use papi to set proxy with wrong mapped account - await setPureProxyAccount(api, evmWallet2.address, convertPublicKeyToSs58(alice.publicKey)) - assert.equal(proxyAddressBeforeCreate, "0x0000000000000000000000000000000000000000000000000000000000000000", "proxy should be zero after wrong signer") - - const callCode = await getTransferCallCode(api, alice) - - // call without proxy - try { - const tx = await contract.pureProxyCall(callCode) - await tx.wait() - } catch (error) { - assert.notEqual(error, undefined, "should fail if proxy not set") - } - - const tx = await contract.createPureProxy() - await tx.wait() - const proxyAddress = await contract.getPureProxy(); - - const expected = getPureProxyAccount(evmWallet2.address) - assert.equal(proxyAddress, expected, "the proxy account not the same as expected") - - // set the proxy again - try { - const tx = await contract.createPureProxy() - await tx.wait() - } catch (error) { - assert.notEqual(error, undefined, "should fail if set proxy again") - } - - // send extrinsic without token - try { - const tx = await contract.pureProxyCall(callCode) - await tx.wait() - } catch (error) { - assert.notEqual(error, undefined, "should fail if proxy without balance") - } - - // set balance for proxy account - const ss58Address = convertPublicKeyToSs58(proxyAddress) - await forceSetBalanceToSs58Address(api, ss58Address) - - // try proxy call finally - const tx2 = await contract.pureProxyCall(callCode) - await tx2.wait() - }) -}); diff --git a/pallets/admin-utils/Cargo.toml b/pallets/admin-utils/Cargo.toml index 22f49e3729..c0abc67ad2 100644 --- a/pallets/admin-utils/Cargo.toml +++ b/pallets/admin-utils/Cargo.toml @@ -45,7 +45,6 @@ pallet-scheduler = { workspace = true } pallet-grandpa = { workspace = true } sp-std = { workspace = true } pallet-subtensor-swap = { workspace = true } -pallet-evm = { workspace = true } pallet-crowdloan = { workspace = true, default-features = false } pallet-preimage = { workspace = true, default-features = false } @@ -59,7 +58,6 @@ std = [ "log/std", "pallet-balances/std", "pallet-drand/std", - "pallet-evm/std", "pallet-evm-chain-id/std", "pallet-grandpa/std", "pallet-scheduler/std", @@ -86,7 +84,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-drand/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-subtensor/runtime-benchmarks", @@ -100,7 +97,6 @@ try-runtime = [ "frame-system/try-runtime", "pallet-balances/try-runtime", "pallet-drand/try-runtime", - "pallet-evm/try-runtime", "pallet-evm-chain-id/try-runtime", "pallet-grandpa/try-runtime", "pallet-scheduler/try-runtime", diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 0ff312f453..8ab39e50cf 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -22,15 +22,6 @@ use sp_weights::Weight; use subtensor_runtime_common::NetUid; type Block = frame_system::mocking::MockBlock; - -pub struct DummyAddressMap; - -impl pallet_evm::AddressMapping for DummyAddressMap { - fn into_account_id(address: sp_core::H160) -> AccountId { - let account = pallet_evm::HashedAddressMapping::::into_account_id(address); - U256::from_big_endian(account.as_ref()) - } -} // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( pub enum Test { @@ -230,7 +221,6 @@ impl pallet_subtensor::Config for Test { type SwapInterface = Swap; type KeySwapOnSubnetCost = InitialKeySwapOnSubnetCost; type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval; - type AddressMapping = DummyAddressMap; type ProxyInterface = (); type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval; } diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 2f3dc85995..2ea43f96c1 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -49,7 +49,6 @@ subtensor-runtime-common = { workspace = true, features = ["approx"] } pallet-collective = { version = "4.0.0-dev", default-features = false, path = "../collective" } pallet-drand = { path = "../drand", default-features = false } -pallet-evm = { workspace = true } pallet-membership = { workspace = true } hex-literal = { workspace = true } num-traits = { version = "0.2.19", default-features = false, features = [ @@ -93,7 +92,6 @@ std = [ "pallet-balances/std", "pallet-collective/std", "pallet-drand/std", - "pallet-evm/std", "pallet-membership/std", "pallet-preimage/std", "pallet-scheduler/std", @@ -136,7 +134,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collective/runtime-benchmarks", - "pallet-evm/runtime-benchmarks", "pallet-drand/runtime-benchmarks", "pallet-membership/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", @@ -152,7 +149,6 @@ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "pallet-balances/try-runtime", - "pallet-evm/try-runtime", "pallet-membership/try-runtime", "pallet-preimage/try-runtime", "pallet-scheduler/try-runtime", diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 7a6686f46c..b239adb70e 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -9,7 +9,7 @@ use frame_benchmarking::v2::*; use frame_support::{StorageDoubleMap, assert_ok}; use frame_system::{RawOrigin, pallet_prelude::BlockNumberFor}; pub use pallet::*; -use sp_core::{H160, H256}; +use sp_core::H256; use sp_runtime::{ BoundedVec, Percent, traits::{BlakeTwo256, Hash}, @@ -20,7 +20,6 @@ use subtensor_runtime_common::{AlphaCurrency, NetUid}; #[frame_benchmarking::v2::benchmarks] mod pallet_benchmarks { use super::*; - use pallet_evm::AddressMapping; #[benchmark] fn register() { @@ -1382,16 +1381,6 @@ mod pallet_benchmarks { _(RawOrigin::Signed(coldkey), hotkey); } - #[benchmark] - fn set_pure_proxy_account() { - let address: H160 = H160::zero(); - let mapped_account = T::AddressMapping::into_account_id(address); - let proxy_account: T::AccountId = account("A", 0, 7); - - #[extrinsic_call] - _(RawOrigin::Signed(mapped_account), address, proxy_account); - } - #[benchmark] fn remove_stake_full_limit() { let netuid = NetUid::from(1); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index edd50d7033..e61aae04e5 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1717,11 +1717,6 @@ pub mod pallet { pub type AssociatedEvmAddress = StorageDoubleMap<_, Twox64Concat, NetUid, Twox64Concat, u16, (H160, u64), OptionQuery>; - #[pallet::storage] - /// --- MAP (H160) --> T::AccountId - pub type PureProxyAccount = - StorageMap<_, Twox64Concat, H160, T::AccountId, OptionQuery>; - /// ======================== /// ==== Subnet Leasing ==== /// ======================== diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index ef037cdc7a..3479ad8101 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -6,7 +6,6 @@ use frame_support::pallet_macros::pallet_section; #[pallet_section] mod config { - use pallet_evm::AddressMapping; use subtensor_swap_interface::SwapHandler; /// Configure the pallet by specifying the parameters and types on which it depends. @@ -56,9 +55,6 @@ mod config { /// Swap interface. type SwapInterface: SwapHandler; - /// Mapping evm address to account Id - type AddressMapping: AddressMapping; - /// Interface to allow interacting with the proxy pallet. type ProxyInterface: crate::ProxyInterface; diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 86ec02b738..01ba58ef3b 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2175,20 +2175,5 @@ mod dispatches { Self::deposit_event(Event::SymbolUpdated { netuid, symbol }); Ok(()) } - - /// Sets proxy account for evm address - #[pallet::call_index(113)] - #[pallet::weight(( - Weight::from_parts(21_010_000, 0).saturating_add(T::DbWeight::get().reads_writes(1, 1)), - DispatchClass::Operational, - Pays::Yes - ))] - pub fn set_pure_proxy_account( - origin: OriginFor, - address: H160, - account: T::AccountId, - ) -> DispatchResult { - Self::do_set_pure_proxy_account(origin, address, account) - } } } diff --git a/pallets/subtensor/src/macros/errors.rs b/pallets/subtensor/src/macros/errors.rs index 46b203c247..1151be75c4 100644 --- a/pallets/subtensor/src/macros/errors.rs +++ b/pallets/subtensor/src/macros/errors.rs @@ -218,10 +218,6 @@ mod errors { SameNetuid, /// The caller does not have enough balance for the operation. InsufficientBalance, - /// Origin not match the mapped EVM account - OriginNotMatchMappedEVM, - /// Pure proxy account already set - PureProxyAccountExisted, /// Too frequent staking operations StakingOperationRateLimitExceeded, /// Invalid lease beneficiary to register the leased network. diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index 4b50275e0f..c0528d0600 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -380,12 +380,5 @@ mod events { /// The symbol that has been updated. symbol: Vec, }, - /// Pure proxy account is set - PureProxyAccountSet { - /// EVM address - address: H160, - /// Pure proxy account - account: T::AccountId, - }, } } diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 10193f1ee3..7f0ff7e597 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -27,14 +27,6 @@ use subtensor_runtime_common::NetUid; use subtensor_swap_interface::{OrderType, SwapHandler}; type Block = frame_system::mocking::MockBlock; -pub struct DummyAddressMap; - -impl pallet_evm::AddressMapping for DummyAddressMap { - fn into_account_id(address: sp_core::H160) -> AccountId { - let account = pallet_evm::HashedAddressMapping::::into_account_id(address); - U256::from_big_endian(account.as_ref()) - } -} // Configure a mock runtime to test the pallet. frame_support::construct_runtime!( @@ -460,7 +452,6 @@ impl crate::Config for Test { type SwapInterface = Swap; type KeySwapOnSubnetCost = InitialKeySwapOnSubnetCost; type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval; - type AddressMapping = DummyAddressMap; type ProxyInterface = FakeProxier; type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval; } diff --git a/pallets/subtensor/src/utils/evm.rs b/pallets/subtensor/src/utils/evm.rs index 52cc813851..652fb8ea27 100644 --- a/pallets/subtensor/src/utils/evm.rs +++ b/pallets/subtensor/src/utils/evm.rs @@ -2,7 +2,6 @@ use super::*; use alloc::string::ToString; use frame_support::ensure; use frame_system::ensure_signed; -use pallet_evm::AddressMapping; use sp_core::{H160, ecdsa::Signature, hashing::keccak_256}; use sp_std::vec::Vec; @@ -101,40 +100,4 @@ impl Pallet { ret_val.sort_by(|(_, block1), (_, block2)| block1.cmp(block2)); ret_val } - - /// Sets a pure proxy account for a given EVM address. - /// - /// This function allows the owner of the EVM-mapped Substrate account to associate a Substrate account - /// with an EVM address as a "pure proxy". The caller must be the Substrate account mapped from the EVM address. - /// If the EVM address already has a pure proxy account, this function will return an error. - /// - /// # Arguments - /// - /// * `origin` - The transaction origin, must be signed by the mapped Substrate account. - /// * `address` - The EVM address to associate with the pure proxy account. - /// * `account` - The Substrate account to set as the pure proxy for the EVM address. - /// - /// # Errors - /// - /// Returns `PureProxyAccountExisted` if the EVM address already has a pure proxy account. - /// Returns `OriginNotMatchMappedEVM` if the caller is not the mapped Substrate account for the EVM address. - pub fn do_set_pure_proxy_account( - origin: T::RuntimeOrigin, - address: H160, - account: T::AccountId, - ) -> dispatch::DispatchResult { - let caller = ensure_signed(origin)?; - if PureProxyAccount::::get(address).is_some() { - return Err(Error::::PureProxyAccountExisted.into()); - } - let owner: T::AccountId = T::AddressMapping::into_account_id(address); - - ensure!(caller == owner, Error::::OriginNotMatchMappedEVM); - - PureProxyAccount::::insert(address, account.clone()); - - Self::deposit_event(Event::PureProxyAccountSet { address, account }); - - Ok(()) - } } diff --git a/precompiles/src/lib.rs b/precompiles/src/lib.rs index 9eab384e3d..2eb83d1678 100644 --- a/precompiles/src/lib.rs +++ b/precompiles/src/lib.rs @@ -24,6 +24,7 @@ use subtensor_runtime_common::ProxyType; use pallet_admin_utils::PrecompileEnum; +use crate::alpha::*; use crate::balance_transfer::*; use crate::crowdloan::*; use crate::ed25519::*; @@ -35,7 +36,6 @@ use crate::staking::*; use crate::storage_query::*; use crate::subnet::*; use crate::uid_lookup::*; -use crate::{alpha::*, pure_proxy::PureProxyPrecompile}; mod alpha; mod balance_transfer; @@ -44,7 +44,6 @@ mod ed25519; mod extensions; mod metagraph; mod neuron; -mod pure_proxy; mod sr25519; mod staking; mod storage_query; @@ -105,7 +104,7 @@ where Self(Default::default()) } - pub fn used_addresses() -> [H160; 21] { + pub fn used_addresses() -> [H160; 20] { [ hash(1), hash(2), @@ -127,7 +126,6 @@ where hash(UidLookupPrecompile::::INDEX), hash(AlphaPrecompile::::INDEX), hash(CrowdloanPrecompile::::INDEX), - hash(PureProxyPrecompile::::INDEX), ] } } @@ -208,9 +206,6 @@ where a if a == hash(CrowdloanPrecompile::::INDEX) => { CrowdloanPrecompile::::try_execute::(handle, PrecompileEnum::Crowdloan) } - a if a == hash(PureProxyPrecompile::::INDEX) => { - PureProxyPrecompile::::try_execute::(handle, PrecompileEnum::PureProxy) - } _ => None, } } diff --git a/precompiles/src/pure_proxy.rs b/precompiles/src/pure_proxy.rs deleted file mode 100644 index 3a7c7dbb89..0000000000 --- a/precompiles/src/pure_proxy.rs +++ /dev/null @@ -1,111 +0,0 @@ -use core::marker::PhantomData; - -use crate::{PrecompileExt, PrecompileHandleExt}; -use codec::DecodeLimit; -use fp_evm::{ExitError, PrecompileFailure}; -use frame_support::dispatch::{GetDispatchInfo, PostDispatchInfo}; -use frame_system::RawOrigin; -use pallet_evm::{AddressMapping, PrecompileHandle}; -use precompile_utils::EvmResult; -use sp_core::keccak_256; -use sp_core::{H160, H256}; -use sp_runtime::traits::Dispatchable; -use sp_std::vec::Vec; - -pub struct PureProxyPrecompile(PhantomData); -const MAX_DECODE_DEPTH: u32 = 8; -impl PureProxyPrecompile -where - R: frame_system::Config + pallet_evm::Config + pallet_subtensor::Config, - R::AccountId: From<[u8; 32]> + Into<[u8; 32]>, -{ - fn into_pure_proxy_account_id(address: &H160) -> R::AccountId { - let mut data = [0u8; 30]; - data[0..10].copy_from_slice(b"pureproxy:"); - data[10..30].copy_from_slice(&address[..]); - let hash = keccak_256(&data); - - R::AccountId::from(Into::<[u8; 32]>::into(hash)) - } -} - -impl PrecompileExt for PureProxyPrecompile -where - R: frame_system::Config + pallet_evm::Config + pallet_subtensor::Config, - R::AccountId: From<[u8; 32]> + Into<[u8; 32]>, - ::RuntimeCall: From> - + GetDispatchInfo - + Dispatchable, - ::AddressMapping: AddressMapping, -{ - const INDEX: u64 = 2058; -} - -#[precompile_utils::precompile] -impl PureProxyPrecompile -where - R: frame_system::Config + pallet_evm::Config + pallet_subtensor::Config, - R::AccountId: From<[u8; 32]> + Into<[u8; 32]>, - ::RuntimeCall: From> - + GetDispatchInfo - + Dispatchable, - ::AddressMapping: AddressMapping, -{ - #[precompile::public("createPureProxy()")] - #[precompile::payable] - pub fn create_pure_proxy(handle: &mut impl PrecompileHandle) -> EvmResult<()> { - let caller = handle.context().caller; - if pallet_subtensor::PureProxyAccount::::get(caller).is_none() { - let account = Self::into_pure_proxy_account_id(&caller); - - let call = pallet_subtensor::Call::::set_pure_proxy_account { - address: caller, - account, - }; - - handle.try_dispatch_runtime_call::( - call, - RawOrigin::Signed(handle.caller_account_id::()), - ) - } else { - Err(PrecompileFailure::Error { - exit_status: ExitError::Other("Pure proxy account already created yet".into()), - }) - } - } - - #[precompile::public("pureProxyCall(uint8[])")] - #[precompile::payable] - pub fn pure_proxy_call(handle: &mut impl PrecompileHandle, call: Vec) -> EvmResult<()> { - let caller = handle.context().caller; - match pallet_subtensor::PureProxyAccount::::get(caller) { - Some(account) => { - let call = ::RuntimeCall::decode_with_depth_limit( - MAX_DECODE_DEPTH, - &mut &call[..], - ) - .map_err(|_| PrecompileFailure::Error { - exit_status: ExitError::Other("The raw call data not correctly encoded".into()), - })?; - - handle.try_dispatch_runtime_call::::RuntimeCall>( - call, - RawOrigin::Signed(account), - ) - } - None => Err(PrecompileFailure::Error { - exit_status: ExitError::Other("Pure proxy account not created yet".into()), - }), - } - } - - #[precompile::public("getPureProxy()")] - #[precompile::view] - fn get_pure_proxy(handle: &mut impl PrecompileHandle) -> EvmResult { - let caller = handle.context().caller; - let result = pallet_subtensor::PureProxyAccount::::get(caller); - let buf: [u8; 32] = result.map(|account| account.into()).unwrap_or([0_u8; 32]); - - Ok(H256::from(buf)) - } -} diff --git a/precompiles/src/solidity/pureProxy.sol b/precompiles/src/solidity/pureProxy.sol deleted file mode 100644 index b5b4886135..0000000000 --- a/precompiles/src/solidity/pureProxy.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma solidity ^0.8.0; - -address constant IPURE_PROXY_ADDRESS = 0x000000000000000000000000000000000000080a; - -interface IPureProxy { - function createPureProxy() external returns (bytes32); - - function pureProxyCall(uint8[] memory call) external; - - function getPureProxy() external view returns (bytes32); -} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f56b89e84e..624ee0edf8 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -218,7 +218,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: 296, + spec_version: 297, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, @@ -1285,7 +1285,6 @@ impl pallet_subtensor::Config for Runtime { type SwapInterface = Swap; type KeySwapOnSubnetCost = SubtensorInitialKeySwapOnSubnetCost; type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval; - type AddressMapping = pallet_evm::HashedAddressMapping; type ProxyInterface = Proxier; type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval; }