Use same fmt and clippy configs as in Substrate (#7611)

* Use same rustfmt.toml as Substrate

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* format format file

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Format with new config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Add Substrate Clippy config

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Print Clippy version in CI

Otherwise its difficult to reproduce locally.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Make fmt happy

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update node/core/pvf/src/error.rs

Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>

* Update node/core/pvf/src/error.rs

Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Tsvetomir Dimitrov <tsvetomir@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2023-08-14 16:29:29 +02:00
committed by GitHub
parent ac435c96cf
commit 342d720573
203 changed files with 1880 additions and 1504 deletions
+18 -15
View File
@@ -14,12 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Parathread and parachains leasing system. Allows para IDs to be claimed, the code and data to be initialized and
//! parachain slots (i.e. continuous scheduling) to be leased. Also allows for parachains and parathreads to be
//! swapped.
//! Parathread and parachains leasing system. Allows para IDs to be claimed, the code and data to be
//! initialized and parachain slots (i.e. continuous scheduling) to be leased. Also allows for
//! parachains and parathreads to be swapped.
//!
//! This doesn't handle the mechanics of determining which para ID actually ends up with a parachain lease. This
//! must handled by a separately, through the trait interface that this pallet provides or the root dispatchables.
//! This doesn't handle the mechanics of determining which para ID actually ends up with a parachain
//! lease. This must handled by a separately, through the trait interface that this pallet provides
//! or the root dispatchables.
pub mod migration;
@@ -98,8 +99,8 @@ pub mod pallet {
/// Amounts held on deposit for each (possibly future) leased parachain.
///
/// The actual amount locked on its behalf by any account at any time is the maximum of the second values
/// of the items in this list whose first value is the account.
/// The actual amount locked on its behalf by any account at any time is the maximum of the
/// second values of the items in this list whose first value is the account.
///
/// The first item in the list is the amount locked for the current Lease Period. Following
/// items are for the subsequent lease periods.
@@ -160,8 +161,8 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Just a connect into the `lease_out` call, in case Root wants to force some lease to happen
/// independently of any other on-chain mechanism to use it.
/// Just a connect into the `lease_out` call, in case Root wants to force some lease to
/// happen independently of any other on-chain mechanism to use it.
///
/// The dispatch origin for this call must match `T::ForceOrigin`.
#[pallet::call_index(0)]
@@ -268,8 +269,8 @@ impl<T: Config> Pallet<T> {
// deposit for the parachain.
let now_held = Self::deposit_held(para, &ended_lease.0);
// If this is less than what we were holding for this leaser's now-ended lease, then
// unreserve it.
// If this is less than what we were holding for this leaser's now-ended lease,
// then unreserve it.
if let Some(rebate) = ended_lease.1.checked_sub(&now_held) {
T::Currency::unreserve(&ended_lease.0, rebate);
}
@@ -392,8 +393,8 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
}
}
// Figure out whether we already have some funds of `leaser` held in reserve for `para_id`.
// If so, then we can deduct those from the amount that we need to reserve.
// Figure out whether we already have some funds of `leaser` held in reserve for
// `para_id`. If so, then we can deduct those from the amount that we need to reserve.
let maybe_additional = amount.checked_sub(&Self::deposit_held(para, &leaser));
if let Some(ref additional) = maybe_additional {
T::Currency::reserve(&leaser, *additional)
@@ -403,7 +404,8 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
let reserved = maybe_additional.unwrap_or_default();
// Check if current lease period is same as period begin, and onboard them directly.
// This will allow us to support onboarding new parachains in the middle of a lease period.
// This will allow us to support onboarding new parachains in the middle of a lease
// period.
if current_lease_period == period_begin {
// Best effort. Not much we can do if this fails.
let _ = T::Registrar::make_parachain(para);
@@ -481,7 +483,8 @@ impl<T: Config> Leaser<BlockNumberFor<T>> for Pallet<T> {
None => return true,
};
// Get the leases, and check each item in the vec which is part of the range we are checking.
// Get the leases, and check each item in the vec which is part of the range we are
// checking.
let leases = Leases::<T>::get(para_id);
for slot in offset..=offset + period_count {
if let Some(Some(_)) = leases.get(slot) {