Skip to content

Commit

Permalink
Merge pull request #2158 from subspace/remove-storage-pallets
Browse files Browse the repository at this point in the history
Remove storage pallets
  • Loading branch information
nazar-pc authored Oct 24, 2023
2 parents 5af517d + 9ff2bbd commit 4d63e88
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 697 deletions.
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions crates/subspace-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -85,10 +82,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",
Expand Down
104 changes: 0 additions & 104 deletions crates/subspace-runtime/src/feed_processor.rs

This file was deleted.

38 changes: 2 additions & 36 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#![recursion_limit = "256"]

mod domains;
mod feed_processor;
mod fees;
mod object_mapping;
mod signed_extensions;
Expand All @@ -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};
Expand All @@ -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;
Expand Down Expand Up @@ -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<dyn FeedProcessor<Self::FeedId>> {
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<Runtime>;
}
Expand Down Expand Up @@ -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,

Expand Down Expand Up @@ -921,7 +886,8 @@ impl_runtime_apis! {
}

fn validated_object_call_hashes() -> Vec<Hash> {
Feeds::successful_puts()
// No pallets produce objects right now
Vec::new()
}
}

Expand Down
69 changes: 8 additions & 61 deletions crates/subspace-runtime/src/object_mapping.rs
Original file line number Diff line number Diff line change
@@ -1,56 +1,12 @@
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};
use subspace_runtime_primitives::Hash;

const MAX_OBJECT_MAPPING_RECURSION_DEPTH: u16 = 5;

pub(crate) fn extract_feeds_block_object_mapping<I: Iterator<Item = Hash>>(
base_offset: u32,
objects: &mut Vec<BlockObject>,
call: &pallet_feeds::Call<Runtime>,
successful_calls: &mut Peekable<I>,
) {
let call_hash = successful_calls.peek();
match call_hash {
Some(hash) => {
if <BlakeTwo256 as HashT>::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<BlockObject>,
call: &pallet_object_store::Call<Runtime>,
) {
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<I: Iterator<Item = Hash>>(
mut base_offset: u32,
objects: &mut Vec<BlockObject>,
Expand Down Expand Up @@ -132,23 +88,14 @@ pub(crate) fn extract_call_block_object_mapping<I: Iterator<Item = Hash>>(
// 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,
);
}
}

Expand Down
1 change: 0 additions & 1 deletion crates/subspace-runtime/tests/integration/main.rs

This file was deleted.

Loading

0 comments on commit 4d63e88

Please sign in to comment.