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

chore: polkadot 0.9.42 #527

Merged
merged 107 commits into from
Jul 20, 2023
Merged

chore: polkadot 0.9.42 #527

merged 107 commits into from
Jul 20, 2023

Conversation

Ad96el
Copy link
Member

@Ad96el Ad96el commented May 30, 2023

fixes KILTProtocol/ticket#2693

Updates to Polkadot dependencies have been made to version 0.9.42. You can find all the changes here.

How to test

Since the Currency trait has been silently deprecated, the unit tests have been adjusted to support the newly introduced fungible traits. Pre- and post-validations have been implemented for the migrations.

Still to be updated

In all pallets where a negative imbalance is used, the Currency trait is still being used. The feecollector (the treasury pallet) has not been updated yet, and there is an open PR addressing this. If the PR is merged, we will be able to completely remove the Currency trait. Currently, the trait is still used in the staking, DID, and CType pallets.

Checklist:

  • I have verified that the code works
    • No panics! (checked arithmetic ops, no indexing array[3] use get(3), ...)
  • I have verified that the code is easy to understand
    • If not, I have left a well-balanced amount of inline comments
  • I have left the code in a better state
  • I have documented the changes (where applicable)
    • Either PR or Ticket to update the Docs
    • Link the PR/Ticket here

@Ad96el Ad96el changed the title Chore/polkadot 0.9.42 chore: polkadot 0.9.42 May 31, 2023
@Ad96el Ad96el requested a review from weichweich July 3, 2023 09:34
Copy link
Member

@ntn-x2 ntn-x2 left a comment

Choose a reason for hiding this comment

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

Mostly looks good. I have some minor points about the migration stuff and few typos in the staking pallet. The biggest point is about the use of .uwnrap() inside the did::create pallet, which is no-good for the runtime logic. It is ok for it to fail instead.

pallets/attestation/src/migrations.rs Outdated Show resolved Hide resolved
pallets/attestation/src/migrations.rs Outdated Show resolved Hide resolved
pallets/did/src/lib.rs Outdated Show resolved Hide resolved
pallets/pallet-configuration/Cargo.toml Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Show resolved Hide resolved
pallets/parachain-staking/src/lib.rs Outdated Show resolved Hide resolved
@Ad96el Ad96el requested a review from ntn-x2 July 10, 2023 16:44
Copy link
Member

@ntn-x2 ntn-x2 left a comment

Choose a reason for hiding this comment

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

I think a lot has been improved since when the PR has been opened. I am happy with all the changes made. As I said, the only thing that might need to be done in a separate PR is a multi-block migration strategy, if needed. Also, we need to check that the logic for account reaping/dust collection has remained the same. I think @weichweich will still have to review this, at some point. But I will approve it on my side.

fn remove_attestation(attestation: AttestationDetailsOf<T>, claim_hash: ClaimHashOf<T>) {
kilt_support::free_deposit::<AccountIdOf<T>, CurrencyOf<T>>(&attestation.deposit);
fn remove_attestation(attestation: AttestationDetailsOf<T>, claim_hash: ClaimHashOf<T>) -> DispatchResult {
AttestationStorageDepositCollector::<T>::free_deposit(attestation.deposit)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

What are possible errors when freeing the deposit and what would this mean for remove_attestation?
I fear that if the error occurs, that there is no possible option to remove the attestation without the governance?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are two possible cases where remove attestation can fail:

  1. The user does not have enough balance on their hold, and the decrease should be Exact. If the precision is set to BestEffort, the actual amount is returned in an Ok response.
  2. Even after increasing the free balance, the user is still under the ED.

As I see it, both cases can be ignored. In the first case, the actual deposit is tracked in the storage. Additionally, when an attestation is removed, we use BestEffort as the precision.

support/src/lib.rs Outdated Show resolved Hide resolved
support/src/lib.rs Show resolved Hide resolved
pallets/attestation/src/migrations.rs Outdated Show resolved Hide resolved
Comment on lines +130 to +131
Attestations::<T>::iter()
.map(|(key, attestations_detail)| -> Weight {
Copy link
Contributor

Choose a reason for hiding this comment

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

How many attestations do we have? I'm afraid that this is not an option for us? Especially since we not only iterate over all attestations but basically over all storage?

pallets/delegation/src/lib.rs Outdated Show resolved Hide resolved
pallets/did/src/lib.rs Outdated Show resolved Hide resolved
pallets/pallet-web3-names/src/lib.rs Outdated Show resolved Hide resolved
runtimes/spiritnet/src/weights/pallet_balances.rs Outdated Show resolved Hide resolved
@weichweich
Copy link
Contributor

Looks good. But the migration has to be redone. I don't think that we can do that in a single block. I propose we do a lazy migration with a permission less call to update them. Like it was suggested in the PR.

@@ -562,7 +579,7 @@ dependencies = [
[[package]]
name = "binary-merkle-tree"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.41#3bd809d59c31c7205a0f36c6ddcba603e43051fc"
source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.42#3bb3882ce094ac211dea93fabfdcd4f902f5a7fd"
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't seem to be up to date with polkadot-v0.9.42. Try running cargo update. This will update all dependencies. You could run cargo update -p sp-io which updates most of the substrate dependencies. Make sure to also check cumulus & polkadot repositories.

Copy link
Member

@ntn-x2 ntn-x2 left a comment

Choose a reason for hiding this comment

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

Did not go over everything, but I like this approach more of migrating a specific account to the new version.

@@ -163,10 +150,7 @@ pub mod test {
assert!(attestation_post_migration.clone().unwrap().deposit.version.is_some());
assert!(attestation_post_migration.unwrap().deposit.version.unwrap() == 1);

//Nothing should happen
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can keep the comment?

@Ad96el Ad96el merged commit 721bbb0 into develop Jul 20, 2023
@Ad96el Ad96el deleted the chore/polkadot-0.9.42 branch July 20, 2023 09:24
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.

3 participants