Skip to content

Commit

Permalink
Add clippy check to CI (#323)
Browse files Browse the repository at this point in the history
Co-authored-by: drewstone <drewstone329@gmail.com>
  • Loading branch information
1xstj and drewstone authored May 2, 2023
1 parent a38d860 commit f0c637d
Show file tree
Hide file tree
Showing 31 changed files with 118 additions and 103 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ jobs:
- uses: actions/checkout@v2
- name: Set-Up
run: sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl protobuf-compiler
- name: Setup DVC
uses: iterative/setup-dvc@v1
- name: Fetch Fixtures
run: ./scripts/fetch-fixtures.sh
- name: Check Format
run: |
SKIP_WASM_BUILD=1 cargo fmt --all -- --check
SKIP_WASM_BUILD=1 cargo clippy --all-targets --workspace --exclude webb-client -- --deny warnings
# Build job
check-build:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions circom-proving/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
[package]
edition = "2021"
name = "circom-proving"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ark-ff = { version = "0.3.0", default-features = false, features = [ "asm"] }
ark-bn254 = { version = "0.3.0" }
ark-circom = { git = "https://github.com/vacp2p/ark-circom", branch = "wasm", default-features = false, features = ["circom-2"] }
ark-ec = { version = "^0.3.0", default-features = false }
ark-relations = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false, features = [ "derive" ] }
ark-ff = { version = "0.3.0", default-features = false, features = ["asm"] }
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", default-features = false, features = ["parallel"] }
ark-relations = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false, features = ["derive"] }
ark-std = { version = "^0.3.0", default-features = false }
ark-bn254 = { version = "0.3.0" }
ark-circom = { git = "https://github.com/vacp2p/ark-circom", branch = "wasm", default-features = false, features = ["circom-2"] }
num-bigint = { version = "0.4", default-features = false, features = ["rand"] }
# For ark-circom
once_cell = "1.14.0"
ark-crypto-primitives = { version = "^0.3.0", features = ["r1cs"], default-features = false }
arkworks-native-gadgets = { version = "1.2.0", default-features = false }
cfg-if = "1.0"
wasmer = { version = "2.3.0", default-features = false }
num-traits = "0.2.11"
thiserror = "1.0.0"
color-eyre = "0.6.1"
num-traits = "0.2.11"
once_cell = "1.14.0"
serde_json = "1.0.48"
arkworks-native-gadgets = { version = "1.2.0", default-features = false }
ark-crypto-primitives = { version = "^0.3.0", features = ["r1cs"], default-features = false }
thiserror = "1.0.0"
wasmer = { version = "2.3.0", default-features = false }

[features]
default = ["wasmer/sys-default"]

34 changes: 18 additions & 16 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ version = "0.1.0"

[dependencies]
codec = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "full", "bit-vec"] }
subxt = { version = "0.25.0" }
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
subxt = { version = "0.25.0" }

[dev-dependencies]
hex = "0.4"
Expand All @@ -23,30 +23,31 @@ tokio = { version = "1.17.0", features = ["full"] }
# arkworks related deps
ark-bls12-381 = { version = "^0.3.0", default-features = false, features = ["curve"] }
ark-bn254 = { version = "^0.3.0", default-features = false, features = ["curve"] }
ark-circom = { git = "https://github.com/gakonst/ark-circom", branch = "master", default-features = false, features = ["circom-2"] }
ark-crypto-primitives = { version = "^0.3.0", features = ["r1cs"], default-features = false }
ark-ec = { version = "^0.3.0", default-features = false }
ark-ff = { version = "^0.3.0", default-features = false }
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", features = ["parallel"] }
ark-relations = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false, features = ["derive"] }
ark-std = { version = "^0.3.0", default-features = false }
ark-circom = { git = "https://github.com/gakonst/ark-circom", branch = "master", default-features = false, features = ["circom-2"] }
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", features = ["parallel"] }
rand = "0.8.4"
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
arkworks-setups = { version = "1.2.1", features = ["r1cs"], default-features = false }
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
num-bigint = { version = "0.4", default-features = false, features = ["rand"] }
orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
rand = "0.8.4"
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }

# For ark-circom
once_cell = "1.14.0"
cfg-if = "1.0"
wasmer = { version = "2.3.0", default-features = false }
num-traits = "0.2.11"
thiserror = "1.0.0"
color-eyre = "0.6.1"
num-traits = "0.2.11"
once_cell = "1.14.0"
serde_json = "1.0.48"

thiserror = "1.0.0"
wasmer = { version = "2.3.0", default-features = false }

# Webb deps
arkworks-native-gadgets = { version = "1.2.0", default-features = false }
Expand All @@ -55,7 +56,8 @@ webb-primitives = { path = "../primitives", features = ["hashing", "verifying",
[features]
default = ["std", "wasmer/sys-default"]
std = [
"frame-support/std",
"frame-system/std",
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
]
wasm = ["wasmer/js", "wasmer/std"]
wasm = ["wasmer/js", "wasmer/std"]
16 changes: 8 additions & 8 deletions pallets/anonymity-mining-claims/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ frame-benchmarking = { default-features = false, git = "https://github.com/parit
hex = "0.4"
orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
pallet-claims-verifier = { path = "../claims-verifier", default-features = false }
pallet-hasher = { path = "../hasher", default-features = false }
pallet-key-storage = { path = "../key-storage" }
pallet-timestamp = { default-features = true, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.39" }
pallet-vanchor-verifier = { path = "../vanchor-verifier", default-features = false }
pallet-claims-verifier = { path = "../claims-verifier", default-features = false }
serde = { version = "1.0.119" }
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }

# For ark-circom
circom-proving = { path = "../../circom-proving", default-features = false }
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", default-features = false, features = ["parallel"] }
ark-circom = { git = "https://github.com/vacp2p/ark-circom", branch = "wasm", default-features = false, features = ["circom-2"] }
num-bigint = { version = "0.4", default-features = false, features = ["rand"] }
once_cell = "1.14.0"
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", default-features = false, features = ["parallel"] }
cfg-if = "1.0"
wasmer = { version = "2.3.0", default-features = false }
num-traits = "0.2.11"
thiserror = "1.0.0"
circom-proving = { path = "../../circom-proving", default-features = false }
color-eyre = "0.6.1"
num-bigint = { version = "0.4", default-features = false, features = ["rand"] }
num-traits = "0.2.11"
once_cell = "1.14.0"
serde_json = "1.0.48"
thiserror = "1.0.0"
wasmer = { version = "2.3.0", default-features = false }

[features]
default = ["std", "wasmer/sys-default"]
Expand Down
3 changes: 2 additions & 1 deletion pallets/anonymity-mining-claims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
//!
//! * `claim_ap`: Allows user to prove in zero knowledge they have a pair (spentUTXO, unspentUTXO)
//! on the MASP
//! and accumulate anonimity points following `inputAmount + rate * (spentTimestamp -
//! and accumulate anonimity points following `inputAmount + rate * (spentTimestamp -
//! unspentTimestamp) * amount`

// Ensure we're `no_std` when compiling for Wasm.
Expand Down Expand Up @@ -272,6 +272,7 @@ pub mod pallet {
pub type ProposalNonce = u32;
pub type RootIndex = u32;

#[allow(dead_code)]
impl<T: Config<I>, I: 'static> Pallet<T, I> {
fn create(
creator: Option<T::AccountId>,
Expand Down
1 change: 1 addition & 0 deletions pallets/anonymity-mining-claims/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::type_complexity, clippy::ptr_arg)]
use crate::mock::*;
use ark_bn254::{Bn254, Fr};
use ark_circom::{read_zkey, WitnessCalculator};
Expand Down
5 changes: 1 addition & 4 deletions pallets/anonymity-mining-claims/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ use webb_primitives::ElementTrait;

use crate::Instance1;
use ark_serialize::CanonicalSerialize;
use frame_support::{assert_err, assert_ok};
// use sp_runtime::traits::Zero;

use circom_proving::{generate_proof, verify_proof};
// use num_bigint::{BigInt, Sign};
use frame_support::{assert_err, assert_ok};
use webb_primitives::webb_proposals::{
ResourceId, SubstrateTargetSystem, TargetSystem, TypedChainId,
};
Expand Down
3 changes: 0 additions & 3 deletions pallets/anonymity-mining-rewards/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ const LIQUIDITY: u128 = 20000000;
const INITIAL_TOTAL_REWARDS_BALANCE: i128 = 30000000;
const DURATION: u64 = 31536000;

const TEST_MAX_EDGES: u32 = 100;
const TEST_TREE_DEPTH: u8 = 32;

#[test]
fn should_initialize_parameters() {
new_test_ext().execute_with(|| {});
Expand Down
6 changes: 3 additions & 3 deletions pallets/asset-registry/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn create_asset() {
#[test]
fn location_mapping_works() {
new_test_ext().execute_with(|| {
let bn = AssetRegistryPallet::to_bounded_name(b"HDX".to_vec().try_into().unwrap()).unwrap();
let bn = AssetRegistryPallet::to_bounded_name(b"HDX".to_vec()).unwrap();

let ed = 1_000_000u128;

Expand Down Expand Up @@ -174,15 +174,15 @@ fn location_mapping_works() {
#[test]
fn genesis_config_works() {
ExtBuilder::default()
.with_native_asset_name(b"NATIVE".to_vec().try_into().unwrap())
.with_native_asset_name(b"NATIVE".to_vec())
.build()
.execute_with(|| {
let native: BoundedVec<u8, <Test as crate::Config>::StringLimit> =
b"NATIVE".to_vec().try_into().unwrap();
assert_eq!(AssetRegistryPallet::asset_ids(native).unwrap(), 0u32);
});
ExtBuilder::default()
.with_assets(vec![(b"ONE".to_vec().try_into().unwrap(), 1_000u128)])
.with_assets(vec![(b"ONE".to_vec(), 1_000u128)])
.build()
.execute_with(|| {
let native: BoundedVec<u8, <Test as crate::Config>::StringLimit> =
Expand Down
1 change: 0 additions & 1 deletion pallets/mixer/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, ConstU32, IdentityLookup},
BuildStorage,
};
use sp_std::convert::{TryFrom, TryInto};
pub use webb_primitives::hasher::{HasherModule, InstanceHasher};
Expand Down
1 change: 0 additions & 1 deletion pallets/signature-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub mod pallet {
};
use frame_system::pallet_prelude::*;
use sp_runtime::traits::AtLeast32Bit;
use webb_primitives::signature_bridge::SetMaintainer;

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
Expand Down
1 change: 1 addition & 0 deletions pallets/signature-bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl Contains<RuntimeOrigin> for SetResourceProposalFilter {
}

pub struct ExecuteAllProposalsFilter;
#[allow(clippy::collapsible_match, clippy::match_like_matches_macro)]
impl Contains<RuntimeCall> for ExecuteAllProposalsFilter {
fn contains(c: &RuntimeCall) -> bool {
match c {
Expand Down
1 change: 1 addition & 0 deletions pallets/token-wrapper-handler/src/mock_signature_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ impl Contains<RuntimeCall> for SetResourceProposalFilter {
}

pub struct ExecuteProposalFilter;
#[allow(clippy::collapsible_match, clippy::match_like_matches_macro)]
impl Contains<RuntimeCall> for ExecuteProposalFilter {
fn contains(c: &RuntimeCall) -> bool {
match c {
Expand Down
14 changes: 7 additions & 7 deletions pallets/token-wrapper-handler/src/tests_signature_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn should_add_token_with_sig_succeed() {
sig.0.to_vec().try_into().unwrap(),
));
// Check that first_token_id is part of pool
assert_eq!(AssetRegistry::contains_asset(pool_share_id, first_token_id), true);
assert!(AssetRegistry::contains_asset(pool_share_id, first_token_id));
})
}

Expand Down Expand Up @@ -264,7 +264,7 @@ fn should_remove_token_with_sig_succeed() {
sig.0.to_vec().try_into().unwrap(),
));
// Check that first_token_id is part of pool
assert_eq!(AssetRegistry::contains_asset(pool_share_id, first_token_id), true);
assert!(AssetRegistry::contains_asset(pool_share_id, first_token_id));
let nonce = webb_proposals::Nonce::from(0x0002);
let header = make_proposal_header(r_id, REMOVE_TOKEN_FUNCTION_SIG, nonce);
let remove_token_proposal_bytes =
Expand All @@ -279,7 +279,7 @@ fn should_remove_token_with_sig_succeed() {
sig.0.to_vec().try_into().unwrap(),
));

assert_eq!(AssetRegistry::contains_asset(pool_share_id, first_token_id), false);
assert!(AssetRegistry::contains_asset(pool_share_id, first_token_id));
})
}

Expand Down Expand Up @@ -437,13 +437,13 @@ fn should_add_many_tokens_with_sig_succeed() {
));

// Check that first_token_id is part of pool
assert_eq!(AssetRegistry::contains_asset(pool_share_id, first_token_id), true);
assert!(AssetRegistry::contains_asset(pool_share_id, first_token_id));

// Check that second_token_id is part of pool
assert_eq!(AssetRegistry::contains_asset(pool_share_id, second_token_id), true);
assert!(AssetRegistry::contains_asset(pool_share_id, second_token_id));

// Check that third_token_id is part of pool
assert_eq!(AssetRegistry::contains_asset(pool_share_id, third_token_id), true);
assert!(AssetRegistry::contains_asset(pool_share_id, third_token_id));
})
}

Expand Down Expand Up @@ -500,7 +500,7 @@ fn should_fail_to_add_same_token_with_sig() {
sig.0.to_vec().try_into().unwrap(),
));
// Check that first_token_id is part of pool
assert_eq!(AssetRegistry::contains_asset(pool_share_id, first_token_id), true);
assert!(AssetRegistry::contains_asset(pool_share_id, first_token_id));

// Have to remake prop_data with incremented nonce
let nonce = webb_proposals::Nonce::from(0x0002);
Expand Down
2 changes: 2 additions & 0 deletions pallets/vanchor-handler/src/mock_signature_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ parameter_types! {
}

pub struct SetResourceProposalFilter;
#[allow(clippy::collapsible_match, clippy::match_like_matches_macro)]
impl Contains<RuntimeCall> for SetResourceProposalFilter {
fn contains(c: &RuntimeCall) -> bool {
match c {
Expand All @@ -302,6 +303,7 @@ impl Contains<RuntimeCall> for SetResourceProposalFilter {
}

pub struct ExecuteProposalFilter;
#[allow(clippy::collapsible_match, clippy::match_like_matches_macro)]
impl Contains<RuntimeCall> for ExecuteProposalFilter {
fn contains(c: &RuntimeCall) -> bool {
match c {
Expand Down
2 changes: 1 addition & 1 deletion pallets/vanchor-handler/src/tests_signature_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn should_add_vanchor_edge_with_sig_succeed() {
new_test_ext_initialized(
src_id.chain_id(),
r_id,
b"VAnchorHandler.execute_vanchor_update_proposal".to_vec().try_into().unwrap(),
b"VAnchorHandler.execute_vanchor_update_proposal".to_vec(),
)
.execute_with(|| {
let curve = Curve::Bn254;
Expand Down
Loading

0 comments on commit f0c637d

Please sign in to comment.