diff --git a/Cargo.lock b/Cargo.lock index cb9ecb2b15..69f30275f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11748,10 +11748,7 @@ dependencies = [ "orml-vesting", "pallet-balances", "pallet-domains", - "pallet-feeds", - "pallet-grandpa-finality-verifier", "pallet-messenger", - "pallet-object-store", "pallet-offences-subspace", "pallet-rewards", "pallet-runtime-configs", @@ -11911,10 +11908,7 @@ dependencies = [ "orml-vesting", "pallet-balances", "pallet-domains", - "pallet-feeds", - "pallet-grandpa-finality-verifier", "pallet-messenger", - "pallet-object-store", "pallet-offences-subspace", "pallet-rewards", "pallet-subspace", diff --git a/crates/subspace-runtime/Cargo.toml b/crates/subspace-runtime/Cargo.toml index ec1f0b9cce..c70969185c 100644 --- a/crates/subspace-runtime/Cargo.toml +++ b/crates/subspace-runtime/Cargo.toml @@ -27,10 +27,7 @@ frame-system-rpc-runtime-api = { version = "4.0.0-dev", default-features = false orml-vesting = { version = "0.4.1-dev", default-features = false, path = "../../orml/vesting" } pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } pallet-domains = { version = "0.1.0", default-features = false, path = "../pallet-domains" } -pallet-feeds = { version = "0.1.0", default-features = false, path = "../pallet-feeds" } -pallet-grandpa-finality-verifier = { version = "0.1.0", default-features = false, path = "../pallet-grandpa-finality-verifier" } pallet-messenger = { version = "0.1.0", path = "../../domains/pallets/messenger", default-features = false } -pallet-object-store = { version = "0.1.0", default-features = false, path = "../pallet-object-store" } pallet-offences-subspace = { version = "0.1.0", default-features = false, path = "../pallet-offences-subspace" } pallet-rewards = { version = "0.1.0", default-features = false, path = "../pallet-rewards" } pallet-runtime-configs = { version = "0.1.0", default-features = false, path = "../pallet-runtime-configs" } @@ -84,10 +81,7 @@ std = [ "orml-vesting/std", "pallet-balances/std", "pallet-domains/std", - "pallet-feeds/std", - "pallet-grandpa-finality-verifier/std", "pallet-messenger/std", - "pallet-object-store/std", "pallet-offences-subspace/std", "pallet-rewards/std", "pallet-runtime-configs/std", diff --git a/crates/subspace-runtime/src/feed_processor.rs b/crates/subspace-runtime/src/feed_processor.rs deleted file mode 100644 index e57472932f..0000000000 --- a/crates/subspace-runtime/src/feed_processor.rs +++ /dev/null @@ -1,104 +0,0 @@ -use crate::{FeedId, Runtime}; -use codec::{Decode, Encode}; -use pallet_feeds::feed_processor::{FeedMetadata, FeedObjectMapping, FeedProcessor}; -use pallet_grandpa_finality_verifier::chain::Chain; -use scale_info::TypeInfo; -use sp_api::HeaderT; -use sp_core::Hasher; -use sp_runtime::traits::BlakeTwo256; -use sp_runtime::{generic, DispatchError}; -use sp_std::prelude::*; - -/// Polkadot-like chain. -struct PolkadotLike; -impl Chain for PolkadotLike { - type BlockNumber = u32; - type Hash = ::Out; - type Header = generic::Header; - type Hasher = BlakeTwo256; -} - -/// Type used to represent a FeedId or ChainId -struct GrandpaValidator(C); - -impl FeedProcessor for GrandpaValidator { - fn init(&self, feed_id: FeedId, data: &[u8]) -> sp_runtime::DispatchResult { - pallet_grandpa_finality_verifier::initialize::(feed_id, data) - } - - fn put(&self, feed_id: FeedId, object: &[u8]) -> Result, DispatchError> { - Ok(Some( - pallet_grandpa_finality_verifier::validate_finalized_block::( - feed_id, object, - )? - .encode(), - )) - } - - fn object_mappings(&self, _feed_id: FeedId, object: &[u8]) -> Vec { - extract_substrate_object_mapping::(object) - } - - fn delete(&self, feed_id: FeedId) -> sp_runtime::DispatchResult { - pallet_grandpa_finality_verifier::purge::(feed_id) - } -} - -struct ParachainImporter(C); - -impl FeedProcessor for ParachainImporter { - fn put(&self, _feed_id: FeedId, object: &[u8]) -> Result, DispatchError> { - let block = C::decode_block::(object)?; - Ok(Some( - (block.block.header.hash(), *block.block.header.number()).encode(), - )) - } - fn object_mappings(&self, _feed_id: FeedId, object: &[u8]) -> Vec { - extract_substrate_object_mapping::(object) - } -} - -fn extract_substrate_object_mapping(object: &[u8]) -> Vec { - let block = match C::decode_block::(object) { - Ok(block) => block, - // we just return empty if we failed to decode as this is not called in runtime - Err(_) => return vec![], - }; - - // we send two mappings pointed to the same object - // block height and block hash - // this would be easier for sync client to crawl through the descendents by block height - // if you already have a block hash, you can fetch the same block with it as well - vec![ - FeedObjectMapping::Custom { - key: block.block.header.number().encode(), - offset: 0, - }, - FeedObjectMapping::Custom { - key: block.block.header.hash().as_ref().to_vec(), - offset: 0, - }, - ] -} - -/// FeedProcessorId represents the available FeedProcessor impls -#[derive(Default, Debug, Clone, Copy, Encode, Decode, TypeInfo, Eq, PartialEq)] -pub enum FeedProcessorKind { - /// Content addressable Feed processor, - #[default] - ContentAddressable, - /// Polkadot like relay chain Feed processor that validates grandpa justifications and indexes the entire block - PolkadotLike, - /// Parachain Feed processor that just indexes the entire block - ParachainLike, -} - -pub(crate) fn feed_processor( - feed_processor_kind: FeedProcessorKind, -) -> Box> { - match feed_processor_kind { - FeedProcessorKind::PolkadotLike => Box::new(GrandpaValidator(PolkadotLike)), - FeedProcessorKind::ContentAddressable => Box::new(()), - FeedProcessorKind::ParachainLike => Box::new(ParachainImporter(PolkadotLike)), - } -} diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index b8626b0d9f..83ee884fcd 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -20,7 +20,6 @@ #![recursion_limit = "256"] mod domains; -mod feed_processor; mod fees; mod object_mapping; mod signed_extensions; @@ -29,8 +28,6 @@ mod signed_extensions; #[cfg(feature = "std")] include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); -use crate::feed_processor::feed_processor; -pub use crate::feed_processor::FeedProcessorKind; use crate::fees::{OnChargeTransaction, TransactionByteFee}; use crate::object_mapping::extract_block_object_mapping; use crate::signed_extensions::{CheckStorageAccess, DisablePallets}; @@ -48,7 +45,6 @@ use frame_support::weights::{ConstantMultiplier, IdentityFee, Weight}; use frame_support::{construct_runtime, parameter_types, PalletId}; use frame_system::limits::{BlockLength, BlockWeights}; use frame_system::EnsureNever; -use pallet_feeds::feed_processor::FeedProcessor; pub use pallet_subspace::AllowAuthoringBy; use pallet_transporter::EndpointHandler; use scale_info::TypeInfo; @@ -671,34 +667,6 @@ impl pallet_rewards::Config for Runtime { type OnReward = StakingOnReward; } -pub type FeedId = u64; - -parameter_types! { - // Limit maximum number of feeds per account - pub const MaxFeeds: u32 = 100; -} - -impl pallet_feeds::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type FeedId = FeedId; - type FeedProcessorKind = FeedProcessorKind; - type MaxFeeds = MaxFeeds; - - fn feed_processor( - feed_processor_kind: Self::FeedProcessorKind, - ) -> Box> { - feed_processor(feed_processor_kind) - } -} - -impl pallet_grandpa_finality_verifier::Config for Runtime { - type ChainId = FeedId; -} - -impl pallet_object_store::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - impl pallet_runtime_configs::Config for Runtime { type WeightInfo = pallet_runtime_configs::weights::SubstrateWeight; } @@ -732,9 +700,6 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 7, Utility: pallet_utility = 8, - Feeds: pallet_feeds = 9, - GrandpaFinalityVerifier: pallet_grandpa_finality_verifier = 10, - ObjectStore: pallet_object_store = 11, Domains: pallet_domains = 12, RuntimeConfigs: pallet_runtime_configs = 14, @@ -921,7 +886,8 @@ impl_runtime_apis! { } fn validated_object_call_hashes() -> Vec { - Feeds::successful_puts() + // No pallets produce objects right now + Vec::new() } } diff --git a/crates/subspace-runtime/src/object_mapping.rs b/crates/subspace-runtime/src/object_mapping.rs index f083c409fb..8e43f89d6c 100644 --- a/crates/subspace-runtime/src/object_mapping.rs +++ b/crates/subspace-runtime/src/object_mapping.rs @@ -1,7 +1,5 @@ use crate::{Block, Runtime, RuntimeCall}; use codec::{Compact, CompactLen, Encode}; -use sp_api::HashT; -use sp_runtime::traits::BlakeTwo256; use sp_std::iter::Peekable; use sp_std::prelude::*; use subspace_core_primitives::objects::{BlockObject, BlockObjectMapping}; @@ -9,48 +7,6 @@ use subspace_runtime_primitives::Hash; const MAX_OBJECT_MAPPING_RECURSION_DEPTH: u16 = 5; -pub(crate) fn extract_feeds_block_object_mapping>( - base_offset: u32, - objects: &mut Vec, - call: &pallet_feeds::Call, - successful_calls: &mut Peekable, -) { - let call_hash = successful_calls.peek(); - match call_hash { - Some(hash) => { - if ::hash(call.encode().as_slice()) != *hash { - return; - } - - // remove the hash and fetch the object mapping for this call - successful_calls.next(); - } - None => return, - } - - call.extract_call_objects() - .into_iter() - .for_each(|object_map| { - objects.push(BlockObject::V0 { - hash: object_map.key, - offset: base_offset + object_map.offset, - }) - }) -} - -pub(crate) fn extract_object_store_block_object_mapping( - base_offset: u32, - objects: &mut Vec, - call: &pallet_object_store::Call, -) { - if let Some(call_object) = call.extract_call_object() { - objects.push(BlockObject::V0 { - hash: call_object.hash, - offset: base_offset + call_object.offset, - }); - } -} - pub(crate) fn extract_utility_block_object_mapping>( mut base_offset: u32, objects: &mut Vec, @@ -132,23 +88,14 @@ pub(crate) fn extract_call_block_object_mapping>( // Add enum variant to the base offset. base_offset += 1; - match call { - RuntimeCall::Feeds(call) => { - extract_feeds_block_object_mapping(base_offset, objects, call, successful_calls); - } - RuntimeCall::ObjectStore(call) => { - extract_object_store_block_object_mapping(base_offset, objects, call); - } - RuntimeCall::Utility(call) => { - extract_utility_block_object_mapping( - base_offset, - objects, - call, - recursion_depth_left, - successful_calls, - ); - } - _ => {} + if let RuntimeCall::Utility(call) = call { + extract_utility_block_object_mapping( + base_offset, + objects, + call, + recursion_depth_left, + successful_calls, + ); } } diff --git a/crates/subspace-runtime/tests/integration/main.rs b/crates/subspace-runtime/tests/integration/main.rs deleted file mode 100644 index 566b9d2cfd..0000000000 --- a/crates/subspace-runtime/tests/integration/main.rs +++ /dev/null @@ -1 +0,0 @@ -mod object_mapping; diff --git a/crates/subspace-runtime/tests/integration/object_mapping.rs b/crates/subspace-runtime/tests/integration/object_mapping.rs deleted file mode 100644 index c33f00985b..0000000000 --- a/crates/subspace-runtime/tests/integration/object_mapping.rs +++ /dev/null @@ -1,338 +0,0 @@ -use codec::Encode; -use hex_literal::hex; -use sp_objects::runtime_decl_for_objects_api::ObjectsApiV1; -use sp_runtime::traits::{BlakeTwo256, Hash as HashT}; -use sp_runtime::BuildStorage; -use subspace_core_primitives::objects::BlockObjectMapping; -use subspace_core_primitives::{crypto, Blake3Hash}; -use subspace_runtime::{ - Block, FeedProcessorKind, Feeds, Header, Runtime, RuntimeCall, RuntimeOrigin, System, - UncheckedExtrinsic, -}; -use subspace_runtime_primitives::Hash; - -#[test] -fn object_mapping() { - let data0: Vec = (0..=99).collect(); - let data1: Vec = (123..=255).collect(); - let data2: Vec = (0..=99).rev().collect(); - let data3: Vec = (123..=255).rev().collect(); - // let (init_data, key, object) = get_encoded_blocks(); - let block = Block { - header: Header { - parent_hash: Default::default(), - number: Default::default(), - state_root: Default::default(), - extrinsics_root: Default::default(), - digest: Default::default(), - }, - extrinsics: vec![ - UncheckedExtrinsic { - signature: None, - function: RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data0.clone(), - }), - }, - UncheckedExtrinsic { - signature: None, - function: RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data1.clone(), - }), - }, - // assuming this call fails, we will remove the 3rd hash from calls - UncheckedExtrinsic { - signature: None, - function: RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data0.clone(), - }), - }, - UncheckedExtrinsic { - signature: None, - function: RuntimeCall::Utility(pallet_utility::Call::batch { - calls: vec![ - RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data2.clone(), - }), - RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data3.clone(), - }), - ], - }), - }, - UncheckedExtrinsic { - signature: None, - function: RuntimeCall::Utility(pallet_utility::Call::as_derivative { - index: 0, - call: Box::new(RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data0.clone(), - })), - }), - }, - UncheckedExtrinsic { - signature: None, - function: RuntimeCall::Utility(pallet_utility::Call::batch_all { - calls: vec![ - RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data2.clone(), - }), - RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: data3.clone(), - }), - ], - }), - }, - ], - }; - - let mut successful_calls = get_successful_calls(block.clone()); - assert_eq!(successful_calls.len(), 8); - // remove third call signifying that it failed - successful_calls.remove(2); - - let encoded_block = block.encode(); - let BlockObjectMapping { objects } = new_test_ext().execute_with(|| { - // init feed - Feeds::create( - RuntimeOrigin::signed([0u8; 32].into()), - FeedProcessorKind::default(), - None, - ) - .expect("create feed should not fail"); - - Runtime::extract_block_object_mapping(block, successful_calls) - }); - - // Expect all 7 objects to be mapped. - assert_eq!(objects.len(), 7); - - // Hashes should be computed correctly. - assert_eq!(objects[0].hash(), crypto::blake3_hash(&data0)); - assert_eq!(objects[1].hash(), crypto::blake3_hash(&data1)); - assert_eq!(objects[2].hash(), crypto::blake3_hash(&data2)); - assert_eq!(objects[3].hash(), crypto::blake3_hash(&data3)); - assert_eq!(objects[4].hash(), crypto::blake3_hash(&data0)); - assert_eq!(objects[5].hash(), crypto::blake3_hash(&data2)); - assert_eq!(objects[6].hash(), crypto::blake3_hash(&data3)); - - // Offsets for mapped objects should be correct - assert_eq!( - &encoded_block[objects[0].offset() as usize..][..data0.encoded_size()], - &data0.encode() - ); - assert_eq!( - &encoded_block[objects[1].offset() as usize..][..data1.encoded_size()], - &data1.encode() - ); - assert_eq!( - &encoded_block[objects[2].offset() as usize..][..data2.encoded_size()], - &data2.encode() - ); - assert_eq!( - &encoded_block[objects[3].offset() as usize..][..data3.encoded_size()], - &data3.encode() - ); - assert_eq!( - &encoded_block[objects[4].offset() as usize..][..data0.encoded_size()], - &data0.encode() - ); - assert_eq!( - &encoded_block[objects[5].offset() as usize..][..data2.encoded_size()], - &data2.encode() - ); - assert_eq!( - &encoded_block[objects[6].offset() as usize..][..data3.encoded_size()], - &data3.encode() - ); -} - -fn get_successful_calls(block: Block) -> Vec { - block - .extrinsics - .iter() - .filter_map(|ext| match &ext.function { - RuntimeCall::Feeds(call) => Some(vec![call.encode()]), - RuntimeCall::Utility(call) => match call { - pallet_utility::Call::batch { calls } - | pallet_utility::Call::batch_all { calls } => Some( - calls - .iter() - .filter_map(|call| match &call { - RuntimeCall::Feeds(call) => Some(call.encode()), - _ => None, - }) - .collect(), - ), - pallet_utility::Call::as_derivative { call, .. } => match call.as_ref() { - RuntimeCall::Feeds(call) => Some(vec![call.encode()]), - _ => None, - }, - _ => None, - }, - _ => None, - }) - .flatten() - .map(|call_encoded| BlakeTwo256::hash(call_encoded.as_slice())) - .collect() -} - -fn key(feed_id: u64, data: &[u8]) -> Blake3Hash { - crypto::blake3_hash_list(&[&feed_id.encode(), data]) -} - -#[test] -fn grandpa_object_mapping() { - let (init_data, keys, object) = get_encoded_blocks(); - let block = Block { - header: Header { - parent_hash: Default::default(), - number: Default::default(), - state_root: Default::default(), - extrinsics_root: Default::default(), - digest: Default::default(), - }, - extrinsics: vec![UncheckedExtrinsic { - signature: None, - function: RuntimeCall::Feeds(pallet_feeds::Call::put { - feed_id: 0, - object: object.clone(), - }), - }], - }; - let successful_calls = get_successful_calls(block.clone()); - let encoded_block = block.encode(); - let BlockObjectMapping { objects } = new_test_ext().execute_with(|| { - // init feed - Feeds::create( - RuntimeOrigin::signed([0u8; 32].into()), - FeedProcessorKind::PolkadotLike, - Some(init_data), - ) - .expect("create feed should not fail"); - - Runtime::extract_block_object_mapping(block, successful_calls) - }); - - assert_eq!(objects.len(), 2); - // Hashes should be computed correctly. - assert_eq!(objects[0].hash(), keys[0]); - assert_eq!(objects[1].hash(), keys[1]); - - // Offsets for mapped objects should be correct - assert_eq!( - &encoded_block[objects[0].offset() as usize..][..object.encoded_size()], - object.encode() - ); - - // Offsets for mapped objects should be correct - assert_eq!( - &encoded_block[objects[1].offset() as usize..][..object.encoded_size()], - object.encode() - ); -} - -fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::::default() - .build_storage() - .unwrap(); - - let mut t: sp_io::TestExternalities = t.into(); - - t.execute_with(|| System::set_block_number(1)); - - t -} - -// returns init data, encoded signed block with finality verification, and the block hash -fn get_encoded_blocks() -> (Vec, Vec, Vec) { - let init_data = vec![ - 157, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 12, 66, 41, 215, 144, 185, 38, 223, 251, 103, 136, 167, 205, 48, 247, - 245, 28, 200, 92, 210, 10, 234, 212, 165, 58, 82, 218, 131, 252, 28, 13, 4, 4, 4, 70, 82, - 78, 75, 249, 1, 1, 12, 59, 106, 39, 188, 206, 182, 164, 45, 98, 163, 168, 208, 42, 111, 13, - 115, 101, 50, 21, 119, 29, 226, 67, 166, 58, 192, 72, 161, 139, 89, 218, 41, 1, 0, 0, 0, 0, - 0, 0, 0, 206, 204, 21, 7, 220, 29, 221, 114, 149, 149, 28, 41, 8, 136, 240, 149, 173, 185, - 4, 77, 27, 115, 214, 150, 230, 223, 6, 93, 104, 59, 212, 252, 1, 0, 0, 0, 0, 0, 0, 0, 107, - 121, 197, 126, 106, 9, 82, 57, 40, 44, 4, 129, 142, 150, 17, 47, 63, 3, 164, 0, 27, 169, - 122, 86, 76, 35, 133, 42, 63, 30, 165, 252, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, - ]; - - ( - init_data, - vec![ - key(0, 0u32.encode().as_slice()), - key( - 0, - hex!("9ab5950cd99156c777eea82c159b26d12474921d755ae404c07695fcaaf83ea1").as_slice(), - ), - ], - vec![ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 12, 66, 41, 215, 144, 185, 38, 223, 251, 103, 136, 167, 205, 48, - 247, 245, 28, 200, 92, 210, 10, 234, 212, 165, 58, 82, 218, 131, 252, 28, 13, 4, 4, 4, - 70, 82, 78, 75, 249, 1, 1, 12, 59, 106, 39, 188, 206, 182, 164, 45, 98, 163, 168, 208, - 42, 111, 13, 115, 101, 50, 21, 119, 29, 226, 67, 166, 58, 192, 72, 161, 139, 89, 218, - 41, 1, 0, 0, 0, 0, 0, 0, 0, 206, 204, 21, 7, 220, 29, 221, 114, 149, 149, 28, 41, 8, - 136, 240, 149, 173, 185, 4, 77, 27, 115, 214, 150, 230, 223, 6, 93, 104, 59, 212, 252, - 1, 0, 0, 0, 0, 0, 0, 0, 107, 121, 197, 126, 106, 9, 82, 57, 40, 44, 4, 129, 142, 150, - 17, 47, 63, 3, 164, 0, 27, 169, 122, 86, 76, 35, 133, 42, 63, 30, 165, 252, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 4, 253, 3, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, - 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, - 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, - 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, - 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, - 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, - 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, - 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, - 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 1, - 4, 70, 82, 78, 75, 41, 10, 1, 0, 0, 0, 0, 0, 0, 0, 154, 181, 149, 12, 217, 145, 86, - 199, 119, 238, 168, 44, 21, 155, 38, 209, 36, 116, 146, 29, 117, 90, 228, 4, 192, 118, - 149, 252, 170, 248, 62, 161, 0, 0, 0, 0, 12, 194, 59, 33, 177, 167, 99, 139, 55, 214, - 52, 34, 123, 121, 206, 178, 56, 129, 10, 241, 247, 80, 167, 175, 231, 60, 66, 31, 225, - 129, 164, 145, 115, 2, 0, 0, 0, 146, 123, 28, 194, 224, 21, 138, 186, 136, 98, 86, 236, - 179, 191, 237, 249, 131, 92, 149, 42, 94, 6, 243, 65, 95, 67, 5, 83, 164, 86, 191, 190, - 61, 178, 214, 66, 169, 63, 198, 67, 44, 251, 31, 96, 224, 201, 117, 209, 250, 130, 219, - 142, 112, 2, 219, 208, 78, 182, 235, 104, 128, 223, 44, 12, 59, 106, 39, 188, 206, 182, - 164, 45, 98, 163, 168, 208, 42, 111, 13, 115, 101, 50, 21, 119, 29, 226, 67, 166, 58, - 192, 72, 161, 139, 89, 218, 41, 194, 59, 33, 177, 167, 99, 139, 55, 214, 52, 34, 123, - 121, 206, 178, 56, 129, 10, 241, 247, 80, 167, 175, 231, 60, 66, 31, 225, 129, 164, - 145, 115, 2, 0, 0, 0, 252, 83, 154, 187, 244, 207, 175, 247, 38, 175, 88, 94, 168, 210, - 97, 128, 48, 36, 67, 125, 63, 84, 110, 123, 111, 149, 79, 12, 93, 205, 150, 230, 129, - 59, 15, 140, 253, 188, 213, 44, 130, 254, 16, 221, 141, 201, 99, 122, 219, 41, 236, - 179, 80, 177, 156, 44, 126, 61, 144, 197, 9, 1, 114, 1, 206, 204, 21, 7, 220, 29, 221, - 114, 149, 149, 28, 41, 8, 136, 240, 149, 173, 185, 4, 77, 27, 115, 214, 150, 230, 223, - 6, 93, 104, 59, 212, 252, 194, 59, 33, 177, 167, 99, 139, 55, 214, 52, 34, 123, 121, - 206, 178, 56, 129, 10, 241, 247, 80, 167, 175, 231, 60, 66, 31, 225, 129, 164, 145, - 115, 2, 0, 0, 0, 163, 20, 66, 157, 116, 143, 137, 49, 28, 129, 222, 207, 26, 70, 101, - 230, 237, 107, 243, 76, 78, 2, 87, 139, 200, 218, 199, 80, 132, 207, 232, 212, 205, - 222, 246, 19, 142, 134, 245, 15, 16, 121, 200, 48, 8, 101, 143, 95, 70, 132, 243, 197, - 157, 110, 126, 36, 167, 12, 93, 25, 2, 224, 66, 9, 107, 121, 197, 126, 106, 9, 82, 57, - 40, 44, 4, 129, 142, 150, 17, 47, 63, 3, 164, 0, 27, 169, 122, 86, 76, 35, 133, 42, 63, - 30, 165, 252, 8, 154, 181, 149, 12, 217, 145, 86, 199, 119, 238, 168, 44, 21, 155, 38, - 209, 36, 116, 146, 29, 117, 90, 228, 4, 192, 118, 149, 252, 170, 248, 62, 161, 4, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 12, 66, 41, 215, 144, 185, 38, 223, 251, 103, 136, 167, 205, 48, 247, 245, 28, 200, - 92, 210, 10, 234, 212, 165, 58, 82, 218, 131, 252, 28, 13, 4, 4, 0, 16, 0, 0, 0, 0, - 222, 46, 166, 66, 115, 122, 201, 206, 232, 161, 134, 15, 159, 154, 51, 219, 59, 155, - 162, 58, 4, 248, 240, 204, 152, 96, 186, 255, 125, 225, 73, 232, 8, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 66, - 41, 215, 144, 185, 38, 223, 251, 103, 136, 167, 205, 48, 247, 245, 28, 200, 92, 210, - 10, 234, 212, 165, 58, 82, 218, 131, 252, 28, 13, 4, 4, 0, 16, 0, 0, 0, 0, - ], - ) -} diff --git a/test/subspace-test-runtime/Cargo.toml b/test/subspace-test-runtime/Cargo.toml index a9fbd0ab28..bbbe709f01 100644 --- a/test/subspace-test-runtime/Cargo.toml +++ b/test/subspace-test-runtime/Cargo.toml @@ -24,10 +24,7 @@ frame-system = { version = "4.0.0-dev", default-features = false, git = "https:/ orml-vesting = { version = "0.4.1-dev", default-features = false, path = "../../orml/vesting" } pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "892bf8e938c6bd2b893d3827d1093cd81baa59a1" } pallet-domains = { version = "0.1.0", default-features = false, path = "../../crates/pallet-domains" } -pallet-feeds = { version = "0.1.0", default-features = false, path = "../../crates/pallet-feeds" } -pallet-grandpa-finality-verifier = { version = "0.1.0", default-features = false, path = "../../crates/pallet-grandpa-finality-verifier" } pallet-messenger = { version = "0.1.0", path = "../../domains/pallets/messenger", default-features = false } -pallet-object-store = { version = "0.1.0", default-features = false, path = "../../crates/pallet-object-store" } pallet-offences-subspace = { version = "0.1.0", default-features = false, path = "../../crates/pallet-offences-subspace" } pallet-rewards = { version = "0.1.0", default-features = false, path = "../../crates/pallet-rewards" } pallet-subspace = { version = "0.1.0", default-features = false, features = ["serde"], path = "../../crates/pallet-subspace" } @@ -77,10 +74,7 @@ std = [ "orml-vesting/std", "pallet-balances/std", "pallet-domains/std", - "pallet-feeds/std", - "pallet-grandpa-finality-verifier/std", "pallet-messenger/std", - "pallet-object-store/std", "pallet-offences-subspace/std", "pallet-rewards/std", "pallet-subspace/std", diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index f4f88055d2..afea9bfed9 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -40,12 +40,10 @@ use frame_support::{construct_runtime, parameter_types, PalletId}; use frame_system::limits::{BlockLength, BlockWeights}; use frame_system::EnsureNever; use pallet_balances::NegativeImbalance; -use pallet_feeds::feed_processor::{FeedMetadata, FeedObjectMapping, FeedProcessor}; -use pallet_grandpa_finality_verifier::chain::Chain; pub use pallet_subspace::AllowAuthoringBy; use pallet_transporter::EndpointHandler; use scale_info::TypeInfo; -use sp_api::{impl_runtime_apis, BlockT, HashT, HeaderT}; +use sp_api::{impl_runtime_apis, BlockT}; use sp_consensus_slots::SlotDuration; use sp_consensus_subspace::{ ChainConstants, EquivocationProof, FarmerPublicKey, PotParameters, SignedVote, SolutionRanges, @@ -53,7 +51,7 @@ use sp_consensus_subspace::{ }; use sp_core::crypto::{ByteArray, KeyTypeId}; use sp_core::storage::StateVersion; -use sp_core::{Hasher, OpaqueMetadata, H256}; +use sp_core::{OpaqueMetadata, H256}; use sp_domains::bundle_producer_election::BundleProducerElectionParams; use sp_domains::{ DomainId, DomainInstanceData, DomainsHoldIdentifier, ExecutionReceipt, OpaqueBundle, @@ -72,9 +70,7 @@ use sp_runtime::traits::{ use sp_runtime::transaction_validity::{ InvalidTransaction, TransactionSource, TransactionValidity, TransactionValidityError, }; -use sp_runtime::{ - create_runtime_str, generic, AccountId32, ApplyExtrinsicResult, DispatchError, Perbill, -}; +use sp_runtime::{create_runtime_str, generic, AccountId32, ApplyExtrinsicResult, Perbill}; use sp_std::iter::Peekable; use sp_std::marker::PhantomData; use sp_std::prelude::*; @@ -686,76 +682,6 @@ impl pallet_rewards::Config for Runtime { type OnReward = (); } -/// Polkadot-like chain. -struct PolkadotLike; - -impl Chain for PolkadotLike { - type BlockNumber = u32; - type Hash = ::Out; - type Header = generic::Header; - type Hasher = BlakeTwo256; -} - -/// Type used to represent a FeedId or ChainId -pub type FeedId = u64; - -pub struct GrandpaValidator(PhantomData); - -impl FeedProcessor for GrandpaValidator { - fn init(&self, feed_id: FeedId, data: &[u8]) -> sp_runtime::DispatchResult { - pallet_grandpa_finality_verifier::initialize::(feed_id, data) - } - - fn put(&self, feed_id: FeedId, object: &[u8]) -> Result, DispatchError> { - Ok(Some( - pallet_grandpa_finality_verifier::validate_finalized_block::( - feed_id, object, - )? - .encode(), - )) - } - - fn object_mappings(&self, _feed_id: FeedId, object: &[u8]) -> Vec { - let block = match C::decode_block::(object) { - Ok(block) => block, - // we just return empty if we failed to decode as this is not called in runtime - Err(_) => return vec![], - }; - // for substrate, we store the height and block hash at that height - let key = (*block.block.header.number(), block.block.header.hash()).encode(); - vec![FeedObjectMapping::Custom { key, offset: 0 }] - } - - fn delete(&self, feed_id: FeedId) -> sp_runtime::DispatchResult { - pallet_grandpa_finality_verifier::purge::(feed_id) - } -} - -parameter_types! { - pub const MaxFeeds: u32 = 10; -} - -impl pallet_feeds::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type FeedId = FeedId; - type FeedProcessorKind = (); - type MaxFeeds = MaxFeeds; - - fn feed_processor( - _feed_processor_id: Self::FeedProcessorKind, - ) -> Box> { - Box::new(GrandpaValidator(PhantomData::)) - } -} - -impl pallet_grandpa_finality_verifier::Config for Runtime { - type ChainId = FeedId; -} - -impl pallet_object_store::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - parameter_types! { // This value doesn't matter, we don't use it (`VestedTransferOrigin = EnsureNever` below). pub const MinVestedTransfer: Balance = 0; @@ -785,9 +711,6 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 5, Utility: pallet_utility = 8, - Feeds: pallet_feeds = 6, - GrandpaFinalityVerifier: pallet_grandpa_finality_verifier = 13, - ObjectStore: pallet_object_store = 10, Domains: pallet_domains = 11, Vesting: orml_vesting = 7, @@ -866,47 +789,6 @@ fn extract_xdm_proof_state_roots( } } -fn extract_feeds_block_object_mapping>( - base_offset: u32, - objects: &mut Vec, - call: &pallet_feeds::Call, - successful_calls: &mut Peekable, -) { - let call_hash = successful_calls.peek(); - match call_hash { - Some(hash) => { - if ::hash(call.encode().as_slice()) != *hash { - return; - } - - // remove the hash and fetch the object mapping for this call - successful_calls.next(); - } - None => return, - } - call.extract_call_objects() - .into_iter() - .for_each(|object_map| { - objects.push(BlockObject::V0 { - hash: object_map.key, - offset: base_offset + object_map.offset, - }) - }) -} - -fn extract_object_store_block_object_mapping( - base_offset: u32, - objects: &mut Vec, - call: &pallet_object_store::Call, -) { - if let Some(call_object) = call.extract_call_object() { - objects.push(BlockObject::V0 { - hash: call_object.hash, - offset: base_offset + call_object.offset, - }); - } -} - fn extract_utility_block_object_mapping>( mut base_offset: u32, objects: &mut Vec, @@ -988,23 +870,14 @@ fn extract_call_block_object_mapping>( // Add enum variant to the base offset. base_offset += 1; - match call { - RuntimeCall::Feeds(call) => { - extract_feeds_block_object_mapping(base_offset, objects, call, successful_calls); - } - RuntimeCall::ObjectStore(call) => { - extract_object_store_block_object_mapping(base_offset, objects, call); - } - RuntimeCall::Utility(call) => { - extract_utility_block_object_mapping( - base_offset, - objects, - call, - recursion_depth_left, - successful_calls, - ); - } - _ => {} + if let RuntimeCall::Utility(call) = call { + extract_utility_block_object_mapping( + base_offset, + objects, + call, + recursion_depth_left, + successful_calls, + ); } } @@ -1195,7 +1068,8 @@ impl_runtime_apis! { } fn validated_object_call_hashes() -> Vec { - Feeds::successful_puts() + // No pallets produce objects right now + Vec::new() } }