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

Update license year, fix comment, add more pallet docs #328

Merged
merged 3 commits into from
May 19, 2023
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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ strip = "symbols"
members = [
"client",
"primitives",
"pallets/anonymity-mining-rewards",
"pallets/anonymity-mining-claims",
"pallets/claims-verifier",
"pallets/masp/anonymity-mining-rewards",
"pallets/masp/anonymity-mining-claims",
"pallets/masp/claims-verifier",
"pallets/asset-registry",
"pallets/hasher",
"pallets/verifier",
Expand Down
2 changes: 1 addition & 1 deletion circom-proving/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn generate_proof<const N: usize>(
Ok((proof, full_assignment))
}

/// Verifies a given RLN proof
/// Verifies a Groth16 proof
///
/// # Errors
///
Expand Down
20 changes: 0 additions & 20 deletions client/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,26 +215,6 @@ pub fn generate_proof(
Ok((proof, full_assignment))
}

/// Verifies a given RLN proof
///
/// # Errors
///
/// Returns a [`ProofError`] if verifying fails. Verification failure does not
/// necessarily mean the proof is incorrect.
pub fn verify_proof(
verifying_key: &VerifyingKey<Bn254>,
proof: &ArkProof<Bn254>,
inputs: &Vec<Fr>,
) -> Result<bool, ProofError> {
// Check that the proof is valid
let pvk = prepare_verifying_key(verifying_key);
//let pr: ArkProof<Curve> = (*proof).into();

let verified = ark_verify_proof(&pvk, proof, inputs)?;

Ok(verified)
}

// Initializes the witness calculator using a bytes vector
#[cfg(not(target_arch = "wasm32"))]
pub fn circom_from_raw(wasm_buffer: Vec<u8>) -> &'static Mutex<WitnessCalculator> {
Expand Down
71 changes: 65 additions & 6 deletions pallets/asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,80 @@
// This file is part of Basilisk-node.
// This file is part of Webb.

// Copyright (C) 2020-2021 Intergalactic, Limited (GIB).
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! # Asset Registry Pallet
//!
//! The Asset Registry pallet provides functionality to register and manage assets on-chain.
//!
//! ## Overview
//!
//! The Asset Registry pallet allows users to register and update assets with unique names and asset
//! types. It also provides the ability to set metadata, such as symbols and decimals, for
//! registered assets. Additionally, the pallet supports setting the native location of assets and
//! managing asset pools by adding or removing assets from existing pools.
//!
//! To use the Asset Registry pallet in your runtime, you need to implement the `Config` trait. This
//! trait defines the types and constants required by the pallet.
//!
//! ## Extrinsics
//!
//! The Asset Registry pallet provides the following extrinsics:
//!
//! - `register`: Register a new asset with a unique name and asset type.
//! - `update`: Update the details of an existing asset.
//! - `set_metadata`: Set metadata for an asset, such as symbol and decimals.
//! - `set_location`: Set the native location of an asset.
//! - `add_asset_to_pool`: Add an asset to an existing asset pool.
//! - `delete_asset_from_pool`: Remove an asset from an existing asset pool.
//!
//! ## Functions
//!
//! The Asset Registry pallet also exposes the following functions to be used internall:
//!
//! - `asset_to_location`: Retrieve the native location of an asset.
//! - `location_to_asset`: Retrieve the asset ID for a given native location.
//! - `contains_asset`: Check if an asset is present in a pool share.
//! - `add_asset_to_existing_pool`: Add an asset to an existing pool share.
//! - `delete_asset_from_existing_pool`: Remove an asset from an existing pool share.
//! - `get`: Retrieve the existential deposit of an asset.
//!
//! ## Events
//!
//! The Asset Registry pallet emits the following events:
//!
//! - `Registered`: Indicates that an asset was successfully registered.
//! - `Updated`: Indicates that an asset was successfully updated.
//! - `MetadataSet`: Indicates that metadata was set for an asset.
//! - `LocationSet`: Indicates that the native location was set for an asset.
//!
//! For more details on the usage and configuration of the Asset Registry pallet, refer to the
//! documentation of the provided types and functions.
//!
//! [`register`]: Call::register
//! [`update`]: Call::update
//! [`set_metadata`]: Call::set_metadata
//! [`set_location`]: Call::set_location
//! [`add_asset_to_pool`]: Call::add_asset_to_pool
//! [`delete_asset_from_pool`]: Call::delete_asset_from_pool
//! [`asset_to_location`]: Pallet::asset_to_location
//! [`location_to_asset`]: Pallet::location_to_asset
//! [`contains_asset`]: Pallet::contains_asset
//! [`add_asset_to_existing_pool`]: Pallet::add_asset_to_existing_pool
//! [`delete_asset_from_existing_pool`]: Pallet::delete

#![allow(clippy::type_complexity)]
#![cfg_attr(not(feature = "std"), no_std)]

Expand Down Expand Up @@ -261,13 +322,11 @@ pub mod pallet {
/// New asset is given `NextAssetId` - sequential asset id
///
/// Adds mapping between `name` and assigned `asset_id` so asset id can
/// be retrieved by name too (Note: this approach is used in AMM
/// implementation (xyk))
/// be retrieved by name too.
///
/// Emits 'Registered` event when successful.
#[pallet::weight(<T as Config>::WeightInfo::register())]
#[pallet::call_index(0)]

pub fn register(
origin: OriginFor<T>,
name: BoundedVec<u8, T::StringLimit>,
Expand Down
2 changes: 1 addition & 1 deletion pallets/hasher/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/hasher/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/key-storage/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/linkable-tree/rpc/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/linkable-tree/rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/linkable-tree/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/linkable-tree/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ codec = { package = "parity-scale-codec", version = "3", default-features = fals
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }

orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
pallet-asset-registry = { path = "../asset-registry", default-features = false }
pallet-asset-registry = { path = "../../asset-registry", default-features = false }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
pallet-linkable-tree = { path = "../linkable-tree", default-features = false }
pallet-mt = { path = "../mt", default-features = false }
pallet-signature-bridge = { path = "../../pallets/signature-bridge", default-features = false }
pallet-token-wrapper = { path = "../token-wrapper", default-features = false }
pallet-vanchor = { path = "../vanchor", default-features = false }
pallet-vanchor-handler = { path = "../../pallets/vanchor-handler", default-features = false }
pallet-linkable-tree = { path = "../../linkable-tree", default-features = false }
pallet-mt = { path = "../../mt", default-features = false }
pallet-signature-bridge = { path = "../../../pallets/signature-bridge", default-features = false }
pallet-token-wrapper = { path = "../../token-wrapper", default-features = false }
pallet-vanchor = { path = "../../vanchor", default-features = false }
pallet-vanchor-handler = { path = "../../../pallets/vanchor-handler", default-features = false }

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" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
webb-primitives = { path = "../../primitives", default-features = false }
webb-primitives = { path = "../../../primitives", default-features = false }

[dev-dependencies]
ark-bls12-381 = { version = "^0.3.0", default-features = false, features = ["curve"] }
Expand All @@ -46,10 +46,10 @@ 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-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-vanchor-verifier = { path = "../../vanchor-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" }
Expand All @@ -59,7 +59,7 @@ sp-runtime = { default-features = false, git = "https://github.com/paritytech/su
ark-circom = { git = "https://github.com/vacp2p/ark-circom", branch = "wasm", default-features = false, features = ["circom-2"] }
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", default-features = false, features = ["parallel"] }
cfg-if = "1.0"
circom-proving = { path = "../../circom-proving", default-features = false }
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ pub fn setup_environment_with_circom(
setup_environment();

println!("Setting up ZKey");
let path_2_2 = "../../solidity-fixtures/solidity-fixtures/reward_2/30/circuit_final.zkey";
let path_2_2 = "../../../solidity-fixtures/solidity-fixtures/reward_2/30/circuit_final.zkey";
let mut file_2_2 = File::open(path_2_2).unwrap();
let params_2_2 = read_zkey(&mut file_2_2).unwrap();

let wasm_2_2_path = "../../solidity-fixtures/solidity-fixtures/reward_2/30/reward_30_2.wasm";
let wasm_2_2_path = "../../../solidity-fixtures/solidity-fixtures/reward_2/30/reward_30_2.wasm";

let wc_2_2 = circom_from_folder(wasm_2_2_path);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ codec = { package = "parity-scale-codec", version = "3", default-features = fals
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }

orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.39", default-features = false }
pallet-asset-registry = { path = "../asset-registry", default-features = false }
pallet-asset-registry = { path = "../../asset-registry", default-features = false }
pallet-balances = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
pallet-linkable-tree = { path = "../linkable-tree", default-features = false }
pallet-mt = { path = "../mt", default-features = false }
pallet-signature-bridge = { path = "../../pallets/signature-bridge", default-features = false }
pallet-token-wrapper = { path = "../token-wrapper", default-features = false }
pallet-vanchor = { path = "../vanchor", default-features = false }
pallet-vanchor-handler = { path = "../../pallets/vanchor-handler", default-features = false }
pallet-linkable-tree = { path = "../../linkable-tree", default-features = false }
pallet-mt = { path = "../../mt", default-features = false }
pallet-signature-bridge = { path = "../../../pallets/signature-bridge", default-features = false }
pallet-token-wrapper = { path = "../../token-wrapper", default-features = false }
pallet-vanchor = { path = "../../vanchor", default-features = false }
pallet-vanchor-handler = { path = "../../../pallets/vanchor-handler", default-features = false }

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" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
webb-primitives = { path = "../../primitives", default-features = false }
webb-primitives = { path = "../../../primitives", default-features = false }

[dev-dependencies]
ark-bls12-381 = { version = "^0.3.0", default-features = false, features = ["curve"] }
Expand All @@ -45,10 +45,10 @@ 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-hasher = { path = "../hasher", default-features = false }
pallet-key-storage = { path = "../key-storage" }
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-vanchor-verifier = { path = "../../vanchor-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" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ log = { version = "0.4.14", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39" }
webb-primitives = { path = "../../primitives", default-features = false, features = ["verifying"] }
webb-primitives = { path = "../../../primitives", default-features = false, features = ["verifying"] }

frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39", optional = true }
frame-system-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.39", optional = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/mixer/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/mixer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/mt/rpc/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/mt/rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion pallets/mt/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of Webb.

// Copyright (C) 2021 Webb Technologies Inc.
// Copyright (C) 2021-2023 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading