Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
4d10259d
Unverified
Commit
4d10259d
authored
Dec 10, 2020
by
Andronik Ordian
Committed by
GitHub
Dec 10, 2020
Browse files
session_info: store the assigment ids (#2102)
* session_info: store the assigment ids * how about this?
parent
dca93d01
Pipeline
#116788
failed with stages
in 28 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
runtime/parachains/src/session_info.rs
View file @
4d10259d
...
...
@@ -19,7 +19,7 @@
//!
//! See https://w3f.github.io/parachain-implementers-guide/runtime/session_info.html.
use
primitives
::
v1
::{
AuthorityDiscoveryId
,
SessionIndex
,
SessionInfo
};
use
primitives
::
v1
::{
AssignmentId
,
AuthorityDiscoveryId
,
SessionIndex
,
SessionInfo
};
use
frame_support
::{
decl_storage
,
decl_module
,
decl_error
,
weights
::
Weight
,
...
...
@@ -38,6 +38,10 @@ pub trait Config:
decl_storage!
{
trait
Store
for
Module
<
T
:
Config
>
as
ParaSessionInfo
{
/// Assignment keys for the current session.
/// Note that this API is private due to it being prone to 'off-by-one' at session boundaries.
/// When in doubt, use `Sessions` API instead.
AssignmentKeysUnsafe
:
Vec
<
AssignmentId
>
;
/// The earliest session for which previous session info is stored.
EarliestStoredSession
get
(
fn
earliest_stored_session
):
SessionIndex
;
/// Session information in a rolling window.
...
...
@@ -83,7 +87,8 @@ impl<T: Config> Module<T> {
let
validators
=
notification
.validators
.clone
();
let
discovery_keys
=
<
T
as
AuthorityDiscoveryConfig
>
::
authorities
();
// FIXME: once we store these keys: https://github.com/paritytech/polkadot/issues/1975
let
_assignment_keys
=
AssignmentKeysUnsafe
::
get
();
// FIXME: remove this once https://github.com/paritytech/polkadot/pull/2092 is merged
let
approval_keys
=
Default
::
default
();
let
validator_groups
=
<
scheduler
::
Module
<
T
>>
::
validator_groups
();
let
n_cores
=
n_parachains
+
config
.parathread_cores
;
...
...
@@ -132,6 +137,29 @@ impl<T: Config> Module<T> {
pub
(
crate
)
fn
initializer_finalize
()
{}
}
impl
<
T
:
Config
>
sp_runtime
::
BoundToRuntimeAppPublic
for
Module
<
T
>
{
type
Public
=
AssignmentId
;
}
impl
<
T
:
pallet_session
::
Config
+
Config
>
pallet_session
::
OneSessionHandler
<
T
::
AccountId
>
for
Module
<
T
>
{
type
Key
=
AssignmentId
;
fn
on_genesis_session
<
'a
,
I
:
'a
>
(
_validators
:
I
)
where
I
:
Iterator
<
Item
=
(
&
'a
T
::
AccountId
,
Self
::
Key
)
>
{
}
fn
on_new_session
<
'a
,
I
:
'a
>
(
_changed
:
bool
,
validators
:
I
,
_queued
:
I
)
where
I
:
Iterator
<
Item
=
(
&
'a
T
::
AccountId
,
Self
::
Key
)
>
{
let
assignment_keys
:
Vec
<
_
>
=
validators
.map
(|(
_
,
v
)|
v
)
.collect
();
AssignmentKeysUnsafe
::
set
(
assignment_keys
);
}
fn
on_disabled
(
_i
:
usize
)
{
}
}
#[cfg(test)]
mod
tests
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment