diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index ac016306c..253d27f76 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -86,14 +86,35 @@ macro_rules! decl_common_types { generic, DispatchError, DispatchResult, RuntimeDebug, SaturatedConversion, }; use zeitgeist_primitives::traits::{DeployPoolApi, DistributeFees, MarketCommonsPalletApi}; - use zrml_market_commons::migrations::{MigrateDisputeMechanism, RemoveMarkets}; pub type Block = generic::Block; type Address = sp_runtime::MultiAddress; - type Migrations = - (RemoveMarkets, MigrateDisputeMechanism); + parameter_types! { + pub const CampaignAssetsPalletStr: &'static str = "CampaignAssets"; + pub const CustomAssetsPalletStr: &'static str = "CustomAssets"; + pub const MarketAssetsPalletStr: &'static str = "MarketAssets"; + pub const LiquidityMiningPalletStr: &'static str = "LiquidityMining"; + pub const RikiddoPalletStr: &'static str = "Rikiddo"; + pub const SimpleDisputesPalletStr: &'static str = "SimpleDisputes"; + } + + type RemoveCustomAssets = RemovePallet; + type RemoveCampaignAssets = RemovePallet; + type RemoveMarketAssets = RemovePallet; + type RemoveLiquidityMining = RemovePallet; + type RemoveRikiddo = RemovePallet; + type RemoveSimpleDisputes = RemovePallet; + + type Migrations = ( + RemoveCustomAssets, + RemoveCampaignAssets, + RemoveMarketAssets, + RemoveLiquidityMining, + RemoveRikiddo, + RemoveSimpleDisputes, + ); pub type Executive = frame_executive::Executive< Runtime, diff --git a/zrml/market-commons/src/migrations.rs b/zrml/market-commons/src/migrations.rs index c532fcab4..7bcc6e2e5 100644 --- a/zrml/market-commons/src/migrations.rs +++ b/zrml/market-commons/src/migrations.rs @@ -15,672 +15,3 @@ // // You should have received a copy of the GNU General Public License // along with Zeitgeist. If not, see . - -use crate::{AccountIdOf, BalanceOf, Config, MarketIdOf, MomentOf, Pallet as MarketCommons}; -use alloc::{vec, vec::Vec}; -use core::marker::PhantomData; -use frame_support::{ - pallet_prelude::Weight, - storage::migration::get_storage_value, - traits::{Get, OnRuntimeUpgrade, StorageVersion}, - Blake2_128Concat, StorageHasher, -}; -use frame_system::pallet_prelude::BlockNumberFor; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use scale_info::TypeInfo; -use sp_runtime::{Perbill, RuntimeDebug, SaturatedConversion, Saturating}; -use zeitgeist_primitives::types::{ - Asset, Deadlines, EarlyClose, Market, MarketBonds, MarketCreation, MarketDisputeMechanism, - MarketPeriod, MarketStatus, MarketType, OutcomeReport, Report, ScoringRule, -}; - -#[cfg(feature = "try-runtime")] -use { - alloc::{collections::BTreeMap, format}, - frame_support::migration::storage_key_iter, - sp_runtime::DispatchError, -}; - -const MARKET_COMMONS: &[u8] = b"MarketCommons"; -const MARKETS: &[u8] = b"Markets"; - -const MARKET_COMMONS_REQUIRED_STORAGE_VERSION_0: u16 = 11; -const MARKET_COMMONS_NEXT_STORAGE_VERSION_0: u16 = 12; - -#[cfg(feature = "try-runtime")] -#[frame_support::storage_alias] -pub(crate) type Markets = - StorageMap, Blake2_128Concat, MarketIdOf, OldMarketOf>; - -// ID type of the campaign asset class. -pub type CampaignAssetId = u128; - -#[derive(Clone, Copy, Debug, Decode, Default, Eq, Encode, MaxEncodedLen, PartialEq, TypeInfo)] -pub enum BaseAssetClass { - #[codec(index = 4)] - #[default] - Ztg, - - #[codec(index = 5)] - ForeignAsset(u32), - - #[codec(index = 7)] - CampaignAsset(#[codec(compact)] CampaignAssetId), -} - -#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct OldMarketWithCampaignBaseAsset< - AccountId, - Balance, - BlockNumber, - Moment, - BaseAssetClass, - MarketId, -> { - pub market_id: MarketId, - /// Base asset of the market. - pub base_asset: BaseAssetClass, - /// Creator of this market. - pub creator: AccountId, - /// Creation type. - pub creation: MarketCreation, - /// A fee that is charged each trade and given to the market creator. - pub creator_fee: Perbill, - /// Oracle that reports the outcome of this market. - pub oracle: AccountId, - /// Metadata for the market, usually a content address of IPFS - /// hosted JSON. Currently limited to 66 bytes (see `MaxEncodedLen` implementation) - pub metadata: Vec, - /// The type of the market. - pub market_type: MarketType, - /// Market start and end - pub period: MarketPeriod, - /// Market deadlines. - pub deadlines: Deadlines, - /// The scoring rule used for the market. - pub scoring_rule: ScoringRule, - /// The current status of the market. - pub status: MarketStatus, - /// The report of the market. Only `Some` if it has been reported. - pub report: Option>, - /// The resolved outcome. - pub resolved_outcome: Option, - /// See [`MarketDisputeMechanism`]. - pub dispute_mechanism: Option, - /// The bonds reserved for this market. - pub bonds: MarketBonds, - /// The time at which the market was closed early. - pub early_close: Option>, -} - -type CorruptedMarketOf = OldMarketWithCampaignBaseAsset< - AccountIdOf, - BalanceOf, - BlockNumberFor, - MomentOf, - BaseAssetClass, - MarketIdOf, ->; - -pub struct RemoveMarkets(PhantomData, MarketIds); - -impl OnRuntimeUpgrade for RemoveMarkets -where - T: Config, - MarketIds: Get>, -{ - fn on_runtime_upgrade() -> Weight { - let mut total_weight = T::DbWeight::get().reads(1); - let market_commons_version = StorageVersion::get::>(); - if market_commons_version != MARKET_COMMONS_REQUIRED_STORAGE_VERSION_0 { - log::info!( - "RemoveMarkets: market-commons version is {:?}, but {:?} is required", - market_commons_version, - MARKET_COMMONS_REQUIRED_STORAGE_VERSION_0, - ); - return total_weight; - } - log::info!("RemoveMarkets: Starting..."); - - let mut corrupted_markets = vec![]; - - for &market_id in MarketIds::get().iter() { - let market_id = market_id.saturated_into::>(); - let is_corrupted = || { - if let Some(market) = get_storage_value::>( - MARKET_COMMONS, - MARKETS, - &MarketIdOf::::from(market_id).using_encoded(Blake2_128Concat::hash), - ) { - matches!(market.base_asset, BaseAssetClass::CampaignAsset(_)) - } else { - false - } - }; - if crate::Markets::::contains_key(market_id) && is_corrupted() { - crate::Markets::::remove(market_id); - corrupted_markets.push(market_id); - } else { - log::warn!( - "RemoveMarkets: Market {:?} was expected to be corrupted, but isn't.", - market_id - ); - } - } - - log::info!("RemoveMarkets: Removed markets {:?}.", corrupted_markets); - let count = MarketIds::get().len() as u64; - total_weight = total_weight - .saturating_add(T::DbWeight::get().reads_writes(count.saturating_mul(2u64), count)); - - StorageVersion::new(MARKET_COMMONS_NEXT_STORAGE_VERSION_0).put::>(); - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); - log::info!("RemoveMarkets: Done!"); - total_weight - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, DispatchError> { - Ok(vec![]) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_previous_state: Vec) -> Result<(), DispatchError> { - for &market_id in MarketIds::get().iter() { - let market_id = market_id.saturated_into::>(); - assert!(!crate::Markets::::contains_key(market_id)); - assert!(crate::Markets::::try_get(market_id).is_err()); - } - - log::info!("RemoveMarkets: Post-upgrade done!"); - Ok(()) - } -} - -const MARKET_COMMONS_REQUIRED_STORAGE_VERSION_1: u16 = 12; -const MARKET_COMMONS_NEXT_STORAGE_VERSION_1: u16 = 13; - -#[derive(Clone, Decode, Encode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct OldMarket { - pub market_id: MarketId, - /// Base asset of the market. - pub base_asset: Asset, - /// Creator of this market. - pub creator: AccountId, - /// Creation type. - pub creation: MarketCreation, - /// A fee that is charged each trade and given to the market creator. - pub creator_fee: Perbill, - /// Oracle that reports the outcome of this market. - pub oracle: AccountId, - /// Metadata for the market, usually a content address of IPFS - /// hosted JSON. Currently limited to 66 bytes (see `MaxEncodedLen` implementation) - pub metadata: Vec, - /// The type of the market. - pub market_type: MarketType, - /// Market start and end - pub period: MarketPeriod, - /// Market deadlines. - pub deadlines: Deadlines, - /// The scoring rule used for the market. - pub scoring_rule: ScoringRule, - /// The current status of the market. - pub status: MarketStatus, - /// The report of the market. Only `Some` if it has been reported. - pub report: Option>, - /// The resolved outcome. - pub resolved_outcome: Option, - /// See [`MarketDisputeMechanism`]. - pub dispute_mechanism: Option, - /// The bonds reserved for this market. - pub bonds: MarketBonds, - /// The time at which the market was closed early. - pub early_close: Option>, -} - -type OldMarketOf = - OldMarket, BalanceOf, BlockNumberFor, MomentOf, MarketIdOf>; - -#[derive(TypeInfo, Clone, Copy, Encode, Eq, Decode, MaxEncodedLen, PartialEq, RuntimeDebug)] -pub enum OldMarketDisputeMechanism { - Authorized, - Court, - SimpleDisputes, -} - -pub struct MigrateDisputeMechanism(PhantomData); - -/// Removes the `SimpleDisputes` MDM by switching markets that use `SimpleDisputes` to `Authorized`. -/// Note that this migration does not unreserve any funds bonded with zrml-simple-dispute's reserve -/// ID. -impl OnRuntimeUpgrade for MigrateDisputeMechanism -where - T: Config, -{ - fn on_runtime_upgrade() -> Weight { - let mut total_weight = T::DbWeight::get().reads(1); - let market_commons_version = StorageVersion::get::>(); - if market_commons_version != MARKET_COMMONS_REQUIRED_STORAGE_VERSION_1 { - log::info!( - "MigrateDisputeMechanism: market-commons version is {:?}, but {:?} is required", - market_commons_version, - MARKET_COMMONS_REQUIRED_STORAGE_VERSION_1, - ); - return total_weight; - } - log::info!("MigrateDisputeMechanism: Starting..."); - - let mut translated = 0u64; - crate::Markets::::translate::, _>(|_, old_market| { - translated.saturating_inc(); - let dispute_mechanism = match old_market.dispute_mechanism { - Some(OldMarketDisputeMechanism::Court) => Some(MarketDisputeMechanism::Court), - Some(_) => Some(MarketDisputeMechanism::Authorized), - None => None, - }; - let new_market = Market { - market_id: old_market.market_id, - base_asset: old_market.base_asset, - creator: old_market.creator, - creation: old_market.creation, - creator_fee: old_market.creator_fee, - oracle: old_market.oracle, - metadata: old_market.metadata, - market_type: old_market.market_type, - period: old_market.period, - deadlines: old_market.deadlines, - scoring_rule: old_market.scoring_rule, - status: old_market.status, - report: old_market.report, - resolved_outcome: old_market.resolved_outcome, - dispute_mechanism, - bonds: old_market.bonds, - early_close: old_market.early_close, - }; - Some(new_market) - }); - log::info!("MigrateDisputeMechanism: Upgraded {} markets.", translated); - total_weight = - total_weight.saturating_add(T::DbWeight::get().reads_writes(translated, translated)); - - StorageVersion::new(MARKET_COMMONS_NEXT_STORAGE_VERSION_1).put::>(); - total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); - log::info!("MigrateDisputeMechanism: Done!"); - total_weight - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, DispatchError> { - let old_markets = storage_key_iter::, OldMarketOf, Blake2_128Concat>( - MARKET_COMMONS, - MARKETS, - ) - .collect::>(); - let markets = Markets::::iter_keys().count(); - let decodable_markets = Markets::::iter_values().count(); - if markets == decodable_markets { - log::info!("All {} markets could successfully be decoded.", markets); - } else { - log::error!( - "Can only decode {} of {} markets - others will be dropped.", - decodable_markets, - markets - ); - } - - Ok(old_markets.encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(previous_state: Vec) -> Result<(), DispatchError> { - let old_markets: BTreeMap, OldMarketOf> = - Decode::decode(&mut &previous_state[..]).unwrap(); - let old_market_count = old_markets.len(); - let new_market_count = crate::Markets::::iter().count(); - assert_eq!(old_market_count, new_market_count); - for (market_id, new_market) in crate::Markets::::iter() { - let old_market = old_markets - .get(&market_id) - .expect(&format!("Market {:?} not found", market_id)[..]); - assert_eq!(old_market.market_id, new_market.market_id); - assert_eq!(old_market.base_asset, new_market.base_asset); - assert_eq!(old_market.creator, new_market.creator); - assert_eq!(old_market.creation, new_market.creation); - assert_eq!(old_market.creator_fee, new_market.creator_fee); - assert_eq!(old_market.oracle, new_market.oracle); - assert_eq!(old_market.metadata, new_market.metadata); - assert_eq!(old_market.market_type, new_market.market_type); - assert_eq!(old_market.period, new_market.period); - assert_eq!(old_market.deadlines, new_market.deadlines); - assert_eq!(old_market.status, new_market.status); - assert_eq!(old_market.report, new_market.report); - assert_eq!(old_market.resolved_outcome, new_market.resolved_outcome); - assert_eq!(old_market.bonds, new_market.bonds); - assert_eq!(old_market.early_close, new_market.early_close); - } - - log::info!("MigrateDisputeMechanism: Post-upgrade market count is {}!", new_market_count); - Ok(()) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::{ - mock::{ExtBuilder, Runtime}, - MarketOf, - }; - use alloc::fmt::Debug; - use frame_support::{ - migration::put_storage_value, parameter_types, Blake2_128Concat, StorageHasher, - }; - use parity_scale_codec::Encode; - use sp_io::storage::root as storage_root; - use sp_runtime::{Perbill, StateVersion}; - use test_case::test_case; - use zeitgeist_primitives::types::{Bond, EarlyCloseState, MarketId}; - - parameter_types! { - pub RemovableMarketIds: Vec = vec![879u32, 877u32, 878u32, 880u32, 882u32]; - pub NoRemovableMarketIds: Vec = vec![]; - } - - #[test] - fn on_runtime_upgrade_increments_the_storage_version() { - ExtBuilder::default().build().execute_with(|| { - set_up_version_remove_markets(); - RemoveMarkets::::on_runtime_upgrade(); - assert_eq!( - StorageVersion::get::>(), - MARKET_COMMONS_NEXT_STORAGE_VERSION_0 - ); - MigrateDisputeMechanism::::on_runtime_upgrade(); - assert_eq!( - StorageVersion::get::>(), - MARKET_COMMONS_NEXT_STORAGE_VERSION_1 - ); - }); - } - - #[test] - fn on_runtime_upgrade_remove_corrupted_markets_works_as_expected() { - ExtBuilder::default().build().execute_with(|| { - set_up_version_remove_markets(); - let pallet = MARKET_COMMONS; - let prefix = MARKETS; - let corrupted_market = construct_corrupt_market(); - for market_id in RemovableMarketIds::get().iter() { - let storage_hash = MarketId::from(*market_id).using_encoded(Blake2_128Concat::hash); - put_storage_value::>( - pallet, - prefix, - &storage_hash, - corrupted_market.clone(), - ); - } - - for market_id in RemovableMarketIds::get().iter() { - let market_id = MarketId::from(*market_id); - assert!(crate::Markets::::contains_key(market_id)); - } - - RemoveMarkets::::on_runtime_upgrade(); - - for market_id in RemovableMarketIds::get().iter() { - let market_id = MarketId::from(*market_id); - assert!(!crate::Markets::::contains_key(market_id)); - } - }); - } - - #[test] - fn on_runtime_upgrade_does_not_remove_valid_markets() { - ExtBuilder::default().build().execute_with(|| { - set_up_version_remove_markets(); - let pallet = MARKET_COMMONS; - let prefix = MARKETS; - let (old_market, _) = construct_old_new_tuple( - Some(OldMarketDisputeMechanism::SimpleDisputes), - Some(MarketDisputeMechanism::Authorized), - ); - for market_id in RemovableMarketIds::get().iter() { - let storage_hash = MarketId::from(*market_id).using_encoded(Blake2_128Concat::hash); - // base asset for the market is not a campaign asset, so not corrupted - put_storage_value::>( - pallet, - prefix, - &storage_hash, - old_market.clone(), - ); - } - - for market_id in RemovableMarketIds::get().iter() { - let market_id = MarketId::from(*market_id); - assert!(crate::Markets::::contains_key(market_id)); - } - - RemoveMarkets::::on_runtime_upgrade(); - - for market_id in RemovableMarketIds::get().iter() { - let market_id = MarketId::from(*market_id); - // all markets still present, because no market was in a corrupted storage layout - assert!(crate::Markets::::contains_key(market_id)); - } - }); - } - - #[test_case(None, None; "none")] - #[test_case( - Some(OldMarketDisputeMechanism::Authorized), - Some(MarketDisputeMechanism::Authorized) - )] - #[test_case(Some(OldMarketDisputeMechanism::Court), Some(MarketDisputeMechanism::Court))] - #[test_case( - Some(OldMarketDisputeMechanism::SimpleDisputes), - Some(MarketDisputeMechanism::Authorized) - )] - fn on_runtime_upgrade_mdm_works_as_expected( - old_scoring_rule: Option, - new_scoring_rule: Option, - ) { - ExtBuilder::default().build().execute_with(|| { - set_up_version_mdm(); - let (old_market, new_market) = - construct_old_new_tuple(old_scoring_rule, new_scoring_rule); - populate_test_data::>( - MARKET_COMMONS, - MARKETS, - vec![old_market], - ); - MigrateDisputeMechanism::::on_runtime_upgrade(); - assert_eq!(crate::Markets::::get(0).unwrap(), new_market); - }); - } - - #[test] - fn on_runtime_upgrade_is_noop_if_versions_are_not_correct() { - ExtBuilder::default().build().execute_with(|| { - StorageVersion::new(MARKET_COMMONS_NEXT_STORAGE_VERSION_1) - .put::>(); - let market = Market { - market_id: 7, - base_asset: Asset::Ztg, - creator: 1, - creation: MarketCreation::Permissionless, - creator_fee: Perbill::from_rational(2u32, 3u32), - oracle: 4, - metadata: vec![0x05; 50], - market_type: MarketType::Categorical(999), - period: MarketPeriod::, MomentOf>::Block(6..7), - deadlines: Deadlines { grace_period: 7, oracle_duration: 8, dispute_duration: 9 }, - scoring_rule: ScoringRule::AmmCdaHybrid, - status: MarketStatus::Active, - report: Some(Report { at: 13, by: 14, outcome: OutcomeReport::Categorical(10) }), - resolved_outcome: None, - dispute_mechanism: Some(MarketDisputeMechanism::Court), - bonds: MarketBonds { - creation: Some(Bond::new(11, 12)), - oracle: None, - outsider: None, - dispute: None, - close_dispute: None, - close_request: None, - }, - early_close: None, - }; - crate::Markets::::insert(333, market); - let tmp = storage_root(StateVersion::V1); - MigrateDisputeMechanism::::on_runtime_upgrade(); - assert_eq!(tmp, storage_root(StateVersion::V1)); - }); - } - - fn set_up_version_remove_markets() { - StorageVersion::new(MARKET_COMMONS_REQUIRED_STORAGE_VERSION_0) - .put::>(); - } - - fn set_up_version_mdm() { - StorageVersion::new(MARKET_COMMONS_REQUIRED_STORAGE_VERSION_1) - .put::>(); - } - - fn construct_old_new_tuple( - old_dispute_mechanism: Option, - new_dispute_mechanism: Option, - ) -> (OldMarketOf, MarketOf) { - let market_id = 0; - let base_asset = Asset::Ztg; - let creator = 1; - let creation = MarketCreation::Advised; - let creator_fee = Perbill::from_rational(2u32, 3u32); - let oracle = 4; - let metadata = vec![5; 50]; - let market_type = MarketType::Scalar(6..=7); - let period = MarketPeriod::Block(8..9); - let deadlines = Deadlines { grace_period: 10, oracle_duration: 11, dispute_duration: 12 }; - let scoring_rule = ScoringRule::AmmCdaHybrid; - let status = MarketStatus::Resolved; - let report = Some(Report { at: 13, by: 14, outcome: OutcomeReport::Categorical(15) }); - let resolved_outcome = Some(OutcomeReport::Categorical(16)); - let bonds = MarketBonds { - creation: Some(Bond { who: 17, value: 18, is_settled: true }), - oracle: Some(Bond { who: 19, value: 20, is_settled: true }), - outsider: Some(Bond { who: 21, value: 22, is_settled: true }), - dispute: Some(Bond { who: 23, value: 24, is_settled: true }), - close_request: Some(Bond { who: 25, value: 26, is_settled: true }), - close_dispute: Some(Bond { who: 27, value: 28, is_settled: true }), - }; - let early_close = Some(EarlyClose { - old: MarketPeriod::Block(29..30), - new: MarketPeriod::Block(31..32), - state: EarlyCloseState::Disputed, - }); - let old_markets = OldMarket { - market_id, - base_asset, - creator, - creation: creation.clone(), - creator_fee, - oracle, - metadata: metadata.clone(), - market_type: market_type.clone(), - period: period.clone(), - deadlines, - scoring_rule, - status, - report: report.clone(), - resolved_outcome: resolved_outcome.clone(), - dispute_mechanism: old_dispute_mechanism, - bonds: bonds.clone(), - early_close: early_close.clone(), - }; - let new_market = Market { - market_id, - base_asset, - creator, - creation: creation.clone(), - creator_fee, - oracle, - metadata: metadata.clone(), - market_type: market_type.clone(), - period: period.clone(), - deadlines, - scoring_rule, - status, - report: report.clone(), - resolved_outcome: resolved_outcome.clone(), - dispute_mechanism: new_dispute_mechanism, - bonds: bonds.clone(), - early_close: early_close.clone(), - }; - (old_markets, new_market) - } - - fn construct_corrupt_market() -> CorruptedMarketOf { - let market_id = 0; - let base_asset = BaseAssetClass::CampaignAsset(5u128); - let creator = 1; - let creation = MarketCreation::Advised; - let creator_fee = Perbill::from_rational(2u32, 3u32); - let oracle = 4; - let metadata = vec![5; 50]; - let market_type = MarketType::Scalar(6..=7); - let period = MarketPeriod::Block(8..9); - let deadlines = Deadlines { grace_period: 10, oracle_duration: 11, dispute_duration: 12 }; - let scoring_rule = ScoringRule::AmmCdaHybrid; - let status = MarketStatus::Resolved; - let report = Some(Report { at: 13, by: 14, outcome: OutcomeReport::Categorical(15) }); - let resolved_outcome = Some(OutcomeReport::Categorical(16)); - let bonds = MarketBonds { - creation: Some(Bond { who: 17, value: 18, is_settled: true }), - oracle: Some(Bond { who: 19, value: 20, is_settled: true }), - outsider: Some(Bond { who: 21, value: 22, is_settled: true }), - dispute: Some(Bond { who: 23, value: 24, is_settled: true }), - close_request: Some(Bond { who: 25, value: 26, is_settled: true }), - close_dispute: Some(Bond { who: 27, value: 28, is_settled: true }), - }; - let early_close = Some(EarlyClose { - old: MarketPeriod::Block(29..30), - new: MarketPeriod::Block(31..32), - state: EarlyCloseState::Disputed, - }); - let dispute_mechanism: Option = - Some(OldMarketDisputeMechanism::Court); - - OldMarketWithCampaignBaseAsset { - market_id, - creator, - base_asset, - creation, - creator_fee, - oracle, - metadata, - market_type, - period, - deadlines, - scoring_rule, - status, - report, - resolved_outcome, - dispute_mechanism, - bonds, - early_close, - } - } - - #[allow(unused)] - fn populate_test_data(pallet: &[u8], prefix: &[u8], data: Vec) - where - H: StorageHasher, - K: TryFrom + Encode, - V: Encode + Clone, - >::Error: Debug, - { - for (key, value) in data.iter().enumerate() { - let storage_hash = K::try_from(key).unwrap().using_encoded(H::hash).as_ref().to_vec(); - put_storage_value::(pallet, prefix, &storage_hash, (*value).clone()); - } - } -}