Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Make Pallet ModuleId and LockIdentifier Configurable #5695

Merged
merged 24 commits into from
Apr 24, 2020

Conversation

emostov
Copy link
Contributor

@emostov emostov commented Apr 18, 2020

Closes #5149

This PR aims to switch MODULE_ID from being hardcoded into pallets over to being specified in runtime configuration.

polkadot companion: paritytech/polkadot#1007

Below are the pallets changed and notes:

  • treasury
  • elections
    • no changes in runtime because elections does not appear to be incorporated currently.
  • elections-phragrem
    • please review the change to the test I made around line 1137. I changed it from assert_eq!(lock.id, MODULE_ID); to assert_eq!(lock.id, *b"phrelect"); because MODULE_ID is no longer defined. However, I am not sure if the right value should be dynamic.
  • evm
    • no changes in runtime because evm does not appear to be incorporated currently.
  • Society

Before you submitting, please check that:

  • You added a brief description of the PR, e.g.:
    • What does it do?
    • What important points reviewers should know?
    • Is there something left for follow-up PRs?
  • You labeled the PR with appropriate labels if you have permissions to do so.
  • You mentioned a related issue if this PR related to it, e.g. Fixes #228 or Related #1337.
  • You asked any particular reviewers to review. If you aren't sure, start with GH suggestions.
  • Your PR adheres the style guide
    • In particular, mind the maximal line length.
    • There is no commented code checked in unless necessary.
    • Any panickers have a proof or removed.
  • You bumped the runtime version if there are breaking changes in the runtime.
  • You updated any rustdocs which may have changed
  • Has the PR altered the external API or interfaces used by Polkadot? Do you have the corresponding Polkadot PR ready?

After you've read this notice feel free to remove it.
Thank you!

✄ -----------------------------------------------------------------------------

@parity-cla-bot
Copy link

It looks like @emostov signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

@shawntabrizi
Copy link
Member

Looks about right, can you please check spacing issues with the lines you have introduced (we use tabs), and there seems to be compilation error, maybe just needs to merge master.

@shawntabrizi shawntabrizi changed the title Active draft for issue #5149 Make Pallet ModuleId and LockIdentifier Configurable Apr 18, 2020
@emostov
Copy link
Contributor Author

emostov commented Apr 18, 2020

I merged in upstream/master and it looks like there still is a compilation error in some of the CI jobs. I did a release build and later ran all the non-ignored tests locally. Both seemed to finish without an issue. Not sure what else to try/look at regarding the compilation error.

Planning on having an accompanying Polkadot PR up within the next 24hrs as long as I can find a quick resolution to the CI errors.

@emostov emostov marked this pull request as ready for review April 20, 2020 14:44
Copy link
Member

@shawntabrizi shawntabrizi left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member

@bkchr bkchr left a comment

Choose a reason for hiding this comment

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

Looks good, just 2 nitpicks.

@@ -1124,7 +1130,7 @@ mod tests {

fn has_lock(who: &u64) -> u64 {
let lock = Balances::locks(who)[0].clone();
assert_eq!(lock.id, MODULE_ID);
assert_eq!(lock.id, *b"phrelect");
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
assert_eq!(lock.id, *b"phrelect");
assert_eq!(lock.id, ElectionsPhragmenModuleId::get());

@@ -147,6 +145,8 @@ type ApprovalFlag = u32;
const APPROVAL_FLAG_LEN: usize = 32;

pub trait Trait: frame_system::Trait {
type ModuleId: Get<LockIdentifier>;
Copy link
Member

Choose a reason for hiding this comment

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

Docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a doc comment /// Identifier for the elections-phragmen pallet's lock and also an equivalent doc comment for elections.

@shawntabrizi shawntabrizi mentioned this pull request Apr 21, 2020
5 tasks
… into zeke/fix/configurable-module-id

Merge in origin branch
@shawntabrizi shawntabrizi requested a review from bkchr April 21, 2020 18:06
@bkchr
Copy link
Member

bkchr commented Apr 22, 2020

Please merge master to fix the conflict.

@emostov
Copy link
Contributor Author

emostov commented Apr 22, 2020

Before this gets merged, should I take any steps to ensure that the polkadot companion PR can be merged in quick succession?

@bkchr
Copy link
Member

bkchr commented Apr 22, 2020

Before this gets merged, should I take any steps to ensure that the polkadot companion PR can be merged in quick succession?

Can we as push to your branch?

@emostov
Copy link
Contributor Author

emostov commented Apr 22, 2020

Before this gets merged, should I take any steps to ensure that the polkadot companion PR can be merged in quick succession?

Can we as push to your branch?

I think you are asking if you can push to my branch? If so, the answer is: yes. Let me know if I need to do anything on my end to make that happen.

@bkchr bkchr merged commit 5038c3a into paritytech:master Apr 24, 2020
@emostov emostov deleted the zeke/fix/configurable-module-id branch May 13, 2020 06:52
lamafab pushed a commit to lamafab/substrate that referenced this pull request Jun 16, 2020
* add module ids to kusama runtime

* update kusam with polkadot runtimes to have moduleids configured

* trivial

* define module id for treasury in crowdfund.rs

* crodfund builds without issue

* remove commented out code

* switch crowdfund  to configurable moduleid

* test-runtime passing

* trivial syntax

* add module id to mock

* Update `Cargo.lock`

Co-authored-by: zeke <[email protected]>
sorpaas pushed a commit that referenced this pull request Nov 20, 2020
* transition treasury to configurable moduleids

* make election module id configurable

* convert runtime and pallet to accept module id config elections-phragmen

* add ModuleId to evm pallet

* change society pallet to configurable module id

* delete commented out module_id

* delete commented out code and merge in upstream  master

* try and convert 4 whitespace to tab

* fix remaining space to tab conversions

* trivial cleaning

* delete comment from elections-phragrems tests

* trivial

* Update frame/elections-phragmen/src/lib.rs

* add docs for elections and elections phragmen

* make has_lock test get moduleid dynamically

* Apply suggestions from code review

Co-Authored-By: Amar Singh <[email protected]>

* make sure get is imported to evm

Co-authored-by: Shawn Tabrizi <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
Co-authored-by: Amar Singh <[email protected]>
Co-authored-by: Benjamin Kampmann <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MODULE_ID should be configurable
7 participants