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
9b5a6560
Commit
9b5a6560
authored
Mar 10, 2021
by
Cecile Tonglet
Browse files
Merge commit
95b2e18e
(no conflict)
parents
d5e196f4
95b2e18e
Pipeline
#127718
failed with stages
in 7 minutes and 11 seconds
Changes
50
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
9b5a6560
This diff is collapsed.
Click to expand it.
bridges/bin/millau/runtime/src/lib.rs
View file @
9b5a6560
...
@@ -458,7 +458,7 @@ impl_runtime_apis! {
...
@@ -458,7 +458,7 @@ impl_runtime_apis! {
}
}
fn
random_seed
()
->
<
Block
as
BlockT
>
::
Hash
{
fn
random_seed
()
->
<
Block
as
BlockT
>
::
Hash
{
RandomnessCollectiveFlip
::
random_seed
()
RandomnessCollectiveFlip
::
random_seed
()
.0
}
}
}
}
...
...
bridges/bin/rialto/runtime/src/lib.rs
View file @
9b5a6560
...
@@ -569,7 +569,7 @@ impl_runtime_apis! {
...
@@ -569,7 +569,7 @@ impl_runtime_apis! {
}
}
fn
random_seed
()
->
<
Block
as
BlockT
>
::
Hash
{
fn
random_seed
()
->
<
Block
as
BlockT
>
::
Hash
{
RandomnessCollectiveFlip
::
random_seed
()
RandomnessCollectiveFlip
::
random_seed
()
.0
}
}
}
}
...
...
node/collation-generation/src/lib.rs
View file @
9b5a6560
...
@@ -46,7 +46,7 @@ use std::sync::Arc;
...
@@ -46,7 +46,7 @@ use std::sync::Arc;
mod
error
;
mod
error
;
const
LOG_TARGET
:
&
'static
str
=
"collation
_
generation"
;
const
LOG_TARGET
:
&
'static
str
=
"
parachain::
collation
-
generation"
;
/// Collation Generation Subsystem
/// Collation Generation Subsystem
pub
struct
CollationGenerationSubsystem
{
pub
struct
CollationGenerationSubsystem
{
...
...
node/core/approval-voting/Cargo.toml
View file @
9b5a6560
...
@@ -17,7 +17,8 @@ kvdb = "0.9.0"
...
@@ -17,7 +17,8 @@ kvdb = "0.9.0"
kvdb-rocksdb
=
"0.11.0"
kvdb-rocksdb
=
"0.11.0"
derive_more
=
"0.99.1"
derive_more
=
"0.99.1"
polkadot-subsystem
=
{
package
=
"polkadot-node-subsystem"
,
path
=
"../../subsystem"
}
polkadot-node-subsystem
=
{
path
=
"../../subsystem"
}
polkadot-node-subsystem-util
=
{
path
=
"../../subsystem-util"
}
polkadot-overseer
=
{
path
=
"../../overseer"
}
polkadot-overseer
=
{
path
=
"../../overseer"
}
polkadot-primitives
=
{
path
=
"../../../primitives"
}
polkadot-primitives
=
{
path
=
"../../../primitives"
}
polkadot-node-primitives
=
{
path
=
"../../primitives"
}
polkadot-node-primitives
=
{
path
=
"../../primitives"
}
...
...
node/core/approval-voting/src/import.rs
View file @
9b5a6560
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
//!
//!
//! We maintain a rolling window of session indices. This starts as empty
//! We maintain a rolling window of session indices. This starts as empty
use
polkadot_subsystem
::{
use
polkadot_
node_
subsystem
::{
messages
::{
messages
::{
RuntimeApiMessage
,
RuntimeApiRequest
,
ChainApiMessage
,
ApprovalDistributionMessage
,
RuntimeApiMessage
,
RuntimeApiRequest
,
ChainApiMessage
,
ApprovalDistributionMessage
,
},
},
...
@@ -708,10 +708,12 @@ mod tests {
...
@@ -708,10 +708,12 @@ mod tests {
use
polkadot_node_subsystem_test_helpers
::
make_subsystem_context
;
use
polkadot_node_subsystem_test_helpers
::
make_subsystem_context
;
use
polkadot_node_primitives
::
approval
::{
VRFOutput
,
VRFProof
};
use
polkadot_node_primitives
::
approval
::{
VRFOutput
,
VRFProof
};
use
polkadot_primitives
::
v1
::
ValidatorIndex
;
use
polkadot_primitives
::
v1
::
ValidatorIndex
;
use
polkadot_subsystem
::
messages
::
AllMessages
;
use
polkadot_
node_
subsystem
::
messages
::
AllMessages
;
use
sp_core
::
testing
::
TaskExecutor
;
use
sp_core
::
testing
::
TaskExecutor
;
use
sp_runtime
::{
Digest
,
DigestItem
};
use
sp_runtime
::{
Digest
,
DigestItem
};
use
sp_consensus_babe
::
Epoch
as
BabeEpoch
;
use
sp_consensus_babe
::{
Epoch
as
BabeEpoch
,
BabeEpochConfiguration
,
AllowedSlots
,
};
use
sp_consensus_babe
::
digests
::{
CompatibleDigestItem
,
PreDigest
,
SecondaryVRFPreDigest
};
use
sp_consensus_babe
::
digests
::{
CompatibleDigestItem
,
PreDigest
,
SecondaryVRFPreDigest
};
use
sp_keyring
::
sr25519
::
Keyring
as
Sr25519Keyring
;
use
sp_keyring
::
sr25519
::
Keyring
as
Sr25519Keyring
;
use
assert_matches
::
assert_matches
;
use
assert_matches
::
assert_matches
;
...
@@ -1358,6 +1360,10 @@ mod tests {
...
@@ -1358,6 +1360,10 @@ mod tests {
duration
:
200
,
duration
:
200
,
authorities
:
vec!
[(
Sr25519Keyring
::
Alice
.public
()
.into
(),
1
)],
authorities
:
vec!
[(
Sr25519Keyring
::
Alice
.public
()
.into
(),
1
)],
randomness
:
[
0u8
;
32
],
randomness
:
[
0u8
;
32
],
config
:
BabeEpochConfiguration
{
c
:
(
1
,
4
),
allowed_slots
:
AllowedSlots
::
PrimarySlots
,
},
}));
}));
}
}
);
);
...
@@ -1463,6 +1469,10 @@ mod tests {
...
@@ -1463,6 +1469,10 @@ mod tests {
duration
:
200
,
duration
:
200
,
authorities
:
vec!
[(
Sr25519Keyring
::
Alice
.public
()
.into
(),
1
)],
authorities
:
vec!
[(
Sr25519Keyring
::
Alice
.public
()
.into
(),
1
)],
randomness
:
[
0u8
;
32
],
randomness
:
[
0u8
;
32
],
config
:
BabeEpochConfiguration
{
c
:
(
1
,
4
),
allowed_slots
:
AllowedSlots
::
PrimarySlots
,
},
}));
}));
}
}
);
);
...
@@ -1714,6 +1724,10 @@ mod tests {
...
@@ -1714,6 +1724,10 @@ mod tests {
duration
:
200
,
duration
:
200
,
authorities
:
vec!
[(
Sr25519Keyring
::
Alice
.public
()
.into
(),
1
)],
authorities
:
vec!
[(
Sr25519Keyring
::
Alice
.public
()
.into
(),
1
)],
randomness
:
[
0u8
;
32
],
randomness
:
[
0u8
;
32
],
config
:
BabeEpochConfiguration
{
c
:
(
1
,
4
),
allowed_slots
:
AllowedSlots
::
PrimarySlots
,
},
}));
}));
}
}
);
);
...
...
node/core/approval-voting/src/lib.rs
View file @
9b5a6560
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
//! of others. It uses this information to determine when candidates and blocks have
//! of others. It uses this information to determine when candidates and blocks have
//! been sufficiently approved to finalize.
//! been sufficiently approved to finalize.
use
polkadot_subsystem
::{
use
polkadot_
node_
subsystem
::{
messages
::{
messages
::{
AssignmentCheckResult
,
ApprovalCheckResult
,
ApprovalVotingMessage
,
AssignmentCheckResult
,
ApprovalCheckResult
,
ApprovalVotingMessage
,
RuntimeApiMessage
,
RuntimeApiRequest
,
ChainApiMessage
,
ApprovalDistributionMessage
,
RuntimeApiMessage
,
RuntimeApiRequest
,
ChainApiMessage
,
ApprovalDistributionMessage
,
...
@@ -31,6 +31,9 @@ use polkadot_subsystem::{
...
@@ -31,6 +31,9 @@ use polkadot_subsystem::{
Subsystem
,
SubsystemContext
,
SubsystemError
,
SubsystemResult
,
SpawnedSubsystem
,
Subsystem
,
SubsystemContext
,
SubsystemError
,
SubsystemResult
,
SpawnedSubsystem
,
FromOverseer
,
OverseerSignal
,
FromOverseer
,
OverseerSignal
,
};
};
use
polkadot_node_subsystem_util
::{
metrics
::{
self
,
prometheus
},
};
use
polkadot_primitives
::
v1
::{
use
polkadot_primitives
::
v1
::{
ValidatorIndex
,
Hash
,
SessionIndex
,
SessionInfo
,
CandidateHash
,
ValidatorIndex
,
Hash
,
SessionIndex
,
SessionInfo
,
CandidateHash
,
CandidateReceipt
,
BlockNumber
,
PersistedValidationData
,
CandidateReceipt
,
BlockNumber
,
PersistedValidationData
,
...
@@ -72,7 +75,7 @@ mod persisted_entries;
...
@@ -72,7 +75,7 @@ mod persisted_entries;
mod
tests
;
mod
tests
;
const
APPROVAL_SESSIONS
:
SessionIndex
=
6
;
const
APPROVAL_SESSIONS
:
SessionIndex
=
6
;
const
LOG_TARGET
:
&
str
=
"approval
_
voting"
;
const
LOG_TARGET
:
&
str
=
"
parachain::
approval
-
voting"
;
/// Configuration for the approval voting subsystem
/// Configuration for the approval voting subsystem
pub
struct
Config
{
pub
struct
Config
{
...
@@ -94,15 +97,79 @@ pub struct ApprovalVotingSubsystem {
...
@@ -94,15 +97,79 @@ pub struct ApprovalVotingSubsystem {
keystore
:
Arc
<
LocalKeystore
>
,
keystore
:
Arc
<
LocalKeystore
>
,
slot_duration_millis
:
u64
,
slot_duration_millis
:
u64
,
db
:
Arc
<
dyn
KeyValueDB
>
,
db
:
Arc
<
dyn
KeyValueDB
>
,
metrics
:
Metrics
,
}
#[derive(Clone)]
struct
MetricsInner
{
imported_candidates_total
:
prometheus
::
Counter
<
prometheus
::
U64
>
,
assignments_produced_total
:
prometheus
::
Counter
<
prometheus
::
U64
>
,
approvals_produced_total
:
prometheus
::
Counter
<
prometheus
::
U64
>
,
}
/// Aproval Voting metrics.
#[derive(Default,
Clone)]
pub
struct
Metrics
(
Option
<
MetricsInner
>
);
impl
Metrics
{
fn
on_candidate_imported
(
&
self
)
{
if
let
Some
(
metrics
)
=
&
self
.0
{
metrics
.imported_candidates_total
.inc
();
}
}
fn
on_assignment_produced
(
&
self
)
{
if
let
Some
(
metrics
)
=
&
self
.0
{
metrics
.assignments_produced_total
.inc
();
}
}
fn
on_approval_produced
(
&
self
)
{
if
let
Some
(
metrics
)
=
&
self
.0
{
metrics
.approvals_produced_total
.inc
();
}
}
}
impl
metrics
::
Metrics
for
Metrics
{
fn
try_register
(
registry
:
&
prometheus
::
Registry
,
)
->
std
::
result
::
Result
<
Self
,
prometheus
::
PrometheusError
>
{
let
metrics
=
MetricsInner
{
imported_candidates_total
:
prometheus
::
register
(
prometheus
::
Counter
::
new
(
"parachain_imported_candidates_total"
,
"Number of candidates imported by the approval voting subsystem"
,
)
?
,
registry
,
)
?
,
assignments_produced_total
:
prometheus
::
register
(
prometheus
::
Counter
::
new
(
"parachain_assignments_produced_total"
,
"Number of assignments produced by the approval voting subsystem"
,
)
?
,
registry
,
)
?
,
approvals_produced_total
:
prometheus
::
register
(
prometheus
::
Counter
::
new
(
"parachain_approvals_produced_total"
,
"Number of approvals produced by the approval voting subsystem"
,
)
?
,
registry
,
)
?
,
};
Ok
(
Metrics
(
Some
(
metrics
)))
}
}
}
impl
ApprovalVotingSubsystem
{
impl
ApprovalVotingSubsystem
{
/// Create a new approval voting subsystem with the given keystore
, slot duration
,
/// Create a new approval voting subsystem with the given keystore
and config
,
/// which creates a DB at the given path. This function will delete the directory
/// which creates a DB at the given path. This function will delete the directory
/// at the given path if it already exists.
/// at the given path if it already exists.
pub
fn
with_config
(
pub
fn
with_config
(
config
:
Config
,
config
:
Config
,
keystore
:
Arc
<
LocalKeystore
>
,
keystore
:
Arc
<
LocalKeystore
>
,
metrics
:
Metrics
,
)
->
std
::
io
::
Result
<
Self
>
{
)
->
std
::
io
::
Result
<
Self
>
{
const
DEFAULT_CACHE_SIZE
:
usize
=
100
*
1024
*
1024
;
// 100MiB default should be fine unless finality stalls.
const
DEFAULT_CACHE_SIZE
:
usize
=
100
*
1024
*
1024
;
// 100MiB default should be fine unless finality stalls.
...
@@ -115,6 +182,7 @@ impl ApprovalVotingSubsystem {
...
@@ -115,6 +182,7 @@ impl ApprovalVotingSubsystem {
keystore
,
keystore
,
slot_duration_millis
:
config
.slot_duration_millis
,
slot_duration_millis
:
config
.slot_duration_millis
,
db
,
db
,
metrics
,
})
})
}
}
}
}
...
@@ -343,6 +411,7 @@ async fn run<C>(
...
@@ -343,6 +411,7 @@ async fn run<C>(
handle_from_overseer
(
handle_from_overseer
(
&
mut
ctx
,
&
mut
ctx
,
&
mut
state
,
&
mut
state
,
&
subsystem
.metrics
,
db_writer
,
db_writer
,
next_msg
?
,
next_msg
?
,
&
mut
last_finalized_height
,
&
mut
last_finalized_height
,
...
@@ -353,6 +422,7 @@ async fn run<C>(
...
@@ -353,6 +422,7 @@ async fn run<C>(
handle_background_request
(
handle_background_request
(
&
mut
ctx
,
&
mut
ctx
,
&
mut
state
,
&
mut
state
,
&
subsystem
.metrics
,
req
,
req
,
)
.await
?
)
.await
?
}
else
{
}
else
{
...
@@ -363,6 +433,7 @@ async fn run<C>(
...
@@ -363,6 +433,7 @@ async fn run<C>(
if
handle_actions
(
if
handle_actions
(
&
mut
ctx
,
&
mut
ctx
,
&
subsystem
.metrics
,
&
mut
wakeups
,
&
mut
wakeups
,
db_writer
,
db_writer
,
&
background_tx
,
&
background_tx
,
...
@@ -378,6 +449,7 @@ async fn run<C>(
...
@@ -378,6 +449,7 @@ async fn run<C>(
// returns `true` if any of the actions was a `Conclude` command.
// returns `true` if any of the actions was a `Conclude` command.
async
fn
handle_actions
(
async
fn
handle_actions
(
ctx
:
&
mut
impl
SubsystemContext
,
ctx
:
&
mut
impl
SubsystemContext
,
metrics
:
&
Metrics
,
wakeups
:
&
mut
Wakeups
,
wakeups
:
&
mut
Wakeups
,
db
:
&
dyn
KeyValueDB
,
db
:
&
dyn
KeyValueDB
,
background_tx
:
&
mpsc
::
Sender
<
BackgroundRequest
>
,
background_tx
:
&
mpsc
::
Sender
<
BackgroundRequest
>
,
...
@@ -406,6 +478,7 @@ async fn handle_actions(
...
@@ -406,6 +478,7 @@ async fn handle_actions(
candidate
,
candidate
,
backing_group
,
backing_group
,
}
=>
{
}
=>
{
metrics
.on_assignment_produced
();
let
block_hash
=
indirect_cert
.block_hash
;
let
block_hash
=
indirect_cert
.block_hash
;
let
validator_index
=
indirect_cert
.validator
;
let
validator_index
=
indirect_cert
.validator
;
...
@@ -439,6 +512,7 @@ async fn handle_actions(
...
@@ -439,6 +512,7 @@ async fn handle_actions(
async
fn
handle_from_overseer
(
async
fn
handle_from_overseer
(
ctx
:
&
mut
impl
SubsystemContext
,
ctx
:
&
mut
impl
SubsystemContext
,
state
:
&
mut
State
<
impl
DBReader
>
,
state
:
&
mut
State
<
impl
DBReader
>
,
metrics
:
&
Metrics
,
db_writer
:
&
dyn
KeyValueDB
,
db_writer
:
&
dyn
KeyValueDB
,
x
:
FromOverseer
<
ApprovalVotingMessage
>
,
x
:
FromOverseer
<
ApprovalVotingMessage
>
,
last_finalized_height
:
&
mut
Option
<
BlockNumber
>
,
last_finalized_height
:
&
mut
Option
<
BlockNumber
>
,
...
@@ -468,6 +542,8 @@ async fn handle_from_overseer(
...
@@ -468,6 +542,8 @@ async fn handle_from_overseer(
);
);
for
(
c_hash
,
c_entry
)
in
block_batch
.imported_candidates
{
for
(
c_hash
,
c_entry
)
in
block_batch
.imported_candidates
{
metrics
.on_candidate_imported
();
let
our_tranche
=
c_entry
let
our_tranche
=
c_entry
.approval_entry
(
&
block_batch
.block_hash
)
.approval_entry
(
&
block_batch
.block_hash
)
.and_then
(|
a
|
a
.our_assignment
()
.map
(|
a
|
a
.tranche
()));
.and_then
(|
a
|
a
.our_assignment
()
.map
(|
a
|
a
.tranche
()));
...
@@ -542,11 +618,12 @@ async fn handle_from_overseer(
...
@@ -542,11 +618,12 @@ async fn handle_from_overseer(
async
fn
handle_background_request
(
async
fn
handle_background_request
(
ctx
:
&
mut
impl
SubsystemContext
,
ctx
:
&
mut
impl
SubsystemContext
,
state
:
&
State
<
impl
DBReader
>
,
state
:
&
State
<
impl
DBReader
>
,
metrics
:
&
Metrics
,
request
:
BackgroundRequest
,
request
:
BackgroundRequest
,
)
->
SubsystemResult
<
Vec
<
Action
>>
{
)
->
SubsystemResult
<
Vec
<
Action
>>
{
match
request
{
match
request
{
BackgroundRequest
::
ApprovalVote
(
vote_request
)
=>
{
BackgroundRequest
::
ApprovalVote
(
vote_request
)
=>
{
issue_approval
(
ctx
,
state
,
vote_request
)
.await
issue_approval
(
ctx
,
state
,
metrics
,
vote_request
)
.await
}
}
BackgroundRequest
::
CandidateValidation
(
BackgroundRequest
::
CandidateValidation
(
validation_data
,
validation_data
,
...
@@ -1443,6 +1520,7 @@ async fn launch_approval(
...
@@ -1443,6 +1520,7 @@ async fn launch_approval(
async
fn
issue_approval
(
async
fn
issue_approval
(
ctx
:
&
mut
impl
SubsystemContext
,
ctx
:
&
mut
impl
SubsystemContext
,
state
:
&
State
<
impl
DBReader
>
,
state
:
&
State
<
impl
DBReader
>
,
metrics
:
&
Metrics
,
request
:
ApprovalVoteRequest
,
request
:
ApprovalVoteRequest
,
)
->
SubsystemResult
<
Vec
<
Action
>>
{
)
->
SubsystemResult
<
Vec
<
Action
>>
{
let
ApprovalVoteRequest
{
validator_index
,
block_hash
,
candidate_index
}
=
request
;
let
ApprovalVoteRequest
{
validator_index
,
block_hash
,
candidate_index
}
=
request
;
...
@@ -1541,6 +1619,8 @@ async fn issue_approval(
...
@@ -1541,6 +1619,8 @@ async fn issue_approval(
validator_index
as
_
,
validator_index
as
_
,
)
?
;
)
?
;
metrics
.on_approval_produced
();
// dispatch to approval distribution.
// dispatch to approval distribution.
ctx
.send_message
(
ApprovalDistributionMessage
::
DistributeApproval
(
IndirectSignedApprovalVote
{
ctx
.send_message
(
ApprovalDistributionMessage
::
DistributeApproval
(
IndirectSignedApprovalVote
{
block_hash
,
block_hash
,
...
...
node/core/approval-voting/src/tests.rs
View file @
9b5a6560
...
@@ -21,7 +21,7 @@ use polkadot_node_primitives::approval::{
...
@@ -21,7 +21,7 @@ use polkadot_node_primitives::approval::{
RELAY_VRF_MODULO_CONTEXT
,
DelayTranche
,
RELAY_VRF_MODULO_CONTEXT
,
DelayTranche
,
};
};
use
polkadot_node_subsystem_test_helpers
::
make_subsystem_context
;
use
polkadot_node_subsystem_test_helpers
::
make_subsystem_context
;
use
polkadot_subsystem
::
messages
::
AllMessages
;
use
polkadot_
node_
subsystem
::
messages
::
AllMessages
;
use
sp_core
::
testing
::
TaskExecutor
;
use
sp_core
::
testing
::
TaskExecutor
;
use
parking_lot
::
Mutex
;
use
parking_lot
::
Mutex
;
...
...
node/core/av-store/src/lib.rs
View file @
9b5a6560
...
@@ -49,7 +49,7 @@ use bitvec::{vec::BitVec, order::Lsb0 as BitOrderLsb0};
...
@@ -49,7 +49,7 @@ use bitvec::{vec::BitVec, order::Lsb0 as BitOrderLsb0};
#[cfg(test)]
#[cfg(test)]
mod
tests
;
mod
tests
;
const
LOG_TARGET
:
&
str
=
"availability"
;
const
LOG_TARGET
:
&
str
=
"
parachain::
availability"
;
mod
columns
{
mod
columns
{
pub
const
DATA
:
u32
=
0
;
pub
const
DATA
:
u32
=
0
;
...
...
node/core/backing/src/lib.rs
View file @
9b5a6560
...
@@ -66,7 +66,7 @@ use statement_table::{
...
@@ -66,7 +66,7 @@ use statement_table::{
};
};
use
thiserror
::
Error
;
use
thiserror
::
Error
;
const
LOG_TARGET
:
&
str
=
"candidate
_
backing"
;
const
LOG_TARGET
:
&
str
=
"
parachain::
candidate
-
backing"
;
#[derive(Debug,
Error)]
#[derive(Debug,
Error)]
enum
Error
{
enum
Error
{
...
@@ -197,7 +197,6 @@ fn primitive_statement_to_table(s: &SignedFullStatement) -> TableSignedStatement
...
@@ -197,7 +197,6 @@ fn primitive_statement_to_table(s: &SignedFullStatement) -> TableSignedStatement
let
statement
=
match
s
.payload
()
{
let
statement
=
match
s
.payload
()
{
Statement
::
Seconded
(
c
)
=>
TableStatement
::
Seconded
(
c
.clone
()),
Statement
::
Seconded
(
c
)
=>
TableStatement
::
Seconded
(
c
.clone
()),
Statement
::
Valid
(
h
)
=>
TableStatement
::
Valid
(
h
.clone
()),
Statement
::
Valid
(
h
)
=>
TableStatement
::
Valid
(
h
.clone
()),
Statement
::
Invalid
(
h
)
=>
TableStatement
::
Invalid
(
h
.clone
()),
};
};
TableSignedStatement
{
TableSignedStatement
{
...
@@ -555,15 +554,12 @@ impl CandidateBackingJob {
...
@@ -555,15 +554,12 @@ impl CandidateBackingJob {
ValidatedCandidateCommand
::
Attest
(
res
)
=>
{
ValidatedCandidateCommand
::
Attest
(
res
)
=>
{
// sanity check.
// sanity check.
if
!
self
.issued_statements
.contains
(
&
candidate_hash
)
{
if
!
self
.issued_statements
.contains
(
&
candidate_hash
)
{
let
statement
=
if
res
.is_ok
()
{
if
res
.is_ok
()
{
Statement
::
Valid
(
candidate_hash
)
let
statement
=
Statement
::
Valid
(
candidate_hash
);
}
else
{
Statement
::
Invalid
(
candidate_hash
)
};
self
.issued_statements
.insert
(
candidate_hash
);
self
.sign_import_and_distribute_statement
(
statement
,
&
parent_span
)
.await
?
;
self
.sign_import_and_distribute_statement
(
statement
,
&
parent_span
)
.await
?
;
}
}
self
.issued_statements
.insert
(
candidate_hash
);
}
}
}
}
}
...
@@ -1241,7 +1237,6 @@ mod tests {
...
@@ -1241,7 +1237,6 @@ mod tests {
match
statement
{
match
statement
{
TableStatement
::
Seconded
(
committed_candidate_receipt
)
=>
Statement
::
Seconded
(
committed_candidate_receipt
),
TableStatement
::
Seconded
(
committed_candidate_receipt
)
=>
Statement
::
Seconded
(
committed_candidate_receipt
),
TableStatement
::
Valid
(
candidate_hash
)
=>
Statement
::
Valid
(
candidate_hash
),
TableStatement
::
Valid
(
candidate_hash
)
=>
Statement
::
Valid
(
candidate_hash
),
TableStatement
::
Invalid
(
candidate_hash
)
=>
Statement
::
Invalid
(
candidate_hash
),
}
}
}
}
...
@@ -1883,15 +1878,11 @@ mod tests {
...
@@ -1883,15 +1878,11 @@ mod tests {
}
.build
();
}
.build
();
let
candidate_a_hash
=
candidate_a
.hash
();
let
candidate_a_hash
=
candidate_a
.hash
();
let
public0
=
CryptoStore
::
sr25519_generate_new
(
&*
test_state
.keystore
,
ValidatorId
::
ID
,
Some
(
&
test_state
.validators
[
0
]
.to_seed
())
)
.await
.expect
(
"Insert key into keystore"
);
let
public2
=
CryptoStore
::
sr25519_generate_new
(
let
public2
=
CryptoStore
::
sr25519_generate_new
(
&*
test_state
.keystore
,
&*
test_state
.keystore
,
ValidatorId
::
ID
,
Some
(
&
test_state
.validators
[
2
]
.to_seed
())
ValidatorId
::
ID
,
Some
(
&
test_state
.validators
[
2
]
.to_seed
())
)
.await
.expect
(
"Insert key into keystore"
);
)
.await
.expect
(
"Insert key into keystore"
);
let
s
ign
ed_
a
=
SignedFullStatement
::
sign
(
let
s
econd
ed_
2
=
SignedFullStatement
::
sign
(
&
test_state
.keystore
,
&
test_state
.keystore
,
Statement
::
Seconded
(
candidate_a
.clone
()),
Statement
::
Seconded
(
candidate_a
.clone
()),
&
test_state
.signing_context
,
&
test_state
.signing_context
,
...
@@ -1899,25 +1890,17 @@ mod tests {
...
@@ -1899,25 +1890,17 @@ mod tests {
&
public2
.into
(),
&
public2
.into
(),
)
.await
.ok
()
.flatten
()
.expect
(
"should be signed"
);
)
.await
.ok
()
.flatten
()
.expect
(
"should be signed"
);
let
signe
d_
b
=
SignedFullStatement
::
sign
(
let
vali
d_
2
=
SignedFullStatement
::
sign
(
&
test_state
.keystore
,
&
test_state
.keystore
,
Statement
::
Inv
alid
(
candidate_a_hash
),
Statement
::
V
alid
(
candidate_a_hash
),
&
test_state
.signing_context
,
&
test_state
.signing_context
,
ValidatorIndex
(
2
),
ValidatorIndex
(
2
),
&
public2
.into
(),
&
public2
.into
(),
)
.await
.ok
()
.flatten
()
.expect
(
"should be signed"
);
)
.await
.ok
()
.flatten
()
.expect
(
"should be signed"
);
let
signed_c
=
SignedFullStatement
::
sign
(
let
statement
=
CandidateBackingMessage
::
Statement
(
test_state
.relay_parent
,
seconded_2
.clone
());
&
test_state
.keystore
,
Statement
::
Invalid
(
candidate_a_hash
),
&
test_state
.signing_context
,
ValidatorIndex
(
0
),
&
public0
.into
(),
)
.await
.ok
()
.flatten
()
.expect
(
"should be signed"
);
let
statement
=
CandidateBackingMessage
::
Statement
(
test_state
.relay_parent
,
signed_a
.clone
());
virtual_overseer
.send
(
FromOverseer
::
Communication
{
msg
:
statement
})
.await
;
virtual_overseer
.send
(
FromOverseer
::
Communication
{
msg
:
statement
})
.await
;
assert_matches!
(
assert_matches!
(
virtual_overseer
.recv
()
.await
,
virtual_overseer
.recv
()
.await
,
...
@@ -1976,51 +1959,10 @@ mod tests {
...
@@ -1976,51 +1959,10 @@ mod tests {
}
}
);
);
// This `Invalid` statement contradicts the `Candidate` statement
// This `Valid` statement is redundant after the `Seconded` statement already sent.
// sent at first.
let
statement
=
CandidateBackingMessage
::
Statement
(
test_state
.relay_parent
,
valid_2
.clone
());
let
statement
=
CandidateBackingMessage
::
Statement
(
test_state
.relay_parent
,
signed_b
.clone
());
virtual_overseer
.send
(
FromOverseer
::
Communication
{
msg
:
statement
})
.await
;
virtual_overseer
.send
(
FromOverseer
::
Communication
{
msg
:
statement
})
.await
;
assert_matches!
(
virtual_overseer
.recv
()
.await
,
AllMessages
::
Provisioner
(
ProvisionerMessage
::
ProvisionableData
(
_
,
ProvisionableData
::
MisbehaviorReport
(
relay_parent
,
validator_index
,
Misbehavior
::
ValidityDoubleVote
(
vdv
),
)
)