From 1189887cdd1ca19899ee21ed23674f1dfb74f947 Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Wed, 12 Jun 2024 15:05:44 +0200 Subject: [PATCH 1/4] Trigger own assignments in approval-voting --- polkadot/node/subsystem-bench/src/lib/approval/mod.rs | 9 ++++++++- .../node/subsystem-bench/src/lib/mock/runtime_api.rs | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs index 5c0c65b11cdb..4a68c95477ca 100644 --- a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs +++ b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs @@ -60,7 +60,7 @@ use polkadot_node_subsystem_util::metrics::Metrics; use polkadot_overseer::Handle as OverseerHandleReal; use polkadot_primitives::{ BlockNumber, CandidateEvent, CandidateIndex, CandidateReceipt, Hash, Header, Slot, - ValidatorIndex, + ValidatorIndex, ASSIGNMENT_KEY_TYPE_ID, }; use prometheus::Registry; use sc_keystore::LocalKeystore; @@ -68,6 +68,7 @@ use sc_service::SpawnTaskHandle; use serde::{Deserialize, Serialize}; use sp_consensus_babe::Epoch as BabeEpoch; use sp_core::H256; +use sp_keystore::Keystore; use std::{ cmp::max, collections::{HashMap, HashSet}, @@ -785,6 +786,12 @@ fn build_overseer( let db: polkadot_node_subsystem_util::database::kvdb_impl::DbAdapter = polkadot_node_subsystem_util::database::kvdb_impl::DbAdapter::new(db, &[]); let keystore = LocalKeystore::in_memory(); + keystore + .sr25519_generate_new( + ASSIGNMENT_KEY_TYPE_ID, + Some(state.test_authorities.key_seeds.first().unwrap().as_str()), + ) + .unwrap(); let system_clock = PastSystemClock::new(SystemClock {}, state.delta_tick_from_generated.clone()); diff --git a/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs b/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs index be9dbd55cb6f..5418db4a94a1 100644 --- a/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs +++ b/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs @@ -28,7 +28,7 @@ use polkadot_node_subsystem_types::OverseerSignal; use polkadot_primitives::{ node_features, AsyncBackingParams, CandidateEvent, CandidateReceipt, CoreState, GroupIndex, GroupRotationInfo, IndexedVec, NodeFeatures, OccupiedCore, ScheduledCore, SessionIndex, - SessionInfo, ValidatorIndex, + SessionInfo, ValidationCode, ValidatorIndex, }; use sp_consensus_babe::Epoch as BabeEpoch; use sp_core::H256; @@ -288,6 +288,13 @@ impl MockRuntimeApi { }; tx.send(Ok((groups, group_rotation_info))).unwrap(); }, + RuntimeApiMessage::Request( + _parent, + RuntimeApiRequest::ValidationCodeByHash(_, tx), + ) => { + let validation_code = ValidationCode(Vec::new()); + tx.send(Ok(Some(validation_code))).unwrap(); + }, // Long term TODO: implement more as needed. message => { unimplemented!("Unexpected runtime-api message: {:?}", message) From 623c8b55643d6f1e322079107c37c3277f728acb Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Mon, 24 Jun 2024 14:11:59 +0200 Subject: [PATCH 2/4] Use NODE_UNDER_TEST --- polkadot/node/subsystem-bench/src/lib/approval/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs index 4a68c95477ca..ab5b3a49d5f6 100644 --- a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs +++ b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs @@ -789,7 +789,7 @@ fn build_overseer( keystore .sr25519_generate_new( ASSIGNMENT_KEY_TYPE_ID, - Some(state.test_authorities.key_seeds.first().unwrap().as_str()), + Some(state.test_authorities.key_seeds.get(NODE_UNDER_TEST).unwrap().as_str()), ) .unwrap(); From 2fca1b0916b238b50fa7e2ebcd7f78d2f1eff24b Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Mon, 24 Jun 2024 14:22:11 +0200 Subject: [PATCH 3/4] Fix error --- polkadot/node/subsystem-bench/src/lib/approval/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs index ab5b3a49d5f6..b033be9986f4 100644 --- a/polkadot/node/subsystem-bench/src/lib/approval/mod.rs +++ b/polkadot/node/subsystem-bench/src/lib/approval/mod.rs @@ -789,7 +789,7 @@ fn build_overseer( keystore .sr25519_generate_new( ASSIGNMENT_KEY_TYPE_ID, - Some(state.test_authorities.key_seeds.get(NODE_UNDER_TEST).unwrap().as_str()), + Some(state.test_authorities.key_seeds.get(NODE_UNDER_TEST as usize).unwrap().as_str()), ) .unwrap(); From 981fa5f94172bd4bc8364f4257be1e52285674af Mon Sep 17 00:00:00 2001 From: Andrei Eres Date: Tue, 25 Jun 2024 10:05:07 +0200 Subject: [PATCH 4/4] Send error message instead of panicking --- polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs b/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs index 5418db4a94a1..ee45ea05c925 100644 --- a/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs +++ b/polkadot/node/subsystem-bench/src/lib/mock/runtime_api.rs @@ -293,7 +293,9 @@ impl MockRuntimeApi { RuntimeApiRequest::ValidationCodeByHash(_, tx), ) => { let validation_code = ValidationCode(Vec::new()); - tx.send(Ok(Some(validation_code))).unwrap(); + if let Err(err) = tx.send(Ok(Some(validation_code))) { + gum::error!(target: LOG_TARGET, ?err, "validation code wasn't received"); + } }, // Long term TODO: implement more as needed. message => {