Migrate some Pallets to Named Events (#5423)

* auctions

* claims

* registrar

* Update purchase.rs

* crowdloan

* slots

* comma
This commit is contained in:
Shawn Tabrizi
2022-05-13 12:49:19 -04:00
committed by GitHub
parent 511891dcce
commit 432cae1a2b
7 changed files with 169 additions and 123 deletions
+55 -32
View File
@@ -128,25 +128,31 @@ pub mod pallet {
pub enum Event<T: Config> {
/// An auction started. Provides its index and the block number where it will begin to
/// close and the first lease period of the quadruplet that is auctioned.
/// `[auction_index, lease_period, ending]`
AuctionStarted(AuctionIndex, LeasePeriodOf<T>, T::BlockNumber),
/// An auction ended. All funds become unreserved. `[auction_index]`
AuctionClosed(AuctionIndex),
AuctionStarted {
auction_index: AuctionIndex,
lease_period: LeasePeriodOf<T>,
ending: T::BlockNumber,
},
/// An auction ended. All funds become unreserved.
AuctionClosed { auction_index: AuctionIndex },
/// Funds were reserved for a winning bid. First balance is the extra amount reserved.
/// Second is the total. `[bidder, extra_reserved, total_amount]`
Reserved(T::AccountId, BalanceOf<T>, BalanceOf<T>),
/// Second is the total.
Reserved { bidder: T::AccountId, extra_reserved: BalanceOf<T>, total_amount: BalanceOf<T> },
/// Funds were unreserved since bidder is no longer active. `[bidder, amount]`
Unreserved(T::AccountId, BalanceOf<T>),
Unreserved { bidder: T::AccountId, amount: BalanceOf<T> },
/// Someone attempted to lease the same slot twice for a parachain. The amount is held in reserve
/// but no parachain slot has been leased.
/// `[parachain_id, leaser, amount]`
ReserveConfiscated(ParaId, T::AccountId, BalanceOf<T>),
ReserveConfiscated { para_id: ParaId, leaser: T::AccountId, amount: BalanceOf<T> },
/// A new bid has been accepted as the current winner.
/// `[who, para_id, amount, first_slot, last_slot]`
BidAccepted(T::AccountId, ParaId, BalanceOf<T>, LeasePeriodOf<T>, LeasePeriodOf<T>),
BidAccepted {
bidder: T::AccountId,
para_id: ParaId,
amount: BalanceOf<T>,
first_slot: LeasePeriodOf<T>,
last_slot: LeasePeriodOf<T>,
},
/// The winning offset was chosen for an auction. This will map into the `Winning` storage map.
/// `[auction_index, block_number]`
WinningOffset(AuctionIndex, T::BlockNumber),
WinningOffset { auction_index: AuctionIndex, block_number: T::BlockNumber },
}
#[pallet::error]
@@ -397,7 +403,11 @@ impl<T: Config> Pallet<T> {
let ending = frame_system::Pallet::<T>::block_number().saturating_add(duration);
AuctionInfo::<T>::put((lease_period_index, ending));
Self::deposit_event(Event::<T>::AuctionStarted(n, lease_period_index, ending));
Self::deposit_event(Event::<T>::AuctionStarted {
auction_index: n,
lease_period: lease_period_index,
ending,
});
Ok(())
}
@@ -472,11 +482,11 @@ impl<T: Config> Pallet<T> {
// ...and record the amount reserved.
ReservedAmounts::<T>::insert(&bidder_para, reserve_required);
Self::deposit_event(Event::<T>::Reserved(
bidder.clone(),
additional,
reserve_required,
));
Self::deposit_event(Event::<T>::Reserved {
bidder: bidder.clone(),
extra_reserved: additional,
total_amount: reserve_required,
});
}
// Return any funds reserved for the previous winner if we are not in the ending period
@@ -495,16 +505,20 @@ impl<T: Config> Pallet<T> {
// It really should be reserved; there's not much we can do here on fail.
let err_amt = CurrencyOf::<T>::unreserve(&who, amount);
debug_assert!(err_amt.is_zero());
Self::deposit_event(Event::<T>::Unreserved(who, amount));
Self::deposit_event(Event::<T>::Unreserved { bidder: who, amount });
}
}
}
// Update the range winner.
Winning::<T>::insert(offset, &current_winning);
Self::deposit_event(Event::<T>::BidAccepted(
bidder, para, amount, first_slot, last_slot,
));
Self::deposit_event(Event::<T>::BidAccepted {
bidder,
para_id: para,
amount,
first_slot,
last_slot,
});
}
Ok(())
}
@@ -535,7 +549,10 @@ impl<T: Config> Pallet<T> {
T::SampleLength::get().max(One::one());
let auction_counter = AuctionCounter::<T>::get();
Self::deposit_event(Event::<T>::WinningOffset(auction_counter, offset));
Self::deposit_event(Event::<T>::WinningOffset {
auction_index: auction_counter,
block_number: offset,
});
let res = Winning::<T>::get(offset)
.unwrap_or([Self::EMPTY; SlotRange::SLOT_RANGE_COUNT]);
// This `remove_all` statement should remove at most `EndingPeriod` / `SampleLength` items,
@@ -585,14 +602,20 @@ impl<T: Config> Pallet<T> {
// The leaser attempted to get a second lease on the same para ID, possibly griefing us. Let's
// keep the amount reserved and let governance sort it out.
if CurrencyOf::<T>::reserve(&leaser, amount).is_ok() {
Self::deposit_event(Event::<T>::ReserveConfiscated(para, leaser, amount));
Self::deposit_event(Event::<T>::ReserveConfiscated {
para_id: para,
leaser,
amount,
});
}
},
Ok(()) => {}, // Nothing to report.
}
}
Self::deposit_event(Event::<T>::AuctionClosed(AuctionCounter::<T>::get()));
Self::deposit_event(Event::<T>::AuctionClosed {
auction_index: AuctionCounter::<T>::get(),
});
}
/// Calculate the final winners from the winning slots.
@@ -1763,11 +1786,11 @@ mod benchmarking {
let origin = T::InitiateOrigin::successful_origin();
}: _(RawOrigin::Root, duration, lease_period_index)
verify {
assert_last_event::<T>(Event::<T>::AuctionStarted(
AuctionCounter::<T>::get(),
LeasePeriodOf::<T>::max_value(),
T::BlockNumber::max_value(),
).into());
assert_last_event::<T>(Event::<T>::AuctionStarted {
auction_index: AuctionCounter::<T>::get(),
lease_period: LeasePeriodOf::<T>::max_value(),
ending: T::BlockNumber::max_value(),
}.into());
}
// Worst case scenario a new bid comes in which kicks out an existing bid for the same slot.
@@ -1859,7 +1882,7 @@ mod benchmarking {
Auctions::<T>::on_initialize(duration + now + T::EndingPeriod::get());
} verify {
let auction_index = AuctionCounter::<T>::get();
assert_last_event::<T>(Event::<T>::AuctionClosed(auction_index).into());
assert_last_event::<T>(Event::<T>::AuctionClosed { auction_index }.into());
assert!(Winning::<T>::iter().count().is_zero());
}
+7 -3
View File
@@ -183,8 +183,8 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Someone claimed some DOTs. `[who, ethereum_address, amount]`
Claimed(T::AccountId, EthereumAddress, BalanceOf<T>),
/// Someone claimed some DOTs.
Claimed { who: T::AccountId, ethereum_address: EthereumAddress, amount: BalanceOf<T> },
}
#[pallet::error]
@@ -581,7 +581,11 @@ impl<T: Config> Pallet<T> {
Signing::<T>::remove(&signer);
// Let's deposit an event to let the outside world know this happened.
Self::deposit_event(Event::<T>::Claimed(dest, signer, balance_due));
Self::deposit_event(Event::<T>::Claimed {
who: dest,
ethereum_address: signer,
amount: balance_due,
});
Ok(())
}
+41 -38
View File
@@ -254,27 +254,27 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Create a new crowdloaning campaign. `[fund_index]`
Created(ParaId),
/// Contributed to a crowd sale. `[who, fund_index, amount]`
Contributed(T::AccountId, ParaId, BalanceOf<T>),
/// Withdrew full balance of a contributor. `[who, fund_index, amount]`
Withdrew(T::AccountId, ParaId, BalanceOf<T>),
/// Create a new crowdloaning campaign.
Created { para_id: ParaId },
/// Contributed to a crowd sale.
Contributed { who: T::AccountId, fund_index: ParaId, amount: BalanceOf<T> },
/// Withdrew full balance of a contributor.
Withdrew { who: T::AccountId, fund_index: ParaId, amount: BalanceOf<T> },
/// The loans in a fund have been partially dissolved, i.e. there are some left
/// over child keys that still need to be killed. `[fund_index]`
PartiallyRefunded(ParaId),
/// All loans in a fund have been refunded. `[fund_index]`
AllRefunded(ParaId),
/// Fund is dissolved. `[fund_index]`
Dissolved(ParaId),
/// over child keys that still need to be killed.
PartiallyRefunded { para_id: ParaId },
/// All loans in a fund have been refunded.
AllRefunded { para_id: ParaId },
/// Fund is dissolved.
Dissolved { para_id: ParaId },
/// The result of trying to submit a new bid to the Slots pallet.
HandleBidResult(ParaId, DispatchResult),
/// The configuration to a crowdloan has been edited. `[fund_index]`
Edited(ParaId),
/// A memo has been updated. `[who, fund_index, memo]`
MemoUpdated(T::AccountId, ParaId, Vec<u8>),
HandleBidResult { para_id: ParaId, result: DispatchResult },
/// The configuration to a crowdloan has been edited.
Edited { para_id: ParaId },
/// A memo has been updated.
MemoUpdated { who: T::AccountId, para_id: ParaId, memo: Vec<u8> },
/// A parachain has been moved to `NewRaise`
AddedToNewRaise(ParaId),
AddedToNewRaise { para_id: ParaId },
}
#[pallet::error]
@@ -351,7 +351,7 @@ pub mod pallet {
fund.raised,
);
Self::deposit_event(Event::<T>::HandleBidResult(para_id, result));
Self::deposit_event(Event::<T>::HandleBidResult { para_id, result });
}
T::WeightInfo::on_initialize(new_raise_len)
} else {
@@ -437,7 +437,7 @@ pub mod pallet {
// Add a lock to the para so that the configuration cannot be changed.
T::Registrar::apply_lock(index);
Self::deposit_event(Event::<T>::Created(index));
Self::deposit_event(Event::<T>::Created { para_id: index });
Ok(())
}
@@ -494,7 +494,7 @@ pub mod pallet {
Funds::<T>::insert(index, &fund);
Self::deposit_event(Event::<T>::Withdrew(who, index, balance));
Self::deposit_event(Event::<T>::Withdrew { who, fund_index: index, amount: balance });
Ok(())
}
@@ -536,11 +536,11 @@ pub mod pallet {
Funds::<T>::insert(index, &fund);
if all_refunded {
Self::deposit_event(Event::<T>::AllRefunded(index));
Self::deposit_event(Event::<T>::AllRefunded { para_id: index });
// Refund for unused refund count.
Ok(Some(T::WeightInfo::refund(refund_count)).into())
} else {
Self::deposit_event(Event::<T>::PartiallyRefunded(index));
Self::deposit_event(Event::<T>::PartiallyRefunded { para_id: index });
// No weight to refund since we did not finish the loop.
Ok(().into())
}
@@ -567,7 +567,7 @@ pub mod pallet {
CurrencyOf::<T>::unreserve(&fund.depositor, fund.deposit);
Funds::<T>::remove(index);
Self::deposit_event(Event::<T>::Dissolved(index));
Self::deposit_event(Event::<T>::Dissolved { para_id: index });
Ok(())
}
@@ -604,7 +604,7 @@ pub mod pallet {
},
);
Self::deposit_event(Event::<T>::Edited(index));
Self::deposit_event(Event::<T>::Edited { para_id: index });
Ok(())
}
@@ -622,7 +622,7 @@ pub mod pallet {
ensure!(balance > Zero::zero(), Error::<T>::NoContributions);
Self::contribution_put(fund.fund_index, &who, &balance, &memo);
Self::deposit_event(Event::<T>::MemoUpdated(who, index, memo));
Self::deposit_event(Event::<T>::MemoUpdated { who, para_id: index, memo });
Ok(())
}
@@ -636,7 +636,7 @@ pub mod pallet {
ensure!(!fund.raised.is_zero(), Error::<T>::NoContributions);
ensure!(!NewRaise::<T>::get().contains(&index), Error::<T>::AlreadyInNewRaise);
NewRaise::<T>::append(index);
Self::deposit_event(Event::<T>::AddedToNewRaise(index));
Self::deposit_event(Event::<T>::AddedToNewRaise { para_id: index });
Ok(())
}
@@ -810,7 +810,7 @@ impl<T: Config> Pallet<T> {
Funds::<T>::insert(index, &fund);
Self::deposit_event(Event::<T>::Contributed(who, index, value));
Self::deposit_event(Event::<T>::Contributed { who, fund_index: index, amount: value });
Ok(())
}
}
@@ -1648,14 +1648,17 @@ mod tests {
// Move to the end of the crowdloan
run_to_block(10);
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
assert_eq!(last_event(), super::Event::<Test>::PartiallyRefunded(para).into());
assert_eq!(
last_event(),
super::Event::<Test>::PartiallyRefunded { para_id: para }.into()
);
// Funds still left over
assert!(!Balances::free_balance(account_id).is_zero());
// Call again
assert_ok!(Crowdloan::refund(Origin::signed(1337), para));
assert_eq!(last_event(), super::Event::<Test>::AllRefunded(para).into());
assert_eq!(last_event(), super::Event::<Test>::AllRefunded { para_id: para }.into());
// Funds are returned
assert_eq!(Balances::free_balance(account_id), 0);
@@ -1983,7 +1986,7 @@ mod benchmarking {
}: _(RawOrigin::Signed(caller), para_id, cap, first_period, last_period, end, Some(verifier))
verify {
assert_last_event::<T>(Event::<T>::Created(para_id).into())
assert_last_event::<T>(Event::<T>::Created { para_id }.into())
}
// Contribute has two arms: PreEnding and Ending, but both are equal complexity.
@@ -2004,7 +2007,7 @@ mod benchmarking {
verify {
// NewRaise is appended to, so we don't need to fill it up for worst case scenario.
assert!(!NewRaise::<T>::get().is_empty());
assert_last_event::<T>(Event::<T>::Contributed(caller, fund_index, contribution).into());
assert_last_event::<T>(Event::<T>::Contributed { who: caller, fund_index, amount: contribution }.into());
}
withdraw {
@@ -2017,7 +2020,7 @@ mod benchmarking {
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
}: _(RawOrigin::Signed(caller), contributor.clone(), fund_index)
verify {
assert_last_event::<T>(Event::<T>::Withdrew(contributor, fund_index, T::MinContribution::get()).into());
assert_last_event::<T>(Event::<T>::Withdrew { who: contributor, fund_index, amount: T::MinContribution::get() }.into());
}
// Worst case: Refund removes `RemoveKeysLimit` keys, and is fully refunded.
@@ -2037,7 +2040,7 @@ mod benchmarking {
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
}: _(RawOrigin::Signed(caller), fund_index)
verify {
assert_last_event::<T>(Event::<T>::AllRefunded(fund_index).into());
assert_last_event::<T>(Event::<T>::AllRefunded { para_id: fund_index }.into());
}
dissolve {
@@ -2048,7 +2051,7 @@ mod benchmarking {
frame_system::Pallet::<T>::set_block_number(T::BlockNumber::max_value());
}: _(RawOrigin::Signed(caller.clone()), fund_index)
verify {
assert_last_event::<T>(Event::<T>::Dissolved(fund_index).into());
assert_last_event::<T>(Event::<T>::Dissolved { para_id: fund_index }.into());
}
edit {
@@ -2077,7 +2080,7 @@ mod benchmarking {
// Doesn't matter what we edit to, so use the same values.
}: _(RawOrigin::Root, para_id, cap, first_period, last_period, end, Some(verifier))
verify {
assert_last_event::<T>(Event::<T>::Edited(para_id).into())
assert_last_event::<T>(Event::<T>::Edited { para_id }.into())
}
add_memo {
@@ -2107,7 +2110,7 @@ mod benchmarking {
}: _(RawOrigin::Signed(caller), fund_index)
verify {
assert!(!NewRaise::<T>::get().is_empty());
assert_last_event::<T>(Event::<T>::AddedToNewRaise(fund_index).into())
assert_last_event::<T>(Event::<T>::AddedToNewRaise { para_id: fund_index }.into())
}
// Worst case scenario: N funds are all in the `NewRaise` list, we are
@@ -2146,7 +2149,7 @@ mod benchmarking {
Crowdloan::<T>::on_initialize(end_block);
} verify {
assert_eq!(EndingsCount::<T>::get(), old_endings_count + 1);
assert_last_event::<T>(Event::<T>::HandleBidResult((n - 1).into(), Ok(())).into());
assert_last_event::<T>(Event::<T>::HandleBidResult { para_id: (n - 1).into(), result: Ok(()) }.into());
}
impl_benchmark_test_suite!(
@@ -432,10 +432,17 @@ fn basic_end_to_end_works() {
// Auction ends at block 110 + offset
run_to_block(109 + offset);
assert!(contains_event(
crowdloan::Event::<Test>::HandleBidResult(ParaId::from(para_2), Ok(())).into()
crowdloan::Event::<Test>::HandleBidResult {
para_id: ParaId::from(para_2),
result: Ok(())
}
.into()
));
run_to_block(110 + offset);
assert_eq!(last_event(), auctions::Event::<Test>::AuctionClosed(1).into());
assert_eq!(
last_event(),
auctions::Event::<Test>::AuctionClosed { auction_index: 1 }.into()
);
// Paras should have won slots
assert_eq!(
+10 -10
View File
@@ -127,9 +127,9 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
Registered(ParaId, T::AccountId),
Deregistered(ParaId),
Reserved(ParaId, T::AccountId),
Registered { para_id: ParaId, manager: T::AccountId },
Deregistered { para_id: ParaId },
Reserved { para_id: ParaId, who: T::AccountId },
}
#[pallet::error]
@@ -492,7 +492,7 @@ impl<T: Config> Pallet<T> {
let info = ParaInfo { manager: who.clone(), deposit, locked: false };
Paras::<T>::insert(id, info);
Self::deposit_event(Event::<T>::Reserved(id, who));
Self::deposit_event(Event::<T>::Reserved { para_id: id, who });
Ok(())
}
@@ -530,7 +530,7 @@ impl<T: Config> Pallet<T> {
// We check above that para has no lifecycle, so this should not fail.
let res = runtime_parachains::schedule_para_initialize::<T>(id, genesis);
debug_assert!(res.is_ok());
Self::deposit_event(Event::<T>::Registered(id, who));
Self::deposit_event(Event::<T>::Registered { para_id: id, manager: who });
Ok(())
}
@@ -549,7 +549,7 @@ impl<T: Config> Pallet<T> {
}
PendingSwap::<T>::remove(id);
Self::deposit_event(Event::<T>::Deregistered(id));
Self::deposit_event(Event::<T>::Deregistered { para_id: id });
Ok(())
}
@@ -1268,7 +1268,7 @@ mod benchmarking {
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
}: _(RawOrigin::Signed(caller.clone()))
verify {
assert_last_event::<T>(Event::<T>::Reserved(LOWEST_PUBLIC_ID, caller).into());
assert_last_event::<T>(Event::<T>::Reserved { para_id: LOWEST_PUBLIC_ID, who: caller }.into());
assert!(Paras::<T>::get(LOWEST_PUBLIC_ID).is_some());
assert_eq!(paras::Pallet::<T>::lifecycle(LOWEST_PUBLIC_ID), None);
}
@@ -1282,7 +1282,7 @@ mod benchmarking {
assert_ok!(Registrar::<T>::reserve(RawOrigin::Signed(caller.clone()).into()));
}: _(RawOrigin::Signed(caller.clone()), para, genesis_head, validation_code)
verify {
assert_last_event::<T>(Event::<T>::Registered(para, caller).into());
assert_last_event::<T>(Event::<T>::Registered{ para_id: para, manager: caller }.into());
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
@@ -1296,7 +1296,7 @@ mod benchmarking {
let validation_code = Registrar::<T>::worst_validation_code();
}: _(RawOrigin::Root, manager.clone(), deposit, para, genesis_head, validation_code)
verify {
assert_last_event::<T>(Event::<T>::Registered(para, manager).into());
assert_last_event::<T>(Event::<T>::Registered { para_id: para, manager }.into());
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
@@ -1308,7 +1308,7 @@ mod benchmarking {
let caller: T::AccountId = whitelisted_caller();
}: _(RawOrigin::Signed(caller), para)
verify {
assert_last_event::<T>(Event::<T>::Deregistered(para).into());
assert_last_event::<T>(Event::<T>::Deregistered { para_id: para }.into());
}
swap {
+24 -20
View File
@@ -133,19 +133,19 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A [new] account was created.
AccountCreated(T::AccountId),
/// Someone's account validity was updated. [who, validity]
ValidityUpdated(T::AccountId, AccountValidity),
/// Someone's purchase balance was updated. [who, free, locked]
BalanceUpdated(T::AccountId, BalanceOf<T>, BalanceOf<T>),
/// A payout was made to a purchaser. [who, free, locked]
PaymentComplete(T::AccountId, BalanceOf<T>, BalanceOf<T>),
/// A new payment account was set. [who]
PaymentAccountSet(T::AccountId),
AccountCreated { who: T::AccountId },
/// Someone's account validity was updated.
ValidityUpdated { who: T::AccountId, validity: AccountValidity },
/// Someone's purchase balance was updated.
BalanceUpdated { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
/// A payout was made to a purchaser.
PaymentComplete { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
/// A new payment account was set.
PaymentAccountSet { who: T::AccountId },
/// A new statement was set.
StatementUpdated,
/// A new statement was set. `[block_number]`
UnlockBlockUpdated(T::BlockNumber),
UnlockBlockUpdated { block_number: T::BlockNumber },
}
#[pallet::error]
@@ -222,7 +222,7 @@ pub mod pallet {
vat: Permill::zero(),
};
Accounts::<T>::insert(&who, status);
Self::deposit_event(Event::<T>::AccountCreated(who));
Self::deposit_event(Event::<T>::AccountCreated { who });
Ok(())
}
@@ -251,7 +251,7 @@ pub mod pallet {
Ok(())
},
)?;
Self::deposit_event(Event::<T>::ValidityUpdated(who, validity));
Self::deposit_event(Event::<T>::ValidityUpdated { who, validity });
Ok(())
}
@@ -283,7 +283,11 @@ pub mod pallet {
Ok(())
},
)?;
Self::deposit_event(Event::<T>::BalanceUpdated(who, free_balance, locked_balance));
Self::deposit_event(Event::<T>::BalanceUpdated {
who,
free: free_balance,
locked: locked_balance,
});
Ok(())
}
@@ -346,11 +350,11 @@ pub mod pallet {
// Setting the user account to `Completed` ends the purchase process for this user.
status.validity = AccountValidity::Completed;
Self::deposit_event(Event::<T>::PaymentComplete(
who.clone(),
status.free_balance,
status.locked_balance,
));
Self::deposit_event(Event::<T>::PaymentComplete {
who: who.clone(),
free: status.free_balance,
locked: status.locked_balance,
});
Ok(())
},
)?;
@@ -367,7 +371,7 @@ pub mod pallet {
T::ConfigurationOrigin::ensure_origin(origin)?;
// Possibly this is worse than having the caller account be the payment account?
PaymentAccount::<T>::put(who.clone());
Self::deposit_event(Event::<T>::PaymentAccountSet(who));
Self::deposit_event(Event::<T>::PaymentAccountSet { who });
Ok(())
}
@@ -402,7 +406,7 @@ pub mod pallet {
);
// Possibly this is worse than having the caller account be the payment account?
UnlockBlock::<T>::set(unlock_block);
Self::deposit_event(Event::<T>::UnlockBlockUpdated(unlock_block));
Self::deposit_event(Event::<T>::UnlockBlockUpdated { block_number: unlock_block });
Ok(())
}
}
+23 -18
View File
@@ -122,19 +122,18 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new `[lease_period]` is beginning.
NewLeasePeriod(LeasePeriodOf<T>),
NewLeasePeriod { lease_period: LeasePeriodOf<T> },
/// A para has won the right to a continuous set of lease periods as a parachain.
/// First balance is any extra amount reserved on top of the para's existing deposit.
/// Second balance is the total amount reserved.
/// `[parachain_id, leaser, period_begin, period_count, extra_reserved, total_amount]`
Leased(
ParaId,
T::AccountId,
LeasePeriodOf<T>,
LeasePeriodOf<T>,
BalanceOf<T>,
BalanceOf<T>,
),
Leased {
para_id: ParaId,
leaser: T::AccountId,
period_begin: LeasePeriodOf<T>,
period_count: LeasePeriodOf<T>,
extra_reserved: BalanceOf<T>,
total_amount: BalanceOf<T>,
},
}
#[pallet::error]
@@ -228,7 +227,7 @@ impl<T: Config> Pallet<T> {
/// We need to on-board and off-board parachains as needed. We should also handle reducing/
/// returning deposits.
fn manage_lease_period_start(lease_period_index: LeasePeriodOf<T>) -> Weight {
Self::deposit_event(Event::<T>::NewLeasePeriod(lease_period_index));
Self::deposit_event(Event::<T>::NewLeasePeriod { lease_period: lease_period_index });
let old_parachains = T::Registrar::parachains();
@@ -408,14 +407,14 @@ impl<T: Config> Leaser<T::BlockNumber> for Pallet<T> {
let _ = T::Registrar::make_parachain(para);
}
Self::deposit_event(Event::<T>::Leased(
para,
leaser.clone(),
Self::deposit_event(Event::<T>::Leased {
para_id: para,
leaser: leaser.clone(),
period_begin,
period_count,
reserved,
amount,
));
extra_reserved: reserved,
total_amount: amount,
});
Ok(())
})
@@ -1027,7 +1026,13 @@ mod benchmarking {
let period_count = 3u32.into();
}: _(RawOrigin::Root, para, leaser.clone(), amount, period_begin, period_count)
verify {
assert_last_event::<T>(Event::<T>::Leased(para, leaser, period_begin, period_count, amount, amount).into());
assert_last_event::<T>(Event::<T>::Leased {
para_id: para,
leaser, period_begin,
period_count,
extra_reserved: amount,
total_amount: amount,
}.into());
}
// Worst case scenario, T parathreads onboard, and C parachains offboard.