Skip to content

Commit

Permalink
Merge pull request #3081 from autonomys/extra-mappings
Browse files Browse the repository at this point in the history
Extract object mappings for remark_with_event and seed_history
  • Loading branch information
nazar-pc authored Oct 1, 2024
2 parents fe64ec3 + 9a39049 commit 3543021
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

15 changes: 15 additions & 0 deletions crates/subspace-runtime/src/object_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ pub(crate) fn extract_call_block_object_mapping(
offset: base_offset + 1,
});
}
RuntimeCall::System(frame_system::Call::remark_with_event { remark }) => {
objects.push(BlockObject {
hash: crypto::blake3_hash(remark),
// Add frame_system::Call enum variant to the base offset.
offset: base_offset + 1,
});
}
RuntimeCall::HistorySeeding(pallet_history_seeding::Call::seed_history { remark }) => {
objects.push(BlockObject {
hash: crypto::blake3_hash(remark),
// Add pallet_history_seeding::Call enum variant to the base offset.
offset: base_offset + 1,
});
}

// Recursively extract object mappings for the call.
RuntimeCall::Utility(call) => {
extract_utility_block_object_mapping(base_offset, objects, call, recursion_depth_left)
Expand Down
10 changes: 7 additions & 3 deletions test/subspace-test-client/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use std::marker::PhantomData;
use std::num::NonZeroU32;
use subspace_runtime_primitives::{AccountId, Balance, Signature};
use subspace_test_runtime::{
AllowAuthoringBy, BalancesConfig, DomainsConfig, EnableRewardsAt, RewardsConfig,
RuntimeGenesisConfig, SubspaceConfig, SudoConfig, SystemConfig, SSC, WASM_BINARY,
AllowAuthoringBy, BalancesConfig, DomainsConfig, EnableRewardsAt, HistorySeedingConfig,
RewardsConfig, RuntimeGenesisConfig, SubspaceConfig, SudoConfig, SystemConfig, SSC,
WASM_BINARY,
};

/// Generate a crypto pair from seed.
Expand Down Expand Up @@ -90,10 +91,13 @@ fn create_genesis_config(
genesis_domains: vec![
crate::evm_domain_chain_spec::get_genesis_domain(sudo_account.clone())
.expect("Must success"),
crate::auto_id_domain_chain_spec::get_genesis_domain(sudo_account)
crate::auto_id_domain_chain_spec::get_genesis_domain(sudo_account.clone())
.expect("Must success"),
],
},
history_seeding: HistorySeedingConfig {
history_seeder: Some(sudo_account),
},
runtime_configs: Default::default(),
})
}
Expand Down
1 change: 1 addition & 0 deletions test/subspace-test-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ frame-support = { default-features = false, git = "https://github.com/subspace/p
frame-system = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631" }
pallet-balances = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631" }
pallet-domains = { version = "0.1.0", default-features = false, path = "../../crates/pallet-domains" }
pallet-history-seeding = { version = "0.1.0", default-features = false, path = "../../crates/pallet-history-seeding" }
pallet-messenger = { version = "0.1.0", path = "../../domains/pallets/messenger", default-features = false }
pallet-mmr = { default-features = false, git = "https://github.com/subspace/polkadot-sdk", rev = "5626154d0781ac9a6ffd5a6207ed237f425ae631" }
pallet-offences-subspace = { version = "0.1.0", default-features = false, path = "../../crates/pallet-offences-subspace" }
Expand Down
21 changes: 21 additions & 0 deletions test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ parameter_types! {
pub TransactionWeightFee: Balance = 100_000 * SHANNON;
}

impl pallet_history_seeding::Config for Runtime {
type WeightInfo = pallet_history_seeding::weights::SubstrateWeight<Runtime>;
}

impl pallet_subspace::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type BlockAuthoringDelay = BlockAuthoringDelay;
Expand Down Expand Up @@ -861,6 +865,8 @@ construct_runtime!(
Messenger: pallet_messenger exclude_parts { Inherent } = 60,
Transporter: pallet_transporter = 61,

HistorySeeding: pallet_history_seeding = 91,

// Reserve some room for other pallets as we'll remove sudo pallet eventually.
Sudo: pallet_sudo = 100,
}
Expand Down Expand Up @@ -1013,6 +1019,21 @@ fn extract_call_block_object_mapping(
offset: base_offset + 1,
});
}
RuntimeCall::System(frame_system::Call::remark_with_event { remark }) => {
objects.push(BlockObject {
hash: crypto::blake3_hash(remark),
// Add frame_system::Call enum variant to the base offset.
offset: base_offset + 1,
});
}
RuntimeCall::HistorySeeding(pallet_history_seeding::Call::seed_history { remark }) => {
objects.push(BlockObject {
hash: crypto::blake3_hash(remark),
// Add pallet_history_seeding::Call enum variant to the base offset.
offset: base_offset + 1,
});
}

// Recursively extract object mappings for the call.
RuntimeCall::Utility(call) => {
extract_utility_block_object_mapping(base_offset, objects, call, recursion_depth_left)
Expand Down

0 comments on commit 3543021

Please sign in to comment.