mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-12 12:15:40 +00:00
Remove Parent Hash to Session mapping (#928)
* Adds a SigningContext type * Bump spec versions * Fixes requested changes * Bump ParachainHost api_version and guard signing_context call * Improve error message * If there is no signing_context api use default value Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
@@ -131,9 +131,13 @@ impl View {
|
||||
///
|
||||
/// This will be pruned later on a call to `prune_old_leaves`, when this leaf
|
||||
/// is not a leaf anymore.
|
||||
pub(super) fn new_local_leaf(&mut self, relay_chain_leaf: Hash, validation_data: MessageValidationData) {
|
||||
pub(super) fn new_local_leaf(
|
||||
&mut self,
|
||||
validation_data: MessageValidationData,
|
||||
) {
|
||||
let relay_chain_leaf = validation_data.signing_context.parent_hash.clone();
|
||||
self.leaf_work.push((
|
||||
relay_chain_leaf,
|
||||
validation_data.signing_context.parent_hash.clone(),
|
||||
LeafView {
|
||||
validation_data,
|
||||
knowledge: Default::default(),
|
||||
@@ -207,7 +211,6 @@ impl View {
|
||||
|
||||
// validate signature.
|
||||
let res = view.validation_data.check_statement(
|
||||
&message.relay_chain_leaf,
|
||||
&message.signed_statement,
|
||||
);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ use sc_network_gossip::{
|
||||
use polkadot_validation::{SignedStatement};
|
||||
use polkadot_primitives::{Block, Hash};
|
||||
use polkadot_primitives::parachain::{
|
||||
ParachainHost, ValidatorId, ErasureChunk as PrimitiveChunk
|
||||
ParachainHost, ValidatorId, ErasureChunk as PrimitiveChunk, SigningContext,
|
||||
};
|
||||
use polkadot_erasure_coding::{self as erasure};
|
||||
use codec::{Decode, Encode};
|
||||
@@ -377,13 +377,12 @@ impl RegisteredMessageValidator {
|
||||
/// relevant to this leaf.
|
||||
pub(crate) fn new_local_leaf(
|
||||
&self,
|
||||
relay_chain_leaf: Hash,
|
||||
validation: MessageValidationData,
|
||||
) -> NewLeafActions {
|
||||
// add an entry in attestation_view
|
||||
// prune any entries from attestation_view which are no longer leaves
|
||||
let mut inner = self.inner.inner.write();
|
||||
inner.attestation_view.new_local_leaf(relay_chain_leaf, validation);
|
||||
inner.attestation_view.new_local_leaf(validation);
|
||||
|
||||
let mut actions = Vec::new();
|
||||
|
||||
@@ -460,11 +459,13 @@ impl GossipService for RegisteredMessageValidator {
|
||||
pub(crate) struct MessageValidationData {
|
||||
/// The authorities' parachain validation keys at a block.
|
||||
pub(crate) authorities: Vec<ValidatorId>,
|
||||
/// The signing context.
|
||||
pub(crate) signing_context: SigningContext,
|
||||
}
|
||||
|
||||
impl MessageValidationData {
|
||||
// check a statement's signature.
|
||||
fn check_statement(&self, relay_chain_leaf: &Hash, statement: &SignedStatement) -> Result<(), ()> {
|
||||
fn check_statement(&self, statement: &SignedStatement) -> Result<(), ()> {
|
||||
let sender = match self.authorities.get(statement.sender as usize) {
|
||||
Some(val) => val,
|
||||
None => return Err(()),
|
||||
@@ -475,7 +476,7 @@ impl MessageValidationData {
|
||||
&statement.statement,
|
||||
&statement.signature,
|
||||
sender.clone(),
|
||||
relay_chain_leaf,
|
||||
&self.signing_context,
|
||||
);
|
||||
|
||||
if good {
|
||||
@@ -826,7 +827,9 @@ mod tests {
|
||||
let topic_c = attestation_topic(hash_c);
|
||||
|
||||
// topic_a is in all 3 views -> succeed
|
||||
validator.inner.write().attestation_view.new_local_leaf(hash_a, MessageValidationData::default());
|
||||
let mut validation_data = MessageValidationData::default();
|
||||
validation_data.signing_context.parent_hash = hash_a;
|
||||
validator.inner.write().attestation_view.new_local_leaf(validation_data);
|
||||
// topic_b is in the neighbor's view but not ours -> fail
|
||||
// topic_c is not in either -> fail
|
||||
|
||||
@@ -937,7 +940,9 @@ mod tests {
|
||||
}
|
||||
});
|
||||
let encoded = statement.encode();
|
||||
validator.inner.write().attestation_view.new_local_leaf(hash_a, MessageValidationData::default());
|
||||
let mut validation_data = MessageValidationData::default();
|
||||
validation_data.signing_context.parent_hash = hash_a;
|
||||
validator.inner.write().attestation_view.new_local_leaf(validation_data);
|
||||
|
||||
{
|
||||
let mut message_allowed = validator.message_allowed();
|
||||
|
||||
Reference in New Issue
Block a user