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

Decouple the session validators from im-online #7127

Merged

Conversation

liuchengxu
Copy link
Contributor

@liuchengxu liuchengxu commented Sep 17, 2020

This PR decouples the session validators from im-online pallet, so that the user of im-online pallet can pass any specific validator list that are ought to be online, particularly useful for the projects having their own staking logic like ChainX.

Fixes #7124

@liuchengxu
Copy link
Contributor Author

Ping @andresilva @bkchr @tomusdrw

Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

IMHO the decoupling is incomplete and may cause more harm than good in it's current form.

frame/im-online/src/lib.rs Outdated Show resolved Hide resolved
Add ValidatorId in im-online Trait

Make im-online compile

Make substrate binary compile
Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

I like the direction it's going to.
Couple of suggestions:

  1. Merge ValidatorSet and SessionInterface. I think the session_index and ValidatorSet must stay tightly coupled.
  2. Add extra implementation docs to the join ValidatorSet trait. AFAIU the validators() can only return different values in case the session_index() changes as well. This stills also have to be coupled with on_before_session_ending callbacks. I.e. session_index() must change after each on_before_session_ending and therefor validators() may change as well.
  3. Implement the joint ValidatorSet trait in pallet_session, so that you can do type ValidatorSet = Session instead of implementing these extra traits for the entire runtime.
  4. Remove pallet-session from im-online/Cargo.toml (or move it to dev-dependencies).

@liuchengxu liuchengxu force-pushed the make-im-online-validator-set-flexiable branch 9 times, most recently from baf5e4e to 2f87b4a Compare September 25, 2020 03:53
Wrap a few too long lines

Add some docs
@liuchengxu liuchengxu force-pushed the make-im-online-validator-set-flexiable branch from 2f87b4a to db2d1a4 Compare September 25, 2020 03:57
@liuchengxu
Copy link
Contributor Author

@tomusdrw I have merged ValidatorSet into SessionInterface trait. Since it's not allowed to use frame dep in primitives, I moved ValidatorIdentification trait into a new pallet-sesion-common pallet, but not sure it's a good choice, I can also put it into session pallet. Please have another review before I continue this PR.

@bkchr
Copy link
Member

bkchr commented Feb 1, 2021

@liuchengxu could you please merge master to this pr and your companion?

@liuchengxu
Copy link
Contributor Author

@bkchr Done.

@bkchr
Copy link
Member

bkchr commented Feb 1, 2021

@liuchengxu you did not update your companion pr :D Sorry for the complex process 🙈

@liuchengxu
Copy link
Contributor Author

@bkchr I'm pretty sure I have updated the companion paritytech/polkadot@08c14e7 :), the companion just needs approval IMO.

@bkchr
Copy link
Member

bkchr commented Feb 1, 2021

Ahh had overseen this! However the pr is not building, I started the build another time to maybe catch some misalignment between the updates. Otherwise please fix the pr. Ty :) You can see the status here in gitlab-check-polkadot-companion-build

@liuchengxu
Copy link
Contributor Author

Hi @bkchr gitlab-check-polkadot-companion-build is green now, and gitlab-check-polkadot-companion-status says polkadot pr #1865 not APPROVED.

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 :)

@bkchr
Copy link
Member

bkchr commented Feb 2, 2021

bot merge

@ghost
Copy link

ghost commented Feb 2, 2021

The PR is currently unmergeable.

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.

Sorry for never have looked over this, but here are really some changes that need to be done. Most of the stuff is also relative straightforward.

Some general comments. You should not bring FRAME concepts to the primitive crates and comments above traits should also be as much as possible generic. This mean, do not mention any particular pallet or whatever.

And again, sorry! If you have done these changes, I will merge this right away!

frame/im-online/src/lib.rs Outdated Show resolved Hide resolved
frame/im-online/src/lib.rs Outdated Show resolved Hide resolved
primitives/session/src/lib.rs Outdated Show resolved Hide resolved
primitives/session/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 129 to 131
/// Returns all the validators ought to be online in a session.
///
/// The returned validators are all expected to be running an authority node.
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
/// Returns all the validators ought to be online in a session.
///
/// The returned validators are all expected to be running an authority node.
/// Returns the active set of validators.

primitives/session/src/lib.rs Outdated Show resolved Hide resolved
}

/// A session handler for specific key type.
pub trait OneSessionHandler<ValidatorId>: BoundToRuntimeAppPublic {
Copy link
Member

Choose a reason for hiding this comment

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

All these 3 traits here are frame specific. Please move them to frame-support. They do not belong here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bkchr Please have another look, hopefully, I have applied all the suggestions, let me know if I miss anything.

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.

Ty for the fast integration!

@bkchr
Copy link
Member

bkchr commented Feb 2, 2021

bot merge

@ghost
Copy link

ghost commented Feb 2, 2021

Waiting for commit status.

@ghost
Copy link

ghost commented Feb 2, 2021

Head SHA changed; merge aborted.

@bkchr
Copy link
Member

bkchr commented Feb 2, 2021

bot merge

@ghost
Copy link

ghost commented Feb 2, 2021

Waiting for commit status.

@ghost ghost merged commit 075796f into paritytech:master Feb 2, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decouple the session validators from im-online pallet
8 participants