diff --git a/polkadot/node/network/protocol/src/lib.rs b/polkadot/node/network/protocol/src/lib.rs index ae92bc0f7f..772149c35a 100644 --- a/polkadot/node/network/protocol/src/lib.rs +++ b/polkadot/node/network/protocol/src/lib.rs @@ -332,19 +332,6 @@ pub mod v1 { } impl StatementDistributionMessage { - /// Get meta data of the given `StatementDistributionMessage`. - pub fn get_metadata(&self) -> StatementMetadata { - match self { - Self::Statement(relay_parent, statement) => StatementMetadata { - relay_parent: *relay_parent, - candidate_hash: statement.unchecked_payload().candidate_hash(), - signed_by: statement.unchecked_validator_index(), - signature: statement.unchecked_signature().clone(), - }, - Self::LargeStatement(metadata) => metadata.clone(), - } - } - /// Get fingerprint describing the contained statement uniquely. pub fn get_fingerprint(&self) -> (CompactStatement, ValidatorIndex) { match self { diff --git a/polkadot/node/network/statement-distribution/src/tests.rs b/polkadot/node/network/statement-distribution/src/tests.rs index a9a534bec2..782c4104ad 100644 --- a/polkadot/node/network/statement-distribution/src/tests.rs +++ b/polkadot/node/network/statement-distribution/src/tests.rs @@ -26,9 +26,9 @@ use polkadot_node_network_protocol::{ }, view, ObservedRole, }; -use polkadot_node_primitives::Statement; +use polkadot_node_primitives::{Statement, UncheckedSignedFullStatement}; use polkadot_node_subsystem_test_helpers::mock::make_ferdie_keystore; -use polkadot_primitives::v2::{SessionInfo, ValidationCode}; +use polkadot_primitives::v2::{Hash, SessionInfo, ValidationCode}; use polkadot_primitives_test_helpers::{dummy_committed_candidate_receipt, dummy_hash}; use polkadot_subsystem::{ jaeger, @@ -1053,9 +1053,7 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing( .expect("should be signed") }; - let metadata = - protocol_v1::StatementDistributionMessage::Statement(hash_a, statement.clone().into()) - .get_metadata(); + let metadata = derive_metadata_assuming_seconded(hash_a, statement.clone().into()); handle .send(FromOverseer::Communication { @@ -1592,9 +1590,7 @@ fn share_prioritizes_backing_group() { .expect("should be signed") }; - let metadata = - protocol_v1::StatementDistributionMessage::Statement(hash_a, statement.clone().into()) - .get_metadata(); + let metadata = derive_metadata_assuming_seconded(hash_a, statement.clone().into()); handle .send(FromOverseer::Communication { @@ -1783,9 +1779,7 @@ fn peer_cant_flood_with_large_statements() { .expect("should be signed") }; - let metadata = - protocol_v1::StatementDistributionMessage::Statement(hash_a, statement.clone().into()) - .get_metadata(); + let metadata = derive_metadata_assuming_seconded(hash_a, statement.clone().into()); for _ in 0..MAX_LARGE_STATEMENTS_PER_SENDER + 1 { handle @@ -1870,3 +1864,15 @@ fn make_session_info(validators: Vec, groups: Vec>) -> SessionInf random_seed: [0u8; 32], } } + +fn derive_metadata_assuming_seconded( + hash: Hash, + statement: UncheckedSignedFullStatement, +) -> protocol_v1::StatementMetadata { + protocol_v1::StatementMetadata { + relay_parent: hash, + candidate_hash: statement.unchecked_payload().candidate_hash(), + signed_by: statement.unchecked_validator_index(), + signature: statement.unchecked_signature().clone(), + } +}