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
16f69cba
Unverified
Commit
16f69cba
authored
Mar 29, 2021
by
asynchronous rob
Committed by
GitHub
Mar 29, 2021
Browse files
send assignments even when we have an approval (#2757)
parent
f08a0c27
Pipeline
#131602
failed with stages
in 14 minutes and 19 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
node/network/approval-distribution/src/lib.rs
View file @
16f69cba
...
...
@@ -944,13 +944,24 @@ impl State {
}
match
approval_state
{
ApprovalState
::
Assigned
(
cert
)
=>
{
assignments
.push
((
IndirectAssignmentCert
{
assignments
.push
((
IndirectAssignmentCert
{
block_hash
:
block
.clone
(),
validator
:
validator_index
.clone
(),
cert
:
cert
.clone
(),
},
candidate_index
.clone
()));
},
candidate_index
.clone
(),
));
}
ApprovalState
::
Approved
(
_
,
signature
)
=>
{
ApprovalState
::
Approved
(
assignment_cert
,
signature
)
=>
{
assignments
.push
((
IndirectAssignmentCert
{
block_hash
:
block
.clone
(),
validator
:
validator_index
.clone
(),
cert
:
assignment_cert
.clone
(),
},
candidate_index
.clone
(),
));
approvals
.push
(
IndirectSignedApprovalVote
{
block_hash
:
block
.clone
(),
validator
:
validator_index
.clone
(),
...
...
node/network/approval-distribution/src/tests.rs
View file @
16f69cba
...
...
@@ -827,3 +827,88 @@ fn import_remotely_then_locally() {
);
});
}
#[test]
fn
sends_assignments_even_when_state_is_approved
()
{
let
peer_a
=
PeerId
::
random
();
let
parent_hash
=
Hash
::
repeat_byte
(
0xFF
);
let
hash
=
Hash
::
repeat_byte
(
0xAA
);
let
peer
=
&
peer_a
;
let
_
=
test_harness
(
State
::
default
(),
|
mut
virtual_overseer
|
async
move
{
let
overseer
=
&
mut
virtual_overseer
;
// new block `hash_a` with 1 candidates
let
meta
=
BlockApprovalMeta
{
hash
,
parent_hash
,
number
:
1
,
candidates
:
vec!
[
Default
::
default
();
1
],
slot
:
1
.into
(),
};
let
msg
=
ApprovalDistributionMessage
::
NewBlocks
(
vec!
[
meta
]);
overseer_send
(
overseer
,
msg
)
.await
;
let
validator_index
=
ValidatorIndex
(
0
);
let
candidate_index
=
0u32
;
// import an assignment and approval locally.
let
cert
=
fake_assignment_cert
(
hash
,
validator_index
);
let
approval
=
IndirectSignedApprovalVote
{
block_hash
:
hash
,
candidate_index
,
validator
:
validator_index
,
signature
:
Default
::
default
(),
};
overseer_send
(
overseer
,
ApprovalDistributionMessage
::
DistributeAssignment
(
cert
.clone
(),
candidate_index
)
)
.await
;
overseer_send
(
overseer
,
ApprovalDistributionMessage
::
DistributeApproval
(
approval
.clone
()),
)
.await
;
// connect the peer.
setup_peer_with_view
(
overseer
,
peer
,
view!
[
hash
])
.await
;
let
assignments
=
vec!
[(
cert
.clone
(),
candidate_index
)];
let
approvals
=
vec!
[
approval
.clone
()];
assert_matches!
(
overseer_recv
(
overseer
)
.await
,
AllMessages
::
NetworkBridge
(
NetworkBridgeMessage
::
SendValidationMessage
(
peers
,
protocol_v1
::
ValidationProtocol
::
ApprovalDistribution
(
protocol_v1
::
ApprovalDistributionMessage
::
Assignments
(
sent_assignments
)
)
))
=>
{
assert_eq!
(
peers
,
vec!
[
peer
.clone
()]);
assert_eq!
(
sent_assignments
,
assignments
);
}
);
assert_matches!
(
overseer_recv
(
overseer
)
.await
,
AllMessages
::
NetworkBridge
(
NetworkBridgeMessage
::
SendValidationMessage
(
peers
,
protocol_v1
::
ValidationProtocol
::
ApprovalDistribution
(
protocol_v1
::
ApprovalDistributionMessage
::
Approvals
(
sent_approvals
)
)
))
=>
{
assert_eq!
(
peers
,
vec!
[
peer
.clone
()]);
assert_eq!
(
sent_approvals
,
approvals
);
}
);
assert!
(
overseer
.recv
()
.timeout
(
TIMEOUT
)
.await
.is_none
(),
"no message should be sent"
,
);
});
}
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