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

Mangata dev v0.9.40 #29

Merged
merged 50 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
cafa148
run CI for release branch
xlc Nov 7, 2022
f4ef99f
Upgrade polkadot-v0.9.31 (#830)
zjb0807 Nov 7, 2022
c23d3d2
add CODECOV_TOKEN (#836)
zjb0807 Nov 10, 2022
2b4d4db
claim_rewards should not create empty records (#835)
wangjj9219 Nov 10, 2022
9d54d0e
Update Readme (#837)
fiexer Nov 10, 2022
5803a01
Token hook refactoring; Posthooks for deposit and transfer (#834)
daniel-savu Nov 10, 2022
3fcd3cf
fix(tokens): PostDeposit hook (#839)
daniel-savu Nov 15, 2022
02ec3ea
Add Centrifuge to users of orml (#842)
mikiquantum Nov 16, 2022
43d237d
Add Crust to ORML (#843)
mmyyrroonn Nov 16, 2022
740f0b8
refactor: make weight argument in xtokens transfers optional (#841)
sander2 Nov 16, 2022
7f95607
Update weight-gen template.hbs (#844)
zjb0807 Nov 21, 2022
e885d8d
prevent nested DelayedOrigin (#845)
xlc Nov 22, 2022
394d4c3
Add try-runtime feature for orml-payments (#846)
zjb0807 Nov 22, 2022
f336875
Update to Polkadot v0.9.32 (#848)
NunoAlexandre Nov 22, 2022
56876b4
Add new for DelayedOrigin (#849)
zjb0807 Nov 23, 2022
10cdcf1
Update README.md (#851)
lrcnz Nov 23, 2022
c218d98
#xcm polishing #xtokens README.md (#856)
dzmitry-lahoda Nov 29, 2022
7e3c9ae
Update github actions (#855)
zjb0807 Nov 29, 2022
65da351
Changed `vested_transfer` extrinsic behavior. (#857)
PraetorP Nov 30, 2022
dc39cfd
Upgrade polkadot-v0.9.33 (#858)
Dec 1, 2022
f94894f
use explicit call index (#865)
wangjj9219 Jan 4, 2023
0e23446
Upgrade to polkadot v0.9.36 (#864)
CertainLach Jan 5, 2023
4f5a3f3
update asset_exists (#866)
xlc Jan 5, 2023
0148924
Fix payments on-idle (#868)
zjb0807 Jan 10, 2023
79d7cdd
Switch to Rust-1.66 (#869)
zjb0807 Jan 10, 2023
04e67e6
feat: derive MEL for Value enum (#867)
wischli Jan 10, 2023
80ed32d
feat:Make the XcmTransfer trait support transfer_multiasset_with_fee …
hqwangningbo Jan 12, 2023
ddbb6be
update bencher deps (#872)
ermalkaleci Jan 16, 2023
0811818
add BenchmarkError::Weightless (#873)
insipx Jan 16, 2023
6c3ec8d
Update jsonrpsee 0.16.2 (#876)
zjb0807 Jan 16, 2023
dd05f64
Update README.md (#879)
joshuacheong Jan 17, 2023
24f0a8b
Update README.md (#880)
joshuacheong Jan 17, 2023
05f0007
Upgrade polkadot-v0.9.37 (#882)
zjb0807 Jan 25, 2023
2335795
Add lock events to tokens pallet (#883)
sea212 Jan 30, 2023
dbf86dc
Update xtokens docs (#885)
zjb0807 Feb 8, 2023
fd04cac
added ajuna network (#887)
darkfriend77 Feb 27, 2023
0a64a0b
Upgrade polkadot-v0.9.38 (#886)
tgmichel Mar 1, 2023
c58f03e
Use xcm::v3 instead of latest (#889)
zjb0807 Mar 2, 2023
6df51b3
max weight fix (#891)
wangjj9219 Mar 7, 2023
a730f79
XcmTransfer Trait (#892)
zjb0807 Mar 13, 2023
8301b6c
fix migration and tests (#893)
wangjj9219 Mar 14, 2023
7183477
build: upgrade polkadot to v0.9.39 (#897)
CertainLach Mar 22, 2023
fc413f8
Add & clean deprecated (#895)
zjb0807 Mar 23, 2023
b605ca7
Expose Xtokens pallet weight (#898)
zjb0807 Mar 28, 2023
0085382
fix unknown-tokens migration (#899)
xlc Mar 28, 2023
19afb58
Upgrade polkadot to v0.9.40 (#902)
devdanco Apr 12, 2023
1e3d3c3
resolve conflicts for 40
devdanco Apr 20, 2023
c386172
fix CI
devdanco May 21, 2023
55d96c8
remove unnecessary workspace word
devdanco May 21, 2023
9284365
update branch ref
devdanco May 25, 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
353 changes: 177 additions & 176 deletions Cargo.dev.toml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ORML is part of the bigger `Open-Web3-Stack` initiative, that is currently under
_In alphabetical order_

- [Acala Network](https://github.com/AcalaNetwork/Acala)
- [Ajuna Network](https://github.com/ajuna-network/Ajuna)
- [Astar Network](https://github.com/AstarNetwork)
- [Bifrost Finance](https://github.com/bifrost-finance/bifrost)
- [Bit.Country](https://github.com/bit-country/Bit-Country-Blockchain)
Expand All @@ -102,8 +103,11 @@ _In alphabetical order_
- [Libra](https://github.com/atscaletech/libra)
- [Listen](https://github.com/listenofficial)
- [Manta Network](https://github.com/Manta-Network)
- [Mangata Finance](https://github.com/mangata-finance)
- [Minterest](https://github.com/minterest-finance/minterest-chain-node)
- [Moonbeam](https://github.com/PureStake/moonbeam/)
- [OAK](https://github.com/OAK-Foundation/OAK-blockchain)
- [Parallel Finance](https://github.com/parallel-finance/)
- [PolkaFoundry Network](https://github.com/PolkaFoundry)
- [Setheum Network](https://github.com/Setheum-Labs/Setheum)
- [Valiu Liquidity Network](https://github.com/valibre-org/vln-node)
Expand Down
40 changes: 20 additions & 20 deletions asset-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,42 @@ serde = { version = "1.0.136", optional = true }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["max-encoded-len"] }

# substrate
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.40" }
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.40" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.40" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.40" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", default-features = false , optional = true }

# polkadot
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.36" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.36" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.36" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.36" }
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.40" }
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.40" }
xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.40" }
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false , branch = "release-v0.9.40" }

# orml
orml-traits = { path = "../traits", version = "0.4.1-dev", default-features = false }

# mangata
mangata-types = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" }
mangata-types = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev-v0.9.40" }


[dev-dependencies]
# substrate
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.36" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.40" }
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false , branch = "polkadot-v0.9.40" }

# cumulus
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.36" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.36" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.36" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.36" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.36" }
cumulus-primitives-core = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" }
cumulus-pallet-dmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" }
cumulus-pallet-xcmp-queue = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" }
cumulus-pallet-xcm = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" }
parachain-info = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.40" }

# polkadot
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.36" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.36" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.36" }
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" }
xcm-simulator = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.40" }

# orml
orml-tokens = { path = "../tokens" }
Expand Down
23 changes: 9 additions & 14 deletions asset-registry/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
use crate::module::*;
use frame_support::{log, pallet_prelude::*, weights::constants::{WEIGHT_REF_TIME_PER_SECOND}};
use frame_support::{log, pallet_prelude::*, weights::constants::WEIGHT_REF_TIME_PER_SECOND};
use orml_traits::{
asset_registry::{AssetMetadata, FixedConversionRateProvider, Inspect, Mutate, WeightToFeeConverter},
GetByKey,
};
use sp_runtime::FixedPointNumber;
use sp_runtime::{traits::Bounded, FixedU128};
use sp_std::prelude::*;
use xcm::latest::{prelude::*, Weight as XcmWeight};
use xcm::v3::{prelude::*, Weight as XcmWeight};
use xcm::VersionedMultiLocation;
use xcm_builder::TakeRevenue;
use xcm_executor::{traits::WeightTrader, Assets};

use crate::module::*;

/*
/// Alias for AssetMetadata to improve readability (and to placate clippy)
pub type DefaultAssetMetadata<T> = AssetMetadata<<T as Config>::Balance, <T as Config>::CustomMetadata>;
Expand Down Expand Up @@ -103,26 +100,24 @@ impl<W: WeightToFeeConverter, R: TakeRevenue> WeightTrader for AssetRegistryTrad
continue;
}

if let Some(fee_increase) = W::convert_weight_to_fee(location, Weight::from_ref_time(weight)) {
if let Some(fee_increase) = W::convert_weight_to_fee(location, weight) {
if fee_increase == 0 {
// if the fee is set very low it could lead to zero fees, in which case
// constructing the fee asset item to subtract from payment would fail.
// Therefore, provide early exit
return Ok(payment);
}

if let Ok(unused) = payment.clone().checked_sub((asset.clone(), fee_increase).into()) {
if let Ok(unused) = payment.clone().checked_sub((*asset, fee_increase).into()) {
let (existing_weight, existing_fee) = match self.bought_weight {
Some(ref x) => (x.weight, x.amount),
None => (Weight::zero(), 0),
};

self.bought_weight = Some(BoughtWeight {
amount: existing_fee.checked_add(fee_increase).ok_or(XcmError::Overflow)?,
weight: existing_weight
.checked_add(&Weight::from_ref_time(weight))
.ok_or(XcmError::Overflow)?,
asset_location: location.clone(),
weight: existing_weight.checked_add(&weight).ok_or(XcmError::Overflow)?,
asset_location: *location,
});
return Ok(unused);
}
Expand All @@ -137,14 +132,14 @@ impl<W: WeightToFeeConverter, R: TakeRevenue> WeightTrader for AssetRegistryTrad

match self.bought_weight {
Some(ref mut bought) => {
let new_weight = bought.weight.saturating_sub(Weight::from_ref_time(weight));
let new_weight = bought.weight.saturating_sub(weight);
let new_amount = W::convert_weight_to_fee(&bought.asset_location, new_weight)?;
let refunded_amount = bought.amount.saturating_sub(new_amount);

bought.weight = new_weight;
bought.amount = new_amount;

Some((AssetId::Concrete(bought.asset_location.clone()), refunded_amount).into())
Some((AssetId::Concrete(bought.asset_location), refunded_amount).into())
}
None => None, // nothing to refund
}
Expand All @@ -154,7 +149,7 @@ impl<W: WeightToFeeConverter, R: TakeRevenue> WeightTrader for AssetRegistryTrad
impl<W: WeightToFeeConverter, R: TakeRevenue> Drop for AssetRegistryTrader<W, R> {
fn drop(&mut self) {
if let Some(ref bought) = self.bought_weight {
R::take_revenue((AssetId::Concrete(bought.asset_location.clone()), bought.amount).into());
R::take_revenue((AssetId::Concrete(bought.asset_location), bought.amount).into());
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use sp_runtime::{
DispatchResult,
};
use sp_std::prelude::*;
use xcm::{v2::prelude::*, VersionedMultiLocation};
use xcm::{v3::prelude::*, VersionedMultiLocation};

pub use impls::*;
pub use module::*;
Expand All @@ -29,6 +29,9 @@ mod mock;
#[cfg(test)]
mod tests;

mod migrations;
pub use migrations::Migration;

#[frame_support::pallet]
pub mod module {
use super::*;
Expand Down Expand Up @@ -121,8 +124,10 @@ pub mod module {
}
}

const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);

#[pallet::pallet]
#[pallet::generate_store(pub (super) trait Store)]
#[pallet::storage_version(STORAGE_VERSION)]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);

Expand Down
44 changes: 44 additions & 0 deletions asset-registry/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use crate::{Config, LocationToAssetId, Pallet, Weight};
use frame_support::pallet_prelude::*;
use frame_support::{migration::storage_key_iter, traits::OnRuntimeUpgrade, StoragePrefixedMap};

use xcm::v3::prelude::*;

pub struct Migration<T>(PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for Migration<T> {
fn on_runtime_upgrade() -> Weight {
let mut weight: Weight = Weight::zero();
let onchain_version = Pallet::<T>::on_chain_storage_version();
if onchain_version < 2 {
let inner_weight = v2::migrate::<T>();
weight.saturating_accrue(inner_weight);
}
weight
}
}

mod v2 {
use super::*;

pub(crate) fn migrate<T: Config>() -> Weight {
let mut weight: Weight = Weight::zero();
let module_prefix = LocationToAssetId::<T>::module_prefix();
let storage_prefix = LocationToAssetId::<T>::storage_prefix();

weight.saturating_accrue(T::DbWeight::get().reads(1));
let old_data =
storage_key_iter::<xcm::v2::MultiLocation, T::AssetId, Twox64Concat>(module_prefix, storage_prefix)
.drain()
.collect::<sp_std::vec::Vec<_>>();

for (old_key, value) in old_data {
weight.saturating_accrue(T::DbWeight::get().writes(1));
let new_key: MultiLocation = old_key.try_into().expect("Stored xcm::v2::MultiLocation");
LocationToAssetId::<T>::insert(new_key, value);
}

StorageVersion::new(2).put::<Pallet<T>>();
weight.saturating_accrue(T::DbWeight::get().writes(1));
weight
}
}
6 changes: 5 additions & 1 deletion asset-registry/src/mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
use super::*;

use mock::para::AssetRegistry;
use scale_info::TypeInfo;
use serde::{Deserialize, Serialize};
use sp_core::bounded::BoundedVec;
use sp_io::TestExternalities;
use sp_runtime::{traits::Convert, AccountId32};
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain};
Expand Down Expand Up @@ -35,6 +38,7 @@ impl Convert<MultiLocation, Option<CurrencyId>> for CurrencyIdConvert {
return Some(asset_id);
}
None

}
}
impl Convert<MultiAsset, Option<CurrencyId>> for CurrencyIdConvert {
Expand Down Expand Up @@ -159,7 +163,7 @@ pub fn para_ext(para_id: u32, asset_data: Option<(Vec<(u32, Vec<u8>)>, u32)>) ->
.unwrap();

if let Some((assets, _)) = asset_data {
GenesisConfig::<Runtime> { assets: assets }
GenesisConfig::<Runtime> { assets }
.assimilate_storage(&mut t)
.unwrap();
}
Expand Down
Loading