Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remote proxy support to AH Kusama #535

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2a17edb
Add remote proxy pallet
bkchr Jan 9, 2025
98bf59b
More tests
bkchr Jan 11, 2025
1a1069c
More tests
bkchr Jan 13, 2025
e58d3c7
Docs
bkchr Jan 14, 2025
67d908b
Start with benchmarks
bkchr Jan 14, 2025
ebb1905
Finish benchmarks
bkchr Jan 15, 2025
ad1f096
Implement remote proxy for Polkadot AH
bkchr Jan 15, 2025
82e49e0
Update pallets/remote-proxy/src/lib.rs
bkchr Jan 16, 2025
6ffc856
FOR THE MIGHTY CLIPPY
bkchr Jan 16, 2025
6e3e420
ZEPTER
bkchr Jan 16, 2025
4e559bf
No instance
bkchr Jan 16, 2025
fe69c39
TAPLO
bkchr Jan 16, 2025
bc69dde
MIGHTY CLIPPY PLEASE ACCEPT ME
bkchr Jan 16, 2025
55f69b1
Kusama AH implementation
bkchr Jan 16, 2025
7c24ca6
Make CI happy
bkchr Jan 16, 2025
7a85c61
Update changelog
bkchr Jan 16, 2025
721d437
Hmm :see_no_evil:
bkchr Jan 16, 2025
6acd4bd
............
bkchr Jan 16, 2025
8bffc52
Disable the Polkadot integration
bkchr Jan 27, 2025
de469a1
Docs
bkchr Jan 27, 2025
765087d
Merge branch 'main' into bkchr-remote-proxy
bkchr Jan 27, 2025
c72658d
Update pallets/remote-proxy/src/lib.rs
bkchr Jan 28, 2025
c8f1c0b
Review comments
bkchr Jan 29, 2025
be6eb45
Fix warning
bkchr Jan 29, 2025
ae39e24
Yes clippy
bkchr Jan 29, 2025
6497477
Fix the benchmarks
bkchr Jan 30, 2025
b3ee9ea
Merge branch 'main' into bkchr-remote-proxy
bkchr Jan 30, 2025
cbef781
More fixes
bkchr Jan 31, 2025
ad9a7f6
Merge remote-tracking branch 'refs/remotes/origin/main'
bkchr Jan 31, 2025
2f439f5
Embarrassing
bkchr Jan 31, 2025
61d3c76
Merge remote-tracking branch 'refs/remotes/origin/bkchr-remote-proxy'
bkchr Jan 31, 2025
a3736ef
Merge branch 'main'
bkchr Jan 31, 2025
654e824
Merge branch 'main' into bkchr-remote-proxy
bkchr Jan 31, 2025
17d82b4
Features (#572)
bkontur Jan 31, 2025
256737b
Benches (#573)
bkontur Feb 3, 2025
5ef3aa3
Update pallets/remote-proxy/src/lib.rs
bkchr Feb 3, 2025
cc66421
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] Feb 5, 2025
979efb2
Fix issues
bkchr Feb 5, 2025
6b2e6e5
Update pallets/remote-proxy/src/lib.rs
bkchr Feb 5, 2025
1930e79
Update pallets/remote-proxy/src/lib.rs
bkchr Feb 5, 2025
7789ad2
Update pallets/remote-proxy/src/lib.rs
bkchr Feb 5, 2025
f72d00c
Update lib.rs
bkchr Feb 5, 2025
2fbb16a
Update lib.rs
bkchr Feb 5, 2025
969f081
Adds failing test
bkchr Feb 7, 2025
0aa57a9
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] Feb 7, 2025
22e7a23
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] Feb 7, 2025
f8d4410
Release `1.4.0`
bkchr Feb 7, 2025
f546124
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Delegate stake pools in Kusama ([polkadot-fellows/runtimes#540](https://github.com/polkadot-fellows/runtimes/pull/540))

- Adds support for remote proxies on AssetHub Polkadot and AssetHub Kusama. ‼️ Builders: Please read the docs and the implications around the lifetime of a proxy on a remote chain. ‼️ ([polkadot-fellows/runtimes#535](https://github.com/polkadot-fellows/runtimes/pull/535))

### Changed

- Kusama Treasury: remove funding to the Kappa Sigma Mu Society and disable burn ([polkadot-fellows/runtimes#507](https://github.com/polkadot-fellows/runtimes/pull/507))
Expand Down
29 changes: 28 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ pallet-proxy = { version = "38.0.0", default-features = false }
pallet-ranked-collective = { version = "38.0.0", default-features = false }
pallet-recovery = { version = "38.0.0", default-features = false }
pallet-referenda = { version = "38.0.0", default-features = false }
pallet-remote-proxy = { path = "pallets/remote-proxy", default-features = false }
pallet-salary = { version = "23.0.0", default-features = false }
pallet-scheduler = { version = "39.0.0", default-features = false }
pallet-session = { version = "38.0.0", default-features = false }
Expand Down Expand Up @@ -229,11 +230,12 @@ sp-offchain = { version = "34.0.0", default-features = false }
sp-runtime = { version = "39.0.1", default-features = false }
sp-session = { version = "36.0.0", default-features = false }
sp-staking = { version = "36.0.0", default-features = false }
sp-state-machine = { version = "0.43.0", default-features = false }
sp-std = { version = "14.0.0", default-features = false }
sp-storage = { version = "21.0.0", default-features = false }
sp-tracing = { version = "17.0.1", default-features = false }
sp-transaction-pool = { version = "34.0.0", default-features = false }
sp-trie = { version = "37.0.0" }
sp-trie = { version = "37.0.0", default-features = false }
sp-version = { version = "37.0.0", default-features = false }
sp-weights = { version = "31.0.0", default-features = false }
static_assertions = { version = "1.1.0" }
Expand Down Expand Up @@ -284,6 +286,7 @@ members = [
"integration-tests/emulated/tests/people/people-kusama",
"integration-tests/emulated/tests/people/people-polkadot",
"integration-tests/zombienet",
"pallets/remote-proxy",
"relay/common",
"relay/kusama",
"relay/kusama/constants",
Expand Down
70 changes: 70 additions & 0 deletions pallets/remote-proxy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
[package]
name = "pallet-remote-proxy"
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
version.workspace = true
authors.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
license.workspace = true
license = "Apache-2.0"


[dependencies]
codec = { features = ["derive", "max-encoded-len"], workspace = true }
scale-info = { features = ["derive"], workspace = true }

cumulus-pallet-parachain-system = { workspace = true }
cumulus-primitives-core = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-proxy = { workspace = true }
sp-core = { workspace = true }
sp-trie = { workspace = true }
sp-runtime = { workspace = true }

[dev-dependencies]
pallet-balances = { workspace = true }
pallet-utility = { workspace = true }
sp-io = { workspace = true }
sp-state-machine = { workspace = true }

[features]
default = ["std"]

std = [
"codec/std",
"cumulus-pallet-parachain-system/std",
"cumulus-primitives-core/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"pallet-proxy/std",
"pallet-utility/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-state-machine/std",
"sp-trie/std",
]

try-runtime = [
"cumulus-pallet-parachain-system/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"pallet-proxy/try-runtime",
"pallet-utility/try-runtime",
"sp-runtime/try-runtime",
]

runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
133 changes: 133 additions & 0 deletions pallets/remote-proxy/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Copyright (C) Polkadot Fellows.
// 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.

// Benchmarks for Remote Proxy Pallet

use super::*;
use crate::Pallet as RemoteProxy;
use alloc::{boxed::Box, vec};
use frame_benchmarking::v2::{
account, impl_test_function, instance_benchmarks, whitelisted_caller,
};
use frame_support::traits::Currency;
use frame_system::RawOrigin;
use sp_runtime::traits::{Bounded, StaticLookup};

const SEED: u32 = 0;

type BalanceOf<T> = <<T as pallet_proxy::Config>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;

fn assert_last_event<T: pallet_proxy::Config>(
generic_event: <T as pallet_proxy::Config>::RuntimeEvent,
) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}

#[instance_benchmarks]
mod benchmarks {
use super::*;
use frame_benchmarking::BenchmarkError;

#[benchmark]
fn remote_proxy() -> Result<(), BenchmarkError> {
// In this case the caller is the "target" proxy
let caller: T::AccountId = account("target", 0, SEED);
<T as pallet_proxy::Config>::Currency::make_free_balance_be(
&caller,
BalanceOf::<T>::max_value() / 2u32.into(),
);
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = whitelisted_caller();
let real_lookup = T::Lookup::unlookup(real.clone());
let call: <T as pallet_proxy::Config>::RuntimeCall =
frame_system::Call::<T>::remark { remark: vec![] }.into();
let (proof, block_number, storage_root) =
T::RemoteProxy::create_remote_proxy_proof(&caller, &real);
BlockToRoot::<T, I>::insert(block_number, storage_root);

#[extrinsic_call]
_(RawOrigin::Signed(caller), real_lookup, None, Box::new(call), proof);

assert_last_event::<T>(pallet_proxy::Event::ProxyExecuted { result: Ok(()) }.into());

Ok(())
}

#[benchmark]
fn register_remote_proxy_proof() -> Result<(), BenchmarkError> {
// In this case the caller is the "target" proxy
let caller: T::AccountId = account("target", 0, SEED);
<T as pallet_proxy::Config>::Currency::make_free_balance_be(
&caller,
BalanceOf::<T>::max_value() / 2u32.into(),
);
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = whitelisted_caller();
let (proof, block_number, storage_root) =
T::RemoteProxy::create_remote_proxy_proof(&caller, &real);
BlockToRoot::<T, I>::insert(block_number, storage_root);

#[extrinsic_call]
_(RawOrigin::Signed(caller), proof);

Ok(())
}

#[benchmark]
fn remote_proxy_with_registered_proof() -> Result<(), BenchmarkError> {
// In this case the caller is the "target" proxy
let caller: T::AccountId = account("target", 0, SEED);
<T as pallet_proxy::Config>::Currency::make_free_balance_be(
&caller,
BalanceOf::<T>::max_value() / 2u32.into(),
);
// ... and "real" is the traditional caller. This is not a typo.
let real: T::AccountId = whitelisted_caller();
let real_lookup = T::Lookup::unlookup(real.clone());
let call: <T as pallet_proxy::Config>::RuntimeCall =
frame_system::Call::<T>::remark { remark: vec![] }.into();
let (proof, block_number, storage_root) =
T::RemoteProxy::create_remote_proxy_proof(&caller, &real);
BlockToRoot::<T, I>::insert(block_number, storage_root);

#[block]
{
frame_support::dispatch_context::run_in_context(|| {
frame_support::dispatch_context::with_context::<
crate::RemoteProxyContext<crate::RemoteBlockNumberOf<T, I>>,
_,
>(|context| {
context.or_default().proofs.push(proof.clone());
});

RemoteProxy::<T, I>::remote_proxy_with_registered_proof(
RawOrigin::Signed(caller).into(),
real_lookup,
None,
Box::new(call),
)
.unwrap()
})
}

assert_last_event::<T>(pallet_proxy::Event::ProxyExecuted { result: Ok(()) }.into());

Ok(())
}

impl_benchmark_test_suite!(RemoteProxy, crate::tests::new_test_ext(), crate::tests::Test);
}
Loading
Loading