diff --git a/Cargo.lock b/Cargo.lock index 202e9f6e8..e75b40eaa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,7 +27,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli 0.28.0", + "gimli 0.28.1", ] [[package]] @@ -211,12 +211,12 @@ dependencies = [ [[package]] name = "async-channel" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37875bd9915b7d67c2f117ea2c30a0989874d0b2cb694fe25403c85763c0c9e" +checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener 3.1.0", + "event-listener 4.0.0", "event-listener-strategy", "futures-core", "pin-project-lite 0.2.13", @@ -224,30 +224,30 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.6.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "17ae5ebefcc48e7452b4987947920dac9450be1110cadf34d1b8c116bdbaf97c" dependencies = [ - "async-lock 2.8.0", + "async-lock 3.2.0", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 1.13.0", + "futures-lite 2.1.0", "slab", ] [[package]] name = "async-global-executor" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +checksum = "9b4353121d5644cdf2beb5726ab752e79a8db1ebb52031770ec47db31d245526" dependencies = [ - "async-channel 1.9.0", + "async-channel 2.1.1", "async-executor", - "async-io 1.13.0", - "async-lock 2.8.0", + "async-io 2.2.1", + "async-lock 3.2.0", "blocking", - "futures-lite 1.13.0", + "futures-lite 2.1.0", "once_cell", ] @@ -273,22 +273,21 @@ dependencies = [ [[package]] name = "async-io" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" +checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" dependencies = [ - "async-lock 3.1.0", + "async-lock 3.2.0", "cfg-if", "concurrent-queue", "futures-io", - "futures-lite 2.0.1", + "futures-lite 2.1.0", "parking", - "polling 3.3.0", - "rustix 0.38.21", + "polling 3.3.1", + "rustix 0.38.27", "slab", "tracing", - "waker-fn", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -302,11 +301,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7" +checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" dependencies = [ - "event-listener 3.1.0", + "event-listener 4.0.0", "event-listener-strategy", "pin-project-lite 0.2.13", ] @@ -324,7 +323,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.21", + "rustix 0.38.27", "windows-sys 0.48.0", ] @@ -334,13 +333,13 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e47d90f65a225c4527103a8d747001fc56e375203592b25ad103e1ca13124c5" dependencies = [ - "async-io 2.2.0", + "async-io 2.2.1", "async-lock 2.8.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", - "rustix 0.38.21", + "rustix 0.38.27", "signal-hook-registry", "slab", "windows-sys 0.48.0", @@ -660,12 +659,12 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ - "async-channel 2.1.0", - "async-lock 3.1.0", + "async-channel 2.1.1", + "async-lock 3.2.0", "async-task", "fastrand 2.0.1", "futures-io", - "futures-lite 2.0.1", + "futures-lite 2.1.0", "piper", "tracing", ] @@ -756,9 +755,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" +checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" dependencies = [ "serde", ] @@ -778,10 +777,11 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.84" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f8e7c90afad890484a21653d08b6e209ae34770fb5ee298f9c699fcc1e5c856" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] @@ -1184,7 +1184,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -1283,9 +1283,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" dependencies = [ "crossbeam-utils", ] @@ -1310,9 +1310,9 @@ checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -1320,9 +1320,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "core2" @@ -1625,15 +1625,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "data-encoding-macro" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" +checksum = "20c01c06f5f429efdf2bae21eb67c28b3df3cf85b7dd2d8ef09c0838dac5d33e" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -1641,9 +1641,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" +checksum = "0047d07f2c89b17dd631c80450d69841a6b5d7fb17278cbc43d7e4cfcf2576f3" dependencies = [ "data-encoding", "syn 1.0.109", @@ -1973,12 +1973,12 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -2008,13 +2008,24 @@ dependencies = [ "pin-project-lite 0.2.13", ] +[[package]] +name = "event-listener" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", +] + [[package]] name = "event-listener-strategy" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 3.1.0", + "event-listener 4.0.0", "pin-project-lite 0.2.13", ] @@ -2075,9 +2086,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.3" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f69037fe1b785e84986b4f2cbcf647381876a00671d25ceef715d7812dd7e1dd" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "file-per-thread-logger" @@ -2091,14 +2102,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", + "redox_syscall 0.4.1", + "windows-sys 0.52.0", ] [[package]] @@ -2162,9 +2173,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -2248,7 +2259,7 @@ name = "frame-election-provider-solution-type" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -2351,7 +2362,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ "frame-support-procedural-tools-derive", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -2521,11 +2532,14 @@ dependencies = [ [[package]] name = "futures-lite" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" +checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" dependencies = [ + "fastrand 2.0.1", "futures-core", + "futures-io", + "parking", "pin-project-lite 0.2.13", ] @@ -2672,9 +2686,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "glob" @@ -2684,15 +2698,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -2720,9 +2734,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -2730,7 +2744,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -2777,9 +2791,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -2986,9 +3000,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3069,7 +3083,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.2", + "hashbrown 0.14.3", ] [[package]] @@ -3147,7 +3161,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.21", + "rustix 0.38.27", "windows-sys 0.48.0", ] @@ -3172,11 +3186,20 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -3273,7 +3296,7 @@ version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd67957d4280217247588ac86614ead007b301ca2fa9f19c19f880a536f029e3" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -4077,9 +4100,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -4190,7 +4213,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.21", + "rustix 0.38.27", ] [[package]] @@ -4266,9 +4289,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -4327,7 +4350,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6d4752e6230d8ef7adf7bd5d8c4b1f6561c1014c5ba9a37445ccefe18aa1db" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro-error", "proc-macro2", "quote", @@ -4623,9 +4646,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -4932,6 +4955,7 @@ version = "4.8.1" dependencies = [ "ddc-primitives", "ddc-traits", + "frame-benchmarking", "frame-support", "frame-system", "hex", @@ -5527,7 +5551,7 @@ name = "pallet-staking-reward-curve" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -5695,9 +5719,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -5710,11 +5734,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.1", "proc-macro2", "quote", "syn 1.0.109", @@ -5819,7 +5843,7 @@ dependencies = [ "libc", "redox_syscall 0.4.1", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -5854,9 +5878,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" @@ -6009,16 +6033,16 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.0" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" +checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite 0.2.13", - "rustix 0.38.21", + "rustix 0.38.27", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -6105,6 +6129,16 @@ dependencies = [ "toml", ] +[[package]] +name = "proc-macro-crate" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +dependencies = [ + "toml_datetime", + "toml_edit", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -6131,9 +6165,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -6473,15 +6507,6 @@ dependencies = [ "bitflags 1.3.2", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.4.1" @@ -6633,9 +6658,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.5" +version = "0.17.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", "getrandom 0.2.11", @@ -6748,7 +6773,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", - "errno 0.3.6", + "errno 0.3.8", "io-lifetimes 1.0.11", "libc", "linux-raw-sys 0.3.8", @@ -6757,15 +6782,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.21" +version = "0.38.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +checksum = "bfeae074e687625746172d639330f1de242a178bf3189b51e35a7a21573513ac" dependencies = [ "bitflags 2.4.1", - "errno 0.3.6", + "errno 0.3.8", "libc", - "linux-raw-sys 0.4.11", - "windows-sys 0.48.0", + "linux-raw-sys 0.4.12", + "windows-sys 0.52.0", ] [[package]] @@ -6950,7 +6975,7 @@ name = "sc-chain-spec-derive" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -7830,7 +7855,7 @@ name = "sc-tracing-proc-macro" version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -7908,7 +7933,7 @@ version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -7953,7 +7978,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.17.5", + "ring 0.17.7", "untrusted 0.9.0", ] @@ -8055,18 +8080,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -8231,9 +8256,9 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "snap" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" +checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" [[package]] name = "snow" @@ -8246,7 +8271,7 @@ dependencies = [ "chacha20poly1305", "curve25519-dalek 4.1.1", "rand_core 0.6.4", - "ring 0.17.5", + "ring 0.17.7", "rustc_version 0.4.0", "sha2 0.10.8", "subtle", @@ -8312,7 +8337,7 @@ version = "4.0.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ "blake2", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -8757,7 +8782,7 @@ version = "5.0.0" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ "Inflector", - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -9197,7 +9222,7 @@ name = "substrate-test-utils-derive" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119c45cdd0d571ad34e5b3ee7518c8cef8d" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.109", @@ -9302,15 +9327,15 @@ dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall 0.4.1", - "rustix 0.38.21", + "rustix 0.38.27", "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -9487,6 +9512,23 @@ dependencies = [ "serde", ] +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +dependencies = [ + "indexmap 2.1.0", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -9646,9 +9688,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "try-runtime-cli" @@ -9729,9 +9771,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" @@ -9796,20 +9838,20 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", - "idna 0.4.0", + "idna 0.5.0", "percent-encoding", ] [[package]] name = "utf8-width" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" [[package]] name = "valuable" @@ -9880,9 +9922,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -9890,9 +9932,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", @@ -9905,9 +9947,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if", "js-sys", @@ -9917,9 +9959,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -9927,9 +9969,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", @@ -9940,9 +9982,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "wasm-gc-api" @@ -10193,9 +10235,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -10207,7 +10249,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.5", + "ring 0.17.7", "untrusted 0.9.0", ] @@ -10229,7 +10271,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.21", + "rustix 0.38.27", ] [[package]] @@ -10288,7 +10330,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -10325,7 +10367,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -10343,6 +10394,21 @@ dependencies = [ "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -10355,6 +10421,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.34.0" @@ -10379,6 +10451,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.34.0" @@ -10403,6 +10481,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.34.0" @@ -10427,6 +10511,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.34.0" @@ -10451,6 +10541,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" @@ -10463,6 +10559,12 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.34.0" @@ -10487,6 +10589,21 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winnow" +version = "0.5.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -10533,9 +10650,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] diff --git a/pallets/ddc-clusters/Cargo.toml b/pallets/ddc-clusters/Cargo.toml index 2573fcae3..953d86390 100644 --- a/pallets/ddc-clusters/Cargo.toml +++ b/pallets/ddc-clusters/Cargo.toml @@ -9,6 +9,7 @@ ddc-primitives = { version = "0.1.0", default-features = false, path = "../../pr ddc-traits = { version = "0.1.0", default-features = false, path = "../../traits" } frame-support = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } frame-system = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } +frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30", optional = true } hex = { version = "0.4", default-features = false } hex-literal = "^0.3.1" pallet-contracts = { default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -25,6 +26,7 @@ pallet-balances = { git = "https://github.com/paritytech/substrate.git", branch pallet-randomness-collective-flip = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } pallet-timestamp = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } sp-core = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } +sp-io = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } sp-tracing = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } substrate-test-utils = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.30" } @@ -36,6 +38,7 @@ std = [ "ddc-primitives/std", "frame-support/std", "frame-system/std", + "frame-benchmarking/std", "pallet-contracts/std", "pallet-ddc-nodes/std", "scale-info/std", @@ -43,3 +46,10 @@ std = [ "sp-runtime/std", "sp-std/std", ] +runtime-benchmarks = [ + "ddc-primitives/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] diff --git a/pallets/ddc-clusters/src/benchmarking.rs b/pallets/ddc-clusters/src/benchmarking.rs new file mode 100644 index 000000000..9f18cd160 --- /dev/null +++ b/pallets/ddc-clusters/src/benchmarking.rs @@ -0,0 +1,113 @@ +//! DdcStaking pallet benchmarking. + +use ddc_primitives::{ClusterGovParams, ClusterId, ClusterParams, NodePubKey}; +pub use frame_benchmarking::{ + account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, + BenchmarkError, +}; +use frame_system::RawOrigin; +use pallet_contracts::chain_extension::UncheckedFrom; +use sp_runtime::{AccountId32, Perquintill}; +use sp_std::prelude::*; +use testing_utils::*; + +use super::*; +use crate::{cluster::ClusterProps, Pallet as DdcClusters}; + +const USER_SEED: u32 = 999666; +const USER_SEED_2: u32 = 999555; + +benchmarks! { + where_clause { where + T::AccountId: UncheckedFrom + AsRef<[u8]> } + + create_cluster { + let cluster_id = ClusterId::from([1; 20]); + let user = account::("user", USER_SEED, 0u32); + let cluster_params = ClusterParams { node_provider_auth_contract: Some(user.clone()) }; + let cluster_gov_params: ClusterGovParams, T::BlockNumber> = ClusterGovParams { + treasury_share: Perquintill::default(), + validators_share: Perquintill::default(), + cluster_reserve_share: Perquintill::default(), + cdn_bond_size: 100u32.into(), + cdn_chill_delay: 50u32.into(), + cdn_unbonding_delay: 50u32.into(), + storage_bond_size: 100u32.into(), + storage_chill_delay: 50u32.into(), + storage_unbonding_delay: 50u32.into(), + unit_per_mb_stored: 10, + unit_per_mb_streamed: 10, + unit_per_put_request: 10, + unit_per_get_request: 10, + }; + }: _(RawOrigin::Root, cluster_id, user.clone(), user, cluster_params, cluster_gov_params) + verify { + assert!(Clusters::::contains_key(cluster_id)); + } + + add_node { + let bytes = [0u8; 32]; + let node_pub_key = NodePubKey::CDNPubKey(AccountId32::from(bytes)); + let cluster_id = ClusterId::from([1; 20]); + let user = account::("user", USER_SEED, 0u32); + let balance = ::Currency::minimum_balance() * 1_000_000u32.into(); + let _ = ::Currency::make_free_balance_be(&user, balance); + let _ = config_cluster_and_node::(user.clone(), node_pub_key.clone(), cluster_id); + }: _(RawOrigin::Signed(user.clone()), cluster_id, node_pub_key.clone()) + verify { + assert!(ClustersNodes::::contains_key(cluster_id, node_pub_key)); + } + + remove_node { + let bytes = [0u8; 32]; + let node_pub_key = NodePubKey::CDNPubKey(AccountId32::from(bytes)); + let cluster_id = ClusterId::from([1; 20]); + let user = account::("user", USER_SEED, 0u32); + let balance = ::Currency::minimum_balance() * 1_000_000u32.into(); + let _ = ::Currency::make_free_balance_be(&user, balance); + let _ = config_cluster_and_node::(user.clone(), node_pub_key.clone(), cluster_id); + let _ = DdcClusters::::add_node( + RawOrigin::Signed(user.clone()).into(), + cluster_id, + node_pub_key.clone() + ); + }: _(RawOrigin::Signed(user.clone()), cluster_id, node_pub_key.clone()) + verify { + assert!(!ClustersNodes::::contains_key(cluster_id, node_pub_key)); + } + + set_cluster_params { + let cluster_id = ClusterId::from([1; 20]); + let user = account::("user", USER_SEED, 0u32); + let user_2 = account::("user", USER_SEED_2, 0u32); + let _ = config_cluster::(user.clone(), cluster_id); + let new_cluster_params = ClusterParams { node_provider_auth_contract: Some(user_2.clone()) }; + }: _(RawOrigin::Signed(user.clone()), cluster_id, new_cluster_params) + verify { + assert_eq!(Clusters::::try_get(cluster_id).unwrap().props, ClusterProps { node_provider_auth_contract: Some(user_2) }); + } + + set_cluster_gov_params { + let cluster_id = ClusterId::from([1; 20]); + let user = account::("user", USER_SEED, 0u32); + let _ = config_cluster::(user, cluster_id); + let new_cluster_gov_params: ClusterGovParams, T::BlockNumber> = ClusterGovParams { + treasury_share: Perquintill::default(), + validators_share: Perquintill::default(), + cluster_reserve_share: Perquintill::default(), + cdn_bond_size: 10u32.into(), + cdn_chill_delay: 5u32.into(), + cdn_unbonding_delay: 5u32.into(), + storage_bond_size: 10u32.into(), + storage_chill_delay: 5u32.into(), + storage_unbonding_delay: 5u32.into(), + unit_per_mb_stored: 1, + unit_per_mb_streamed: 1, + unit_per_put_request: 1, + unit_per_get_request: 1, + }; + }: _(RawOrigin::Root, cluster_id, new_cluster_gov_params.clone()) + verify { + assert_eq!(ClustersGovParams::::try_get(cluster_id).unwrap(), new_cluster_gov_params); + } +} diff --git a/pallets/ddc-clusters/src/lib.rs b/pallets/ddc-clusters/src/lib.rs index dad079fa2..a9c501854 100644 --- a/pallets/ddc-clusters/src/lib.rs +++ b/pallets/ddc-clusters/src/lib.rs @@ -15,6 +15,14 @@ #![recursion_limit = "256"] #![feature(is_some_and)] // ToDo: delete at rustc > 1.70 +pub mod weights; +use crate::weights::WeightInfo; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; +#[cfg(any(feature = "runtime-benchmarks", test))] +pub mod testing_utils; + #[cfg(test)] pub(crate) mod mock; #[cfg(test)] @@ -30,7 +38,7 @@ use ddc_primitives::{ }; use ddc_traits::{ cluster::{ClusterCreator, ClusterVisitor, ClusterVisitorError}, - staking::{StakingVisitor, StakingVisitorError}, + staking::{StakerCreator, StakingVisitor, StakingVisitorError}, }; use frame_support::{ assert_ok, @@ -66,7 +74,9 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; type NodeRepository: NodeRepository; // todo: get rid of tight coupling with nodes-pallet type StakingVisitor: StakingVisitor; + type StakerCreator: StakerCreator>; type Currency: LockableCurrency; + type WeightInfo: WeightInfo; } #[pallet::event] @@ -95,6 +105,8 @@ pub mod pallet { /// Cluster candidate should not plan to chill. NodeChillingIsProhibited, NodeAuthContractCallFailed, + NodeAuthContractDeployFailed, + NodeAuthNodeAuthorizationNotSuccessful, } #[pallet::storage] @@ -178,7 +190,7 @@ pub mod pallet { where T::AccountId: UncheckedFrom + AsRef<[u8]>, { - #[pallet::weight(10_000)] + #[pallet::weight(::WeightInfo::create_cluster())] pub fn create_cluster( origin: OriginFor, cluster_id: ClusterId, @@ -197,7 +209,7 @@ pub mod pallet { ) } - #[pallet::weight(10_000)] + #[pallet::weight(::WeightInfo::add_node())] pub fn add_node( origin: OriginFor, cluster_id: ClusterId, @@ -246,7 +258,7 @@ pub mod pallet { Ok(()) } - #[pallet::weight(10_000)] + #[pallet::weight(::WeightInfo::remove_node())] pub fn remove_node( origin: OriginFor, cluster_id: ClusterId, @@ -267,7 +279,7 @@ pub mod pallet { } // Sets Governance non-sensetive parameters only - #[pallet::weight(10_000)] + #[pallet::weight(::WeightInfo::set_cluster_params())] pub fn set_cluster_params( origin: OriginFor, cluster_id: ClusterId, @@ -285,7 +297,7 @@ pub mod pallet { } // Requires Governance approval - #[pallet::weight(10_000)] + #[pallet::weight(::WeightInfo::set_cluster_gov_params())] pub fn set_cluster_gov_params( origin: OriginFor, cluster_id: ClusterId, @@ -499,6 +511,10 @@ pub mod pallet { match error { NodeProviderAuthContractError::ContractCallFailed => Error::::NodeAuthContractCallFailed, + NodeProviderAuthContractError::ContractDeployFailed => + Error::::NodeAuthContractDeployFailed, + NodeProviderAuthContractError::NodeAuthorizationNotSuccessful => + Error::::NodeAuthNodeAuthorizationNotSuccessful, } } } diff --git a/pallets/ddc-clusters/src/mock.rs b/pallets/ddc-clusters/src/mock.rs index e0fd9471b..deb7bb03c 100644 --- a/pallets/ddc-clusters/src/mock.rs +++ b/pallets/ddc-clusters/src/mock.rs @@ -4,7 +4,7 @@ use crate::{self as pallet_ddc_clusters, *}; use ddc_primitives::{ClusterId, NodePubKey}; -use ddc_traits::staking::{StakingVisitor, StakingVisitorError}; +use ddc_traits::staking::{StakerCreator, StakingVisitor, StakingVisitorError}; use frame_support::{ construct_runtime, parameter_types, traits::{ConstU32, ConstU64, Everything, Nothing}, @@ -190,11 +190,15 @@ impl crate::pallet::Config for Test { type Currency = Balances; type NodeRepository = DdcNodes; type StakingVisitor = TestStakingVisitor; + type StakerCreator = TestStaker; + type WeightInfo = (); } pub(crate) type DdcStakingCall = crate::Call; pub(crate) type TestRuntimeCall = ::RuntimeCall; pub struct TestStakingVisitor; +pub struct TestStaker; + impl StakingVisitor for TestStakingVisitor { fn has_activated_stake( _node_pub_key: &NodePubKey, @@ -210,6 +214,18 @@ impl StakingVisitor for TestStakingVisitor { } } +impl StakerCreator> for TestStaker { + fn bond_stake_and_participate( + _stash: T::AccountId, + _controller: T::AccountId, + _node: NodePubKey, + _value: BalanceOf, + _cluster_id: ClusterId, + ) -> sp_runtime::DispatchResult { + Ok(()) + } +} + pub struct ExtBuilder; impl ExtBuilder { diff --git a/pallets/ddc-clusters/src/node_provider_auth.rs b/pallets/ddc-clusters/src/node_provider_auth.rs index e3f038818..d73e45628 100644 --- a/pallets/ddc-clusters/src/node_provider_auth.rs +++ b/pallets/ddc-clusters/src/node_provider_auth.rs @@ -2,8 +2,10 @@ use crate::Config; use codec::Encode; use ddc_primitives::{NodePubKey, NodeType}; use frame_support::weights::Weight; +use hex_literal::hex; use pallet_contracts::chain_extension::UncheckedFrom; -use sp_std::prelude::Vec; +use sp_runtime::traits::Hash; +use sp_std::{prelude::Vec, vec}; /// ink! 4.x selector for the "is_authorized" message, equals to the first four bytes of the /// blake2("is_authorized"). See also: https://use.ink/basics/selectors#selector-calculation/, @@ -15,7 +17,7 @@ const INK_SELECTOR_IS_AUTHORIZED: [u8; 4] = [0x96, 0xb0, 0x45, 0x3e]; const EXTENSION_CALL_GAS_LIMIT: Weight = Weight::from_ref_time(5_000_000_000_000); pub struct NodeProviderAuthContract { - contract_id: T::AccountId, + pub contract_id: T::AccountId, caller_id: T::AccountId, } @@ -59,6 +61,72 @@ where Ok(is_authorized) } + pub fn deploy_contract( + &self, + caller_id: T::AccountId, + ) -> Result { + pub const CTOR_SELECTOR: [u8; 4] = hex!("9bae9d5e"); + + fn encode_constructor() -> Vec { + let mut call_data = CTOR_SELECTOR.to_vec(); + let x = 0_u128; + for _ in 0..9 { + x.encode_to(&mut call_data); + } + call_data + } + + // Load the contract code. + let wasm = &include_bytes!("./test_data/node_provider_auth_white_list.wasm")[..]; + let _wasm_hash = ::Hashing::hash(wasm); + let contract_args = encode_constructor(); + + // Deploy the contract. + let contract_id = pallet_contracts::Pallet::::bare_instantiate( + caller_id.clone(), + Default::default(), + EXTENSION_CALL_GAS_LIMIT, + None, + wasm.into(), + contract_args, + vec![], + false, + ) + .result + .map_err(|_| NodeProviderAuthContractError::ContractDeployFailed)? + .account_id; + + Ok(Self::new(contract_id, caller_id)) + } + + pub fn authorize_node( + &self, + node_pub_key: NodePubKey, + ) -> Result { + pub const ADD_DDC_NODE_SELECTOR: [u8; 4] = hex!("7a04093d"); + + let call_data = { + // is_authorized(node_provider: AccountId, node: Vec, node_variant: u8) -> bool + let args: ([u8; 4], Vec) = + (ADD_DDC_NODE_SELECTOR, node_pub_key.encode()[1..].to_vec()); + args.encode() + }; + + let _ = pallet_contracts::Pallet::::bare_call( + self.caller_id.clone(), + self.contract_id.clone(), + Default::default(), + EXTENSION_CALL_GAS_LIMIT, + None, + call_data, + false, + ) + .result + .map_err(|_| NodeProviderAuthContractError::NodeAuthorizationNotSuccessful)?; + + Ok(true) + } + pub fn new(contract_id: T::AccountId, caller_id: T::AccountId) -> Self { Self { contract_id, caller_id } } @@ -66,4 +134,6 @@ where pub enum NodeProviderAuthContractError { ContractCallFailed, + ContractDeployFailed, + NodeAuthorizationNotSuccessful, } diff --git a/pallets/ddc-clusters/src/testing_utils.rs b/pallets/ddc-clusters/src/testing_utils.rs new file mode 100644 index 000000000..b32e9ecca --- /dev/null +++ b/pallets/ddc-clusters/src/testing_utils.rs @@ -0,0 +1,133 @@ +//! DdcStaking pallet benchmarking. + +use ddc_primitives::{ + CDNNodeParams, ClusterGovParams, ClusterId, ClusterParams, NodeParams, NodePubKey, +}; +pub use frame_benchmarking::{ + account, benchmarks, impl_benchmark_test_suite, whitelist_account, whitelisted_caller, + BenchmarkError, +}; +use frame_system::RawOrigin; +use pallet_contracts::chain_extension::UncheckedFrom; +use pallet_ddc_nodes::Node; +use sp_runtime::Perquintill; +use sp_std::prelude::*; + +use crate::{Pallet as DdcClusters, *}; + +pub fn config_cluster(user: T::AccountId, cluster_id: ClusterId) +where + T::AccountId: UncheckedFrom + AsRef<[u8]>, +{ + let cluster_params = ClusterParams { node_provider_auth_contract: Some(user.clone()) }; + let cluster_gov_params: ClusterGovParams, T::BlockNumber> = ClusterGovParams { + treasury_share: Perquintill::default(), + validators_share: Perquintill::default(), + cluster_reserve_share: Perquintill::default(), + cdn_bond_size: 100u32.into(), + cdn_chill_delay: 50u32.into(), + cdn_unbonding_delay: 50u32.into(), + storage_bond_size: 100u32.into(), + storage_chill_delay: 50u32.into(), + storage_unbonding_delay: 50u32.into(), + unit_per_mb_stored: 10, + unit_per_mb_streamed: 10, + unit_per_put_request: 10, + unit_per_get_request: 10, + }; + + let _ = DdcClusters::::create_cluster( + RawOrigin::Root.into(), + cluster_id, + user.clone(), + user, + cluster_params, + cluster_gov_params, + ); +} + +pub fn config_cluster_and_node( + user: T::AccountId, + node_pub_key: NodePubKey, + cluster_id: ClusterId, +) -> Result<(), Box> +where + T::AccountId: UncheckedFrom + AsRef<[u8]>, +{ + let cluster_params = ClusterParams { node_provider_auth_contract: Some(user.clone()) }; + let cdn_node_params = CDNNodeParams { + host: vec![1u8, 255], + http_port: 35000u16, + grpc_port: 25000u16, + p2p_port: 15000u16, + }; + + let cluster_gov_params: ClusterGovParams, T::BlockNumber> = ClusterGovParams { + treasury_share: Perquintill::default(), + validators_share: Perquintill::default(), + cluster_reserve_share: Perquintill::default(), + cdn_bond_size: 100u32.into(), + cdn_chill_delay: 50u32.into(), + cdn_unbonding_delay: 50u32.into(), + storage_bond_size: 100u32.into(), + storage_chill_delay: 50u32.into(), + storage_unbonding_delay: 50u32.into(), + unit_per_mb_stored: 10, + unit_per_mb_streamed: 10, + unit_per_put_request: 10, + unit_per_get_request: 10, + }; + + let _ = DdcClusters::::create_cluster( + RawOrigin::Root.into(), + cluster_id, + user.clone(), + user.clone(), + cluster_params, + cluster_gov_params, + ); + + if let Ok(new_node) = + Node::::new(node_pub_key.clone(), user.clone(), NodeParams::CDNParams(cdn_node_params)) + { + let _ = T::NodeRepository::create(new_node); + } + + T::StakerCreator::bond_stake_and_participate( + user.clone(), + user.clone(), + node_pub_key.clone(), + 10_000u32.into(), + cluster_id, + ) + .unwrap(); + + let mut auth_contract = NodeProviderAuthContract::::new(user.clone(), user.clone()); + auth_contract = auth_contract.deploy_contract(user.clone())?; + auth_contract.authorize_node(node_pub_key)?; + + let updated_cluster_params = + ClusterParams { node_provider_auth_contract: Some(auth_contract.contract_id) }; + + // Register auth contract + let _ = DdcClusters::::set_cluster_params( + RawOrigin::Signed(user).into(), + cluster_id, + updated_cluster_params, + ); + + Ok(()) +} + +impl From for Box { + fn from(error: NodeProviderAuthContractError) -> Self { + match error { + NodeProviderAuthContractError::ContractCallFailed => + Box::new(BenchmarkError::Stop("NodeAuthContractCallFailed")), + NodeProviderAuthContractError::ContractDeployFailed => + Box::new(BenchmarkError::Stop("NodeAuthContractDeployFailed")), + NodeProviderAuthContractError::NodeAuthorizationNotSuccessful => + Box::new(BenchmarkError::Stop("NodeAuthNodeAuthorizationNotSuccessful")), + } + } +} diff --git a/pallets/ddc-clusters/src/weights.rs b/pallets/ddc-clusters/src/weights.rs new file mode 100644 index 000000000..96e4b735f --- /dev/null +++ b/pallets/ddc-clusters/src/weights.rs @@ -0,0 +1,155 @@ + +//! Autogenerated weights for `pallet_ddc_clusters` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-16, STEPS: `200`, REPEAT: 1000, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `Raids-MacBook-Pro-2.local`, CPU: `` +//! EXECUTION: None, WASM-EXECUTION: Interpreted, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/cere +// benchmark +// pallet +// --chain +// dev +// --pallet +// pallet_ddc_clusters +// --extrinsic +// * +// --steps +// 20 +// --repeat +// 50 +// --output +// pallets/ddc-clusters/src/weights.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for pallet_ddc_clusters. +pub trait WeightInfo { + fn create_cluster() -> Weight; + fn add_node() -> Weight; + fn remove_node() -> Weight; + fn set_cluster_params() -> Weight; + fn set_cluster_gov_params() -> Weight; +} + +/// Weight functions for `pallet_ddc_clusters`. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + // Storage: DdcClusters Clusters (r:1 w:1) + // Storage: DdcClusters ClustersGovParams (r:0 w:1) + fn create_cluster() -> Weight { + // Minimum execution time: 14_000 nanoseconds. + Weight::from_ref_time(15_000_000u64) + .saturating_add(T::DbWeight::get().reads(1u64)) + .saturating_add(T::DbWeight::get().writes(2u64)) + } + // Storage: DdcClusters Clusters (r:1 w:0) + // Storage: DdcNodes CDNNodes (r:1 w:1) + // Storage: DdcStaking Nodes (r:1 w:0) + // Storage: DdcStaking CDNs (r:1 w:0) + // Storage: DdcStaking Storages (r:1 w:0) + // Storage: DdcStaking Bonded (r:1 w:0) + // Storage: DdcStaking Ledger (r:1 w:0) + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + // Storage: DdcClusters ClustersNodes (r:0 w:1) + // Storage: unknown [0x89eb0d6a8a691dae2cd15ed0369931ce0a949ecafa5c3f93f8121833646e15c3] (r:1 w:0) + // Storage: unknown [0xc3ad1d87683b6ac25f2e809346840d7a7ed0c05653ee606dba68aba3bdb5d957] (r:1 w:0) + fn add_node() -> Weight { + // Minimum execution time: 307_000 nanoseconds. + Weight::from_ref_time(354_000_000u64) + .saturating_add(T::DbWeight::get().reads(15u64)) + .saturating_add(T::DbWeight::get().writes(5u64)) + } + // Storage: DdcClusters Clusters (r:1 w:0) + // Storage: DdcNodes CDNNodes (r:1 w:1) + // Storage: DdcClusters ClustersNodes (r:0 w:1) + fn remove_node() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(24_000_000u64) + .saturating_add(T::DbWeight::get().reads(2u64)) + .saturating_add(T::DbWeight::get().writes(2u64)) + } + // Storage: DdcClusters Clusters (r:1 w:1) + fn set_cluster_params() -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(16_000_000u64) + .saturating_add(T::DbWeight::get().reads(1u64)) + .saturating_add(T::DbWeight::get().writes(1u64)) + } + // Storage: DdcClusters Clusters (r:1 w:0) + // Storage: DdcClusters ClustersGovParams (r:0 w:1) + fn set_cluster_gov_params() -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(16_000_000u64) + .saturating_add(T::DbWeight::get().reads(1u64)) + .saturating_add(T::DbWeight::get().writes(1u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + // Storage: DdcClusters Clusters (r:1 w:1) + // Storage: DdcClusters ClustersGovParams (r:0 w:1) + fn create_cluster() -> Weight { + // Minimum execution time: 14_000 nanoseconds. + Weight::from_ref_time(15_000_000u64) + .saturating_add(RocksDbWeight::get().reads(1u64)) + .saturating_add(RocksDbWeight::get().writes(2u64)) + } + // Storage: DdcClusters Clusters (r:1 w:0) + // Storage: DdcNodes CDNNodes (r:1 w:1) + // Storage: DdcStaking Nodes (r:1 w:0) + // Storage: DdcStaking CDNs (r:1 w:0) + // Storage: DdcStaking Storages (r:1 w:0) + // Storage: DdcStaking Bonded (r:1 w:0) + // Storage: DdcStaking Ledger (r:1 w:0) + // Storage: System Account (r:1 w:0) + // Storage: Contracts ContractInfoOf (r:1 w:1) + // Storage: Contracts CodeStorage (r:1 w:0) + // Storage: Timestamp Now (r:1 w:0) + // Storage: System EventTopics (r:2 w:2) + // Storage: DdcClusters ClustersNodes (r:0 w:1) + // Storage: unknown [0x89eb0d6a8a691dae2cd15ed0369931ce0a949ecafa5c3f93f8121833646e15c3] (r:1 w:0) + // Storage: unknown [0xc3ad1d87683b6ac25f2e809346840d7a7ed0c05653ee606dba68aba3bdb5d957] (r:1 w:0) + fn add_node() -> Weight { + // Minimum execution time: 307_000 nanoseconds. + Weight::from_ref_time(354_000_000u64) + .saturating_add(RocksDbWeight::get().reads(15u64)) + .saturating_add(RocksDbWeight::get().writes(5u64)) + } + // Storage: DdcClusters Clusters (r:1 w:0) + // Storage: DdcNodes CDNNodes (r:1 w:1) + // Storage: DdcClusters ClustersNodes (r:0 w:1) + fn remove_node() -> Weight { + // Minimum execution time: 23_000 nanoseconds. + Weight::from_ref_time(24_000_000u64) + .saturating_add(RocksDbWeight::get().reads(2u64)) + .saturating_add(RocksDbWeight::get().writes(2u64)) + } + // Storage: DdcClusters Clusters (r:1 w:1) + fn set_cluster_params() -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(16_000_000u64) + .saturating_add(RocksDbWeight::get().reads(1u64)) + .saturating_add(RocksDbWeight::get().writes(1u64)) + } + // Storage: DdcClusters Clusters (r:1 w:0) + // Storage: DdcClusters ClustersGovParams (r:0 w:1) + fn set_cluster_gov_params() -> Weight { + // Minimum execution time: 15_000 nanoseconds. + Weight::from_ref_time(16_000_000u64) + .saturating_add(RocksDbWeight::get().reads(1u64)) + .saturating_add(RocksDbWeight::get().writes(1u64)) + } +} \ No newline at end of file diff --git a/pallets/ddc-staking/src/lib.rs b/pallets/ddc-staking/src/lib.rs index 4d4efff3d..d7bbad30e 100644 --- a/pallets/ddc-staking/src/lib.rs +++ b/pallets/ddc-staking/src/lib.rs @@ -33,7 +33,7 @@ pub use ddc_primitives::{ClusterId, NodePubKey, NodeType}; use ddc_traits::{ cluster::{ClusterCreator, ClusterVisitor, ClusterVisitorError}, node::{NodeCreator, NodeVisitor}, - staking::{StakingVisitor, StakingVisitorError}, + staking::{StakerCreator, StakingVisitor, StakingVisitorError}, }; use frame_support::{ @@ -959,6 +959,37 @@ pub mod pallet { } } + impl StakerCreator> for Pallet { + fn bond_stake_and_participate( + stash: T::AccountId, + controller: T::AccountId, + node: NodePubKey, + value: BalanceOf, + cluster_id: ClusterId, + ) -> DispatchResult { + Nodes::::insert(&node, &stash); + Providers::::insert(&stash, &node); + >::insert(&stash, &controller); + let stash_balance = T::Currency::free_balance(&stash); + let value = value.min(stash_balance); + Self::deposit_event(Event::::Bonded(stash.clone(), value)); + let item = StakingLedger { + stash: stash.clone(), + total: value, + active: value, + chilling: Default::default(), + unlocking: Default::default(), + }; + Self::update_ledger(&controller, &item); + match node { + NodePubKey::StoragePubKey(_node) => Self::do_add_storage(&stash, cluster_id), + NodePubKey::CDNPubKey(_node) => Self::do_add_cdn(&stash, cluster_id), + } + + Ok(()) + } + } + impl StakingVisitor for Pallet { fn has_activated_stake( node_pub_key: &NodePubKey, diff --git a/pallets/ddc-staking/src/testing_utils.rs b/pallets/ddc-staking/src/testing_utils.rs index ccccc8f14..7dec075cc 100644 --- a/pallets/ddc-staking/src/testing_utils.rs +++ b/pallets/ddc-staking/src/testing_utils.rs @@ -119,7 +119,7 @@ pub fn create_stash_controller_node_with_balance( } let cluster_id = ClusterId::from([1; 20]); - let cluster_params = ClusterParams { node_provider_auth_contract: stash.clone() }; + let cluster_params = ClusterParams { node_provider_auth_contract: Some(stash.clone()) }; let cluster_gov_params: ClusterGovParams, T::BlockNumber> = ClusterGovParams { treasury_share: Perquintill::default(), validators_share: Perquintill::default(), diff --git a/runtime/cere-dev/Cargo.toml b/runtime/cere-dev/Cargo.toml index 6f5df81a5..e4fbf99f4 100644 --- a/runtime/cere-dev/Cargo.toml +++ b/runtime/cere-dev/Cargo.toml @@ -218,6 +218,7 @@ runtime-benchmarks = [ "pallet-society/runtime-benchmarks", "pallet-staking/runtime-benchmarks", "pallet-ddc-customers/runtime-benchmarks", + "pallet-ddc-clusters/runtime-benchmarks", "pallet-ddc-nodes/runtime-benchmarks", "pallet-ddc-staking/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", diff --git a/runtime/cere-dev/src/lib.rs b/runtime/cere-dev/src/lib.rs index 2d3fc2f98..d39b1f0ad 100644 --- a/runtime/cere-dev/src/lib.rs +++ b/runtime/cere-dev/src/lib.rs @@ -1353,7 +1353,9 @@ impl pallet_ddc_clusters::Config for Runtime { type RuntimeEvent = RuntimeEvent; type NodeRepository = pallet_ddc_nodes::Pallet; type StakingVisitor = pallet_ddc_staking::Pallet; + type StakerCreator = pallet_ddc_staking::Pallet; type Currency = Balances; + type WeightInfo = pallet_ddc_clusters::weights::SubstrateWeight; } parameter_types! { @@ -1541,6 +1543,7 @@ mod benches { [pallet_session, SessionBench::] [pallet_staking, Staking] [pallet_ddc_customers, DdcCustomers] + [pallet_ddc_clusters, DdcClusters] [pallet_ddc_staking, DdcStaking] [pallet_ddc_nodes, DdcNodes] [frame_system, SystemBench::] diff --git a/traits/src/staking.rs b/traits/src/staking.rs index af1a185e2..06697856f 100644 --- a/traits/src/staking.rs +++ b/traits/src/staking.rs @@ -12,6 +12,16 @@ pub trait StakingVisitor { fn has_chilling_attempt(node_pub_key: &NodePubKey) -> Result; } +pub trait StakerCreator { + fn bond_stake_and_participate( + stash: T::AccountId, + controller: T::AccountId, + node: NodePubKey, + value: Balance, + cluster_id: ClusterId, + ) -> sp_runtime::DispatchResult; +} + pub enum StakingVisitorError { NodeStakeDoesNotExist, NodeStakeIsInBadState,