Repository: chainx-org/ChainX (language: rust)

Issue:
Move `xpallet_protocol` into primitives



Discussion / hints:

Fix patch:
diff --git a/Cargo.lock b/Cargo.lock
index abcf9d6c8..6e69bbef8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -737,7 +737,7 @@ dependencies = [
  "substrate-build-script-utils",
  "xp-genesis-builder",
  "xp-io",
- "xpallet-protocol",
+ "xp-protocol",
 ]
 
 [[package]]
@@ -866,6 +866,7 @@ dependencies = [
  "static_assertions",
  "substrate-wasm-builder-runner",
  "xp-mining-staking",
+ "xp-protocol",
  "xp-runtime",
  "xpallet-assets",
  "xpallet-assets-registrar",
@@ -882,7 +883,6 @@ dependencies = [
  "xpallet-mining-asset-rpc-runtime-api",
  "xpallet-mining-staking",
  "xpallet-mining-staking-rpc-runtime-api",
- "xpallet-protocol",
  "xpallet-support",
  "xpallet-system",
 ]
@@ -8859,6 +8859,16 @@ dependencies = [
  "xp-mining-common",
 ]
 
+[[package]]
+name = "xp-protocol"
+version = "2.0.0-alpha.0"
+dependencies = [
+ "chainx-primitives",
+ "parity-scale-codec",
+ "serde",
+ "sp-runtime",
+]
+
 [[package]]
 name = "xp-runtime"
 version = "2.0.0-alpha.0"
@@ -8889,8 +8899,8 @@ dependencies = [
  "sp-io",
  "sp-runtime",
  "sp-std",
+ "xp-protocol",
  "xpallet-assets-registrar",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -8909,8 +8919,8 @@ dependencies = [
  "sp-runtime",
  "sp-std",
  "xp-assets-registrar",
+ "xp-protocol",
  "xp-runtime",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -8956,9 +8966,9 @@ dependencies = [
  "sp-io",
  "sp-runtime",
  "sp-std",
+ "xp-protocol",
  "xpallet-assets",
  "xpallet-assets-registrar",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -9011,11 +9021,11 @@ dependencies = [
  "sp-runtime",
  "sp-std",
  "xp-io",
+ "xp-protocol",
  "xpallet-assets",
  "xpallet-assets-registrar",
  "xpallet-gateway-common",
  "xpallet-gateway-records",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -9039,12 +9049,12 @@ dependencies = [
  "sp-runtime",
  "sp-std",
  "xp-io",
+ "xp-protocol",
  "xp-runtime",
  "xpallet-assets",
  "xpallet-assets-registrar",
  "xpallet-gateway-bitcoin",
  "xpallet-gateway-records",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -9093,10 +9103,10 @@ dependencies = [
  "sp-io",
  "sp-runtime",
  "sp-std",
+ "xp-protocol",
  "xp-runtime",
  "xpallet-assets",
  "xpallet-assets-registrar",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -9141,10 +9151,10 @@ dependencies = [
  "sp-runtime",
  "sp-std",
  "xp-genesis-builder",
+ "xp-protocol",
  "xpallet-assets",
  "xpallet-mining-asset",
  "xpallet-mining-staking",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -9169,10 +9179,10 @@ dependencies = [
  "sp-std",
  "xp-mining-common",
  "xp-mining-staking",
+ "xp-protocol",
  "xpallet-assets",
  "xpallet-assets-registrar",
  "xpallet-mining-staking",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -9224,8 +9234,8 @@ dependencies = [
  "xp-genesis-builder",
  "xp-mining-common",
  "xp-mining-staking",
+ "xp-protocol",
  "xp-runtime",
- "xpallet-protocol",
  "xpallet-support",
 ]
 
@@ -9253,16 +9263,6 @@ dependencies = [
  "xpallet-mining-staking",
 ]
 
-[[package]]
-name = "xpallet-protocol"
-version = "2.0.0-alpha.0"
-dependencies = [
- "chainx-primitives",
- "parity-scale-codec",
- "serde",
- "sp-runtime",
-]
-
 [[package]]
 name = "xpallet-support"
 version = "2.0.0-alpha.0"
@@ -9285,7 +9285,7 @@ dependencies = [
  "serde",
  "sp-runtime",
  "sp-std",
- "xpallet-protocol",
+ "xp-protocol",
 ]
 
 [[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 88143b864..6f16d3a39 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -25,6 +25,7 @@ members = [
     "primitives/io",
     "primitives/mining/common",
     "primitives/mining/staking",
+    "primitives/protocol",
     "primitives/runtime",
     "rpc",
     "runtime",
@@ -50,7 +51,6 @@ members = [
     "xpallets/mining/staking",
     "xpallets/mining/staking/rpc",
     "xpallets/mining/staking/rpc/runtime-api",
-    "xpallets/protocol",
     "xpallets/support",
     "xpallets/system",
 ]
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index 087f24597..623c96886 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -52,7 +52,7 @@ chainx-rpc = { path = "../rpc" }
 chainx-runtime = { path = "../runtime" }
 xp-io = { path = "../primitives/io" }
 xp-genesis-builder  = { path  = "../primitives/genesis-builder" }
-xpallet-protocol = { path = "../xpallets/protocol" }
+xp-protocol = { path = "../primitives/protocol" }
 
 [build-dependencies]
 substrate-build-script-utils = "2.0.0"
diff --git a/cli/src/chain_spec.rs b/cli/src/chain_spec.rs
index 2be2a1640..6f4a56fe3 100644
--- a/cli/src/chain_spec.rs
+++ b/cli/src/chain_spec.rs
@@ -18,7 +18,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
 
 use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
 
-use xpallet_protocol::{BTC_DECIMALS, PCX, PCX_DECIMALS, X_BTC};
+use xp_protocol::{BTC_DECIMALS, PCX, PCX_DECIMALS, X_BTC};
 
 use chainx_runtime::{
     constants::{currency::DOLLARS, time::DAYS},
diff --git a/primitives/genesis-builder/Cargo.toml b/primitives/genesis-builder/Cargo.toml
index e87378337..39ba552cb 100644
--- a/primitives/genesis-builder/Cargo.toml
+++ b/primitives/genesis-builder/Cargo.toml
@@ -7,16 +7,18 @@ edition = "2018"
 [dependencies]
 serde = { version = "1.0", features = ["derive"], optional = true }
 
+# ChainX primitives
 chainx-primitives = { path = "../../primitives", default-features = false }
 
+# ChainX pallets
 xpallet-support = { path = "../../xpallets/support", default-features = false }
 
 [features]
 default = ["std"]
 std = [
     "serde/std",
-
+    # ChainX primitives
     "chainx-primitives/std",
-
+    # ChainX pallets
     "xpallet-support/std",
 ]
diff --git a/xpallets/protocol/Cargo.toml b/primitives/protocol/Cargo.toml
similarity index 84%
rename from xpallets/protocol/Cargo.toml
rename to primitives/protocol/Cargo.toml
index 813f62ada..4a6b54f4e 100644
--- a/xpallets/protocol/Cargo.toml
+++ b/primitives/protocol/Cargo.toml
@@ -1,5 +1,5 @@
 [package]
-name = "xpallet-protocol"
+name = "xp-protocol"
 version = "2.0.0-alpha.0"
 authors = ["The ChainX Authors"]
 edition = "2018"
@@ -12,7 +12,7 @@ serde = { version = "1.0", optional = true }
 sp-runtime = { version = "2.0.0", default-features = false }
 
 # ChainX primitives
-chainx-primitives = { path = "../../primitives", default-features = false }
+chainx-primitives = { path = "..", default-features = false }
 
 [features]
 default = ["std"]
diff --git a/xpallets/protocol/src/asset.rs b/primitives/protocol/src/asset.rs
similarity index 100%
rename from xpallets/protocol/src/asset.rs
rename to primitives/protocol/src/asset.rs
diff --git a/xpallets/protocol/src/lib.rs b/primitives/protocol/src/lib.rs
similarity index 100%
rename from xpallets/protocol/src/lib.rs
rename to primitives/protocol/src/lib.rs
diff --git a/xpallets/protocol/src/network.rs b/primitives/protocol/src/network.rs
similarity index 100%
rename from xpallets/protocol/src/network.rs
rename to primitives/protocol/src/network.rs
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index 8ba68c2fb..0cd0c5992 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -30,9 +30,9 @@ sp-version = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-executive = { version = "2.0.0", default-features = false }
+frame-support = { version = "2.0.0", default-features = false }
 frame-system = { version = "2.0.0", default-features = false }
 frame-system-rpc-runtime-api = { version = "2.0.0", default-features = false }
-frame-support = { version = "2.0.0", default-features = false }
 pallet-authority-discovery = { version = "2.0.0", default-features = false }
 pallet-authorship = { version = "2.0.0", default-features = false }
 pallet-babe = { version = "2.0.0", default-features = false }
@@ -69,8 +69,9 @@ orml-currencies = { version = "0.3", default-features = false }
 
 # ChainX primitives
 chainx-primitives = { path = "../primitives", default-features = false }
-xp-runtime = { path = "../primitives/runtime", default-features = false }
 xp-mining-staking = { path = "../primitives/mining/staking", default-features = false }
+xp-protocol = { path = "../primitives/protocol", default-features = false }
+xp-runtime = { path = "../primitives/runtime", default-features = false }
 
 # ChainX pallets
 xpallet-assets = { path = "../xpallets/assets", default-features = false }
@@ -89,7 +90,6 @@ xpallet-mining-asset = { path  = "../xpallets/mining/asset", default-features =
 xpallet-mining-asset-rpc-runtime-api = { path  = "../xpallets/mining/asset/rpc/runtime-api", default-features = false }
 xpallet-mining-staking = { path  = "../xpallets/mining/staking", default-features = false }
 xpallet-mining-staking-rpc-runtime-api = { path  = "../xpallets/mining/staking/rpc/runtime-api", default-features = false }
-xpallet-protocol = { path = "../xpallets/protocol", default-features = false }
 xpallet-system = { path = "../xpallets/system", default-features = false }
 xpallet-support = { path = "../xpallets/support", default-features = false }
 
@@ -117,9 +117,9 @@ std = [
     "sp-version/std",
     # Substrate pallets
     "frame-executive/std",
+    "frame-support/std",
     "frame-system/std",
     "frame-system-rpc-runtime-api/std",
-    "frame-support/std",
     "pallet-authority-discovery/std",
     "pallet-authorship/std",
     "pallet-babe/std",
@@ -151,8 +151,9 @@ std = [
     "orml-currencies/std",
     # ChainX primitives
     "chainx-primitives/std",
-    "xp-runtime/std",
     "xp-mining-staking/std",
+    "xp-protocol/std",
+    "xp-runtime/std",
     # ChainX pallets
     "xpallet-assets/std",
     "xpallet-assets-registrar/std",
@@ -169,15 +170,14 @@ std = [
     "xpallet-mining-asset-rpc-runtime-api/std",
     "xpallet-mining-staking/std",
     "xpallet-mining-staking-rpc-runtime-api/std",
-    "xpallet-protocol/std",
     "xpallet-system/std",
     "xpallet-support/std",
 ]
 runtime-benchmarks = [
     "frame-benchmarking",
+    "frame-support/runtime-benchmarks",
     "frame-system-benchmarking",
     "frame-system/runtime-benchmarks",
-    "frame-support/runtime-benchmarks",
     "sp-runtime/runtime-benchmarks",
     "pallet-balances/runtime-benchmarks",
     "pallet-collective/runtime-benchmarks",
diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs
index d2861da28..8caaf6fc7 100644
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -70,6 +70,7 @@ pub use chainx_primitives::{
     Index, Moment, ReferralId, Signature, Token,
 };
 pub use xp_mining_staking::SessionIndex;
+pub use xp_protocol::*;
 pub use xp_runtime::Memo;
 
 // xpallet re-exports
@@ -87,7 +88,6 @@ pub use xpallet_gateway_common::{
     types::{GenericTrusteeIntentionProps, GenericTrusteeSessionInfo, TrusteeInfoConfig},
 };
 pub use xpallet_gateway_records::Withdrawal;
-pub use xpallet_protocol::*;
 
 /// Constant values used within the runtime.
 pub mod constants;
@@ -828,7 +828,7 @@ impl xpallet_system::Trait for Runtime {
 }
 
 parameter_types! {
-    pub const ChainXAssetId: AssetId = xpallet_protocol::PCX;
+    pub const ChainXAssetId: AssetId = xp_protocol::PCX;
 }
 
 impl xpallet_assets_registrar::Trait for Runtime {
diff --git a/xpallets/assets-registrar/Cargo.toml b/xpallets/assets-registrar/Cargo.toml
index 9b2772d27..08eded9ea 100644
--- a/xpallets/assets-registrar/Cargo.toml
+++ b/xpallets/assets-registrar/Cargo.toml
@@ -14,16 +14,16 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 
 # ChainX primitives
 chainx-primitives = { path = "../../primitives", default-features = false }
 xp-assets-registrar = { path = "../../primitives/assets-registrar", default-features = false }
+xp-protocol = { path = "../../primitives/protocol", default-features = false }
 xp-runtime = { path = "../../primitives/runtime", default-features = false }
 
 # ChainX pallets
-xpallet-protocol = { path = "../protocol", default-features = false }
 xpallet-support = { path = "../support", default-features = false }
 
 [dev-dependencies]
@@ -40,14 +40,14 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrate pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     # ChainX primitives
     "chainx-primitives/std",
     "xp-assets-registrar/std",
+    "xp-protocol/std",
     "xp-runtime/std",
     # ChainX pallets
-    "xpallet-protocol/std",
     "xpallet-support/std",
 ]
 runtime-benchmarks = [
diff --git a/xpallets/assets-registrar/src/verifier.rs b/xpallets/assets-registrar/src/verifier.rs
index ee259ae2c..493067748 100644
--- a/xpallets/assets-registrar/src/verifier.rs
+++ b/xpallets/assets-registrar/src/verifier.rs
@@ -1,6 +1,6 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use xpallet_protocol::{ASSET_DESC_MAX_LEN, ASSET_TOKEN_NAME_MAX_LEN, ASSET_TOKEN_SYMBOL_MAX_LEN};
+use xp_protocol::{ASSET_DESC_MAX_LEN, ASSET_TOKEN_NAME_MAX_LEN, ASSET_TOKEN_SYMBOL_MAX_LEN};
 
 use super::*;
 
diff --git a/xpallets/assets/Cargo.toml b/xpallets/assets/Cargo.toml
index fccb29861..4ef4c0cad 100644
--- a/xpallets/assets/Cargo.toml
+++ b/xpallets/assets/Cargo.toml
@@ -15,18 +15,18 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrte pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 
 # Orml
 orml-traits = { version = "0.3", default-features = false }
 
 # ChainX primitives
 chainx-primitives = { path = "../../primitives", default-features = false }
+xp-protocol = { path = "../../primitives/protocol", default-features = false }
 
 # ChainX pallets
 xpallet-assets-registrar = { path = "../assets-registrar", default-features = false }
-xpallet-protocol = { path = "../protocol", default-features = false }
 xpallet-support = { path = "../support", default-features = false }
 
 [dev-dependencies]
@@ -44,15 +44,15 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrte pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     # Orml
     "orml-traits/std",
     # ChainX primitives
     "chainx-primitives/std",
+    "xp-protocol/std",
     # ChainX pallets
     "xpallet-assets-registrar/std",
-    "xpallet-protocol/std",
     "xpallet-support/std",
 ]
 runtime-benchmarks = [
diff --git a/xpallets/assets/src/benchmarking.rs b/xpallets/assets/src/benchmarking.rs
index 874fb81bb..bcf20e61c 100644
--- a/xpallets/assets/src/benchmarking.rs
+++ b/xpallets/assets/src/benchmarking.rs
@@ -7,7 +7,7 @@ use frame_system::RawOrigin;
 
 use crate::Module as XAssets;
 
-const ASSET_ID: AssetId = xpallet_protocol::X_BTC;
+const ASSET_ID: AssetId = xp_protocol::X_BTC;
 const SEED: u32 = 0;
 
 benchmarks! {
diff --git a/xpallets/assets/src/mock.rs b/xpallets/assets/src/mock.rs
index 647253cbf..b1c31a35b 100644
--- a/xpallets/assets/src/mock.rs
+++ b/xpallets/assets/src/mock.rs
@@ -1,18 +1,21 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use crate::*;
-use crate::{Module, Trait};
-use chainx_primitives::AssetId;
-use frame_support::{impl_outer_event, impl_outer_origin, parameter_types, sp_io, weights::Weight};
+use std::collections::BTreeMap;
+
 use sp_core::H256;
 use sp_runtime::{
     testing::Header,
     traits::{BlakeTwo256, IdentityLookup},
     Perbill,
 };
-use std::collections::BTreeMap;
 
-pub use xpallet_protocol::X_BTC;
+use frame_support::{impl_outer_event, impl_outer_origin, parameter_types, sp_io, weights::Weight};
+
+use chainx_primitives::AssetId;
+pub use xp_protocol::X_BTC;
+
+use crate::*;
+use crate::{Module, Trait};
 
 /// The AccountId alias in this test module.
 pub(crate) type AccountId = u64;
diff --git a/xpallets/dex/spot/Cargo.toml b/xpallets/dex/spot/Cargo.toml
index 2293b2f3f..ffdc16d9d 100644
--- a/xpallets/dex/spot/Cargo.toml
+++ b/xpallets/dex/spot/Cargo.toml
@@ -15,17 +15,17 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 pallet-balances = { version = "2.0.0", default-features = false }
 
 # ChainX primitives
 chainx-primitives = { path = "../../../primitives", default-features = false }
+xp-protocol = { path = "../../../primitives/protocol", default-features = false, optional = true }
 
 # ChainX pallets
 xpallet-assets = { path = "../../assets", default-features = false }
 xpallet-assets-registrar = { path = "../../assets-registrar", default-features = false }
-xpallet-protocol = { path = "../../protocol", default-features = false, optional = true }
 xpallet-support = { path = "../../support", default-features = false }
 
 [dev-dependencies]
@@ -33,7 +33,7 @@ env_logger = "0.7.1"
 sp-core = "2.0.0"
 sp-io = "2.0.0"
 frame-benchmarking = "2.0.0"
-xpallet-protocol = { path = "../../protocol" }
+xp-protocol = { path = "../../../primitives/protocol" }
 
 [features]
 default = ["std"]
@@ -45,8 +45,8 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrate pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     "pallet-balances/std",
     # ChainX primitives
     "chainx-primitives/std",
@@ -57,5 +57,5 @@ std = [
 ]
 runtime-benchmarks = [
     "frame-benchmarking",
-    "xpallet-protocol",
+    "xp-protocol",
 ]
diff --git a/xpallets/dex/spot/src/benchmarking.rs b/xpallets/dex/spot/src/benchmarking.rs
index 8ab65eda0..14fa845e8 100644
--- a/xpallets/dex/spot/src/benchmarking.rs
+++ b/xpallets/dex/spot/src/benchmarking.rs
@@ -1,10 +1,10 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use super::*;
-
 pub use frame_benchmarking::{account, benchmarks};
 use frame_system::RawOrigin;
-use xpallet_protocol::X_BTC;
+use xp_protocol::X_BTC;
+
+use super::*;
 
 const EOS: AssetId = 8888;
 const ETH: AssetId = 9999;
diff --git a/xpallets/dex/spot/src/mock.rs b/xpallets/dex/spot/src/mock.rs
index e4571035a..9403048b3 100644
--- a/xpallets/dex/spot/src/mock.rs
+++ b/xpallets/dex/spot/src/mock.rs
@@ -1,7 +1,5 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use crate::*;
-
 use std::{
     cell::RefCell,
     collections::{BTreeMap, HashSet},
@@ -16,8 +14,10 @@ use sp_runtime::{
 };
 
 use chainx_primitives::{AssetId, BlockNumber};
+use xp_protocol::{BTC_DECIMALS, PCX, PCX_DECIMALS, X_BTC, X_DOT};
 use xpallet_assets::{AssetInfo, AssetRestrictions, Chain};
-use xpallet_protocol::{BTC_DECIMALS, PCX, PCX_DECIMALS, X_BTC, X_DOT};
+
+use crate::*;
 
 /// The AccountId alias in this test module.
 pub(crate) type AccountId = u64;
diff --git a/xpallets/gateway/bitcoin/Cargo.toml b/xpallets/gateway/bitcoin/Cargo.toml
index 701758eb4..316465be7 100644
--- a/xpallets/gateway/bitcoin/Cargo.toml
+++ b/xpallets/gateway/bitcoin/Cargo.toml
@@ -17,8 +17,8 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 pallet-timestamp = { version = "2.0.0", default-features = false }
 
 # Orml
@@ -27,12 +27,12 @@ orml-utilities = { version = "0.3", default-features = false }
 # ChainX primitives
 chainx-primitives = { path = "../../../primitives", default-features = false }
 xp-io = { path = "../../../primitives/io", default-features = false }
+xp-protocol = { path = "../../../primitives/protocol", default-features = false }
 
 # ChainX pallets
 xpallet-assets = { path = "../../assets", default-features = false }
 xpallet-gateway-common = { path = "../common", default-features = false }
 xpallet-gateway-records = { path = "../records", default-features = false }
-xpallet-protocol = { path = "../../protocol", default-features = false }
 xpallet-support = { path = "../../support", default-features = false }
 
 # light-bitcoin
@@ -58,19 +58,19 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrate pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     "pallet-timestamp/std",
     # Orml
     "orml-utilities/std",
     # ChainX primitives
     "chainx-primitives/std",
     "xp-io/std",
+    "xp-protocol/std",
     # ChainX pallets
     "xpallet-assets/std",
     "xpallet-gateway-common/std",
     "xpallet-gateway-records/std",
-    "xpallet-protocol/std",
     "xpallet-support/std",
     # light-bitcoin
     "light-bitcoin/std",
diff --git a/xpallets/gateway/bitcoin/src/benchmarking.rs b/xpallets/gateway/bitcoin/src/benchmarking.rs
index 79b5ca61f..3e6432f73 100644
--- a/xpallets/gateway/bitcoin/src/benchmarking.rs
+++ b/xpallets/gateway/bitcoin/src/benchmarking.rs
@@ -2,18 +2,19 @@
 
 use frame_benchmarking::{benchmarks, whitelisted_caller};
 use frame_system::RawOrigin;
-use light_bitcoin::merkle::PartialMerkleTree;
 
-use crate::Module as XGatewayBitcoin;
 use xpallet_assets::Module as XAssets;
 use xpallet_gateway_records::Module as XGatewayRecords;
 use xpallet_gateway_records::WithdrawalState;
 
+use light_bitcoin::merkle::PartialMerkleTree;
+
 use super::*;
 use crate::tests::common::{self, *};
 use crate::types::*;
+use crate::Module as XGatewayBitcoin;
 
-const ASSET_ID: AssetId = xpallet_protocol::X_BTC;
+const ASSET_ID: AssetId = xp_protocol::X_BTC;
 
 fn withdraw_tx() -> (Transaction, BtcRelayedTxInfo, Transaction) {
     // https://btc.com/62c389f1974b8a44737d76f92da0f5cd7f6f48d065e7af6ba368298361141270.rawhex
diff --git a/xpallets/gateway/bitcoin/src/lib.rs b/xpallets/gateway/bitcoin/src/lib.rs
index 6d77925a6..43126ac70 100644
--- a/xpallets/gateway/bitcoin/src/lib.rs
+++ b/xpallets/gateway/bitcoin/src/lib.rs
@@ -427,7 +427,7 @@ decl_module! {
 }
 
 impl<T: Trait> ChainT<BalanceOf<T>> for Module<T> {
-    const ASSET_ID: AssetId = xpallet_protocol::X_BTC;
+    const ASSET_ID: AssetId = xp_protocol::X_BTC;
 
     fn chain() -> Chain {
         Chain::Bitcoin
diff --git a/xpallets/gateway/common/Cargo.toml b/xpallets/gateway/common/Cargo.toml
index c0163ce45..957a36209 100644
--- a/xpallets/gateway/common/Cargo.toml
+++ b/xpallets/gateway/common/Cargo.toml
@@ -17,19 +17,19 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 
 # ChainX primitives
 chainx-primitives = { path = "../../../primitives", default-features = false }
-xp-runtime = { path = "../../../primitives/runtime", default-features = false }
 xp-io = { path = "../../../primitives/io", default-features = false, optional = true }
+xp-protocol = { path = "../../../primitives/protocol", default-features = false }
+xp-runtime = { path = "../../../primitives/runtime", default-features = false }
 
 # ChainX pallets
 xpallet-assets = { path = "../../assets", default-features = false }
 xpallet-assets-registrar = { path = "../../assets-registrar", default-features = false }
 xpallet-gateway-records = { path = "../records", default-features = false }
-xpallet-protocol = { path = "../../protocol", default-features = false }
 xpallet-support = { path = "../../support", default-features = false }
 
 # light-bitcoin
@@ -54,17 +54,17 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrate pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     # ChainX primitives
     "chainx-primitives/std",
     "xp-io/std",
+    "xp-protocol/std",
     "xp-runtime/std",
     # ChainX pallets
     "xpallet-assets/std",
     "xpallet-assets-registrar/std",
     "xpallet-gateway-records/std",
-    "xpallet-protocol/std",
     "xpallet-support/std",
     # light-bitcoin
     "light-bitcoin/std",
diff --git a/xpallets/gateway/common/src/benchmarks/benchmarking.rs b/xpallets/gateway/common/src/benchmarks/benchmarking.rs
index 4f72d4b56..7fd989e67 100644
--- a/xpallets/gateway/common/src/benchmarks/benchmarking.rs
+++ b/xpallets/gateway/common/src/benchmarks/benchmarking.rs
@@ -1,19 +1,20 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use crate::*;
 use codec::{Decode, Encode};
 
+use sp_std::prelude::*;
+
 use frame_benchmarking::benchmarks;
 use frame_system::RawOrigin;
 use sp_core::crypto::AccountId32;
-use sp_std::prelude::*;
 
 use chainx_primitives::AssetId;
+use xpallet_gateway_records::Module as XGatewayRecords;
 
 use crate::Module as XGatewayCommon;
-use xpallet_gateway_records::Module as XGatewayRecords;
+use crate::*;
 
-const ASSET_ID: AssetId = xpallet_protocol::X_BTC;
+const ASSET_ID: AssetId = xp_protocol::X_BTC;
 
 benchmarks! {
     _{ }
diff --git a/xpallets/gateway/common/src/benchmarks/mock.rs b/xpallets/gateway/common/src/benchmarks/mock.rs
index 2cb8ea7c6..ebeb3880f 100644
--- a/xpallets/gateway/common/src/benchmarks/mock.rs
+++ b/xpallets/gateway/common/src/benchmarks/mock.rs
@@ -1,7 +1,7 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use core::time::Duration;
 use std::cell::RefCell;
+use std::time::Duration;
 
 use codec::{Decode, Encode};
 
@@ -18,17 +18,15 @@ use sp_runtime::{
 };
 
 use chainx_primitives::AssetId;
+pub use xp_protocol::{X_BTC, X_ETH};
 use xpallet_assets::AssetRestrictions;
 use xpallet_assets_registrar::{AssetInfo, Chain};
+use xpallet_support::traits::{MultisigAddressFor, Validator};
 
 use super::mock_impls;
 use crate::trustees;
 use crate::types::TrusteeInfoConfig;
 
-pub use xpallet_protocol::X_BTC;
-pub use xpallet_protocol::X_ETH;
-use xpallet_support::traits::{MultisigAddressFor, Validator};
-
 pub(crate) type AccountId = AccountId32;
 pub(crate) type BlockNumber = u64;
 pub(crate) type Balance = u128;
diff --git a/xpallets/gateway/records/Cargo.toml b/xpallets/gateway/records/Cargo.toml
index 5227823f5..590f84125 100644
--- a/xpallets/gateway/records/Cargo.toml
+++ b/xpallets/gateway/records/Cargo.toml
@@ -14,20 +14,20 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 
 # Orml
 orml-utilities = { version = "0.3", default-features = false }
 
 # ChainX primitives
 chainx-primitives = { path = "../../../primitives", default-features = false }
+xp-protocol = { path = "../../../primitives/protocol", default-features = false }
 xp-runtime = { path = "../../../primitives/runtime", default-features = false }
 
 # ChainX pallets
 xpallet-assets = { path = "../../assets", default-features = false }
 xpallet-assets-registrar = { path = "../../assets-registrar", default-features = false }
-xpallet-protocol = { path = "../../protocol", default-features = false }
 xpallet-support = { path = "../../support", default-features = false }
 
 [dev-dependencies]
@@ -44,17 +44,17 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrate pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     # Orml
     "orml-utilities/std",
     # ChainX primitives
     "chainx-primitives/std",
+    "xp-protocol/std",
     "xp-runtime/std",
     # ChainX pallets
     "xpallet-assets/std",
     "xpallet-assets-registrar/std",
-    "xpallet-protocol/std",
     "xpallet-support/std",
 ]
 runtime-benchmarks = [
diff --git a/xpallets/gateway/records/src/benchmarking.rs b/xpallets/gateway/records/src/benchmarking.rs
index cbe4fb1db..10e854324 100644
--- a/xpallets/gateway/records/src/benchmarking.rs
+++ b/xpallets/gateway/records/src/benchmarking.rs
@@ -1,12 +1,12 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use super::*;
-use crate::Module as XGatewayRecords;
-
 use frame_benchmarking::{benchmarks, whitelisted_caller};
 use frame_system::RawOrigin;
 
-const ASSET_ID: AssetId = xpallet_protocol::X_BTC;
+use super::*;
+use crate::Module as XGatewayRecords;
+
+const ASSET_ID: AssetId = xp_protocol::X_BTC;
 
 fn deposit<T: Trait>(who: T::AccountId, amount: BalanceOf<T>) {
     let receiver_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(who);
diff --git a/xpallets/gateway/records/src/mock.rs b/xpallets/gateway/records/src/mock.rs
index 6db88d60e..822bd0b24 100644
--- a/xpallets/gateway/records/src/mock.rs
+++ b/xpallets/gateway/records/src/mock.rs
@@ -1,7 +1,5 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use crate::*;
-
 use frame_support::{impl_outer_origin, parameter_types, sp_io, weights::Weight};
 use sp_core::H256;
 use sp_runtime::{
@@ -11,9 +9,11 @@ use sp_runtime::{
 };
 
 use chainx_primitives::AssetId;
+pub use xp_protocol::{X_BTC, X_ETH};
 use xpallet_assets::AssetRestrictions;
 use xpallet_assets_registrar::AssetInfo;
-pub use xpallet_protocol::{X_BTC, X_ETH};
+
+use crate::*;
 
 /// The AccountId alias in this test module.
 pub(crate) type AccountId = u64;
diff --git a/xpallets/genesis-builder/Cargo.toml b/xpallets/genesis-builder/Cargo.toml
index 70dd039c8..640fef408 100644
--- a/xpallets/genesis-builder/Cargo.toml
+++ b/xpallets/genesis-builder/Cargo.toml
@@ -20,12 +20,12 @@ pallet-balances = { version = "2.0.0", default-features = false }
 # ChainX primitives
 chainx-primitives = { path = "../../primitives", default-features = false }
 xp-genesis-builder = { path = "../../primitives/genesis-builder", default-features = false }
+xp-protocol = { path = "../../primitives/protocol", default-features = false }
 
 # ChainX pallets
 xpallet-assets = { path = "../assets", default-features = false }
 xpallet-mining-asset = { path  = "../mining/asset", default-features = false }
 xpallet-mining-staking = { path  = "../mining/staking", default-features = false }
-xpallet-protocol = { path = "../protocol", default-features = false }
 xpallet-support = { path = "../support", default-features = false }
 
 [features]
@@ -33,20 +33,20 @@ default = ["std"]
 std = [
     "codec/std",
     "serde",
-
+    # Substrate primitives
     "sp-runtime/std",
     "sp-std/std",
-
+    # Substrate pallets
     "frame-support/std",
     "frame-system/std",
     "pallet-balances/std",
-
+    # ChainX primitives
     "chainx-primitives/std",
     "xp-genesis-builder/std",
-
+    "xp-protocol/std",
+    # ChainX pallets
     "xpallet-assets/std",
     "xpallet-mining-asset/std",
     "xpallet-mining-staking/std",
-    "xpallet-protocol/std",
     "xpallet-support/std",
 ]
diff --git a/xpallets/genesis-builder/src/lib.rs b/xpallets/genesis-builder/src/lib.rs
index d6cb7bd7f..82a979589 100644
--- a/xpallets/genesis-builder/src/lib.rs
+++ b/xpallets/genesis-builder/src/lib.rs
@@ -109,7 +109,7 @@ mod genesis {
     pub mod xassets {
         use crate::{AssetBalanceOf, Trait};
         use xp_genesis_builder::FreeBalanceInfo;
-        use xpallet_protocol::X_BTC;
+        use xp_protocol::X_BTC;
 
         pub fn initialize<T: Trait>(
             xbtc_assets: &[FreeBalanceInfo<T::AccountId, AssetBalanceOf<T>>],
@@ -174,7 +174,7 @@ mod genesis {
     pub mod xmining_asset {
         use crate::Trait;
         use xp_genesis_builder::{XBtcMiner, XMiningAssetParams};
-        use xpallet_protocol::X_BTC;
+        use xp_protocol::X_BTC;
 
         /// Mining asset module initialization only involves the mining weight.
         /// - Set xbtc mining asset weight.
diff --git a/xpallets/mining/asset/Cargo.toml b/xpallets/mining/asset/Cargo.toml
index fef4759f1..c1212e40c 100644
--- a/xpallets/mining/asset/Cargo.toml
+++ b/xpallets/mining/asset/Cargo.toml
@@ -16,19 +16,19 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 
 # ChainX primitives
 chainx-primitives = { path = "../../../primitives", default-features = false }
 xp-mining-common = { path  = "../../../primitives/mining/common", default-features = false }
 xp-mining-staking = { path  = "../../../primitives/mining/staking", default-features = false }
+xp-protocol = { path = "../../../primitives/protocol", default-features = false }
 
 # ChainX pallets
 xpallet-assets = { path = "../../assets", default-features = false }
 xpallet-assets-registrar = { path = "../../assets-registrar", default-features = false }
 xpallet-mining-staking = { path = "../../mining/staking", default-features = false }
-xpallet-protocol = { path = "../../protocol", default-features = false }
 xpallet-support = { path = "../../support", default-features = false }
 
 [dev-dependencies]
@@ -51,17 +51,17 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrte pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     # ChainX primitives
     "chainx-primitives/std",
     "xp-mining-common/std",
     "xp-mining-staking/std",
+    "xp-protocol/std",
     # ChainX pallets
     "xpallet-assets/std",
     "xpallet-assets-registrar/std",
     "xpallet-mining-staking/std",
-    "xpallet-protocol/std",
     "xpallet-support/std",
 ]
 runtime-benchmarks = [
diff --git a/xpallets/mining/asset/src/benchmarking.rs b/xpallets/mining/asset/src/benchmarking.rs
index 71bf8228d..635ef1985 100644
--- a/xpallets/mining/asset/src/benchmarking.rs
+++ b/xpallets/mining/asset/src/benchmarking.rs
@@ -1,10 +1,10 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use super::*;
-
 pub use frame_benchmarking::{account, benchmarks};
 use frame_system::RawOrigin;
-use xpallet_protocol::X_BTC;
+use xp_protocol::X_BTC;
+
+use super::*;
 
 const SEED: u32 = 0;
 
diff --git a/xpallets/mining/asset/src/impls.rs b/xpallets/mining/asset/src/impls.rs
index ca68c1bcb..95df4da3e 100644
--- a/xpallets/mining/asset/src/impls.rs
+++ b/xpallets/mining/asset/src/impls.rs
@@ -1,14 +1,16 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use super::*;
 use codec::Encode;
 use sp_core::crypto::UncheckedFrom;
 use sp_runtime::traits::{Hash, Saturating};
+
 use xp_mining_common::{
     generic_weight_factors, BaseMiningWeight, Claim, ComputeMiningWeight, WeightFactors, WeightType,
 };
 use xp_mining_staking::MiningPower;
 
+use super::*;
+
 impl<'a, T: Trait> BaseMiningWeight<BalanceOf<T>, T::BlockNumber> for AssetLedgerWrapper<'a, T> {
     fn amount(&self) -> BalanceOf<T> {
         xpallet_assets::Module::<T>::total_issuance(&self.asset_id)
@@ -85,7 +87,7 @@ impl<T: Trait> ComputeMiningWeight<T::AccountId, T::BlockNumber> for Module<T> {
 // * `on_move_pre`
 //
 // ```rust
-// if xpallet_protocol::PCX == *target {
+// if xp_protocol::PCX == *target {
 //     return Ok(());
 // }
 // ```
diff --git a/xpallets/mining/asset/src/mock.rs b/xpallets/mining/asset/src/mock.rs
index a1f2981ec..625aadd4d 100644
--- a/xpallets/mining/asset/src/mock.rs
+++ b/xpallets/mining/asset/src/mock.rs
@@ -1,8 +1,10 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use crate::*;
-use crate::{Module, Trait};
-use chainx_primitives::AssetId;
+use std::{
+    cell::RefCell,
+    collections::{BTreeMap, HashSet},
+};
+
 use frame_support::{
     impl_outer_event, impl_outer_origin, parameter_types, traits::Get, weights::Weight,
 };
@@ -12,13 +14,14 @@ use sp_runtime::{
     traits::{BlakeTwo256, IdentityLookup},
     Perbill,
 };
-use std::{
-    cell::RefCell,
-    collections::{BTreeMap, HashSet},
-};
+
+use chainx_primitives::AssetId;
 use xp_mining_staking::SessionIndex;
 use xpallet_assets::{AssetInfo, AssetRestrictions, Chain};
 
+use crate::*;
+use crate::{Module, Trait};
+
 pub const INIT_TIMESTAMP: u64 = 30_000;
 
 /// The AccountId alias in this test module.
@@ -177,7 +180,7 @@ impl pallet_session::OneSessionHandler<AccountId> for OtherSessionHandler {
 
 pub(crate) fn btc() -> (AssetId, AssetInfo, AssetRestrictions) {
     (
-        xpallet_protocol::X_BTC,
+        xp_protocol::X_BTC,
         AssetInfo::new::<Test>(
             b"X-BTC".to_vec(),
             b"X-BTC".to_vec(),
@@ -382,8 +385,8 @@ impl ExtBuilder {
         .assimilate_storage(&mut storage);
 
         let _ = GenesisConfig::<Test> {
-            claim_restrictions: vec![(xpallet_protocol::X_BTC, (7, 3))],
-            mining_power_map: vec![(xpallet_protocol::X_BTC, 400)],
+            claim_restrictions: vec![(xp_protocol::X_BTC, (7, 3))],
+            mining_power_map: vec![(xp_protocol::X_BTC, 400)],
         }
         .assimilate_storage(&mut storage);
 
diff --git a/xpallets/mining/staking/Cargo.toml b/xpallets/mining/staking/Cargo.toml
index c2ccbe710..59d7a444f 100644
--- a/xpallets/mining/staking/Cargo.toml
+++ b/xpallets/mining/staking/Cargo.toml
@@ -17,8 +17,8 @@ sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
 frame-benchmarking = { version = "2.0.0", default-features = false, optional = true }
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 pallet-balances = { version = "2.0.0", default-features = false }
 pallet-session = { version = "2.0.0", default-features = false }
 
@@ -36,9 +36,9 @@ xpallet-support = { path = "../../support", default-features = false }
 env_logger = "0.7.1"
 sp-core = "2.0.0"
 sp-io = "2.0.0"
+xp-protocol = { path = "../../../primitives/protocol" }
 frame-benchmarking = "2.0.0"
 pallet-timestamp = "2.0.0"
-xpallet-protocol = { path = "../../protocol" }
 
 [features]
 default = ["std"]
@@ -52,8 +52,8 @@ std = [
     "sp-staking/std",
     "sp-std/std",
     # Substrate pallets
-    "frame-system/std",
     "frame-support/std",
+    "frame-system/std",
     "pallet-balances/std",
     "pallet-session/std",
     # ChainX primitives
diff --git a/xpallets/system/Cargo.toml b/xpallets/system/Cargo.toml
index 0708ca725..f33f9636d 100644
--- a/xpallets/system/Cargo.toml
+++ b/xpallets/system/Cargo.toml
@@ -13,11 +13,11 @@ sp-runtime = { version = "2.0.0", default-features = false }
 sp-std = { version = "2.0.0", default-features = false }
 
 # Substrate pallets
-frame-system = { version = "2.0.0", default-features = false }
 frame-support = { version = "2.0.0", default-features = false }
+frame-system = { version = "2.0.0", default-features = false }
 
-# ChainX pallets
-xpallet-protocol = { path = "../protocol", default-features = false }
+# ChainX primitives
+xp-protocol = { path = "../../primitives/protocol", default-features = false }
 
 [features]
 default = ["std"]
@@ -28,8 +28,8 @@ std = [
     "sp-runtime/std",
     "sp-std/std",
     # Substrate pallets
-    "frame-system/std",
     "frame-support/std",
-    # ChainX pallets
-    "xpallet-protocol/std",
+    "frame-system/std",
+    # ChainX primitives
+    "xp-protocol/std",
 ]
diff --git a/xpallets/system/src/lib.rs b/xpallets/system/src/lib.rs
index 051f75077..56882208d 100644
--- a/xpallets/system/src/lib.rs
+++ b/xpallets/system/src/lib.rs
@@ -14,7 +14,7 @@ use frame_support::{
 };
 use frame_system::ensure_root;
 
-use xpallet_protocol::NetworkType;
+use xp_protocol::NetworkType;
 
 const PALLET_MARK: &[u8; 1] = b"#";
 const ALWAYS_ALLOW: [&str; 1] = ["Sudo"];


Test patch:
diff --git a/xpallets/assets-registrar/src/tests.rs b/xpallets/assets-registrar/src/tests.rs
index 1b425d912..b2cbd32c1 100644
--- a/xpallets/assets-registrar/src/tests.rs
+++ b/xpallets/assets-registrar/src/tests.rs
@@ -12,7 +12,7 @@ use sp_runtime::{
 };
 
 use chainx_primitives::AssetId;
-use xpallet_protocol::X_BTC;
+use xp_protocol::X_BTC;
 
 use crate::*;
 
@@ -97,7 +97,7 @@ impl Default for ExtBuilder {
 
 pub(crate) fn btc() -> (AssetId, AssetInfo) {
     (
-        xpallet_protocol::X_BTC,
+        xp_protocol::X_BTC,
         AssetInfo::new::<Test>(
             b"X-BTC".to_vec(),
             b"X-BTC".to_vec(),
diff --git a/xpallets/assets/src/tests.rs b/xpallets/assets/src/tests.rs
index fc8189437..88c939cbb 100644
--- a/xpallets/assets/src/tests.rs
+++ b/xpallets/assets/src/tests.rs
@@ -1,12 +1,12 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-pub use crate::mock::*;
-use crate::*;
-
 use frame_support::{assert_noop, assert_ok};
 use frame_system::{EventRecord, Phase};
 
-use xpallet_protocol::X_BTC;
+use xp_protocol::X_BTC;
+
+pub use crate::mock::*;
+use crate::*;
 
 #[test]
 fn test_genesis() {
diff --git a/xpallets/dex/spot/src/tests.rs b/xpallets/dex/spot/src/tests.rs
index bab30a229..23beb95a8 100644
--- a/xpallets/dex/spot/src/tests.rs
+++ b/xpallets/dex/spot/src/tests.rs
@@ -2,13 +2,14 @@
 
 #![cfg(test)]
 
-use super::mock::*;
-use super::*;
+use sp_std::collections::btree_map::BTreeMap;
 
 use frame_support::{assert_noop, assert_ok};
-use sp_std::collections::btree_map::BTreeMap;
 use xpallet_assets::AssetType;
 
+use super::mock::*;
+use super::*;
+
 pub(crate) const EOS: AssetId = 8888;
 pub(crate) const ETH: AssetId = 9999;
 
@@ -17,7 +18,7 @@ pub(crate) fn t_issue_pcx(to: AccountId, value: Balance) {
 }
 
 pub(crate) fn t_generic_issue(asset_id: AssetId, to: AccountId, value: Balance) {
-    if asset_id == xpallet_protocol::PCX {
+    if asset_id == xp_protocol::PCX {
         t_issue_pcx(to, value);
     } else {
         assert_ok!(XAssets::issue(&asset_id, &to, value));
@@ -25,7 +26,7 @@ pub(crate) fn t_generic_issue(asset_id: AssetId, to: AccountId, value: Balance)
 }
 
 pub(crate) fn t_generic_free_balance(who: AccountId, asset_id: AssetId) -> Balance {
-    if asset_id == xpallet_protocol::PCX {
+    if asset_id == xp_protocol::PCX {
         Balances::free_balance(who)
     } else {
         XAssets::usable_balance(&who, &asset_id)
diff --git a/xpallets/gateway/bitcoin/src/tests/mock.rs b/xpallets/gateway/bitcoin/src/tests/mock.rs
index 4b16d19e3..c31fa53e8 100644
--- a/xpallets/gateway/bitcoin/src/tests/mock.rs
+++ b/xpallets/gateway/bitcoin/src/tests/mock.rs
@@ -4,8 +4,8 @@
 
 use super::common::*;
 
-use core::time::Duration;
 use std::cell::RefCell;
+use std::time::Duration;
 
 // Substrate
 use frame_support::{impl_outer_origin, parameter_types, sp_io, weights::Weight};
@@ -16,16 +16,14 @@ use sp_runtime::{
     AccountId32, Perbill,
 };
 
-// light-bitcoin
-use light_bitcoin::primitives::Compact;
-
 use chainx_primitives::AssetId;
+pub use xp_protocol::{X_BTC, X_ETH};
 use xpallet_assets::AssetRestrictions;
 use xpallet_assets_registrar::AssetInfo;
 use xpallet_gateway_common::types::TrusteeInfoConfig;
 
-pub use xpallet_protocol::X_BTC;
-pub use xpallet_protocol::X_ETH;
+// light-bitcoin
+use light_bitcoin::primitives::Compact;
 
 /// The AccountId alias in this test module.
 pub(crate) type AccountId = AccountId32;
diff --git a/xpallets/gateway/common/tests/mock.rs b/xpallets/gateway/common/tests/mock.rs
index c0f719138..840a4f830 100644
--- a/xpallets/gateway/common/tests/mock.rs
+++ b/xpallets/gateway/common/tests/mock.rs
@@ -1,8 +1,8 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use core::time::Duration;
 use std::cell::RefCell;
 use std::str::FromStr;
+use std::time::Duration;
 
 use codec::{Decode, Encode};
 
@@ -19,15 +19,12 @@ use sp_runtime::{
 };
 
 use chainx_primitives::AssetId;
+pub use xp_protocol::{X_BTC, X_ETH};
 use xpallet_assets::AssetRestrictions;
 use xpallet_assets_registrar::{AssetInfo, Chain};
 use xpallet_gateway_bitcoin::{BtcHeader, BtcNetwork, BtcParams, BtcTxVerifier, Compact};
-
 use xpallet_gateway_common::trustees;
 use xpallet_gateway_common::types::TrusteeInfoConfig;
-
-pub use xpallet_protocol::X_BTC;
-pub use xpallet_protocol::X_ETH;
 use xpallet_support::traits::MultisigAddressFor;
 
 pub(crate) type AccountId = AccountId32;
diff --git a/xpallets/mining/asset/src/tests.rs b/xpallets/mining/asset/src/tests.rs
index f3ad860e8..a315a5af0 100644
--- a/xpallets/mining/asset/src/tests.rs
+++ b/xpallets/mining/asset/src/tests.rs
@@ -1,7 +1,5 @@
 // Copyright 2019-2020 ChainX Project Authors. Licensed under GPL-3.0.
 
-use super::*;
-use crate::mock::*;
 use frame_support::{
     assert_err, assert_ok,
     traits::{Get, OnInitialize},
@@ -9,7 +7,10 @@ use frame_support::{
 use frame_system::RawOrigin;
 
 use xp_mining_staking::SessionIndex;
-use xpallet_protocol::X_BTC;
+use xp_protocol::X_BTC;
+
+use super::*;
+use crate::mock::*;
 
 fn t_system_block_number_inc(number: BlockNumber) {
     System::set_block_number((System::block_number() + number).into());
@@ -82,7 +83,7 @@ fn t_xbtc_set_claim_staking_requirement(new: StakingRequirement) {
 fn assert_xbtc_reward_pot_balance(value: Balance) {
     assert_eq!(
         Balances::free_balance(
-            &DummyAssetRewardPotAccountDeterminer::reward_pot_account_for(&xpallet_protocol::X_BTC)
+            &DummyAssetRewardPotAccountDeterminer::reward_pot_account_for(&xp_protocol::X_BTC)
         ),
         value
     );
@@ -368,7 +369,7 @@ fn total_issuance_should_work() {
 fn t_set_xbtc_asset_power(new: FixedAssetPower) {
     assert_ok!(XMiningAsset::set_asset_power(
         Origin::root(),
-        xpallet_protocol::X_BTC,
+        xp_protocol::X_BTC,
         new
     ));
 }
@@ -436,20 +437,17 @@ fn asset_mining_reward_should_work() {
         // Disable the staking requirement.
         assert_ok!(XMiningAsset::set_claim_staking_requirement(
             Origin::root(),
-            xpallet_protocol::X_BTC,
+            xp_protocol::X_BTC,
             0
         ));
 
         assert_eq!(Balances::free_balance(&t_1), 0);
-        assert_ok!(XMiningAsset::claim(
-            Origin::signed(t_1),
-            xpallet_protocol::X_BTC
-        ));
+        assert_ok!(XMiningAsset::claim(Origin::signed(t_1), xp_protocol::X_BTC));
         assert_eq!(
             Balances::free_balance(&t_1),
             xbtc_pot_balance - xbtc_pot_balance / 10
         );
-        let referral = DummyGatewayReferralGetter::referral_of(&t_1, xpallet_protocol::X_BTC)
+        let referral = DummyGatewayReferralGetter::referral_of(&t_1, xp_protocol::X_BTC)
             .unwrap_or(TREASURY_ACCOUNT);
         assert_eq!(Balances::free_balance(&referral), xbtc_pot_balance / 10);
         assert_eq!(Balances::free_balance(&TREASURY_ACCOUNT), treasury_balance);