From 452b1dd1a142350bae1bb128b983ab7f0f9ae6db Mon Sep 17 00:00:00 2001 From: pifragile Date: Fri, 16 Jun 2023 18:10:42 +0200 Subject: [PATCH] Faucet (#333) * integrate faucet locally * benchmarking for faucet and reputation commitments * implement faucet cli * implement faucet integration tests * fix cli and weights * weights * clippy * unpatch pallets * taplo fmt * update cargo.lock --- Cargo.lock | 265 +++++++++++------- Cargo.toml | 36 +-- client/bootstrap_demo_community.py | 66 +++++ client/py_client/client.py | 20 ++ client/src/cli_args.rs | 133 ++++++++- client/src/main.rs | 246 +++++++++++++++- runtime/Cargo.toml | 9 +- runtime/src/lib.rs | 58 +++- runtime/src/weights/mod.rs | 3 + .../src/weights/pallet_encointer_faucet.rs | 120 ++++++++ ...pallet_encointer_reputation_commitments.rs | 50 ++++ runtime/src/weights/pallet_treasury.rs | 151 ++++++++++ scripts/benchmark_runtime.sh | 6 +- 13 files changed, 1033 insertions(+), 130 deletions(-) create mode 100644 runtime/src/weights/pallet_encointer_faucet.rs create mode 100644 runtime/src/weights/pallet_encointer_reputation_commitments.rs create mode 100644 runtime/src/weights/pallet_treasury.rs diff --git a/Cargo.lock b/Cargo.lock index 6bd90fec..4b0ccc00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,7 +15,7 @@ dependencies = [ [[package]] name = "ac-compose-macros" version = "0.4.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#2a479c447ec4f0041149af111d8ef99da4cb0d11" +source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#d17eb3389550e675350593829218e8949a7dd06b" dependencies = [ "ac-primitives", "log", @@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "ac-node-api" version = "0.4.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#2a479c447ec4f0041149af111d8ef99da4cb0d11" +source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#d17eb3389550e675350593829218e8949a7dd06b" dependencies = [ "ac-primitives", "bitvec", @@ -47,7 +47,7 @@ dependencies = [ [[package]] name = "ac-primitives" version = "0.7.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#2a479c447ec4f0041149af111d8ef99da4cb0d11" +source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#d17eb3389550e675350593829218e8949a7dd06b" dependencies = [ "frame-system", "impl-serde 0.4.0", @@ -83,7 +83,7 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli 0.27.2", + "gimli 0.27.3", ] [[package]] @@ -358,9 +358,9 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" +checksum = "8868f09ff8cea88b079da74ae569d9b8c62a23c68c746240b704ee6f7525c89c" [[package]] name = "asn1-rs" @@ -460,7 +460,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.19", + "rustix 0.37.20", "slab", "socket2 0.4.9", "waker-fn", @@ -656,7 +656,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.3", "constant_time_eq", ] @@ -667,7 +667,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.3", "constant_time_eq", ] @@ -678,7 +678,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" dependencies = [ "arrayref", - "arrayvec 0.7.2", + "arrayvec 0.7.3", "cc", "cfg-if 1.0.0", "constant_time_eq", @@ -741,9 +741,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "bounded-collections" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07fbd1d11282a1eb134d3c3b7cf8ce213b5161c6e5f73fb1b98618482c606b64" +checksum = "eb5b05133427c07c4776906f673ccf36c21b102c9829c641a5b56bd151d44fd6" dependencies = [ "log", "parity-scale-codec", @@ -1030,9 +1030,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.2" +version = "4.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "401a4694d2bf92537b6867d94de48c4842089645fdcdf6c71865b175d836e9c2" +checksum = "80672091db20273a15cf9fdd4e47ed43b5091ec9841bf4c6145c9dfbbcae09ed" dependencies = [ "clap_builder", "clap_derive", @@ -1050,9 +1050,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.1" +version = "4.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72394f3339a76daf211e57d4bcb374410f3965dcc606dd0e03738c7888766980" +checksum = "c1458a1df40e1e2afebb7ab60ce55c1fa8f431146205aa5f4887e0b111c27636" dependencies = [ "anstream", "anstyle", @@ -1123,9 +1123,9 @@ checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" [[package]] name = "constant_time_eq" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13418e745008f7349ec7e449155f419a61b92b58a99cc3616942b926825ec76b" +checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" [[package]] name = "convert_case" @@ -1191,7 +1191,7 @@ version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "253531aca9b6f56103c9420369db3263e784df39aa1c90685a1f69cfbba0623e" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.3", "bumpalo", "cranelift-bforest", "cranelift-codegen-meta", @@ -1337,22 +1337,22 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.14" +version = "0.9.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", "cfg-if 1.0.0", "crossbeam-utils", - "memoffset 0.8.0", + "memoffset 0.9.0", "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ "cfg-if 1.0.0", ] @@ -1478,9 +1478,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109308c20e8445959c2792e81871054c6a17e6976489a93d2769641a2ba5839c" +checksum = "e88abab2f5abbe4c56e8f1fb431b784d710b709888f35755a160e62e33fe38e8" dependencies = [ "cc", "cxxbridge-flags", @@ -1490,9 +1490,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daf4c6755cdf10798b97510e0e2b3edb9573032bd9379de8fffa59d68165494f" +checksum = "5c0c11acd0e63bae27dcd2afced407063312771212b7a823b4fd72d633be30fb" dependencies = [ "cc", "codespan-reporting", @@ -1505,15 +1505,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882074421238e84fe3b4c65d0081de34e5b323bf64555d3e61991f76eb64a7bb" +checksum = "8d3816ed957c008ccd4728485511e3d9aaf7db419aa321e3d2c5a2f3411e36c8" [[package]] name = "cxxbridge-macro" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a076022ece33e7686fb76513518e219cca4fce5750a8ae6d1ce6c0f48fd1af9" +checksum = "a26acccf6f445af85ea056362561a24ef56cdc15fcc685f03aec50b9c702cb6d" dependencies = [ "proc-macro2", "quote", @@ -1948,7 +1948,7 @@ dependencies = [ [[package]] name = "encointer-balances-tx-payment" version = "1.0.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "frame-support", @@ -1964,7 +1964,7 @@ dependencies = [ [[package]] name = "encointer-balances-tx-payment-rpc" version = "1.0.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-balances-tx-payment-rpc-runtime-api", "encointer-primitives", @@ -1988,7 +1988,7 @@ dependencies = [ [[package]] name = "encointer-balances-tx-payment-rpc-runtime-api" version = "1.0.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "frame-support", @@ -2001,7 +2001,7 @@ dependencies = [ [[package]] name = "encointer-ceremonies-assignment" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "sp-runtime", @@ -2045,7 +2045,7 @@ dependencies = [ [[package]] name = "encointer-meetup-validation" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "parity-scale-codec", @@ -2059,7 +2059,7 @@ dependencies = [ name = "encointer-node-notee" version = "1.3.3" dependencies = [ - "clap 4.3.2", + "clap 4.3.4", "encointer-balances-tx-payment-rpc", "encointer-balances-tx-payment-rpc-runtime-api", "encointer-node-notee-runtime", @@ -2135,6 +2135,8 @@ dependencies = [ "pallet-encointer-ceremonies-rpc-runtime-api", "pallet-encointer-communities", "pallet-encointer-communities-rpc-runtime-api", + "pallet-encointer-faucet", + "pallet-encointer-reputation-commitments", "pallet-encointer-scheduler", "pallet-grandpa", "pallet-insecure-randomness-collective-flip", @@ -2144,6 +2146,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", "pallet-utility", "parity-scale-codec", "scale-info", @@ -2167,11 +2170,12 @@ dependencies = [ [[package]] name = "encointer-primitives" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "bs58", "crc 2.1.0", "ep-core", + "frame-support", "geohash", "log", "parity-scale-codec", @@ -2186,7 +2190,7 @@ dependencies = [ [[package]] name = "encointer-rpc" version = "0.1.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "jsonrpsee", "thiserror", @@ -2239,7 +2243,7 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "ep-core" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "impl-serde 0.3.2", "parity-scale-codec", @@ -2510,7 +2514,7 @@ dependencies = [ "Inflector", "array-bytes", "chrono", - "clap 4.3.2", + "clap 4.3.4", "comfy-table", "frame-benchmarking", "frame-support", @@ -2743,7 +2747,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" dependencies = [ - "rustix 0.37.19", + "rustix 0.37.20", "windows-sys 0.48.0", ] @@ -3007,9 +3011,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" [[package]] name = "glob" @@ -3532,7 +3536,7 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.37.19", + "rustix 0.37.20", "windows-sys 0.48.0", ] @@ -3562,9 +3566,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" dependencies = [ "wasm-bindgen", ] @@ -3613,7 +3617,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" dependencies = [ "anyhow", - "arrayvec 0.7.2", + "arrayvec 0.7.3", "async-lock", "async-trait", "beef", @@ -3974,7 +3978,7 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2766dcd2be8c87d5e1f35487deb22d765f49c6ae1251b3633efe3b25698bd3d2" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.3", "asynchronous-codec", "bytes 1.4.0", "either", @@ -4403,9 +4407,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "lru" @@ -4517,7 +4521,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.19", + "rustix 0.37.20", ] [[package]] @@ -4540,9 +4544,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] @@ -4827,9 +4831,9 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.38" +version = "0.2.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d0df99cfcd2530b2e694f6e17e7f37b8e26bb23983ac530c0c97408837c631" +checksum = "b13b648036a2339d06de780866fbdfda0dde886de7b3af2ddeba8b14f4ee34ac" dependencies = [ "cfg-if 0.1.10", "libc", @@ -4962,7 +4966,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.3", "itoa", ] @@ -5221,7 +5225,7 @@ dependencies = [ [[package]] name = "pallet-encointer-balances" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "approx", "encointer-primitives", @@ -5240,7 +5244,7 @@ dependencies = [ [[package]] name = "pallet-encointer-bazaar" version = "1.1.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "frame-benchmarking", @@ -5257,7 +5261,7 @@ dependencies = [ [[package]] name = "pallet-encointer-bazaar-rpc" version = "1.0.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "encointer-rpc", @@ -5276,7 +5280,7 @@ dependencies = [ [[package]] name = "pallet-encointer-bazaar-rpc-runtime-api" version = "1.0.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "frame-support", @@ -5287,7 +5291,7 @@ dependencies = [ [[package]] name = "pallet-encointer-ceremonies" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-ceremonies-assignment", "encointer-meetup-validation", @@ -5312,7 +5316,7 @@ dependencies = [ [[package]] name = "pallet-encointer-ceremonies-rpc" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "encointer-rpc", @@ -5331,7 +5335,7 @@ dependencies = [ [[package]] name = "pallet-encointer-ceremonies-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "frame-support", @@ -5342,7 +5346,7 @@ dependencies = [ [[package]] name = "pallet-encointer-communities" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "frame-benchmarking", @@ -5361,7 +5365,7 @@ dependencies = [ [[package]] name = "pallet-encointer-communities-rpc" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "encointer-rpc", @@ -5380,17 +5384,60 @@ dependencies = [ [[package]] name = "pallet-encointer-communities-rpc-runtime-api" version = "1.2.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "sp-api", "sp-std", ] +[[package]] +name = "pallet-encointer-faucet" +version = "1.2.0" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" +dependencies = [ + "approx", + "encointer-primitives", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-encointer-communities", + "pallet-encointer-reputation-commitments", + "pallet-treasury", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-encointer-reputation-commitments" +version = "1.2.0" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" +dependencies = [ + "approx", + "encointer-primitives", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-encointer-ceremonies", + "pallet-encointer-communities", + "pallet-encointer-scheduler", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-encointer-scheduler" version = "1.1.0" -source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#91d488954798ddbafa6690da6cd2de81a6e3670c" +source = "git+https://github.com/encointer/pallets?branch=polkadot-v0.9.42#e443bdd15f38f76f01c1f17732ce8376708556f7" dependencies = [ "encointer-primitives", "frame-benchmarking", @@ -5570,6 +5617,23 @@ dependencies = [ "sp-weights", ] +[[package]] +name = "pallet-treasury" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#569aae5341ea0c1d10426fa1ec13a36c0b64393b" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -5611,7 +5675,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ - "arrayvec 0.7.2", + "arrayvec 0.7.3", "bitvec", "byte-slice-cast", "bytes 1.4.0", @@ -6634,9 +6698,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.37.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" dependencies = [ "bitflags", "errno", @@ -6673,9 +6737,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0167bac7a9f490495f3c33013e7722b53cb087ecbe082fb0c6387c96f634ea50" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -6828,7 +6892,7 @@ source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.4 dependencies = [ "array-bytes", "chrono", - "clap 4.3.2", + "clap 4.3.4", "fdlimit", "futures", "libp2p", @@ -7542,7 +7606,7 @@ name = "sc-storage-monitor" version = "0.1.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#569aae5341ea0c1d10426fa1ec13a36c0b64393b" dependencies = [ - "clap 4.3.2", + "clap 4.3.4", "fs4", "futures", "log", @@ -8950,7 +9014,7 @@ dependencies = [ [[package]] name = "substrate-api-client" version = "0.12.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#2a479c447ec4f0041149af111d8ef99da4cb0d11" +source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#d17eb3389550e675350593829218e8949a7dd06b" dependencies = [ "ac-compose-macros", "ac-node-api", @@ -8999,7 +9063,7 @@ dependencies = [ [[package]] name = "substrate-client-keystore" version = "0.9.0" -source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#2a479c447ec4f0041149af111d8ef99da4cb0d11" +source = "git+https://github.com/scs/substrate-api-client.git?branch=polkadot-v0.9.42#d17eb3389550e675350593829218e8949a7dd06b" dependencies = [ "array-bytes", "async-trait", @@ -9176,7 +9240,7 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.19", + "rustix 0.37.20", "windows-sys 0.48.0", ] @@ -9661,7 +9725,7 @@ version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.42#569aae5341ea0c1d10426fa1ec13a36c0b64393b" dependencies = [ "async-trait", - "clap 4.3.2", + "clap 4.3.4", "frame-remote-externalities", "frame-try-runtime", "hex", @@ -9852,9 +9916,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.3.3" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345444e32442451b267fc254ae85a209c64be56d2890e601a0c37ff0c3c5ecd2" +checksum = "0fa2982af2eec27de306107c027578ff7f423d65f7250e40ce0fea8f45248b81" dependencies = [ "getrandom 0.2.10", ] @@ -9916,11 +9980,10 @@ dependencies = [ [[package]] name = "want" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" dependencies = [ - "log", "try-lock", ] @@ -9944,9 +10007,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -9954,9 +10017,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" dependencies = [ "bumpalo", "log", @@ -9969,9 +10032,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.36" +version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d1985d03709c53167ce907ff394f5316aa22cb4e12761295c5dc57dacb6297e" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -9981,9 +10044,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9991,9 +10054,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", @@ -10004,9 +10067,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.86" +version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] name = "wasm-instrument" @@ -10298,9 +10361,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.63" +version = "0.3.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" dependencies = [ "js-sys", "wasm-bindgen", @@ -10815,9 +10878,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" +checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 30c13b9a..e5744e4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,23 +10,25 @@ members = [ ] #only while debugging -#[patch."https://github.com/encointer/pallets"] -#encointer-balances-tx-payment = { path = "../encointer-pallets/balances-tx-payment" } -#encointer-balances-tx-payment-rpc = { path = "../encointer-pallets/balances-tx-payment/rpc" } -#encointer-balances-tx-payment-rpc-runtime-api = { path = "../encointer-pallets/balances-tx-payment/rpc/runtime-api" } -#encointer-ceremonies-assignment = { path = "../encointer-pallets/ceremonies/assignment" } -#encointer-primitives = { path = "../encointer-pallets/primitives" } -#pallet-encointer-balances = { path = "../encointer-pallets/balances" } -#pallet-encointer-bazaar = { path = "../encointer-pallets/bazaar" } -#pallet-encointer-bazaar-rpc = { path = "../encointer-pallets/bazaar/rpc" } -#pallet-encointer-bazaar-rpc-runtime-api = { path = "../encointer-pallets/bazaar/rpc/runtime-api" } -#pallet-encointer-ceremonies = { path = "../encointer-pallets/ceremonies" } -#pallet-encointer-ceremonies-rpc = { path = "../encointer-pallets/ceremonies/rpc" } -#pallet-encointer-ceremonies-rpc-runtime-api = { path = "../encointer-pallets/ceremonies/rpc/runtime-api" } -#pallet-encointer-communities = { path = "../encointer-pallets/communities" } -#pallet-encointer-communities-rpc = { path = "../encointer-pallets/communities/rpc" } -#pallet-encointer-communities-rpc-runtime-api = { path = "../encointer-pallets/communities/rpc/runtime-api" } -#pallet-encointer-scheduler = { path = "../encointer-pallets/scheduler" } +[patch."https://github.com/encointer/pallets"] +# encointer-balances-tx-payment = { path = "../encointer-pallets/balances-tx-payment" } +# encointer-balances-tx-payment-rpc = { path = "../encointer-pallets/balances-tx-payment/rpc" } +# encointer-balances-tx-payment-rpc-runtime-api = { path = "../encointer-pallets/balances-tx-payment/rpc/runtime-api" } +# encointer-ceremonies-assignment = { path = "../encointer-pallets/ceremonies/assignment" } +# encointer-primitives = { path = "../encointer-pallets/primitives" } +# pallet-encointer-balances = { path = "../encointer-pallets/balances" } +# pallet-encointer-bazaar = { path = "../encointer-pallets/bazaar" } +# pallet-encointer-bazaar-rpc = { path = "../encointer-pallets/bazaar/rpc" } +# pallet-encointer-bazaar-rpc-runtime-api = { path = "../encointer-pallets/bazaar/rpc/runtime-api" } +# pallet-encointer-ceremonies = { path = "../encointer-pallets/ceremonies" } +# pallet-encointer-ceremonies-rpc = { path = "../encointer-pallets/ceremonies/rpc" } +# pallet-encointer-ceremonies-rpc-runtime-api = { path = "../encointer-pallets/ceremonies/rpc/runtime-api" } +# pallet-encointer-communities = { path = "../encointer-pallets/communities" } +# pallet-encointer-communities-rpc = { path = "../encointer-pallets/communities/rpc" } +# pallet-encointer-communities-rpc-runtime-api = { path = "../encointer-pallets/communities/rpc/runtime-api" } +# pallet-encointer-faucet = { path = "../encointer-pallets/faucet" } +# pallet-encointer-reputation-commitments = { path = "../encointer-pallets/reputation-commitments" } +# pallet-encointer-scheduler = { path = "../encointer-pallets/scheduler" } # [patch."https://github.com/scs/substrate-api-client"] # substrate-api-client = { path = "../substrate-api-client" } diff --git a/client/bootstrap_demo_community.py b/client/bootstrap_demo_community.py index c39befd3..82e73771 100755 --- a/client/bootstrap_demo_community.py +++ b/client/bootstrap_demo_community.py @@ -256,6 +256,70 @@ def test_endorsements_by_reputables(client, cid): # endorsee count is still 5 check_participant_count(client, cid, "Endorsee", 5) +def balance(x): + return x * 10**12 + + +def test_faucet(client, cid): + client.set_faucet_reserve_amount("//Alice", balance(3000)) + client.await_block(2) + balance_bob = client.balance("//Bob") + client.create_faucet("//Bob", "TestFaucet", balance(10000), balance(1000), [cid], cid=cid, pay_fees_in_cc=True) + client.await_block(2) + faucet_account = "5CRaq3MpDT1j1d7xoaG3LDwqgC5AoTzRtGptSHm2yFrWoVid" + print(client.balance("//Bob"), flush=True) + print(balance_bob, flush=True) + print(client.balance(faucet_account), flush=True) + if(not client.balance(faucet_account) == balance(10000)): + print(f"Wrong Faucet balance after faucet creation") + exit(1) + if(not balance_bob - client.balance("//Bob") == balance(13000)): + print(f"Wrong Bob balance after faucet creation") + exit(1) + print('Faucet created', flush=True) + + balance_charlie = client.balance("//Charlie") + client.drip_faucet("//Charlie", faucet_account, 1, cid=cid, pay_fees_in_cc=True) + client.await_block(2) + if(not client.balance("//Charlie") == balance_charlie + balance(1000)): + print(f"Drip failed") + exit(1) + print('Faucet dripped', flush=True) + + balance_bob = client.balance("//Bob") + client.dissolve_faucet("//Alice", faucet_account, "//Eve") + client.await_block(2) + + if(not client.balance("//Eve") == balance(9000)): + print(f"Dissolve failed") + exit(1) + + if(not client.balance("//Bob") == balance_bob + balance(3000)): + print(f"Dissolve failed") + exit(1) + + print('Faucet dissolved', flush=True) + client.create_faucet("//Bob", "TestFaucet", balance(10000), balance(9000), [cid], cid=cid, pay_fees_in_cc=True) + client.await_block(2) + if(not client.balance(faucet_account) == balance(10000)): + print(f"Faucet creation failed") + exit(1) + print('Faucet created', flush=True) + client.drip_faucet("//Charlie", faucet_account, 1, cid=cid, pay_fees_in_cc=True) + client.await_block(2) + print('Faucet dripped', flush=True) + balance_bob = client.balance("//Bob") + client.close_faucet("//Bob", faucet_account, cid=cid, pay_fees_in_cc=True) + client.await_block(2) + if(not client.balance(faucet_account) == 0): + print(f"Faucet closing failed with wrong faucet balance") + exit(1) + + if(not client.balance("//Bob") == balance_bob + balance(3000)): + print(f"Faucet closing failed with wrong bob balance") + exit(1) + print('Faucet closed', flush=True) + @click.command() @click.option('--client', default='../target/release/encointer-client-notee', help='Client binary to communicate with the chain.') @click.option('-u', '--url', default='ws://127.0.0.1', help='URL of the chain.') @@ -312,6 +376,8 @@ def main(ipfs_local, client, url, port, spec_file, test): print("claim_reward fees were not refunded if paid in cc") exit(1) + test_faucet(client, cid) + fee_payment_transfers(client, cid) test_reputation_caching(client, cid, accounts) diff --git a/client/py_client/client.py b/client/py_client/client.py index cf7244ac..89fa479c 100644 --- a/client/py_client/client.py +++ b/client/py_client/client.py @@ -253,3 +253,23 @@ def transfer(self, cid, source, dest, amount, pay_fees_in_cc=False): def purge_community_ceremony(self, cid, from_cindex, to_cindex, pay_fees_in_cc=False): ret = self.run_cli_command(["purge-community-ceremony", str(from_cindex), str(to_cindex)], cid, pay_fees_in_cc) return ret.stdout.decode("utf-8").strip() + + def create_faucet(self, account, facuet_name, amount, drip_amount, whitelist, cid=None, pay_fees_in_cc=False): + ret = self.run_cli_command(["create-faucet", account, facuet_name, str(amount), str(drip_amount)] + whitelist, cid, pay_fees_in_cc) + return ret.stdout.decode("utf-8").strip() + + def drip_faucet(self, account, facuet_account, cindex, cid=None, pay_fees_in_cc=False): + ret = self.run_cli_command(["drip-faucet", account, facuet_account, str(cindex)], cid, pay_fees_in_cc) + return ret.stdout.decode("utf-8").strip() + + def dissolve_faucet(self, account, facuet_account, beneficiary, cid=None, pay_fees_in_cc=False): + ret = self.run_cli_command(["dissolve-faucet", "--signer", account, facuet_account, beneficiary], cid, pay_fees_in_cc) + return ret.stdout.decode("utf-8").strip() + + def close_faucet(self, account, facuet_account, cid=None, pay_fees_in_cc=False): + ret = self.run_cli_command(["close-faucet", account, facuet_account], cid, pay_fees_in_cc) + return ret.stdout.decode("utf-8").strip() + + def set_faucet_reserve_amount(self, account, amount, cid=None, pay_fees_in_cc=False): + ret = self.run_cli_command(["set-faucet-reserve-amount", "--signer", account, str(amount)], cid, pay_fees_in_cc) + return ret.stdout.decode("utf-8").strip() \ No newline at end of file diff --git a/client/src/cli_args.rs b/client/src/cli_args.rs index 2afe5d94..83f18b6e 100644 --- a/client/src/cli_args.rs +++ b/client/src/cli_args.rs @@ -2,16 +2,21 @@ use clap::{App, Arg, ArgMatches}; use sp_core::{bytes, H256 as Hash}; const ACCOUNT_ARG: &str = "accountid"; +const FAUCET_ACCOUNT_ARG: &str = "faucet-account"; +const FAUCET_BENEFICIARY_ARG: &str = "faucet-beneficiary"; const SEED_ARG: &str = "seed"; const SIGNER_ARG: &str = "signer"; const CID_ARG: &str = "cid"; const ATTESTEES_ARG: &str = "attestees"; +const WHITELIST_ARG: &str = "whitelist"; const CEREMONY_INDEX_ARG: &str = "ceremony-index"; const IPFS_CID_ARG: &str = "ipfs-cid"; +const FAUCET_NAME_ARG: &str = "faucet-name"; const BOOTSTRAPPER_ARG: &str = "bootstrapper"; const FUNDEES_ARG: &str = "fundees"; const FROM_CINDEX_ARG: &str = "from-cindex"; const TO_CINDEX_ARG: &str = "to-cindex"; +const CINDEX_ARG: &str = "cindex"; const ENDORSEES_ARG: &str = "endorsees"; const TIME_OFFSET_ARG: &str = "time-offset"; const ALL_FLAG: &str = "all"; @@ -19,20 +24,28 @@ const DRYRUN_FLAG: &str = "dryrun"; const TX_PAYMENT_CID_ARG: &str = "tx-payment-cid"; const MEETUP_INDEX_ARG: &str = "meetup-index"; const AT_BLOCK_ARG: &str = "at"; +const FAUCET_BALANCE_ARG: &str = "faucet-balance"; +const FAUCET_DRIP_AMOUNT_ARG: &str = "faucet-drip-amount"; +const FAUCET_RESERVE_AMOUNT_ARG: &str = "faucet-reserve-amount"; pub trait EncointerArgs<'b> { fn account_arg(self) -> Self; + fn faucet_account_arg(self) -> Self; + fn faucet_beneficiary_arg(self) -> Self; fn seed_arg(self) -> Self; fn signer_arg(self, help: &'b str) -> Self; fn optional_cid_arg(self) -> Self; fn attestees_arg(self) -> Self; + fn whitelist_arg(self) -> Self; fn ceremony_index_arg(self) -> Self; fn ipfs_cid_arg(self) -> Self; + fn faucet_name_arg(self) -> Self; fn bootstrapper_arg(self) -> Self; fn fundees_arg(self) -> Self; #[allow(clippy::wrong_self_convention)] fn from_cindex_arg(self) -> Self; fn to_cindex_arg(self) -> Self; + fn cindex_arg(self) -> Self; fn endorsees_arg(self) -> Self; fn time_offset_arg(self) -> Self; fn all_flag(self) -> Self; @@ -40,21 +53,29 @@ pub trait EncointerArgs<'b> { fn tx_payment_cid_arg(self) -> Self; fn meetup_index_arg(self) -> Self; fn at_block_arg(self) -> Self; + fn faucet_balance_arg(self) -> Self; + fn faucet_drip_amount_arg(self) -> Self; + fn faucet_reserve_amount_arg(self) -> Self; } pub trait EncointerArgsExtractor { fn account_arg(&self) -> Option<&str>; + fn faucet_account_arg(&self) -> Option<&str>; + fn faucet_beneficiary_arg(&self) -> Option<&str>; fn seed_arg(&self) -> Option<&str>; fn signer_arg(&self) -> Option<&str>; fn cid_arg(&self) -> Option<&str>; fn attestees_arg(&self) -> Option>; + fn whitelist_arg(&self) -> Option>; fn ceremony_index_arg(&self) -> Option; fn ipfs_cid_arg(&self) -> Option<&str>; + fn faucet_name_arg(&self) -> Option<&str>; fn bootstrapper_arg(&self) -> Option<&str>; fn fundees_arg(&self) -> Option>; #[allow(clippy::wrong_self_convention)] fn from_cindex_arg(&self) -> Option; fn to_cindex_arg(&self) -> Option; + fn cindex_arg(&self) -> Option; fn endorsees_arg(&self) -> Option>; fn time_offset_arg(&self) -> Option; fn all_flag(&self) -> bool; @@ -62,6 +83,9 @@ pub trait EncointerArgsExtractor { fn tx_payment_cid_arg(&self) -> Option<&str>; fn meetup_index_arg(&self) -> Option; fn at_block_arg(&self) -> Option; + fn faucet_balance_arg(&self) -> Option; + fn faucet_drip_amount_arg(&self) -> Option; + fn faucet_reserve_amount_arg(&self) -> Option; } impl<'a, 'b> EncointerArgs<'b> for App<'a, 'b> { @@ -75,6 +99,26 @@ impl<'a, 'b> EncointerArgs<'b> for App<'a, 'b> { ) } + fn faucet_account_arg(self) -> Self { + self.arg( + Arg::with_name(FAUCET_ACCOUNT_ARG) + .takes_value(true) + .required(true) + .value_name("SS58") + .help("faucet account in ss58check format"), + ) + } + + fn faucet_beneficiary_arg(self) -> Self { + self.arg( + Arg::with_name(FAUCET_BENEFICIARY_ARG) + .takes_value(true) + .required(true) + .value_name("SS58") + .help("faucet account in ss58check format"), + ) + } + fn seed_arg(self) -> Self { self.arg( Arg::with_name(SEED_ARG) @@ -120,6 +164,16 @@ impl<'a, 'b> EncointerArgs<'b> for App<'a, 'b> { ) } + fn whitelist_arg(self) -> Self { + self.arg( + Arg::with_name(WHITELIST_ARG) + .takes_value(true) + .required(true) + .multiple(true) + .min_values(1), + ) + } + fn ceremony_index_arg(self) -> Self { self.arg( Arg::with_name(CEREMONY_INDEX_ARG) @@ -142,6 +196,16 @@ impl<'a, 'b> EncointerArgs<'b> for App<'a, 'b> { ) } + fn faucet_name_arg(self) -> Self { + self.arg( + Arg::with_name(FAUCET_NAME_ARG) + .required(true) + .takes_value(true) + .value_name("STRING") + .help("faucet name"), + ) + } + fn bootstrapper_arg(self) -> Self { self.arg( Arg::with_name(BOOTSTRAPPER_ARG) @@ -181,6 +245,15 @@ impl<'a, 'b> EncointerArgs<'b> for App<'a, 'b> { .help("last ceremony index to be purged"), ) } + fn cindex_arg(self) -> Self { + self.arg( + Arg::with_name(CINDEX_ARG) + .takes_value(true) + .required(true) + .value_name("CINDEX") + .help("cindex"), + ) + } fn endorsees_arg(self) -> Self { self.arg( Arg::with_name(ENDORSEES_ARG) @@ -257,6 +330,35 @@ impl<'a, 'b> EncointerArgs<'b> for App<'a, 'b> { .help("block hash at which to query"), ) } + + fn faucet_balance_arg(self) -> Self { + self.arg( + Arg::with_name(FAUCET_BALANCE_ARG) + .takes_value(true) + .required(true) + .value_name("FAUCET_BALANCE") + .help("faucet balance"), + ) + } + + fn faucet_drip_amount_arg(self) -> Self { + self.arg( + Arg::with_name(FAUCET_DRIP_AMOUNT_ARG) + .takes_value(true) + .required(true) + .value_name("FAUCET_DRIP_AMOUNT") + .help("faucet drip amount"), + ) + } + fn faucet_reserve_amount_arg(self) -> Self { + self.arg( + Arg::with_name(FAUCET_RESERVE_AMOUNT_ARG) + .takes_value(true) + .required(true) + .value_name("FAUCET_RESERVE_AMOUNT") + .help("faucet reserve amount"), + ) + } } impl<'a> EncointerArgsExtractor for ArgMatches<'a> { @@ -264,6 +366,14 @@ impl<'a> EncointerArgsExtractor for ArgMatches<'a> { self.value_of(ACCOUNT_ARG) } + fn faucet_account_arg(&self) -> Option<&str> { + self.value_of(FAUCET_ACCOUNT_ARG) + } + + fn faucet_beneficiary_arg(&self) -> Option<&str> { + self.value_of(FAUCET_BENEFICIARY_ARG) + } + fn seed_arg(&self) -> Option<&str> { self.value_of(SEED_ARG) } @@ -280,6 +390,10 @@ impl<'a> EncointerArgsExtractor for ArgMatches<'a> { self.values_of(ATTESTEES_ARG).map(|c| c.collect()) } + fn whitelist_arg(&self) -> Option> { + self.values_of(WHITELIST_ARG).map(|c| c.collect()) + } + fn ceremony_index_arg(&self) -> Option { self.value_of(CEREMONY_INDEX_ARG).map(|v| v.parse().unwrap()) } @@ -288,6 +402,10 @@ impl<'a> EncointerArgsExtractor for ArgMatches<'a> { self.value_of(IPFS_CID_ARG) } + fn faucet_name_arg(&self) -> Option<&str> { + self.value_of(FAUCET_NAME_ARG) + } + fn bootstrapper_arg(&self) -> Option<&str> { self.value_of(BOOTSTRAPPER_ARG) } @@ -302,7 +420,9 @@ impl<'a> EncointerArgsExtractor for ArgMatches<'a> { fn to_cindex_arg(&self) -> Option { self.value_of(TO_CINDEX_ARG).map(|v| v.parse().unwrap()) } - + fn cindex_arg(&self) -> Option { + self.value_of(CINDEX_ARG).map(|v| v.parse().unwrap()) + } fn endorsees_arg(&self) -> Option> { self.values_of(ENDORSEES_ARG).map(|v| v.collect()) } @@ -327,9 +447,18 @@ impl<'a> EncointerArgsExtractor for ArgMatches<'a> { let vec = bytes::from_hex(hex) .unwrap_or_else(|_| panic!("bytes::from_hex failed, data is: {hex}")); if vec.len() != 32 { - panic!("in at_block_arg fn, vec is: {:#?}", vec); + panic!("in at_block_arg fn, vec is: {vec:#?}"); } Hash::from_slice(&vec) }) } + fn faucet_balance_arg(&self) -> Option { + self.value_of(FAUCET_BALANCE_ARG).map(|v| v.parse().unwrap()) + } + fn faucet_drip_amount_arg(&self) -> Option { + self.value_of(FAUCET_DRIP_AMOUNT_ARG).map(|v| v.parse().unwrap()) + } + fn faucet_reserve_amount_arg(&self) -> Option { + self.value_of(FAUCET_RESERVE_AMOUNT_ARG).map(|v| v.parse().unwrap()) + } } diff --git a/client/src/main.rs b/client/src/main.rs index 104d6fb2..b7bd2076 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -56,14 +56,17 @@ use encointer_primitives::{ MeetupIndexType, ParticipantIndexType, ProofOfAttendance, Reputation, }, communities::{CidName, CommunityIdentifier}, + faucet::{FaucetNameType, FromStr as FaucetNameFromStr, WhiteListType}, fixed::transcendental::exp, scheduler::{CeremonyIndexType, CeremonyPhaseType}, }; use log::*; +use pallet_transaction_payment::FeeDetails; use sp_application_crypto::{ed25519, sr25519}; use sp_core::{crypto::Ss58Codec, sr25519 as sr25519_core, Pair}; use sp_keyring::AccountKeyring; use sp_keystore::Keystore; +use sp_rpc::number::NumberOrHex; use sp_runtime::MultiSignature; use std::{collections::HashMap, path::PathBuf, str::FromStr}; use substrate_api_client::{ @@ -77,9 +80,6 @@ use substrate_api_client::{ }; use substrate_client_keystore::{KeystoreExt, LocalKeystore}; -use pallet_transaction_payment::FeeDetails; -use sp_rpc::number::NumberOrHex; - const PREFUNDING_NR_OF_TRANSFER_EXTRINSICS: u128 = 1000; const VERSION: &str = env!("CARGO_PKG_VERSION"); @@ -1560,6 +1560,242 @@ async fn main() { Ok(()) }), ) + .add_cmd( + Command::new("create-faucet") + .description("Create faucet") + .options(|app| { + app.setting(AppSettings::ColoredHelp) + .account_arg() + .faucet_name_arg() + .faucet_balance_arg() + .faucet_drip_amount_arg() + .whitelist_arg() + }) + .runner(move |_args: &str, matches: &ArgMatches<'_>| { + let who = matches.account_arg().map(get_pair_from_str).unwrap(); + + let mut api = get_chain_api(matches); + api.set_signer(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from( + who.clone(), + ))); + + let faucet_name_raw = matches.faucet_name_arg().unwrap(); + let faucet_balance = matches.faucet_balance_arg().unwrap(); + let drip_amount = matches.faucet_drip_amount_arg().unwrap(); + + let whitelist_vec: Vec<_> = matches.whitelist_arg().unwrap() + .into_iter() + .map(|c| verify_cid(&api, + c, + None)) + .collect(); + let whitelist: WhiteListType = WhiteListType::try_from(whitelist_vec).unwrap(); + + let faucet_name = FaucetNameType::from_str(faucet_name_raw).unwrap(); + let tx_payment_cid_arg = matches.tx_payment_cid_arg(); + set_api_extrisic_params_builder(&mut api, tx_payment_cid_arg); + + + let xt: EncointerXt<_> = compose_extrinsic!( + api, + "EncointerFaucet", + "create_faucet", + faucet_name, + faucet_balance, + whitelist, + drip_amount + ); + + ensure_payment(&api, &xt.encode().into(), tx_payment_cid_arg); + let report = api.submit_and_watch_extrinsic_until(xt, XtStatus::Ready).unwrap(); + println!("Faucet created by {}. status: '{:?}'", who.public(), report.status); + Ok(()) + }), + ) + .add_cmd( + Command::new("drip-faucet") + .description("Drip faucet") + .options(|app| { + app.setting(AppSettings::ColoredHelp) + .account_arg() + .faucet_account_arg() + .cindex_arg() + }) + .runner(move |_args: &str, matches: &ArgMatches<'_>| { + let who = matches.account_arg().map(get_pair_from_str).unwrap(); + + let mut api = get_chain_api(matches); + api.set_signer(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from( + who.clone(), + ))); + + let cid = verify_cid(&api, matches.cid_arg().expect("please supply argument --cid"), None); + + let cindex = matches.cindex_arg().unwrap(); + let faucet_account = get_accountid_from_str(matches.faucet_account_arg().unwrap()); + + let tx_payment_cid_arg = matches.tx_payment_cid_arg(); + set_api_extrisic_params_builder(&mut api, tx_payment_cid_arg); + + let xt: EncointerXt<_> = compose_extrinsic!( + api, + "EncointerFaucet", + "drip", + faucet_account, + cid, + cindex + ); + + + ensure_payment(&api, &xt.encode().into(), tx_payment_cid_arg); + let report = api.submit_and_watch_extrinsic_until(xt, XtStatus::Ready).unwrap(); + + println!("Faucet dripped to {}. status: '{:?}'", who.public(), report.status); + Ok(()) + }), + ) + .add_cmd( + Command::new("dissolve-faucet") + .description("Dissolve faucet") + .options(|app| { + app.setting(AppSettings::ColoredHelp) + .signer_arg("account with necessary privileges (sudo or councillor)") + .faucet_account_arg() + .faucet_beneficiary_arg() + }) + .runner(|_args: &str, matches: &ArgMatches<'_>| { + let signer = matches.signer_arg() + .map_or_else(|| AccountKeyring::Alice.pair(), |signer| get_pair_from_str(signer).into()); + let signer = ParentchainExtrinsicSigner::new(signer); + + let faucet_account = get_accountid_from_str(matches.faucet_account_arg().unwrap()); + let beneficiary = get_accountid_from_str(matches.faucet_beneficiary_arg().unwrap()); + + let mut api = get_chain_api(matches); + api.set_signer(signer); + + + let dissolve_faucet_call = compose_call!( + api.metadata(), + "EncointerFaucet", + "dissolve_faucet", + faucet_account.clone(), + beneficiary + ); + + // return calls as `OpaqueCall`s to get the same return type in both branches + let dissolve_faucet_call = if contains_sudo_pallet(api.metadata()) { + let dissolve_faucet_call = sudo_call(api.metadata(), dissolve_faucet_call); + info!("Printing raw sudo call for js/apps:"); + print_raw_call("sudo(dissolve_faucet)", &dissolve_faucet_call); + + OpaqueCall::from_tuple(&dissolve_faucet_call) + + } else { + let threshold = (get_councillors(&api).unwrap().len() / 2 + 1) as u32; + info!("Printing raw collective propose calls with threshold {} for js/apps", threshold); + let propose_dissolve_faucet = collective_propose_call(api.metadata(), threshold, dissolve_faucet_call); + print_raw_call("collective_propose(dissolve_faucet)", &propose_dissolve_faucet); + + OpaqueCall::from_tuple(&propose_dissolve_faucet) + }; + + let tx_payment_cid_arg = matches.tx_payment_cid_arg(); + set_api_extrisic_params_builder(&mut api, tx_payment_cid_arg); + + send_and_wait_for_in_block(&api, xt(&api, dissolve_faucet_call), tx_payment_cid_arg); + + println!("Faucet dissolved: {faucet_account:?}"); + Ok(()) + }), + ) + .add_cmd( + Command::new("close-faucet") + .description("Close faucet") + .options(|app| { + app.setting(AppSettings::ColoredHelp) + .account_arg() + .faucet_account_arg() + }) + .runner(move |_args: &str, matches: &ArgMatches<'_>| { + let who = matches.account_arg().map(get_pair_from_str).unwrap(); + + let mut api = get_chain_api(matches); + api.set_signer(ParentchainExtrinsicSigner::new(sr25519_core::Pair::from( + who, + ))); + + let faucet_account = get_accountid_from_str(matches.faucet_account_arg().unwrap()); + + let tx_payment_cid_arg = matches.tx_payment_cid_arg(); + set_api_extrisic_params_builder(&mut api, tx_payment_cid_arg); + + let xt: EncointerXt<_> = compose_extrinsic!( + api, + "EncointerFaucet", + "close_faucet", + faucet_account.clone() + ); + + + ensure_payment(&api, &xt.encode().into(), tx_payment_cid_arg); + let report = api.submit_and_watch_extrinsic_until(xt, XtStatus::Ready).unwrap(); + + println!("Faucet closed: {faucet_account}. status: '{:?}'", report.status); + Ok(()) + }), + ) + .add_cmd( + Command::new("set-faucet-reserve-amount") + .description("Set faucet pallet reserve amount") + .options(|app| { + app.setting(AppSettings::ColoredHelp) + .signer_arg("account with necessary privileges (sudo or councillor)") + .faucet_reserve_amount_arg() + }) + .runner(|_args: &str, matches: &ArgMatches<'_>| { + let signer = matches.signer_arg() + .map_or_else(|| AccountKeyring::Alice.pair(), |signer| get_pair_from_str(signer).into()); + let signer = ParentchainExtrinsicSigner::new(signer); + + let reserve_amount = matches.faucet_reserve_amount_arg().unwrap(); + + let mut api = get_chain_api(matches); + api.set_signer(signer); + + + let set_reserve_amount_call = compose_call!( + api.metadata(), + "EncointerFaucet", + "set_reserve_amount", + reserve_amount + ); + // return calls as `OpaqueCall`s to get the same return type in both branches + let set_reserve_amount_call = if contains_sudo_pallet(api.metadata()) { + let set_reserve_amount_call = sudo_call(api.metadata(), set_reserve_amount_call); + info!("Printing raw sudo call for js/apps:"); + print_raw_call("sudo(set_reserve_amount)", &set_reserve_amount_call); + + OpaqueCall::from_tuple(&set_reserve_amount_call) + + } else { + let threshold = (get_councillors(&api).unwrap().len() / 2 + 1) as u32; + info!("Printing raw collective propose calls with threshold {} for js/apps", threshold); + let propose_set_reserve_amount = collective_propose_call(api.metadata(), threshold, set_reserve_amount_call); + print_raw_call("collective_propose(set_reserve_amount)", &propose_set_reserve_amount); + + OpaqueCall::from_tuple(&propose_set_reserve_amount) + }; + + let tx_payment_cid_arg = matches.tx_payment_cid_arg(); + set_api_extrisic_params_builder(&mut api, tx_payment_cid_arg); + + send_and_wait_for_in_block(&api, xt(&api, set_reserve_amount_call), tx_payment_cid_arg); + + println!("Reserve amount set: {reserve_amount:?}"); + Ok(()) + }), + ) // To handle when no subcommands match .no_cmd(|_args, _matches| { println!("No subcommand matched"); @@ -2012,8 +2248,8 @@ fn endorse_newcomers( let call = compose_call!(api.metadata(), "EncointerCeremonies", "endorse_newcomer", cid, endorsee); - let encoded_xt: Bytes = offline_xt(&api, call, nonce).encode().into(); - ensure_payment(&api, &encoded_xt, tx_payment_cid_arg); + let encoded_xt: Bytes = offline_xt(api, call, nonce).encode().into(); + ensure_payment(api, &encoded_xt, tx_payment_cid_arg); let _tx_report = api .submit_and_watch_opaque_extrinsic_until(encoded_xt, XtStatus::Ready) .unwrap(); diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index b817847d..28db412a 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -26,6 +26,8 @@ pallet-encointer-ceremonies = { default-features = false, git = "https://github. pallet-encointer-ceremonies-rpc-runtime-api = { default-features = false, git = "https://github.com/encointer/pallets", branch = "polkadot-v0.9.42" } pallet-encointer-communities = { default-features = false, git = "https://github.com/encointer/pallets", branch = "polkadot-v0.9.42" } pallet-encointer-communities-rpc-runtime-api = { default-features = false, git = "https://github.com/encointer/pallets", branch = "polkadot-v0.9.42" } +pallet-encointer-faucet = { default-features = false, git = "https://github.com/encointer/pallets", branch = "polkadot-v0.9.42" } +pallet-encointer-reputation-commitments = { default-features = false, git = "https://github.com/encointer/pallets", branch = "polkadot-v0.9.42" } pallet-encointer-scheduler = { default-features = false, git = "https://github.com/encointer/pallets", branch = "polkadot-v0.9.42" } # substrate deps @@ -42,6 +44,7 @@ pallet-scheduler = { version = "4.0.0-dev", default-features = false, git = "htt pallet-sudo = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } pallet-transaction-payment = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } +pallet-treasury = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } pallet-utility = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } sp-api = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } sp-block-builder = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" } @@ -92,6 +95,7 @@ std = [ "pallet-timestamp/std", "pallet-transaction-payment-rpc-runtime-api/std", "pallet-transaction-payment/std", + "pallet-treasury/std", "sp-api/std", "sp-block-builder/std", "sp-consensus-aura/std", @@ -114,8 +118,9 @@ std = [ "pallet-encointer-ceremonies-rpc-runtime-api/std", "pallet-encointer-communities/std", "pallet-encointer-communities-rpc-runtime-api/std", + "pallet-encointer-faucet/std", + "pallet-encointer-reputation-commitments/std", "pallet-encointer-scheduler/std", - #"frame-try-runtime?/std", "frame-try-runtime/std", ] runtime-benchmarks = [ @@ -133,6 +138,8 @@ runtime-benchmarks = [ "pallet-encointer-bazaar/runtime-benchmarks", "pallet-encointer-ceremonies/runtime-benchmarks", "pallet-encointer-communities/runtime-benchmarks", + "pallet-encointer-faucet/runtime-benchmarks", + "pallet-encointer-reputation-commitments/runtime-benchmarks", "pallet-encointer-scheduler/runtime-benchmarks", ] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 541fc091..bfe8177d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -39,7 +39,7 @@ pub use frame_support::{ }, IdentityFee, Weight, }, - StorageValue, + PalletId, StorageValue, }; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; @@ -53,6 +53,8 @@ pub use pallet_encointer_balances::Call as EncointerBalancesCall; pub use pallet_encointer_bazaar::Call as EncointerBazaarCall; pub use pallet_encointer_ceremonies::Call as EncointerCeremoniesCall; pub use pallet_encointer_communities::Call as EncointerCommunitiesCall; +pub use pallet_encointer_faucet::Call as EncointerFaucetCall; +pub use pallet_encointer_reputation_commitments::Call as EncointerReputationCommitmentsCall; pub use pallet_encointer_scheduler::Call as EncointerSchedulerCall; pub use encointer_balances_tx_payment::{AssetBalanceOf, AssetIdOf, BalanceToCommunityBalance}; @@ -94,6 +96,9 @@ pub const ONE_DAY: Moment = 86_400_000; pub type AssetId = AssetIdOf; pub type AssetBalance = AssetBalanceOf; +const MILLICENTS: Balance = 1_000_000_000; +const CENTS: Balance = 1_000 * MILLICENTS; + /// Opaque types. These are used by the CLI to instantiate machinery that don't need to know /// the specifics of the runtime. They can then be made to be agnostic over specific formats /// of data like extrinsics, allowing for them to continue syncing the network through upgrades @@ -347,7 +352,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type MaxLocks = MaxLocks; - type MaxReserves = (); + type MaxReserves = ConstU32<128>; type ReserveIdentifier = [u8; 8]; /// The type for recording an account's balance. type Balance = Balance; @@ -416,6 +421,7 @@ parameter_types! { pub const MeetupSizeTarget: u64 = 10; pub const MeetupMinSize: u64 = 3; pub const MeetupNewbieLimitDivider: u64 = 2; + pub const FaucetPalletId: PalletId = PalletId(*b"ectrfct0"); } impl pallet_encointer_scheduler::Config for Runtime { @@ -474,6 +480,48 @@ impl pallet_asset_tx_payment::Config for Runtime { >; } +parameter_types! { + pub const ProposalBond: Permill = Permill::from_percent(5); + pub const ProposalBondMinimum: Balance = 100 * MILLICENTS; + pub const ProposalBondMaximum: Balance = 500 * CENTS; + pub const SpendPeriod: BlockNumber = 6 * DAYS; + pub const Burn: Permill = Permill::from_percent(1); + pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry"); + pub const MaxApprovals: u32 = 10; +} + +impl pallet_treasury::Config for Runtime { + type PalletId = TreasuryPalletId; + type Currency = pallet_balances::Pallet; + type ApproveOrigin = EnsureRoot; + type RejectOrigin = EnsureRoot; + type RuntimeEvent = RuntimeEvent; + type OnSlash = (); //No proposal + type ProposalBond = ProposalBond; + type ProposalBondMinimum = ProposalBondMinimum; + type ProposalBondMaximum = ProposalBondMaximum; + type SpendPeriod = SpendPeriod; //Cannot be 0: Error: Thread 'tokio-runtime-worker' panicked at 'attempt to calculate the remainder with a divisor of zero + type Burn = (); //No burn + type BurnDestination = (); //No burn + type SpendFunds = (); //No spend, no bounty + type MaxApprovals = MaxApprovals; + type WeightInfo = weights::pallet_treasury::WeightInfo; + type SpendOrigin = frame_support::traits::NeverEnsureOrigin; //No spend, no bounty +} + +impl pallet_encointer_reputation_commitments::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type WeightInfo = weights::pallet_encointer_reputation_commitments::WeightInfo; +} + +impl pallet_encointer_faucet::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type ControllerOrigin = EnsureRoot; + type Currency = Balances; + type PalletId = FaucetPalletId; + type WeightInfo = weights::pallet_encointer_faucet::WeightInfo; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub struct Runtime where @@ -497,12 +545,15 @@ construct_runtime!( Utility: pallet_utility::{Pallet, Call, Event} = 40, Proxy: pallet_proxy::{Pallet, Call, Storage, Event} = 44, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 48, + Treasury: pallet_treasury::{Pallet, Call, Storage, Event} = 49, EncointerScheduler: pallet_encointer_scheduler::{Pallet, Call, Storage, Config, Event} = 60, EncointerCeremonies: pallet_encointer_ceremonies::{Pallet, Call, Storage, Config, Event} = 61, EncointerCommunities: pallet_encointer_communities::{Pallet, Call, Storage, Config, Event} = 62, EncointerBalances: pallet_encointer_balances::{Pallet, Call, Storage, Config, Event} = 63, EncointerBazaar: pallet_encointer_bazaar::{Pallet, Call, Storage, Event} = 64, + EncointerReputationCommitments: pallet_encointer_reputation_commitments::{Pallet, Call, Storage, Event} = 65, + EncointerFaucet: pallet_encointer_faucet::{Pallet, Call, Storage, Event} = 66, } ); @@ -559,7 +610,10 @@ mod benches { [pallet_encointer_bazaar, EncointerBazaar] [pallet_encointer_ceremonies, EncointerCeremonies] [pallet_encointer_communities, EncointerCommunities] + [pallet_encointer_faucet, EncointerFaucet] + [pallet_encointer_reputation_commitments, EncointerReputationCommitments] [pallet_encointer_scheduler, EncointerScheduler] + ); } diff --git a/runtime/src/weights/mod.rs b/runtime/src/weights/mod.rs index 8875b509..49f7af66 100644 --- a/runtime/src/weights/mod.rs +++ b/runtime/src/weights/mod.rs @@ -5,4 +5,7 @@ pub mod pallet_encointer_balances; pub mod pallet_encointer_bazaar; pub mod pallet_encointer_ceremonies; pub mod pallet_encointer_communities; +pub mod pallet_encointer_faucet; +pub mod pallet_encointer_reputation_commitments; pub mod pallet_encointer_scheduler; +pub mod pallet_treasury; diff --git a/runtime/src/weights/pallet_encointer_faucet.rs b/runtime/src/weights/pallet_encointer_faucet.rs new file mode 100644 index 00000000..b003d72d --- /dev/null +++ b/runtime/src/weights/pallet_encointer_faucet.rs @@ -0,0 +1,120 @@ + +//! Autogenerated weights for `pallet_encointer_faucet` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-06-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Fabian-iPhone.localdomain`, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/encointer-node-notee +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_encointer_faucet +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=runtime/src/weights/pallet_encointer_faucet.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_encointer_faucet`. +pub struct WeightInfo(PhantomData); +impl pallet_encointer_faucet::WeightInfo for WeightInfo { + /// Storage: EncointerCommunities CommunityIdentifiers (r:1 w:0) + /// Proof: EncointerCommunities CommunityIdentifiers (max_values: Some(1), max_size: Some(90002), added: 90497, mode: MaxEncodedLen) + /// Storage: EncointerFaucet Faucets (r:1 w:1) + /// Proof: EncointerFaucet Faucets (max_values: None, max_size: Some(9372), added: 11847, mode: MaxEncodedLen) + /// Storage: EncointerFaucet ReserveAmount (r:1 w:0) + /// Proof: EncointerFaucet ReserveAmount (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: EncointerReputationCommitments CurrentPurposeId (r:1 w:1) + /// Proof: EncointerReputationCommitments CurrentPurposeId (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) + /// Storage: EncointerReputationCommitments Purposes (r:0 w:1) + /// Proof: EncointerReputationCommitments Purposes (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + fn create_faucet() -> Weight { + // Proof Size summary in bytes: + // Measured: `195` + // Estimated: `91487` + // Minimum execution time: 214_000_000 picoseconds. + Weight::from_parts(228_000_000, 0) + .saturating_add(Weight::from_parts(0, 91487)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: EncointerFaucet Faucets (r:1 w:0) + /// Proof: EncointerFaucet Faucets (max_values: None, max_size: Some(9372), added: 11847, mode: MaxEncodedLen) + /// Storage: EncointerReputationCommitments Purposes (r:1 w:0) + /// Proof: EncointerReputationCommitments Purposes (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Storage: EncointerCeremonies ParticipantReputation (r:1 w:0) + /// Proof Skipped: EncointerCeremonies ParticipantReputation (max_values: None, max_size: None, mode: Measured) + /// Storage: EncointerReputationCommitments Commitments (r:1 w:1) + /// Proof: EncointerReputationCommitments Commitments (max_values: None, max_size: Some(102), added: 2577, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn drip() -> Weight { + // Proof Size summary in bytes: + // Measured: `668` + // Estimated: `12837` + // Minimum execution time: 197_000_000 picoseconds. + Weight::from_parts(199_000_000, 0) + .saturating_add(Weight::from_parts(0, 12837)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: EncointerFaucet Faucets (r:1 w:1) + /// Proof: EncointerFaucet Faucets (max_values: None, max_size: Some(9372), added: 11847, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:0) + /// Proof: Balances Reserves (max_values: None, max_size: Some(3122), added: 5597, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn dissolve_faucet() -> Weight { + // Proof Size summary in bytes: + // Measured: `331` + // Estimated: `12837` + // Minimum execution time: 173_000_000 picoseconds. + Weight::from_parts(181_000_000, 0) + .saturating_add(Weight::from_parts(0, 12837)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: EncointerFaucet Faucets (r:1 w:1) + /// Proof: EncointerFaucet Faucets (max_values: None, max_size: Some(9372), added: 11847, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Balances Reserves (r:1 w:0) + /// Proof: Balances Reserves (max_values: None, max_size: Some(3122), added: 5597, mode: MaxEncodedLen) + fn close_faucet() -> Weight { + // Proof Size summary in bytes: + // Measured: `331` + // Estimated: `12837` + // Minimum execution time: 175_000_000 picoseconds. + Weight::from_parts(183_000_000, 0) + .saturating_add(Weight::from_parts(0, 12837)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: EncointerFaucet ReserveAmount (r:0 w:1) + /// Proof: EncointerFaucet ReserveAmount (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + fn set_reserve_amount() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(30_000_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/runtime/src/weights/pallet_encointer_reputation_commitments.rs b/runtime/src/weights/pallet_encointer_reputation_commitments.rs new file mode 100644 index 00000000..4f97b8a1 --- /dev/null +++ b/runtime/src/weights/pallet_encointer_reputation_commitments.rs @@ -0,0 +1,50 @@ + +//! Autogenerated weights for `pallet_encointer_reputation_commitments` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-06-08, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `Fabian-iPhone.localdomain`, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/encointer-node-notee +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_encointer_reputation_commitments +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=runtime/src/weights/pallet_encointer_reputation_commitments.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_encointer_reputation_commitments`. +pub struct WeightInfo(PhantomData); +impl pallet_encointer_reputation_commitments::WeightInfo for WeightInfo { + // Storage: EncointerReputationCommitments CurrentPurposeId (r:1 w:1) + // Storage: EncointerReputationCommitments Purposes (r:0 w:1) + fn register_purpose() -> Weight { + // Minimum execution time: 51_000 nanoseconds. + Weight::from_parts(54_000_000, 0) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: EncointerReputationCommitments Purposes (r:1 w:0) + // Storage: EncointerCeremonies ParticipantReputation (r:1 w:0) + // Storage: EncointerReputationCommitments Commitments (r:1 w:1) + fn commit_reputation() -> Weight { + // Minimum execution time: 74_000 nanoseconds. + Weight::from_parts(76_000_000, 0) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} diff --git a/runtime/src/weights/pallet_treasury.rs b/runtime/src/weights/pallet_treasury.rs new file mode 100644 index 00000000..1d1872cc --- /dev/null +++ b/runtime/src/weights/pallet_treasury.rs @@ -0,0 +1,151 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +//! Autogenerated weights for `pallet_treasury` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-04-28, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `bm6`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama-dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/production/polkadot +// benchmark +// pallet +// --chain=kusama-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet_treasury +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --header=./file_header.txt +// --output=./runtime/kusama/src/weights/ + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_treasury`. +pub struct WeightInfo(PhantomData); +impl pallet_treasury::WeightInfo for WeightInfo { + /// Storage: Treasury ProposalCount (r:1 w:1) + /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:0 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn spend() -> Weight { + // Proof Size summary in bytes: + // Measured: `6` + // Estimated: `1887` + // Minimum execution time: 14_692_000 picoseconds. + Weight::from_parts(15_059_000, 0) + .saturating_add(Weight::from_parts(0, 1887)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Treasury ProposalCount (r:1 w:1) + /// Proof: Treasury ProposalCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:0 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn propose_spend() -> Weight { + // Proof Size summary in bytes: + // Measured: `107` + // Estimated: `1489` + // Minimum execution time: 26_358_000 picoseconds. + Weight::from_parts(26_761_000, 0) + .saturating_add(Weight::from_parts(0, 1489)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Treasury Proposals (r:1 w:1) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + fn reject_proposal() -> Weight { + // Proof Size summary in bytes: + // Measured: `265` + // Estimated: `3593` + // Minimum execution time: 39_586_000 picoseconds. + Weight::from_parts(40_113_000, 0) + .saturating_add(Weight::from_parts(0, 3593)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: Treasury Proposals (r:1 w:0) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// The range of component `p` is `[0, 99]`. + fn approve_proposal(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `433 + p * (8 ±0)` + // Estimated: `3573` + // Minimum execution time: 9_225_000 picoseconds. + Weight::from_parts(11_898_418, 0) + .saturating_add(Weight::from_parts(0, 3573)) + // Standard Error: 888 + .saturating_add(Weight::from_parts(30_177, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + fn remove_approval() -> Weight { + // Proof Size summary in bytes: + // Measured: `90` + // Estimated: `1887` + // Minimum execution time: 6_896_000 picoseconds. + Weight::from_parts(7_093_000, 0) + .saturating_add(Weight::from_parts(0, 1887)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Treasury Deactivated (r:1 w:1) + /// Proof: Treasury Deactivated (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Balances InactiveIssuance (r:1 w:1) + /// Proof: Balances InactiveIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Treasury Approvals (r:1 w:1) + /// Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// Storage: Treasury Proposals (r:100 w:100) + /// Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + /// Storage: System Account (r:201 w:201) + /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: Bounties BountyApprovals (r:1 w:1) + /// Proof: Bounties BountyApprovals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) + /// The range of component `p` is `[0, 100]`. + fn on_initialize_proposals(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `264 + p * (251 ±0)` + // Estimated: `3593 + p * (5206 ±0)` + // Minimum execution time: 62_552_000 picoseconds. + Weight::from_parts(65_526_861, 0) + .saturating_add(Weight::from_parts(0, 3593)) + // Standard Error: 20_034 + .saturating_add(Weight::from_parts(37_730_613, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_parts(0, 5206).saturating_mul(p.into())) + } +} diff --git a/scripts/benchmark_runtime.sh b/scripts/benchmark_runtime.sh index 28ae2e8a..abee0154 100755 --- a/scripts/benchmark_runtime.sh +++ b/scripts/benchmark_runtime.sh @@ -36,9 +36,11 @@ pallets=( # "pallet_balances" \ # "pallet_encointer_balances" # "pallet_encointer_bazaar" - "pallet_encointer_ceremonies" +# "pallet_encointer_ceremonies" # "pallet_encointer_communities" # "pallet_encointer_scheduler" + "pallet_encointer_faucet" + "pallet_encointer_reputation_commitments" ) for pallet in ${pallets[*]}; do @@ -55,6 +57,6 @@ for pallet in ${pallets[*]}; do --wasm-execution=compiled \ --heap-pages=4096 \ --output="$WEIGHT_OUTPUT_DIR"/"$pallet".rs \ - --template="$SCRIPTS_DIR"/frame-weight-template-full-info.hbs + #--template="$SCRIPTS_DIR"/frame-weight-template-full-info.hbs done