Skip to content

Commit

Permalink
XCMP, xTokens, Assets, AssetManager and Treasury for Manta (#1050)
Browse files Browse the repository at this point in the history
Co-authored-by: ferrell-code <charlie@manta.network>
Co-authored-by: zqhxuyuan <zqhxuyuan@gmail.com>
  • Loading branch information
3 people authored Apr 6, 2023
1 parent eb538c3 commit f319bcc
Show file tree
Hide file tree
Showing 26 changed files with 6,489 additions and 47 deletions.
40 changes: 40 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/src/chain_specs/manta/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ fn manta_dev_genesis(
polkadot_xcm: PolkadotXcmConfig {
safe_xcm_version: Some(SAFE_XCM_VERSION),
},
asset_manager: Default::default(),
}
}

Expand Down
3 changes: 3 additions & 0 deletions primitives/manta/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub type AccountId = <Signer as IdentifyAccount>::AccountId;
/// This index is used to look up accounts.
pub type AccountIndex = u32;

/// Manta Asset Id Type
pub type MantaAssetId = u128;

/// Calamari Asset Id Type
pub type CalamariAssetId = u128;

Expand Down
1 change: 1 addition & 0 deletions runtime/calamari/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ orml-xtokens = { git = "https://github.com/manta-network/open-runtime-module-lib

# Self dependencies
pallet-asset-manager = { path = '../../pallets/asset-manager' }
runtime-common = { path = '../common', features = ["test-helpers"] }


[features]
Expand Down
2 changes: 1 addition & 1 deletion runtime/calamari/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ impl_runtime_apis! {
));
pub const CheckedAccount: Option<AccountId> = None;
pub const KsmLocation: MultiLocation = MultiLocation::parent();
pub KmaLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(2084)));
pub KmaLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(ParachainInfo::parachain_id().into())));
}

impl pallet_xcm_benchmarks::Config for Runtime {
Expand Down
5 changes: 5 additions & 0 deletions runtime/calamari/tests/integrations_mock/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ use frame_support::{
traits::{tokens::ExistenceRequirement, Get, PalletInfo, StorageInfo, StorageInfoTrait},
StorageHasher, Twox128,
};
use runtime_common::test_helpers::{
self_reserve_xcm_message_receiver_side, self_reserve_xcm_message_sender_side,
to_reserve_xcm_message_receiver_side, to_reserve_xcm_message_sender_side,
ADVERTISED_DEST_WEIGHT,
};

use manta_primitives::{
assets::{
Expand Down
5 changes: 5 additions & 0 deletions runtime/calamari/tests/xcm_mock/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ use frame_support::{
assert_err, assert_noop, assert_ok, traits::tokens::fungibles::Mutate, WeakBoundedVec,
};
use manta_primitives::{assets::AssetLocation, constants::WEIGHT_PER_SECOND};
use runtime_common::test_helpers::{
self_reserve_xcm_message_receiver_side, self_reserve_xcm_message_sender_side,
to_reserve_xcm_message_receiver_side, to_reserve_xcm_message_sender_side,
ADVERTISED_DEST_WEIGHT,
};
use xcm::{latest::prelude::*, v2::Response, VersionedMultiLocation, WrapVersion};
use xcm_executor::traits::{Convert, WeightBounds};
use xcm_simulator::TestExt;
Expand Down
43 changes: 43 additions & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,54 @@ frame-support = { git = 'https://github.com/paritytech/substrate.git', branch =
pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", default-features = false }
sp-runtime = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", default-features = false }
sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28", default-features = false }
xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28", optional = true }

# Self dependencies
manta-primitives = { path = '../../primitives/manta', default-features = false }

[dev-dependencies]
lazy_static = "1.4.0"
reqwest = { version = "0.11", features = ["blocking"] }
serde_json = "1.0"

# 3rd dependencies
codec = { package = "parity-scale-codec", version = "3.1.2" }
scale-info = { version = "2.1.2", features = ["derive"] }

# Substrate dependencies
frame-system = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }
pallet-assets = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }
pallet-balances = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }
pallet-utility = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }
sp-core = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }
sp-io = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }
sp-std = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.28" }

# Polkadot dependencies
pallet-xcm = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
polkadot-core-primitives = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
polkadot-parachain = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
polkadot-runtime-parachains = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
xcm = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
xcm-builder = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
xcm-executor = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
xcm-simulator = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }

# Cumulus dependencies
cumulus-pallet-dmp-queue = { git = 'https://github.com/paritytech/cumulus.git', branch = "polkadot-v0.9.28" }
cumulus-pallet-parachain-system = { git = 'https://github.com/paritytech/cumulus.git', branch = "polkadot-v0.9.28" }
cumulus-pallet-xcm = { git = 'https://github.com/paritytech/cumulus.git', branch = "polkadot-v0.9.28" }
cumulus-pallet-xcmp-queue = { git = 'https://github.com/paritytech/cumulus.git', branch = "polkadot-v0.9.28" }
cumulus-primitives-parachain-inherent = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.28" }
cumulus-test-relay-sproof-builder = { git = "https://github.com/paritytech/cumulus.git", branch = "polkadot-v0.9.28" }
parachain-info = { git = 'https://github.com/paritytech/cumulus.git', branch = "polkadot-v0.9.28" }

# Orml dependencies
orml-traits = { git = "https://github.com/manta-network/open-runtime-module-library.git", branch = "polkadot-v0.9.28" }
orml-xtokens = { git = "https://github.com/manta-network/open-runtime-module-library.git", branch = "polkadot-v0.9.28" }

# Self dependencies
pallet-asset-manager = { path = '../../pallets/asset-manager' }

[features]
default = ["std"]
Expand All @@ -29,6 +71,7 @@ std = [
"sp-runtime/std",
"sp-std/std",
]
test-helpers = ["xcm"]
try-runtime = [
"frame-support/try-runtime",
]
3 changes: 3 additions & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

pub mod migration;

#[cfg(feature = "test-helpers")]
pub mod test_helpers;

use frame_support::{parameter_types, weights::Weight};
use manta_primitives::{constants::WEIGHT_PER_NANOS, types::BlockNumber};
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Manta. If not, see <http://www.gnu.org/licenses/>.

#![cfg(test)]

pub mod integrations_mock;
pub mod xcm_mock;

use sp_std::vec;
use xcm::{
latest::{
Expand All @@ -37,7 +32,7 @@ use xcm::{
};

// 4_000_000_000 is a typical configuration value provided to dApp developers for `dest_weight`
// argument when sending xcm message to Calamari. ie moonbeam, sub-wallet, phala, etc
// argument when sending xcm message to Manta. ie moonbeam, sub-wallet, phala, etc
pub const ADVERTISED_DEST_WEIGHT: u64 = 4_000_000_000;

// Composition of self_reserve message composed by xTokens on the sender side
Expand Down
46 changes: 41 additions & 5 deletions runtime/manta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ version = '4.0.4'
[dependencies]
codec = { package = "parity-scale-codec", version = '3.1.2', default-features = false, features = ["derive", "max-encoded-len"] }
hex-literal = { version = '0.3.4', optional = true }
log = { version = "0.4.16", default-features = false }
scale-info = { version = "2.1.2", default-features = false, features = ["derive"] }
serde = { version = "1.0.140", features = ['derive'], optional = true }
smallvec = "1.8.0"
Expand Down Expand Up @@ -40,6 +41,7 @@ frame-system-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.
frame-try-runtime = { git = "https://github.com/paritytech/substrate.git", default-features = false, optional = true, branch = "polkadot-v0.9.28" }

# Substrate pallets
pallet-assets = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.28" }
pallet-aura = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.28" }
pallet-authorship = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.28" }
pallet-balances = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.28" }
Expand All @@ -50,12 +52,15 @@ pallet-sudo = { git = 'https://github.com/paritytech/substrate.git', default-fea
pallet-timestamp = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.28" }
pallet-transaction-payment = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.28" }
pallet-transaction-payment-rpc-runtime-api = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.28" }
pallet-treasury = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.28" }
pallet-utility = { git = 'https://github.com/paritytech/substrate.git', default-features = false, branch = "polkadot-v0.9.28" }

# Cumulus dependencies
cumulus-pallet-dmp-queue = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, branch = "polkadot-v0.9.28" }
cumulus-pallet-parachain-system = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, branch = "polkadot-v0.9.28" }
cumulus-pallet-session-benchmarking = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, optional = true, branch = "polkadot-v0.9.28" }
cumulus-pallet-xcm = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, branch = "polkadot-v0.9.28" }
cumulus-pallet-xcmp-queue = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, branch = "polkadot-v0.9.28" }
cumulus-primitives-core = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, branch = "polkadot-v0.9.28" }
cumulus-primitives-timestamp = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, branch = "polkadot-v0.9.28" }
cumulus-primitives-utility = { git = 'https://github.com/paritytech/cumulus.git', default-features = false, branch = "polkadot-v0.9.28" }
Expand All @@ -68,19 +73,31 @@ pallet-author-inherent = { git = "https://github.com/manta-network/nimbus.git",

# Polkadot dependencies
pallet-xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28" }
pallet-xcm-benchmarks = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28", optional = true }
polkadot-parachain = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28" }
polkadot-primitives = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28" }
xcm = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28" }
xcm-builder = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28" }
xcm-executor = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.28" }

# Third party (vendored) dependencies
orml-traits = { git = 'https://github.com/manta-network/open-runtime-module-library.git', default-features = false, branch = "polkadot-v0.9.28" }
orml-xtokens = { git = 'https://github.com/manta-network/open-runtime-module-library.git', default-features = false, branch = "polkadot-v0.9.28" }

# Self dependencies
manta-collator-selection = { path = '../../pallets/collator-selection', default-features = false }
manta-primitives = { path = '../../primitives/manta', default-features = false }
pallet-asset-manager = { path = '../../pallets/asset-manager', default-features = false }
pallet-parachain-staking = { path = '../../pallets/parachain-staking', default-features = false }
runtime-common = { path = '../common', default-features = false }
session-key-primitives = { path = '../../primitives/session-keys', default-features = false }

[dev-dependencies]
polkadot-core-primitives = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
polkadot-runtime-parachains = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }
runtime-common = { path = '../common', features = ["test-helpers"] }
xcm-simulator = { git = 'https://github.com/paritytech/polkadot.git', branch = "release-v0.9.28" }

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']

Expand All @@ -93,6 +110,7 @@ runtime-benchmarks = [
'cumulus-pallet-session-benchmarking/runtime-benchmarks',
'hex-literal',
'sp-runtime/runtime-benchmarks',
'xcm-builder/runtime-benchmarks',
'frame-benchmarking',
'frame-system-benchmarking',
'frame-support/runtime-benchmarks',
Expand All @@ -105,9 +123,15 @@ runtime-benchmarks = [
'pallet-multisig/runtime-benchmarks',
'pallet-utility/runtime-benchmarks',
'pallet-timestamp/runtime-benchmarks',
'pallet-xcm/runtime-benchmarks',
'pallet-treasury/runtime-benchmarks',
'pallet-parachain-staking/runtime-benchmarks',
'pallet-preimage/runtime-benchmarks',
'pallet-assets/runtime-benchmarks',
'pallet-asset-manager/runtime-benchmarks',
'cumulus-pallet-xcmp-queue/runtime-benchmarks',
'cumulus-pallet-parachain-system/runtime-benchmarks',
'pallet-xcm-benchmarks',
]
try-runtime = [
'frame-executive/try-runtime',
Expand All @@ -122,6 +146,9 @@ try-runtime = [
'pallet-timestamp/try-runtime',
'pallet-transaction-payment/try-runtime',
'pallet-utility/try-runtime',
'pallet-treasury/try-runtime',
'pallet-assets/try-runtime',
'pallet-asset-manager/try-runtime',
'runtime-common/try-runtime',
]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
Expand Down Expand Up @@ -157,22 +184,31 @@ std = [
'pallet-timestamp/std',
'pallet-session/std',
'pallet-sudo/std',
'sp-application-crypto/std',
'pallet-xcm/std',
'pallet-transaction-payment/std',
'pallet-treasury/std',
'manta-primitives/std',
'runtime-common/std',
'parachain-info/std',
'cumulus-pallet-parachain-system/std',
'cumulus-pallet-dmp-queue/std',
"cumulus-pallet-xcmp-queue/std",
"cumulus-pallet-xcm/std",
"cumulus-primitives-core/std",
"cumulus-primitives-timestamp/std",
"cumulus-primitives-utility/std",
"cumulus-pallet-dmp-queue/std",
"pallet-author-inherent/std",
"pallet-aura-style-filter/std",
'session-key-primitives/std',
'polkadot-primitives/std',
'manta-collator-selection/std',
'xcm/std',
'pallet-xcm/std',
'xcm-executor/std',
'xcm-builder/std',
'xcm-executor/std',
'polkadot-primitives/std',
'manta-collator-selection/std',
'pallet-treasury/std',
'pallet-assets/std',
'pallet-asset-manager/std',
'orml-traits/std',
'orml-xtokens/std',
]
Loading

0 comments on commit f319bcc

Please sign in to comment.