-
Notifications
You must be signed in to change notification settings - Fork 140
Add remote proxy support to AH Kusama #535
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
Merged
Merged
Changes from 23 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
2a17edb
Add remote proxy pallet
bkchr 98bf59b
More tests
bkchr 1a1069c
More tests
bkchr e58d3c7
Docs
bkchr 67d908b
Start with benchmarks
bkchr ebb1905
Finish benchmarks
bkchr ad1f096
Implement remote proxy for Polkadot AH
bkchr 82e49e0
Update pallets/remote-proxy/src/lib.rs
bkchr 6ffc856
FOR THE MIGHTY CLIPPY
bkchr 6e3e420
ZEPTER
bkchr 4e559bf
No instance
bkchr fe69c39
TAPLO
bkchr bc69dde
MIGHTY CLIPPY PLEASE ACCEPT ME
bkchr 55f69b1
Kusama AH implementation
bkchr 7c24ca6
Make CI happy
bkchr 7a85c61
Update changelog
bkchr 721d437
Hmm :see_no_evil:
bkchr 6acd4bd
............
bkchr 8bffc52
Disable the Polkadot integration
bkchr de469a1
Docs
bkchr 765087d
Merge branch 'main' into bkchr-remote-proxy
bkchr c72658d
Update pallets/remote-proxy/src/lib.rs
bkchr c8f1c0b
Review comments
bkchr be6eb45
Fix warning
bkchr ae39e24
Yes clippy
bkchr 6497477
Fix the benchmarks
bkchr b3ee9ea
Merge branch 'main' into bkchr-remote-proxy
bkchr cbef781
More fixes
bkchr ad9a7f6
Merge remote-tracking branch 'refs/remotes/origin/main'
bkchr 2f439f5
Embarrassing
bkchr 61d3c76
Merge remote-tracking branch 'refs/remotes/origin/bkchr-remote-proxy'
bkchr a3736ef
Merge branch 'main'
bkchr 654e824
Merge branch 'main' into bkchr-remote-proxy
bkchr 17d82b4
Features (#572)
bkontur 256737b
Benches (#573)
bkontur 5ef3aa3
Update pallets/remote-proxy/src/lib.rs
bkchr cc66421
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] 979efb2
Fix issues
bkchr 6b2e6e5
Update pallets/remote-proxy/src/lib.rs
bkchr 1930e79
Update pallets/remote-proxy/src/lib.rs
bkchr 7789ad2
Update pallets/remote-proxy/src/lib.rs
bkchr f72d00c
Update lib.rs
bkchr 2fbb16a
Update lib.rs
bkchr 969f081
Adds failing test
bkchr 0aa57a9
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] 22e7a23
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] f8d4410
Release `1.4.0`
bkchr f546124
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] f20aed0
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] 86a1b14
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] 3404050
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] 47fd640
Merge branch 'main' into bkchr-remote-proxy
fellowship-merge-bot[bot] bdd9736
Update pallets/remote-proxy/src/lib.rs
bkchr f25b9fd
Update pallets/remote-proxy/src/lib.rs
bkchr 1091f28
Merge remote-tracking branch 'origin/main' into bkchr-remote-proxy
bkchr 40a8c9e
Fixes and some reworks of the internals
bkchr b9a7eb9
Fixes
bkchr 44abbdd
TAPLO
bkchr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| [package] | ||
| name = "pallet-remote-proxy" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| repository.workspace = true | ||
| license.workspace = true | ||
bkchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [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", | ||
| ] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.