Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove common runtime #609

Merged
merged 7 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
717 changes: 333 additions & 384 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ panic = 'unwind'
[workspace]
members = [
'node',
'runtime/common',
'runtime/hydradx',
'pallets/omnipool',
'pallets/dca',
Expand Down Expand Up @@ -40,7 +39,6 @@ primitives = { path = "primitives", default-features = false }
hydradx-traits = { path = "traits", default-features = false }
hydra-dx-math = { path = "math", default-features = false }

common-runtime = { path = "runtime/common", default-features = false }
hydradx-adapters = { path = "runtime/adapters", default-features = false }
hydradx-runtime = { path = "runtime/hydradx", default-features = false }

Expand Down Expand Up @@ -205,7 +203,6 @@ pallet-xcm = { git = "https://github.com/paritytech/polkadot", branch = "release
polkadot-xcm = { package = "xcm", git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38", default-features = false }
xcm-executor = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38", default-features = false }
xcm-builder = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38", default-features = false }
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.38", default-features = false }

substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
substrate-build-script-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
Expand Down
4 changes: 1 addition & 3 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "runtime-integration-tests"
version = "1.7.16"
version = "1.7.17"
description = "Integration tests"
authors = ["GalacticCouncil"]
edition = "2021"
Expand All @@ -14,7 +14,6 @@ tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
scraper = { workspace = true }
primitives = { workspace = true }
hydradx-runtime = { workspace = true }
common-runtime = { workspace = true }
pallet-omnipool = { workspace = true }
pallet-circuit-breaker = { workspace = true }
pallet-omnipool-liquidity-mining = { workspace = true }
Expand Down Expand Up @@ -175,7 +174,6 @@ std = [
"pallet-authorship/std",
"hydradx-traits/std",
"pallet-relaychain-info/std",
"common-runtime/std",
"polkadot-runtime/std",
"hydradx-runtime/std",
]
40 changes: 20 additions & 20 deletions integration-tests/src/omnipool_price_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ use crate::polkadot_test_net::*;

use frame_support::assert_ok;
use frame_system::RawOrigin;
use hydradx_runtime::Balance;
use hydradx_runtime::Omnipool;
use hydradx_runtime::RuntimeOrigin;
use hydradx_runtime::Tokens;
use hydradx_runtime::{adapters::OraclePriceProviderAdapterForOmnipool, Omnipool, RuntimeOrigin, Tokens};
use hydradx_traits::{OraclePeriod, PriceOracle};
use primitives::AssetId;
use primitives::{AssetId, Balance};
use sp_runtime::{FixedU128, Permill};
use xcm_emulator::TestExt;

Expand All @@ -22,11 +19,12 @@ fn omnipool_oracle_adapter_should_return_price_for_arbitraty_pairs() {

set_relaychain_block_number(100);

let price = common_runtime::adapters::OraclePriceProviderAdapterForOmnipool::<
AssetId,
hydradx_runtime::EmaOracle,
hydradx_runtime::LRNA,
>::price(HDX, DAI, OraclePeriod::Short);
let price =
OraclePriceProviderAdapterForOmnipool::<AssetId, hydradx_runtime::EmaOracle, hydradx_runtime::LRNA>::price(
HDX,
DAI,
OraclePeriod::Short,
);

assert!(price.is_some());
});
Expand All @@ -41,11 +39,12 @@ fn omnipool_oracle_adapter_should_return_price_for_when_lrna_is_asset_a() {

set_relaychain_block_number(100);

let price = common_runtime::adapters::OraclePriceProviderAdapterForOmnipool::<
AssetId,
hydradx_runtime::EmaOracle,
hydradx_runtime::LRNA,
>::price(LRNA, DAI, OraclePeriod::Short);
let price =
OraclePriceProviderAdapterForOmnipool::<AssetId, hydradx_runtime::EmaOracle, hydradx_runtime::LRNA>::price(
LRNA,
DAI,
OraclePeriod::Short,
);

assert!(price.is_some());
});
Expand All @@ -60,11 +59,12 @@ fn omnipool_oracle_adapter_should_return_price_for_when_lrna_is_asset_b() {

set_relaychain_block_number(100);

let price = common_runtime::adapters::OraclePriceProviderAdapterForOmnipool::<
AssetId,
hydradx_runtime::EmaOracle,
hydradx_runtime::LRNA,
>::price(DAI, LRNA, OraclePeriod::Short);
let price =
OraclePriceProviderAdapterForOmnipool::<AssetId, hydradx_runtime::EmaOracle, hydradx_runtime::LRNA>::price(
DAI,
LRNA,
OraclePeriod::Short,
);

assert!(price.is_some());
});
Expand Down
9 changes: 3 additions & 6 deletions integration-tests/src/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

use crate::polkadot_test_net::*;

use frame_support::traits::tokens::fungibles::Mutate;
use frame_support::{
assert_ok,
traits::{OnFinalize, OnInitialize},
sp_runtime::{FixedU128, Permill},
traits::{tokens::fungibles::Mutate, OnFinalize, OnInitialize},
};
use hydradx_runtime::{EmaOracle, RuntimeOrigin};
use hydradx_runtime::{EmaOracle, RuntimeOrigin, OMNIPOOL_SOURCE};
use hydradx_traits::{
AggregatedPriceOracle,
OraclePeriod::{self, *},
};
use pallet_ema_oracle::OracleError;
use polkadot_primitives::v2::BlockNumber;
use sp_runtime::{FixedU128, Permill};
use xcm_emulator::TestExt;

pub fn hydradx_run_to_block(to: BlockNumber) {
Expand All @@ -31,8 +30,6 @@ pub fn hydradx_run_to_block(to: BlockNumber) {
}
}

use common_runtime::{adapters::OMNIPOOL_SOURCE, AssetId, CORE_ASSET_ID};

const HDX: AssetId = CORE_ASSET_ID;

const SUPPORTED_PERIODS: &[OraclePeriod] = &[LastBlock, Short, TenMinutes];
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/polkadot_test_net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use frame_support::{
};
pub use hydradx_runtime::{AccountId, NativeExistentialDeposit, Treasury, VestingPalletId};
use pallet_transaction_multi_payment::Price;
use primitives::{AssetId, Balance};
pub use primitives::{constants::chain::CORE_ASSET_ID, AssetId, Balance};

use cumulus_primitives_core::ParaId;
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
Expand Down
3 changes: 1 addition & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hydradx"
version = "10.0.0"
version = "10.0.1"
description = "HydraDX node"
authors = ["GalacticCouncil"]
edition = "2021"
Expand Down Expand Up @@ -28,7 +28,6 @@ clap = { version = "4.1.8", features = [ "derive" ] }
futures = "0.3.21"

# local dependencies
common-runtime = { workspace = true }
hydradx-runtime = { workspace = true }
primitives = { workspace = true }

Expand Down
7 changes: 5 additions & 2 deletions node/src/chain_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ use hydradx_runtime::{
pallet_claims::EthereumAddress, AccountId, AssetRegistryConfig, AuraId, Balance, BalancesConfig, ClaimsConfig,
CollatorSelectionConfig, CouncilConfig, DusterConfig, ElectionsConfig, GenesisConfig, GenesisHistoryConfig,
MultiTransactionPaymentConfig, ParachainInfoConfig, SessionConfig, Signature, SystemConfig,
TechnicalCommitteeConfig, TokensConfig, VestingConfig, UNITS, WASM_BINARY,
TechnicalCommitteeConfig, TokensConfig, VestingConfig, WASM_BINARY,
};
use primitives::{
constants::currency::{NATIVE_EXISTENTIAL_DEPOSIT, UNITS},
AssetId, BlockNumber, Price,
};
use primitives::{constants::currency::NATIVE_EXISTENTIAL_DEPOSIT, AssetId, BlockNumber, Price};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
Expand Down
2 changes: 1 addition & 1 deletion node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#![allow(clippy::all)]

use common_runtime::{AccountId, Balance, Block, Index};
use cumulus_client_cli::CollatorOptions;
use cumulus_client_consensus_aura::{AuraConsensus, BuildAuraConsensusParams, SlotProportion};
use cumulus_client_consensus_common::{ParachainBlockImport as TParachainBlockImport, ParachainConsensus};
Expand All @@ -33,6 +32,7 @@ use cumulus_relay_chain_interface::{RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_minimal_node::build_minimal_relay_chain_node;
use jsonrpsee::RpcModule;
use polkadot_service::CollatorPair;
use primitives::{AccountId, Balance, Block, Index};
use sc_consensus::ImportQueue;
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch, NativeVersion};
use sc_network::NetworkService;
Expand Down
3 changes: 2 additions & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "primitives"
version = "5.7.3"
version = "5.8.0"
authors = ["GalacticCouncil"]
edition = "2021"
repository = "https://github.com/galacticcouncil/HydraDX-node"
Expand All @@ -14,6 +14,7 @@ static_assertions = "1.1.0"

# Substrate dependencies
frame-support = { workspace = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.38", default-features = false }
Roznovjak marked this conversation as resolved.
Show resolved Hide resolved
Roznovjak marked this conversation as resolved.
Show resolved Hide resolved

# Polkadot dependencies
polkadot-primitives = { workspace = true }
Expand Down
32 changes: 32 additions & 0 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@
// limitations under the License.

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::sp_runtime::FixedU128;

/// Opaque, encoded, unchecked extrinsic.
pub use frame_support::sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
use frame_support::sp_runtime::{
generic,
traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiSignature,
};

pub mod constants;

/// An index to a block.
Expand All @@ -43,3 +52,26 @@ pub type CollectionId = u128;

/// NFT Item ID
pub type ItemId = u128;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = MultiSignature;

/// Some way of identifying an account on the chain. We intentionally make it equivalent
/// to the public key of our transaction signing scheme.
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;

/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
/// never know...
pub type AccountIndex = u32;

/// Index of a transaction in the chain.
pub type Index = u32;

/// A hash of some data used by the chain.
pub type Hash = sp_core::H256;

/// Header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;

/// Block type.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
118 changes: 0 additions & 118 deletions runtime/common/Cargo.toml

This file was deleted.

Loading
Loading