mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 11:21:07 +00:00
* Substrate companion for #8163 https://github.com/paritytech/substrate/pull/8163 * "Update Substrate" Co-authored-by: parity-processbot <>
This commit is contained in:
Generated
+215
-192
File diff suppressed because it is too large
Load Diff
@@ -248,15 +248,14 @@ pub(crate) fn compute_assignments(
|
||||
) -> HashMap<CoreIndex, OurAssignment> {
|
||||
let (index, assignments_key): (ValidatorIndex, AssignmentPair) = {
|
||||
let key = config.assignment_keys.iter().enumerate()
|
||||
.filter_map(|(i, p)| match keystore.key_pair(p) {
|
||||
Ok(pair) => Some((i as ValidatorIndex, pair)),
|
||||
Err(sc_keystore::Error::PairNotFound(_)) => None,
|
||||
.find_map(|(i, p)| match keystore.key_pair(p) {
|
||||
Ok(Some(pair)) => Some((i as ValidatorIndex, pair)),
|
||||
Ok(None) => None,
|
||||
Err(e) => {
|
||||
tracing::warn!(target: LOG_TARGET, "Encountered keystore error: {:?}", e);
|
||||
None
|
||||
}
|
||||
})
|
||||
.next();
|
||||
});
|
||||
|
||||
match key {
|
||||
None => return Default::default(),
|
||||
|
||||
@@ -1384,7 +1384,7 @@ fn sign_approval(
|
||||
candidate_hash: CandidateHash,
|
||||
session_index: SessionIndex,
|
||||
) -> Option<ValidatorSignature> {
|
||||
let key = keystore.key_pair::<ValidatorPair>(public).ok()?;
|
||||
let key = keystore.key_pair::<ValidatorPair>(public).ok().flatten()?;
|
||||
|
||||
let payload = approval_signing_payload(
|
||||
ApprovalVote(candidate_hash),
|
||||
|
||||
@@ -891,7 +891,8 @@ impl CandidateBackingJob {
|
||||
.as_ref()?
|
||||
.sign(self.keystore.clone(), statement)
|
||||
.await
|
||||
.ok()?;
|
||||
.ok()
|
||||
.flatten()?;
|
||||
self.metrics.on_statement_signed();
|
||||
Some(signed)
|
||||
}
|
||||
@@ -1600,7 +1601,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
2,
|
||||
&public2.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let signed_b = SignedFullStatement::sign(
|
||||
&test_state.keystore,
|
||||
@@ -1608,7 +1609,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
5,
|
||||
&public1.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let statement = CandidateBackingMessage::Statement(test_state.relay_parent, signed_a.clone());
|
||||
|
||||
@@ -1742,7 +1743,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
2,
|
||||
&public2.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let signed_b = SignedFullStatement::sign(
|
||||
&test_state.keystore,
|
||||
@@ -1750,7 +1751,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
5,
|
||||
&public1.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let signed_c = SignedFullStatement::sign(
|
||||
&test_state.keystore,
|
||||
@@ -1758,7 +1759,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
3,
|
||||
&public3.into(),
|
||||
).await.expect("should be signed");
|
||||
).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;
|
||||
@@ -1895,7 +1896,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
2,
|
||||
&public2.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let signed_b = SignedFullStatement::sign(
|
||||
&test_state.keystore,
|
||||
@@ -1903,7 +1904,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
2,
|
||||
&public2.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let signed_c = SignedFullStatement::sign(
|
||||
&test_state.keystore,
|
||||
@@ -1911,7 +1912,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
0,
|
||||
&public0.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let statement = CandidateBackingMessage::Statement(test_state.relay_parent, signed_a.clone());
|
||||
|
||||
@@ -2224,7 +2225,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
2,
|
||||
&validator2.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
// Send in a `Statement` with a candidate.
|
||||
let statement = CandidateBackingMessage::Statement(
|
||||
@@ -2362,7 +2363,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
2,
|
||||
&public2.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
// Send in a `Statement` with a candidate.
|
||||
let statement = CandidateBackingMessage::Statement(
|
||||
@@ -2504,7 +2505,7 @@ mod tests {
|
||||
&test_state.signing_context,
|
||||
2,
|
||||
&public2.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
let statement = CandidateBackingMessage::Statement(
|
||||
test_state.relay_parent,
|
||||
|
||||
@@ -268,10 +268,20 @@ impl JobTrait for BitfieldSigningJob {
|
||||
drop(span_availability);
|
||||
let _span = span.child("signing");
|
||||
|
||||
let signed_bitfield = validator
|
||||
.sign(keystore.clone(), bitfield)
|
||||
let signed_bitfield = match validator.sign(keystore.clone(), bitfield)
|
||||
.await
|
||||
.map_err(|e| Error::Keystore(e))?;
|
||||
.map_err(|e| Error::Keystore(e))?
|
||||
{
|
||||
Some(b) => b,
|
||||
None => {
|
||||
tracing::error!(
|
||||
target: LOG_TARGET,
|
||||
"Key was found at construction, but while signing it could not be found.",
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
metrics.on_bitfield_signed();
|
||||
|
||||
drop(_span);
|
||||
|
||||
@@ -63,7 +63,7 @@ mod select_availability_bitfields {
|
||||
&<SigningContext<Hash>>::default(),
|
||||
validator_idx,
|
||||
&public.into(),
|
||||
).await.expect("Should be signed")
|
||||
).await.ok().flatten().expect("Should be signed")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -884,7 +884,7 @@ mod test {
|
||||
&signing_context,
|
||||
0,
|
||||
&malicious.into(),
|
||||
)).expect("should be signed");
|
||||
)).ok().flatten().expect("should be signed");
|
||||
|
||||
let msg = BitfieldGossipMessage {
|
||||
relay_parent: hash_a.clone(),
|
||||
@@ -949,7 +949,7 @@ mod test {
|
||||
&signing_context,
|
||||
42,
|
||||
&validator,
|
||||
)).expect("should be signed");
|
||||
)).ok().flatten().expect("should be signed");
|
||||
|
||||
let msg = BitfieldGossipMessage {
|
||||
relay_parent: hash_a.clone(),
|
||||
@@ -1006,7 +1006,7 @@ mod test {
|
||||
&signing_context,
|
||||
0,
|
||||
&validator,
|
||||
)).expect("should be signed");
|
||||
)).ok().flatten().expect("should be signed");
|
||||
|
||||
let msg = BitfieldGossipMessage {
|
||||
relay_parent: hash_a.clone(),
|
||||
@@ -1121,7 +1121,7 @@ mod test {
|
||||
&signing_context,
|
||||
0,
|
||||
&validator,
|
||||
)).expect("should be signed");
|
||||
)).ok().flatten().expect("should be signed");
|
||||
|
||||
state.peer_views.insert(peer_b.clone(), view![hash]);
|
||||
state.peer_views.insert(peer_a.clone(), view![hash]);
|
||||
@@ -1217,7 +1217,7 @@ mod test {
|
||||
&signing_context,
|
||||
0,
|
||||
&validator,
|
||||
)).expect("should be signed");
|
||||
)).ok().flatten().expect("should be signed");
|
||||
|
||||
let msg = BitfieldGossipMessage {
|
||||
relay_parent: hash_a.clone(),
|
||||
@@ -1376,7 +1376,7 @@ mod test {
|
||||
&signing_context,
|
||||
0,
|
||||
&validator,
|
||||
)).expect("should be signed");
|
||||
)).ok().flatten().expect("should be signed");
|
||||
|
||||
state.peer_views.insert(peer_b.clone(), view![hash]);
|
||||
state.peer_views.insert(peer_a.clone(), view![hash]);
|
||||
|
||||
@@ -1135,7 +1135,7 @@ mod tests {
|
||||
&signing_context,
|
||||
0,
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed");
|
||||
)).ok().flatten().expect("should be signed");
|
||||
let noted = head_data.note_statement(a_seconded_val_0.clone());
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
@@ -1152,7 +1152,7 @@ mod tests {
|
||||
&signing_context,
|
||||
0,
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed"));
|
||||
)).ok().flatten().expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
@@ -1163,7 +1163,7 @@ mod tests {
|
||||
&signing_context,
|
||||
0,
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed"));
|
||||
)).ok().flatten().expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::NotUseful);
|
||||
|
||||
@@ -1174,7 +1174,7 @@ mod tests {
|
||||
&signing_context,
|
||||
1,
|
||||
&bob_public.into(),
|
||||
)).expect("should be signed"));
|
||||
)).ok().flatten().expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
@@ -1185,7 +1185,7 @@ mod tests {
|
||||
&signing_context,
|
||||
1,
|
||||
&bob_public.into(),
|
||||
)).expect("should be signed"));
|
||||
)).ok().flatten().expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
}
|
||||
@@ -1388,7 +1388,7 @@ mod tests {
|
||||
&signing_context,
|
||||
0,
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed"));
|
||||
)).ok().flatten().expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
@@ -1398,7 +1398,7 @@ mod tests {
|
||||
&signing_context,
|
||||
1,
|
||||
&bob_public.into(),
|
||||
)).expect("should be signed"));
|
||||
)).ok().flatten().expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
@@ -1408,7 +1408,7 @@ mod tests {
|
||||
&signing_context,
|
||||
2,
|
||||
&charlie_public.into(),
|
||||
)).expect("should be signed"));
|
||||
)).ok().flatten().expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
@@ -1540,7 +1540,7 @@ mod tests {
|
||||
&signing_context,
|
||||
0,
|
||||
&alice_public.into(),
|
||||
).await.expect("should be signed");
|
||||
).await.ok().flatten().expect("should be signed");
|
||||
|
||||
StoredStatement {
|
||||
comparator: StoredStatementComparator {
|
||||
@@ -1708,7 +1708,7 @@ mod tests {
|
||||
&signing_context,
|
||||
0,
|
||||
&alice_public.into(),
|
||||
).await.expect("should be signed")
|
||||
).await.ok().flatten().expect("should be signed")
|
||||
};
|
||||
|
||||
handle.send(FromOverseer::Communication {
|
||||
|
||||
@@ -351,7 +351,7 @@ impl Validator {
|
||||
&self,
|
||||
keystore: SyncCryptoStorePtr,
|
||||
payload: Payload,
|
||||
) -> Result<Signed<Payload, RealPayload>, KeystoreError> {
|
||||
) -> Result<Option<Signed<Payload, RealPayload>>, KeystoreError> {
|
||||
Signed::sign(&keystore, payload, &self.signing_context, self.index, &self.key).await
|
||||
}
|
||||
|
||||
|
||||
@@ -915,20 +915,26 @@ impl<Payload: EncodeAs<RealPayload>, RealPayload: Encode> Signed<Payload, RealPa
|
||||
context: &SigningContext<H>,
|
||||
validator_index: ValidatorIndex,
|
||||
key: &ValidatorId,
|
||||
) -> Result<Self, KeystoreError> {
|
||||
) -> Result<Option<Self>, KeystoreError> {
|
||||
let data = Self::payload_data(&payload, context);
|
||||
let signature: ValidatorSignature = CryptoStore::sign_with(
|
||||
let signature = CryptoStore::sign_with(
|
||||
&**keystore,
|
||||
ValidatorId::ID,
|
||||
&key.into(),
|
||||
&data,
|
||||
).await?.try_into().map_err(|_| KeystoreError::KeyNotSupported(ValidatorId::ID))?;
|
||||
Ok(Self {
|
||||
).await?;
|
||||
|
||||
let signature = match signature {
|
||||
Some(sig) => sig.try_into().map_err(|_| KeystoreError::KeyNotSupported(ValidatorId::ID))?,
|
||||
None => return Ok(None),
|
||||
};
|
||||
|
||||
Ok(Some(Self {
|
||||
payload,
|
||||
validator_index,
|
||||
signature,
|
||||
real_payload: std::marker::PhantomData,
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
/// Validate the payload given the context and public key.
|
||||
|
||||
@@ -1000,7 +1000,7 @@ mod tests {
|
||||
signing_context,
|
||||
*val_idx,
|
||||
&key.public().into(),
|
||||
).await.unwrap().signature().clone();
|
||||
).await.unwrap().unwrap().signature().clone();
|
||||
|
||||
validity_votes.push(ValidityAttestation::Explicit(signature).into());
|
||||
}
|
||||
@@ -1101,7 +1101,7 @@ mod tests {
|
||||
&signing_context,
|
||||
validator_index,
|
||||
&key.public().into(),
|
||||
).await.unwrap()
|
||||
).await.unwrap().unwrap()
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
Reference in New Issue
Block a user