Skip to content

Commit

Permalink
add anonymity-mining-claims to runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
semaraugusto committed Mar 17, 2023
1 parent 13e84e3 commit 30c6e34
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 23 deletions.
32 changes: 16 additions & 16 deletions pallets/anonymity-mining-claims/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Pallet that handles anonymity mining claims."
edition = "2018"
homepage = "https://substrate.dev"
license = "Unlicense"
name = "pallet-anonimity-mining-claims"
name = "pallet-anonymity-mining-claims"
repository = "https://github.com/webb-tools/protocol-substrate"
version = "1.0.0"

Expand All @@ -24,42 +24,41 @@ pallet-signature-bridge = { path = "../../pallets/signature-bridge", default-fea
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-claims-verifier = { path = "../claims-verifier", default-features = false }
pallet-hasher = { path = "../hasher", default-features = false }

frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
webb-primitives = { path = "../../primitives", default-features = false }
ark-std = { version = "^0.3.0", default-features = false }
ark-bn254 = { version = "^0.3.0", default-features = false, features = ["curve"] }
ark-ff = { version = "^0.3.0", default-features = false }
ark-serialize = { version = "^0.3.0", default-features = false, features = ["derive"] }
circom-proving = { path = "../../circom-proving", default-features = false }
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
arkworks-setups = { version = "1.2.1", features = ["r1cs"], default-features = false }
ark-circom = { git = "https://github.com/vacp2p/ark-circom", branch = "wasm", default-features = false, features = ["circom-2"] }
hex = "0.4"
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.36", default-features = false }
ark-relations = { version = "^0.3.0", default-features = false }
ark-groth16 = { git = "https://github.com/arkworks-rs/groth16", rev = "765817f", default-features = false, features = ["parallel"] }

[dev-dependencies]
ark-bls12-381 = { version = "^0.3.0", default-features = false, features = ["curve"] }
ark-bn254 = { version = "^0.3.0", default-features = false, features = ["curve"] }
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-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 }
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.36" }
hex = "0.4"
orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.36", default-features = false }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library.git", branch = "polkadot-v0.9.36", 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.36" }
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.36" }
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.36" }

# 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"
cfg-if = "1.0"
Expand Down Expand Up @@ -95,3 +94,4 @@ std = [
"pallet-token-wrapper/std",

]
wasm = ["wasmer/js", "wasmer/std"]
6 changes: 3 additions & 3 deletions standalone/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pallet-vanchor = { path = "../../pallets/vanchor", default-features = false }
pallet-vanchor-handler = { path = "../../pallets/vanchor-handler", default-features = false }
pallet-vanchor-verifier = { path = "../../pallets/vanchor-verifier", default-features = false }
pallet-claims-verifier = { path = "../../pallets/claims-verifier", default-features = false }
pallet-anonimity-mining-claims = { path = "../../pallets/anonymity-mining-claims", default-features = false }
pallet-anonymity-mining-claims = { path = "../../pallets/anonymity-mining-claims", default-features = false }
pallet-verifier = { path = "../../pallets/verifier", default-features = false }
webb-primitives = { path = "../../primitives", default-features = false, features = ["hashing"] }

Expand Down Expand Up @@ -135,7 +135,7 @@ runtime-benchmarks = [
"pallet-token-wrapper-handler/runtime-benchmarks",
"pallet-relayer-registry/runtime-benchmarks",
"pallet-key-storage/runtime-benchmarks",
"pallet-anonimity-mining-claims/runtime-benchmarks",
"pallet-anonymity-mining-claims/runtime-benchmarks",
]

std = [
Expand Down Expand Up @@ -197,7 +197,7 @@ std = [
"pallet-verifier/std",
"pallet-vanchor-verifier/std",
"pallet-claims-verifier/std",
"pallet-anonimity-mining-claims/std",
"pallet-anonymity-mining-claims/std",
"pallet-mt/std",
"pallet-linkable-tree/std",
"pallet-mixer/std",
Expand Down
61 changes: 57 additions & 4 deletions standalone/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use webb_primitives::{
hashing::{ethereum::Keccak256HasherBn254, ArkworksPoseidonHasherBn254},
linkable_tree::LinkableTreeInspector,
signing::SignatureVerifier,
verifying::ArkworksVerifierBn254,
verifying::{ArkworksVerifierBn254, CircomVerifierBn254},
Amount, ChainId, LeafIndex,
};

Expand Down Expand Up @@ -1171,6 +1171,59 @@ impl pallet_vanchor_verifier::Config<pallet_vanchor_verifier::Instance1> for Run
type WeightInfo = pallet_vanchor_verifier::weights::WebbWeight<Runtime>;
}

impl pallet_claims_verifier::Config<pallet_claims_verifier::Instance1> for Runtime {
type RuntimeEvent = RuntimeEvent;
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
type Verifier = CircomVerifierBn254;
type MaxParameterLength = MaxParameterLength;
type WeightInfo = pallet_claims_verifier::weights::WebbWeight<Runtime>;
}

parameter_types! {
pub const PotId: PalletId = PalletId(*b"py/claim");
pub const APVanchorTreeId: u32 = 99;
pub const UnspentRootHistorySize: u32 = 30;
pub const SpentRootHistorySize: u32 = 30;
pub const RewardAssetId: AssetId = 2;
pub const AnonymityPointsAssetId: AssetId = 1;
pub const NativeCurrencyId: AssetId = 0;
pub const MaxAnchors: u32 = 2;
}

impl pallet_anonymity_mining_claims::Config<pallet_anonymity_mining_claims::Instance1> for Runtime {
// type RuntimeEvent = RuntimeEvent;
// // type PalletId = VAnchorPalletId;
// type APVanchorTreeId = VAnchorPalletId;
// type LinkableTree = LinkableTreeBn254;
// type VAnchorVerifier = VAnchorVerifier;
// type KeyStorage = KeyStorage;
// type EthereumHasher = Keccak256HasherBn254;
// type IntoField = ArkworksIntoFieldBn254;
// type Currency = Currencies;
// type MaxFee = MaxFee;
// type MaxExtAmount = MaxExtAmount;
// type MaxCurrencyId = MaxCurrencyId;
// type PostDepositHook = ();
// type ProposalNonce = u32;
// type NativeCurrencyId = GetNativeCurrencyId;
// type TokenWrapper = TokenWrapper;
// type WeightInfo = ();

type RuntimeEvent = RuntimeEvent;
type PotId = PotId;
type APVanchorTreeId = APVanchorTreeId;
type MaxAnchors = MaxAnchors;
type Currency = Currencies;
type VAnchor = VAnchorBn254;
type NativeCurrencyId = NativeCurrencyId;
type AnonymityPointsAssetId = AnonymityPointsAssetId;
type RewardAssetId = RewardAssetId;
type UnspentRootHistorySize = UnspentRootHistorySize;
type SpentRootHistorySize = SpentRootHistorySize;
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
type ClaimsVerifier = ClaimsVerifier;
}

parameter_types! {
#[derive(Copy, Clone, Debug, PartialEq, Eq, scale_info::TypeInfo)]
pub const MaxAssetIdInPool: u32 = 100;
Expand Down Expand Up @@ -1487,7 +1540,7 @@ construct_runtime!(
VAnchorBn254: pallet_vanchor::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},

// VAnchor
ClaimsBn254: pallet_anonimity_mining_claims::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},
ClaimsBn254: pallet_anonymity_mining_claims::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>},

// VAnchor Handler
VAnchorHandlerBn254: pallet_vanchor_handler::<Instance1>::{Pallet, Call, Storage, Event<T>},
Expand Down Expand Up @@ -1778,7 +1831,7 @@ impl_runtime_apis! {
list_benchmark!(list, extra, pallet_signature_bridge, SignatureBridge);
list_benchmark!(list, extra, pallet_relayer_registry, RelayerRegistry);
list_benchmark!(list, extra, pallet_key_storage, KeyStorage);
list_benchmark!(list, extra, pallet_anonimity_mining_claims, ClaimsBn254);
list_benchmark!(list, extra, pallet_anonymity_mining_claims, ClaimsBn254);

let storage_info = AllPalletsWithSystem::storage_info();

Expand Down Expand Up @@ -1818,7 +1871,7 @@ impl_runtime_apis! {
add_benchmark!(params, batches, pallet_signature_bridge, SignatureBridge);
add_benchmark!(params, batches, pallet_relayer_registry, RelayerRegistry);
add_benchmark!(params, batches, pallet_key_storage, KeyStorage);
add_benchmark!(params, batches, pallet_anonimity_mining_claims, ClaimsBn254);
add_benchmark!(params, batches, pallet_anonymity_mining_claims, ClaimsBn254);

if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
Ok(batches)
Expand Down

0 comments on commit 30c6e34

Please sign in to comment.