-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix tracking validator set in ImOnline #3596
Conversation
core/sr-primitives/src/testing.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl PartialOrd for UintAuthorityId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHy not just auto derive it?
core/sr-primitives/src/testing.rs
Outdated
| } | ||
| } | ||
|
|
||
| impl Ord for UintAuthorityId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
Co-Authored-By: Bastian Köcher <[email protected]>
… into td-imonline-session
srml/im-online/src/tests.rs
Outdated
| }; | ||
| let signature = id.sign(&heartbeat.encode()).unwrap(); | ||
|
|
||
| // when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // when |
srml/im-online/src/tests.rs
Outdated
| assert!(!ImOnline::is_online_in_current_session(0)); | ||
|
|
||
| // when | ||
| heartbeat(block, 2, 0, 1.into()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get how in block 1 session_index = 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I changed the code a bit but my question still holds)
(I am aware of the buffering and that we need one extra rotate_session to write the buffered validators)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Session rotations are independent of blocks. In regular node-runtime that would never happen though.
|
|
||
| assert_eq!(Session::current_index(), 2); | ||
| // TODO: hmmm... | ||
| assert_eq!(Session::validators(), vec![1, 2, 3]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? I was expecting all 6 of them to get buffered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first time you call advance_session we switch to:
current(vec![]), queued(vec![1, 2, 3])
second time you call advance_session we switch to:
current(vec![1, 2, 3]), queued(vec![1,...6]))
Initially both current and queued are empty.
kianenigma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added another small test, one should probably add a LOT more in a separate PR; looks good as-is to be merged and fix a potentially critical issue.
srml/im-online/src/tests.rs
Outdated
| advance_session(); | ||
|
|
||
| assert_eq!(Session::current_index(), 2); | ||
| // TODO: hmmm... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this ToDo forgotten here? If not a follow-up ticket or a better explanation would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, it was addressed by this comment: #3596 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, my bad. I should have just asked the question. Writing to TODO was maybe too much :D
|
Everything fixed now, should be good to go. |
* Use session::validators instead of staking::current_elected * Basic test framework. * Initialize validators, attempt to heartbeat. * Use dummy crypto for im-online testing. * Remove printlns. * Finish test, make it invalid. * Add reporting test. * Finalize the test. * Remove dumbness. * Updates. * Update AuRa * Update srml/im-online/src/tests.rs Co-Authored-By: Bastian Köcher <[email protected]> * Derive Ord * Add some more tests. * Remove stray todo. * Bump runtime version. * Bump impl-trait-for-tuples. * Enforce new version of trait-for-tuples.
* Use session::validators instead of staking::current_elected * Basic test framework. * Initialize validators, attempt to heartbeat. * Use dummy crypto for im-online testing. * Remove printlns. * Finish test, make it invalid. * Add reporting test. * Finalize the test. * Remove dumbness. * Updates. * Update AuRa * Update srml/im-online/src/tests.rs Co-Authored-By: Bastian Köcher <[email protected]> * Derive Ord * Add some more tests. * Remove stray todo. * Bump runtime version. * Bump impl-trait-for-tuples. * Enforce new version of trait-for-tuples.
* Use session::validators instead of staking::current_elected * Basic test framework. * Initialize validators, attempt to heartbeat. * Use dummy crypto for im-online testing. * Remove printlns. * Finish test, make it invalid. * Add reporting test. * Finalize the test. * Remove dumbness. * Updates. * Update AuRa * Update srml/im-online/src/tests.rs Co-Authored-By: Bastian Köcher <[email protected]> * Derive Ord * Add some more tests. * Remove stray todo. * Bump runtime version. * Bump impl-trait-for-tuples. * Enforce new version of trait-for-tuples.
Resolves #3553
Currently
im-onlineis using (indirectly)staking::current_elected_setto get the validators and report those who didn't send aHeartbeat.That's incorrect, since
sessionis buffering the keys (and validator set changes). In this PR we useSession::validatorsinstead, which allows us to get rid of the extra associated type.im-onlinemodule.stakingAppKey).UintAuthorityIdmore usable in tests.Polkadot PR: #429