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

Add remote proxy support to AH Kusama #535

wants to merge 48 commits into from

Conversation

bkchr
Copy link
Contributor

@bkchr bkchr commented Jan 9, 2025

This adds remote proxy support to AssetHub on Polkadot and Kusama. Currently it is configured only to support using proxies registered on the relay chain to work on AssetHub. In the future this can be expanded.

Copy link
Contributor

@xlc xlc left a comment

Choose a reason for hiding this comment

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

this is not in polkadot-sdk repo so how do we want to test it on westend?

pallets/remote-proxy/src/lib.rs Show resolved Hide resolved
@bkchr
Copy link
Contributor Author

bkchr commented Jan 10, 2025

this is not in polkadot-sdk repo so how do we want to test it on westend?

I will also port it there. I wanted to include it in the next release if possible. People are having more and more these problems of proxies not being on AH and similar. This pallet could solve the issue without requiring a root referendum (we already had one and another is prepared AFAIK).

@bkchr bkchr marked this pull request as ready for review January 15, 2025 20:49
@bkchr bkchr mentioned this pull request Jan 15, 2025
6 tasks
pallets/remote-proxy/src/lib.rs Outdated Show resolved Hide resolved
pallets/remote-proxy/src/lib.rs Outdated Show resolved Hide resolved
system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs Outdated Show resolved Hide resolved
@bkchr bkchr changed the title Add remote proxy pallet Add remote proxy support to AH Polkadot&Kusama Jan 16, 2025
@acatangiu
Copy link
Contributor

I'd be more comfortable if we also did a security audit for this before adding it to live Polkadot AssetHub

@bkchr
Copy link
Contributor Author

bkchr commented Jan 17, 2025

I'd be more comfortable if we also did a security audit for this before adding it to live Polkadot AssetHub

The scope of the changes is quite narrow. Doing some proper review should be fine. The only difference to the real proxy pallet is that the data is coming in from the outside.

@bkchr bkchr changed the title Add remote proxy support to AH Polkadot&Kusama Add remote proxy support to AH Kusama Jan 27, 2025
bkchr and others added 4 commits January 31, 2025 12:52
<!-- Remember that you can run `/merge` to enable auto-merge in the PR
-->

<!-- Remember to modify the changelog. If you don't need to modify it,
you can check the following box.
Instead, if you have already modified it, simply delete the following
line. -->

- [ ] Does not require a CHANGELOG entry
@bkchr
Copy link
Contributor Author

bkchr commented Jan 31, 2025

/cmd bench --pallet pallet_remote_proxy

Copy link

Command "bench --pallet pallet_remote_proxy" has started 🚀 See logs here

@bkchr
Copy link
Contributor Author

bkchr commented Jan 31, 2025

/cmd bench --pallet pallet_remote_prox

@bkchr
Copy link
Contributor Author

bkchr commented Jan 31, 2025

/cmd bench --pallet pallet_remote_proxy

Copy link

Command "bench --pallet pallet_remote_proxy" has started 🚀 See logs here

@bkontur
Copy link
Contributor

bkontur commented Jan 31, 2025

Command "bench --pallet pallet_remote_proxy" has started 🚀 See logs here

needs https://github.com/polkadot-fellows/runtimes/pull/573/files#diff-80668ff8e793b64f36a9a3ec512df5cbca4ad448c157a5d81abda1b15f35f1daR1129

+ [pallet_remote_proxy, RemoteProxyRelayChain]

plus feature propagation and compilation is fixed here: #573

Copy link

github-actions bot commented Feb 1, 2025

Command "bench --pallet pallet_remote_proxy" has finished ✅ See logs here

<!-- Remember that you can run `/merge` to enable auto-merge in the PR
-->

<!-- Remember to modify the changelog. If you don't need to modify it,
you can check the following box.
Instead, if you have already modified it, simply delete the following
line. -->

- [ ] Does not require a CHANGELOG entry
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"

pallets/remote-proxy/src/lib.rs Show resolved Hide resolved
@bkchr bkchr enabled auto-merge (squash) February 3, 2025 21:36
pallets/remote-proxy/src/lib.rs Outdated Show resolved Hide resolved
/// The remote block number.
type RemoteBlockNumber: Parameter + Saturating + MaxEncodedLen + Default;
/// The hash type used by the remote chain.
type Hash: Parameter + MaxEncodedLen;
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
type Hash: Parameter + MaxEncodedLen;
type RemoteHash: Parameter + MaxEncodedLen;

Nit, but maybe not worth renaming.

/// The hash type used by the remote chain.
type Hash: Parameter + MaxEncodedLen;
/// The hasher used by the remote chain.
type Hasher: Hasher<Out = Self::Hash>;
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
type Hasher: Hasher<Out = Self::Hash>;
type RemoreHasher: Hasher<Out = Self::RemoteHash>;

Ditto


// Update the block to root mappings.
BlockToRoot::<T>::insert(&block, hash);
BlockToRoot::<T>::remove(block.saturating_sub(T::MaxStorageRootsToKeep::get()));
Copy link
Member

Choose a reason for hiding this comment

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

Hm how does this work?
Would this not only get every second block from the relay? Then how does it ensure to clean up the storage? Or do you just assume that it is always every second and never misses a block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good find 🙈

}

impl<T: Config, I: 'static> OnSystemEvent for Pallet<T, I> {
fn on_validation_data(validation_data: &PersistedValidationData) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we force-consume weight here? This function does not seem to expect any weight return or similar.
Or we include its weight in on_initialize.

pallets/remote-proxy/src/lib.rs Outdated Show resolved Hide resolved
let key = T::RemoteProxy::proxy_definition_storage_key(&real_remote);

let db =
sp_trie::StorageProof::new(proof).into_memory_db::<RemoteHasherOf<T, I>>();
Copy link
Member

Choose a reason for hiding this comment

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

Is this a heavy operation or something that consumes lots of memory? Then maybe we could enforce a sane upper bound for the proof size and abort if someone puts multiple megabyte.

pallets/remote-proxy/src/lib.rs Show resolved Hide resolved
},
};

ensure!(def.delay.is_zero(), Error::<T, I>::Unannounced);
Copy link
Member

Choose a reason for hiding this comment

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

Important check, and also good to mention in the docs that this only works for delay=0 proxies.

pallets/remote-proxy/src/lib.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants