Skip to content

Commit

Permalink
enable ci
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszaaa committed Oct 19, 2022
1 parent 8d29e21 commit 991d9f0
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 166 deletions.
62 changes: 45 additions & 17 deletions .github/workflows/mangata-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,64 @@ on:
push:
branches: [ mangata-dev ]

name: build
name: CI

env:
TOOLCHAIN: nightly-2022-05-11


jobs:
check:
name: Rust project
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install newset Cargo
- name: Install ${{ env.TOOLCHAIN }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-05-11
toolchain: ${{ env.TOOLCHAIN }}
default: true
- name: Install nightly-2022-05-11 with wasm
components: rustfmt
target: wasm32-unknown-unknown
- name: Check formatting
uses: actions-rs/cargo@v1
with:
toolchain: ${{ env.TOOLCHAIN }}
command: fmt
args: --all -- --check

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install ${{ env.TOOLCHAIN }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-05-11
toolchain: ${{ env.TOOLCHAIN }}
default: true
components: rustfmt
target: wasm32-unknown-unknown
- name: Check Cargo version
run: |
cargo --version
- name: Build UT
- name: Check formatting
uses: actions-rs/cargo@v1
with:
toolchain: nightly-2022-05-11
command: test
args: --release -j2 --no-run
- name: Run UT
toolchain: ${{ env.TOOLCHAIN }}
command: build
args: --release

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install ${{ env.TOOLCHAIN }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.TOOLCHAIN }}
default: true
components: rustfmt
target: wasm32-unknown-unknown
- name: Check formatting
uses: actions-rs/cargo@v1
with:
toolchain: nightly-2022-05-11
toolchain: ${{ env.TOOLCHAIN }}
command: test
args: --release
args: -p sc-block-builder-ver -p sc-basic-authorship-ver -p frame-executive -p frame-system -p sc-consensus-slots -p sc-consensus-aura

4 changes: 1 addition & 3 deletions client/basic-authorship-ver/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
use sc_transaction_pool_api::{InPoolTransaction, TransactionPool};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::{ApplyExtrinsicFailed::Validity, Error::ApplyExtrinsicFailed, HeaderBackend};
use sp_consensus::{
DisableProofRecording, EnableProofRecording, ProofRecording, Proposal,
};
use sp_consensus::{DisableProofRecording, EnableProofRecording, ProofRecording, Proposal};
use sp_core::traits::SpawnNamed;
use sp_inherents::InherentData;
use sp_runtime::{
Expand Down
11 changes: 5 additions & 6 deletions frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
use scale_info::TypeInfo;
use sp_io::storage;
use sp_runtime::{traits::Hash, RuntimeDebug};
use sp_std::vec;
use sp_std::{marker::PhantomData, prelude::*, result};
use sp_std::{marker::PhantomData, prelude::*, result, vec};

use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
Expand Down Expand Up @@ -753,7 +752,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
if position_yes.is_none() {
voting.ayes.push(who.clone());
} else {
return Err(Error::<T, I>::DuplicateVote.into());
return Err(Error::<T, I>::DuplicateVote.into())
}
if let Some(pos) = position_no {
voting.nays.swap_remove(pos);
Expand All @@ -762,7 +761,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
if position_no.is_none() {
voting.nays.push(who.clone());
} else {
return Err(Error::<T, I>::DuplicateVote.into());
return Err(Error::<T, I>::DuplicateVote.into())
}
if let Some(pos) = position_yes {
voting.ayes.swap_remove(pos);
Expand Down Expand Up @@ -816,15 +815,15 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
),
Pays::Yes,
)
.into());
.into())
} else if disapproved {
Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes });
let proposal_count = Self::do_disapprove_proposal(proposal_hash);
return Ok((
Some(T::WeightInfo::close_early_disapproved(seats, proposal_count)),
Pays::No,
)
.into());
.into())
}

// Only allow actual closing of the proposal after the voting period has ended.
Expand Down
25 changes: 12 additions & 13 deletions frame/executive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ where
// Check that `parent_hash` is correct.
let n = header.number().clone();
assert!(
n > System::BlockNumber::zero()
&& <frame_system::Pallet<System>>::block_hash(n - System::BlockNumber::one())
== *header.parent_hash(),
n > System::BlockNumber::zero() &&
<frame_system::Pallet<System>>::block_hash(n - System::BlockNumber::one()) ==
*header.parent_hash(),
"Parent hash should be valid.",
);

Expand Down Expand Up @@ -978,8 +978,8 @@ mod tests {
.assimilate_storage(&mut t)
.unwrap();
let xt = TestXt::new(call_transfer(2, 69), sign_extra(1, 0, 0));
let weight = xt.get_dispatch_info().weight
+ <Runtime as frame_system::Config>::BlockWeights::get()
let weight = xt.get_dispatch_info().weight +
<Runtime as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.base_extrinsic;
let fee: Balance =
Expand Down Expand Up @@ -1199,8 +1199,8 @@ mod tests {
assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok());

// default weight for `TestXt` == encoded length.
let extrinsic_weight = len as Weight
+ <Runtime as frame_system::Config>::BlockWeights::get()
let extrinsic_weight = len as Weight +
<Runtime as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.base_extrinsic;
assert_eq!(
Expand Down Expand Up @@ -1271,8 +1271,8 @@ mod tests {
Call::System(SystemCall::remark { remark: vec![1u8] }),
sign_extra(1, 0, 0),
);
let weight = xt.get_dispatch_info().weight
+ <Runtime as frame_system::Config>::BlockWeights::get()
let weight = xt.get_dispatch_info().weight +
<Runtime as frame_system::Config>::BlockWeights::get()
.get(DispatchClass::Normal)
.base_extrinsic;
let fee: Balance =
Expand Down Expand Up @@ -1519,10 +1519,9 @@ mod tests {
// Weights are recorded correctly
assert_eq!(
frame_system::Pallet::<Runtime>::block_weight().total(),
custom_runtime_upgrade_weight
+ runtime_upgrade_weight
+ on_initialize_weight
+ base_block_weight,
custom_runtime_upgrade_weight +
runtime_upgrade_weight +
on_initialize_weight + base_block_weight,
);
});
}
Expand Down
62 changes: 31 additions & 31 deletions frame/support/src/traits/tokens/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ use crate::{
traits::Get,
};
use codec::{FullCodec, MaxEncodedLen};
use sp_runtime::traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize, Member};
use frame_support::Parameter;
use mangata_types::{Balance as BalancePrimitive, TokenId};
use sp_std::fmt::Debug;
use scale_info::TypeInfo;
use frame_support::Parameter;
use sp_std::result;
use sp_runtime::traits::{AtLeast32BitUnsigned, MaybeSerializeDeserialize, Member};
use sp_std::{fmt::Debug, result};

mod reservable;
pub use reservable::{NamedReservableCurrency, ReservableCurrency};
Expand All @@ -46,40 +45,40 @@ pub trait MultiTokenImbalanceWithZeroTrait<CurrencyId> {
pub trait MultiTokenCurrency<AccountId> {
/// The balance of an account.
type Balance: AtLeast32BitUnsigned
+ FullCodec
+ Copy
+ MaybeSerializeDeserialize
+ Debug
+ Default
+ MaxEncodedLen
+ TypeInfo
+ From<BalancePrimitive>
+ Into<BalancePrimitive>;
+ FullCodec
+ Copy
+ MaybeSerializeDeserialize
+ Debug
+ Default
+ MaxEncodedLen
+ TypeInfo
+ From<BalancePrimitive>
+ Into<BalancePrimitive>;

type CurrencyId: Parameter
+ Member
+ Copy
+ MaybeSerializeDeserialize
+ Ord
+ Default
+ AtLeast32BitUnsigned
+ FullCodec
+ MaxEncodedLen
+ TypeInfo
+ From<TokenId>
+ Into<TokenId>;
+ Member
+ Copy
+ MaybeSerializeDeserialize
+ Ord
+ Default
+ AtLeast32BitUnsigned
+ FullCodec
+ MaxEncodedLen
+ TypeInfo
+ From<TokenId>
+ Into<TokenId>;

/// The opaque token type for an imbalance. This is returned by unbalanced
/// operations and must be dealt with. It may be dropped but cannot be
/// cloned.
type PositiveImbalance: Imbalance<Self::Balance, Opposite = Self::NegativeImbalance>
+ MultiTokenImbalanceWithZeroTrait<Self::CurrencyId>;
+ MultiTokenImbalanceWithZeroTrait<Self::CurrencyId>;

/// The opaque token type for an imbalance. This is returned by unbalanced
/// operations and must be dealt with. It may be dropped but cannot be
/// cloned.
type NegativeImbalance: Imbalance<Self::Balance, Opposite = Self::PositiveImbalance>
+ MultiTokenImbalanceWithZeroTrait<Self::CurrencyId>;
+ MultiTokenImbalanceWithZeroTrait<Self::CurrencyId>;

// PUBLIC IMMUTABLES

Expand Down Expand Up @@ -123,10 +122,7 @@ pub trait MultiTokenCurrency<AccountId> {
currency_id: Self::CurrencyId,
amount: Self::Balance,
) -> (Self::PositiveImbalance, Self::NegativeImbalance) {
(
Self::burn(currency_id, amount.clone()),
Self::issue(currency_id, amount),
)
(Self::burn(currency_id, amount.clone()), Self::issue(currency_id, amount))
}

/// The 'free' balance of a given account.
Expand Down Expand Up @@ -217,7 +213,11 @@ pub trait MultiTokenCurrency<AccountId> {

/// Similar to deposit_creating, only accepts a `NegativeImbalance` and
/// returns nothing on success.
fn resolve_creating(currency_id: Self::CurrencyId, who: &AccountId, value: Self::NegativeImbalance) {
fn resolve_creating(
currency_id: Self::CurrencyId,
who: &AccountId,
value: Self::NegativeImbalance,
) {
let v = value.peek();
drop(value.offset(Self::deposit_creating(currency_id, who, v)));
}
Expand Down
24 changes: 14 additions & 10 deletions frame/transaction-payment-mangata/asset-tx-payment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

//! It does this by extending transactions to include an optional `AssetId` that specifies the asset
//! to be used for payment (defaulting to the native token on `None`). It expects an
//! [`OnChargeAssetTransaction`] implementation analogously to [`pallet-transaction-payment-mangata`]. The
//! included [`FungiblesAdapter`] (implementing [`OnChargeAssetTransaction`]) determines the fee
//! amount by converting the fee calculated by [`pallet-transaction-payment-mangata`] into the desired
//! asset.
//! [`OnChargeAssetTransaction`] implementation analogously to
//! [`pallet-transaction-payment-mangata`]. The included [`FungiblesAdapter`] (implementing
//! [`OnChargeAssetTransaction`]) determines the fee amount by converting the fee calculated by
//! [`pallet-transaction-payment-mangata`] into the desired asset.
//!
//! ## Integration

Expand Down Expand Up @@ -127,8 +127,9 @@ pub mod pallet {
/// Require the transactor pay for themselves and maybe include a tip to gain additional priority
/// in the queue. Allows paying via both `Currency` as well as `fungibles::Balanced`.
///
/// Wraps the transaction logic in [`pallet_transaction_payment_mangata`] and extends it with assets.
/// An asset id of `None` falls back to the underlying transaction payment via the native currency.
/// Wraps the transaction logic in [`pallet_transaction_payment_mangata`] and extends it with
/// assets. An asset id of `None` falls back to the underlying transaction payment via the native
/// currency.
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct ChargeAssetTxPayment<T: Config> {
Expand Down Expand Up @@ -159,7 +160,9 @@ where
info: &DispatchInfoOf<T::Call>,
len: usize,
) -> Result<(BalanceOf<T>, InitialPayment<T>), TransactionValidityError> {
let fee = pallet_transaction_payment_mangata::Pallet::<T>::compute_fee(len as u32, info, self.tip);
let fee = pallet_transaction_payment_mangata::Pallet::<T>::compute_fee(
len as u32, info, self.tip,
);
debug_assert!(self.tip <= fee, "tip should be included in the computed fee");
if fee.is_zero() {
Ok((fee, InitialPayment::Nothing))
Expand Down Expand Up @@ -262,9 +265,10 @@ where
)?;
},
InitialPayment::Asset(already_withdrawn) => {
let actual_fee = pallet_transaction_payment_mangata::Pallet::<T>::compute_actual_fee(
len as u32, info, post_info, tip,
);
let actual_fee =
pallet_transaction_payment_mangata::Pallet::<T>::compute_actual_fee(
len as u32, info, post_info, tip,
);
T::OnChargeAssetTransaction::correct_and_deposit_fee(
&who,
info,
Expand Down
4 changes: 3 additions & 1 deletion frame/transaction-payment-mangata/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ use jsonrpsee::{
proc_macros::rpc,
types::error::{CallError, ErrorCode, ErrorObject},
};
use pallet_transaction_payment_rpc_runtime_api_mangata::{FeeDetails, InclusionFee, RuntimeDispatchInfo};
use pallet_transaction_payment_rpc_runtime_api_mangata::{
FeeDetails, InclusionFee, RuntimeDispatchInfo,
};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::Bytes;
Expand Down
2 changes: 1 addition & 1 deletion frame/uniques/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub mod pallet {
type CreateOrigin: EnsureOriginWithArg<
Self::Origin,
Self::CollectionId,
Success = Self::AccountId
Success = Self::AccountId,
>;

/// Locker trait to enable Locking mechanism downstream.
Expand Down
Loading

0 comments on commit 991d9f0

Please sign in to comment.