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

[AHM] referenda pallet #558

Merged

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Jan 22, 2025

meant to be merged into dev-asset-hub-migration branch

referenda pallet migration


let referendum = if let ReferendumInfo::Ongoing(mut status) = referendum {
// TODO: map call and update preimage
// TODO: if mapping fails cancel referendum
Copy link
Member

@ggwpez ggwpez Jan 22, 2025

Choose a reason for hiding this comment

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

I wonder if we have to set alarms in the scheduler? The scheduler normally checks if it went into "passing" or something.
Could be that it is not needed for big OpenGov refs since people vote on them often and that also sets the alarm. But it would probably cleaner to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. I keep it in mind. Not sure yet how we solve it, but for sure make sure it works correctly

@ggwpez ggwpez mentioned this pull request Jan 23, 2025
64 tasks
i
} else {
defensive!("Call encoded length is too large for inline encoding");
// TODO: if we have such a case we would need to dispatch two call on behalf of
Copy link
Contributor Author

Choose a reason for hiding this comment

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

right now they actually all fit

Copy link
Member

Choose a reason for hiding this comment

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

You mean all ongoing referenda reference calls that - after translation - dont have more than 128 bytes? Huh, did not expect that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, never panics here

#[derive(
Encode, Decode, Eq, PartialEq, Clone, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen,
)]
pub enum VersionedLocatableAccount {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

based on this RFC - paritytech/polkadot-sdk#4715

I would prefer these types to be located in the same repo as the runtimes itself. Bu that would mean we need to copy past them for westend, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ggwpez what you think? should I move it to sdk?

/// The `RuntimeOrigin` is a type argument that needs to be mapped to AH `RuntimeOrigin`.
/// Inline `proposal`s and the ones stored by `Preimage` pallet should also be mapped to get the
/// final local `pallet_referenda::ReferendumInfoFor::<T, ()>`.
pub type RcReferendumInfoOf<T, I> = ReferendumInfo<
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
pub type RcReferendumInfoOf<T, I> = ReferendumInfo<
// From https://github.com/polkadot-fellows/runtimes/blob/a560cf00324a8520cab2b1a9c5e4a36efea9dae9/pallets/ah-migrator/src/referenda.rs#L30-L39
pub type RcReferendumInfoOf<T, I> = ReferendumInfo<

I think its good to have the location as link here so we can easily compare with the original and check if something changed later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the link to the same type? the closes type is ReferendumInfoOf<T, I> in referenda pallet

Copy link
Member

Choose a reason for hiding this comment

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

🤦‍♂️ oh, yea thats what i meant

pallets/ah-migrator/src/referenda.rs Show resolved Hide resolved
e
} else {
log::warn!("Failed to fetch preimage for referendum {}", id);
cancel_referendum(id, status);
Copy link
Member

Choose a reason for hiding this comment

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

Note: we have to cancel here because we cannot translate the preimage, right? So even though ongoing referenda without preimage are normally perfectly fine, in this case they are not because we can ensure that they are translated correctly?
Need to write this into some doc that people still try to post their preimages before the migration starts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right if we cannot fetch and translate we cannot even keep the same hash, because it has not meaning on new chain.

i
} else {
defensive!("Call encoded length is too large for inline encoding");
// TODO: if we have such a case we would need to dispatch two call on behalf of
Copy link
Member

Choose a reason for hiding this comment

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

You mean all ongoing referenda reference calls that - after translation - dont have more than 128 bytes? Huh, did not expect that.

defensive!("Call encoded length is too large for inline encoding");
// TODO: if we have such a case we would need to dispatch two call on behalf of
// the original preimage submitter to release the funds for the new preimage
// deposit and dispatch the call to note a new preimage. or we provide a
Copy link
Member

Choose a reason for hiding this comment

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

As intermediate solution we could also just request the hash of the translated call, then we dont have to cancel the referenda and also dont have to make calls on behalf of the preimage submitter. The fellowship could then as cleanup step after the migration submit the translated preimage.
I think that should be good for now to not make it too complicated.

Otherwise we can probably also mess with the storage of the preimage pallet to overwrite the preimage with the new content and keep the deposit active.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wont cancel them because they do not fit into inline. Just now no cases and I wanna move forward for now.
But right now, we can use Preimage::note, but that would request that preimage and for the referendums that wont pass we will have to cleanup/unrequest them. totally fine, but I leave it as is for now.


//! Track configurations for governance.

// TODO: RC_DAYS, RC_MINUTES should be RC_RC_DAYS, RC_MINUTES, etc.
Copy link
Member

Choose a reason for hiding this comment

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

Okay you marked it here 👍


/// Relay Chain Utility Call obtained from cargo expand.
///
/// The variants that are not generally used in Governance are not included.
Copy link
Member

Choose a reason for hiding this comment

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

We have to pay attention that this does not change in the SDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right. we probably need to give some heads up to devs and ask them to let us know if they introducing any changes to migrating pallets

return Err(a)
},
};
Self::map(rc_call).map_err(|_| a)
Copy link
Member

@ggwpez ggwpez Jan 28, 2025

Choose a reason for hiding this comment

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

Do you know what calls are in the referenda pallet that we do not translate? Should also be in the user impact section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not yet. my plan still to have everything translated. I think I will know later if we have anything we cannot translate

},
RcRuntimeCall::Treasury(inner_call) => {
let call =
inner_call.using_encoded(|mut e| Decode::decode(&mut e)).map_err(|err| {
Copy link
Member

Choose a reason for hiding this comment

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

Sorry what is this doing? Why do we not have to call map?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here we know that RC inner call layout is basically the same with AH inner call, it encodes to the same sequence of bytes, and instead of manually mapping it, we can just encode RC treasury call and decode it to AH treasury call (true for all treasury calls for example except treasury spend call for which we have an arm above).

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, since this pallet's calls do not have anything to translate in them 👍


/// Pay on the local chain with `fungibles` implementation if the beneficiary and the asset are both
/// local.
pub struct LocalPay<F, A, C>(core::marker::PhantomData<(F, A, C)>);
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
pub struct LocalPay<F, A, C>(core::marker::PhantomData<(F, A, C)>);
// From https://github.com/polkadot-fellows/runtimes/blob/a560cf00324a8520cab2b1a9c5e4a36efea9dae9/system-parachains/common/src/pay.rs#L42-L114
pub struct LocalPay<F, A, C>(core::marker::PhantomData<(F, A, C)>);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a new type (=

Cargo.toml Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Did you add the new crate to the members as well?

@muharem
Copy link
Contributor Author

muharem commented Jan 29, 2025

ah, I have two very different branches, local and remote

@ggwpez
Copy link
Member

ggwpez commented Jan 29, 2025

Oh damn, i wrote you that i rebased your branch 🙃 you can also force push and rebase again otherwise

@muharem
Copy link
Contributor Author

muharem commented Jan 29, 2025

Oh damn, i wrote you that i rebased your branch 🙃 you can also force push and rebase again otherwise

I think solved. Can you check my replies and lets merge it

@muharem
Copy link
Contributor Author

muharem commented Jan 29, 2025

Oh damn, i wrote you that i rebased your branch 🙃 you can also force push and rebase again otherwise

Yes. my fault. I also accepted your code proposals from review after merging dev branch locally and introducing inner referenda stage (=

@ggwpez ggwpez marked this pull request as ready for review January 29, 2025 11:03
@ggwpez ggwpez merged commit 3dbad2b into polkadot-fellows:dev-asset-hub-migration Jan 29, 2025
33 of 51 checks passed
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.

2 participants