mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 20:31:13 +00:00
remove Default from CandidateDescriptor (#4484)
* remove Default from CandidateHash * Apply suggestions from code review Co-authored-by: Andronik Ordian <write@reusable.software> * chore: fmt * remove backed candidate default * Partial migration away from CandidateReceipt::default * Remove more CandidateReceipt defaults * fmt * Mostly remove CommittedCandidateReceipt default usage * Remove CommittedCandidateReceipt * Remove more Defaults from polakdot primitives v1 + fmt * Remove more Default from polkadot primites v1 * WIP trying to get overseer example + tests to compile * feat: add primitives test helpers * reduce deps of helper * update primitive helpers * make candidate validation compile * fixup cargo lock * make av-store compile * fixup disputes coordinator tests * test: fixup backing * test: fixup approval voting * fixup bitfield signing * test: fixup runtime-api * test: fixup availability dist * foxi[ pverseer test] * remove some Defaults, remove bounds from `dummy` All `fn dummy` in primitives need to be removed anyways. This aids in the transition. * it's a test helper, so always use std * test: fixup parachains runtime tests Excluding benches. * fix keyring * fix paras runtime properly, no more default * Remove fn dummy() usage from approval voting * Move TestCandidateBuilder out of av store to test helpers * Make candidate validation tests pass * Make most dispute coirdinator tests pass * Make provisioner tests work * Make availability recovery tests work with test helpers * Update polkadot-collator-protocol tests * Update statement distribution tests * Update polkadot overseer examples and tests * Derive default for validation code so we don't break unrelated things * Make para runtime test pass (no bench) * Some more work * chore: cargo fmt * cargo fix * avoid some Default::default * fixup dispute coordinator test * remove unused crate deps * remove Default::default wherever possible, replace by dummy_* for the most part * chore: cargo fmt * Remove some warnings * Remove CommittedCandidateReceipt dummy * Remove CandidateReceipt dummy * Remove CandidateDescriptor dummy * Remove commented out code * Fix para runtime tests * chore: nightly * Some updates to the builder * Dynamically adjust mock head data size * Make dispute cooridinator tests work * Fix test candidate_backing_reorders_votes work * +nightly-2021-10-29 fmt * Spelling and remove a default use in builder * Various clean up * More small updates * fmt * More small updates * Doc comments for test helpers * cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=kusama-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras_inherent --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/kusama/src/weights/runtime_parachains_paras_inherent.rs * cargo run --quiet --release --features=runtime-benchmarks -- benchmark --chain=polkadot-dev --steps=50 --repeat=20 --pallet=runtime_parachains::paras_inherent --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --header=./file_header.txt --output=./runtime/polkadot/src/weights/runtime_parachains_paras_inherent.rs * Update lib.rs * review comments * fix warnings * fix test by using correct candidate receipt relay parent Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: emostov <32168567+emostov@users.noreply.github.com> Co-authored-by: Parity Bot <admin@parity.io> Co-authored-by: Gavin Wood <gavin@parity.io>
This commit is contained in:
committed by
GitHub
parent
916497e5db
commit
0f1a9fb1eb
@@ -15,6 +15,7 @@
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::*;
|
||||
use ::test_helpers::{dummy_hash, make_valid_candidate_descriptor};
|
||||
use assert_matches::assert_matches;
|
||||
use futures::executor;
|
||||
use polkadot_node_core_pvf::PrepareError;
|
||||
@@ -25,20 +26,6 @@ use polkadot_primitives::v1::{HeadData, UpwardMessage};
|
||||
use sp_core::testing::TaskExecutor;
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
|
||||
fn collator_sign(descriptor: &mut CandidateDescriptor, collator: Sr25519Keyring) {
|
||||
descriptor.collator = collator.public().into();
|
||||
let payload = polkadot_primitives::v1::collator_signature_payload(
|
||||
&descriptor.relay_parent,
|
||||
&descriptor.para_id,
|
||||
&descriptor.persisted_validation_data_hash,
|
||||
&descriptor.pov_hash,
|
||||
&descriptor.validation_code_hash,
|
||||
);
|
||||
|
||||
descriptor.signature = collator.sign(&payload[..]).into();
|
||||
assert!(descriptor.check_collator_signature().is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn correctly_checks_included_assumption() {
|
||||
let validation_data: PersistedValidationData = Default::default();
|
||||
@@ -48,10 +35,16 @@ fn correctly_checks_included_assumption() {
|
||||
let relay_parent = [2; 32].into();
|
||||
let para_id = 5.into();
|
||||
|
||||
let mut candidate = CandidateDescriptor::default();
|
||||
candidate.relay_parent = relay_parent;
|
||||
candidate.persisted_validation_data_hash = persisted_validation_data_hash;
|
||||
candidate.para_id = para_id;
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
para_id,
|
||||
relay_parent,
|
||||
persisted_validation_data_hash,
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let pool = TaskExecutor::new();
|
||||
let (mut ctx, mut ctx_handle) =
|
||||
@@ -59,7 +52,7 @@ fn correctly_checks_included_assumption() {
|
||||
|
||||
let (check_fut, check_result) = check_assumption_validation_data(
|
||||
ctx.sender(),
|
||||
&candidate,
|
||||
&descriptor,
|
||||
OccupiedCoreAssumption::Included,
|
||||
)
|
||||
.remote_handle();
|
||||
@@ -114,10 +107,16 @@ fn correctly_checks_timed_out_assumption() {
|
||||
let relay_parent = [2; 32].into();
|
||||
let para_id = 5.into();
|
||||
|
||||
let mut candidate = CandidateDescriptor::default();
|
||||
candidate.relay_parent = relay_parent;
|
||||
candidate.persisted_validation_data_hash = persisted_validation_data_hash;
|
||||
candidate.para_id = para_id;
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
para_id,
|
||||
relay_parent,
|
||||
persisted_validation_data_hash,
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let pool = TaskExecutor::new();
|
||||
let (mut ctx, mut ctx_handle) =
|
||||
@@ -125,7 +124,7 @@ fn correctly_checks_timed_out_assumption() {
|
||||
|
||||
let (check_fut, check_result) = check_assumption_validation_data(
|
||||
ctx.sender(),
|
||||
&candidate,
|
||||
&descriptor,
|
||||
OccupiedCoreAssumption::TimedOut,
|
||||
)
|
||||
.remote_handle();
|
||||
@@ -178,10 +177,16 @@ fn check_is_bad_request_if_no_validation_data() {
|
||||
let relay_parent = [2; 32].into();
|
||||
let para_id = 5.into();
|
||||
|
||||
let mut candidate = CandidateDescriptor::default();
|
||||
candidate.relay_parent = relay_parent;
|
||||
candidate.persisted_validation_data_hash = persisted_validation_data_hash;
|
||||
candidate.para_id = para_id;
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
para_id,
|
||||
relay_parent,
|
||||
persisted_validation_data_hash,
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let pool = TaskExecutor::new();
|
||||
let (mut ctx, mut ctx_handle) =
|
||||
@@ -189,7 +194,7 @@ fn check_is_bad_request_if_no_validation_data() {
|
||||
|
||||
let (check_fut, check_result) = check_assumption_validation_data(
|
||||
ctx.sender(),
|
||||
&candidate,
|
||||
&descriptor,
|
||||
OccupiedCoreAssumption::Included,
|
||||
)
|
||||
.remote_handle();
|
||||
@@ -226,10 +231,16 @@ fn check_is_bad_request_if_no_validation_code() {
|
||||
let relay_parent = [2; 32].into();
|
||||
let para_id = 5.into();
|
||||
|
||||
let mut candidate = CandidateDescriptor::default();
|
||||
candidate.relay_parent = relay_parent;
|
||||
candidate.persisted_validation_data_hash = persisted_validation_data_hash;
|
||||
candidate.para_id = para_id;
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
para_id,
|
||||
relay_parent,
|
||||
persisted_validation_data_hash,
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let pool = TaskExecutor::new();
|
||||
let (mut ctx, mut ctx_handle) =
|
||||
@@ -237,7 +248,7 @@ fn check_is_bad_request_if_no_validation_code() {
|
||||
|
||||
let (check_fut, check_result) = check_assumption_validation_data(
|
||||
ctx.sender(),
|
||||
&candidate,
|
||||
&descriptor,
|
||||
OccupiedCoreAssumption::TimedOut,
|
||||
)
|
||||
.remote_handle();
|
||||
@@ -286,10 +297,16 @@ fn check_does_not_match() {
|
||||
let relay_parent = [2; 32].into();
|
||||
let para_id = 5.into();
|
||||
|
||||
let mut candidate = CandidateDescriptor::default();
|
||||
candidate.relay_parent = relay_parent;
|
||||
candidate.persisted_validation_data_hash = [3; 32].into();
|
||||
candidate.para_id = para_id;
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
para_id,
|
||||
relay_parent,
|
||||
Hash::from([3; 32]),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let pool = TaskExecutor::new();
|
||||
let (mut ctx, mut ctx_handle) =
|
||||
@@ -297,7 +314,7 @@ fn check_does_not_match() {
|
||||
|
||||
let (check_fut, check_result) = check_assumption_validation_data(
|
||||
ctx.sender(),
|
||||
&candidate,
|
||||
&descriptor,
|
||||
OccupiedCoreAssumption::Included,
|
||||
)
|
||||
.remote_handle();
|
||||
@@ -361,11 +378,16 @@ fn candidate_validation_ok_is_ok() {
|
||||
let head_data = HeadData(vec![1, 1, 1]);
|
||||
let validation_code = ValidationCode(vec![2; 16]);
|
||||
|
||||
let mut descriptor = CandidateDescriptor::default();
|
||||
descriptor.pov_hash = pov.hash();
|
||||
descriptor.para_head = head_data.hash();
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
1.into(),
|
||||
dummy_hash(),
|
||||
validation_data.hash(),
|
||||
pov.hash(),
|
||||
validation_code.hash(),
|
||||
head_data.hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
@@ -412,10 +434,16 @@ fn candidate_validation_bad_return_is_invalid() {
|
||||
let pov = PoV { block_data: BlockData(vec![1; 32]) };
|
||||
let validation_code = ValidationCode(vec![2; 16]);
|
||||
|
||||
let mut descriptor = CandidateDescriptor::default();
|
||||
descriptor.pov_hash = pov.hash();
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
1.into(),
|
||||
dummy_hash(),
|
||||
validation_data.hash(),
|
||||
pov.hash(),
|
||||
validation_code.hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
@@ -448,10 +476,16 @@ fn candidate_validation_timeout_is_internal_error() {
|
||||
let pov = PoV { block_data: BlockData(vec![1; 32]) };
|
||||
let validation_code = ValidationCode(vec![2; 16]);
|
||||
|
||||
let mut descriptor = CandidateDescriptor::default();
|
||||
descriptor.pov_hash = pov.hash();
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
1.into(),
|
||||
dummy_hash(),
|
||||
validation_data.hash(),
|
||||
pov.hash(),
|
||||
validation_code.hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
@@ -483,10 +517,16 @@ fn candidate_validation_code_mismatch_is_invalid() {
|
||||
let pov = PoV { block_data: BlockData(vec![1; 32]) };
|
||||
let validation_code = ValidationCode(vec![2; 16]);
|
||||
|
||||
let mut descriptor = CandidateDescriptor::default();
|
||||
descriptor.pov_hash = pov.hash();
|
||||
descriptor.validation_code_hash = ValidationCode(vec![1; 16]).hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
1.into(),
|
||||
dummy_hash(),
|
||||
validation_data.hash(),
|
||||
pov.hash(),
|
||||
ValidationCode(vec![1; 16]).hash(),
|
||||
dummy_hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let check = perform_basic_checks(
|
||||
&descriptor,
|
||||
@@ -523,11 +563,16 @@ fn compressed_code_works() {
|
||||
.map(ValidationCode)
|
||||
.unwrap();
|
||||
|
||||
let mut descriptor = CandidateDescriptor::default();
|
||||
descriptor.pov_hash = pov.hash();
|
||||
descriptor.para_head = head_data.hash();
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
1.into(),
|
||||
dummy_hash(),
|
||||
validation_data.hash(),
|
||||
pov.hash(),
|
||||
validation_code.hash(),
|
||||
head_data.hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let validation_result = WasmValidationResult {
|
||||
head_data,
|
||||
@@ -563,11 +608,16 @@ fn code_decompression_failure_is_invalid() {
|
||||
.map(ValidationCode)
|
||||
.unwrap();
|
||||
|
||||
let mut descriptor = CandidateDescriptor::default();
|
||||
descriptor.pov_hash = pov.hash();
|
||||
descriptor.para_head = head_data.hash();
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
1.into(),
|
||||
dummy_hash(),
|
||||
validation_data.hash(),
|
||||
pov.hash(),
|
||||
validation_code.hash(),
|
||||
head_data.hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let validation_result = WasmValidationResult {
|
||||
head_data,
|
||||
@@ -604,11 +654,16 @@ fn pov_decompression_failure_is_invalid() {
|
||||
|
||||
let validation_code = ValidationCode(vec![2; 16]);
|
||||
|
||||
let mut descriptor = CandidateDescriptor::default();
|
||||
descriptor.pov_hash = pov.hash();
|
||||
descriptor.para_head = head_data.hash();
|
||||
descriptor.validation_code_hash = validation_code.hash();
|
||||
collator_sign(&mut descriptor, Sr25519Keyring::Alice);
|
||||
let descriptor = make_valid_candidate_descriptor(
|
||||
1.into(),
|
||||
dummy_hash(),
|
||||
validation_data.hash(),
|
||||
pov.hash(),
|
||||
validation_code.hash(),
|
||||
head_data.hash(),
|
||||
dummy_hash(),
|
||||
Sr25519Keyring::Alice,
|
||||
);
|
||||
|
||||
let validation_result = WasmValidationResult {
|
||||
head_data,
|
||||
|
||||
Reference in New Issue
Block a user