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

XCMP, xTokens, Assets, AssetManager and Treasury for Manta #1050

Merged
merged 25 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
04a7c95
Add xcm, assets, assetmanager, treasury
ghzlatarev Mar 21, 2023
0eb039b
Fix benchmarking
ghzlatarev Mar 21, 2023
983fffb
Clean up
ghzlatarev Mar 21, 2023
db40850
Add xTokens to callfilter
ghzlatarev Mar 21, 2023
426e195
Add xcm-tests
ghzlatarev Mar 22, 2023
a14dd41
Merge branch 'manta' into ghzlatarev/manta-xcm
ghzlatarev Mar 24, 2023
a99a343
Use reasonable prices for treasury constants
ghzlatarev Mar 24, 2023
8f16ccc
dedupe some code
ghzlatarev Mar 24, 2023
8c0805c
Use feature
ghzlatarev Mar 24, 2023
8457880
Fix cargo imports
ghzlatarev Mar 24, 2023
da5ef9e
CLean up common.rs
ghzlatarev Mar 28, 2023
5395682
Better name for feature
ghzlatarev Mar 28, 2023
1702f8d
Taplo fmt
ghzlatarev Mar 28, 2023
afca5a2
Clean up xcm benchmarks code
ghzlatarev Mar 28, 2023
4f8df97
Merge branch 'manta' into ghzlatarev/manta-xcm
ghzlatarev Mar 28, 2023
30b9f0e
Update weights files
ghzlatarev Mar 28, 2023
ee96b6c
Fix occurences of kma, ksm, kusama
ghzlatarev Mar 29, 2023
8193915
Merge branch 'manta' into ghzlatarev/manta-xcm
ferrell-code Mar 29, 2023
e4cddfc
Address pr comments
ghzlatarev Apr 4, 2023
9ac0e40
Merge branch 'manta' into ghzlatarev/manta-xcm
ghzlatarev Apr 4, 2023
900f201
Fix benchmarks
ghzlatarev Apr 4, 2023
dd7935b
Merge branch 'manta' into ghzlatarev/manta-xcm
ghzlatarev Apr 4, 2023
09938af
Merge remote-tracking branch 'origin/manta' into ghzlatarev/manta-xcm
zqhxuyuan Apr 6, 2023
c9b119f
parachain id use parachain info
zqhxuyuan Apr 6, 2023
3d8aacd
Increase spend period in comparison to Calamari
ghzlatarev Apr 6, 2023
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
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 @@ -148,6 +148,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
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