Skip to content

Commit

Permalink
Bifrost v0.9.92 (#1143)
Browse files Browse the repository at this point in the history
* Bifrost v0.9.92

* feat: 🎸 prod_or_fast (#1144)

* feat: 🎸 prod_or_fast

* fix: 🐛 default-features

* Fix DelegatorVotes removal (#1147)

* Fix DelegatorVotes removal

* Fix

* fix-vtoken-channel-shares-creation (#1150)

* Remove `bifrost_channel_commission` pallet (#1155)

* [skip ci]:artiface with git sha (#1156)

Co-authored-by: TomatoAres <[email protected]>

* Add timeunit revise function (#1157)

* add recreate_currency_ongoing_timeunit function

* fixes

---------

Co-authored-by: yooml <[email protected]>
Co-authored-by: Herry Ho <[email protected]>
Co-authored-by: 战神西红柿 <[email protected]>
Co-authored-by: TomatoAres <[email protected]>
  • Loading branch information
5 people authored Jan 20, 2024
1 parent 79538b1 commit 7b09365
Show file tree
Hide file tree
Showing 19 changed files with 334 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/srtool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- name: Archive Subwasm results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.chain }}-runtime
name: ${{ matrix.chain }}-runtime-${{ github.sha }}
path: |
${{ matrix.chain }}-info.json
${{ matrix.chain }}-info_compressed.json
Expand Down
4 changes: 3 additions & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ kusama-runtime = { package = "staging-kusama-runtime", git = "https
kusama-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
polkadot-runtime-constants = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
polkadot-service = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0" }
Expand Down
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.9.90"
version = "0.9.92"
authors = ["Liebi Technologies <[email protected]>"]
description = "Bifrost Parachain Node"
build = "build.rs"
Expand Down
3 changes: 3 additions & 0 deletions pallets/channel-commission/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ pub mod pallet {
vtoken,
DEFAULT_COMMISSION_RATE,
);

// for each vtoken, add the 0 share to ChannelVtokenShares storage
ChannelVtokenShares::<T>::insert(channel_id, vtoken, Permill::zero());
});

Self::deposit_event(Event::ChannelRegistered {
Expand Down
23 changes: 23 additions & 0 deletions pallets/channel-commission/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ fn set_commission_tokens_should_work() {
#[test]
fn register_channel_should_work() {
ExtBuilder::default().one_hundred_for_alice_n_bob().build().execute_with(|| {
// set commission tokens: VKSM -> KSM
assert_ok!(ChannelCommission::set_commission_tokens(
RuntimeOrigin::signed(ALICE),
VKSM,
KSM,
));

// set commission tokens: VBNC -> BNC
assert_ok!(ChannelCommission::set_commission_tokens(
RuntimeOrigin::signed(ALICE),
VBNC,
BNC,
));

assert_ok!(ChannelCommission::register_channel(
RuntimeOrigin::signed(ALICE),
CHANNEL_A_NAME.to_vec(),
Expand All @@ -83,6 +97,15 @@ fn register_channel_should_work() {

// next channel id has been increased
assert_eq!(ChannelNextId::<Runtime>::get(), 1);

// ChannelCommissionTokenRates have been set for Channel A in both VKSM and VBNC
assert_eq!(ChannelCommissionTokenRates::<Runtime>::get(0, VKSM), DEFAULT_COMMISSION_RATE);
assert_eq!(ChannelCommissionTokenRates::<Runtime>::get(0, VBNC), DEFAULT_COMMISSION_RATE);

// ChannelVtokenShares has been initialized for Channel A in both VKSM and VBNC
assert_eq!(ChannelVtokenShares::<Runtime>::get(0, VKSM), Permill::from_percent(0));

assert_eq!(ChannelVtokenShares::<Runtime>::get(0, VBNC), Permill::from_percent(0));
});
}

Expand Down
21 changes: 21 additions & 0 deletions pallets/vtoken-minting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ pub mod pallet {
FastRedeemFailed {
err: DispatchError,
},
CurrencyTimeUnitRecreated {
token_id: CurrencyIdOf<T>,
time_unit: TimeUnit,
},
}

#[pallet::error]
Expand Down Expand Up @@ -802,6 +806,23 @@ pub mod pallet {
Self::deposit_event(Event::MinTimeUnitSet { token_id, time_unit });
Ok(())
}

#[pallet::call_index(13)]
#[pallet::weight({0})]
pub fn recreate_currency_ongoing_time_unit(
origin: OriginFor<T>,
token_id: CurrencyIdOf<T>,
time_unit: TimeUnit,
) -> DispatchResult {
T::ControlOrigin::ensure_origin(origin)?;

OngoingTimeUnit::<T>::mutate(&token_id, |old_time_unit| {
*old_time_unit = Some(time_unit.clone())
});

Self::deposit_event(Event::CurrencyTimeUnitRecreated { token_id, time_unit });
Ok(())
}
}

impl<T: Config> Pallet<T> {
Expand Down
19 changes: 19 additions & 0 deletions pallets/vtoken-minting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,22 @@ fn fast_redeem_for_fil() {
);
});
}

#[test]
fn recreate_currency_ongoing_time_unit_should_work() {
ExtBuilder::default().one_hundred_for_alice_n_bob().build().execute_with(|| {
env_logger::try_init().unwrap_or(());

// set KSM ongoing time unit to be Era(1)
OngoingTimeUnit::<Runtime>::insert(KSM, TimeUnit::Era(1));
assert_eq!(VtokenMinting::ongoing_time_unit(KSM), Some(TimeUnit::Era(1)));

// recreate_currency_ongoing_time_unit the ongoing time unit of KSM to be Round(2)
assert_ok!(VtokenMinting::recreate_currency_ongoing_time_unit(
RuntimeOrigin::signed(ALICE),
KSM,
TimeUnit::Round(2)
));
assert_eq!(VtokenMinting::ongoing_time_unit(KSM), Some(TimeUnit::Round(2)));
})
}
7 changes: 7 additions & 0 deletions pallets/vtoken-minting/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub trait WeightInfo {
fn rebond() -> Weight;
fn rebond_by_unlock_id() -> Weight;
fn on_initialize() -> Weight;
fn recreate_currency_ongoing_time_unit() -> Weight;
}

// For backwards compatibility and tests
Expand Down Expand Up @@ -278,4 +279,10 @@ impl WeightInfo for () {
Weight::from_parts(15_243_000, 3492)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}

fn recreate_currency_ongoing_time_unit() -> Weight {
Weight::from_parts(70_238_000, 4197)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
}
4 changes: 2 additions & 2 deletions pallets/vtoken-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ pub mod pallet {
if !VoteDelegatorFor::<T>::contains_key((&who, vtoken, poll_index)) {
VoteDelegatorFor::<T>::insert((&who, vtoken, poll_index), derivative_index);
}
let _ = DelegatorVotes::<T>::clear(u32::MAX, None);
DelegatorVotes::<T>::remove(vtoken, poll_index);
DelegatorVotes::<T>::try_mutate(
vtoken,
poll_index,
Expand Down Expand Up @@ -796,7 +796,7 @@ pub mod pallet {
{
let success = Response::DispatchResult(MaybeErrorCode::Success) == response;
if success {
let _ = DelegatorVotes::<T>::clear(u32::MAX, None);
DelegatorVotes::<T>::remove(vtoken, poll_index);
}
PendingRemoveDelegatorVote::<T>::remove(query_id);
Self::deposit_event(Event::<T>::DelegatorVoteRemovedNotified {
Expand Down
19 changes: 17 additions & 2 deletions pallets/vtoken-voting/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,30 @@ impl BlockNumberProvider for RelaychainDataProvider {
}
}

parameter_types! {
pub static VTokenSupply: Balance = u64::MAX.into();
pub static TokenSupply: Balance = u64::MAX.into();
}

pub struct SimpleVTokenSupplyProvider;

impl SimpleVTokenSupplyProvider {
pub fn set_vtoken_supply(supply: Balance) {
VTokenSupply::set(supply);
}

pub fn set_token_supply(supply: Balance) {
TokenSupply::set(supply);
}
}

impl VTokenSupplyProvider<CurrencyId, Balance> for SimpleVTokenSupplyProvider {
fn get_vtoken_supply(_: CurrencyId) -> Option<Balance> {
Some(u64::MAX.into())
Some(VTokenSupply::get())
}

fn get_token_supply(_: CurrencyId) -> Option<Balance> {
Some(u64::MAX.into())
Some(TokenSupply::get())
}
}

Expand Down
Loading

0 comments on commit 7b09365

Please sign in to comment.