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

Migrates pallet-multisig to Consideration #1782

Closed
wants to merge 11 commits into from

Conversation

gupnik
Copy link
Contributor

@gupnik gupnik commented Oct 3, 2023

Part of #226

In order to simply migrate the existing runtimes, a diff can look like the following:

-	type DepositBase = DepositBase;
-	type DepositFactor = DepositFactor;
+       type Consideration = HoldConsideration<
+		AccountId,
+		Balances,
+		MultisigHoldReason,
+		LinearStoragePrice<DepositBase, DepositFactor, Balance>,
+	>;

@Polkadot-Forum
Copy link

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/frame-monthly-update/4628/1

@gupnik gupnik added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Jan 5, 2024
@gupnik gupnik marked this pull request as ready for review January 9, 2024 04:08
@gupnik gupnik requested review from a team January 9, 2024 04:08
Comment on lines +739 to +740
let updated_multisig = MultisigsFor::<Test>::get(&multi, &call_hash).unwrap();
assert_eq!(updated_multisig.depositor, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

should we check all fields for sanity?

T::Currency::unreserve(&r.depositor, r.deposit);
// take consideration
let Ok(ticket) =
T::Consideration::new(&r.depositor, Footprint::from_parts(1, threshold as usize))
Copy link
Contributor

Choose a reason for hiding this comment

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

when migrating, shouldn't we take exactly r.deposit instead of calculating using the current config? to handle the case where the reserve amounts changed.

Copy link
Contributor Author

@gupnik gupnik Jan 16, 2024

Choose a reason for hiding this comment

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

As we are un-reserving the previous amount, isn't it a fair assumption to charge the current amount in this lazy migration?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't say so, because it's not what the user agreed to / understood at the time that they made the multisig. I would expect deposit amount changes to only impact new multisigs, not be applied retroactively

Copy link
Contributor Author

@gupnik gupnik Jan 17, 2024

Choose a reason for hiding this comment

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

I see your point, but I also don't think that this is a significant issue. It occurs only for a specific case when the deposit amount has changed between the time of creation vs this migration, which is also handled, just that it requires an increase in the deposit. @ggwpez @kianenigma Would love to get your thoughts here. I imagine this was the reason we were trying to add new_from_exact API in consideration, but this looks to me as a better trade-off.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes this is why we were trying to add new_from_exact. I guess adding that failed/is still in progress? :P

Copy link
Member

@ggwpez ggwpez Jan 17, 2024

Choose a reason for hiding this comment

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

#2274 can be used to migrate them over with an exact amount.
It was added as new trait to not bloat the existing one and not introduce use-once code that lingers forever.

I think we shouldn't change the amounts on the fly, the user only agreed to the amount that they signed and if they are early adopters of Polkadot we should not punish that for no good reason.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we shouldn't change the amounts on the fly, the user only agreed to the amount that they signed and if they are early adopters of Polkadot we should not punish that for no good reason.

I agree

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 think we shouldn't change the amounts on the fly, the user only agreed to the amount that they signed and if they are early adopters of Polkadot we should not punish that for no good reason.

Thanks - but I do see this pattern already being used in preimage pallet here. Won't that be impacted with a similar reasoning?

Copy link
Contributor

@liamaharon liamaharon Jan 18, 2024

Choose a reason for hiding this comment

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

Yes, I would have also argued to not have used that pattern in the preimage pallet.

T::Consideration::new(&r.depositor, Footprint::from_parts(1, threshold as usize))
.defensive_proof("Unexpected inability to take deposit after unreserved")
else {
return true
Copy link
Contributor

Choose a reason for hiding this comment

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

if this returns early, the new multisig is not added to MultisigsFor. should we just defensive log but continue anyways to not break the multisig?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, multisig can't exist in the system if we were not able to take the consideration. I can throw an error in this case though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be bad ux for a multisig to just vanish?

This shouldn't be an issue if we don't try re-reserving different amounts, though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't vanish but the migration would fail hinting the user to add funds if needed.

Copy link
Contributor

@liamaharon liamaharon Jan 17, 2024

Choose a reason for hiding this comment

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

I don't see where it fails, maybe I misunderstand but I see ensure_updated returns true in this conditional if the consideration fails to create

Copy link
Contributor Author

@gupnik gupnik Jan 17, 2024

Choose a reason for hiding this comment

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

Yeah, I should have been clearer. I meant that once it throws an error as I mentioned above, it should be fine. Will update that.

I can throw an error in this case though.

Comment on lines +130 to +131
/// The amount held in reserve of the `depositor`, to be returned once the operation ends.
ticket: Ticket,
Copy link
Member

Choose a reason for hiding this comment

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

I think the name Ticket was swapped for Consideration or so.


/// The set of open multisig operations.
#[pallet::storage]
pub type MultisigsFor<T: Config> = StorageDoubleMap<
Copy link
Member

Choose a reason for hiding this comment

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

This is a breaking change and will probably mess with wallets/indexers etc since they look at the old map.
I dont think there is an easy way out without MBMs (audit stalled for another month), so not sure what to best do.

Copy link
Contributor

@liamaharon liamaharon Jan 18, 2024

Choose a reason for hiding this comment

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

TBH since this is not the highest priority I don't think too much of a problem to wait for MBMs.. should try to minimise breakage of these apis as much as possible, as you point out. with this change, possibly every multisig UI in the ecosystem would break :P

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, fine to wait for MBM if that's the case.

<Multisigs<T>>::remove(&id, call_hash);
T::Currency::unreserve(&m.depositor, m.deposit);
<MultisigsFor<T>>::remove(&id, call_hash);
let _ = m.ticket.drop(&m.depositor);
Copy link
Member

Choose a reason for hiding this comment

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

Does it panic when its not manually dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean if someone forgot to call drop on the ticket?

Copy link
Member

Choose a reason for hiding this comment

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

in general i think let _ should be a no-no across the repo.

If in this situation, you specifically want to drop the result you should call mem::drop (AFAIK)

@@ -665,6 +691,25 @@ impl<T: Config> Pallet<T> {
signatories.insert(index, who);
Ok(signatories)
}

pub(crate) fn ensure_updated(id: &T::AccountId, call_hash: &[u8; 32], threshold: u16) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can safely expose this function publicly as extrinsic to manually nudge it to speed up the process.

bkchr pushed a commit that referenced this pull request Apr 10, 2024
* Try check-rustdoc pipeline

* another try

* another try without `--all-features`

* fixed cargo doc issues

* exclude relay-rialto-parachain-client from cargo doc

---------

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
@cla-bot-2021
Copy link

cla-bot-2021 bot commented Jul 8, 2024

User @codeknix, please sign the CLA here.

@bkchr
Copy link
Member

bkchr commented Jul 17, 2024

@gupnik what is the status on this?

@gupnik
Copy link
Contributor Author

gupnik commented Jul 17, 2024

@gupnik what is the status on this?

Yes, it's in my todo list but haven't been able to get back to this yet. Will try to prioritise. Thanks for the reminder.

@cla-bot-2021
Copy link

cla-bot-2021 bot commented Oct 1, 2024

User @codekitz, please sign the CLA here.

@gupnik gupnik closed this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants