diff --git a/Cargo.lock b/Cargo.lock index 70a42fd8df..c886fecc62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -786,6 +786,8 @@ dependencies = [ "moonbeam-rpc-primitives-debug", "moonbeam-rpc-primitives-txpool", "num_enum 0.5.11", + "oracle-benchmarks", + "orml-oracle", "orml-xcm-support", "orml-xtokens", "pallet-assets", @@ -816,10 +818,11 @@ dependencies = [ "pallet-evm-precompile-xcm", "pallet-identity", "pallet-inflation", + "pallet-membership", "pallet-multisig", + "pallet-price-aggregator", "pallet-proxy", "pallet-session", - "pallet-static-price-provider", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -14032,7 +14035,6 @@ dependencies = [ "pallet-proxy", "pallet-scheduler", "pallet-session", - "pallet-static-price-provider", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", @@ -14104,6 +14106,8 @@ dependencies = [ "moonbeam-rpc-primitives-debug", "moonbeam-rpc-primitives-txpool", "num_enum 0.5.11", + "oracle-benchmarks", + "orml-oracle", "orml-xcm-support", "orml-xtokens", "pallet-assets", @@ -14135,10 +14139,11 @@ dependencies = [ "pallet-identity", "pallet-inflation", "pallet-insecure-randomness-collective-flip", + "pallet-membership", "pallet-multisig", + "pallet-price-aggregator", "pallet-proxy", "pallet-session", - "pallet-static-price-provider", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", diff --git a/bin/collator/src/parachain/chain_spec/astar.rs b/bin/collator/src/parachain/chain_spec/astar.rs index acc9934555..69d3472e8a 100644 --- a/bin/collator/src/parachain/chain_spec/astar.rs +++ b/bin/collator/src/parachain/chain_spec/astar.rs @@ -18,10 +18,11 @@ //! Astar chain specifications. +use astar_primitives::oracle::CurrencyAmount; use astar_runtime::{ wasm_binary_unwrap, AccountId, AuraId, Balance, DappStakingConfig, EVMConfig, InflationConfig, - InflationParameters, ParachainInfoConfig, Precompiles, Signature, SystemConfig, TierThreshold, - ASTR, + InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles, + PriceAggregatorConfig, Signature, SystemConfig, TierThreshold, ASTR, }; use cumulus_primitives_core::ParaId; use sc_service::ChainType; @@ -192,6 +193,20 @@ fn make_genesis( params: InflationParameters::default(), ..Default::default() }, + oracle_membership: OracleMembershipConfig { + members: vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + ] + .try_into() + .expect("Assumption is that at least two members will be allowed."), + ..Default::default() + }, + price_aggregator: PriceAggregatorConfig { + circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] + .try_into() + .expect("Must work since buffer should have at least a single value."), + }, } } diff --git a/bin/collator/src/parachain/chain_spec/shiden.rs b/bin/collator/src/parachain/chain_spec/shiden.rs index ee7542d94a..3869cefc0a 100644 --- a/bin/collator/src/parachain/chain_spec/shiden.rs +++ b/bin/collator/src/parachain/chain_spec/shiden.rs @@ -22,11 +22,12 @@ use cumulus_primitives_core::ParaId; use sc_service::ChainType; use shiden_runtime::{ wasm_binary_unwrap, AccountId, AuraId, Balance, DappStakingConfig, EVMConfig, InflationConfig, - InflationParameters, ParachainInfoConfig, Precompiles, Signature, SystemConfig, TierThreshold, - SDN, + InflationParameters, OracleMembershipConfig, ParachainInfoConfig, Precompiles, + PriceAggregatorConfig, Signature, SystemConfig, TierThreshold, SDN, }; use sp_core::{sr25519, Pair, Public}; +use astar_primitives::oracle::CurrencyAmount; use sp_runtime::{ traits::{IdentifyAccount, Verify}, Permill, @@ -191,6 +192,20 @@ fn make_genesis( params: InflationParameters::default(), ..Default::default() }, + oracle_membership: OracleMembershipConfig { + members: vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + ] + .try_into() + .expect("Assumption is that at least two members will be allowed."), + ..Default::default() + }, + price_aggregator: PriceAggregatorConfig { + circular_buffer: vec![CurrencyAmount::from_rational(5, 10)] + .try_into() + .expect("Must work since buffer should have at least a single value."), + }, } } diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index 82e6e3192c..3d999fb8d7 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -57,6 +57,7 @@ pallet-evm-precompile-modexp = { workspace = true } pallet-evm-precompile-sha3fips = { workspace = true } pallet-evm-precompile-simple = { workspace = true } pallet-identity = { workspace = true } +pallet-membership = { workspace = true } pallet-multisig = { workspace = true } pallet-proxy = { workspace = true } pallet-session = { workspace = true, features = ["historical"] } @@ -88,6 +89,7 @@ xcm-builder = { workspace = true } xcm-executor = { workspace = true } # orml dependencies +orml-oracle = { workspace = true } orml-xcm-support = { workspace = true } orml-xtokens = { workspace = true } @@ -112,10 +114,13 @@ pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } pallet-evm-precompile-xcm = { workspace = true } pallet-inflation = { workspace = true } -pallet-static-price-provider = { workspace = true } +pallet-price-aggregator = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } +# Get rid of this after uplifting to high enough version of ORML so we get access to benchmark support for the pallet +oracle-benchmarks = { workspace = true } + dapp-staking-v3-runtime-api = { workspace = true } # Moonbeam tracing @@ -140,6 +145,10 @@ std = [ "sp-std/std", "sp-api/std", "sp-core/std", + "oracle-benchmarks/std", + "pallet-membership/std", + "pallet-price-aggregator/std", + "orml-oracle/std", "sp-consensus-aura/std", "sp-arithmetic/std", "sp-io/std", @@ -159,7 +168,6 @@ std = [ "pallet-aura/std", "pallet-balances/std", "pallet-proxy/std", - "pallet-static-price-provider/std", "pallet-dapp-staking-v3/std", "pallet-dapp-staking-migration/std", "dapp-staking-v3-runtime-api/std", @@ -233,7 +241,9 @@ runtime-benchmarks = [ "pallet-ethereum/runtime-benchmarks", "pallet-dapp-staking-v3/runtime-benchmarks", "pallet-dapp-staking-migration/runtime-benchmarks", + "pallet-price-aggregator/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "pallet-xc-asset-config/runtime-benchmarks", @@ -263,10 +273,13 @@ try-runtime = [ "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", "pallet-utility/try-runtime", - "pallet-static-price-provider/try-runtime", "pallet-vesting/try-runtime", "pallet-xc-asset-config/try-runtime", "pallet-ethereum/try-runtime", + "orml-oracle/try-runtime", + "pallet-price-aggregator/try-runtime", + "pallet-membership/try-runtime", + "oracle-benchmarks/try-runtime", "pallet-assets/try-runtime", "pallet-authorship/try-runtime", "pallet-collator-selection/try-runtime", diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index c328b31e98..f2be6d12b8 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -74,6 +74,7 @@ use astar_primitives::{ PeriodNumber, SmartContract, StandardTierSlots, TierId, }, evm::EvmRevertCodeHandler, + oracle::{CurrencyAmount, CurrencyId, DummyCombineData}, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Nonce, }; @@ -327,10 +328,6 @@ parameter_types! { pub const MinimumStakingAmount: Balance = 500 * ASTR; } -impl pallet_static_price_provider::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - #[cfg(feature = "runtime-benchmarks")] pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] @@ -365,7 +362,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type Currency = Balances; type SmartContract = SmartContract; type ManagerOrigin = frame_system::EnsureRoot; - type NativePriceProvider = StaticPriceProvider; + type NativePriceProvider = PriceAggregator; type StakingRewardHandler = Inflation; type CycleConfiguration = InflationCycleConfig; type Observers = Inflation; @@ -1033,6 +1030,60 @@ impl pallet_proxy::Config for Runtime { type AnnouncementDepositFactor = AnnouncementDepositFactor; } +parameter_types! { + pub const NativeCurrencyId: CurrencyId = CurrencyId::ASTR; + // Aggregate values for one day. + pub const AggregationDuration: BlockNumber = 7200; +} + +impl pallet_price_aggregator::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type MaxValuesPerBlock = ConstU32<8>; + type ProcessBlockValues = pallet_price_aggregator::MedianBlockValue; + type NativeCurrencyId = NativeCurrencyId; + // 7 days + type CircularBufferLength = ConstU32<7>; + type AggregationDuration = AggregationDuration; + type WeightInfo = pallet_price_aggregator::weights::SubstrateWeight; +} + +parameter_types! { + // Cannot specify `Root` so need to do it like this, unfortunately. + pub RootOperatorAccountId: AccountId = AccountId::from([0xffu8; 32]); +} + +impl orml_oracle::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnNewData = PriceAggregator; + type CombineData = DummyCombineData; + type Time = Timestamp; + type OracleKey = CurrencyId; + type OracleValue = CurrencyAmount; + type RootOperatorAccountId = RootOperatorAccountId; + type Members = OracleMembership; + type MaxHasDispatchedSize = ConstU32<8>; + type WeightInfo = oracle_benchmarks::weights::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type MaxFeedValues = ConstU32<2>; + #[cfg(not(feature = "runtime-benchmarks"))] + type MaxFeedValues = ConstU32<1>; +} + +pub type OracleMembershipInstance = pallet_membership::Instance1; +impl pallet_membership::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AddOrigin = EnsureRoot; + type RemoveOrigin = EnsureRoot; + type SwapOrigin = EnsureRoot; + type ResetOrigin = EnsureRoot; + type PrimeOrigin = EnsureRoot; + + type MembershipInitialized = (); + type MembershipChanged = (); + type MaxMembers = ConstU32<16>; + type WeightInfo = pallet_membership::weights::SubstrateWeight; +} + construct_runtime!( pub struct Runtime { @@ -1056,6 +1107,9 @@ construct_runtime!( Inflation: pallet_inflation = 33, DappStaking: pallet_dapp_staking_v3 = 34, Assets: pallet_assets = 36, + PriceAggregator: pallet_price_aggregator = 37, + Oracle: orml_oracle = 38, + OracleMembership: pallet_membership:: = 39, Authorship: pallet_authorship = 40, CollatorSelection: pallet_collator_selection = 41, @@ -1077,9 +1131,6 @@ construct_runtime!( Contracts: pallet_contracts = 70, Sudo: pallet_sudo = 99, - - // To be removed & cleaned up once proper oracle is implemented - StaticPriceProvider: pallet_static_price_provider = 253, } ); @@ -1118,8 +1169,9 @@ pub type Executive = frame_executive::Executive< >; parameter_types! { - pub const DappStakingMigrationName: &'static str = "DappStakingMigration"; - + pub const StaticPriceProviderName: &'static str = "StaticPriceProvider"; + // 0.18 $ + pub const InitPrice: CurrencyAmount = CurrencyAmount::from_rational(18, 100); } /// All migrations that will run on the next runtime upgrade. @@ -1127,11 +1179,28 @@ parameter_types! { /// Once done, migrations should be removed from the tuple. pub type Migrations = ( frame_support::migrations::RemovePallet< - DappStakingMigrationName, + StaticPriceProviderName, ::DbWeight, >, + OracleIntegrationLogic, + pallet_price_aggregator::PriceAggregatorInitializer, ); +use frame_support::traits::OnRuntimeUpgrade; +pub struct OracleIntegrationLogic; +impl OnRuntimeUpgrade for OracleIntegrationLogic { + fn on_runtime_upgrade() -> Weight { + // 1. Set initial storage versions for the membership pallet + use frame_support::traits::StorageVersion; + StorageVersion::new(4) + .put::>(); + + // No storage version for the `orml_oracle` pallet, it's essentially 0 + + ::DbWeight::get().writes(1) + } +} + type EventRecord = frame_system::EventRecord< ::RuntimeEvent, ::Hash, diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index a46d903fd3..f4533e6bc6 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -114,7 +114,6 @@ pallet-evm-precompile-xcm = { workspace = true } pallet-evm-precompile-xvm = { workspace = true } pallet-inflation = { workspace = true } pallet-price-aggregator = { workspace = true } -pallet-static-price-provider = { workspace = true } pallet-unified-accounts = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } @@ -204,7 +203,6 @@ std = [ "orml-oracle/std", "dapp-staking-v3-runtime-api/std", "pallet-inflation/std", - "pallet-static-price-provider/std", "pallet-price-aggregator/std", "pallet-identity/std", "pallet-multisig/std", @@ -293,7 +291,6 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-dapp-staking-v3/try-runtime", "pallet-inflation/try-runtime", - "pallet-static-price-provider/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", "pallet-transaction-payment/try-runtime", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index ea9f017d4a..6f76477c57 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -389,10 +389,6 @@ impl pallet_preimage::Config for Runtime { >; } -impl pallet_static_price_provider::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - #[cfg(feature = "runtime-benchmarks")] pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] @@ -1259,8 +1255,6 @@ construct_runtime!( // Remove after benchmarks are available in orml_oracle OracleBenchmarks: oracle_benchmarks = 251, - // To be removed & cleaned up once proper oracle is implemented - StaticPriceProvider: pallet_static_price_provider = 253, } ); diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index 7a675540b1..7f7b35b8ae 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -59,6 +59,7 @@ pallet-evm-precompile-sha3fips = { workspace = true } pallet-evm-precompile-simple = { workspace = true } pallet-identity = { workspace = true } pallet-insecure-randomness-collective-flip = { workspace = true } +pallet-membership = { workspace = true } pallet-multisig = { workspace = true } pallet-proxy = { workspace = true } pallet-session = { workspace = true, features = ["historical"] } @@ -90,6 +91,7 @@ xcm-builder = { workspace = true } xcm-executor = { workspace = true } # orml dependencies +orml-oracle = { workspace = true } orml-xcm-support = { workspace = true } orml-xtokens = { workspace = true } @@ -114,10 +116,13 @@ pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } pallet-evm-precompile-xcm = { workspace = true } pallet-inflation = { workspace = true } -pallet-static-price-provider = { workspace = true } +pallet-price-aggregator = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } +# Get rid of this after uplifting to high enough version of ORML so we get access to benchmark support for the pallet +oracle-benchmarks = { workspace = true } + dapp-staking-v3-runtime-api = { workspace = true } precompile-utils = { workspace = true } @@ -146,7 +151,6 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-arithmetic/std", - "pallet-static-price-provider/std", "sp-runtime-interface/std", "sp-version/std", "sp-block-builder/std", @@ -161,6 +165,7 @@ std = [ "pallet-assets/std", "pallet-balances/std", "pallet-contracts/std", + "oracle-benchmarks/std", "pallet-contracts-primitives/std", "pallet-dynamic-evm-base-fee/std", "pallet-ethereum/std", @@ -185,18 +190,21 @@ std = [ "pallet-evm-precompile-xcm/std", "pallet-identity/std", "pallet-multisig/std", + "pallet-membership/std", "pallet-insecure-randomness-collective-flip/std", "pallet-session/std", "pallet-utility/std", "pallet-proxy/std", "pallet-timestamp/std", "pallet-vesting/std", + "orml-oracle/std", "sp-offchain/std", "sp-session/std", "pallet-sudo/std", "pallet-transaction-payment/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-xcm/std", + "pallet-price-aggregator/std", "parachain-info/std", "polkadot-parachain/std", "polkadot-primitives/std", @@ -240,12 +248,14 @@ runtime-benchmarks = [ "pallet-xcm/runtime-benchmarks", "pallet-xcm-benchmarks/runtime-benchmarks", "astar-xcm-benchmarks/runtime-benchmarks", + "pallet-membership/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "pallet-xc-asset-config/runtime-benchmarks", "pallet-collator-selection/runtime-benchmarks", "astar-primitives/runtime-benchmarks", "pallet-assets/runtime-benchmarks", "pallet-dynamic-evm-base-fee/runtime-benchmarks", + "pallet-price-aggregator/runtime-benchmarks", "cumulus-primitives-utility/runtime-benchmarks", ] try-runtime = [ @@ -258,6 +268,9 @@ try-runtime = [ "frame-system/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", + "orml-oracle/try-runtime", + "pallet-price-aggregator/try-runtime", + "pallet-membership/try-runtime", "pallet-dapp-staking-v3/try-runtime", "pallet-dapp-staking-migration/try-runtime", "pallet-inflation/try-runtime", @@ -266,7 +279,6 @@ try-runtime = [ "pallet-transaction-payment/try-runtime", "pallet-utility/try-runtime", "pallet-vesting/try-runtime", - "pallet-static-price-provider/try-runtime", "pallet-ethereum/try-runtime", "pallet-xc-asset-config/try-runtime", "pallet-assets/try-runtime", @@ -288,6 +300,7 @@ try-runtime = [ "pallet-dynamic-evm-base-fee/try-runtime", "pallet-evm/try-runtime", "orml-xtokens/try-runtime", + "oracle-benchmarks/try-runtime", ] evm-tracing = [ "moonbeam-evm-tracer", diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index 2fd0b78e0e..150ca623ef 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -73,7 +73,7 @@ use astar_primitives::{ PeriodNumber, SmartContract, TierId, TierSlots as TierSlotsFunc, }, evm::EvmRevertCodeHandler, - oracle::CurrencyAmount, + oracle::{CurrencyAmount, CurrencyId, DummyCombineData}, xcm::AssetLocationIdConverter, Address, AssetId, BlockNumber, Hash, Header, Nonce, }; @@ -327,10 +327,6 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = pallet_multisig::weights::SubstrateWeight; } -impl pallet_static_price_provider::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - #[cfg(feature = "runtime-benchmarks")] pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] @@ -378,7 +374,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type Currency = Balances; type SmartContract = SmartContract; type ManagerOrigin = frame_system::EnsureRoot; - type NativePriceProvider = StaticPriceProvider; + type NativePriceProvider = PriceAggregator; type StakingRewardHandler = Inflation; type CycleConfiguration = InflationCycleConfig; type Observers = Inflation; @@ -1034,6 +1030,60 @@ impl pallet_proxy::Config for Runtime { type AnnouncementDepositFactor = AnnouncementDepositFactor; } +parameter_types! { + pub const NativeCurrencyId: CurrencyId = CurrencyId::SDN; + // Aggregate values for one day. + pub const AggregationDuration: BlockNumber = 7200; +} + +impl pallet_price_aggregator::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type MaxValuesPerBlock = ConstU32<8>; + type ProcessBlockValues = pallet_price_aggregator::MedianBlockValue; + type NativeCurrencyId = NativeCurrencyId; + // 7 days + type CircularBufferLength = ConstU32<7>; + type AggregationDuration = AggregationDuration; + type WeightInfo = pallet_price_aggregator::weights::SubstrateWeight; +} + +parameter_types! { + // Cannot specify `Root` so need to do it like this, unfortunately. + pub RootOperatorAccountId: AccountId = AccountId::from([0xffu8; 32]); +} + +impl orml_oracle::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnNewData = PriceAggregator; + type CombineData = DummyCombineData; + type Time = Timestamp; + type OracleKey = CurrencyId; + type OracleValue = CurrencyAmount; + type RootOperatorAccountId = RootOperatorAccountId; + type Members = OracleMembership; + type MaxHasDispatchedSize = ConstU32<8>; + type WeightInfo = oracle_benchmarks::weights::SubstrateWeight; + #[cfg(feature = "runtime-benchmarks")] + type MaxFeedValues = ConstU32<2>; + #[cfg(not(feature = "runtime-benchmarks"))] + type MaxFeedValues = ConstU32<1>; +} + +pub type OracleMembershipInstance = pallet_membership::Instance1; +impl pallet_membership::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type AddOrigin = EnsureRoot; + type RemoveOrigin = EnsureRoot; + type SwapOrigin = EnsureRoot; + type ResetOrigin = EnsureRoot; + type PrimeOrigin = EnsureRoot; + + type MembershipInitialized = (); + type MembershipChanged = (); + type MaxMembers = ConstU32<16>; + type WeightInfo = pallet_membership::weights::SubstrateWeight; +} + construct_runtime!( pub struct Runtime { @@ -1057,6 +1107,9 @@ construct_runtime!( Inflation: pallet_inflation = 33, DappStaking: pallet_dapp_staking_v3 = 34, Assets: pallet_assets = 36, + PriceAggregator: pallet_price_aggregator = 37, + Oracle: orml_oracle = 38, + OracleMembership: pallet_membership:: = 39, Authorship: pallet_authorship = 40, CollatorSelection: pallet_collator_selection = 41, @@ -1079,9 +1132,6 @@ construct_runtime!( RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 71, Sudo: pallet_sudo = 99, - - // To be removed & cleaned up once proper oracle is implemented - StaticPriceProvider: pallet_static_price_provider = 253, } ); @@ -1120,19 +1170,38 @@ pub type Executive = frame_executive::Executive< >; parameter_types! { - pub const DappStakingMigrationName: &'static str = "DappStakingMigration"; - + pub const StaticPriceProviderName: &'static str = "StaticPriceProvider"; + // 0.32 $ + pub const InitPrice: CurrencyAmount = CurrencyAmount::from_rational(32, 100); } + /// All migrations that will run on the next runtime upgrade. /// /// Once done, migrations should be removed from the tuple. pub type Migrations = ( frame_support::migrations::RemovePallet< - DappStakingMigrationName, + StaticPriceProviderName, ::DbWeight, >, + OracleIntegrationLogic, + pallet_price_aggregator::PriceAggregatorInitializer, ); +use frame_support::traits::OnRuntimeUpgrade; +pub struct OracleIntegrationLogic; +impl OnRuntimeUpgrade for OracleIntegrationLogic { + fn on_runtime_upgrade() -> Weight { + // 1. Set initial storage versions for the membership pallet + use frame_support::traits::StorageVersion; + StorageVersion::new(4) + .put::>(); + + // No storage version for the `orml_oracle` pallet, it's essentially 0 + + ::DbWeight::get().writes(1) + } +} + type EventRecord = frame_system::EventRecord< ::RuntimeEvent, ::Hash, @@ -1216,6 +1285,8 @@ mod benches { [pallet_dynamic_evm_base_fee, DynamicEvmBaseFee] [xcm_benchmarks_generic, XcmGeneric] [xcm_benchmarks_fungible, XcmFungible] + [pallet_price_aggregator, PriceAggregator] + [pallet_membership, OracleMembership] ); } diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index e769ed2df5..0232fa665f 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -44,5 +44,5 @@ mod dapp_staking_v3; #[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] mod assets_chain_extensions; -#[cfg(any(feature = "shibuya"))] +#[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] mod oracle; diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 431e910cf0..5bfd398fec 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -38,7 +38,6 @@ pub use shibuya::*; #[cfg(feature = "shibuya")] mod shibuya { use super::*; - use parity_scale_codec::Decode; pub use shibuya_runtime::*; /// 1 SBY. @@ -161,7 +160,6 @@ impl ExtBuilder { .assimilate_storage(&mut t) .unwrap(); - #[cfg(any(feature = "shibuya"))] // Setup initial oracle members as BuildStorage>::assimilate_storage( &pallet_membership::GenesisConfig:: { @@ -171,7 +169,6 @@ impl ExtBuilder { &mut t) .unwrap(); - #[cfg(any(feature = "shibuya"))] // Setup initial native currency price as BuildStorage>::assimilate_storage( &pallet_price_aggregator::GenesisConfig:: { @@ -229,9 +226,7 @@ pub fn run_to_block(n: BlockNumber) { while System::block_number() < n { let block_number = System::block_number(); TransactionPayment::on_finalize(block_number); - #[cfg(any(feature = "shibuya"))] Oracle::on_finalize(block_number); - #[cfg(any(feature = "shibuya"))] PriceAggregator::on_finalize(block_number); DappStaking::on_finalize(block_number); Authorship::on_finalize(block_number); @@ -250,9 +245,7 @@ pub fn run_to_block(n: BlockNumber) { Timestamp::set_timestamp(block_number as u64 * BLOCK_TIME); TransactionPayment::on_initialize(block_number); DappStaking::on_initialize(block_number); - #[cfg(any(feature = "shibuya"))] Oracle::on_initialize(block_number); - #[cfg(any(feature = "shibuya"))] PriceAggregator::on_initialize(block_number); Authorship::on_initialize(block_number); Aura::on_initialize(block_number);