Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run cargo fmt + cargo clippy + update GA-CI #31

Merged
merged 6 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,62 @@ jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-03-25
override: true
target: wasm32-unknown-unknown
- name: Install llvm-10
run: sudo apt-get install llvm-10 clang-10
- uses: actions/checkout@v2
with:
submodules: 'true'

# With rustup's nice new toml format, we just need to run rustup show to install the toolchain
# https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659
- name: Setup Rust toolchain
run: rustup show

- name: Cache Rust Dependecies
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
enclave/target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: cargo build --verbose --release
run: cargo build --release

- name: Upload integritee-collator
uses: actions/upload-artifact@v2
with:
name: integritee-collator-${{ github.sha }}
path: target/release/integritee-collator

fmt:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: Setup Rust toolchain
run: rustup show

- name: fmt check
# fail job on warnings with `-- --check`
run: cargo fmt --all -- --check

clippy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'

- name: Setup Rust toolchain
run: rustup show

- name: clippy
# fail job on warnings with `-- -D warnings`
run: cargo clippy -- -D warnings

create-artifacts:
needs: build
runs-on: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
hard_tabs=true
merge_imports=true
imports_granularity= "Crate"
22 changes: 11 additions & 11 deletions polkadot-parachains/integritee-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, traits::ConvertInto,
traits::{BlakeTwo256, Block as BlockT, AccountIdLookup},
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
Expand All @@ -37,8 +37,8 @@ use sp_version::RuntimeVersion;

// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types, match_type,
traits::{Randomness, All, IsInVec},
construct_runtime, match_type, parameter_types,
traits::{All, IsInVec, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Weight,
Expand Down Expand Up @@ -210,10 +210,10 @@ impl pallet_timestamp::Config for Runtime {
}

parameter_types! {
pub const ExistentialDeposit: u128 = 1 * MILLITEER;
pub const TransferFee: u128 = 1 * MILLITEER;
pub const CreationFee: u128 = 1 * MILLITEER;
pub const TransactionByteFee: u128 = 1 * MICROTEER;
pub const ExistentialDeposit: u128 = MILLITEER;
pub const TransferFee: u128 = MILLITEER;
pub const CreationFee: u128 = MILLITEER;
pub const TransactionByteFee: u128 = MICROTEER;
pub const MaxLocks: u32 = 50;
pub const MaxReserves: u32 = 50;
}
Expand Down Expand Up @@ -413,10 +413,10 @@ impl cumulus_pallet_dmp_queue::Config for Runtime {
}

parameter_types! {
pub const AssetDeposit: Balance = 1 * TEER;
pub const AssetDeposit: Balance = TEER;
pub const ApprovalDeposit: Balance = 100 * MILLITEER;
pub const StringLimit: u32 = 50;
pub const MetadataDepositBase: Balance = 1 * TEER;
pub const MetadataDepositBase: Balance = TEER;
pub const MetadataDepositPerByte: Balance = 10 * MILLITEER;
pub const UnitBody: BodyId = BodyId::Unit;
}
Expand Down Expand Up @@ -666,7 +666,7 @@ impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
.create_inherent_data()
.expect("Could not create the timestamp inherent data");

inherent_data.check_extrinsics(&block)
inherent_data.check_extrinsics(block)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//! Autogenerated weights for frame_system
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
Expand All @@ -18,7 +17,6 @@
// --heap-pages=4096
// --output=./polkadot-parachains/integritee-runtime/src/weights/frame_system.rs


#![allow(unused_parens)]
#![allow(unused_imports)]

Expand All @@ -28,36 +26,35 @@ use sp_std::marker::PhantomData;
/// Weight functions for frame_system.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_system::WeightInfo for WeightInfo<T> {
fn remark(_b: u32, ) -> Weight {
fn remark(_b: u32) -> Weight {
(1_374_000 as Weight)
}
fn remark_with_event(b: u32, ) -> Weight {
fn remark_with_event(b: u32) -> Weight {
(15_447_000 as Weight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(b as Weight))
}
fn set_heap_pages() -> Weight {
(1_600_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
(1_600_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_changes_trie_config() -> Weight {
(7_500_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn set_storage(i: u32, ) -> Weight {
fn set_storage(i: u32) -> Weight {
(0 as Weight)
// Standard Error: 1_000
.saturating_add((583_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_storage(i: u32, ) -> Weight {
fn kill_storage(i: u32) -> Weight {
(0 as Weight)
// Standard Error: 1_000
.saturating_add((491_000 as Weight).saturating_mul(i as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(i as Weight)))
}
fn kill_prefix(p: u32, ) -> Weight {
fn kill_prefix(p: u32) -> Weight {
(8_516_000 as Weight)
// Standard Error: 1_000
.saturating_add((744_000 as Weight).saturating_mul(p as Weight))
Expand Down
3 changes: 3 additions & 0 deletions polkadot-parachains/integritee-runtime/src/weights/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! The weights used in the integritee-parachain-runtime

// the generated files do not pass clippy
#![allow(clippy::all)]

pub mod frame_system;
pub mod pallet_balances;
pub mod pallet_teerex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//! Autogenerated weights for pallet_balances
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
Expand All @@ -18,7 +17,6 @@
// --heap-pages=4096
// --output=./polkadot-parachains/integritee-runtime/src/weights/pallet_balances.rs


#![allow(unused_parens)]
#![allow(unused_imports)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//! Autogenerated weights for pallet_teerex
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
Expand All @@ -18,7 +17,6 @@
// --heap-pages=4096
// --output=./polkadot-parachains/integritee-runtime/src/weights/pallet_teerex.rs


#![allow(unused_parens)]
#![allow(unused_imports)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//! Autogenerated weights for pallet_timestamp
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
Expand All @@ -18,7 +17,6 @@
// --heap-pages=4096
// --output=./polkadot-parachains/integritee-runtime/src/weights/pallet_timestamp.rs


#![allow(unused_parens)]
#![allow(unused_imports)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

//! Autogenerated weights for pallet_vesting
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
Expand All @@ -18,7 +17,6 @@
// --heap-pages=4096
// --output=./polkadot-parachains/integritee-runtime/src/weights/pallet_vesting.rs


#![allow(unused_parens)]
#![allow(unused_imports)]

Expand All @@ -28,40 +26,40 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_vesting.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_vesting::WeightInfo for WeightInfo<T> {
fn vest_locked(l: u32, ) -> Weight {
fn vest_locked(l: u32) -> Weight {
(37_483_000 as Weight)
// Standard Error: 61_000
.saturating_add((469_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn vest_unlocked(l: u32, ) -> Weight {
fn vest_unlocked(l: u32) -> Weight {
(43_297_000 as Weight)
// Standard Error: 32_000
.saturating_add((258_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn vest_other_locked(l: u32, ) -> Weight {
fn vest_other_locked(l: u32) -> Weight {
(37_665_000 as Weight)
// Standard Error: 51_000
.saturating_add((419_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn vest_other_unlocked(l: u32, ) -> Weight {
fn vest_other_unlocked(l: u32) -> Weight {
(42_345_000 as Weight)
// Standard Error: 43_000
.saturating_add((313_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn vested_transfer(_l: u32, ) -> Weight {
fn vested_transfer(_l: u32) -> Weight {
(130_736_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn force_vested_transfer(_l: u32, ) -> Weight {
fn force_vested_transfer(_l: u32) -> Weight {
(133_697_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
Expand Down
36 changes: 17 additions & 19 deletions polkadot-parachains/shell-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, traits::ConvertInto,
traits::{BlakeTwo256, Block as BlockT, AccountIdLookup},
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult,
};
Expand All @@ -37,30 +37,30 @@ use sp_version::RuntimeVersion;

// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types, match_type,
traits::{Randomness, All, IsInVec},
construct_runtime, match_type, parameter_types,
traits::{All, IsInVec, Randomness},
weights::{
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
DispatchClass, IdentityFee, Weight,
},
StorageValue,
};
use frame_system::limits::{BlockLength, BlockWeights};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
pub use sp_runtime::{Perbill, Permill};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;

pub use pallet_balances::Call as BalancesCall;

// XCM imports
use frame_support::traits::Filter;
use xcm::v0::{Junction::*, MultiLocation, MultiLocation::*, NetworkId};
use xcm_builder::{
LocationInverter, ParentIsDefault, FixedWeightBounds, AllowUnpaidExecutionFrom,
ParentAsSuperuser, SovereignSignedViaLocation,
AllowUnpaidExecutionFrom, FixedWeightBounds, LocationInverter, ParentAsSuperuser,
ParentIsDefault, SovereignSignedViaLocation,
};
use xcm_executor::{Config, XcmExecutor};
use frame_support::traits::Filter;

pub type SessionHandlers = ();

Expand Down Expand Up @@ -152,11 +152,10 @@ parameter_types! {
pub struct DisableTokenTxFilter;
impl Filter<Call> for DisableTokenTxFilter {
fn filter(call: &Call) -> bool {
match call {
// Balances and Vesting's transfer (which can be used to transfer)
Call::Balances(_) | Call::Vesting(pallet_vesting::Call::vested_transfer(..)) => false,
_ => true
}
!matches!(
call,
Call::Balances(_) | Call::Vesting(pallet_vesting::Call::vested_transfer(..))
)
}
}

Expand Down Expand Up @@ -212,10 +211,10 @@ impl pallet_timestamp::Config for Runtime {
}

parameter_types! {
pub const ExistentialDeposit: u128 = 1 * MILLITEER;
pub const TransferFee: u128 = 1 * MILLITEER;
pub const CreationFee: u128 = 1 * MILLITEER;
pub const TransactionByteFee: u128 = 1 * MICROTEER;
pub const ExistentialDeposit: u128 = MILLITEER;
pub const TransferFee: u128 = MILLITEER;
pub const CreationFee: u128 = MILLITEER;
pub const TransactionByteFee: u128 = MICROTEER;
pub const MaxLocks: u32 = 50;
pub const MaxReserves: u32 = 50;
}
Expand Down Expand Up @@ -330,7 +329,6 @@ impl pallet_aura::Config for Runtime {
type AuthorityId = AuraId;
}


construct_runtime! {
pub enum Runtime where
Block = Block,
Expand All @@ -339,7 +337,7 @@ construct_runtime! {
{
System: frame_system::{Pallet, Call, Storage, Config, Event<T>} = 0,
ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Config, Storage, Inherent, Event<T>, ValidateUnsigned} = 1,

Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3,
ParachainInfo: parachain_info::{Pallet, Storage, Config} = 4,
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 5,
Expand Down
Loading