From ce6a1becca14314d0a60781470b796fae7a06d78 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 1 Oct 2024 11:50:01 +1000 Subject: [PATCH 1/2] Add history seeding to the test runtime --- Cargo.lock | 1 + test/subspace-test-client/src/chain_spec.rs | 10 +++++++--- test/subspace-test-runtime/Cargo.toml | 1 + test/subspace-test-runtime/src/lib.rs | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3140fa39b7..f39400dd9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13127,6 +13127,7 @@ dependencies = [ "frame-system-rpc-runtime-api", "pallet-balances", "pallet-domains", + "pallet-history-seeding", "pallet-messenger", "pallet-mmr", "pallet-offences-subspace", diff --git a/test/subspace-test-client/src/chain_spec.rs b/test/subspace-test-client/src/chain_spec.rs index 96058be781..88310eca96 100644 --- a/test/subspace-test-client/src/chain_spec.rs +++ b/test/subspace-test-client/src/chain_spec.rs @@ -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. @@ -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(), }) } diff --git a/test/subspace-test-runtime/Cargo.toml b/test/subspace-test-runtime/Cargo.toml index bc9ca2e02f..e507bd04bc 100644 --- a/test/subspace-test-runtime/Cargo.toml +++ b/test/subspace-test-runtime/Cargo.toml @@ -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" } diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 2a01ba49c1..4c20616b54 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -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; +} + impl pallet_subspace::Config for Runtime { type RuntimeEvent = RuntimeEvent; type BlockAuthoringDelay = BlockAuthoringDelay; @@ -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, } From 9a39049986bf378a845486dcff8c0b8bf477e1a5 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 1 Oct 2024 11:50:33 +1000 Subject: [PATCH 2/2] Add object mappings for remark_with_event & seed_history --- crates/subspace-runtime/src/object_mapping.rs | 15 +++++++++++++++ test/subspace-test-runtime/src/lib.rs | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/crates/subspace-runtime/src/object_mapping.rs b/crates/subspace-runtime/src/object_mapping.rs index 16074f2c74..c41fd028a0 100644 --- a/crates/subspace-runtime/src/object_mapping.rs +++ b/crates/subspace-runtime/src/object_mapping.rs @@ -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) diff --git a/test/subspace-test-runtime/src/lib.rs b/test/subspace-test-runtime/src/lib.rs index 4c20616b54..2e75ba7678 100644 --- a/test/subspace-test-runtime/src/lib.rs +++ b/test/subspace-test-runtime/src/lib.rs @@ -1019,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)