Skip to content

Commit

Permalink
Bifrost v0.15.1 (#1514)
Browse files Browse the repository at this point in the history
* refactor: 💡 update MaximumUnlockIdOfTimeUnit

* refactor: 💡 cli

* Fix slp transfer back (#1518)

* Fix slp transfer_back

* Vtoken minting redeem_amount must be greater than entrance_account_balance

---------

Co-authored-by: NingBo Wang <[email protected]>
  • Loading branch information
yooml and hqwangningbo authored Dec 2, 2024
1 parent a9098fb commit 43d4d1c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bifrost-cli"
version = "0.15.0"
version = "0.15.1"
authors = ["Liebi Technologies <[email protected]>"]
description = "Bifrost Parachain Node"
build = "build.rs"
Expand Down
43 changes: 29 additions & 14 deletions pallets/slp/src/agents/parachain_staking_agent/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use super::types::{
MoonbeamCall, MoonbeamCurrencyId, MoonbeamParachainStakingCall, MoonbeamXtokensCall,
};
use super::types::{MoonbeamCall, MoonbeamParachainStakingCall, PolkadotXcmCall};
use crate::{
agents::{MantaCall, MantaCurrencyId, MantaParachainStakingCall, MantaXtokensCall},
pallet::{Error, Event},
Expand Down Expand Up @@ -48,11 +46,13 @@ use sp_runtime::{
};
use sp_std::prelude::*;
use xcm::{
latest::{AssetId, Assets},
opaque::v3::{
Junction::{AccountId32, Parachain},
MultiLocation,
},
v3::prelude::*,
v4::Asset,
VersionedLocation,
};

Expand Down Expand Up @@ -1370,6 +1370,8 @@ impl<T: Config>

// Make sure the receiving account is the Exit_account from vtoken-minting module.
let (entrance_account, _) = T::VtokenMinting::get_entrance_and_exit_accounts();
let entrance_account_id =
entrance_account.encode().try_into().map_err(|_| Error::<T>::FailToConvert)?;

if currency_id == BNC {
let from_account = Pallet::<T>::multilocation_to_account(from)?;
Expand All @@ -1381,22 +1383,35 @@ impl<T: Config>
parents: 1,
interior: X2(
Parachain(T::ParachainId::get().into()),
AccountId32 {
network: None,
id: entrance_account
.encode()
.try_into()
.map_err(|_| Error::<T>::FailToConvert)?,
},
AccountId32 { network: None, id: entrance_account_id },
),
}));

// Construct xcm message.
let call: Vec<u8> = match currency_id {
MOVR | GLMR => MoonbeamCall::Xtokens(MoonbeamXtokensCall::<T>::Transfer(
MoonbeamCurrencyId::SelfReserve,
amount.unique_saturated_into(),
dest,
MOVR | GLMR => MoonbeamCall::<T>::PolkadotXcm(PolkadotXcmCall::TransferAssets(
Box::new(
Location::new(1, X1(Parachain(T::ParachainId::get().into())))
.into_versioned(),
),
Box::new(
Location::new(
0,
X1(AccountId32 { network: None, id: entrance_account_id }),
)
.into_versioned(),
),
Box::new(
Assets::from(vec![Asset {
id: AssetId(xcm::v4::Location::new(
0,
xcm::v4::prelude::PalletInstance(10),
)),
fun: xcm::v4::Fungibility::Fungible(amount.unique_saturated_into()),
}])
.into(),
),
0,
Unlimited,
))
.encode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@

use crate::{BalanceOf, Config};
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_arithmetic::Percent;
use sp_core::H160;
use sp_runtime::{
traits::{IdentityLookup, StaticLookup},
RuntimeDebug,
};
use sp_std::{boxed::Box, vec::Vec};
use xcm::{opaque::v3::WeightLimit, VersionedLocation};
use xcm::{opaque::v3::WeightLimit, VersionedAssets, VersionedLocation};

#[derive(Encode, Decode, RuntimeDebug, Clone)]
pub enum MoonbeamCall<T: Config> {
Expand All @@ -36,8 +35,8 @@ pub enum MoonbeamCall<T: Config> {
Staking(MoonbeamParachainStakingCall<T>),
#[codec(index = 30)]
Utility(Box<MoonbeamUtilityCall<Self>>),
#[codec(index = 106)]
Xtokens(MoonbeamXtokensCall<T>),
#[codec(index = 103)]
PolkadotXcm(PolkadotXcmCall),
}

impl<T: Config> MoonbeamCall<T> {
Expand Down Expand Up @@ -89,17 +88,13 @@ pub enum MoonbeamParachainStakingCall<T: Config> {
}

#[derive(Encode, Decode, RuntimeDebug, Clone)]
pub enum MoonbeamXtokensCall<T: Config> {
#[codec(index = 0)]
Transfer(MoonbeamCurrencyId, BalanceOf<T>, Box<VersionedLocation>, WeightLimit),
}

#[derive(PartialEq, Eq, Copy, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub enum MoonbeamCurrencyId {
// Our native token
SelfReserve,
// Assets representing other chains native tokens
ForeignAsset(u128),
// Our local assets
LocalAssetReserve(u128),
pub enum PolkadotXcmCall {
#[codec(index = 11)]
TransferAssets(
Box<VersionedLocation>,
Box<VersionedLocation>,
Box<VersionedAssets>,
u32,
WeightLimit,
),
}
2 changes: 1 addition & 1 deletion pallets/vtoken-minting/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ impl<T: Config> Pallet<T> {
&redeemer,
redeem_currency_amount,
)?;
return Ok((redeem_currency_amount, RedeemTo::Native(redeemer)));
}
return Ok((redeem_currency_amount, RedeemTo::Native(redeemer)));
}
Ok((Default::default(), RedeemTo::Native(redeemer)))
}
Expand Down
8 changes: 2 additions & 6 deletions runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bifrost"),
impl_name: create_runtime_str!("bifrost"),
authoring_version: 1,
spec_version: 15000,
spec_version: 15001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -1539,7 +1539,7 @@ impl bifrost_vtoken_minting::OnRedeemSuccess<AccountId, CurrencyId, Balance> for

parameter_types! {
pub const MaximumUnlockIdOfUser: u32 = 10;
pub const MaximumUnlockIdOfTimeUnit: u32 = 50;
pub const MaximumUnlockIdOfTimeUnit: u32 = 1000;
pub BifrostFeeAccount: AccountId = TreasuryPalletId::get().into_account_truncating();
}

Expand Down Expand Up @@ -2000,12 +2000,8 @@ pub mod migrations {

/// Unreleased migrations. Add new ones here:
pub type Unreleased = (
bifrost_parachain_staking::migrations::RemoveDelegatorReserveToLockAndCollatorReserveToLock<
Runtime,
>,
// permanent migration, do not remove
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
bifrost_flexible_fee::migrations::v3::MigrateToV3<Runtime>,
);
}

Expand Down
7 changes: 2 additions & 5 deletions runtime/bifrost-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bifrost_polkadot"),
impl_name: create_runtime_str!("bifrost_polkadot"),
authoring_version: 0,
spec_version: 15000,
spec_version: 15001,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down Expand Up @@ -1392,7 +1392,7 @@ impl bifrost_vtoken_minting::OnRedeemSuccess<AccountId, CurrencyId, Balance> for

parameter_types! {
pub const MaximumUnlockIdOfUser: u32 = 10;
pub const MaximumUnlockIdOfTimeUnit: u32 = 50;
pub const MaximumUnlockIdOfTimeUnit: u32 = 1000;
pub BifrostFeeAccount: AccountId = TreasuryPalletId::get().into_account_truncating();
}

Expand Down Expand Up @@ -1902,9 +1902,6 @@ pub mod migrations {
pub type Unreleased = (
// permanent migration, do not remove
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
bifrost_parachain_staking::migrations::InitGenesisMigration<Runtime>,
frame_support::migrations::RemovePallet<CollatorSelectionName, RocksDbWeight>,
bifrost_flexible_fee::migrations::v3::PolkadotMigrateToV3<Runtime>,
);
}

Expand Down

0 comments on commit 43d4d1c

Please sign in to comment.