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
a91b117c
Unverified
Commit
a91b117c
authored
Aug 17, 2020
by
Andronik Ordian
Committed by
GitHub
Aug 17, 2020
Browse files
move AssignmentKind and CoreAssigment to scheduler (#1571)
parent
c61d9076
Pipeline
#104080
canceled with stages
in 5 minutes and 52 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
node/subsystem/src/messages.rs
View file @
a91b117c
...
...
@@ -33,7 +33,7 @@ use polkadot_node_primitives::{
use
polkadot_primitives
::
v1
::{
AvailableData
,
BackedCandidate
,
BlockNumber
,
CandidateDescriptor
,
CandidateEvent
,
CandidateReceipt
,
CollatorId
,
CommittedCandidateReceipt
,
CoreAssignment
,
CoreOccupied
,
CoreState
,
ErasureChunk
,
GlobalValidationData
,
GroupRotationInfo
,
CoreState
,
ErasureChunk
,
GlobalValidationData
,
GroupRotationInfo
,
Hash
,
Id
as
ParaId
,
LocalValidationData
,
OccupiedCoreAssumption
,
OmittedValidationData
,
PoV
,
SessionIndex
,
SignedAvailabilityBitfield
,
ValidationCode
,
ValidatorId
,
ValidatorIndex
,
ValidatorSignature
,
...
...
@@ -345,19 +345,6 @@ impl ChainApiMessage {
}
}
/// The information on scheduler assignments that some somesystems may be querying.
#[derive(Debug,
Clone)]
pub
struct
SchedulerRoster
{
/// Validator-to-groups assignments.
pub
validator_groups
:
Vec
<
Vec
<
ValidatorIndex
>>
,
/// All scheduled paras.
pub
scheduled
:
Vec
<
CoreAssignment
>
,
/// Upcoming paras (chains and threads).
pub
upcoming
:
Vec
<
ParaId
>
,
/// Occupied cores.
pub
availability_cores
:
Vec
<
Option
<
CoreOccupied
>>
,
}
/// A sender for the result of a runtime API request.
pub
type
RuntimeApiSender
<
T
>
=
oneshot
::
Sender
<
Result
<
T
,
crate
::
errors
::
RuntimeApiError
>>
;
...
...
primitives/src/v1.rs
View file @
a91b117c
...
...
@@ -434,53 +434,6 @@ pub enum CoreOccupied {
Parachain
,
}
/// The assignment type.
#[derive(Clone,
Encode,
Decode)]
#[cfg_attr(feature
=
"std"
,
derive(PartialEq,
Debug))]
pub
enum
AssignmentKind
{
/// A parachain.
Parachain
,
/// A parathread.
Parathread
(
CollatorId
,
u32
),
}
/// How a free core is scheduled to be assigned.
#[derive(Clone,
Encode,
Decode)]
#[cfg_attr(feature
=
"std"
,
derive(PartialEq,
Debug))]
pub
struct
CoreAssignment
{
/// The core that is assigned.
pub
core
:
CoreIndex
,
/// The unique ID of the para that is assigned to the core.
pub
para_id
:
Id
,
/// The kind of the assignment.
pub
kind
:
AssignmentKind
,
/// The index of the validator group assigned to the core.
pub
group_idx
:
GroupIndex
,
}
impl
CoreAssignment
{
/// Get the ID of a collator who is required to collate this block.
pub
fn
required_collator
(
&
self
)
->
Option
<&
CollatorId
>
{
match
self
.kind
{
AssignmentKind
::
Parachain
=>
None
,
AssignmentKind
::
Parathread
(
ref
id
,
_
)
=>
Some
(
id
),
}
}
/// Get the `CoreOccupied` from this.
pub
fn
to_core_occupied
(
&
self
)
->
CoreOccupied
{
match
self
.kind
{
AssignmentKind
::
Parachain
=>
CoreOccupied
::
Parachain
,
AssignmentKind
::
Parathread
(
ref
collator
,
retries
)
=>
CoreOccupied
::
Parathread
(
ParathreadEntry
{
claim
:
ParathreadClaim
(
self
.para_id
,
collator
.clone
()),
retries
,
}
),
}
}
}
/// Validation data omitted from most candidate descriptor structs, as it can be derived from the
/// relay-parent.
#[derive(Clone,
Encode,
Decode)]
...
...
runtime/parachains/src/inclusion.rs
View file @
a91b117c
...
...
@@ -25,7 +25,7 @@ use primitives::v1::{
validation_data_hash
,
ValidatorId
,
CandidateCommitments
,
CandidateDescriptor
,
ValidatorIndex
,
Id
as
ParaId
,
AvailabilityBitfield
as
AvailabilityBitfield
,
SignedAvailabilityBitfields
,
SigningContext
,
BackedCandidate
,
CoreIndex
,
GroupIndex
,
CoreAssignment
,
CommittedCandidateReceipt
,
BackedCandidate
,
CoreIndex
,
GroupIndex
,
CommittedCandidateReceipt
,
CandidateReceipt
,
HeadData
,
};
use
frame_support
::{
...
...
@@ -37,7 +37,7 @@ use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use
sp_staking
::
SessionIndex
;
use
sp_runtime
::{
DispatchError
,
traits
::{
One
,
Saturating
}};
use
crate
::{
configuration
,
paras
};
use
crate
::{
configuration
,
paras
,
scheduler
::
CoreAssignment
};
/// A bitfield signed by a validator indicating that it is keeping its piece of the erasure-coding
/// for any backed candidates referred to by a `1` bit available.
...
...
@@ -668,7 +668,6 @@ mod tests {
use
primitives
::
v1
::{
SignedAvailabilityBitfield
,
CompactStatement
as
Statement
,
ValidityAttestation
,
CollatorId
,
CandidateCommitments
,
SignedStatement
,
CandidateDescriptor
,
ValidationCode
,
AssignmentKind
,
};
use
frame_support
::
traits
::{
OnFinalize
,
OnInitialize
};
use
keyring
::
Sr25519Keyring
;
...
...
@@ -680,6 +679,7 @@ mod tests {
use
crate
::
initializer
::
SessionChangeNotification
;
use
crate
::
configuration
::
HostConfiguration
;
use
crate
::
paras
::
ParaGenesisArgs
;
use
crate
::
scheduler
::
AssignmentKind
;
fn
default_config
()
->
HostConfiguration
<
BlockNumber
>
{
let
mut
config
=
HostConfiguration
::
default
();
...
...
runtime/parachains/src/scheduler.rs
View file @
a91b117c
...
...
@@ -38,7 +38,7 @@
use
sp_std
::
prelude
::
*
;
use
sp_std
::
convert
::
TryInto
;
use
primitives
::
v1
::{
Id
as
ParaId
,
ValidatorIndex
,
CoreAssignment
,
CoreOccupied
,
CoreIndex
,
AssignmentKin
d
,
Id
as
ParaId
,
ValidatorIndex
,
CoreOccupied
,
CoreIndex
,
CollatorI
d
,
GroupIndex
,
ParathreadClaim
,
ParathreadEntry
,
GroupRotationInfo
,
ScheduledCore
,
};
use
frame_support
::{
...
...
@@ -105,6 +105,54 @@ pub enum FreedReason {
TimedOut
,
}
/// The assignment type.
#[derive(Clone,
Encode,
Decode)]
#[cfg_attr(feature
=
"std"
,
derive(PartialEq,
Debug))]
pub
enum
AssignmentKind
{
/// A parachain.
Parachain
,
/// A parathread.
Parathread
(
CollatorId
,
u32
),
}
/// How a free core is scheduled to be assigned.
#[derive(Clone,
Encode,
Decode)]
#[cfg_attr(feature
=
"std"
,
derive(PartialEq,
Debug))]
pub
struct
CoreAssignment
{
/// The core that is assigned.
pub
core
:
CoreIndex
,
/// The unique ID of the para that is assigned to the core.
pub
para_id
:
ParaId
,
/// The kind of the assignment.
pub
kind
:
AssignmentKind
,
/// The index of the validator group assigned to the core.
pub
group_idx
:
GroupIndex
,
}
impl
CoreAssignment
{
/// Get the ID of a collator who is required to collate this block.
pub
fn
required_collator
(
&
self
)
->
Option
<&
CollatorId
>
{
match
self
.kind
{
AssignmentKind
::
Parachain
=>
None
,
AssignmentKind
::
Parathread
(
ref
id
,
_
)
=>
Some
(
id
),
}
}
/// Get the `CoreOccupied` from this.
pub
fn
to_core_occupied
(
&
self
)
->
CoreOccupied
{
match
self
.kind
{
AssignmentKind
::
Parachain
=>
CoreOccupied
::
Parachain
,
AssignmentKind
::
Parathread
(
ref
collator
,
retries
)
=>
CoreOccupied
::
Parathread
(
ParathreadEntry
{
claim
:
ParathreadClaim
(
self
.para_id
,
collator
.clone
()),
retries
,
}
),
}
}
}
pub
trait
Trait
:
frame_system
::
Trait
+
configuration
::
Trait
+
paras
::
Trait
{
}
decl_storage!
{
...
...
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