From c6d4dfeb64b5d3f290c4021444be699b548f7c47 Mon Sep 17 00:00:00 2001 From: Shaun Wang Date: Thu, 14 Sep 2023 19:16:32 +1000 Subject: [PATCH 1/6] XVM: replace MultiAddress with AccountId for ink! contracts (#1024) * XVM: replace MultiAddress with AccountId for ink! contracts. * Remove unused feature in integration tests. --- pallets/xvm/src/lib.rs | 4 +--- pallets/xvm/src/tests.rs | 2 +- tests/integration/src/xvm.rs | 28 ++++++++++++++-------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/pallets/xvm/src/lib.rs b/pallets/xvm/src/lib.rs index d3c0284b68..1b5de63c64 100644 --- a/pallets/xvm/src/lib.rs +++ b/pallets/xvm/src/lib.rs @@ -47,7 +47,6 @@ use pallet_contracts_primitives::ReturnFlags; use pallet_evm::GasWeightMapping; use parity_scale_codec::Decode; use sp_core::{H160, U256}; -use sp_runtime::traits::StaticLookup; use sp_std::{marker::PhantomData, prelude::*}; use astar_primitives::{ @@ -290,8 +289,7 @@ where let dest = { let error = CallFailure::revert(InvalidTarget, overheads); - let decoded = Decode::decode(&mut target.as_ref()).map_err(|_| error.clone())?; - T::Lookup::lookup(decoded).map_err(|_| error) + Decode::decode(&mut target.as_ref()).map_err(|_| error.clone()) }?; // With overheads, less weight is available. diff --git a/pallets/xvm/src/tests.rs b/pallets/xvm/src/tests.rs index 52794acb9b..09593bd012 100644 --- a/pallets/xvm/src/tests.rs +++ b/pallets/xvm/src/tests.rs @@ -58,7 +58,7 @@ fn calling_into_same_vm_is_not_allowed() { weight_limit: Weight::from_parts(1_000_000, 1_000_000), }; let wasm_vm_id = VmId::Wasm; - let wasm_target = MultiAddress::::Id(ALICE).encode(); + let wasm_target = ALICE.encode(); let wasm_used_weight: Weight = weights::SubstrateWeight::::wasm_call_overheads(); assert_noop!( diff --git a/tests/integration/src/xvm.rs b/tests/integration/src/xvm.rs index 2bca811e5c..08291ce51d 100644 --- a/tests/integration/src/xvm.rs +++ b/tests/integration/src/xvm.rs @@ -231,7 +231,7 @@ fn wasm_payable_call_via_xvm_works() { }, VmId::Wasm, ALICE, - MultiAddress::::Id(wasm_payable_addr.clone()).encode(), + wasm_payable_addr.clone().encode(), // Calling `deposit` hex::decode("0000002a").expect("invalid selector hex"), value, @@ -255,10 +255,10 @@ fn calling_wasm_payable_from_evm_fails_if_caller_contract_balance_below_ed() { RuntimeOrigin::root(), alith(), evm_caller_addr.clone(), - // to: 0x00a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c + // to: 0xa8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c // input: 0x0000002a (deposit) // value: 1000000000 - hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000002100a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"), + hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000000000000000020a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c00000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"), U256::from(value), 1_000_000, U256::from(DefaultBaseFeePerGas::get()), @@ -295,10 +295,10 @@ fn calling_wasm_payable_from_evm_works() { RuntimeOrigin::root(), alith(), evm_caller_addr.clone(), - // to: 0x00a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c + // to: 0xa8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c // input: 0x0000002a (deposit) // value: 1000000000 - hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000002100a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"), + hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000000000000000020a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c00000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"), U256::from(value), 1_000_000, U256::from(DefaultBaseFeePerGas::get()), @@ -363,10 +363,10 @@ fn reentrance_not_allowed() { let evm_caller_addr = deploy_evm_contract(CALL_WASM_PAYBLE); let _ = deploy_wasm_contract(WASM_PAYABLE_NAME); - // to: 0x00a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c + // to: 0xa8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c // input: 0x0000002a (deposit) // value: 1000000000 - let call_wasm_payable_input = hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000002100a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"); + let call_wasm_payable_input = hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000003b9aca000000000000000000000000000000000000000000000000000000000000000020a8f69d59df362b69a8d4acdb9001eb3e1b8d067b8fdaa70081aed945bde5c48c00000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"); let input = hex::decode("0000002a") .expect("invalid selector hex") .iter() @@ -522,7 +522,7 @@ fn wasm_call_via_xvm_fails_if_revert() { }, VmId::Wasm, ALICE, - MultiAddress::::Id(wasm_callee_addr.clone()).encode(), + wasm_callee_addr.clone().encode(), input, 0, None, @@ -546,10 +546,10 @@ fn evm_caller_reverts_if_wasm_callee_reverted() { let _ = deploy_wasm_contract(WASM_DUMMY_ERROR_NAME); let evm_caller_addr = deploy_evm_contract(CALL_WASM_PAYBLE); - // to: 0x00a0565d335eb7545deeb25563471219e6f0c9b9bb504a112a5f26fe61237c5a23 + // to: 0xa0565d335eb7545deeb25563471219e6f0c9b9bb504a112a5f26fe61237c5a23 // input: 0x0000002a (do_revert) // value: 0 - let input = hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002100a0565d335eb7545deeb25563471219e6f0c9b9bb504a112a5f26fe61237c5a230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"); + let input = hex::decode("4012b914000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020a0565d335eb7545deeb25563471219e6f0c9b9bb504a112a5f26fe61237c5a2300000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"); let tx = CheckedEthereumTx { target: evm_caller_addr.clone(), input: EthereumTxInput::try_from(input).expect("input too large"), @@ -666,7 +666,7 @@ fn wasm_call_via_xvm_fails_if_storage_deposit_limit_exhausted() { }, VmId::Wasm, ALICE, - MultiAddress::::Id(wasm_callee_addr.clone()).encode(), + wasm_callee_addr.clone().encode(), input, 0, Some(0) @@ -696,7 +696,7 @@ fn wasm_call_via_xvm_call_works_if_sufficient_storage_deposit_limit() { }, VmId::Wasm, ALICE, - MultiAddress::::Id(wasm_callee_addr.clone()).encode(), + wasm_callee_addr.clone().encode(), input, 0, Some(UNIT) @@ -742,11 +742,11 @@ fn calling_wasm_from_evm_works_if_sufficient_storage_deposit_limit() { RuntimeOrigin::root(), alith(), evm_caller_addr.clone(), - // to: 0x000e0ddb5a5f0b99d7be468a3051a94073ec6b1900178316401a52b93415026999 + // to: 0x0e0ddb5a5f0b99d7be468a3051a94073ec6b1900178316401a52b93415026999 // input: 0x0000002a (store) // value: 0 // storage_deposit_limit: 1_000_000_000_000 - hex::decode("2d9338da000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e8d4a510000000000000000000000000000000000000000000000000000000000000000021000e0ddb5a5f0b99d7be468a3051a94073ec6b1900178316401a52b934150269990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"), + hex::decode("2d9338da000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e8d4a5100000000000000000000000000000000000000000000000000000000000000000200e0ddb5a5f0b99d7be468a3051a94073ec6b1900178316401a52b9341502699900000000000000000000000000000000000000000000000000000000000000040000002a00000000000000000000000000000000000000000000000000000000").expect("invalid call input hex"), U256::zero(), 1_000_000, U256::from(DefaultBaseFeePerGas::get()), From c4ce8f1d26d95acd0651ee3566593d9c14352a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Pa=C4=8Dandi?= <3002868+Dinonard@users.noreply.github.com> Date: Mon, 18 Sep 2023 22:51:18 +0200 Subject: [PATCH 2/6] Remove unused XCM consts (#1026) --- runtime/astar/src/xcm_config.rs | 5 ----- runtime/shibuya/src/xcm_config.rs | 5 ----- runtime/shiden/src/xcm_config.rs | 5 ----- 3 files changed, 15 deletions(-) diff --git a/runtime/astar/src/xcm_config.rs b/runtime/astar/src/xcm_config.rs index 5c86c9e93f..c147f4cdf4 100644 --- a/runtime/astar/src/xcm_config.rs +++ b/runtime/astar/src/xcm_config.rs @@ -20,7 +20,6 @@ use super::{ AccountId, AllPalletsWithSystem, AssetId, Assets, AstarAssetLocationIdConverter, Balance, Balances, DealWithFees, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, TreasuryAccountId, WeightToFee, XcAssetConfig, XcmpQueue, - MAXIMUM_BLOCK_WEIGHT, }; use frame_support::{ match_types, parameter_types, @@ -270,10 +269,6 @@ impl xcm_executor::Config for XcmConfig { type SafeCallFilter = SafeCallFilter; } -parameter_types! { - pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(10); -} - /// Local origins on this chain are allowed to dispatch XCM sends/executions. pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/runtime/shibuya/src/xcm_config.rs b/runtime/shibuya/src/xcm_config.rs index 3848b0bd1a..4ef26d328d 100644 --- a/runtime/shibuya/src/xcm_config.rs +++ b/runtime/shibuya/src/xcm_config.rs @@ -20,7 +20,6 @@ use super::{ AccountId, AllPalletsWithSystem, AssetId, Assets, Balance, Balances, DealWithFees, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, ShibuyaAssetLocationIdConverter, TreasuryAccountId, WeightToFee, XcAssetConfig, XcmpQueue, - MAXIMUM_BLOCK_WEIGHT, }; use frame_support::{ match_types, parameter_types, @@ -204,10 +203,6 @@ impl xcm_executor::Config for XcmConfig { type SafeCallFilter = Everything; } -parameter_types! { - pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(10); -} - /// Local origins on this chain are allowed to dispatch XCM sends/executions. pub type LocalOriginToLocation = SignedToAccountId32; diff --git a/runtime/shiden/src/xcm_config.rs b/runtime/shiden/src/xcm_config.rs index 981c906c5c..ee3a3d678b 100644 --- a/runtime/shiden/src/xcm_config.rs +++ b/runtime/shiden/src/xcm_config.rs @@ -20,7 +20,6 @@ use super::{ AccountId, AllPalletsWithSystem, AssetId, Assets, Balance, Balances, BurnFees, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, ShidenAssetLocationIdConverter, TreasuryAccountId, WeightToFee, XcAssetConfig, XcmpQueue, - MAXIMUM_BLOCK_WEIGHT, }; use frame_support::{ match_types, parameter_types, @@ -274,10 +273,6 @@ impl xcm_executor::Config for XcmConfig { type SafeCallFilter = SafeCallFilter; } -parameter_types! { - pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(10); -} - /// Local origins on this chain are allowed to dispatch XCM sends/executions. pub type LocalOriginToLocation = SignedToAccountId32; From 676293714227065c8323a37269b18297073f0c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dino=20Pa=C4=8Dandi?= <3002868+Dinonard@users.noreply.github.com> Date: Fri, 22 Sep 2023 12:51:39 +0100 Subject: [PATCH 3/6] Remove unused XCM consts (#1026) (#1028) --- Cargo.lock | 16 ++++++++-------- bin/collator/Cargo.toml | 2 +- runtime/astar/Cargo.toml | 2 +- runtime/local/Cargo.toml | 2 +- runtime/shibuya/Cargo.toml | 2 +- runtime/shiden/Cargo.toml | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28f586a9b3..63ae1234c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -404,7 +404,7 @@ dependencies = [ [[package]] name = "astar-collator" -version = "5.18.0" +version = "5.18.1" dependencies = [ "astar-primitives", "astar-runtime", @@ -533,7 +533,7 @@ dependencies = [ [[package]] name = "astar-runtime" -version = "5.18.0" +version = "5.18.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -5495,7 +5495,7 @@ checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "local-runtime" -version = "5.18.0" +version = "5.18.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -10171,9 +10171,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" +checksum = "c956be1b23f4261676aed05a0046e204e8a6836e50203902683a718af0797989" dependencies = [ "bytes", "rand 0.8.5", @@ -12356,7 +12356,7 @@ dependencies = [ [[package]] name = "shibuya-runtime" -version = "5.18.0" +version = "5.18.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -12464,7 +12464,7 @@ dependencies = [ [[package]] name = "shiden-runtime" -version = "5.18.0" +version = "5.18.1" dependencies = [ "array-bytes 6.1.0", "astar-primitives", @@ -14462,7 +14462,7 @@ checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if", "digest 0.10.7", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] diff --git a/bin/collator/Cargo.toml b/bin/collator/Cargo.toml index 3c7fccb18e..3e2f1533b8 100644 --- a/bin/collator/Cargo.toml +++ b/bin/collator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-collator" -version = "5.18.0" +version = "5.18.1" description = "Astar collator implementation in Rust." build = "build.rs" default-run = "astar-collator" diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 83458c9806..c4ad5a0858 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "astar-runtime" -version = "5.18.0" +version = "5.18.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index 44012e1760..5fab41f77f 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "local-runtime" -version = "5.18.0" +version = "5.18.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 20e1cf7efd..72c1d69ce5 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shibuya-runtime" -version = "5.18.0" +version = "5.18.1" build = "build.rs" authors.workspace = true edition.workspace = true diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 9e8b34b62a..8a86693eb6 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "shiden-runtime" -version = "5.18.0" +version = "5.18.1" build = "build.rs" authors.workspace = true edition.workspace = true From 9395ce0c50da8fc92b368be37403d839e5a17448 Mon Sep 17 00:00:00 2001 From: Marijan <77665447+mc2eqe@users.noreply.github.com> Date: Mon, 25 Sep 2023 09:25:18 +0200 Subject: [PATCH 4/6] Added concurrency for cancel previous runs (#1029) --- .github/workflows/base_checks.yaml | 14 ++++---------- .github/workflows/coverage.yaml | 14 ++++---------- .github/workflows/static-analysis.yml | 14 ++++---------- .github/workflows/tests.yaml | 14 ++++---------- 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/.github/workflows/base_checks.yaml b/.github/workflows/base_checks.yaml index 2e7283dc89..89c36530d6 100644 --- a/.github/workflows/base_checks.yaml +++ b/.github/workflows/base_checks.yaml @@ -6,17 +6,11 @@ on: tags-ignore: - v[0-9]+.[0-9]+.[0-9]+* workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + jobs: - clean-up-actions: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - # Only cancel non-master branch runs - if: ${{ github.ref != 'refs/heads/master' }} - uses: styfle/cancel-workflow-action@0.11.0 - with: - access_token: ${{ github.token }} - compile-and-check: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 0c71ebad42..c029940d61 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -3,17 +3,11 @@ on: pull_request: types: [opened, reopened, synchronize, ready_for_review] workflow_dispatch: -jobs: - clean-up-actions: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - # Only cancel non-master branch runs - if: ${{ github.ref != 'refs/heads/master' }} - uses: styfle/cancel-workflow-action@0.11.0 - with: - access_token: ${{ github.token }} +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} +jobs: coverage: if: github.event.pull_request.draft == false runs-on: ubuntu-latest diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index fef5cba5d9..b63af25587 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,16 +1,10 @@ name: Static Analysis on: [push, workflow_dispatch] -jobs: - clean-up-actions: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - # Only cancel non-master branch runs - if: ${{ github.ref != 'refs/heads/master' }} - uses: styfle/cancel-workflow-action@0.11.0 - with: - access_token: ${{ github.token }} +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} +jobs: fmt: if: github.event.pull_request.draft == false runs-on: [self-hosted, Linux, X64] diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6218f3d9d3..10fe04f9b4 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -6,17 +6,11 @@ on: tags-ignore: - v[0-9]+.[0-9]+.[0-9]+* workflow_dispatch: -jobs: - clean-up-actions: - runs-on: ubuntu-latest - steps: - - name: Cancel Previous Runs - # Only cancel non-master branch runs - if: ${{ github.ref != 'refs/heads/master' }} - uses: styfle/cancel-workflow-action@0.11.0 - with: - access_token: ${{ github.token }} +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} +jobs: test-runtimes: runs-on: ubuntu-latest steps: From ac29f4dc92f903f6631351820dbb75a763269ac2 Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Mon, 25 Sep 2023 19:52:49 +0530 Subject: [PATCH 5/6] feat: remove deprecated functionality (#999) * feat: remove deprecated functionality remove deprecated custom signaturee pallet * feat: apply code suggestions * feat: remove deprecated pallet --- Cargo.lock | 24 -- Cargo.toml | 1 - pallets/custom-signatures/Cargo.toml | 43 --- pallets/custom-signatures/src/ethereum.rs | 100 ------- pallets/custom-signatures/src/lib.rs | 220 -------------- pallets/custom-signatures/src/tests.rs | 334 ---------------------- runtime/astar/Cargo.toml | 3 - runtime/astar/src/lib.rs | 27 +- runtime/local/Cargo.toml | 3 - runtime/local/src/lib.rs | 26 +- runtime/shibuya/Cargo.toml | 3 - runtime/shibuya/src/lib.rs | 26 +- runtime/shiden/Cargo.toml | 3 - runtime/shiden/src/lib.rs | 26 +- 14 files changed, 8 insertions(+), 831 deletions(-) delete mode 100644 pallets/custom-signatures/Cargo.toml delete mode 100644 pallets/custom-signatures/src/ethereum.rs delete mode 100644 pallets/custom-signatures/src/lib.rs delete mode 100644 pallets/custom-signatures/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index 63ae1234c2..5028d29d9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -571,7 +571,6 @@ dependencies = [ "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", - "pallet-custom-signatures", "pallet-dapps-staking", "pallet-ethereum", "pallet-evm", @@ -5523,7 +5522,6 @@ dependencies = [ "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", - "pallet-custom-signatures", "pallet-dapps-staking", "pallet-democracy", "pallet-ethereum", @@ -7085,26 +7083,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-custom-signatures" -version = "4.6.0" -dependencies = [ - "assert_matches", - "frame-support", - "frame-system", - "hex-literal", - "libsecp256k1", - "pallet-balances", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-dapps-staking" version = "3.10.0" @@ -12397,7 +12375,6 @@ dependencies = [ "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", - "pallet-custom-signatures", "pallet-dapps-staking", "pallet-democracy", "pallet-ethereum", @@ -12502,7 +12479,6 @@ dependencies = [ "pallet-collective", "pallet-contracts", "pallet-contracts-primitives", - "pallet-custom-signatures", "pallet-dapps-staking", "pallet-ethereum", "pallet-evm", diff --git a/Cargo.toml b/Cargo.toml index fd6f3ee412..a6d739f9df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -272,7 +272,6 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu # (wasm) pallet-block-reward = { path = "./pallets/block-reward", default-features = false } pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false } -pallet-custom-signatures = { path = "./pallets/custom-signatures", default-features = false } pallet-dapps-staking = { path = "./pallets/dapps-staking", default-features = false } pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false } pallet-xvm = { path = "./pallets/xvm", default-features = false } diff --git a/pallets/custom-signatures/Cargo.toml b/pallets/custom-signatures/Cargo.toml deleted file mode 100644 index 94dc4a7e3a..0000000000 --- a/pallets/custom-signatures/Cargo.toml +++ /dev/null @@ -1,43 +0,0 @@ -[package] -name = "pallet-custom-signatures" -version = "4.6.0" -license = "Apache-2.0" -description = "FRAME pallet for user defined extrinsic signatures" -authors.workspace = true -edition.workspace = true -homepage.workspace = true -repository.workspace = true - -[dependencies] -frame-support = { workspace = true } -frame-system = { workspace = true } -parity-scale-codec = { workspace = true } -scale-info = { workspace = true } -serde = { workspace = true, optional = true } -sp-core = { workspace = true } -sp-io = { workspace = true } -sp-runtime = { workspace = true } -sp-std = { workspace = true } - -[dev-dependencies] -assert_matches = { workspace = true } -hex-literal = { workspace = true } -libsecp256k1 = { workspace = true } -pallet-balances = { workspace = true } -sp-keyring = { workspace = true } - -[features] -default = ["std"] -std = [ - "serde", - "parity-scale-codec/std", - "pallet-balances/std", - "scale-info/std", - "sp-io/std", - "sp-std/std", - "sp-core/std", - "sp-runtime/std", - "frame-support/std", - "frame-system/std", -] -try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/custom-signatures/src/ethereum.rs b/pallets/custom-signatures/src/ethereum.rs deleted file mode 100644 index 0a93d3803b..0000000000 --- a/pallets/custom-signatures/src/ethereum.rs +++ /dev/null @@ -1,100 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Ethereum prefixed signatures compatibility instances. - -use parity_scale_codec::{Decode, Encode}; -use sp_core::ecdsa; -use sp_io::{crypto::secp256k1_ecdsa_recover_compressed, hashing::keccak_256}; -use sp_runtime::traits::{IdentifyAccount, Lazy, Verify}; -use sp_runtime::MultiSignature; -use sp_std::prelude::*; - -/// Ethereum-compatible signature type. -#[derive(Encode, Decode, PartialEq, Eq, Clone, scale_info::TypeInfo)] -pub struct EthereumSignature(pub [u8; 65]); - -impl sp_std::fmt::Debug for EthereumSignature { - fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result { - write!(f, "EthereumSignature({:?})", &self.0[..]) - } -} - -impl From for EthereumSignature { - fn from(signature: ecdsa::Signature) -> Self { - Self(signature.into()) - } -} - -impl sp_std::convert::TryFrom> for EthereumSignature { - type Error = (); - - fn try_from(data: Vec) -> Result { - if data.len() == 65 { - let mut inner = [0u8; 65]; - inner.copy_from_slice(&data[..]); - Ok(EthereumSignature(inner)) - } else { - Err(()) - } - } -} - -/// Constructs the message that Ethereum RPC's `personal_sign` and `eth_sign` would sign. -/// -/// Note: sign message hash to escape of message length estimation. -pub fn signable_message(what: &[u8]) -> Vec { - let hash = keccak_256(what); - let mut v = b"\x19Ethereum Signed Message:\n32".to_vec(); - v.extend_from_slice(&hash[..]); - v -} - -/// Attempts to recover the Ethereum public key from a message signature signed by using -/// the Ethereum RPC's `personal_sign` and `eth_sign`. -impl Verify for EthereumSignature { - type Signer = ::Signer; - - fn verify>( - &self, - mut msg: L, - account: &::AccountId, - ) -> bool { - let msg = keccak_256(&signable_message(msg.get())); - match secp256k1_ecdsa_recover_compressed(&self.0, &msg).ok() { - Some(public) => { - let signer = Self::Signer::from(ecdsa::Public::from_raw(public)); - *account == signer.into_account() - } - None => false, - } - } -} - -#[test] -fn verify_should_works() { - use hex_literal::hex; - use sp_core::{ecdsa, Pair}; - - let msg = "test eth signed message"; - let pair = ecdsa::Pair::from_seed(&hex![ - "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" - ]); - let account = ::Signer::from(pair.public()).into_account(); - let signature = EthereumSignature(hex!["f5d5cc953828e3fb0d81f3176d88fa5c73d3ad3dc4bc7a8061b03a6db2cd73337778df75a1443e8c642f6ceae0db39b90c321ac270ad7836695cae76f703f3031c"]); - assert_eq!(signature.verify(msg.as_ref(), &account), true); -} diff --git a/pallets/custom-signatures/src/lib.rs b/pallets/custom-signatures/src/lib.rs deleted file mode 100644 index 530cfd9d02..0000000000 --- a/pallets/custom-signatures/src/lib.rs +++ /dev/null @@ -1,220 +0,0 @@ -// This file is part of Astar. - -// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#![cfg_attr(not(feature = "std"), no_std)] - -pub use pallet::*; - -/// Ethereum-compatible signatures (eth_sign API call). -pub mod ethereum; - -#[cfg(test)] -mod tests; - -#[frame_support::pallet] -pub mod pallet { - use frame_support::{ - dispatch::{Dispatchable, GetDispatchInfo}, - pallet_prelude::*, - traits::{Currency, ExistenceRequirement, Get, OnUnbalanced, WithdrawReasons}, - }; - use frame_system::{ensure_none, pallet_prelude::*}; - use sp_runtime::traits::{IdentifyAccount, Verify}; - use sp_std::{convert::TryFrom, prelude::*}; - - #[pallet::pallet] - pub struct Pallet(_); - - /// The balance type of this pallet. - pub type BalanceOf = - <::Currency as Currency<::AccountId>>::Balance; - - #[pallet::config] - pub trait Config: frame_system::Config { - /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - /// A signable call. - type RuntimeCall: Parameter - + Dispatchable - + GetDispatchInfo; - - /// User defined signature type. - type Signature: Parameter + Verify + TryFrom>; - - /// User defined signer type. - type Signer: IdentifyAccount; - - /// The currency trait. - type Currency: Currency; - - /// The call fee destination. - type OnChargeTransaction: OnUnbalanced< - >::NegativeImbalance, - >; - - /// The call processing fee amount. - #[pallet::constant] - type CallFee: Get>; - - /// The call magic number. - #[pallet::constant] - type CallMagicNumber: Get; - - /// A configuration for base priority of unsigned transactions. - /// - /// This is exposed so that it can be tuned for particular runtime, when - /// multiple pallets send unsigned transactions. - type UnsignedPriority: Get; - } - - #[pallet::error] - pub enum Error { - /// Signature decode fails. - DecodeFailure, - /// Signature and account mismatched. - InvalidSignature, - /// Bad nonce parameter. - BadNonce, - } - - #[pallet::event] - #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum Event { - /// A call just executed. \[result\] - Executed(T::AccountId, DispatchResult), - } - - #[pallet::call] - impl Pallet { - /// # - /// - O(1). - /// - Limited storage reads. - /// - One DB write (event). - /// - Weight of derivative `call` execution + read/write + 10_000. - /// # - #[pallet::call_index(0)] - #[pallet::weight({ - let dispatch_info = call.get_dispatch_info(); - (dispatch_info.weight.saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - .saturating_add(Weight::from_parts(10_000, 0)), - dispatch_info.class) - })] - pub fn call( - origin: OriginFor, - call: Box<::RuntimeCall>, - signer: T::AccountId, - signature: Vec, - #[pallet::compact] nonce: T::Index, - ) -> DispatchResultWithPostInfo { - ensure_none(origin)?; - - // Ensure that transaction isn't stale - ensure!( - nonce == frame_system::Pallet::::account_nonce(signer.clone()), - Error::::BadNonce, - ); - - let signature = ::Signature::try_from(signature) - .map_err(|_| Error::::DecodeFailure)?; - - // Ensure that transaction signature is valid - ensure!( - Self::valid_signature(&call, &signer, &signature, &nonce), - Error::::InvalidSignature - ); - - // Increment account nonce - frame_system::Pallet::::inc_account_nonce(signer.clone()); - - // Processing fee - let tx_fee = T::Currency::withdraw( - &signer, - T::CallFee::get(), - WithdrawReasons::FEE, - ExistenceRequirement::AllowDeath, - )?; - T::OnChargeTransaction::on_unbalanced(tx_fee); - - // Dispatch call - let new_origin = frame_system::RawOrigin::Signed(signer.clone()).into(); - let res = call.dispatch(new_origin).map(|_| ()); - Self::deposit_event(Event::Executed(signer, res.map_err(|e| e.error))); - - // Fee already charged - Ok(Pays::No.into()) - } - } - - impl Pallet { - /// Verify custom signature and returns `true` if correct. - pub fn valid_signature( - call: &Box<::RuntimeCall>, - signer: &T::AccountId, - signature: &T::Signature, - nonce: &T::Index, - ) -> bool { - let payload = (T::CallMagicNumber::get(), *nonce, call.clone()); - signature.verify(&payload.encode()[..], signer) - } - } - - pub(crate) const SIGNATURE_DECODE_FAILURE: u8 = 1; - - #[pallet::validate_unsigned] - impl frame_support::unsigned::ValidateUnsigned for Pallet { - type Call = Call; - - fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { - // Call decomposition (we have only one possible value here) - let (call, signer, signature, nonce) = match call { - Call::call { - call, - signer, - signature, - nonce, - } => (call, signer, signature, nonce), - _ => return InvalidTransaction::Call.into(), - }; - - // Check that tx isn't stale - if *nonce != frame_system::Pallet::::account_nonce(signer.clone()) { - return InvalidTransaction::Stale.into(); - } - - // Check signature encoding - if let Ok(signature) = ::Signature::try_from(signature.clone()) { - // Verify signature - if Self::valid_signature(call, signer, &signature, nonce) { - ValidTransaction::with_tag_prefix("CustomSignatures") - .priority(T::UnsignedPriority::get()) - .and_provides((call, signer, nonce)) - .longevity(64_u64) - .propagate(true) - .build() - } else { - // Signature mismatched to given signer - InvalidTransaction::BadProof.into() - } - } else { - // Signature encoding broken - InvalidTransaction::Custom(SIGNATURE_DECODE_FAILURE).into() - } - } - } -} diff --git a/pallets/custom-signatures/src/tests.rs b/pallets/custom-signatures/src/tests.rs deleted file mode 100644 index 67ac06eb9b..0000000000 --- a/pallets/custom-signatures/src/tests.rs +++ /dev/null @@ -1,334 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use crate as custom_signatures; -use assert_matches::assert_matches; -use custom_signatures::*; -use frame_support::{ - traits::{ConstU32, Contains}, - {assert_err, assert_ok, parameter_types}, -}; -use hex_literal::hex; -use parity_scale_codec::Encode; -use sp_core::{ecdsa, Pair}; -use sp_io::{hashing::keccak_256, TestExternalities}; -use sp_keyring::AccountKeyring as Keyring; -use sp_runtime::{ - testing::{Header, H256}, - traits::{BlakeTwo256, IdentifyAccount, IdentityLookup, Verify}, - transaction_validity::TransactionPriority, - MultiSignature, MultiSigner, -}; - -pub const ECDSA_SEED: [u8; 32] = - hex_literal::hex!["7e9c7ad85df5cdc88659f53e06fb2eb9bab3ebc59083a3190eaf2c730332529c"]; - -type Balance = u128; -type BlockNumber = u64; -type Signature = MultiSignature; -type AccountId = <::Signer as IdentifyAccount>::AccountId; -type Block = frame_system::mocking::MockBlock; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; - -frame_support::construct_runtime!( - pub enum Runtime where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - Balances: pallet_balances, - System: frame_system, - CustomSignatures: custom_signatures, - } -); - -parameter_types! { - pub const BlockHashCount: u64 = 250; -} - -pub struct NoRemarkFilter; -impl Contains for NoRemarkFilter { - fn contains(call: &RuntimeCall) -> bool { - match call { - RuntimeCall::System(method) => match method { - frame_system::Call::remark { .. } => false, - _ => true, - }, - _ => true, - } - } -} - -impl frame_system::Config for Runtime { - type RuntimeOrigin = RuntimeOrigin; - type BaseCallFilter = NoRemarkFilter; - type Index = u32; - type BlockNumber = BlockNumber; - type RuntimeCall = RuntimeCall; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = pallet_balances::AccountData; - type OnNewAccount = (); - type OnKilledAccount = (); - type DbWeight = (); - type SystemWeightInfo = (); - type BlockWeights = (); - type BlockLength = (); - type SS58Prefix = (); - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const ExistentialDeposit: Balance = 1; -} - -impl pallet_balances::Config for Runtime { - type Balance = Balance; - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = frame_system::Pallet; - type WeightInfo = (); - type MaxLocks = (); - type MaxReserves = (); - type ReserveIdentifier = (); - type HoldIdentifier = (); - type FreezeIdentifier = (); - type MaxHolds = ConstU32<0>; - type MaxFreezes = ConstU32<0>; -} - -const MAGIC_NUMBER: u16 = 0xff50; -parameter_types! { - pub const Priority: TransactionPriority = TransactionPriority::MAX; - pub const CallFee: Balance = 42; - pub const CallMagicNumber: u16 = MAGIC_NUMBER; -} - -impl Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Signature = ethereum::EthereumSignature; - type Signer = ::Signer; - type CallMagicNumber = CallMagicNumber; - type Currency = Balances; - type CallFee = CallFee; - type OnChargeTransaction = (); - type UnsignedPriority = Priority; -} - -fn new_test_ext() -> TestExternalities { - let mut storage = frame_system::GenesisConfig::default() - .build_storage::() - .unwrap(); - - let pair = ecdsa::Pair::from_seed(&ECDSA_SEED); - let account = MultiSigner::from(pair.public()).into_account(); - let _ = pallet_balances::GenesisConfig:: { - balances: vec![(account, 1_000_000_000)], - } - .assimilate_storage(&mut storage); - - let mut ext = TestExternalities::from(storage); - ext.execute_with(|| System::set_block_number(1)); - ext -} - -/// Simple `eth_sign` implementation, should be equal to exported by RPC -fn eth_sign(seed: &[u8; 32], data: &[u8]) -> Vec { - let call_msg = ethereum::signable_message(data); - let ecdsa_msg = libsecp256k1::Message::parse(&keccak_256(&call_msg)); - let secret = libsecp256k1::SecretKey::parse(&seed).expect("valid seed"); - let (signature, recovery_id) = libsecp256k1::sign(&ecdsa_msg, &secret); - let mut out = Vec::new(); - out.extend_from_slice(&signature.serialize()[..]); - // Fix recovery ID: Ethereum uses 27/28 notation - out.push(recovery_id.serialize() + 27); - out -} - -#[test] -fn eth_sign_works() { - let seed = hex!["ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"]; - let text = b"Hello Astar"; - let signature = hex!["0cc6d5de6db06727fe43a260e7c9a417be3daab9b0e4e65e276f543e5c2f3de67e9e26d903d5301181e13033f61692db2dca67c1f8992b62476eaf8cb3a597101c"]; - assert_eq!(eth_sign(&seed, &text[..]), signature); -} - -#[test] -fn invalid_signature() { - let bob: ::AccountId = Keyring::Bob.into(); - let alice: ::AccountId = Keyring::Alice.into(); - let call = pallet_balances::Call::::transfer { - dest: alice.clone(), - value: 1_000, - } - .into(); - let signature = Vec::from(&hex!["dd0992d40e5cdf99db76bed162808508ac65acd7ae2fdc8573594f03ed9c939773e813181788fc02c3c68f3fdc592759b35f6354484343e18cb5317d34dab6c61b"][..]); - new_test_ext().execute_with(|| { - assert_err!( - CustomSignatures::call(RuntimeOrigin::none(), Box::new(call), bob, signature, 0), - Error::::InvalidSignature, - ); - }); -} - -#[test] -fn balance_transfer() { - new_test_ext().execute_with(|| { - let pair = ecdsa::Pair::from_seed(&ECDSA_SEED); - let account = MultiSigner::from(pair.public()).into_account(); - - let alice: ::AccountId = Keyring::Alice.into(); - assert_eq!(System::account(alice.clone()).data.free, 0); - - let call: RuntimeCall = pallet_balances::Call::::transfer { - dest: alice.clone(), - value: 1_000, - } - .into(); - let payload = (MAGIC_NUMBER, 0u32, call.clone()); - let signature = eth_sign(&ECDSA_SEED, payload.encode().as_ref()).into(); - - assert_eq!(System::account(account.clone()).nonce, 0); - assert_ok!(CustomSignatures::call( - RuntimeOrigin::none(), - Box::new(call.clone()), - account.clone(), - signature, - 0, - )); - assert_eq!(System::account(alice.clone()).data.free, 1_000); - assert_eq!(System::account(account.clone()).nonce, 1); - assert_eq!(System::account(account.clone()).data.free, 999_998_958); - assert_matches!( - System::events() - .last() - .expect("events expected") - .event - .clone(), - RuntimeEvent::CustomSignatures(Event::Executed(used_account, Ok(..),)) - if used_account == account - ); - - let signature = eth_sign(&ECDSA_SEED, payload.encode().as_ref()).into(); - assert_err!( - CustomSignatures::call( - RuntimeOrigin::none(), - Box::new(call.clone()), - account.clone(), - signature, - 0, - ), - Error::::BadNonce, - ); - - let payload = (MAGIC_NUMBER, 1u32, call.clone()); - let signature = eth_sign(&ECDSA_SEED, payload.encode().as_ref()).into(); - assert_eq!(System::account(account.clone()).nonce, 1); - assert_ok!(CustomSignatures::call( - RuntimeOrigin::none(), - Box::new(call.clone()), - account.clone(), - signature, - 1, - )); - assert_eq!(System::account(alice).data.free, 2_000); - assert_eq!(System::account(account.clone()).nonce, 2); - assert_eq!(System::account(account.clone()).data.free, 999_997_916); - }) -} - -#[test] -fn call_fixtures() { - use sp_core::crypto::Ss58Codec; - - let seed = hex!["ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"]; - let pair = ecdsa::Pair::from_seed(&seed); - assert_eq!( - MultiSigner::from(pair.public()) - .into_account() - .to_ss58check(), - "5EGynCAEvv8NLeHx8vDMvb8hTcEcMYUMWCDQEEncNEfNWB2W", - ); - - let dest = - AccountId::from_ss58check("5GVwcV6EzxxYbXBm7H6dtxc9TCgL4oepMXtgqWYEc3VXJoaf").unwrap(); - let call: RuntimeCall = - pallet_balances::Call::::transfer_allow_death { dest, value: 1000 }.into(); - assert_eq!( - call.encode(), - hex!["0000c4305fb88b6ccb43d6552dc11d18e7b0ee3185247adcc6e885eb284adf6c563da10f"], - ); - - let payload = (MAGIC_NUMBER, 0u32, call.clone()); - assert_eq!( - payload.encode(), - hex![ - "50ff000000000000c4305fb88b6ccb43d6552dc11d18e7b0ee3185247adcc6e885eb284adf6c563da10f" - ], - ); - - let signature = hex!["6ecb474240df46ee5cde8f51cf5ccf4c75d15ac3c1772aea6c8189604263c98b16350883438c4eaa447ebcb6889d516f70351fd704bb3521072cd2fccc7c99dc1c"]; - assert_eq!(eth_sign(&seed, payload.encode().as_ref()), signature) -} - -#[test] -fn not_allowed_call_filtered() { - new_test_ext().execute_with(|| { - let pair = ecdsa::Pair::from_seed(&ECDSA_SEED); - let account = MultiSigner::from(pair.public()).into_account(); - - let alice: ::AccountId = Keyring::Alice.into(); - assert_eq!(System::account(alice.clone()).data.free, 0); - - let call: RuntimeCall = frame_system::Call::::remark { - remark: Vec::<_>::new(), - } - .into(); - // sanity check, call should be filtered out - assert!(!::BaseCallFilter::contains(&call)); - - let payload = (MAGIC_NUMBER, 0u32, call.clone()); - let signature = eth_sign(&ECDSA_SEED, payload.encode().as_ref()).into(); - - assert_eq!(System::account(account.clone()).nonce, 0); - assert_ok!(CustomSignatures::call( - RuntimeOrigin::none(), - Box::new(call.clone()), - account.clone(), - signature, - 0, - )); - assert_eq!(System::account(account.clone()).nonce, 1); - - assert_matches!( - System::events() - .last() - .expect("events expected") - .event - .clone(), - RuntimeEvent::CustomSignatures(Event::Executed(used_account, Err(..),)) - if used_account == account - ); - }) -} diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index c4ad5a0858..23b64b08c7 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -101,7 +101,6 @@ frame-try-runtime = { workspace = true, optional = true } astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } pallet-collator-selection = { workspace = true } -pallet-custom-signatures = { workspace = true } pallet-dapps-staking = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dapps-staking = { workspace = true } @@ -150,7 +149,6 @@ std = [ "pallet-balances/std", "pallet-proxy/std", "pallet-block-reward/std", - "pallet-custom-signatures/std", "pallet-dapps-staking/std", "pallet-evm-precompile-dapps-staking/std", "pallet-evm-precompile-batch/std", @@ -241,7 +239,6 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-proxy/try-runtime", "pallet-block-reward/try-runtime", - "pallet-custom-signatures/try-runtime", "pallet-dapps-staking/try-runtime", "pallet-block-reward/try-runtime", "pallet-sudo/try-runtime", diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 816dbd2803..92578b231d 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -62,12 +62,9 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Bounded, ConvertInto, - DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, Verify, - Zero, - }, - transaction_validity::{ - TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, + DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, Zero, }, + transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, }; use sp_std::prelude::*; @@ -313,24 +310,6 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = pallet_multisig::weights::SubstrateWeight; } -parameter_types! { - pub const EcdsaUnsignedPriority: TransactionPriority = TransactionPriority::MAX / 2; - pub const CallFee: Balance = ASTR / 10; - pub const CallMagicNumber: u16 = 0x0250; -} - -impl pallet_custom_signatures::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Signature = pallet_custom_signatures::ethereum::EthereumSignature; - type Signer = ::Signer; - type CallMagicNumber = CallMagicNumber; - type Currency = Balances; - type CallFee = CallFee; - type OnChargeTransaction = ToStakingPot; - type UnsignedPriority = EcdsaUnsignedPriority; -} - parameter_types! { pub const BlockPerEra: BlockNumber = DAYS; pub const RegisterDeposit: Balance = 1000 * ASTR; @@ -916,7 +895,6 @@ impl InstanceFilter for ProxyType { | RuntimeCall::XcAssetConfig(..) // Skip entire EVM pallet // Skip entire Ethereum pallet - // Skip entire EthCall pallet | RuntimeCall::BaseFee(..) // Skip entire Contracts pallet ) } @@ -1025,7 +1003,6 @@ construct_runtime!( EVM: pallet_evm = 60, Ethereum: pallet_ethereum = 61, - EthCall: pallet_custom_signatures = 62, BaseFee: pallet_base_fee = 63, Contracts: pallet_contracts = 70, diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index 5fab41f77f..0dee086613 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -69,7 +69,6 @@ astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } pallet-chain-extension-dapps-staking = { workspace = true } pallet-chain-extension-xvm = { workspace = true } -pallet-custom-signatures = { workspace = true } pallet-dapps-staking = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dapps-staking = { workspace = true } @@ -115,7 +114,6 @@ std = [ "pallet-contracts-primitives/std", "pallet-chain-extension-dapps-staking/std", "pallet-chain-extension-xvm/std", - "pallet-custom-signatures/std", "pallet-dapps-staking/std", "pallet-base-fee/std", "pallet-ethereum/std", @@ -197,7 +195,6 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-block-reward/try-runtime", "pallet-contracts/try-runtime", - "pallet-custom-signatures/try-runtime", "pallet-dapps-staking/try-runtime", "pallet-grandpa/try-runtime", "pallet-insecure-randomness-collective-flip/try-runtime", diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 40c1e7e9a3..4c74ed639c 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -51,11 +51,9 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, - DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, Verify, - }, - transaction_validity::{ - TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, + DispatchInfoOf, Dispatchable, NumberFor, PostDispatchInfoOf, UniqueSaturatedInto, }, + transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, RuntimeDebug, }; use sp_std::prelude::*; @@ -587,24 +585,6 @@ impl pallet_ethereum::Config for Runtime { type ExtraDataLength = ConstU32<30>; } -parameter_types! { - pub const EcdsaUnsignedPriority: TransactionPriority = TransactionPriority::MAX / 2; - pub const CallFee: Balance = AST / 10; - pub const CallMagicNumber: u16 = 0xff51; -} - -impl pallet_custom_signatures::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Signature = pallet_custom_signatures::ethereum::EthereumSignature; - type Signer = ::Signer; - type CallMagicNumber = CallMagicNumber; - type Currency = Balances; - type CallFee = CallFee; - type OnChargeTransaction = (); - type UnsignedPriority = EcdsaUnsignedPriority; -} - parameter_types! { pub MaximumSchedulerWeight: Weight = NORMAL_DISPATCH_RATIO * RuntimeBlockWeights::get().max_block; } @@ -910,7 +890,6 @@ impl InstanceFilter for ProxyType { | RuntimeCall::DappsStaking(..) // Skip entire EVM pallet // Skip entire Ethereum pallet - // Skip entire EthCall pallet | RuntimeCall::BaseFee(..) // Skip entire Contracts pallet | RuntimeCall::Democracy(..) @@ -1009,7 +988,6 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment, EVM: pallet_evm, Ethereum: pallet_ethereum, - EthCall: pallet_custom_signatures, BaseFee: pallet_base_fee, Contracts: pallet_contracts, Sudo: pallet_sudo, diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 72c1d69ce5..3d356dd75a 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -100,7 +100,6 @@ pallet-block-reward = { workspace = true } pallet-chain-extension-dapps-staking = { workspace = true } pallet-chain-extension-xvm = { workspace = true } pallet-collator-selection = { workspace = true } -pallet-custom-signatures = { workspace = true } pallet-dapps-staking = { workspace = true } pallet-ethereum-checked = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } @@ -166,7 +165,6 @@ std = [ "pallet-contracts-primitives/std", "pallet-chain-extension-dapps-staking/std", "pallet-chain-extension-xvm/std", - "pallet-custom-signatures/std", "pallet-base-fee/std", "pallet-ethereum/std", "pallet-preimage/std", @@ -269,7 +267,6 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-balances/try-runtime", "pallet-block-reward/try-runtime", - "pallet-custom-signatures/try-runtime", "pallet-dapps-staking/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 24c352cc60..540978beab 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -59,11 +59,9 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Bounded, ConvertInto, - DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, Verify, - }, - transaction_validity::{ - TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, + DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, }, + transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, }; use sp_std::prelude::*; @@ -345,24 +343,6 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = pallet_multisig::weights::SubstrateWeight; } -parameter_types! { - pub const EcdsaUnsignedPriority: TransactionPriority = TransactionPriority::MAX / 2; - pub const CallFee: Balance = SBY / 10; - pub const CallMagicNumber: u16 = 0xff51; -} - -impl pallet_custom_signatures::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Signature = pallet_custom_signatures::ethereum::EthereumSignature; - type Signer = ::Signer; - type CallMagicNumber = CallMagicNumber; - type Currency = Balances; - type CallFee = CallFee; - type OnChargeTransaction = ToStakingPot; - type UnsignedPriority = EcdsaUnsignedPriority; -} - parameter_types! { pub MaximumSchedulerWeight: Weight = NORMAL_DISPATCH_RATIO * RuntimeBlockWeights::get().max_block; } @@ -1140,7 +1120,6 @@ impl InstanceFilter for ProxyType { | RuntimeCall::XcAssetConfig(..) // Skip entire EVM pallet // Skip entire Ethereum pallet - // Skip entire EthCall pallet | RuntimeCall::BaseFee(..) // Skip entire Contracts pallet | RuntimeCall::Democracy(..) @@ -1243,7 +1222,6 @@ construct_runtime!( Identity: pallet_identity = 12, Timestamp: pallet_timestamp = 13, Multisig: pallet_multisig = 14, - EthCall: pallet_custom_signatures = 15, RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 16, Scheduler: pallet_scheduler = 17, Proxy: pallet_proxy = 18, diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 8a86693eb6..743a8e6d5d 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -103,7 +103,6 @@ frame-try-runtime = { workspace = true, optional = true } astar-primitives = { workspace = true } pallet-block-reward = { workspace = true } pallet-collator-selection = { workspace = true } -pallet-custom-signatures = { workspace = true } pallet-dapps-staking = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dapps-staking = { workspace = true } @@ -152,7 +151,6 @@ std = [ "pallet-contracts/std", "pallet-contracts-primitives/std", "pallet-block-reward/std", - "pallet-custom-signatures/std", "pallet-base-fee/std", "pallet-ethereum/std", "pallet-evm/std", @@ -241,7 +239,6 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-balances/try-runtime", "pallet-block-reward/try-runtime", - "pallet-custom-signatures/try-runtime", "pallet-dapps-staking/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index f4bee24487..ecb37a6bc5 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -58,11 +58,9 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{ AccountIdConversion, AccountIdLookup, BlakeTwo256, Block as BlockT, Bounded, ConvertInto, - DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, Verify, - }, - transaction_validity::{ - TransactionPriority, TransactionSource, TransactionValidity, TransactionValidityError, + DispatchInfoOf, Dispatchable, OpaqueKeys, PostDispatchInfoOf, UniqueSaturatedInto, }, + transaction_validity::{TransactionSource, TransactionValidity, TransactionValidityError}, ApplyExtrinsicResult, FixedPointNumber, Perbill, Permill, Perquintill, RuntimeDebug, }; use sp_std::prelude::*; @@ -317,24 +315,6 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = pallet_multisig::weights::SubstrateWeight; } -parameter_types! { - pub const EcdsaUnsignedPriority: TransactionPriority = TransactionPriority::MAX / 2; - pub const CallFee: Balance = SDN / 10; - pub const CallMagicNumber: u16 = 0x0150; -} - -impl pallet_custom_signatures::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; - type Signature = pallet_custom_signatures::ethereum::EthereumSignature; - type Signer = ::Signer; - type CallMagicNumber = CallMagicNumber; - type Currency = Balances; - type CallFee = CallFee; - type OnChargeTransaction = ToStakingPot; - type UnsignedPriority = EcdsaUnsignedPriority; -} - parameter_types! { pub const BlockPerEra: BlockNumber = DAYS; pub const RegisterDeposit: Balance = 100 * SDN; @@ -904,7 +884,6 @@ impl InstanceFilter for ProxyType { | RuntimeCall::XcAssetConfig(..) // Skip entire EVM pallet // Skip entire Ethereum pallet - // Skip entire EthCall pallet | RuntimeCall::BaseFee(..) // Skip entire Contracts pallet ) } @@ -1013,7 +992,6 @@ construct_runtime!( EVM: pallet_evm = 60, Ethereum: pallet_ethereum = 61, - EthCall: pallet_custom_signatures = 62, BaseFee: pallet_base_fee = 63, Contracts: pallet_contracts = 70, From 51a1b84f7608882371aa4382d11f950f998de01b Mon Sep 17 00:00:00 2001 From: Ashutosh Varma Date: Wed, 27 Sep 2023 08:20:11 +0530 Subject: [PATCH 6/6] feat: `pallet_unified_accounts` implementation (#1019) * wip * feat: add initial implementation for `pallet_account` * feat: add test helpers and refactor * feat: setup mock and add tests for eip712 sig * feat: add `pallet_account` to local runtime * fix: runtime-benchmarks build * feat: add claim js script * feat: add tests for lookup and on kill * feat: add more tests * feat: add benchmarks * fix: build issues * feat: add to shibuya * feat: update xvm integration tests * feat: add intergration test for lookup * fix: formatting * fix: integration tests * feat: apply code review suggestions * feat: update pallet directory name * feat: expand tests * fix: benchmarks and weights * feat: use claim account in integration tests * feat: apply code suggestions * feat: remove `SignatureHelper` trait * feat: update claim script * feat: add check in default claim to manage collisions * fix: benchmarks * feat: inline `add_mappings()` method * feat: apply benchmarks weights & code suggestions * feat: re-run `pallet_balances` benchmarks --- Cargo.lock | 914 ++++++++++++++++-- Cargo.toml | 4 +- pallets/unified-accounts/Cargo.toml | 76 ++ pallets/unified-accounts/src/benchmarking.rs | 76 ++ pallets/unified-accounts/src/lib.rs | 405 ++++++++ pallets/unified-accounts/src/mock.rs | 231 +++++ pallets/unified-accounts/src/tests.rs | 336 +++++++ pallets/unified-accounts/src/weights.rs | 127 +++ primitives/src/ethereum_checked.rs | 12 + primitives/src/evm.rs | 22 + rpc-tests/claim.mjs | 65 ++ rpc-tests/package.json | 5 +- rpc-tests/yarn.lock | 664 ++++++++++--- runtime/local/Cargo.toml | 4 + runtime/local/src/lib.rs | 31 +- runtime/local/src/weights/mod.rs | 1 + runtime/local/src/weights/pallet_balances.rs | 153 +++ runtime/shibuya/Cargo.toml | 4 + runtime/shibuya/src/lib.rs | 39 +- runtime/shibuya/src/weights/mod.rs | 1 + .../shibuya/src/weights/pallet_balances.rs | 153 +++ tests/integration/Cargo.toml | 2 + tests/integration/src/account.rs | 41 + tests/integration/src/lib.rs | 3 + tests/integration/src/setup.rs | 47 +- tests/integration/src/xvm.rs | 45 +- 26 files changed, 3159 insertions(+), 302 deletions(-) create mode 100644 pallets/unified-accounts/Cargo.toml create mode 100644 pallets/unified-accounts/src/benchmarking.rs create mode 100644 pallets/unified-accounts/src/lib.rs create mode 100644 pallets/unified-accounts/src/mock.rs create mode 100644 pallets/unified-accounts/src/tests.rs create mode 100644 pallets/unified-accounts/src/weights.rs create mode 100644 rpc-tests/claim.mjs create mode 100644 runtime/local/src/weights/pallet_balances.rs create mode 100644 runtime/shibuya/src/weights/pallet_balances.rs create mode 100644 tests/integration/src/account.rs diff --git a/Cargo.lock b/Cargo.lock index 5028d29d9e..a13fd5143b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -300,6 +300,15 @@ version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" +[[package]] +name = "array-init" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" +dependencies = [ + "nodrop", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -606,7 +615,7 @@ dependencies = [ "polkadot-runtime", "polkadot-runtime-common", "scale-info", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-block-builder", "sp-consensus-aura", @@ -679,15 +688,26 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.71" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", "syn 2.0.25", ] +[[package]] +name = "async_io_stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c" +dependencies = [ + "futures 0.3.28", + "pharos", + "rustc_version 0.4.0", +] + [[package]] name = "asynchronous-codec" version = "0.6.1" @@ -698,7 +718,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", ] [[package]] @@ -787,6 +807,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + [[package]] name = "beef" version = "0.5.2" @@ -986,6 +1012,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" +[[package]] +name = "bs58" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" +dependencies = [ + "sha2 0.10.7", + "tinyvec", +] + [[package]] name = "bstr" version = "0.2.17" @@ -1051,6 +1087,9 @@ name = "bytes" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +dependencies = [ + "serde", +] [[package]] name = "bzip2-sys" @@ -1095,6 +1134,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cargo_metadata" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.17", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" version = "1.0.79" @@ -1130,7 +1183,7 @@ version = "0.15.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "215c0072ecc28f92eeb0eea38ba63ddfcb65c2828c46311d646f1a3ff5f9841c" dependencies = [ - "smallvec", + "smallvec 1.11.0", ] [[package]] @@ -1309,6 +1362,58 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "coins-bip32" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b6be4a5df2098cd811f3194f64ddb96c267606bffd9689ac7b0160097b01ad3" +dependencies = [ + "bs58 0.5.0", + "coins-core", + "digest 0.10.7", + "hmac 0.12.1", + "k256", + "serde", + "sha2 0.10.7", + "thiserror", +] + +[[package]] +name = "coins-bip39" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8fba409ce3dc04f7d804074039eb68b960b0829161f8e06c95fea3f122528" +dependencies = [ + "bitvec", + "coins-bip32", + "hmac 0.12.1", + "once_cell", + "pbkdf2 0.12.2", + "rand 0.8.5", + "sha2 0.10.7", + "thiserror", +] + +[[package]] +name = "coins-core" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" +dependencies = [ + "base64 0.21.2", + "bech32", + "bs58 0.5.0", + "digest 0.10.7", + "generic-array 0.14.7", + "hex", + "ripemd", + "serde", + "serde_derive", + "sha2 0.10.7", + "sha3", + "thiserror", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -1321,8 +1426,8 @@ version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" dependencies = [ - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "unicode-width", ] @@ -1348,6 +1453,18 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "const-hex" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849ed393c907c90016652a01465a12d86361cd38ad2a7de026c56a520cc259" +dependencies = [ + "cfg-if", + "cpufeatures", + "hex", + "serde", +] + [[package]] name = "const-oid" version = "0.9.3" @@ -1450,7 +1567,7 @@ dependencies = [ "hashbrown 0.13.2", "log", "regalloc2", - "smallvec", + "smallvec 1.11.0", "target-lexicon", ] @@ -1486,7 +1603,7 @@ checksum = "64a25d9d0a0ae3079c463c34115ec59507b4707175454f0eee0891e83e30e82d" dependencies = [ "cranelift-codegen", "log", - "smallvec", + "smallvec 1.11.0", "target-lexicon", ] @@ -1518,7 +1635,7 @@ dependencies = [ "cranelift-frontend", "itertools", "log", - "smallvec", + "smallvec 1.11.0", "wasmparser", "wasmtime-types", ] @@ -2582,6 +2699,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "519b83cd10f5f6e969625a409f735182bea5558cd8b64c655806ceaae36f1999" +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + [[package]] name = "dyn-clonable" version = "0.9.0" @@ -2725,6 +2848,34 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enr" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0be7b2ac146c1f99fe245c02d16af0696450d8e06c135db75e10eeb9e642c20d" +dependencies = [ + "base64 0.21.2", + "bytes", + "hex", + "k256", + "log", + "rand 0.8.5", + "rlp", + "serde", + "serde-hex", + "sha3", + "zeroize", +] + [[package]] name = "enum-as-inner" version = "0.5.1" @@ -2827,6 +2978,45 @@ dependencies = [ "libc", ] +[[package]] +name = "eth-keystore" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fda3bf123be441da5260717e0661c25a2fd9cb2b2c1d20bf2e05580047158ab" +dependencies = [ + "aes 0.8.3", + "ctr 0.9.2", + "digest 0.10.7", + "hex", + "hmac 0.12.1", + "pbkdf2 0.11.0", + "rand 0.8.5", + "scrypt", + "serde", + "serde_json", + "sha2 0.10.7", + "sha3", + "thiserror", + "uuid 0.8.2", +] + +[[package]] +name = "ethabi" +version = "18.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7413c5f74cc903ea37386a8965a936cbeb334bd270862fdece542c1b2dcbc898" +dependencies = [ + "ethereum-types", + "hex", + "once_cell", + "regex", + "serde", + "serde_json", + "sha3", + "thiserror", + "uint", +] + [[package]] name = "ethbloom" version = "0.13.0" @@ -2876,6 +3066,217 @@ dependencies = [ "uint", ] +[[package]] +name = "ethers" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba3fd516c15a9a587135229466dbbfc85796de55c5660afbbb1b1c78517d85c" +dependencies = [ + "ethers-addressbook", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-middleware", + "ethers-providers", + "ethers-signers", +] + +[[package]] +name = "ethers-addressbook" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0245617f11b8178fa50b52e433e2c34ac69f39116b62c8be2437decf2edf1986" +dependencies = [ + "ethers-core", + "once_cell", + "serde", + "serde_json", +] + +[[package]] +name = "ethers-contract" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02bb80fd2c22631a5eb8a02cbf373cc5fd86937fc966bb670b9a884580c8e71c" +dependencies = [ + "const-hex", + "ethers-contract-abigen", + "ethers-contract-derive", + "ethers-core", + "ethers-providers", + "futures-util", + "once_cell", + "pin-project", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "ethers-contract-abigen" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22c54db0d393393e732a5b20273e4f8ab89f0cce501c84e75fab9c126799a6e6" +dependencies = [ + "Inflector", + "const-hex", + "dunce", + "ethers-core", + "eyre", + "prettyplease 0.2.10", + "proc-macro2", + "quote", + "regex", + "serde", + "serde_json", + "syn 2.0.25", + "toml 0.7.6", + "walkdir", +] + +[[package]] +name = "ethers-contract-derive" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62ee4f216184a1304b707ed258f4f70aa40bf7e1522ab8963d127a8d516eaa1a" +dependencies = [ + "Inflector", + "const-hex", + "ethers-contract-abigen", + "ethers-core", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.25", +] + +[[package]] +name = "ethers-core" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c29523f73c12753165781c6e5dc11c84d3e44c080a15f7c6cfbd70b514cb6f1" +dependencies = [ + "arrayvec 0.7.4", + "bytes", + "cargo_metadata 0.17.0", + "chrono", + "const-hex", + "elliptic-curve 0.13.5", + "ethabi", + "generic-array 0.14.7", + "k256", + "num_enum 0.7.0", + "once_cell", + "open-fastrlp", + "rand 0.8.5", + "rlp", + "serde", + "serde_json", + "strum 0.25.0", + "syn 2.0.25", + "tempfile", + "thiserror", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "ethers-etherscan" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aab5af432b3fe5b7756b60df5c9ddeb85a13414575ad8a9acd707c24f0a77a5" +dependencies = [ + "ethers-core", + "reqwest", + "semver 1.0.17", + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "ethers-middleware" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356151d5ded56d4918146366abc9dfc9df367cf0096492a7a5477b21b7693615" +dependencies = [ + "async-trait", + "auto_impl", + "ethers-contract", + "ethers-core", + "ethers-etherscan", + "ethers-providers", + "ethers-signers", + "futures-channel", + "futures-locks", + "futures-util", + "instant", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "url", +] + +[[package]] +name = "ethers-providers" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00c84664b294e47fc2860d6db0db0246f79c4c724e552549631bb9505b834bee" +dependencies = [ + "async-trait", + "auto_impl", + "base64 0.21.2", + "bytes", + "const-hex", + "enr", + "ethers-core", + "futures-core", + "futures-timer", + "futures-util", + "hashers", + "http", + "instant", + "jsonwebtoken", + "once_cell", + "pin-project", + "reqwest", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", + "tracing-futures", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "ws_stream_wasm", +] + +[[package]] +name = "ethers-signers" +version = "2.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "170b299698702ef1f53d2275af7d6d97409cfa4f9398ee9ff518f6bc9102d0ad" +dependencies = [ + "async-trait", + "coins-bip32", + "coins-bip39", + "const-hex", + "elliptic-curve 0.13.5", + "eth-keystore", + "ethers-core", + "rand 0.8.5", + "sha2 0.10.7", + "thiserror", + "tracing", +] + [[package]] name = "event-listener" version = "2.5.3" @@ -3009,6 +3410,16 @@ dependencies = [ "syn 2.0.25", ] +[[package]] +name = "eyre" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "fake-simd" version = "0.1.2" @@ -3036,6 +3447,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + [[package]] name = "fatality" version = "0.0.6" @@ -3090,7 +3507,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "sc-client-db", - "smallvec", + "smallvec 1.11.0", "sp-blockchain", "sp-core", "sp-database", @@ -3604,7 +4021,7 @@ dependencies = [ "paste", "scale-info", "serde", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-arithmetic", "sp-core", @@ -3807,15 +4224,25 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "waker-fn", ] +[[package]] +name = "futures-locks" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ec6fe3675af967e67c5536c0b9d44e34e6c52f86bedc4ea49c5317b8e94d06" +dependencies = [ + "futures-channel", + "futures-task", +] + [[package]] name = "futures-macro" version = "0.3.28" @@ -3855,6 +4282,10 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +dependencies = [ + "gloo-timers", + "send_wrapper 0.4.0", +] [[package]] name = "futures-util" @@ -3870,7 +4301,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "pin-utils", "slab", ] @@ -3986,6 +4417,18 @@ dependencies = [ "regex", ] +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "group" version = "0.12.1" @@ -4086,6 +4529,15 @@ version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +[[package]] +name = "hashers" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2bca93b15ea5a746f220e56587f71e73c6165eab783df9e26590069953e3c30" +dependencies = [ + "fxhash", +] + [[package]] name = "heck" version = "0.4.1" @@ -4201,7 +4653,7 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", ] [[package]] @@ -4244,7 +4696,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "socket2 0.4.9", "tokio", "tower-service", @@ -4385,6 +4837,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "indexmap" version = "1.9.3" @@ -4469,6 +4927,7 @@ dependencies = [ "frame-support", "frame-system", "hex", + "libsecp256k1", "pallet-assets", "pallet-balances", "pallet-contracts", @@ -4478,6 +4937,7 @@ dependencies = [ "pallet-evm", "pallet-evm-precompile-assets-erc20", "pallet-proxy", + "pallet-unified-accounts", "pallet-utility", "parity-scale-codec", "precompile-utils", @@ -4731,6 +5191,20 @@ dependencies = [ "jsonrpsee-types", ] +[[package]] +name = "jsonwebtoken" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" +dependencies = [ + "base64 0.21.2", + "pem", + "ring", + "serde", + "serde_json", + "simple_asn1", +] + [[package]] name = "k256" version = "0.13.1" @@ -4742,6 +5216,7 @@ dependencies = [ "elliptic-curve 0.13.5", "once_cell", "sha2 0.10.7", + "signature 2.1.0", ] [[package]] @@ -4826,7 +5301,7 @@ dependencies = [ "scale-info", "serde", "serde_derive", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-arithmetic", "sp-authority-discovery", @@ -4860,7 +5335,7 @@ dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", - "smallvec", + "smallvec 1.11.0", "sp-core", "sp-runtime", "sp-weights", @@ -4872,7 +5347,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7d770dcb02bf6835887c3a979b5107a04ff4bbde97a5f0928d27404a155add9" dependencies = [ - "smallvec", + "smallvec 1.11.0", ] [[package]] @@ -4896,7 +5371,7 @@ dependencies = [ "parking_lot 0.12.1", "regex", "rocksdb", - "smallvec", + "smallvec 1.11.0", ] [[package]] @@ -5022,7 +5497,7 @@ dependencies = [ "quick-protobuf", "rand 0.8.5", "rw-stream-sink", - "smallvec", + "smallvec 1.11.0", "thiserror", "unsigned-varint", "void", @@ -5038,7 +5513,7 @@ dependencies = [ "libp2p-core", "log", "parking_lot 0.12.1", - "smallvec", + "smallvec 1.11.0", "trust-dns-resolver", ] @@ -5059,7 +5534,7 @@ dependencies = [ "lru 0.10.1", "quick-protobuf", "quick-protobuf-codec", - "smallvec", + "smallvec 1.11.0", "thiserror", "void", ] @@ -5070,7 +5545,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" dependencies = [ - "bs58", + "bs58 0.4.0", "ed25519-dalek", "log", "multiaddr", @@ -5103,7 +5578,7 @@ dependencies = [ "quick-protobuf", "rand 0.8.5", "sha2 0.10.7", - "smallvec", + "smallvec 1.11.0", "thiserror", "uint", "unsigned-varint", @@ -5124,7 +5599,7 @@ dependencies = [ "libp2p-swarm", "log", "rand 0.8.5", - "smallvec", + "smallvec 1.11.0", "socket2 0.4.9", "tokio", "trust-dns-proto", @@ -5220,7 +5695,7 @@ dependencies = [ "libp2p-identity", "libp2p-swarm", "rand 0.8.5", - "smallvec", + "smallvec 1.11.0", ] [[package]] @@ -5239,7 +5714,7 @@ dependencies = [ "libp2p-swarm-derive", "log", "rand 0.8.5", - "smallvec", + "smallvec 1.11.0", "tokio", "void", ] @@ -5550,6 +6025,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", + "pallet-unified-accounts", "pallet-utility", "pallet-vesting", "pallet-xvm", @@ -5688,6 +6164,12 @@ dependencies = [ "rawpointer", ] +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + [[package]] name = "md-5" version = "0.10.5" @@ -5786,6 +6268,12 @@ dependencies = [ "thrift", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -6172,7 +6660,7 @@ dependencies = [ "futures 0.3.28", "log", "pin-project", - "smallvec", + "smallvec 1.11.0", "unsigned-varint", ] @@ -6296,6 +6784,12 @@ dependencies = [ "memoffset 0.6.5", ] +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "nohash-hasher" version = "0.2.0" @@ -6432,6 +6926,15 @@ dependencies = [ "num_enum_derive 0.6.1", ] +[[package]] +name = "num_enum" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70bf6736f74634d299d00086f02986875b3c2d924781a6a2cb6c201e73da0ceb" +dependencies = [ + "num_enum_derive 0.7.0", +] + [[package]] name = "num_enum_derive" version = "0.5.11" @@ -6456,6 +6959,18 @@ dependencies = [ "syn 2.0.25", ] +[[package]] +name = "num_enum_derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ea360eafe1022f7cc56cd7b869ed57330fb2453d0c7831d99b74c65d2f5597" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.25", +] + [[package]] name = "number_prefix" version = "0.4.0" @@ -6519,6 +7034,31 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "open-fastrlp" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "786393f80485445794f6043fd3138854dd109cc6c4bd1a6383db304c9ce9b9ce" +dependencies = [ + "arrayvec 0.7.4", + "auto_impl", + "bytes", + "ethereum-types", + "open-fastrlp-derive", +] + +[[package]] +name = "open-fastrlp-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "003b2be5c6c53c1cfeb0a238b8a1c3915cd410feb684457a36c10038f764bb1c" +dependencies = [ + "bytes", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "openssl-probe" version = "0.1.5" @@ -7018,7 +7558,7 @@ dependencies = [ "rand_pcg", "scale-info", "serde", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-core", "sp-io", @@ -7144,7 +7684,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -8127,6 +8667,31 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-unified-accounts" +version = "0.1.0" +dependencies = [ + "astar-primitives", + "ethers", + "frame-benchmarking", + "frame-support", + "frame-system", + "hex", + "libsecp256k1", + "log", + "pallet-balances", + "pallet-ethereum", + "pallet-evm", + "pallet-timestamp", + "parity-scale-codec", + "precompile-utils", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -8392,7 +8957,7 @@ dependencies = [ "instant", "libc", "redox_syscall 0.2.16", - "smallvec", + "smallvec 1.11.0", "winapi", ] @@ -8405,7 +8970,7 @@ dependencies = [ "cfg-if", "libc", "redox_syscall 0.3.5", - "smallvec", + "smallvec 1.11.0", "windows-targets 0.48.1", ] @@ -8439,6 +9004,16 @@ dependencies = [ "digest 0.10.7", ] +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest 0.10.7", + "hmac 0.12.1", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -8523,6 +9098,16 @@ dependencies = [ "indexmap 1.9.3", ] +[[package]] +name = "pharos" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414" +dependencies = [ + "futures 0.3.28", + "rustc_version 0.4.0", +] + [[package]] name = "pin-project" version = "1.1.2" @@ -8551,9 +9136,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.10" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c40d25201921e5ff0c862a505c6557ea88568a4e3ace775ab55e93f2f4f9d57" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -9178,7 +9763,7 @@ name = "polkadot-node-metrics" version = "0.9.43" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" dependencies = [ - "bs58", + "bs58 0.4.0", "futures 0.3.28", "futures-timer", "log", @@ -9210,7 +9795,7 @@ dependencies = [ "rand 0.8.5", "sc-authority-discovery", "sc-network", - "strum", + "strum 0.24.1", "thiserror", "tracing-gum", ] @@ -9262,7 +9847,7 @@ dependencies = [ "polkadot-primitives", "polkadot-statement-table", "sc-network", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-authority-discovery", "sp-consensus-babe", @@ -9488,7 +10073,7 @@ dependencies = [ "scale-info", "serde", "serde_derive", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-arithmetic", "sp-authority-discovery", @@ -9568,7 +10153,7 @@ dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", - "smallvec", + "smallvec 1.11.0", "sp-core", "sp-runtime", "sp-weights", @@ -9579,7 +10164,7 @@ name = "polkadot-runtime-metrics" version = "0.9.43" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" dependencies = [ - "bs58", + "bs58 0.4.0", "parity-scale-codec", "polkadot-primitives", "sp-std", @@ -9783,7 +10368,7 @@ dependencies = [ "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "windows-sys 0.48.0", ] @@ -10384,7 +10969,7 @@ dependencies = [ "fxhash", "log", "slice-group-by", - "smallvec", + "smallvec 1.11.0", ] [[package]] @@ -10431,6 +11016,40 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ab07dc67230e4a4718e70fd5c20055a4334b121f1f9db8fe63ef39ce9b8c846" +[[package]] +name = "reqwest" +version = "0.11.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" +dependencies = [ + "base64 0.21.2", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite 0.2.13", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + [[package]] name = "resolv-conf" version = "0.7.0" @@ -10581,7 +11200,7 @@ dependencies = [ "scale-info", "serde", "serde_derive", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-authority-discovery", "sp-block-builder", @@ -10613,7 +11232,7 @@ dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", - "smallvec", + "smallvec 1.11.0", "sp-core", "sp-runtime", "sp-weights", @@ -10853,6 +11472,15 @@ dependencies = [ "bytemuck", ] +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher 0.4.4", +] + [[package]] name = "same-file" version = "1.0.6" @@ -11440,7 +12068,7 @@ dependencies = [ "sc-utils", "serde", "serde_json", - "smallvec", + "smallvec 1.11.0", "snow", "sp-arithmetic", "sp-blockchain", @@ -11492,7 +12120,7 @@ dependencies = [ "sc-peerset", "sc-utils", "serde", - "smallvec", + "smallvec 1.11.0", "sp-blockchain", "sp-consensus", "sp-consensus-grandpa", @@ -11568,7 +12196,7 @@ dependencies = [ "sc-network-common", "sc-peerset", "sc-utils", - "smallvec", + "smallvec 1.11.0", "sp-arithmetic", "sp-blockchain", "sp-consensus", @@ -12070,6 +12698,18 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "764cad9e7e1ca5fe15b552859ff5d96a314e6ed2934f2260168cd5dfa5891409" +[[package]] +name = "scrypt" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f9e24d2b632954ded8ab2ef9fea0a0c769ea56ea98bddbafbad22caeeadf45d" +dependencies = [ + "hmac 0.12.1", + "pbkdf2 0.11.0", + "salsa20", + "sha2 0.10.7", +] + [[package]] name = "sct" version = "0.6.1" @@ -12213,6 +12853,18 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + [[package]] name = "serde" version = "1.0.171" @@ -12222,6 +12874,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-hex" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca37e3e4d1b39afd7ff11ee4e947efae85adfddf4841787bfa47c470e96dc26d" +dependencies = [ + "array-init", + "serde", + "smallvec 0.6.14", +] + [[package]] name = "serde_derive" version = "1.0.171" @@ -12253,6 +12916,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + [[package]] name = "sha-1" version = "0.9.8" @@ -12407,6 +13082,7 @@ dependencies = [ "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", + "pallet-unified-accounts", "pallet-utility", "pallet-vesting", "pallet-xc-asset-config", @@ -12419,7 +13095,7 @@ dependencies = [ "polkadot-runtime", "polkadot-runtime-common", "scale-info", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-block-builder", "sp-consensus-aura", @@ -12515,7 +13191,7 @@ dependencies = [ "polkadot-runtime", "polkadot-runtime-common", "scale-info", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-block-builder", "sp-consensus-aura", @@ -12603,6 +13279,18 @@ dependencies = [ "similar", ] +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time 0.3.23", +] + [[package]] name = "siphasher" version = "0.3.10" @@ -12657,6 +13345,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "smallvec" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" +dependencies = [ + "maybe-uninit", +] + [[package]] name = "smallvec" version = "1.11.0" @@ -12897,7 +13594,7 @@ dependencies = [ "sp-mmr-primitives", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -12939,7 +13636,7 @@ dependencies = [ "bitflags 1.3.2", "blake2", "bounded-collections", - "bs58", + "bs58 0.4.0", "dyn-clonable", "ed25519-zebra", "futures 0.3.28", @@ -13078,7 +13775,7 @@ dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum", + "strum 0.24.1", ] [[package]] @@ -13266,7 +13963,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.12.1", "rand 0.8.5", - "smallvec", + "smallvec 1.11.0", "sp-core", "sp-externalities", "sp-panic-handler", @@ -13437,7 +14134,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "smallvec", + "smallvec 1.11.0", "sp-arithmetic", "sp-core", "sp-debug-derive", @@ -13464,7 +14161,7 @@ checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", "maplit", - "strum", + "strum 0.24.1", ] [[package]] @@ -13579,7 +14276,16 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", +] + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros 0.25.2", ] [[package]] @@ -13595,6 +14301,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8d03b598d3d0fff69bf533ee3ef19b8eeb342729596df84bcc7e1f96ec4059" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.25", +] + [[package]] name = "stun" version = "0.4.4" @@ -13718,10 +14437,10 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e dependencies = [ "ansi_term", "build-helper", - "cargo_metadata", + "cargo_metadata 0.15.4", "filetime", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", "toml 0.7.6", "walkdir", @@ -13812,15 +14531,14 @@ checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" [[package]] name = "tempfile" -version = "3.6.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "autocfg", "cfg-if", - "fastrand", + "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix 0.37.23", + "rustix 0.38.3", "windows-sys 0.48.0", ] @@ -14011,20 +14729,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2 0.4.9", + "socket2 0.5.3", "tokio-macros", "windows-sys 0.48.0", ] @@ -14069,7 +14786,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "tokio", "tokio-util", ] @@ -14084,7 +14801,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "tokio", "tracing", ] @@ -14156,7 +14873,7 @@ dependencies = [ "http", "http-body", "http-range-header", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "tower-layer", "tower-service", ] @@ -14181,7 +14898,7 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.10", + "pin-project-lite 0.2.13", "tracing-attributes", "tracing-core", ] @@ -14276,7 +14993,7 @@ dependencies = [ "serde", "serde_json", "sharded-slab", - "smallvec", + "smallvec 1.11.0", "thread_local", "tracing", "tracing-core", @@ -14294,7 +15011,7 @@ dependencies = [ "hashbrown 0.13.2", "log", "rustc-hex", - "smallvec", + "smallvec 1.11.0", ] [[package]] @@ -14333,7 +15050,7 @@ dependencies = [ "ipnet", "lazy_static", "rand 0.8.5", - "smallvec", + "smallvec 1.11.0", "socket2 0.4.9", "thiserror", "tinyvec", @@ -14355,7 +15072,7 @@ dependencies = [ "lru-cache", "parking_lot 0.12.1", "resolv-conf", - "smallvec", + "smallvec 1.11.0", "thiserror", "tokio", "tracing", @@ -14560,6 +15277,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.10", + "serde", +] + [[package]] name = "uuid" version = "1.4.0" @@ -14737,8 +15464,8 @@ checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -15215,7 +15942,7 @@ dependencies = [ "tokio", "turn", "url", - "uuid", + "uuid 1.4.0", "waitgroup", "webrtc-mdns", "webrtc-util", @@ -15377,7 +16104,7 @@ dependencies = [ "scale-info", "serde", "serde_derive", - "smallvec", + "smallvec 1.11.0", "sp-api", "sp-authority-discovery", "sp-block-builder", @@ -15410,7 +16137,7 @@ dependencies = [ "frame-support", "polkadot-primitives", "polkadot-runtime-common", - "smallvec", + "smallvec 1.11.0", "sp-core", "sp-runtime", "sp-weights", @@ -15677,6 +16404,25 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "ws_stream_wasm" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7999f5f4217fe3818726b66257a4475f71e74ffd190776ad053fa159e50737f5" +dependencies = [ + "async_io_stream", + "futures 0.3.28", + "js-sys", + "log", + "pharos", + "rustc_version 0.4.0", + "send_wrapper 0.6.0", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wyz" version = "0.5.1" @@ -15862,7 +16608,7 @@ dependencies = [ "polkadot-primitives", "polkadot-runtime-parachains", "scale-info", - "smallvec", + "smallvec 1.11.0", "sp-core", "sp-io", "sp-runtime", diff --git a/Cargo.toml b/Cargo.toml index a6d739f9df..d63c7c2e35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,13 +82,14 @@ rlp = "0.5" tracing = "0.1.34" similar-asserts = { version = "1.1.0" } assert_matches = "1.3.0" -libsecp256k1 = "0.7.0" +libsecp256k1 = { version = "0.7.0", default-features = false } impl-trait-for-tuples = "0.2.2" slices = "0.2.0" derive_more = { version = "0.99" } proc-macro2 = "1.0" quote = "1.0" syn = { version = "1.0" } +ethers = { version = "2.0.9", default_features = false } # Substrate # (wasm) @@ -277,6 +278,7 @@ pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features pallet-xvm = { path = "./pallets/xvm", default-features = false } pallet-xcm = { path = "./pallets/pallet-xcm", default-features = false } pallet-ethereum-checked = { path = "./pallets/ethereum-checked", default-features = false } +pallet-unified-accounts = { path = "./pallets/unified-accounts", default-features = false } astar-primitives = { path = "./primitives", default-features = false } diff --git a/pallets/unified-accounts/Cargo.toml b/pallets/unified-accounts/Cargo.toml new file mode 100644 index 0000000000..c74c5ac954 --- /dev/null +++ b/pallets/unified-accounts/Cargo.toml @@ -0,0 +1,76 @@ +[package] +name = "pallet-unified-accounts" +version = "0.1.0" +description = "Pallet for mapping VM accounts with native accounts" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +libsecp256k1 = { workspace = true, optional = true, features = ["hmac", "static-context"] } +log = { workspace = true } +parity-scale-codec = { workspace = true } +scale-info = { workspace = true } + +frame-support = { workspace = true } +frame-system = { workspace = true } +sp-core = { workspace = true } +sp-io = { workspace = true } +sp-runtime = { workspace = true } +sp-std = { workspace = true } + +# Benchmarks +frame-benchmarking = { workspace = true, optional = true } + +precompile-utils = { workspace = true } + +# frontier +pallet-evm = { workspace = true } + +# Astar +astar-primitives = { workspace = true } + +[dev-dependencies] +ethers = { workspace = true } +hex = { workspace = true } +pallet-balances = { workspace = true } +pallet-ethereum = { workspace = true } +pallet-evm = { workspace = true } +pallet-timestamp = { workspace = true } + +[features] +default = ["std"] +std = [ + "hex/std", + "log/std", + "libsecp256k1", + "libsecp256k1/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-std/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std", + "frame-support/std", + "frame-system/std", + "astar-primitives/std", + "precompile-utils/std", + "pallet-evm/std", + "pallet-balances/std", + "pallet-timestamp/std", + "pallet-ethereum/std", +] +runtime-benchmarks = [ + "libsecp256k1/hmac", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "astar-primitives/runtime-benchmarks", + "pallet-ethereum/runtime-benchmarks", + "pallet-evm/runtime-benchmarks", +] +try-runtime = ["frame-support/try-runtime", "pallet-evm/try-runtime"] diff --git a/pallets/unified-accounts/src/benchmarking.rs b/pallets/unified-accounts/src/benchmarking.rs new file mode 100644 index 0000000000..a4291e63c3 --- /dev/null +++ b/pallets/unified-accounts/src/benchmarking.rs @@ -0,0 +1,76 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +#![cfg(feature = "runtime-benchmarks")] + +use super::*; +use frame_benchmarking::v2::*; +use frame_system::RawOrigin; + +/// Assert that the last event equals the provided one. +fn assert_last_event(generic_event: ::RuntimeEvent) { + frame_system::Pallet::::assert_last_event(generic_event.into()); +} + +#[benchmarks] +mod benchmarks { + use super::*; + + #[benchmark] + fn claim_evm_address() { + let caller: T::AccountId = whitelisted_caller(); + let eth_secret_key = libsecp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap(); + let evm_address = Pallet::::eth_address(ð_secret_key); + let signature = Pallet::::eth_sign_prehash( + &Pallet::::build_signing_payload(&caller), + ð_secret_key, + ) + .into(); + + let caller_clone = caller.clone(); + + #[extrinsic_call] + _(RawOrigin::Signed(caller), evm_address, signature); + + assert_last_event::( + Event::::AccountClaimed { + account_id: caller_clone, + evm_address, + } + .into(), + ); + } + + #[benchmark] + fn claim_default_evm_address() { + let caller: T::AccountId = whitelisted_caller(); + let caller_clone = caller.clone(); + let evm_address = T::DefaultNativeToEvm::into_h160(caller.clone()); + + #[extrinsic_call] + _(RawOrigin::Signed(caller)); + + assert_last_event::( + Event::::AccountClaimed { + account_id: caller_clone, + evm_address, + } + .into(), + ); + } +} diff --git a/pallets/unified-accounts/src/lib.rs b/pallets/unified-accounts/src/lib.rs new file mode 100644 index 0000000000..c2c53643e8 --- /dev/null +++ b/pallets/unified-accounts/src/lib.rs @@ -0,0 +1,405 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +//! # Pallet Unified Account +//! +//! A simple module for managing mappings (both ways) between different +//! address schemes, inspired from Acala's evm-accounts pallet +//! https://github.com/AcalaNetwork/Acala/tree/master/modules/evm-accounts +//! +//! - [`Config`] +//! - [`Call`] +//! +//! ## Overview +//! +//! The Unified Accounts module provide functionality for native account holders to +//! connect their evm address to have a unified experence across the different VMs. +//! - Connect evm address you control +//! - Connect default evm address +//! +//! ## Interface +//! +//! * `claim_evm_address`: Creates the double mappings for the provided evm address with caller +//! account id given that no prior mapping exists for both and signature provided is valid. +//! * `claim_default_evm_address`: Creates the double mapping with default evm address given that +//! no prior mapping exists. +//! +//! WARNINGS: +//! * This pallet only handles transfer of native balance only, for the rest of native assets +//! hold by evm address like XC20, DAppStaking unclaimed rewards, etc should be transferred +//! manually beforehand by user himself otherwise FUNDS WILL BE LOST FOREVER. +//! * Once mapping is created it cannot be changed. +//! +//! ## Traits +//! +//! * `UnifiedAddressMapper`: Interface to access pallet's mappings with defaults +//! +//! ## Implementations +//! +//! * [`StaticLookup`](sp_runtime::traits::StaticLookup): Lookup implementations for accepting H160 +//! * [`AddressMapping`](pallet_evm::AddressMapping): Wrapper over `UnifiedAddressMapper` for evm address mapping +//! to account id. +//! * [`AccountMapping`](astar_primitives::ethereum_checked::AccountMapping): Wrapper over `UnifiedAddressMapper` +//! for account id mappings to h160. +//! * `KillAccountMapping`: [`OnKilledAccount`](frame_support::traits::OnKilledAccount) implementation to remove +//! the mappings from storage after account is reaped. + +#![cfg_attr(not(feature = "std"), no_std)] + +use astar_primitives::{ + ethereum_checked::AccountMapping, + evm::{EvmAddress, UnifiedAddressMapper}, +}; +use frame_support::{ + pallet_prelude::*, + traits::{ + fungible::{Inspect, Mutate}, + tokens::{Fortitude::*, Preservation::*}, + IsType, OnKilledAccount, + }, +}; +use frame_system::{ensure_signed, pallet_prelude::*}; +use pallet_evm::AddressMapping; +use precompile_utils::keccak256; +use sp_core::{H160, H256, U256}; +use sp_io::hashing::keccak_256; +use sp_runtime::{ + traits::{LookupError, StaticLookup, Zero}, + MultiAddress, +}; +use sp_std::marker::PhantomData; + +pub use pallet::*; + +pub mod weights; +pub use weights::WeightInfo; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; +mod mock; +mod tests; + +/// ECDSA Signature type, with last bit for recovering address +type EvmSignature = [u8; 65]; + +#[frame_support::pallet] +pub mod pallet { + use super::*; + + #[pallet::pallet] + pub struct Pallet(PhantomData); + + #[pallet::config] + pub trait Config: frame_system::Config { + /// The overarching event type + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + /// The Currency for managing evm address assets + type Currency: Mutate; + /// Default evm address to account id conversion + type DefaultEvmToNative: AddressMapping; + /// Default account id to evm address conversion + type DefaultNativeToEvm: AccountMapping; + /// EVM chain id + type ChainId: Get; + /// Weight information for the extrinsics in this module + type WeightInfo: WeightInfo; + } + + #[pallet::error] + pub enum Error { + /// AccountId or EvmAddress already mapped + AlreadyMapped, + /// The signature is malformed + UnexpectedSignatureFormat, + /// The signature verification failed due to mismatch evm address + InvalidSignature, + } + + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + /// Evm Address claimed. + /// Double Mapping b/w native and evm address created + AccountClaimed { + account_id: T::AccountId, + evm_address: EvmAddress, + }, + } + + /// Native accounts for evm address + /// NativeToEvm: EvmAddress => Option + #[pallet::storage] + pub type NativeToEvm = + StorageMap<_, Blake2_128Concat, EvmAddress, T::AccountId, OptionQuery>; + + /// Evm addresses for native accounts + /// EvmToNative: AccountId => Option + #[pallet::storage] + pub type EvmToNative = + StorageMap<_, Blake2_128Concat, T::AccountId, EvmAddress, OptionQuery>; + + #[pallet::call] + impl Pallet { + /// Claim account mapping between Substrate account and Evm address. + /// Ensure no prior mapping exists for evm address. + /// + /// - `evm_address`: The evm address to bind to the caller's account + /// - `signature`: A signature generated by the address to prove ownership + /// + /// WARNING: + /// - This extrisic only handles transfer of native balance, if your EVM + /// address contains any other native assets like XC20, DAppStaking unclaimed rewards, + /// etc you need to transfer them before hand, otherwise FUNDS WILL BE LOST FOREVER. + /// - Once connected user cannot change their mapping EVER. + #[pallet::call_index(0)] + #[pallet::weight(T::WeightInfo::claim_evm_address())] + pub fn claim_evm_address( + origin: OriginFor, + evm_address: EvmAddress, + signature: EvmSignature, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + // make sure no prior mapping exists + ensure!( + !EvmToNative::::contains_key(&who), + Error::::AlreadyMapped + ); + ensure!( + !NativeToEvm::::contains_key(evm_address), + Error::::AlreadyMapped + ); + + // recover evm address from signature + let address = Self::verify_signature(&who, &signature) + .ok_or(Error::::UnexpectedSignatureFormat)?; + + ensure!(evm_address == address, Error::::InvalidSignature); + + // Check if the default account id already exists for this evm address + let default_account_id = T::DefaultEvmToNative::into_account_id(evm_address.clone()); + if frame_system::Pallet::::account_exists(&default_account_id) { + // Transfer all the free native balance from old account id to the newly + // since this `default_account_id` will no longer be connected to evm address + // and users cannot access it. + // For the reset of the assets types (like XC20, etc) that should be handled by UI. + T::Currency::transfer( + &default_account_id, + &who, + T::Currency::reducible_balance(&default_account_id, Expendable, Polite), + Expendable, + )?; + } + + // create double mappings for the pair + NativeToEvm::::insert(&evm_address, &who); + EvmToNative::::insert(&who, &evm_address); + + Self::deposit_event(Event::AccountClaimed { + account_id: who, + evm_address, + }); + Ok(()) + } + + /// Claim default evm address for given account id + /// Ensure no prior mapping exists for the account + /// + /// WARNINGS: Once connected user cannot change their mapping EVER. + #[pallet::call_index(1)] + #[pallet::weight(T::WeightInfo::claim_default_evm_address())] + pub fn claim_default_evm_address(origin: OriginFor) -> DispatchResult { + let who = ensure_signed(origin)?; + // claim default evm address + let _ = Self::do_claim_default_evm_address(who)?; + Ok(()) + } + } +} + +impl Pallet { + /// Claim the default evm address + fn do_claim_default_evm_address(account_id: T::AccountId) -> Result { + ensure!( + !EvmToNative::::contains_key(&account_id), + Error::::AlreadyMapped + ); + // get the default evm address + let evm_address = T::DefaultNativeToEvm::into_h160(account_id.clone()); + // make sure default address is not already mapped, this should not + // happen but for sanity check. + ensure!( + !NativeToEvm::::contains_key(&evm_address), + Error::::AlreadyMapped + ); + // create double mappings for the pair with default evm address + NativeToEvm::::insert(&evm_address, &account_id); + EvmToNative::::insert(&account_id, &evm_address); + + Self::deposit_event(Event::AccountClaimed { + account_id, + evm_address, + }); + Ok(evm_address) + } +} + +/// EIP-712 compatible signature scheme for verifying ownership of EVM Address +/// https://eips.ethereum.org/EIPS/eip-712 +/// +/// Raw Data = Domain Separator + Type Hash + keccak256(AccountId) +impl Pallet { + pub fn build_signing_payload(who: &T::AccountId) -> [u8; 32] { + let domain_separator = Self::build_domain_separator(); + let args_hash = Self::build_args_hash(who); + + let mut payload = b"\x19\x01".to_vec(); + payload.extend_from_slice(&domain_separator); + payload.extend_from_slice(&args_hash); + keccak_256(&payload) + } + + pub fn verify_signature(who: &T::AccountId, sig: &EvmSignature) -> Option { + let payload_hash = Self::build_signing_payload(who); + + sp_io::crypto::secp256k1_ecdsa_recover(sig, &payload_hash) + .map(|pubkey| H160::from(H256::from_slice(&keccak_256(&pubkey)))) + .ok() + } + + fn build_domain_separator() -> [u8; 32] { + let mut domain = + keccak256!("EIP712Domain(string name,string version,uint256 chainId,bytes32 salt)") + .to_vec(); + domain.extend_from_slice(&keccak256!("Astar EVM Claim")); // name + domain.extend_from_slice(&keccak256!("1")); // version + domain.extend_from_slice(&(<[u8; 32]>::from(U256::from(T::ChainId::get())))); // chain id + domain.extend_from_slice( + frame_system::Pallet::::block_hash(T::BlockNumber::zero()).as_ref(), + ); // genesis block hash + keccak_256(domain.as_slice()) + } + + fn build_args_hash(account: &T::AccountId) -> [u8; 32] { + let mut args_hash = keccak256!("Claim(bytes substrateAddress)").to_vec(); + args_hash.extend_from_slice(&keccak_256(&account.encode())); + keccak_256(args_hash.as_slice()) + } +} + +#[cfg(any(feature = "std", feature = "runtime-benchmarks"))] +impl Pallet { + /// Sign the given prehash with provided eth private key + pub fn eth_sign_prehash(prehash: &[u8; 32], secret: &libsecp256k1::SecretKey) -> [u8; 65] { + let (sig, recovery_id) = libsecp256k1::sign(&libsecp256k1::Message::parse(prehash), secret); + let mut r = [0u8; 65]; + r[0..64].copy_from_slice(&sig.serialize()[..]); + r[64] = recovery_id.serialize(); + r + } + + /// Get the eth address for given eth private key + pub fn eth_address(secret: &libsecp256k1::SecretKey) -> EvmAddress { + EvmAddress::from_slice( + &sp_io::hashing::keccak_256( + &libsecp256k1::PublicKey::from_secret_key(secret).serialize()[1..65], + )[12..], + ) + } +} + +/// UnifiedAddressMapper implementation using pallet's mapping +/// and default address scheme from pallet's config +impl UnifiedAddressMapper for Pallet { + fn to_account_id(evm_address: &EvmAddress) -> Option { + NativeToEvm::::get(evm_address) + } + + fn to_account_id_or_default(evm_address: &EvmAddress) -> T::AccountId { + NativeToEvm::::get(evm_address).unwrap_or_else(|| { + // fallback to default account_id + T::DefaultEvmToNative::into_account_id(evm_address.clone()) + }) + } + + fn to_default_account_id(evm_address: &EvmAddress) -> T::AccountId { + T::DefaultEvmToNative::into_account_id(evm_address.clone()) + } + + fn to_h160(account_id: &T::AccountId) -> Option { + EvmToNative::::get(account_id) + } + + fn to_h160_or_default(account_id: &T::AccountId) -> EvmAddress { + EvmToNative::::get(account_id).unwrap_or_else(|| { + // fallback to default account_id + T::DefaultNativeToEvm::into_h160(account_id.clone()) + }) + } + + fn to_default_h160(account_id: &T::AccountId) -> EvmAddress { + T::DefaultNativeToEvm::into_h160(account_id.clone()) + } +} + +/// AccountMapping wrapper implementation +impl AccountMapping for Pallet { + fn into_h160(account: T::AccountId) -> H160 { + >::to_h160_or_default(&account) + } +} + +/// AddressMapping wrapper implementation +impl AddressMapping for Pallet { + fn into_account_id(evm_address: H160) -> T::AccountId { + >::to_account_id_or_default(&evm_address) + } +} + +/// OnKilledAccout hooks implementation for removing storage mapping +/// for killed accounts +pub struct KillAccountMapping(PhantomData); +impl OnKilledAccount for KillAccountMapping { + fn on_killed_account(who: &T::AccountId) { + // remove mapping created by `claim_account` or `get_or_create_evm_address` + if let Some(evm_addr) = EvmToNative::::take(who) { + NativeToEvm::::remove(evm_addr); + EvmToNative::::remove(who); + } + } +} + +/// A lookup implementation returning the `AccountId` from `MultiAddress::Address20` (EVM Address). +impl StaticLookup for Pallet { + type Source = MultiAddress; + type Target = T::AccountId; + + fn lookup(a: Self::Source) -> Result { + match a { + MultiAddress::Address20(i) => Ok( + >::to_account_id_or_default( + &EvmAddress::from_slice(&i), + ), + ), + _ => Err(LookupError), + } + } + + fn unlookup(a: Self::Target) -> Self::Source { + MultiAddress::Id(a) + } +} diff --git a/pallets/unified-accounts/src/mock.rs b/pallets/unified-accounts/src/mock.rs new file mode 100644 index 0000000000..1b0f4a4851 --- /dev/null +++ b/pallets/unified-accounts/src/mock.rs @@ -0,0 +1,231 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +#![cfg(test)] + +use super::*; +use crate as pallet_unified_accounts; +use astar_primitives::ethereum_checked::HashedAccountMapping; +use frame_support::{ + construct_runtime, parameter_types, + sp_io::TestExternalities, + traits::{ConstU128, ConstU64, FindAuthor}, + weights::Weight, +}; +use pallet_ethereum::PostLogContent; +use pallet_evm::{FeeCalculator, HashedAddressMapping}; +use sp_core::{keccak_256, H160, H256, U256}; +use sp_runtime::{ + testing::Header, + traits::{AccountIdLookup, BlakeTwo256}, + AccountId32, ConsensusEngineId, +}; + +parameter_types! { + pub BlockWeights: frame_system::limits::BlockWeights = + frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, 0)); +} + +impl frame_system::Config for TestRuntime { + type BaseCallFilter = frame_support::traits::Everything; + type BlockWeights = (); + type BlockLength = (); + type RuntimeOrigin = RuntimeOrigin; + type Index = u64; + type RuntimeCall = RuntimeCall; + type BlockNumber = BlockNumber; + type Hash = H256; + type Hashing = BlakeTwo256; + type AccountId = AccountId; + type Lookup = (AccountIdLookup, UnifiedAccounts); + type Header = Header; + type RuntimeEvent = RuntimeEvent; + type BlockHashCount = ConstU64<250>; + type DbWeight = (); + type Version = (); + type PalletInfo = PalletInfo; + type AccountData = pallet_balances::AccountData; + type OnNewAccount = (); + type OnKilledAccount = KillAccountMapping; + type SystemWeightInfo = (); + type SS58Prefix = (); + type OnSetCode = (); + type MaxConsumers = frame_support::traits::ConstU32<16>; +} + +impl pallet_balances::Config for TestRuntime { + type MaxLocks = ConstU32<4>; + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type Balance = Balance; + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ConstU128<2>; + type AccountStore = System; + type WeightInfo = (); + type HoldIdentifier = (); + type FreezeIdentifier = (); + type MaxHolds = ConstU32<0>; + type MaxFreezes = ConstU32<0>; +} + +impl pallet_timestamp::Config for TestRuntime { + type Moment = u64; + type OnTimestampSet = (); + type MinimumPeriod = ConstU64<3>; + type WeightInfo = (); +} + +pub struct MockFeeCalculator; +impl FeeCalculator for MockFeeCalculator { + fn min_gas_price() -> (U256, Weight) { + (U256::one(), Weight::zero()) + } +} + +pub struct MockFindAuthor; +impl FindAuthor for MockFindAuthor { + fn find_author<'a, I>(_digests: I) -> Option + where + I: 'a + IntoIterator, + { + Some(H160::from_low_u64_be(1)) + } +} + +parameter_types! { + pub WeightPerGas: Weight = Weight::from_parts(1, 0); + pub const BlockGasLimit: U256 = U256::MAX; + pub ChainId: u64 = 1024; +} + +impl pallet_evm::Config for TestRuntime { + type FeeCalculator = MockFeeCalculator; + type GasWeightMapping = pallet_evm::FixedGasWeightMapping; + type WeightPerGas = WeightPerGas; + type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; + type CallOrigin = pallet_evm::EnsureAddressRoot; + type WithdrawOrigin = pallet_evm::EnsureAddressTruncated; + type AddressMapping = UnifiedAccounts; + type Currency = Balances; + type RuntimeEvent = RuntimeEvent; + type Runner = pallet_evm::runner::stack::Runner; + type PrecompilesType = (); + type PrecompilesValue = (); + type ChainId = ChainId; + type OnChargeTransaction = (); + type BlockGasLimit = BlockGasLimit; + type OnCreate = (); + type FindAuthor = MockFindAuthor; + type Timestamp = Timestamp; + type WeightInfo = pallet_evm::weights::SubstrateWeight; + type GasLimitPovSizeRatio = ConstU64<4>; +} + +parameter_types! { + pub const PostBlockAndTxnHashes: PostLogContent = PostLogContent::BlockAndTxnHashes; +} + +impl pallet_ethereum::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type StateRoot = pallet_ethereum::IntermediateStateRoot; + type PostLogContent = PostBlockAndTxnHashes; + type ExtraDataLength = ConstU32<30>; +} + +parameter_types! { + pub TxWeightLimit: Weight = Weight::from_parts(u64::max_value(), 0); +} + +impl pallet_unified_accounts::Config for TestRuntime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type DefaultEvmToNative = HashedAddressMapping; + type DefaultNativeToEvm = HashedAccountMapping; + type ChainId = ChainId; + type WeightInfo = (); +} + +pub(crate) type AccountId = AccountId32; +pub(crate) type BlockNumber = u64; +pub(crate) type Balance = u128; + +pub const ALICE: AccountId32 = AccountId32::new([0u8; 32]); +pub const BOB: AccountId32 = AccountId32::new([1u8; 32]); +pub const CHARLIE: AccountId32 = AccountId32::new([2u8; 32]); + +pub fn alice_secret() -> libsecp256k1::SecretKey { + libsecp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap() +} + +pub fn bob_secret() -> libsecp256k1::SecretKey { + libsecp256k1::SecretKey::parse(&keccak_256(b"Bob")).unwrap() +} + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +construct_runtime!( + pub struct TestRuntime + where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system, + Timestamp: pallet_timestamp, + Balances: pallet_balances, + Evm: pallet_evm, + Ethereum: pallet_ethereum, + UnifiedAccounts: pallet_unified_accounts, + } +); + +pub struct ExtBuilder { + balances: Vec<(AccountId, Balance)>, +} + +impl Default for ExtBuilder { + fn default() -> Self { + Self { + balances: vec![ + (ALICE, 1_000_000_000_000), + (BOB, 1_000_000_000_000), + (CHARLIE, 1_000_000_000_000), + ], + } + } +} + +impl ExtBuilder { + pub fn build(self) -> TestExternalities { + let mut t = frame_system::GenesisConfig::default() + .build_storage::() + .unwrap(); + + pallet_balances::GenesisConfig:: { + balances: self.balances, + } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = TestExternalities::from(t); + ext.execute_with(|| System::set_block_number(1)); + ext + } +} diff --git a/pallets/unified-accounts/src/tests.rs b/pallets/unified-accounts/src/tests.rs new file mode 100644 index 0000000000..93dd97937a --- /dev/null +++ b/pallets/unified-accounts/src/tests.rs @@ -0,0 +1,336 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +#![cfg(test)] + +use super::*; +use frame_support::{assert_noop, assert_ok}; +use mock::*; + +use ethers::{ + contract::{Eip712, EthAbiType}, + core::types::{transaction::eip712::Eip712, Bytes}, +}; +use parity_scale_codec::Encode; +use sp_runtime::{traits::StaticLookup, AccountId32, MultiAddress}; + +/// EIP712 Payload struct +#[derive(Eip712, EthAbiType, Clone)] +#[eip712( + name = "Astar EVM Claim", + version = "1", + chain_id = 1024, + // mock genisis hash + raw_salt = "0x4545454545454545454545454545454545454545454545454545454545454545" + )] +struct Claim { + substrate_address: Bytes, +} + +/// Build the signature payload for given native account and eth private key +fn get_evm_signature(who: &AccountId32, secret: &libsecp256k1::SecretKey) -> [u8; 65] { + // sign the payload + UnifiedAccounts::eth_sign_prehash( + &Claim { + substrate_address: who.encode().into(), + } + .encode_eip712() + .unwrap(), + secret, + ) +} + +/// Create the mappings for the accounts +fn connect_accounts(who: &AccountId32, secret: &libsecp256k1::SecretKey) { + assert_ok!(UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(who.clone()), + UnifiedAccounts::eth_address(secret), + get_evm_signature(who, secret) + )); +} + +#[test] +fn eip712_signature_verify_works() { + ExtBuilder::default().build().execute_with(|| { + let claim = Claim { + substrate_address: ALICE.encode().into(), + }; + + let claim_hash = UnifiedAccounts::build_signing_payload(&ALICE); + // assert signing payload is correct + assert_eq!( + claim.encode_eip712().unwrap(), + claim_hash, + "signing payload should match" + ); + + // sign the payload + let sig = UnifiedAccounts::eth_sign_prehash(&claim_hash, &alice_secret()); + assert_eq!( + Some(UnifiedAccounts::eth_address(&alice_secret())), + UnifiedAccounts::verify_signature(&ALICE, &sig), + "signature verification should work" + ); + }); +} + +#[test] +fn static_lookup_works() { + ExtBuilder::default().build().execute_with(|| { + let alice_eth = UnifiedAccounts::eth_address(&alice_secret()); + let bob_eth = UnifiedAccounts::eth_address(&bob_secret()); + let bob_default_account_id = + >::to_default_account_id(&bob_eth); + + // create mappings for alice + connect_accounts(&ALICE, &alice_secret()); + + // mapping should work if available + assert_eq!( + ::lookup(MultiAddress::Address20(alice_eth.into())) + .unwrap(), + ALICE + ); + + // should use default if not mapping + assert_eq!( + ::lookup(MultiAddress::Address20(bob_eth.into())) + .unwrap(), + bob_default_account_id + ); + }); +} + +#[test] +fn on_killed_account_hook() { + ExtBuilder::default().build().execute_with(|| { + let alice_eth = UnifiedAccounts::eth_address(&alice_secret()); + + // create the mappings + connect_accounts(&ALICE, &alice_secret()); + + // kill alice by transfering everything to bob + Balances::set_balance(&ALICE, 0); + + // check killed account events + assert!(System::events().iter().any(|r| matches!( + &r.event, + RuntimeEvent::System(frame_system::Event::KilledAccount { account }) if account == &ALICE + ))); + + // make sure mapping is removed + assert_eq!(EvmToNative::::get(ALICE), None); + assert_eq!(NativeToEvm::::get(alice_eth), None); + }); +} + +#[test] +fn account_claim_should_work() { + ExtBuilder::default().build().execute_with(|| { + let alice_eth = UnifiedAccounts::eth_address(&alice_secret()); + // default ss58 account associated with eth address + let alice_eth_old_account = ::DefaultEvmToNative::into_account_id(alice_eth.clone()); + let signature = get_evm_signature(&ALICE, &alice_secret()); + + // transfer some funds to alice_eth (H160) + assert_ok!(Balances::transfer_allow_death( + RuntimeOrigin::signed(BOB), + alice_eth_old_account.clone().into(), + 1001 + )); + + // claim the account + assert_ok!(UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(ALICE), + alice_eth, + signature + )); + + // check if all of balances is transfered to new account (ALICE) from + // old account (alice_eth_old_account) + assert!(System::events().iter().any(|r| matches!( + &r.event, + RuntimeEvent::System(frame_system::Event::KilledAccount { account }) if account == &alice_eth_old_account + ))); + + // check for claim account event + System::assert_last_event( + RuntimeEvent::UnifiedAccounts(crate::Event::AccountClaimed { account_id: ALICE.clone(), evm_address: alice_eth.clone()}) + ); + + // make sure mappings are in place + assert_eq!( + NativeToEvm::::get(alice_eth).unwrap(), ALICE + ); + assert_eq!( + EvmToNative::::get(ALICE).unwrap(), alice_eth + ) + }); +} + +#[test] +fn account_default_claim_works() { + ExtBuilder::default().build().execute_with(|| { + let alice_default_evm = + ::DefaultNativeToEvm::into_h160(ALICE.into()); + + // claim default account + assert_ok!(UnifiedAccounts::claim_default_evm_address( + RuntimeOrigin::signed(ALICE) + )); + System::assert_last_event(RuntimeEvent::UnifiedAccounts( + crate::Event::AccountClaimed { + account_id: ALICE.clone(), + evm_address: alice_default_evm.clone(), + }, + )); + + // check UnifiedAddressMapper's mapping works + assert_eq!( + >::to_h160(&ALICE), + Some(alice_default_evm) + ); + assert_eq!( + >::to_account_id(&alice_default_evm), + Some(ALICE) + ); + + // should not allow to claim afterwards + assert_noop!( + UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(ALICE), + UnifiedAccounts::eth_address(&alice_secret()), + get_evm_signature(&ALICE, &alice_secret()) + ), + Error::::AlreadyMapped + ); + }); +} + +#[test] +fn account_default_claim_should_not_work_if_collision() { + ExtBuilder::default().build().execute_with(|| { + let bob_default_h160 = >::to_default_h160(&BOB); + + // create mapping of alice native with bob's default address + // in real world possibilty of this happening is minuscule + NativeToEvm::::insert(&bob_default_h160, &ALICE); + EvmToNative::::insert(&ALICE, &bob_default_h160); + + // bob try claiming default h160 address, it should fail since alice already + // has mapping in place with it. + assert_noop!( + UnifiedAccounts::claim_default_evm_address(RuntimeOrigin::signed(BOB)), + Error::::AlreadyMapped + ); + + // check mappings are consistent + assert_eq!( + >::to_h160(&ALICE), + Some(bob_default_h160) + ); + assert_eq!( + >::to_account_id(&bob_default_h160), + Some(ALICE) + ); + }); +} + +#[test] +fn replay_attack_should_not_be_possible() { + ExtBuilder::default().build().execute_with(|| { + let alice_eth = UnifiedAccounts::eth_address(&alice_secret()); + let alice_signature = get_evm_signature(&ALICE, &alice_secret()); + + // alice claim her eth address first + assert_ok!(UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(ALICE), + alice_eth, + alice_signature + )); + + // bob intercepted alice signature and tries to perform + // replay attack to claim alice eth address as his own, + // this should fail. + assert_noop!( + UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(BOB), + alice_eth, + alice_signature + ), + Error::::AlreadyMapped + ); + }); +} + +#[test] +fn frontrun_attack_should_not_be_possible() { + ExtBuilder::default().build().execute_with(|| { + let alice_eth = UnifiedAccounts::eth_address(&alice_secret()); + let alice_signature = get_evm_signature(&ALICE, &alice_secret()); + + // bob intercepted alice signature and tries to perform + // frontrun attack to claim alice eth address as his own + // this should fail with InvalidSignature. + assert_noop!( + UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(BOB), + alice_eth, + alice_signature + ), + Error::::InvalidSignature + ); + + // alice can claim her eth address + assert_ok!(UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(ALICE), + alice_eth, + alice_signature + )); + }); +} + +#[test] +fn connecting_mapped_accounts_should_not_work() { + ExtBuilder::default().build().execute_with(|| { + // connect ALICE accounts + connect_accounts(&ALICE, &alice_secret()); + + // AccountId already mapped + // ALICE attempts to connect another evm address + assert_noop!( + UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(ALICE), + UnifiedAccounts::eth_address(&bob_secret()), + get_evm_signature(&BOB, &bob_secret()) + ), + Error::::AlreadyMapped + ); + + // eth address already mapped + // BOB attempts to connect alice_eth that is already mapped + assert_noop!( + UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(BOB), + UnifiedAccounts::eth_address(&alice_secret()), + get_evm_signature(&ALICE, &alice_secret()) + ), + Error::::AlreadyMapped + ); + }); +} diff --git a/pallets/unified-accounts/src/weights.rs b/pallets/unified-accounts/src/weights.rs new file mode 100644 index 0000000000..81ea31fd29 --- /dev/null +++ b/pallets/unified-accounts/src/weights.rs @@ -0,0 +1,127 @@ + +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +//! Autogenerated weights for pallet_unified_accounts +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-09-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=shibuya-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_unified_accounts +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/unified_accounts_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weight functions needed for pallet_unified_accounts. +pub trait WeightInfo { + fn claim_evm_address() -> Weight; + fn claim_default_evm_address() -> Weight; +} + +/// Weights for pallet_unified_accounts using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: UnifiedAccounts EvmToNative (r:1 w:1) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts NativeToEvm (r:1 w:1) + /// Proof: UnifiedAccounts NativeToEvm (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: EVMChainId ChainId (r:1 w:0) + /// Proof: EVMChainId ChainId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: System BlockHash (r:1 w:0) + /// Proof: System BlockHash (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn claim_evm_address() -> Weight { + // Proof Size summary in bytes: + // Measured: `256` + // Estimated: `3593` + // Minimum execution time: 64_843_000 picoseconds. + Weight::from_parts(65_508_000, 3593) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: UnifiedAccounts EvmToNative (r:1 w:1) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts NativeToEvm (r:1 w:1) + /// Proof: UnifiedAccounts NativeToEvm (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn claim_default_evm_address() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `3533` + // Minimum execution time: 16_399_000 picoseconds. + Weight::from_parts(16_806_000, 3533) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: UnifiedAccounts EvmToNative (r:1 w:1) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts NativeToEvm (r:1 w:1) + /// Proof: UnifiedAccounts NativeToEvm (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: EVMChainId ChainId (r:1 w:0) + /// Proof: EVMChainId ChainId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: System BlockHash (r:1 w:0) + /// Proof: System BlockHash (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:0) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn claim_evm_address() -> Weight { + // Proof Size summary in bytes: + // Measured: `256` + // Estimated: `3593` + // Minimum execution time: 64_843_000 picoseconds. + Weight::from_parts(65_508_000, 3593) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: UnifiedAccounts EvmToNative (r:1 w:1) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts NativeToEvm (r:1 w:1) + /// Proof: UnifiedAccounts NativeToEvm (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn claim_default_evm_address() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `3533` + // Minimum execution time: 16_399_000 picoseconds. + Weight::from_parts(16_806_000, 3533) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } +} diff --git a/primitives/src/ethereum_checked.rs b/primitives/src/ethereum_checked.rs index 29af13c229..51eda15a0b 100644 --- a/primitives/src/ethereum_checked.rs +++ b/primitives/src/ethereum_checked.rs @@ -30,8 +30,11 @@ use frame_support::{ traits::ConstU32, BoundedVec, }; +use sp_core::Hasher; use sp_std::{prelude::*, result::Result}; +use crate::AccountId; + /// Max Ethereum tx input size: 65_536 bytes pub const MAX_ETHEREUM_TX_INPUT_SIZE: u32 = 2u32.pow(16); @@ -101,3 +104,12 @@ pub trait CheckedEthereumTransact { pub trait AccountMapping { fn into_h160(account: AccountId) -> H160; } + +/// Hashed derive mapping for converting account id to evm address +pub struct HashedAccountMapping(sp_std::marker::PhantomData); +impl> AccountMapping for HashedAccountMapping { + fn into_h160(account: AccountId) -> H160 { + let payload = (b"evm:", account); + H160::from_slice(&payload.using_encoded(H::hash)[0..20]) + } +} diff --git a/primitives/src/evm.rs b/primitives/src/evm.rs index 25d1599219..766f7bf7a8 100644 --- a/primitives/src/evm.rs +++ b/primitives/src/evm.rs @@ -19,11 +19,14 @@ use crate::{AccountId, AssetId}; use frame_support::ensure; +use sp_core::H160; use sp_std::marker::PhantomData; use pallet_assets::AssetsCallback; use pallet_evm_precompile_assets_erc20::AddressToAssetId; +pub type EvmAddress = H160; + /// Revert opt code. It's inserted at the precompile addresses, to make them functional in EVM. pub const EVM_REVERT_CODE: &[u8] = &[0x60, 0x00, 0x60, 0x00, 0xfd]; @@ -54,3 +57,22 @@ where Ok(()) } } + +/// Mapping between Native and EVM Addresses +pub trait UnifiedAddressMapper { + /// Gets the account id associated with given evm address, if mapped else None. + fn to_account_id(evm_address: &EvmAddress) -> Option; + /// Gets the account id associated with given evm address. + /// If no mapping exists, then return the default evm address. + fn to_account_id_or_default(evm_address: &EvmAddress) -> AccountId; + /// Gets the default account id which is associated with given evm address. + fn to_default_account_id(evm_address: &EvmAddress) -> AccountId; + + /// Gets the evm address associated with given account id, if mapped else None. + fn to_h160(account_id: &AccountId) -> Option; + /// Gets the evm address associated with given account id. + /// If no mapping exists, then return the default account id. + fn to_h160_or_default(account_id: &AccountId) -> EvmAddress; + /// Gets the default evm address which is associated with given account id. + fn to_default_h160(account_id: &AccountId) -> EvmAddress; +} diff --git a/rpc-tests/claim.mjs b/rpc-tests/claim.mjs new file mode 100644 index 0000000000..809752bb13 --- /dev/null +++ b/rpc-tests/claim.mjs @@ -0,0 +1,65 @@ +/// TODO: make this into a rpc test when integrated in Shiden & Astar + +import { JsonRpcProvider, Wallet } from "ethers" +import { WsProvider, ApiPromise, Keyring } from '@polkadot/api'; + +async function waitForTx(tx, signer, api) { + return new Promise((resolve, reject) => { + tx.signAndSend(signer, (result) => { + if (result.status.isInBlock) { + console.log(`\t Transaction included at blockHash ${result.status.asInBlock}`); + } else if (result.status.isFinalized) { + console.log(`\t Transaction finalized at blockHash ${result.status.asFinalized}`); + result.events.forEach(({ phase, event: { data, method, section } }) => { + console.log(`\t' ${phase}: ${section}.${method}:: ${data}`); + }); + resolve(result.txHash) + } else if (result.isError) { + reject(); + } + }) + }) +} + +async function buildSignature(signer, substrateAddress, api, chainId) { + return await signer.signTypedData({ + chainId, + name: "Astar EVM Claim", + version: "1", + salt: await api.query.system.blockHash(0) // genisis hash + }, { + Claim: [ + { name: 'substrateAddress', type: 'bytes' } + ], + }, { + substrateAddress + }) +} + +async function claimEvmAccount(account, evmAddress, signature, api) { + return await waitForTx(api.tx.unifiedAccounts.claimEvmAddress(evmAddress, signature), account) +} + +async function main() { + const api = await ApiPromise.create({ provider: new WsProvider('ws://127.0.0.1:9944') }); + await api.isReady; + + const keyring = new Keyring({ type: 'sr25519' }); + const alice = keyring.addFromUri('//Alice', { name: 'Alice default' }) + + const provider = new JsonRpcProvider("http://127.0.0.1:9944"); + const { chainId } = await provider.getNetwork(); + const ethSigner = new Wallet("0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391", provider); + + const sig = await buildSignature(ethSigner, alice.publicKey, api, chainId); + console.log(`Signature - ${sig}`) + const hash = await claimEvmAccount(alice, ethSigner.address, sig, api); + console.log(`Claim Extrisic - ${hash}`); + + console.log(`Claimed Account ${await api.query.unifiedAccounts.evmToNative(alice.address)}, EVM Account: ${ethSigner.address}`); + console.log(`EVM Balance=${await provider.getBalance(ethSigner.address)}`) + + api.disconnect(); +} + +await main() diff --git a/rpc-tests/package.json b/rpc-tests/package.json index ad51a9a26d..636f5b90f8 100644 --- a/rpc-tests/package.json +++ b/rpc-tests/package.json @@ -8,8 +8,9 @@ "author": "AstarNetwork", "license": "ISC", "dependencies": { - "@polkadot/util-crypto": "^10.4.2", + "@polkadot/api": "^10.9.1", "solc": "^0.8.18", - "web3": "^1.8.2" + "web3": "^1.8.2", + "ethers": "6" } } diff --git a/rpc-tests/yarn.lock b/rpc-tests/yarn.lock index d5b7eca9fa..a735b485da 100644 --- a/rpc-tests/yarn.lock +++ b/rpc-tests/yarn.lock @@ -2,12 +2,10 @@ # yarn lockfile v1 -"@babel/runtime@^7.20.13", "@babel/runtime@^7.20.6": - version "7.21.0" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673" - integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw== - dependencies: - regenerator-runtime "^0.13.11" +"@adraffy/ens-normalize@1.9.2": + version "1.9.2" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.9.2.tgz#60111a5d9db45b2e5cbb6231b0bb8d97e8659316" + integrity sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg== "@ethereumjs/common@2.5.0": version "2.5.0" @@ -210,144 +208,352 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" -"@noble/hashes@1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.2.0.tgz#a3150eeb09cc7ab207ebf6d7b9ad311a9bdbed12" - integrity sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ== +"@noble/curves@1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.1.0.tgz#f13fc667c89184bc04cccb9b11e8e7bae27d8c3d" + integrity sha512-091oBExgENk/kGj3AZmtBDMpxQPDtxQABR2B9lb1JbVTs6ytdzZNwvhxQ4MWasRNEzlbEH8jCWFCwhF/Obj5AA== + dependencies: + "@noble/hashes" "1.3.1" + +"@noble/hashes@1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183" + integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA== + +"@noble/hashes@1.3.1": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.1.tgz#8831ef002114670c603c458ab8b11328406953a9" + integrity sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA== "@noble/secp256k1@1.7.1": version "1.7.1" resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c" integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw== -"@polkadot/networks@10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/networks/-/networks-10.4.2.tgz#d7878c6aad8173c800a21140bfe5459261724456" - integrity sha512-FAh/znrEvWBiA/LbcT5GXHsCFUl//y9KqxLghSr/CreAmAergiJNT0MVUezC7Y36nkATgmsr4ylFwIxhVtuuCw== - dependencies: - "@babel/runtime" "^7.20.13" - "@polkadot/util" "10.4.2" - "@substrate/ss58-registry" "^1.38.0" +"@polkadot/api-augment@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-augment/-/api-augment-10.9.1.tgz#9fc81b81903229bb23b0b16783e97ec52a5d4f1b" + integrity sha512-kRZZvCFVcN4hAH4dJ+Qzfdy27/4EEq3oLDf3ihj0LTVrAezSWcKPGE3EVFy+Mn6Lo4SUc7RVyoKvIUhSk2l4Dg== + dependencies: + "@polkadot/api-base" "10.9.1" + "@polkadot/rpc-augment" "10.9.1" + "@polkadot/types" "10.9.1" + "@polkadot/types-augment" "10.9.1" + "@polkadot/types-codec" "10.9.1" + "@polkadot/util" "^12.3.1" + tslib "^2.5.3" + +"@polkadot/api-base@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-base/-/api-base-10.9.1.tgz#27f63c4950814c2f10535f794121fa1384dc2207" + integrity sha512-Q3m2KzlceMK2kX8bhnUZWk3RT6emmijeeFZZQgCePpEcrSeNjnqG4qjuTPgkveaOkUT8MAoDc5Avuzcc2jlW9g== + dependencies: + "@polkadot/rpc-core" "10.9.1" + "@polkadot/types" "10.9.1" + "@polkadot/util" "^12.3.1" + rxjs "^7.8.1" + tslib "^2.5.3" + +"@polkadot/api-derive@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-10.9.1.tgz#04a4ca3285fd215c4cd50cfb3f4791d38dd90050" + integrity sha512-mRud1UZCFIc4Z63qAoGSIHh/foyUYADfy1RQYCmPpeFKfIdCIrHpd7xFdJXTOMYOS0BwlM6u4qli/ZT4XigezQ== + dependencies: + "@polkadot/api" "10.9.1" + "@polkadot/api-augment" "10.9.1" + "@polkadot/api-base" "10.9.1" + "@polkadot/rpc-core" "10.9.1" + "@polkadot/types" "10.9.1" + "@polkadot/types-codec" "10.9.1" + "@polkadot/util" "^12.3.1" + "@polkadot/util-crypto" "^12.3.1" + rxjs "^7.8.1" + tslib "^2.5.3" + +"@polkadot/api@10.9.1", "@polkadot/api@^10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-10.9.1.tgz#156b3436f45ef18218960804988c1f552d2c4e46" + integrity sha512-ND/2UqZBWvtt4PfV03OStTKg0mxmPk4UpMAgJKutdgsz/wP9CYJ1KbjwFgPNekL9JnzbKQsWyQNPVrcw7kQk8A== + dependencies: + "@polkadot/api-augment" "10.9.1" + "@polkadot/api-base" "10.9.1" + "@polkadot/api-derive" "10.9.1" + "@polkadot/keyring" "^12.3.1" + "@polkadot/rpc-augment" "10.9.1" + "@polkadot/rpc-core" "10.9.1" + "@polkadot/rpc-provider" "10.9.1" + "@polkadot/types" "10.9.1" + "@polkadot/types-augment" "10.9.1" + "@polkadot/types-codec" "10.9.1" + "@polkadot/types-create" "10.9.1" + "@polkadot/types-known" "10.9.1" + "@polkadot/util" "^12.3.1" + "@polkadot/util-crypto" "^12.3.1" + eventemitter3 "^5.0.1" + rxjs "^7.8.1" + tslib "^2.5.3" + +"@polkadot/keyring@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-12.4.2.tgz#ff66c531ff29c1c9cb7c0f8411930bc18c76e2d3" + integrity sha512-VH91feSL6GiVVLcJ6V8h6jIAuq62bfvhM75AMcjTFol6MDqFl25jdjkHfZ2bQhig330LIhLw89nKdYr2/OfwjA== + dependencies: + "@polkadot/util" "12.4.2" + "@polkadot/util-crypto" "12.4.2" + tslib "^2.6.2" + +"@polkadot/networks@12.4.2", "@polkadot/networks@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/networks/-/networks-12.4.2.tgz#6b3dcbdd016beb0ea585009fd61b048b99b17d1c" + integrity sha512-dd7vss+86kpOyy/C+DuCWChGfhwHBHtrzJ9ArbbpY75qc8SqdP90lj/c13ZCHr5I1l+coy31gyyMj5i6ja1Dpg== + dependencies: + "@polkadot/util" "12.4.2" + "@substrate/ss58-registry" "^1.43.0" + tslib "^2.6.2" + +"@polkadot/rpc-augment@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-augment/-/rpc-augment-10.9.1.tgz#214ec3ee145d20caa61ea204041a3aadb89c6b0f" + integrity sha512-MaLHkNlyqN20ZRYr6uNd1BZr1OsrnX9qLAmsl0mcrri1vPGRH6VHjfFH1RBLkikpWD82v17g0l2hLwdV1ZHMcw== + dependencies: + "@polkadot/rpc-core" "10.9.1" + "@polkadot/types" "10.9.1" + "@polkadot/types-codec" "10.9.1" + "@polkadot/util" "^12.3.1" + tslib "^2.5.3" + +"@polkadot/rpc-core@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-10.9.1.tgz#798c514dbed6f6c2e43098a494c9f51fb144dc31" + integrity sha512-ZtA8B8SfXSAwVkBlCcKRHw0eSM7ec/sbiNOM5GasXPeRujUgT7lOwSH2GbUZSqe9RfRDMp6DvO9c2JoGc3LLWw== + dependencies: + "@polkadot/rpc-augment" "10.9.1" + "@polkadot/rpc-provider" "10.9.1" + "@polkadot/types" "10.9.1" + "@polkadot/util" "^12.3.1" + rxjs "^7.8.1" + tslib "^2.5.3" + +"@polkadot/rpc-provider@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-10.9.1.tgz#de3a474bbcd26d28d9cd3134acdb3b5ce92b680b" + integrity sha512-4QzT2QzD+320+eT6b79sGAA85Tt3Bb8fQvse4r5Mom2iiBd2SO81vOhxSAOaIe4GUsw25VzFJmsbe7+OObItdg== + dependencies: + "@polkadot/keyring" "^12.3.1" + "@polkadot/types" "10.9.1" + "@polkadot/types-support" "10.9.1" + "@polkadot/util" "^12.3.1" + "@polkadot/util-crypto" "^12.3.1" + "@polkadot/x-fetch" "^12.3.1" + "@polkadot/x-global" "^12.3.1" + "@polkadot/x-ws" "^12.3.1" + eventemitter3 "^5.0.1" + mock-socket "^9.2.1" + nock "^13.3.1" + tslib "^2.5.3" + optionalDependencies: + "@substrate/connect" "0.7.26" + +"@polkadot/types-augment@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-augment/-/types-augment-10.9.1.tgz#5f1c1225c04ffbfe243629a46087c9c9de25a6b3" + integrity sha512-OY9/jTMFRFqYdkUnfcGwqMLC64A0Q25bjvCuVQCVjsPFKE3wl0Kt5rNT01eV2UmLXrR6fY0xWbR2w80bLA7CIQ== + dependencies: + "@polkadot/types" "10.9.1" + "@polkadot/types-codec" "10.9.1" + "@polkadot/util" "^12.3.1" + tslib "^2.5.3" + +"@polkadot/types-codec@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-codec/-/types-codec-10.9.1.tgz#f30026d3dfeaa69c07c45fa66d1c39318fd232cc" + integrity sha512-mJ5OegKGraY1FLvEa8FopRCr3pQrhDkcn5RNOjmgJQozENVeRaxhk0NwxYz7IojFvSDnKnc6lNQfKaaSe5pLHg== + dependencies: + "@polkadot/util" "^12.3.1" + "@polkadot/x-bigint" "^12.3.1" + tslib "^2.5.3" + +"@polkadot/types-create@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-create/-/types-create-10.9.1.tgz#087d7e2af51cce558b67e3859613b932a3bdc0a3" + integrity sha512-OVz50MGTTuiuVnRP/zAx4CTuLioc0hsiwNwqN2lNhmIJGtnQ4Vy/7mQRsIWehiYz6g0Vzzm5B3qWkTXO1NSN5w== + dependencies: + "@polkadot/types-codec" "10.9.1" + "@polkadot/util" "^12.3.1" + tslib "^2.5.3" + +"@polkadot/types-known@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-10.9.1.tgz#fe0c7e55191aa843119edcaf9abb5d2471463a7d" + integrity sha512-zCMVWc4pJtkbMFPu72bD4IhvV/gkHXPX3C5uu92WdmCfnn0vEIEsMKWlVXVVvQQZKAqvs/awpqIfrUtEViOGEA== + dependencies: + "@polkadot/networks" "^12.3.1" + "@polkadot/types" "10.9.1" + "@polkadot/types-codec" "10.9.1" + "@polkadot/types-create" "10.9.1" + "@polkadot/util" "^12.3.1" + tslib "^2.5.3" + +"@polkadot/types-support@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/types-support/-/types-support-10.9.1.tgz#17a861aab8e5a225a4e20cefa2d16076ddd51baf" + integrity sha512-XsieuLDsszvMZQlleacQBfx07i/JkwQV/UxH9q8Hz7Okmaz9pEVEW1h3ka2/cPuC7a4l32JhaORBUYshBZNdJg== + dependencies: + "@polkadot/util" "^12.3.1" + tslib "^2.5.3" + +"@polkadot/types@10.9.1": + version "10.9.1" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-10.9.1.tgz#f111d00f7278ad3be95deba3d701fafefe080cb2" + integrity sha512-AG33i2ZGGfq7u+5rkAdGrXAQHHl844/Yv+junH5ZzX69xiCoWO1bH/yzDUNBdpki2GlACWvF9nLYh3F2tVF93w== + dependencies: + "@polkadot/keyring" "^12.3.1" + "@polkadot/types-augment" "10.9.1" + "@polkadot/types-codec" "10.9.1" + "@polkadot/types-create" "10.9.1" + "@polkadot/util" "^12.3.1" + "@polkadot/util-crypto" "^12.3.1" + rxjs "^7.8.1" + tslib "^2.5.3" + +"@polkadot/util-crypto@12.4.2", "@polkadot/util-crypto@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-12.4.2.tgz#e19258dab5f2d4fe49f2d074d36d33a445e50b74" + integrity sha512-JP7OrEKYx35P3wWc2Iu9F6BfYMIkywXik908zQqPxwoQhr8uDLP1Qoyu9Sws+hE97Yz1O4jBVvryS2le0yusog== + dependencies: + "@noble/curves" "1.1.0" + "@noble/hashes" "1.3.1" + "@polkadot/networks" "12.4.2" + "@polkadot/util" "12.4.2" + "@polkadot/wasm-crypto" "^7.2.2" + "@polkadot/wasm-util" "^7.2.2" + "@polkadot/x-bigint" "12.4.2" + "@polkadot/x-randomvalues" "12.4.2" + "@scure/base" "1.1.1" + tslib "^2.6.2" -"@polkadot/util-crypto@^10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-10.4.2.tgz#871fb69c65768bd48c57bb5c1f76a85d979fb8b5" - integrity sha512-RxZvF7C4+EF3fzQv8hZOLrYCBq5+wA+2LWv98nECkroChY3C2ZZvyWDqn8+aonNULt4dCVTWDZM0QIY6y4LUAQ== +"@polkadot/util@12.4.2", "@polkadot/util@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-12.4.2.tgz#65759f4b366c2a787fd21abacab8cf8ab1aebbf9" + integrity sha512-NcTCbnIzMb/3TvJNEbaiu/9EvYIBuzDwZfqQ4hzL0GAptkF8aDkKMDCfQ/j3FI38rR+VTPQHNky9fvWglGKGRw== dependencies: - "@babel/runtime" "^7.20.13" - "@noble/hashes" "1.2.0" - "@noble/secp256k1" "1.7.1" - "@polkadot/networks" "10.4.2" - "@polkadot/util" "10.4.2" - "@polkadot/wasm-crypto" "^6.4.1" - "@polkadot/x-bigint" "10.4.2" - "@polkadot/x-randomvalues" "10.4.2" - "@scure/base" "1.1.1" - ed2curve "^0.3.0" - tweetnacl "^1.0.3" - -"@polkadot/util@10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-10.4.2.tgz#df41805cb27f46b2b4dad24c371fa2a68761baa1" - integrity sha512-0r5MGICYiaCdWnx+7Axlpvzisy/bi1wZGXgCSw5+ZTyPTOqvsYRqM2X879yxvMsGfibxzWqNzaiVjToz1jvUaA== - dependencies: - "@babel/runtime" "^7.20.13" - "@polkadot/x-bigint" "10.4.2" - "@polkadot/x-global" "10.4.2" - "@polkadot/x-textdecoder" "10.4.2" - "@polkadot/x-textencoder" "10.4.2" + "@polkadot/x-bigint" "12.4.2" + "@polkadot/x-global" "12.4.2" + "@polkadot/x-textdecoder" "12.4.2" + "@polkadot/x-textencoder" "12.4.2" "@types/bn.js" "^5.1.1" bn.js "^5.2.1" - -"@polkadot/wasm-bridge@6.4.1": - version "6.4.1" - resolved "https://registry.yarnpkg.com/@polkadot/wasm-bridge/-/wasm-bridge-6.4.1.tgz#e97915dd67ba543ec3381299c2a5b9330686e27e" - integrity sha512-QZDvz6dsUlbYsaMV5biZgZWkYH9BC5AfhT0f0/knv8+LrbAoQdP3Asbvddw8vyU9sbpuCHXrd4bDLBwUCRfrBQ== - dependencies: - "@babel/runtime" "^7.20.6" - -"@polkadot/wasm-crypto-asmjs@6.4.1": - version "6.4.1" - resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-asmjs/-/wasm-crypto-asmjs-6.4.1.tgz#3cc76bbda5ea4a7a860982c64f9565907b312253" - integrity sha512-UxZTwuBZlnODGIQdCsE2Sn/jU0O2xrNQ/TkhRFELfkZXEXTNu4lw6NpaKq7Iey4L+wKd8h4lT3VPVkMcPBLOvA== - dependencies: - "@babel/runtime" "^7.20.6" - -"@polkadot/wasm-crypto-init@6.4.1": - version "6.4.1" - resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-init/-/wasm-crypto-init-6.4.1.tgz#4d9ab0030db52cf177bf707ef8e77aa4ca721668" - integrity sha512-1ALagSi/nfkyFaH6JDYfy/QbicVbSn99K8PV9rctDUfxc7P06R7CoqbjGQ4OMPX6w1WYVPU7B4jPHGLYBlVuMw== - dependencies: - "@babel/runtime" "^7.20.6" - "@polkadot/wasm-bridge" "6.4.1" - "@polkadot/wasm-crypto-asmjs" "6.4.1" - "@polkadot/wasm-crypto-wasm" "6.4.1" - -"@polkadot/wasm-crypto-wasm@6.4.1": - version "6.4.1" - resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-wasm/-/wasm-crypto-wasm-6.4.1.tgz#97180f80583b18f6a13c1054fa5f7e8da40b1028" - integrity sha512-3VV9ZGzh0ZY3SmkkSw+0TRXxIpiO0nB8lFwlRgcwaCihwrvLfRnH9GI8WE12mKsHVjWTEVR3ogzILJxccAUjDA== - dependencies: - "@babel/runtime" "^7.20.6" - "@polkadot/wasm-util" "6.4.1" - -"@polkadot/wasm-crypto@^6.4.1": - version "6.4.1" - resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-6.4.1.tgz#79310e23ad1ca62362ba893db6a8567154c2536a" - integrity sha512-FH+dcDPdhSLJvwL0pMLtn/LIPd62QDPODZRCmDyw+pFjLOMaRBc7raomWUOqyRWJTnqVf/iscc2rLVLNMyt7ag== - dependencies: - "@babel/runtime" "^7.20.6" - "@polkadot/wasm-bridge" "6.4.1" - "@polkadot/wasm-crypto-asmjs" "6.4.1" - "@polkadot/wasm-crypto-init" "6.4.1" - "@polkadot/wasm-crypto-wasm" "6.4.1" - "@polkadot/wasm-util" "6.4.1" - -"@polkadot/wasm-util@6.4.1": - version "6.4.1" - resolved "https://registry.yarnpkg.com/@polkadot/wasm-util/-/wasm-util-6.4.1.tgz#74aecc85bec427a9225d9874685944ea3dc3ab76" - integrity sha512-Uwo+WpEsDmFExWC5kTNvsVhvqXMZEKf4gUHXFn4c6Xz4lmieRT5g+1bO1KJ21pl4msuIgdV3Bksfs/oiqMFqlw== - dependencies: - "@babel/runtime" "^7.20.6" - -"@polkadot/x-bigint@10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/x-bigint/-/x-bigint-10.4.2.tgz#7eb2ec732259df48b5a00f07879a1331e05606ec" - integrity sha512-awRiox+/XSReLzimAU94fPldowiwnnMUkQJe8AebYhNocAj6SJU00GNoj6j6tAho6yleOwrTJXZaWFBaQVJQNg== - dependencies: - "@babel/runtime" "^7.20.13" - "@polkadot/x-global" "10.4.2" - -"@polkadot/x-global@10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/x-global/-/x-global-10.4.2.tgz#5662366e3deda0b4c8f024b2d902fa838f9e60a4" - integrity sha512-g6GXHD/ykZvHap3M6wh19dO70Zm43l4jEhlxf5LtTo5/0/UporFCXr2YJYZqfbn9JbQwl1AU+NroYio+vtJdiA== - dependencies: - "@babel/runtime" "^7.20.13" - -"@polkadot/x-randomvalues@10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/x-randomvalues/-/x-randomvalues-10.4.2.tgz#895f1220d5a4522a83d8d5014e3c1e03b129893e" - integrity sha512-mf1Wbpe7pRZHO0V3V89isPLqZOy5XGX2bCqsfUWHgb1NvV1MMx5TjVjdaYyNlGTiOkAmJKlOHshcfPU2sYWpNg== - dependencies: - "@babel/runtime" "^7.20.13" - "@polkadot/x-global" "10.4.2" - -"@polkadot/x-textdecoder@10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/x-textdecoder/-/x-textdecoder-10.4.2.tgz#93202f3e5ad0e7f75a3fa02d2b8a3343091b341b" - integrity sha512-d3ADduOKUTU+cliz839+KCFmi23pxTlabH7qh7Vs1GZQvXOELWdqFOqakdiAjtMn68n1KVF4O14Y+OUm7gp/zA== - dependencies: - "@babel/runtime" "^7.20.13" - "@polkadot/x-global" "10.4.2" - -"@polkadot/x-textencoder@10.4.2": - version "10.4.2" - resolved "https://registry.yarnpkg.com/@polkadot/x-textencoder/-/x-textencoder-10.4.2.tgz#cd2e6c8a66b0b400a73f0164e99c510fb5c83501" - integrity sha512-mxcQuA1exnyv74Kasl5vxBq01QwckG088lYjc3KwmND6+pPrW2OWagbxFX5VFoDLDAE+UJtnUHsjdWyOTDhpQA== - dependencies: - "@babel/runtime" "^7.20.13" - "@polkadot/x-global" "10.4.2" + tslib "^2.6.2" + +"@polkadot/wasm-bridge@7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-bridge/-/wasm-bridge-7.2.2.tgz#957b82b17927fe080729e8930b5b5c554f77b8df" + integrity sha512-CgNENd65DVYtackOVXXRA0D1RPoCv5+77IdBCf7kNqu6LeAnR4nfTI6qjaApUdN1xRweUsQjSH7tu7VjkMOA0A== + dependencies: + "@polkadot/wasm-util" "7.2.2" + tslib "^2.6.1" + +"@polkadot/wasm-crypto-asmjs@7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-asmjs/-/wasm-crypto-asmjs-7.2.2.tgz#25243a4d5d8d997761141b616623cacff4329f13" + integrity sha512-wKg+cpsWQCTSVhjlHuNeB/184rxKqY3vaklacbLOMbUXieIfuDBav5PJdzS3yeiVE60TpYaHW4iX/5OYHS82gg== + dependencies: + tslib "^2.6.1" + +"@polkadot/wasm-crypto-init@7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-init/-/wasm-crypto-init-7.2.2.tgz#ffd105b87fc1b679c06c85c0848183c27bc539e3" + integrity sha512-vD4iPIp9x+SssUIWUenxWLPw4BVIwhXHNMpsV81egK990tvpyIxL205/EF5QRb1mKn8WfWcNFm5tYwwh9NdnnA== + dependencies: + "@polkadot/wasm-bridge" "7.2.2" + "@polkadot/wasm-crypto-asmjs" "7.2.2" + "@polkadot/wasm-crypto-wasm" "7.2.2" + "@polkadot/wasm-util" "7.2.2" + tslib "^2.6.1" + +"@polkadot/wasm-crypto-wasm@7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-wasm/-/wasm-crypto-wasm-7.2.2.tgz#9e49a1565bda2bc830708693b491b37ad8a2144d" + integrity sha512-3efoIB6jA3Hhv6k0YIBwCtlC8gCSWCk+R296yIXRLLr3cGN415KM/PO/d1JIXYI64lbrRzWRmZRhllw3jf6Atg== + dependencies: + "@polkadot/wasm-util" "7.2.2" + tslib "^2.6.1" + +"@polkadot/wasm-crypto@^7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-7.2.2.tgz#3c4b300c0997f4f7e2ddcdf8101d97fa1f5d1a7f" + integrity sha512-1ZY1rxUTawYm0m1zylvBMFovNIHYgG2v/XoASNp/EMG5c8FQIxCbhJRaTBA983GVq4lN/IAKREKEp9ZbLLqssA== + dependencies: + "@polkadot/wasm-bridge" "7.2.2" + "@polkadot/wasm-crypto-asmjs" "7.2.2" + "@polkadot/wasm-crypto-init" "7.2.2" + "@polkadot/wasm-crypto-wasm" "7.2.2" + "@polkadot/wasm-util" "7.2.2" + tslib "^2.6.1" + +"@polkadot/wasm-util@7.2.2", "@polkadot/wasm-util@^7.2.2": + version "7.2.2" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-util/-/wasm-util-7.2.2.tgz#f8aa62eba9a35466aa23f3c5634f3e8dbd398bbf" + integrity sha512-N/25960ifCc56sBlJZ2h5UBpEPvxBmMLgwYsl7CUuT+ea2LuJW9Xh8VHDN/guYXwmm92/KvuendYkEUykpm/JQ== + dependencies: + tslib "^2.6.1" + +"@polkadot/x-bigint@12.4.2", "@polkadot/x-bigint@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/x-bigint/-/x-bigint-12.4.2.tgz#a63c9c926443231206726103d06c117ac2248de8" + integrity sha512-VRbkhdIf7CyWiUSyHemYi2fFWjBetUGyqpzsIHEclmzvqhKPfs7Kd2ZRdoXKU5QM56eD0sV2pyJxL34dv36/rw== + dependencies: + "@polkadot/x-global" "12.4.2" + tslib "^2.6.2" + +"@polkadot/x-fetch@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/x-fetch/-/x-fetch-12.4.2.tgz#c5b70aacf7491ec9e51b0b14a7dbda44e9f3a11c" + integrity sha512-QEtYIUO6q6LupYkOl+vRwAkbBSSNHbALG8Y3+L/tFDubeXQl79vCkJFmsjhLewpsDIwTFTPNOwzA0ZEyb+0HZw== + dependencies: + "@polkadot/x-global" "12.4.2" + node-fetch "^3.3.2" + tslib "^2.6.2" + +"@polkadot/x-global@12.4.2", "@polkadot/x-global@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/x-global/-/x-global-12.4.2.tgz#cc6ed596698678f98a53547b9adb712eadfd5175" + integrity sha512-CwbjSt1Grmn56xAj+hGC8ZB0uZxMl92K+VkBH0KxjgcbAX/D24ZD/0ds8pAnUYrO4aYHYq2j2MAGVSMdHcMBAQ== + dependencies: + tslib "^2.6.2" + +"@polkadot/x-randomvalues@12.4.2": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/x-randomvalues/-/x-randomvalues-12.4.2.tgz#399a7f831e465e6cd5aea64f8220693b07be86fa" + integrity sha512-HVlXRWY9RfN54RgfDroDy2itWmtTUtr119DfPl3wjnBf9i4wl/M+848OYlmCZCTpViTJrvWVSEJH9zVgchlNnw== + dependencies: + "@polkadot/x-global" "12.4.2" + tslib "^2.6.2" + +"@polkadot/x-textdecoder@12.4.2": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/x-textdecoder/-/x-textdecoder-12.4.2.tgz#fea941decbe32d24aa3f951a511bf576dc104826" + integrity sha512-cyUoKwdSIiBXAaWnGdMYqnaNHc5NV9skQh/fITis3ufKKi3pMwxJ5IwhhfDZpuKDl/3fDXF40Z3fqtTeUnoRXA== + dependencies: + "@polkadot/x-global" "12.4.2" + tslib "^2.6.2" + +"@polkadot/x-textencoder@12.4.2": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/x-textencoder/-/x-textencoder-12.4.2.tgz#a717fe2701ade5648600ff3a34d4d1224d916ee3" + integrity sha512-xrcwx55B2K7j9CnVucGLFl0qd5sb7W5Ei6dOsWgDnZNjZPBqsx9jTBQSBv9HmyHE4GEnF4z0rpO0msy3S7Sj9Q== + dependencies: + "@polkadot/x-global" "12.4.2" + tslib "^2.6.2" + +"@polkadot/x-ws@^12.3.1": + version "12.4.2" + resolved "https://registry.yarnpkg.com/@polkadot/x-ws/-/x-ws-12.4.2.tgz#675e2d7effd6cafebc43783484a6ae55afb58f20" + integrity sha512-dYUtpbPa/JNd94tPAM9iHMzhR8MZ4wtOPh8gvueQRRYC8ZYQ9NPwjbBImY2FRfx7wCG1tFLAR6OEw4ToLLJNsA== + dependencies: + "@polkadot/x-global" "12.4.2" + tslib "^2.6.2" + ws "^8.13.0" "@scure/base@1.1.1": version "1.1.1" @@ -359,10 +565,24 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== -"@substrate/ss58-registry@^1.38.0": - version "1.39.0" - resolved "https://registry.yarnpkg.com/@substrate/ss58-registry/-/ss58-registry-1.39.0.tgz#eb916ff5fea7fa02e77745823fde21af979273d2" - integrity sha512-qZYpuE6n+mwew+X71dOur/CbMXj6rNW27o63JeJwdQH/GvcSKm3JLNhd+bGzwUKg0D/zD30Qc6p4JykArzM+tA== +"@substrate/connect-extension-protocol@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@substrate/connect-extension-protocol/-/connect-extension-protocol-1.0.1.tgz#fa5738039586c648013caa6a0c95c43265dbe77d" + integrity sha512-161JhCC1csjH3GE5mPLEd7HbWtwNSPJBg3p1Ksz9SFlTzj/bgEwudiRN2y5i0MoLGCIJRYKyKGMxVnd29PzNjg== + +"@substrate/connect@0.7.26": + version "0.7.26" + resolved "https://registry.yarnpkg.com/@substrate/connect/-/connect-0.7.26.tgz#a0ee5180c9cb2f29250d1219a32f7b7e7dea1196" + integrity sha512-uuGSiroGuKWj1+38n1kY5HReer5iL9bRwPCzuoLtqAOmI1fGI0hsSI2LlNQMAbfRgr7VRHXOk5MTuQf5ulsFRw== + dependencies: + "@substrate/connect-extension-protocol" "^1.0.1" + eventemitter3 "^4.0.7" + smoldot "1.0.4" + +"@substrate/ss58-registry@^1.43.0": + version "1.43.0" + resolved "https://registry.yarnpkg.com/@substrate/ss58-registry/-/ss58-registry-1.43.0.tgz#93108e45cb7ef6d82560c153e3692c2aa1c711b3" + integrity sha512-USEkXA46P9sqClL7PZv0QFsit4S8Im97wchKG0/H/9q3AT/S76r40UHfCr4Un7eBJPE23f7fU9BZ0ITpP9MCsA== "@szmarczak/http-timer@^4.0.5": version "4.0.6" @@ -419,6 +639,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== +"@types/node@18.15.13": + version "18.15.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469" + integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q== + "@types/node@^12.12.6": version "12.20.55" resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240" @@ -458,6 +683,11 @@ accepts@~1.3.8: mime-types "~2.1.34" negotiator "0.6.3" +aes-js@4.0.0-beta.5: + version "4.0.0-beta.5" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-4.0.0-beta.5.tgz#8d2452c52adedebc3a3e28465d858c11ca315873" + integrity sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q== + ajv@^6.12.3: version "6.12.6" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" @@ -828,6 +1058,11 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" +data-uri-to-buffer@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" + integrity sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A== + debug@2.6.9, debug@^2.2.0: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" @@ -835,6 +1070,13 @@ debug@2.6.9, debug@^2.2.0: dependencies: ms "2.0.0" +debug@^4.1.0: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + decode-uri-component@^0.2.0: version "0.2.2" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.2.tgz#e69dbe25d37941171dd540e024c444cd5188e1e9" @@ -887,13 +1129,6 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -ed2curve@^0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/ed2curve/-/ed2curve-0.3.0.tgz#322b575152a45305429d546b071823a93129a05d" - integrity sha512-8w2fmmq3hv9rCrcI7g9hms2pMunQr1JINfcjwR9tAyZqhtyaMN991lF/ZfHfr5tzZQ8c7y7aBgZbjfbd0fjFwQ== - dependencies: - tweetnacl "1.x.x" - ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" @@ -1033,6 +1268,19 @@ ethereumjs-util@^7.1.0, ethereumjs-util@^7.1.1, ethereumjs-util@^7.1.2, ethereum ethereum-cryptography "^0.1.3" rlp "^2.2.4" +ethers@6: + version "6.7.1" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.7.1.tgz#9c65e8b5d8e9ad77b7e8cf1c46099892cfafad49" + integrity sha512-qX5kxIFMfg1i+epfgb0xF4WM7IqapIIu50pOJ17aebkxxa4BacW5jFrQRmCJpDEg2ZK2oNtR5QjrQ1WDBF29dA== + dependencies: + "@adraffy/ens-normalize" "1.9.2" + "@noble/hashes" "1.1.2" + "@noble/secp256k1" "1.7.1" + "@types/node" "18.15.13" + aes-js "4.0.0-beta.5" + tslib "2.4.0" + ws "8.5.0" + ethjs-unit@0.1.6: version "0.1.6" resolved "https://registry.yarnpkg.com/ethjs-unit/-/ethjs-unit-0.1.6.tgz#c665921e476e87bce2a9d588a6fe0405b2c41699" @@ -1046,6 +1294,16 @@ eventemitter3@4.0.4: resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.4.tgz#b5463ace635a083d018bdc7c917b4c5f10a85384" integrity sha512-rlaVLnVxtxvoyLsQQFBx53YmXHDxRIzzTLbdfxqi4yocpSjAxXwkU0cScM5JgSKMqEhrZpnvQ2D9gjylR0AimQ== +eventemitter3@^4.0.7: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +eventemitter3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4" + integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA== + evp_bytestokey@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" @@ -1123,6 +1381,14 @@ fast-json-stable-stringify@^2.0.0: resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== +fetch-blob@^3.1.2, fetch-blob@^3.1.4: + version "3.2.0" + resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" + integrity sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ== + dependencies: + node-domexception "^1.0.0" + web-streams-polyfill "^3.0.3" + finalhandler@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" @@ -1167,6 +1433,13 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +formdata-polyfill@^4.0.10: + version "4.0.10" + resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" + integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== + dependencies: + fetch-blob "^3.1.2" + forwarded@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" @@ -1496,7 +1769,7 @@ json-schema@0.4.0: resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== -json-stringify-safe@~5.0.1: +json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== @@ -1534,6 +1807,11 @@ keyv@^4.0.0: dependencies: json-buffer "3.0.1" +lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + lowercase-keys@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" @@ -1661,11 +1939,21 @@ mock-fs@^4.1.0: resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.14.0.tgz#ce5124d2c601421255985e6e94da80a7357b1b18" integrity sha512-qYvlv/exQ4+svI3UOvPUpLDF0OMX5euvUH0Ny4N5QyRyhNdgAgUrVH3iUINSzEPLvx0kbo/Bp28GJKIqvE7URw== +mock-socket@^9.2.1: + version "9.2.1" + resolved "https://registry.yarnpkg.com/mock-socket/-/mock-socket-9.2.1.tgz#cc9c0810aa4d0afe02d721dcb2b7e657c00e2282" + integrity sha512-aw9F9T9G2zpGipLLhSNh6ZpgUyUl4frcVmRN08uE1NWPWg43Wx6+sGPDbQ7E5iFZZDJW5b5bypMeAEHqTbIFag== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + ms@2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" @@ -1726,11 +2014,26 @@ next-tick@^1.1.0: resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.1.0.tgz#1836ee30ad56d67ef281b22bd199f709449b35eb" integrity sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ== +nock@^13.3.1: + version "13.3.3" + resolved "https://registry.yarnpkg.com/nock/-/nock-13.3.3.tgz#179759c07d3f88ad3e794ace885629c1adfd3fe7" + integrity sha512-z+KUlILy9SK/RjpeXDiDUEAq4T94ADPHE3qaRkf66mpEhzc/ytOMm3Bwdrbq6k1tMWkbdujiKim3G2tfQARuJw== + dependencies: + debug "^4.1.0" + json-stringify-safe "^5.0.1" + lodash "^4.17.21" + propagate "^2.0.0" + node-addon-api@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.2.tgz#432cfa82962ce494b132e9d72a15b29f71ff5d32" integrity sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA== +node-domexception@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" + integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== + node-fetch@2.6.7: version "2.6.7" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad" @@ -1738,6 +2041,15 @@ node-fetch@2.6.7: dependencies: whatwg-url "^5.0.0" +node-fetch@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.3.2.tgz#d1e889bacdf733b4ff3b2b243eb7a12866a0b78b" + integrity sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA== + dependencies: + data-uri-to-buffer "^4.0.0" + fetch-blob "^3.1.4" + formdata-polyfill "^4.0.10" + node-gyp-build@^4.2.0: version "4.6.0" resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055" @@ -1812,6 +2124,11 @@ p-cancelable@^3.0.0: resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-3.0.0.tgz#63826694b54d61ca1c20ebcb6d3ecf5e14cd8050" integrity sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw== +pako@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" + integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== + parse-headers@^2.0.0: version "2.0.5" resolved "https://registry.yarnpkg.com/parse-headers/-/parse-headers-2.0.5.tgz#069793f9356a54008571eb7f9761153e6c770da9" @@ -1848,6 +2165,11 @@ process@^0.11.10: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== +propagate@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45" + integrity sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag== + proxy-addr@~2.0.7: version "2.0.7" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" @@ -1936,11 +2258,6 @@ readable-stream@^3.6.0: string_decoder "^1.1.1" util-deprecate "^1.0.1" -regenerator-runtime@^0.13.11: - version "0.13.11" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" - integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== - request@^2.79.0: version "2.88.2" resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" @@ -1994,6 +2311,13 @@ rlp@^2.2.4: dependencies: bn.js "^5.2.0" +rxjs@^7.8.1: + version "7.8.1" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543" + integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg== + dependencies: + tslib "^2.1.0" + safe-buffer@5.2.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@^5.2.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" @@ -2109,6 +2433,14 @@ simple-get@^2.7.0: once "^1.3.1" simple-concat "^1.0.0" +smoldot@1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/smoldot/-/smoldot-1.0.4.tgz#e4c38cedad68d699a11b5b9ce72bb75c891bfd98" + integrity sha512-N3TazI1C4GGrseFH/piWyZCCCRJTRx2QhDfrUKRT4SzILlW5m8ayZ3QTKICcz1C/536T9cbHHJyP7afxI6Mi1A== + dependencies: + pako "^2.0.4" + ws "^8.8.1" + solc@^0.8.18: version "0.8.19" resolved "https://registry.yarnpkg.com/solc/-/solc-0.8.19.tgz#cac6541106ae3cff101c740042c7742aa56a2ed3" @@ -2221,6 +2553,16 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= +tslib@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" + integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== + +tslib@^2.1.0, tslib@^2.5.3, tslib@^2.6.1, tslib@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -2228,11 +2570,6 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" -tweetnacl@1.x.x, tweetnacl@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596" - integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw== - tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" @@ -2352,6 +2689,11 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" +web-streams-polyfill@^3.0.3: + version "3.2.1" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz#71c2718c52b45fd49dbeee88634b3a60ceab42a6" + integrity sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q== + web3-bzz@1.8.2: version "1.8.2" resolved "https://registry.yarnpkg.com/web3-bzz/-/web3-bzz-1.8.2.tgz#67ea1c775874056250eece551ded22905ed08784" @@ -2623,6 +2965,11 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +ws@8.5.0: + version "8.5.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.5.0.tgz#bfb4be96600757fe5382de12c670dab984a1ed4f" + integrity sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg== + ws@^3.0.0: version "3.3.3" resolved "https://registry.yarnpkg.com/ws/-/ws-3.3.3.tgz#f1cf84fe2d5e901ebce94efaece785f187a228f2" @@ -2632,6 +2979,11 @@ ws@^3.0.0: safe-buffer "~5.1.0" ultron "~1.1.0" +ws@^8.13.0, ws@^8.8.1: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.13.0.tgz#9a9fb92f93cf41512a0735c8f4dd09b8a1211cd0" + integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA== + xhr-request-promise@^0.1.2: version "0.1.3" resolved "https://registry.yarnpkg.com/xhr-request-promise/-/xhr-request-promise-0.1.3.tgz#2d5f4b16d8c6c893be97f1a62b0ed4cf3ca5f96c" diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index 0dee086613..e442ec2293 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -75,6 +75,7 @@ pallet-evm-precompile-dapps-staking = { workspace = true } pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } pallet-evm-precompile-xvm = { workspace = true } +pallet-unified-accounts = { workspace = true } pallet-xvm = { workspace = true } # Moonbeam tracing @@ -159,6 +160,7 @@ std = [ "pallet-scheduler/std", "pallet-treasury/std", "pallet-xvm/std", + "pallet-unified-accounts/std", "pallet-ethereum-checked/std", "moonbeam-evm-tracer/std", "moonbeam-rpc-primitives-debug/std", @@ -181,6 +183,7 @@ runtime-benchmarks = [ "pallet-collective/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", "pallet-ethereum-checked/runtime-benchmarks", + "pallet-unified-accounts/runtime-benchmarks", "astar-primitives/runtime-benchmarks", "pallet-assets/runtime-benchmarks", ] @@ -204,6 +207,7 @@ try-runtime = [ "pallet-utility/try-runtime", "pallet-vesting/try-runtime", "pallet-xvm/try-runtime", + "pallet-unified-accounts/try-runtime", "pallet-ethereum/try-runtime", "pallet-assets/try-runtime", "pallet-scheduler/try-runtime", diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 4c74ed639c..f183bc7c5a 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -59,8 +59,8 @@ use sp_runtime::{ use sp_std::prelude::*; pub use astar_primitives::{ - evm::EvmRevertCodeHandler, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, - Index, Signature, + ethereum_checked::HashedAccountMapping, evm::EvmRevertCodeHandler, AccountId, Address, AssetId, + Balance, BlockNumber, Hash, Header, Index, Signature, }; #[cfg(feature = "std")] @@ -199,7 +199,7 @@ impl frame_system::Config for Runtime { /// The aggregated dispatch type that is available for extrinsics. type RuntimeCall = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; + type Lookup = (AccountIdLookup, UnifiedAccounts); /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. @@ -227,7 +227,7 @@ impl frame_system::Config for Runtime { /// What to do if a new account is created. type OnNewAccount = (); /// What to do if an account is fully reaped from the system. - type OnKilledAccount = (); + type OnKilledAccount = pallet_unified_accounts::KillAccountMapping; /// The data to be stored in an account. type AccountData = pallet_balances::AccountData; /// Weight information for the extrinsics of this pallet. @@ -290,7 +290,7 @@ impl pallet_balances::Config for Runtime { type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; + type WeightInfo = weights::pallet_balances::SubstrateWeight; type HoldIdentifier = (); type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; @@ -444,13 +444,13 @@ impl pallet_utility::Config for Runtime { type WeightInfo = pallet_utility::weights::SubstrateWeight; } -///TODO: Placeholder account mapping. This would be replaced once account abstraction is finished. -pub struct HashedAccountMapping; -impl astar_primitives::ethereum_checked::AccountMapping for HashedAccountMapping { - fn into_h160(account_id: AccountId) -> H160 { - let data = (b"evm:", account_id); - return H160::from_slice(&data.using_encoded(sp_io::hashing::blake2_256)[0..20]); - } +impl pallet_unified_accounts::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type DefaultEvmToNative = pallet_evm::HashedAddressMapping; + type DefaultNativeToEvm = HashedAccountMapping; + type ChainId = ChainId; + type WeightInfo = pallet_unified_accounts::weights::SubstrateWeight; } parameter_types! { @@ -464,14 +464,14 @@ impl pallet_ethereum_checked::Config for Runtime { type XvmTxWeightLimit = XvmTxWeightLimit; type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; - type AccountMapping = HashedAccountMapping; + type AccountMapping = UnifiedAccounts; type XcmTransactOrigin = pallet_ethereum_checked::EnsureXcmEthereumTx; type WeightInfo = pallet_ethereum_checked::weights::SubstrateWeight; } impl pallet_xvm::Config for Runtime { type GasWeightMapping = pallet_evm::FixedGasWeightMapping; - type AccountMapping = HashedAccountMapping; + type AccountMapping = UnifiedAccounts; type EthereumTransact = EthereumChecked; type WeightInfo = pallet_xvm::weights::SubstrateWeight; } @@ -557,7 +557,7 @@ impl pallet_evm::Config for Runtime { type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = pallet_evm::EnsureAddressRoot; type WithdrawOrigin = pallet_evm::EnsureAddressTruncated; - type AddressMapping = pallet_evm::HashedAddressMapping; + type AddressMapping = UnifiedAccounts; type Currency = Balances; type RuntimeEvent = RuntimeEvent; type Runner = pallet_evm::runner::stack::Runner; @@ -1001,6 +1001,7 @@ construct_runtime!( Proxy: pallet_proxy, Preimage: pallet_preimage, EthereumChecked: pallet_ethereum_checked, + UnifiedAccounts: pallet_unified_accounts, } ); diff --git a/runtime/local/src/weights/mod.rs b/runtime/local/src/weights/mod.rs index 2db3ac12ab..cfb33e5fac 100644 --- a/runtime/local/src/weights/mod.rs +++ b/runtime/local/src/weights/mod.rs @@ -17,3 +17,4 @@ // along with Astar. If not, see . pub mod pallet_assets; +pub mod pallet_balances; diff --git a/runtime/local/src/weights/pallet_balances.rs b/runtime/local/src/weights/pallet_balances.rs new file mode 100644 index 0000000000..72416e77b7 --- /dev/null +++ b/runtime/local/src/weights/pallet_balances.rs @@ -0,0 +1,153 @@ + +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +//! Autogenerated weights for pallet_balances +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-09-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=shibuya-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_balances +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/balances_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weights for pallet_balances using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl pallet_balances::WeightInfo for SubstrateWeight { + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn transfer_allow_death() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `3593` + // Minimum execution time: 54_598_000 picoseconds. + Weight::from_parts(55_039_000, 3593) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer_keep_alive() -> Weight { + // Proof Size summary in bytes: + // Measured: `52` + // Estimated: `3593` + // Minimum execution time: 39_626_000 picoseconds. + Weight::from_parts(40_238_000, 3593) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_set_balance_creating() -> Weight { + // Proof Size summary in bytes: + // Measured: `140` + // Estimated: `3593` + // Minimum execution time: 16_675_000 picoseconds. + Weight::from_parts(16_939_000, 3593) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn force_set_balance_killing() -> Weight { + // Proof Size summary in bytes: + // Measured: `182` + // Estimated: `3593` + // Minimum execution time: 26_023_000 picoseconds. + Weight::from_parts(26_587_000, 3593) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn force_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `197` + // Estimated: `6196` + // Minimum execution time: 57_231_000 picoseconds. + Weight::from_parts(58_030_000, 6196) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn transfer_all() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `3593` + // Minimum execution time: 51_686_000 picoseconds. + Weight::from_parts(52_193_000, 3593) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_unreserve() -> Weight { + // Proof Size summary in bytes: + // Measured: `140` + // Estimated: `3593` + // Minimum execution time: 19_416_000 picoseconds. + Weight::from_parts(19_850_000, 3593) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 19_161_000 picoseconds. + Weight::from_parts(19_253_000, 990) + // Standard Error: 8_562 + .saturating_add(Weight::from_parts(13_649_240, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } +} diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 3d356dd75a..cd9aa9c236 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -109,6 +109,7 @@ pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } pallet-evm-precompile-xcm = { workspace = true } pallet-evm-precompile-xvm = { workspace = true } +pallet-unified-accounts = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } pallet-xvm = { workspace = true } @@ -204,6 +205,7 @@ std = [ "pallet-xcm/std", "pallet-xc-asset-config/std", "pallet-xvm/std", + "pallet-unified-accounts/std", "pallet-ethereum-checked/std", "pallet-scheduler/std", "parachain-info/std", @@ -251,6 +253,7 @@ runtime-benchmarks = [ "pallet-preimage/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "pallet-ethereum-checked/runtime-benchmarks", + "pallet-unified-accounts/runtime-benchmarks", "pallet-xvm/runtime-benchmarks", "polkadot-runtime/runtime-benchmarks", "orml-xtokens/runtime-benchmarks", @@ -300,6 +303,7 @@ try-runtime = [ "pallet-preimage/try-runtime", "pallet-base-fee/try-runtime", "pallet-evm/try-runtime", + "pallet-unified-accounts/try-runtime", "pallet-ethereum-checked/try-runtime", "orml-xtokens/try-runtime", ] diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 540978beab..cbe0283f8f 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -67,9 +67,10 @@ use sp_runtime::{ use sp_std::prelude::*; pub use astar_primitives::{ - ethereum_checked::CheckedEthereumTransact, evm::EvmRevertCodeHandler, - xcm::AssetLocationIdConverter, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, - Index, Signature, + ethereum_checked::{CheckedEthereumTransact, HashedAccountMapping}, + evm::EvmRevertCodeHandler, + xcm::AssetLocationIdConverter, + AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, }; use pallet_evm_precompile_assets_erc20::AddressToAssetId; @@ -254,7 +255,7 @@ impl frame_system::Config for Runtime { /// The aggregated dispatch type that is available for extrinsics. type RuntimeCall = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; + type Lookup = (AccountIdLookup, UnifiedAccounts); /// The index type for storing how many extrinsics an account has signed. type Index = Index; /// The index type for blocks. @@ -277,7 +278,7 @@ impl frame_system::Config for Runtime { type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; type OnNewAccount = (); - type OnKilledAccount = (); + type OnKilledAccount = pallet_unified_accounts::KillAccountMapping; type DbWeight = RocksDbWeight; type BaseCallFilter = BaseFilter; type SystemWeightInfo = frame_system::weights::SubstrateWeight; @@ -578,7 +579,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; - type WeightInfo = pallet_balances::weights::SubstrateWeight; + type WeightInfo = weights::pallet_balances::SubstrateWeight; type HoldIdentifier = (); type FreezeIdentifier = (); type MaxHolds = ConstU32<0>; @@ -745,15 +746,6 @@ impl pallet_transaction_payment::Config for Runtime { type LengthToFee = ConstantMultiplier; } -///TODO: Placeholder account mapping. This would be replaced once account abstraction is finished. -pub struct HashedAccountMapping; -impl astar_primitives::ethereum_checked::AccountMapping for HashedAccountMapping { - fn into_h160(account_id: AccountId) -> H160 { - let data = (b"evm:", account_id); - return H160::from_slice(&data.using_encoded(sp_io::hashing::blake2_256)[0..20]); - } -} - parameter_types! { /// Equal to normal class dispatch weight limit. pub XvmTxWeightLimit: Weight = NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT; @@ -764,14 +756,14 @@ impl pallet_ethereum_checked::Config for Runtime { type XvmTxWeightLimit = XvmTxWeightLimit; type InvalidEvmTransactionError = pallet_ethereum::InvalidTransactionWrapper; type ValidatedTransaction = pallet_ethereum::ValidatedTransaction; - type AccountMapping = HashedAccountMapping; + type AccountMapping = UnifiedAccounts; type XcmTransactOrigin = pallet_ethereum_checked::EnsureXcmEthereumTx; type WeightInfo = pallet_ethereum_checked::weights::SubstrateWeight; } impl pallet_xvm::Config for Runtime { type GasWeightMapping = pallet_evm::FixedGasWeightMapping; - type AccountMapping = HashedAccountMapping; + type AccountMapping = UnifiedAccounts; type EthereumTransact = EthereumChecked; type WeightInfo = pallet_xvm::weights::SubstrateWeight; } @@ -851,7 +843,7 @@ impl pallet_evm::Config for Runtime { type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping; type CallOrigin = pallet_evm::EnsureAddressRoot; type WithdrawOrigin = pallet_evm::EnsureAddressTruncated; - type AddressMapping = pallet_evm::HashedAddressMapping; + type AddressMapping = UnifiedAccounts; type Currency = Balances; type RuntimeEvent = RuntimeEvent; type Runner = pallet_evm::runner::stack::Runner; @@ -1211,6 +1203,15 @@ impl pallet_xc_asset_config::Config for Runtime { type WeightInfo = pallet_xc_asset_config::weights::SubstrateWeight; } +impl pallet_unified_accounts::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type DefaultEvmToNative = pallet_evm::HashedAddressMapping; + type DefaultNativeToEvm = HashedAccountMapping; + type ChainId = EVMChainId; + type WeightInfo = pallet_unified_accounts::weights::SubstrateWeight; +} + construct_runtime!( pub struct Runtime where Block = Block, @@ -1254,6 +1255,7 @@ construct_runtime!( BaseFee: pallet_base_fee = 62, EVMChainId: pallet_evm_chain_id = 63, EthereumChecked: pallet_ethereum_checked = 64, + UnifiedAccounts: pallet_unified_accounts = 65, Contracts: pallet_contracts = 70, @@ -1398,6 +1400,7 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_ethereum_checked, EthereumChecked] [pallet_xvm, Xvm] + [pallet_unified_accounts, UnifiedAccounts] ); } diff --git a/runtime/shibuya/src/weights/mod.rs b/runtime/shibuya/src/weights/mod.rs index 2db3ac12ab..cfb33e5fac 100644 --- a/runtime/shibuya/src/weights/mod.rs +++ b/runtime/shibuya/src/weights/mod.rs @@ -17,3 +17,4 @@ // along with Astar. If not, see . pub mod pallet_assets; +pub mod pallet_balances; diff --git a/runtime/shibuya/src/weights/pallet_balances.rs b/runtime/shibuya/src/weights/pallet_balances.rs new file mode 100644 index 0000000000..72416e77b7 --- /dev/null +++ b/runtime/shibuya/src/weights/pallet_balances.rs @@ -0,0 +1,153 @@ + +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +//! Autogenerated weights for pallet_balances +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-09-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `devserver-01`, CPU: `Intel(R) Xeon(R) E-2236 CPU @ 3.40GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("shibuya-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/astar-collator +// benchmark +// pallet +// --chain=shibuya-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_balances +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./benchmark-results/balances_weights.rs +// --template=./scripts/templates/weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weights for pallet_balances using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl pallet_balances::WeightInfo for SubstrateWeight { + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn transfer_allow_death() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `3593` + // Minimum execution time: 54_598_000 picoseconds. + Weight::from_parts(55_039_000, 3593) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn transfer_keep_alive() -> Weight { + // Proof Size summary in bytes: + // Measured: `52` + // Estimated: `3593` + // Minimum execution time: 39_626_000 picoseconds. + Weight::from_parts(40_238_000, 3593) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_set_balance_creating() -> Weight { + // Proof Size summary in bytes: + // Measured: `140` + // Estimated: `3593` + // Minimum execution time: 16_675_000 picoseconds. + Weight::from_parts(16_939_000, 3593) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn force_set_balance_killing() -> Weight { + // Proof Size summary in bytes: + // Measured: `182` + // Estimated: `3593` + // Minimum execution time: 26_023_000 picoseconds. + Weight::from_parts(26_587_000, 3593) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn force_transfer() -> Weight { + // Proof Size summary in bytes: + // Measured: `197` + // Estimated: `6196` + // Minimum execution time: 57_231_000 picoseconds. + Weight::from_parts(58_030_000, 6196) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: UnifiedAccounts EvmToNative (r:1 w:0) + /// Proof: UnifiedAccounts EvmToNative (max_values: None, max_size: Some(68), added: 2543, mode: MaxEncodedLen) + fn transfer_all() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `3593` + // Minimum execution time: 51_686_000 picoseconds. + Weight::from_parts(52_193_000, 3593) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn force_unreserve() -> Weight { + // Proof Size summary in bytes: + // Measured: `140` + // Estimated: `3593` + // Minimum execution time: 19_416_000 picoseconds. + Weight::from_parts(19_850_000, 3593) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: System Account (r:999 w:999) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// The range of component `u` is `[1, 1000]`. + fn upgrade_accounts(u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + u * (136 ±0)` + // Estimated: `990 + u * (2603 ±0)` + // Minimum execution time: 19_161_000 picoseconds. + Weight::from_parts(19_253_000, 990) + // Standard Error: 8_562 + .saturating_add(Weight::from_parts(13_649_240, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into())) + } +} diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index bacba8f98c..091dff78b8 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -10,6 +10,7 @@ repository.workspace = true [dependencies] env_logger = { workspace = true } hex = { workspace = true } +libsecp256k1 = { workspace = true, features = ["hmac", "static-context"] } parity-scale-codec = { workspace = true } sha3 = { workspace = true } @@ -34,6 +35,7 @@ sp-runtime = { workspace = true } # astar dependencies pallet-ethereum-checked = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } +pallet-unified-accounts = { workspace = true } precompile-utils = { workspace = true } astar-primitives = { workspace = true } diff --git a/tests/integration/src/account.rs b/tests/integration/src/account.rs new file mode 100644 index 0000000000..5c1e55a1cb --- /dev/null +++ b/tests/integration/src/account.rs @@ -0,0 +1,41 @@ +// This file is part of Astar. + +// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd. +// SPDX-License-Identifier: GPL-3.0-or-later + +// Astar is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Astar is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Astar. If not, see . + +use crate::setup::*; +pub use sp_io::hashing::keccak_256; + +#[test] +fn transfer_to_h160_via_lookup() { + new_test_ext().execute_with(|| { + let eth_address = H160::from_slice(&keccak_256(b"Alice")[0..20]); + + // make sure account is empty + assert!(EVM::is_account_empty(ð_address)); + + // tranfer to evm account + assert_ok!(Balances::transfer( + RuntimeOrigin::signed(ALICE), + MultiAddress::Address20(eth_address.clone().into()), + UNIT, + )); + + // evm account should have recieved the funds + let (account, _) = EVM::account_basic(ð_address); + assert_eq!(account.balance, (UNIT - ExistentialDeposit::get()).into()); + }); +} diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index c36fc93edc..9b599b80f6 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -31,3 +31,6 @@ mod assets; #[cfg(feature = "shibuya")] mod xvm; + +#[cfg(feature = "shibuya")] +mod account; diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index e19400f15c..aa46e80b12 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -25,9 +25,10 @@ pub use frame_support::{ }; pub use pallet_evm::AddressMapping; pub use sp_core::{H160, H256, U256}; +pub use sp_io::hashing::keccak_256; pub use sp_runtime::{AccountId32, MultiAddress}; -pub use astar_primitives::ethereum_checked::AccountMapping; +pub use astar_primitives::{ethereum_checked::AccountMapping, evm::UnifiedAddressMapper}; #[cfg(feature = "shibuya")] pub use shibuya::*; @@ -39,17 +40,13 @@ mod shibuya { /// 1 SBY. pub const UNIT: Balance = SBY; - // TODO: once Account Unification is finished, remove `alith` and `alicia`, - // which are mocks of two way account/address mapping. - - /// H160 address mapped from `ALICE`. - pub fn alith() -> H160 { - h160_from(ALICE) + pub fn alith_secret_key() -> libsecp256k1::SecretKey { + libsecp256k1::SecretKey::parse(&keccak_256(b"Alith")).unwrap() } - /// `AccountId32` mapped from `alith()`. - pub fn alicia() -> AccountId32 { - account_id_from(alith()) + /// H160 address mapped to `ALICE`. + pub fn alith() -> H160 { + UnifiedAccounts::eth_address(&alith_secret_key()) } /// Convert `H160` to `AccountId32`. @@ -57,11 +54,6 @@ mod shibuya { ::AddressMapping::into_account_id(address) } - /// Convert `AccountId32` to `H160`. - pub fn h160_from(account_id: AccountId32) -> H160 { - ::AccountMapping::into_h160(account_id) - } - /// Deploy an EVM contract with code. pub fn deploy_evm_contract(code: &str) -> H160 { assert_ok!(EVM::create2( @@ -112,6 +104,29 @@ mod shibuya { assert_eq!(Balances::free_balance(&address), ExistentialDeposit::get(),); address } + + /// Build the signature payload for given native account and eth private key + fn get_evm_signature(who: &AccountId32, secret: &libsecp256k1::SecretKey) -> [u8; 65] { + // sign the payload + UnifiedAccounts::eth_sign_prehash(&UnifiedAccounts::build_signing_payload(who), secret) + } + + /// Create the mappings for the accounts + pub fn connect_accounts(who: &AccountId32, secret: &libsecp256k1::SecretKey) { + assert_ok!(UnifiedAccounts::claim_evm_address( + RuntimeOrigin::signed(who.clone()), + UnifiedAccounts::eth_address(secret), + get_evm_signature(who, secret) + )); + } + + pub fn claim_default_accounts(account: AccountId) { + let default_h160 = UnifiedAccounts::to_default_h160(&account); + assert_ok!(UnifiedAccounts::claim_default_evm_address( + RuntimeOrigin::signed(account.clone()) + )); + assert_eq!(UnifiedAccounts::to_h160(&account).unwrap(), default_h160); + } } #[cfg(feature = "shiden")] @@ -185,8 +200,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities { (ALICE, INITIAL_AMOUNT), (BOB, INITIAL_AMOUNT), (CAT, INITIAL_AMOUNT), - #[cfg(feature = "shibuya")] - (alicia(), INITIAL_AMOUNT), ]) .build() } diff --git a/tests/integration/src/xvm.rs b/tests/integration/src/xvm.rs index 08291ce51d..0ec64a74f7 100644 --- a/tests/integration/src/xvm.rs +++ b/tests/integration/src/xvm.rs @@ -176,6 +176,9 @@ const CALL_EVM_PAYBLE_NAME: &'static str = "call_xvm_payable"; #[test] fn evm_payable_call_via_xvm_works() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let evm_payable_addr = deploy_evm_contract(EVM_PAYABLE); let value = UNIT; @@ -247,6 +250,9 @@ fn wasm_payable_call_via_xvm_works() { #[test] fn calling_wasm_payable_from_evm_fails_if_caller_contract_balance_below_ed() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let _ = deploy_wasm_contract(WASM_PAYABLE_NAME); let evm_caller_addr = deploy_evm_contract(CALL_WASM_PAYBLE); @@ -284,6 +290,9 @@ fn calling_wasm_payable_from_evm_fails_if_caller_contract_balance_below_ed() { #[test] fn calling_wasm_payable_from_evm_works() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let wasm_payable_callee_addr = deploy_wasm_contract(WASM_PAYABLE_NAME); let evm_caller_addr = deploy_evm_contract(CALL_WASM_PAYBLE); @@ -314,16 +323,16 @@ fn calling_wasm_payable_from_evm_works() { #[test] fn calling_evm_payable_from_wasm_works() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let evm_payable_callee_addr = deploy_evm_contract(EVM_PAYABLE); let wasm_caller_addr = deploy_wasm_contract(CALL_EVM_PAYBLE_NAME); let value = UNIT; - // TODO: after Account Unification finished, remove this mock account. - // It is needed now because currently the `AccountMapping` and `AddressMapping` are - // both one way mapping. - let mock_unified_wasm_account = account_id_from(h160_from(wasm_caller_addr.clone())); - let _ = Balances::deposit_creating(&mock_unified_wasm_account, value); + // claim the default mappings for wasm contract + claim_default_accounts(wasm_caller_addr.clone()); let evm_payable = evm_payable_callee_addr.as_ref().to_vec(); let deposit_func = hex::decode("d0e30db0").expect("invalid deposit function hex"); @@ -348,16 +357,19 @@ fn calling_evm_payable_from_wasm_works() { value ); - // TODO: after Account Unification finished, enable the wasm address balance check - // and remove the mock account balance check. - // assert_eq!(Balances::free_balance(&wasm_address), ExistentialDeposit::get()); - assert_eq!(Balances::free_balance(&mock_unified_wasm_account), 0); + assert_eq!( + Balances::free_balance(&wasm_caller_addr), + ExistentialDeposit::get() + ); }); } #[test] fn reentrance_not_allowed() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + // Call path: WASM -> EVM -> WASM let wasm_caller_addr = deploy_wasm_contract(CALL_EVM_PAYBLE_NAME); let evm_caller_addr = deploy_evm_contract(CALL_WASM_PAYBLE); @@ -422,6 +434,9 @@ const EVM_DUMMY_ERROR: &'static str = "608060405234801561001057600080fd5b5061023 #[test] fn evm_call_via_xvm_fails_if_revert() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let evm_callee_addr = deploy_evm_contract(EVM_DUMMY_ERROR); let result = Xvm::call( @@ -513,6 +528,9 @@ const WASM_DUMMY_ERROR_NAME: &'static str = "dummy_error"; #[test] fn wasm_call_via_xvm_fails_if_revert() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let wasm_callee_addr = deploy_wasm_contract(WASM_DUMMY_ERROR_NAME); let input = hex::decode("0000002a").expect("invalid selector hex"); let result = Xvm::call( @@ -543,6 +561,9 @@ fn wasm_call_via_xvm_fails_if_revert() { #[test] fn evm_caller_reverts_if_wasm_callee_reverted() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let _ = deploy_wasm_contract(WASM_DUMMY_ERROR_NAME); let evm_caller_addr = deploy_evm_contract(CALL_WASM_PAYBLE); @@ -576,6 +597,9 @@ fn evm_caller_reverts_if_wasm_callee_reverted() { #[test] fn wasm_caller_reverts_if_evm_callee_reverted() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let evm_callee_addr = deploy_evm_contract(EVM_DUMMY_ERROR); let wasm_caller_addr = deploy_wasm_contract(CALL_EVM_PAYBLE_NAME); @@ -732,6 +756,9 @@ const CALL_XVM_PAYABLE_WITH_SDL: &'static str = "608060405234801561001057600080f #[test] fn calling_wasm_from_evm_works_if_sufficient_storage_deposit_limit() { new_test_ext().execute_with(|| { + // create account mappings + connect_accounts(&ALICE, &alith_secret_key()); + let wasm_callee_addr = deploy_wasm_contract(WASM_SIMPLE_STORAGE_NAME); let evm_caller_addr = deploy_evm_contract(CALL_XVM_PAYABLE_WITH_SDL);