Skip to content

Add pools to centrifuge runtime#1233

Merged
hieronx merged 59 commits into
mainfrom
feature/add-pools-to-centrifuge
Apr 4, 2023
Merged

Add pools to centrifuge runtime#1233
hieronx merged 59 commits into
mainfrom
feature/add-pools-to-centrifuge

Conversation

@mustermeiszer

@mustermeiszer mustermeiszer commented Mar 7, 2023

Copy link
Copy Markdown
Collaborator

Description

This PR adds all relvant pallets, struct logic to the the Centrifuge runtime.

Fixes #1224, #1225, #1226

Changes and Descriptions

  • Adds new weights for Centrifuge
  • Adds new weights for Altair
  • Fixes pallet-pool-registry benchmarks
  • Adds new loans-pallet to Centrifuge

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Charcoal has been deployed and upgrade

Tasks:

  • Write integration test for creating a pool → not possible currently, as integration-tests, Issue see Integration-Test for Altair and Centrifuge #1288
  • Pump runtime version number
  • Charcoal has been upgraded successfully
  • Proxy setup has been reviewed
  • Loans is integrated
  • Deposit amount for Pools is right

Release Process

Checklist: https://centrifuge.hackmd.io/@mq/H1tt-AT9s?type=view

@mustermeiszer mustermeiszer added the D7-essential Pull request essentially changes code. New Release needed. Audit would be nice. label Mar 7, 2023
@mustermeiszer

Copy link
Copy Markdown
Collaborator Author

@offerijns can you take a look at the pool parameters?

Comment thread runtime/centrifuge/src/lib.rs
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
@branan

branan commented Mar 7, 2023

Copy link
Copy Markdown
Contributor

Regarding things like the various minimum time parameters - I believe in Altair we have several of these configured differently based on if the benchmarks are being built (since the benches do everything in a single block). Development runtime just sets them to unsafe defaults all the time, since it doesn't matter there.

@branan

branan commented Mar 9, 2023

Copy link
Copy Markdown
Contributor

I ended up pushing the temp loans enablement for now because some stuff is still broken, but I didn't want to keep the whole branch on my laptop any longer.

The only remaining known issue is that the pool-registry benchmarks rely on investor accounts being generated with fake tranche tokens so that pending redemption orders can block immediate execution of the update extrinsic. Those fake tranche tokens were removed in the tranche tests refactor PR. It should be a quick fix.

Once that's done and we confirm the whole benchmark stack is playing nicely, we can rip out the loans stuff again in preparation for the new version to land.

@mustermeiszer

Copy link
Copy Markdown
Collaborator Author

Ran the benchmarks locally:

First failure here:

Starting benchmark: pallet_pool_registry::register
Starting benchmark: pallet_pool_registry::update_no_execution
Error: Input("Benchmark pallet_pool_registry::update_no_execution failed: BalanceTooLow")
Error: Intermediate error occurred. Cleaning up artifacts in '/tmp/runtime/centrifuge'
Aborting!

Comment thread runtime/centrifuge/src/lib.rs Outdated
@lemunozm

Copy link
Copy Markdown
Contributor

I'm going to take the freedom to rebase this to the latest main in order to be able to create another PR with the loan addition.

@lemunozm lemunozm force-pushed the feature/add-pools-to-centrifuge branch from 5359e41 to 7706d1e Compare March 14, 2023 09:38
@lemunozm

Copy link
Copy Markdown
Contributor

PR with the loans addition: #1254

@lemunozm

Copy link
Copy Markdown
Contributor

I rebase it and fix minor errors

@wischli wischli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have some remarks and found at least two blockers (happy to be corrected).

Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight<Self>;
// NOTE: Benchmarks are failing with
// "Error: Input("failed to submit candidacy")"
type WeightInfo = ();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I want to raise my concern for merging with default weights. Phragmen is not recommended to be used on Parachains due to its O(n^3) complexity. Has anyone dug into the issue?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No. I am not sure why we need it at all for council rotation and if there might be a more lightweight approach. Anyways, the error I found while testing the benchmark on Altair a year ago.

I did not run them again for Centrifuge.

Comment thread runtime/centrifuge/src/lib.rs Outdated
}

/// Checks whether the given `who` has the role
/// of a `TrancehInvestor` for the given pool.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// of a `TrancehInvestor` for the given pool.
/// of a `TrancheInvestor` for the given pool.

Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs
Comment thread runtime/centrifuge/src/lib.rs
PoolSystem: pallet_pool_system::{Pallet, Call, Storage, Event<T>} = 181,
Permissions: pallet_permissions::{Pallet, Call, Storage, Event<T>} = 182,
Investments: pallet_investments::{Pallet, Call, Storage, Event<T>} = 183,
InterestAccrual: pallet_interest_accrual::{Pallet, Storage, Event<T>, Config<T>} = 184,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

pallet_interest_accrual sets the StorageVersion to Release::v2 in its GenesisBuild. However, we don't run any migration for Centrifuge. As a result, the StorageVersion storage will default to 0. This needs to be addressed.

Additionally, pallet_interest_accrual still uses the old scheme of handling StorageVersion, but this is another story. With the "new" way, the pallet would actually be initialized with the latest version for Centrifuge runtime.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That was a very good catch!
By now, can it be fixed applying the migration as it is done in altair?
cc @branan

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All we need to do is set pallet_interest_accrual::StorageVersion to ReleaseV2. As there is no storage trie yet on the Centrifuge runtime, no other migration is required.

Theoretically, we could also handle this the next time we bump the version but let's not start such inconsistencies.

@NunoAlexandre NunoAlexandre mentioned this pull request Mar 28, 2023
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight<Self>;
// NOTE: Benchmarks are failing with
// "Error: Input("failed to submit candidacy")"
type WeightInfo = ();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No. I am not sure why we need it at all for council rotation and if there might be a more lightweight approach. Anyways, the error I found while testing the benchmark on Altair a year ago.

I did not run them again for Centrifuge.

Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs
Comment thread runtime/centrifuge/src/lib.rs
Comment thread runtime/centrifuge/src/lib.rs Outdated
wischli
wischli previously approved these changes Mar 28, 2023

@wischli wischli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once the branch is rebased to master, let's rerun benchmarks to include pallet_elections_phragmen. But even with the default weights, it should be fine. So no blocker.


pub struct SetStorageVersionToV2<T>(sp_std::marker::PhantomData<T>);

impl<T: Config> OnRuntimeUpgrade for SetStorageVersionToV2<T> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In theory we could change Release::default() to be V2 now, and the unpopulated storage key would be V2 on Centrifuge without us needing to run a migration

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed and defaulted to V2.

Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs Outdated
Comment thread runtime/centrifuge/src/lib.rs
@mustermeiszer

Copy link
Copy Markdown
Collaborator Author

/benchmark centrifuge

@github-actions

github-actions Bot commented Apr 4, 2023

Copy link
Copy Markdown

✅ Uploaded benchmarks for: centrifuge
Find the artifact here: https://github.com/centrifuge/centrifuge-chain/actions/runs/4605478777

wischli
wischli previously approved these changes Apr 4, 2023

@wischli wischli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

lemunozm
lemunozm previously approved these changes Apr 4, 2023

@lemunozm lemunozm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

hieronx
hieronx previously approved these changes Apr 4, 2023
@mustermeiszer mustermeiszer dismissed stale reviews from hieronx, lemunozm, and wischli via 4915a47 April 4, 2023 11:58
@hieronx hieronx merged commit 920fcc1 into main Apr 4, 2023
@lemunozm lemunozm deleted the feature/add-pools-to-centrifuge branch April 4, 2023 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

D5-breaks-api Pull request changes public api. Document changes publicly. D7-essential Pull request essentially changes code. New Release needed. Audit would be nice.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pools pallets to Centrifuge runtime

5 participants