diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8c27dcc..6e171fb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,7 @@ name: DockerMultiplatform on: push: branches: [main] + workflow_dispatch: jobs: build-arm64: runs-on: [self-hosted, linux, ARM64] diff --git a/Cargo.lock b/Cargo.lock index 6e46def..4ad60b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,16 +18,16 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" dependencies = [ - "gimli", + "gimli 0.27.3", ] [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli", + "gimli 0.28.0", ] [[package]] @@ -172,9 +172,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -205,24 +205,23 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" [[package]] name = "anstyle-parse" @@ -244,9 +243,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -254,9 +253,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "approx" @@ -310,7 +309,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.25", + "time", ] [[package]] @@ -326,7 +325,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.25", + "time", ] [[package]] @@ -397,33 +396,33 @@ dependencies = [ [[package]] name = "async-lock" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ "event-listener", ] [[package]] name = "async-recursion" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] name = "async-trait" -version = "0.1.72" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc6dde6e4ed435a4c1ee4e73592f5ba9da2151af10076cc04858746af9352d09" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -436,7 +435,7 @@ dependencies = [ "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", ] [[package]] @@ -464,16 +463,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ - "addr2line 0.20.0", + "addr2line 0.21.0", "cc", "cfg-if", "libc", "miniz_oxide", - "object 0.31.1", + "object 0.32.1", "rustc-demangle", ] @@ -503,9 +502,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64ct" @@ -543,13 +542,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.12", + "prettyplease 0.2.15", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -560,9 +559,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bitvec" @@ -587,24 +586,24 @@ dependencies = [ [[package]] name = "blake2b_simd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.2.6", + "constant_time_eq", ] [[package]] name = "blake2s_simd" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" +checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq 0.2.6", + "constant_time_eq", ] [[package]] @@ -617,7 +616,7 @@ dependencies = [ "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq 0.3.0", + "constant_time_eq", ] [[package]] @@ -695,9 +694,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.6.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", "serde", @@ -714,9 +713,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "byte-slice-cast" @@ -732,9 +731,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" @@ -744,9 +743,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "bzip2-sys" @@ -793,9 +792,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", "libc", @@ -823,9 +822,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.4" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" dependencies = [ "smallvec", ] @@ -869,17 +868,16 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", - "time 0.1.45", "wasm-bindgen", - "winapi", + "windows-targets 0.48.5", ] [[package]] @@ -936,20 +934,19 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.21" +version = "4.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c27cdf28c0f604ba3f512b0c9a409f8de8513e4816705deb0498b627e7c3a3fd" +checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.21" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a9f1ab5e9f01a9b81f202e8562eb9a10de70abf9eaeac1be465c28b75aa4aa" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", @@ -959,21 +956,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "codespan-reporting" @@ -1030,12 +1027,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" -[[package]] -name = "constant_time_eq" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" - [[package]] name = "constant_time_eq" version = "0.3.0" @@ -1106,7 +1097,7 @@ dependencies = [ "cranelift-codegen-shared", "cranelift-entity", "cranelift-isle", - "gimli", + "gimli 0.27.3", "hashbrown 0.13.2", "log", "regalloc2", @@ -1270,9 +1261,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4c2f4e1afd912bc40bfd6fed5d9dc1f288e0ba01bfcc835cc5bc3eb13efe15" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", @@ -1357,23 +1348,37 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-rc.1" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +checksum = "622178105f911d937a42cdb140730ba4a3ed2becd8ae6ce39c7d28b5d75d4588" dependencies = [ "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", "fiat-crypto", - "packed_simd_2", - "platforms 3.0.2", + "platforms 3.1.2", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.36", +] + [[package]] name = "cxx" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1ba0a82363c553ecb7b4cd58ba6e1c017baef8e3cca4e7d66ca17879201144" +checksum = "bbe98ba1789d56fb3db3bee5e032774d4f421b685de7ba703643584ba24effbe" dependencies = [ "cc", "cxxbridge-flags", @@ -1383,9 +1388,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac9ec8372f860c6ee7c6463b96a26d08dd590bcbcd9bf2d1894db09ae81410d3" +checksum = "c4ce20f6b8433da4841b1dadfb9468709868022d829d5ca1f2ffbda928455ea3" dependencies = [ "cc", "codespan-reporting", @@ -1393,24 +1398,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] name = "cxxbridge-flags" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "409667bbb937bae87f7cfa91ca29e1415bb92d415371e3344b5269c10d90d595" +checksum = "20888d9e1d2298e2ff473cee30efe7d5036e437857ab68bbfea84c74dba91da2" [[package]] name = "cxxbridge-macro" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fb2a9757fb085d6d97856b28d4f049141ca4a61a64c697f4426433b5f6caa1f" +checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -1525,9 +1530,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" [[package]] name = "derive-syn-parse" @@ -1667,7 +1672,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -1711,9 +1716,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "ecdsa" @@ -1750,6 +1755,16 @@ dependencies = [ "signature 1.6.4", ] +[[package]] +name = "ed25519" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +dependencies = [ + "pkcs8 0.10.2", + "signature 2.1.0", +] + [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -1757,13 +1772,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek 3.2.0", - "ed25519", - "rand 0.7.3", - "serde", + "ed25519 1.5.3", "sha2 0.9.9", "zeroize", ] +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek 4.1.0", + "ed25519 2.2.2", + "rand_core 0.6.4", + "serde", + "sha2 0.10.7", + "zeroize", +] + [[package]] name = "ed25519-zebra" version = "3.1.0" @@ -1813,7 +1840,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "968405c8fdc9b3bf4df0a6638858cc0b52462836ab6b1c87377785dd09cf1c0b" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.2", + "crypto-bigint 0.5.3", "digest 0.10.7", "ff 0.13.0", "generic-array 0.14.7", @@ -1870,9 +1897,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -1975,9 +2002,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.20" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" +checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" [[package]] name = "file-per-thread-logger" @@ -2037,9 +2064,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "libz-sys", @@ -2253,7 +2280,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -2265,7 +2292,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -2275,7 +2302,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -2355,7 +2382,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.38.7", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -2378,13 +2405,13 @@ dependencies = [ [[package]] name = "functionland-fula" version = "0.1.0" -source = "git+https://github.com/functionland/fula-pallet?branch=fula/release#86b8e1a6d157ea59c9fcdfb88bb04fae788e939d" +source = "git+https://github.com/functionland/fula-pallet?branch=main#0f8a1ce097c8099b7b1e86da28092225c16c07db" dependencies = [ "frame-benchmarking", "frame-support", "frame-system", "fula-pool", - "libm 0.2.7", + "libm", "pallet-balances", "parity-scale-codec", "scale-info", @@ -2462,7 +2489,7 @@ dependencies = [ "futures-io", "memchr", "parking", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "waker-fn", ] @@ -2474,7 +2501,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -2484,8 +2511,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" dependencies = [ "futures-io", - "rustls 0.20.8", - "webpki 0.22.0", + "rustls 0.20.9", + "webpki 0.22.1", ] [[package]] @@ -2519,7 +2546,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "pin-utils", "slab", ] @@ -2618,6 +2645,12 @@ dependencies = [ "stable_deref_trait", ] +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + [[package]] name = "glob" version = "0.3.1" @@ -2661,9 +2694,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -2680,9 +2713,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.3.7" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c3372087601b532857d332f5957cbae686da52bb7810bf038c3e3c3cc2fa0d" +checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" dependencies = [ "log", "pest", @@ -2813,6 +2846,15 @@ dependencies = [ "hmac 0.8.1", ] +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + [[package]] name = "hostname" version = "0.3.1" @@ -2843,7 +2885,7 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", ] [[package]] @@ -2860,9 +2902,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -2886,7 +2928,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "socket2 0.4.9", "tokio", "tower-service", @@ -2903,11 +2945,27 @@ dependencies = [ "http", "hyper", "log", - "rustls 0.20.8", + "rustls 0.20.9", + "rustls-native-certs", + "tokio", + "tokio-rustls 0.23.4", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +dependencies = [ + "futures-util", + "http", + "hyper", + "log", + "rustls 0.21.7", "rustls-native-certs", "tokio", - "tokio-rustls", - "webpki-roots", + "tokio-rustls 0.24.1", + "webpki-roots 0.23.1", ] [[package]] @@ -3127,7 +3185,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.3", + "socket2 0.5.4", "widestring", "windows-sys 0.48.0", "winreg", @@ -3146,7 +3204,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.2", - "rustix 0.38.7", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -3185,9 +3243,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" +checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" dependencies = [ "jsonrpsee-core", "jsonrpsee-http-client", @@ -3200,9 +3258,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb" +checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" dependencies = [ "futures-util", "http", @@ -3213,17 +3271,17 @@ dependencies = [ "soketto", "thiserror", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-util", "tracing", - "webpki-roots", + "webpki-roots 0.25.2", ] [[package]] name = "jsonrpsee-core" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4e70b4439a751a5de7dd5ed55eacff78ebf4ffe0fc009cb1ebb11417f5b536b" +checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", "arrayvec 0.7.4", @@ -3249,13 +3307,13 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc345b0a43c6bc49b947ebeb936e886a419ee3d894421790c969cc56040542ad" +checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" dependencies = [ "async-trait", "hyper", - "hyper-rustls", + "hyper-rustls 0.24.1", "jsonrpsee-core", "jsonrpsee-types", "rustc-hash", @@ -3268,9 +3326,9 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baa6da1e4199c10d7b1d0a6e5e8bd8e55f351163b6f4b3cbb044672a69bd4c1c" +checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" dependencies = [ "heck", "proc-macro-crate", @@ -3281,9 +3339,9 @@ dependencies = [ [[package]] name = "jsonrpsee-server" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb69dad85df79527c019659a992498d03f8495390496da2f07e6c24c2b356fc" +checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" dependencies = [ "futures-channel", "futures-util", @@ -3303,9 +3361,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bd522fe1ce3702fd94812965d7bb7a3364b1c9aba743944c5a00529aae80f8c" +checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" dependencies = [ "anyhow", "beef", @@ -3317,9 +3375,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b83daeecfc6517cfe210df24e570fb06213533dfb990318fae781f4c7119dd9" +checksum = "4e1b3975ed5d73f456478681a417128597acd6a2487855fdb7b4a3d4d195bf5e" dependencies = [ "http", "jsonrpsee-client-transport", @@ -3396,9 +3454,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libloading" @@ -3410,12 +3468,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - [[package]] name = "libm" version = "0.2.7" @@ -3546,12 +3598,12 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" +checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek", + "ed25519-dalek 2.0.0", "log", "multiaddr", "multihash 0.17.0", @@ -3682,7 +3734,7 @@ dependencies = [ "parking_lot 0.12.1", "quinn-proto", "rand 0.8.5", - "rustls 0.20.8", + "rustls 0.20.9", "thiserror", "tokio", ] @@ -3763,9 +3815,9 @@ dependencies = [ "libp2p-identity", "rcgen 0.10.0", "ring", - "rustls 0.20.8", + "rustls 0.20.9", "thiserror", - "webpki 0.22.0", + "webpki 0.22.1", "x509-parser 0.14.0", "yasna", ] @@ -3831,7 +3883,7 @@ dependencies = [ "rw-stream-sink", "soketto", "url", - "webpki-roots", + "webpki-roots 0.22.6", ] [[package]] @@ -3947,9 +3999,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" +checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" dependencies = [ "nalgebra", ] @@ -3968,9 +4020,9 @@ checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "lock_api" @@ -3984,9 +4036,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" @@ -4092,9 +4144,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memfd" @@ -4453,9 +4505,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -4464,9 +4516,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ "num-traits", ] @@ -4542,9 +4594,9 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -4613,16 +4665,6 @@ dependencies = [ "sha2 0.10.7", ] -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if", - "libm 0.1.4", -] - [[package]] name = "pallet-aura" version = "4.0.0-dev" @@ -4735,7 +4777,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -4894,9 +4936,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78f19d20a0d2cc52327a88d131fa1c4ea81ea4a04714aedcfeca2dd410049cf8" +checksum = "ab512a34b3c2c5e465731cc7668edf79208bbe520be03484eeb05e63ed221735" dependencies = [ "blake2", "crc32fast", @@ -4914,9 +4956,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -4929,9 +4971,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -5002,7 +5044,7 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -5067,19 +5109,20 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" +checksum = "d7a4d085fd991ac8d5b05a147b437791b4260b76326baf0fc60cf7c9c27ecd33" dependencies = [ + "memchr", "thiserror", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" +checksum = "a2bee7be22ce7918f641a33f08e3f43388c7656772244e2bbb2477f44cc9021a" dependencies = [ "pest", "pest_generator", @@ -5087,22 +5130,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" +checksum = "d1511785c5e98d79a05e8a6bc34b4ac2168a0e3e92161862030ad84daa223141" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] name = "pest_meta" -version = "2.7.2" +version = "2.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" +checksum = "b42f0394d3123e33353ca5e1e89092e533d2cc490389f2bd6131c43c634ebc5f" dependencies = [ "once_cell", "pest", @@ -5111,12 +5154,12 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap 2.0.0", ] [[package]] @@ -5136,7 +5179,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -5147,9 +5190,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.11" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c516611246607d0c04186886dbb3a754368ef82c79e9827a802c6d836dd111c" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -5191,9 +5234,9 @@ checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" [[package]] name = "platforms" -version = "3.0.2" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d7ddaed09e0eb771a79ab0fd64609ba0afb0a8366421957936ad14cbd13630" +checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" [[package]] name = "polling" @@ -5207,7 +5250,7 @@ dependencies = [ "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "windows-sys 0.48.0", ] @@ -5248,9 +5291,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f32154ba0af3a075eefa1eda8bb414ee928f62303a54ea85b8d6638ff1a6ee9e" +checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" [[package]] name = "ppv-lite86" @@ -5300,12 +5343,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64d9ba0963cdcea2e1b2230fbae2bab30eb25a174be395c41e764bfb65dd62" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -5363,14 +5406,14 @@ checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] @@ -5403,13 +5446,13 @@ dependencies = [ [[package]] name = "prometheus-client-derive-encode" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b6a5217beb0ad503ee7fa752d451c905113d70721b937126158f3106a48cc1" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.36", ] [[package]] @@ -5524,19 +5567,19 @@ dependencies = [ "rand 0.8.5", "ring", "rustc-hash", - "rustls 0.20.8", + "rustls 0.20.9", "slab", "thiserror", "tinyvec", "tracing", - "webpki 0.22.0", + "webpki 0.22.1", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -5663,7 +5706,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.25", + "time", "x509-parser 0.13.2", "yasna", ] @@ -5676,7 +5719,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.25", + "time", "yasna", ] @@ -5711,22 +5754,22 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ef7e18e8841942ddb1cf845054f8008410030a3997875d9e49b7a363063df1" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfaf0c85b766276c797f3791f5bc6d5bd116b41d53049af2789666b0c0bc9fa" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -5743,14 +5786,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.6", - "regex-syntax 0.7.4", + "regex-automata 0.3.8", + "regex-syntax 0.7.5", ] [[package]] @@ -5764,13 +5807,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", ] [[package]] @@ -5781,9 +5824,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "resolv-conf" @@ -5968,14 +6011,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.7" +version = "0.38.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "172891ebdceb05aa0005f533a6cbfca599ddd7d966f6f5d4d9b2e70478e70399" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys 0.4.7", "windows-sys 0.48.0", ] @@ -5994,14 +6037,26 @@ dependencies = [ [[package]] name = "rustls" -version = "0.20.8" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +dependencies = [ + "log", + "ring", + "sct 0.7.0", + "webpki 0.22.1", +] + +[[package]] +name = "rustls" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", + "rustls-webpki 0.101.5", "sct 0.7.0", - "webpki 0.22.0", ] [[package]] @@ -6022,7 +6077,27 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.2", + "base64 0.21.4", +] + +[[package]] +name = "rustls-webpki" +version = "0.100.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" +dependencies = [ + "ring", + "untrusted", ] [[package]] @@ -6142,7 +6217,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -6639,7 +6714,7 @@ dependencies = [ "futures", "futures-timer", "hyper", - "hyper-rustls", + "hyper-rustls 0.23.2", "libp2p", "num_cpus", "once_cell", @@ -6945,7 +7020,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -7216,29 +7291,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.183" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -7335,9 +7410,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" [[package]] name = "signal-hook-registry" @@ -7383,15 +7458,15 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -7416,14 +7491,14 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" +checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" dependencies = [ "aes-gcm 0.9.4", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", + "curve25519-dalek 4.1.0", "rand_core 0.6.4", "ring", "rustc_version", @@ -7443,9 +7518,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -7499,7 +7574,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -7709,7 +7784,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -7728,7 +7803,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -7763,8 +7838,8 @@ version = "7.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" dependencies = [ "bytes", - "ed25519", - "ed25519-dalek", + "ed25519 1.5.3", + "ed25519-dalek 1.0.1", "futures", "libsecp256k1", "log", @@ -7907,7 +7982,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -8093,7 +8168,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -8170,9 +8245,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.41.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfc443bad666016e012538782d9e3006213a7db43e9fb1dda91657dc06a6fa08" +checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" dependencies = [ "Inflector", "num-format", @@ -8347,7 +8422,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.6", + "toml 0.7.8", "walkdir", "wasm-opt", ] @@ -8644,9 +8719,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "91e02e55d62894af2a08aca894c6577281f76769ba47c94d5756bec8ac6e7373" dependencies = [ "proc-macro2", "quote", @@ -8700,14 +8775,14 @@ checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "tempfile" -version = "3.7.1" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ "cfg-if", "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix 0.38.7", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -8728,22 +8803,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -8783,20 +8858,9 @@ dependencies = [ [[package]] name = "time" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "time" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ "deranged", "itoa", @@ -8813,9 +8877,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -8866,20 +8930,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.1" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "532826ff75199d5833b9d2c5fe410f29235e25704ee5f0ef599fb51c21f4a4da" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg", "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2 0.4.9", + "socket2 0.5.4", "tokio-macros", "windows-sys 0.48.0", ] @@ -8892,7 +8955,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -8912,9 +8975,19 @@ version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" dependencies = [ - "rustls 0.20.8", + "rustls 0.20.9", + "tokio", + "webpki 0.22.1", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.7", "tokio", - "webpki 0.22.0", ] [[package]] @@ -8924,7 +8997,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "tokio", "tokio-util", ] @@ -8939,7 +9012,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "tokio", "tracing", ] @@ -8955,9 +9028,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" dependencies = [ "serde", "serde_spanned", @@ -8976,9 +9049,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap 2.0.0", "serde", @@ -9000,18 +9073,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.0", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "tower-layer", "tower-service", ] @@ -9036,7 +9109,7 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.11", + "pin-project-lite 0.2.13", "tracing-attributes", "tracing-core", ] @@ -9049,7 +9122,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] @@ -9266,9 +9339,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ucd-trie" @@ -9296,9 +9369,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -9343,9 +9416,9 @@ dependencies = [ [[package]] name = "unsigned-varint" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86a8dc7f45e4c1b0d30e43038c38f274e77af056aa5f74b93c2cf9eb3c1c836" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" dependencies = [ "asynchronous-codec", "bytes", @@ -9361,9 +9434,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna 0.4.0", @@ -9426,9 +9499,9 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" dependencies = [ "same-file", "winapi-util", @@ -9449,12 +9522,6 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -9482,7 +9549,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", "wasm-bindgen-shared", ] @@ -9516,7 +9583,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9645,7 +9712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" dependencies = [ "downcast-rs", - "libm 0.2.7", + "libm", "memory_units", "num-rational", "num-traits", @@ -9658,7 +9725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624e6333e861ef49095d2d678b76ebf30b06bf37effca845be7e5b87c90071b7" dependencies = [ "downcast-rs", - "libm 0.2.7", + "libm", "num-traits", "paste", ] @@ -9726,7 +9793,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.2", + "base64 0.21.4", "bincode", "directories-next", "file-per-thread-logger", @@ -9751,7 +9818,7 @@ dependencies = [ "cranelift-frontend", "cranelift-native", "cranelift-wasm", - "gimli", + "gimli 0.27.3", "log", "object 0.30.4", "target-lexicon", @@ -9770,7 +9837,7 @@ dependencies = [ "anyhow", "cranelift-codegen", "cranelift-native", - "gimli", + "gimli 0.27.3", "object 0.30.4", "target-lexicon", "wasmtime-environ", @@ -9784,7 +9851,7 @@ checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" dependencies = [ "anyhow", "cranelift-entity", - "gimli", + "gimli 0.27.3", "indexmap 1.9.3", "log", "object 0.30.4", @@ -9806,7 +9873,7 @@ dependencies = [ "bincode", "cfg-if", "cpp_demangle", - "gimli", + "gimli 0.27.3", "log", "object 0.30.4", "rustc-demangle", @@ -9899,9 +9966,9 @@ dependencies = [ [[package]] name = "webpki" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +checksum = "f0e74f82d49d545ad128049b7e88f6576df2da6b02e9ce565c6f533be576957e" dependencies = [ "ring", "untrusted", @@ -9913,9 +9980,24 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki 0.22.1", +] + +[[package]] +name = "webpki-roots" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" +dependencies = [ + "rustls-webpki 0.100.3", ] +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + [[package]] name = "webrtc" version = "0.6.0" @@ -9942,7 +10024,7 @@ dependencies = [ "sha2 0.10.7", "stun", "thiserror", - "time 0.3.25", + "time", "tokio", "turn", "url", @@ -9974,9 +10056,9 @@ dependencies = [ [[package]] name = "webrtc-dtls" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" +checksum = "c4a00f4242f2db33307347bd5be53263c52a0331c96c14292118c9a6bb48d267" dependencies = [ "aes 0.6.0", "aes-gcm 0.10.2", @@ -9991,12 +10073,11 @@ dependencies = [ "hkdf", "hmac 0.12.1", "log", - "oid-registry 0.6.1", "p256", "p384", "rand 0.8.5", "rand_core 0.6.4", - "rcgen 0.9.3", + "rcgen 0.10.0", "ring", "rustls 0.19.1", "sec1 0.3.0", @@ -10009,7 +10090,7 @@ dependencies = [ "tokio", "webpki 0.21.4", "webrtc-util", - "x25519-dalek 2.0.0-pre.1", + "x25519-dalek 2.0.0", "x509-parser 0.13.2", ] @@ -10127,13 +10208,14 @@ dependencies = [ [[package]] name = "which" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" dependencies = [ "either", - "libc", + "home", "once_cell", + "rustix 0.38.13", ] [[package]] @@ -10202,7 +10284,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -10220,7 +10302,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.1", + "windows-targets 0.48.5", ] [[package]] @@ -10240,17 +10322,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -10261,9 +10343,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -10279,9 +10361,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -10297,9 +10379,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -10315,9 +10397,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -10333,9 +10415,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -10345,9 +10427,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -10363,15 +10445,15 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.4" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acaaa1190073b2b101e15083c38ee8ec891b5e05cbee516521e94ec008f61e64" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] @@ -10408,12 +10490,13 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "2.0.0-pre.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek 4.1.0", "rand_core 0.6.4", + "serde", "zeroize", ] @@ -10433,7 +10516,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.25", + "time", ] [[package]] @@ -10451,7 +10534,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.25", + "time", ] [[package]] @@ -10474,7 +10557,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.25", + "time", ] [[package]] @@ -10494,7 +10577,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.36", ] [[package]] diff --git a/LICENSE b/LICENSE index 8b13789..c5defcd 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1 @@ - +SBP-M1 review: empty license file diff --git a/README.md b/README.md index da5a260..89952ec 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[//]: # (SBP-M1 review: needs updating to Functionland, with link to forked repo) ![SugarFunge](/docs/sf-name.png) # Substrate-based SugarFunge Node @@ -7,7 +8,6 @@ Read more about [Owned Economies](https://github.com/SugarFunge/OwnedEconomies). ## Local Testnet - > **Important**: to be able to use all [sugarfunge-api](https://github.com/functionland/sugarfunge-api) endpoints without problem you must run at least two validators
@@ -20,7 +20,6 @@ Read more about [Owned Economies](https://github.com/SugarFunge/OwnedEconomies). cargo run --release -- --chain ./customSpecRaw.json --enable-offchain-indexing true --base-path=/var/lib/.sugarfunge-node/data/node01 --keystore-path=/var/lib/.sugarfunge-node/keys/node01 --port=30334 --rpc-port 9944 --rpc-cors=all --rpc-methods=Unsafe --rpc-external --validator --name MyNode01 --password-filename="/var/lib/.sugarfunge-node/passwords/password1.txt" --node-key=peerID_secret_key ``` - 2nd Validator: ``` bash ./target/release/sugarfunge-node key insert --base-path=/var/lib/.sugarfunge-node/data/node02 --keystore-path=/var/lib/.sugarfunge-node/keys/node02 --chain customSpecRaw.json --scheme Sr25519 --suri "word1 ... word12" --password-filename "/var/lib/.sugarfunge-node/passwords/password2.txt" --key-type aura @@ -29,3 +28,7 @@ cargo run --release -- --chain ./customSpecRaw.json --enable-offchain-indexing t cargo run --release -- --chain ./customSpecRaw.json --enable-offchain-indexing true --base-path=/var/lib/.sugarfunge-node/data/node02 --keystore-path=/var/lib/.sugarfunge-node/keys/node02 --port=30335 --rpc-port 9945 --rpc-cors=all --rpc-methods=Unsafe --rpc-external --validator --name MyNode02 --password-filename="/var/lib/.sugarfunge-node/passwords/password2.txt" --node-key=peerID_secret_key --bootnodes /ip4/127.0.0.1/tcp/30334/p2p/12D3KooWBeXV65svCyknCvG1yLxXVFwRxzBLqvBJnUF6W84BLugv ``` +[//]: # (SBP-M1 review: insufficient documentation) +[//]: # (SBP-M1 review: limited tests) +[//]: # (SBP-M1 review: LICENSE file empty) +[//]: # (SBP-M1 review: `docker run functionland/node:release` fails with `/run_node.sh: 11: wait: Illegal option -n`) \ No newline at end of file diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 9a269a7..c9aff45 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -1,3 +1,5 @@ +[//]: # (SBP-M1 review: appears to be taken from docs.substrate.io without attribution) + # Substrate SugarFunge Node A fresh FRAME-based [Substrate](https://www.substrate.io/) node, ready for hacking :rocket: @@ -32,6 +34,7 @@ cargo build --release Once the project has been built, the following command can be used to explore all parameters and subcommands: +[//]: # (SBP-M1 review: node binary is `sugarfunge-node` - same mistake made throughout doc) ```sh ./target/release/sf-node -h ``` @@ -65,6 +68,8 @@ RUST_LOG=debug RUST_BACKTRACE=1 ./target/release/sf-node -lruntime=debug --dev ### Multi-Node Local Testnet If you want to see the multi-node consensus algorithm in action, refer to + +[//]: # (SBP-M1 review: broken link) [our Start a Private Network tutorial](https://substrate.dev/docs/en/tutorials/start-a-private-network/). ## Template Structure diff --git a/docs/rust-setup.md b/docs/rust-setup.md index 34f6e43..b8cf788 100644 --- a/docs/rust-setup.md +++ b/docs/rust-setup.md @@ -2,6 +2,8 @@ title: Installation --- +[//]: # (SBP-M1 review: appears to be taken from docs.substrate.io without attribution) + This page will guide you through the steps needed to prepare a computer for development with the Substrate Node Template. Since Substrate is built with [the Rust programming language](https://www.rust-lang.org/), the first thing you will need to do is diff --git a/node/Cargo.toml b/node/Cargo.toml index 8b837b1..d04c5f2 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -5,6 +5,7 @@ authors = ["SugarFunge Developers"] edition = "2021" license = "Proprietary" build = "build.rs" +#SBP-M1 review: no description, repository [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -16,8 +17,10 @@ name = "sugarfunge-node" clap = { version = "4.0.22", features = ["derive"] } futures = { version = "0.3.21", features = ["thread-pool"]} serde_json = "1.0.96" +#SBP-M1 review: unused? getrandom = { version = "0.2", features = ["js"] } tokio = { version = "1.22.0" } +#SBP-M1 review: outdated bs58 = { version = "0.4.0" } sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } @@ -44,6 +47,7 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "polk pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } # These dependencies are used for SugarFunge's RPCs +#SBP-M1 review: outdated jsonrpsee = { version = "0.16.2", features = ["server"] } sc-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } diff --git a/pallets/bag/Cargo.toml b/pallets/bag/Cargo.toml index fbdcc81..d6ad712 100644 --- a/pallets/bag/Cargo.toml +++ b/pallets/bag/Cargo.toml @@ -3,14 +3,16 @@ name = 'sugarfunge-bag' version = "0.1.0" authors = ["SugarFunge Developers"] edition = "2021" +#SBP-M1 review: ensure that licenses satisfy the requirements of all dependencies license = "Proprietary" +#SBP-M1 review: no description, repository [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies] - codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } +#SBP-M1 review: appears unused, remove scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } integer-sqrt = "0.1.5" frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } @@ -19,14 +21,17 @@ frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } +#SBP-M1 review: appears unused, remove pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sugarfunge-primitives = { git = "https://github.com/SugarFunge/sugarfunge-primitives", branch = "fula/release", default-features = false } sugarfunge-asset = { git = "https://github.com/SugarFunge/sugarfunge-asset", branch = "fula/release", default-features = false } +#SBP-M1 review: external dependencies not reviewed, but quick glance shows issues such as no benchmarks, invalid weights, unnecessary cargo.lock, minimal tests [dev-dependencies] +#SBP-M1 review: not required if listed within dependencies above sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } diff --git a/pallets/bag/README.md b/pallets/bag/README.md index 8d751a4..4fc6002 100644 --- a/pallets/bag/README.md +++ b/pallets/bag/README.md @@ -1 +1,4 @@ -License: Unlicense \ No newline at end of file +[//]: # (SBP-M1 review: license does not match cargo.toml) +License: Unlicense + +[//]: # (SBP-M1 review: no documentation) \ No newline at end of file diff --git a/pallets/bag/src/benchmarking.rs b/pallets/bag/src/benchmarking.rs index c343d6c..a1f1577 100644 --- a/pallets/bag/src/benchmarking.rs +++ b/pallets/bag/src/benchmarking.rs @@ -7,10 +7,13 @@ use crate::Pallet as Bag; use frame_benchmarking::v2::*; use frame_system::RawOrigin; +// SBP-M1 review: missing benchmarks for dispatchable functions +// SBP-M1 review: add ci to require successful benchmark tests before merging #[benchmarks] mod benchmarks { use super::*; + // SBP-M1 review: remove sample benchmark #[benchmark] fn do_something() { let value = 100u32.into(); @@ -20,6 +23,7 @@ mod benchmarks { assert_eq!(Something::::get(), Some(value)); } + // SBP-M1 review: remove sample benchmark #[benchmark] fn verify() { assert_eq!(Something::::get(), Some(s)); diff --git a/pallets/bag/src/lib.rs b/pallets/bag/src/lib.rs index 156677d..4712754 100644 --- a/pallets/bag/src/lib.rs +++ b/pallets/bag/src/lib.rs @@ -24,6 +24,7 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +// SBP-M1 review: move within pallet module as only used there type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -33,12 +34,15 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + // SBP-M1 review: remove template comment /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] + // SBP-M1 review: loose pallet coupling preferable, can sugarfunge_asset dependency be brought in via trait (associated type on this pallets Config trait)? pub trait Config: frame_system::Config + sugarfunge_asset::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; + // SBP-M1 review: add doc comment type PalletId: Get; /// Max number of owners @@ -49,6 +53,7 @@ pub mod pallet { #[pallet::constant] type CreateBagDeposit: Get>; + // SBP-M1 review: add doc comment type Currency: Currency + ReservableCurrency; } @@ -68,6 +73,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] + // SBP-M1 review: add doc comments pub enum Event { Register { who: T::AccountId, @@ -91,8 +97,10 @@ pub mod pallet { }, } + // SBP-M1 review: remove template comment // Errors inform users that something went wrong. #[pallet::error] + // SBP-M1 review: add doc comments pub enum Error { BagClassExists, BagExists, @@ -104,72 +112,107 @@ pub mod pallet { InsufficientShares, } + // SBP-M1 review: remove template comment // Dispatchable functions allows users to interact with the pallet and invoke state changes. // These functions materialize as "extrinsics", which are often compared to transactions. // Dispatchable functions must be annotated with a weight and must return a DispatchResult. #[pallet::call] impl Pallet { + // SBP-M1 review: add doc comments #[pallet::call_index(0)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn register( origin: OriginFor, class_id: T::ClassId, + // SBP-M1 review: redefine this type on this pallets Config to avoid tight pallet coupling - runtime can reuse same types to configure as appropriate metadata: sugarfunge_asset::ClassMetadataOf, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: could simplify and just return value from Self::do_register(..) Self::do_register(&who, class_id, metadata)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } + // SBP-M1 review: whilst a deposit is taken for a bag, anyone can call this to create bags and mint tokens. Consider whether this should perhaps be limited to the class owner or governance? + // SBP-M1 review: add doc comments + // SBP-M1 review: register(..) and create(..) names too similar, consider improving naming to be more explicit #[pallet::call_index(1)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn create( origin: OriginFor, class_id: T::ClassId, + // SBP-M1 review: use bounded vectors + // SBP-M1 review: use tuple - e.g. `shares: BoundedVec<(T::AccountId, T::Balance), T::MaxShares>` owners: Vec, + // SBP-M1 review: consider the regulatory impact of the term shares shares: Vec, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: could simplify and just return value from Self::do_create(..) Self::do_create(&who, class_id, &owners, &shares)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } + // SBP-M1 review: add doc comments #[pallet::call_index(2)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn deposit( origin: OriginFor, bag: T::AccountId, + // SBP-M1 review: use bounded vectors + // SBP-M1 review: use tuple to collect corresponding values together - e.g. BoundedVec<(T::ClassId, BoundedVec<(T::AssetId, T::Balance), Max>), Max> class_ids: Vec, asset_ids: Vec>, amounts: Vec>, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: could simplify and just return value from Self::do_deposit(..) Self::do_deposit(&who, &bag, class_ids, asset_ids, amounts)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } + // SBP-M1 review: add doc comments #[pallet::call_index(3)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn sweep( origin: OriginFor, + // SBP-M1 review: consider reordering so 'to' is last (from > to) to: T::AccountId, bag: T::AccountId, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: could simplify and just return value from Self::do_sweep(..) Self::do_sweep(&who, &to, &bag)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } } } +// SBP-M1 review: add doc comment for struct #[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct BagClass { /// The operator of the bag @@ -178,6 +221,7 @@ pub struct BagClass { pub class_id: ClassId, } +// SBP-M1 review: add doc comment for struct #[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct Bag { /// The operator of the bag @@ -187,6 +231,7 @@ pub struct Bag { /// The asset_id for minting shares pub asset_id: AssetId, /// Total number of shares + // SBP-M1 review: consider making Balance a type on Config - runtime can configure it with type from primitives pub total_shares: Balance, } @@ -194,14 +239,19 @@ impl Pallet { pub fn do_register( who: &T::AccountId, class_id: T::ClassId, + // SBP-M1 review: not consumed, can pass by reference metadata: sugarfunge_asset::ClassMetadataOf, ) -> DispatchResult { ensure!( + // SBP-M1 review: needless borrow !BagClasses::::contains_key(&class_id), Error::::BagClassExists ); + // SBP-M1 review: refactor into account_id() function let owner = ::PalletId::get().into_account_truncating(); + // SBP-M1 review: access via trait bounds on Config item - e.g. type Asset : CreateClass + // SBP-M1 review: unnecessary clone and needless borrows sugarfunge_asset::Pallet::::do_create_class(&who, &owner, class_id, metadata.clone())?; let bag_class = BagClass { @@ -209,9 +259,12 @@ impl Pallet { class_id, }; + // SBP-M1 review: BagClasses are never removed, consider mechanism for avoiding state bloat + // SBP-M1 review: BagClasses removal should also remove NextBagId entry BagClasses::::insert(class_id, &bag_class); Self::deposit_event(Event::Register { + // SBP-M1 review: unnecessary clone who: who.clone(), class_id, }); @@ -219,58 +272,78 @@ impl Pallet { Ok(()) } + // SBP-M1 review: too many lines, refactor pub fn do_create( who: &T::AccountId, class_id: T::ClassId, + // SBP-M1 review: use bounded vectors + // SBP-M1 review: combine into single parameter using tuple owners: &Vec, shares: &Vec, + // SBP-M1 review: return type not used anywhere, use DispatchResult ) -> Result { ensure!( + // SBP-M1 review: needless borrow BagClasses::::contains_key(&class_id), Error::::InvalidBagClass ); + // SBP-M1 review: using bounded vector of tuples avoids this ensure!(owners.len() == shares.len(), Error::::InvalidArrayLength); + // SBP-M1 review: try_mutate unnecessary as no error returned, use .mutate(). Safe math fix will require try_mutate however, returning ArithmeticError::Overflow depending on id value + // SBP-M1 review: needless borrow let bag_id = NextBagId::::try_mutate(&class_id, |id| -> Result { let current_id = *id; + // SBP-M1 review: use safe math *id = *id + 1; Ok(current_id) })?; + // SBP-M1 review: convert directly into u64 to save a cast let block_number: u32 = >::block_number().unique_saturated_into(); let sub = vec![block_number as u64, class_id.into(), bag_id]; let bag = ::PalletId::get().into_sub_account_truncating(sub); ensure!(!Bags::::contains_key(&bag), Error::::BagExists); + // SBP-M1 review: consider whether bag deposit should increase based on number of shares. A static deposit value may not account for very large share structures. let deposit = T::CreateBagDeposit::get(); ::Currency::transfer(who, &bag, deposit, AllowDeath)?; let asset_id: T::AssetId = bag_id.into(); + // SBP-M1 review: refactor into account_id() function let operator: T::AccountId = ::PalletId::get().into_account_truncating(); // Mint shares for each owner + // SBP-M1 review: iteration should be bounded to complete within block limits. Each iteration is adding state and should be benchmarked accordingly. for (idx, owner) in owners.iter().enumerate() { + // SBP-M1 review: access via trait bounds on Config item - e.g. type Asset : CreateClass + Mint sugarfunge_asset::Pallet::::do_mint( &operator, + // SBP-M1 review: needless borrow &owner, class_id, asset_id, + // SBP-M1 review: indexing may panic, .get() preferred. Eliminated by using tuple as suggested above shares[idx], )?; } let new_bag = Bag { + // SBP-M1 review: unnecessary clone operator: operator.clone(), class_id, asset_id, total_shares: shares.iter().sum(), }; + // SBP-M1 review: Bags are never removed, consider mechanism for avoiding state bloat + // SBP-M1 review: corresponding bag accounts need cleanup when bag removed, with deposit returned Bags::::insert(&bag, &new_bag); + // SBP-M1 review: unnecessary clones Self::deposit_event(Event::Created { bag: bag.clone(), who: who.clone(), @@ -279,18 +352,22 @@ impl Pallet { owners: owners.clone(), }); + // SBP-M1 review: unnecessary clone and return type not used Ok(bag.clone()) } pub fn do_deposit( who: &T::AccountId, bag: &T::AccountId, + // SBP-M1 review: combine values into tuple to eliminate length checking and simplify iteration class_ids: Vec, asset_ids: Vec>, amounts: Vec>, ) -> DispatchResult { + // SBP-M1 review: needless borrow ensure!(Bags::::contains_key(&bag), Error::::InvalidBag); + // SBP-M1 review: can be eliminated by using tuple ensure!( class_ids.len() == amounts.len(), Error::::InvalidArrayLength @@ -300,47 +377,62 @@ impl Pallet { Error::::InvalidArrayLength ); + // SBP-M1 review: iteration should be bounded to complete within block limits. Each iteration is changing state and should be benchmarked accordingly. for (idx, class_id) in class_ids.iter().enumerate() { + // SBP-M1 review: improve parameter data type to avoid this ensure!( + // SBP-M1 review: indexing may panic, .get() preferred. Can be eliminated by improving parameter type asset_ids[idx].len() == amounts[idx].len(), Error::::InvalidArrayLength ); + // SBP-M1 review: access via trait bounds on Config item - e.g. type Asset : CreateClass + Mint + BatchTransfer sugarfunge_asset::Pallet::::do_batch_transfer_from( + // SBP-M1 review: needless borrows &who, &who, &bag, *class_id, + // SBP-M1 review: indexing may panic, .get() preferred. Can be eliminated by improving parameter type asset_ids[idx].clone(), amounts[idx].clone(), )?; } + // SBP-M1 review: unnecessary clones Self::deposit_event(Event::Deposit { bag: bag.clone(), who: who.clone(), }); + // SBP-M1 review: unnecessary .into() Ok(().into()) } + // SBP-M1 review: should sweep not remove bag from Bags storage item? + // SBP-M1 review: too many lines, refactor pub fn do_sweep( who: &T::AccountId, to: &T::AccountId, bag: &T::AccountId, + // SBP-M1 review: return type not used anywhere, use DispatchResult ) -> Result<(Vec, Vec>, Vec>), DispatchError> { let bag_info = Bags::::get(bag).ok_or(Error::::InvalidBag)?; + // SBP-M1 review: access via trait bounds on Config item - e.g. type Asset : Inspect let shares = sugarfunge_asset::Pallet::::balance_of(who, bag_info.class_id, bag_info.asset_id); ensure!( + // SBP-M1 review: shares >= bag_info.total_shares ? shares == bag_info.total_shares, Error::::InsufficientShares ); + // SBP-M1 review: refactor into account_id() function let operator: T::AccountId = ::PalletId::get().into_account_truncating(); // Burn bag shares + // SBP-M1 review: access via trait bounds on Config item - e.g. type Asset : Burn sugarfunge_asset::Pallet::::do_burn( &operator, who, @@ -349,14 +441,20 @@ impl Pallet { bag_info.total_shares, )?; + // SBP-M1 review: access via trait bounds on Config item - e.g. type Asset : Inspect + // SBP-M1 review: needless borrow let balances = sugarfunge_asset::Pallet::::balances_of_owner(&bag)?; + // SBP-M1 review: iteration should be bounded to complete within block limits. + // SBP-M1 review: destructure into clearer variable names let balances = balances.iter().fold( ( + // SBP-M1 review: simplify using tuple Vec::::new(), Vec::>::new(), Vec::>::new(), ), |(mut class_ids, mut asset_ids, mut balances), (class_id, asset_id, balance)| { + // SBP-M1 review: use .map_or_else() let class_idx = if let Some(class_idx) = class_ids.iter().position(|class| *class == *class_id) { @@ -367,34 +465,44 @@ impl Pallet { class_idx }; if asset_ids.len() <= class_idx { + // SBP-M1 review: use safe math asset_ids.resize(class_idx + 1, vec![]); } + // SBP-M1 review: indexing may panic, prefer .get() asset_ids[class_idx].push(*asset_id); if balances.len() <= class_idx { + // SBP-M1 review: use safe math balances.resize(class_idx + 1, vec![]); } + // SBP-M1 review: indexing may panic, prefer .get() balances[class_idx].push(*balance); (class_ids, asset_ids, balances) }, ); + // SBP-M1 review: iteration should be bounded to complete within block limits. for (idx, class_id) in balances.0.iter().enumerate() { + // SBP-M1 review: access via trait bounds on Config item - e.g. type Asset : BatchTransfer sugarfunge_asset::Pallet::::do_batch_transfer_from( + // SBP-M1 review: needless borrows &bag, &bag, to, *class_id, + // SBP-M1 review: indexing may panic, prefer .get() balances.1[idx].clone(), balances.2[idx].clone(), )?; } + // SBP-M1 review: unnecessary clones Self::deposit_event(Event::Sweep { bag: bag.clone(), who: who.clone(), to: to.clone(), }); + // SBP-M1 review: return type not used anywhere Ok(balances) } } diff --git a/pallets/bag/src/tests.rs b/pallets/bag/src/tests.rs index e6f7fbb..64d4deb 100644 --- a/pallets/bag/src/tests.rs +++ b/pallets/bag/src/tests.rs @@ -1,6 +1,11 @@ use crate::mock::*; use frame_support::{assert_ok, bounded_vec}; +// SBP-M1 review: no test for register dispatchable function +// SBP-M1 review: no assertion for Deposit and Sweep events +// SBP-M1 review: no assertions for errors + +// SBP-M1 review: replace with assert_last_event or assert_has_event fn last_event() -> RuntimeEvent { frame_system::Pallet::::events() .pop() @@ -65,12 +70,14 @@ fn deposit_assets() { assert_ok!(Bag::create(RuntimeOrigin::signed(1), 1000, vec![2], vec![1])); + // SBP-M1 review: replace with assert_last_event or assert_has_event, passing event with expected values for comparison if let RuntimeEvent::Bag(crate::Event::Created { bag, who, class_id, asset_id, owners, + }) = last_event() { assert_eq!(who, 1); @@ -179,6 +186,7 @@ fn sweep_assets() { )); assert_ok!(Bag::create(RuntimeOrigin::signed(1), 1000, vec![2], vec![1])); + // SBP-M1 review: replace with assert_last_event or assert_has_event, passing event with expected values for comparison if let RuntimeEvent::Bag(crate::Event::Created { bag, who, diff --git a/pallets/bridge/Cargo.toml b/pallets/bridge/Cargo.toml index 9fb208f..b61b3d8 100644 --- a/pallets/bridge/Cargo.toml +++ b/pallets/bridge/Cargo.toml @@ -1,14 +1,21 @@ +#SBP-M1 review: not used by runtime, review is not exhaustive +#SBP-M1 review: no readme/documentation [package] +#SBP-M1 review: use double quotes for consistency name = 'sugarfunge-bridge' version = "0.1.0" +#SBP-M1 review: no commits by author in git history, implying code has been copied from elsewhere without attribution and proper licensing authors = ["david@chainsafe.io", "SugarFunge Developers"] edition = '2021' +#SBP-M1 review: no description, repository, license [dependencies] # third-party dependencies codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } +#SBP-M1 review: doesnt appear to be used by pallet, remove serde = { version = "1.0.160", optional = true } +#SBP-M1 review: doesnt appear to be used by pallet, remove getrandom = { version = "0.2", features = ["js"] } # primitives @@ -24,10 +31,15 @@ frame-system = { git = "https://github.com/paritytech/substrate", branch = "polk sugarfunge-primitives = { git = "https://github.com/SugarFunge/sugarfunge-primitives", branch = "fula/release", default-features = false } sugarfunge-asset = { git = "https://github.com/SugarFunge/sugarfunge-asset", branch = "fula/release", default-features = false } +#SBP-M1 review: external dependencies not reviewed, but quick glance shows issues such as no benchmarks, invalid weights, unnecessary cargo.lock, minimal tests +#SBP-M1 review: doesnt actually seem to be used by pallet logic, only in mock +#SBP-M1 review: doesnt actually seem to be used by pallet logic, only in mock + pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } [build-dependencies] wasm-builder-runner = { version = "3.0.0", package = "substrate-wasm-builder-runner"} +#SBP-M1 review: add line break [features] default = ["std"] std = [ diff --git a/pallets/bridge/src/lib.rs b/pallets/bridge/src/lib.rs index 889295b..a743387 100644 --- a/pallets/bridge/src/lib.rs +++ b/pallets/bridge/src/lib.rs @@ -1,3 +1,4 @@ +// SBP-M1 review: not used by runtime, review is not exhaustive // Ensure we're `no_std` when compiling for Wasm. #![cfg_attr(not(feature = "std"), no_std)] @@ -25,19 +26,24 @@ mod mock; #[cfg(test)] mod tests; +// SBP-M1 review: consider reducing visibility pub type ChainId = u8; pub type DepositNonce = u64; pub type ResourceId = [u8; 32]; /// Helper function to concatenate a chain ID and some bytes to produce a resource ID. /// The common format is (31 bytes unique ID + 1 byte chain ID). +// SBP-M1 review: reduce visibility pub fn derive_resource_id(chain: u8, id: &[u8]) -> ResourceId { let mut r_id: ResourceId = [0; 32]; r_id[31] = chain; // last byte is chain id let range = if id.len() > 31 { 31 } else { id.len() }; // Use at most 31 bytes for i in 0..range { + // SBP-M1 review: indexing may panic + // SBP-M1 review: use safe math r_id[30 - i] = id[range - 1 - i]; // Ensure left padding for eth compatibility } + // SBP-M1 review: unneeded return statement return r_id; } @@ -50,6 +56,7 @@ pub enum ProposalStatus { #[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct ProposalVotes { + // SBP-M1 review: change to BoundedVec to improve clarity pub votes_for: MaxVotesOf, pub votes_against: MaxVotesOf, pub status: ProposalStatus, @@ -63,14 +70,17 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::config] + // SBP-M1 review: sugarfunge_asset not used, remove pub trait Config: frame_system::Config + sugarfunge_asset::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; + // SBP-M1 review: missing doc comment type PalletId: Get; /// RuntimeOrigin used to administer the pallet type AdminOrigin: EnsureOrigin; + // SBP-M1 review: add line break for consistency /// Proposed dispatchable call type Proposal: Parameter + Dispatchable @@ -80,18 +90,23 @@ pub mod pallet { /// This must be unique and must not collide with existing IDs within a set of bridged chains. type ChainId: Get; + // SBP-M1 review: missing doc comment type ProposalLifetime: Get; + // SBP-M1 review: missing doc comment #[pallet::constant] type DefaultRelayerThreshold: Get; + // SBP-M1 review: missing doc comment #[pallet::constant] type MaxResourceMetadata: Get; + // SBP-M1 review: missing doc comment #[pallet::constant] type MaxVotes: Get; } + // SBP-M1 review: consider reducing visibility pub type ResourceMetadataOf = BoundedVec::MaxResourceMetadata>; pub type MaxVotesOf = BoundedVec<::AccountId, ::MaxVotes>; @@ -106,12 +121,14 @@ pub mod pallet { pub enum Event { /// Vote threshold has changed (new_threshold) RelayerThresholdChanged(u32), + // SBP-M1 review: consider renaming to AllowListed /// Chain now available for transfers (chain_id) ChainWhitelisted(ChainId), /// Relayer added to set RelayerAdded(T::AccountId), /// Relayer removed from set RelayerRemoved(T::AccountId), + // SBP-M1 review: typo /// FunglibleTransfer is for relaying fungibles (dest_id, nonce, resource_id, amount, recipient, metadata) FungibleTransfer(ChainId, DepositNonce, ResourceId, U256, Vec), /// NonFungibleTransfer is for relaying NFTS (dest_id, nonce, resource_id, token_id, recipient, metadata) @@ -141,8 +158,10 @@ pub mod pallet { /// Relayer threshold cannot be 0 InvalidThreshold, /// Interactions with this chain is not permitted + // SBP-M1 review: consider renaming to AllowListed ChainNotWhitelisted, /// Chain has already been enabled + // SBP-M1 review: consider renaming to AllowListed ChainAlreadyWhitelisted, /// Resource ID provided isn't mapped to anything ResourceDoesNotExist, @@ -184,11 +203,13 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn relayer_threshold)] + // SBP-M1 review: pub(super) pub type RelayerThreshold = StorageValue<_, u32, ValueQuery, T::DefaultRelayerThreshold>; #[pallet::storage] #[pallet::getter(fn relayer_count)] + // SBP-M1 review: pub(super) pub type RelayerCount = StorageValue<_, u32, ValueQuery>; #[pallet::storage] @@ -213,6 +234,8 @@ pub mod pallet { /// - O(1) lookup and insert /// # #[pallet::call_index(0)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn set_threshold(origin: OriginFor, threshold: u32) -> DispatchResult { Self::ensure_admin(origin)?; @@ -225,6 +248,8 @@ pub mod pallet { /// - O(1) write /// # #[pallet::call_index(1)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn set_resource( origin: OriginFor, @@ -244,6 +269,8 @@ pub mod pallet { /// - O(1) removal /// # #[pallet::call_index(2)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn remove_resource(origin: OriginFor, id: ResourceId) -> DispatchResult { Self::ensure_admin(origin)?; @@ -256,7 +283,10 @@ pub mod pallet { /// - O(1) lookup and insert /// # #[pallet::call_index(3)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] + // SBP-M1 review: consider renaming to allow_chain pub fn whitelist_chain(origin: OriginFor, id: ChainId) -> DispatchResult { Self::ensure_admin(origin)?; Self::whitelist(id) @@ -268,6 +298,8 @@ pub mod pallet { /// - O(1) lookup and insert /// # #[pallet::call_index(4)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn add_relayer(origin: OriginFor, v: T::AccountId) -> DispatchResult { Self::ensure_admin(origin)?; @@ -280,6 +312,8 @@ pub mod pallet { /// - O(1) lookup and removal /// # #[pallet::call_index(5)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn remove_relayer(origin: OriginFor, v: T::AccountId) -> DispatchResult { Self::ensure_admin(origin)?; @@ -294,8 +328,11 @@ pub mod pallet { /// # /// - weight of proposed call, regardless of whether execution is performed /// # + // SBP-M1 review: remove commented out weight attribute // #[weight = (call.get_dispatch_info().weight + 195_000_000, call.get_dispatch_info().class, Pays::Yes)] #[pallet::call_index(6)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn acknowledge_proposal( origin: OriginFor, @@ -324,6 +361,8 @@ pub mod pallet { /// - Fixed, since execution of proposal should not be included /// # #[pallet::call_index(7)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn reject_proposal( origin: OriginFor, @@ -354,8 +393,11 @@ pub mod pallet { /// # /// - weight of proposed call, regardless of whether execution is performed /// # + // SBP-M1 review: remove commented out weight attribute // #[weight = (prop.get_dispatch_info().weight + 195_000_000, prop.get_dispatch_info().class, Pays::Yes)] #[pallet::call_index(8)] + // SBP-M1 review: implement benchmark and use resulting weight function + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn eval_vote_state( origin: OriginFor, @@ -373,6 +415,7 @@ pub mod pallet { impl Pallet { // *** Utility methods *** + // SBP-M1 review: reduce visibility pub fn ensure_admin(o: T::RuntimeOrigin) -> DispatchResult { T::AdminOrigin::try_origin(o) .map(|_| ()) @@ -381,28 +424,39 @@ impl Pallet { } /// Checks if who is a relayer + // SBP-M1 review: reduce visibility pub fn is_relayer(who: &T::AccountId) -> bool { Self::relayers(who) } /// Provides an AccountId for the pallet. /// This is used both as an origin check and deposit/withdrawal account. + // SBP-M1 review: reduce visibility pub fn account_id() -> T::AccountId { ::PalletId::get().into_account_truncating() } /// Asserts if a resource is registered + // SBP-M1 review: reduce visibility + // SBP-M1 review: use .is_some() pub fn resource_exists(id: ResourceId) -> bool { + // SBP-M1 review: unneeded return statement return Self::resources(id) != None; } + // SBP-M1 review: consider renaming to chain_allowlisted /// Checks if a chain exists as a whitelisted destination + // SBP-M1 review: reduce visibility + // SBP-M1 review: use .is_some() pub fn chain_whitelisted(id: ChainId) -> bool { + // SBP-M1 review: unneeded return statement return Self::chains(id) != None; } /// Increments the deposit nonce for the specified chain ID fn bump_nonce(id: ChainId) -> DepositNonce { + // SBP-M1 review: use >.mutate() which also allows a return value + // SBP-M1 review: use safe math let nonce = Self::chains(id).unwrap_or_default() + 1; ChainNonces::::insert(id, nonce); nonce @@ -411,6 +465,7 @@ impl Pallet { // *** Admin methods *** /// Set a new voting threshold + // SBP-M1 review: reduce visibility pub fn set_relayer_threshold(threshold: u32) -> DispatchResult { ensure!(threshold > 0, Error::::InvalidThreshold); RelayerThreshold::::put(threshold); @@ -419,18 +474,22 @@ impl Pallet { } /// Register a method for a resource Id, enabling associated transfers + // SBP-M1 review: reduce visibility pub fn register_resource(id: ResourceId, method: ResourceMetadataOf) -> DispatchResult { Resources::::insert(id, method); Ok(()) } /// Removes a resource ID, disabling associated transfer + // SBP-M1 review: reduce visibility pub fn unregister_resource(id: ResourceId) -> DispatchResult { Resources::::remove(id); Ok(()) } + // SBP-M1 review: consider renaming to 'allow' /// Whitelist a chain ID for transfer + // SBP-M1 review: reduce visibility pub fn whitelist(id: ChainId) -> DispatchResult { // Cannot whitelist this chain ensure!(id != T::ChainId::get(), Error::::InvalidChainId); @@ -439,18 +498,21 @@ impl Pallet { !Self::chain_whitelisted(id), Error::::ChainAlreadyWhitelisted ); + // SBP-M1 review: unnecessary borrow ChainNonces::::insert(&id, 0); Self::deposit_event(Event::ChainWhitelisted(id)); Ok(()) } /// Adds a new relayer to the set + // SBP-M1 review: reduce visibility pub fn register_relayer(relayer: T::AccountId) -> DispatchResult { ensure!( !Self::is_relayer(&relayer), Error::::RelayerAlreadyExists ); Relayers::::insert(&relayer, true); + // SBP-M1 review: use safe math RelayerCount::::mutate(|i| *i += 1); Self::deposit_event(Event::RelayerAdded(relayer)); @@ -458,9 +520,11 @@ impl Pallet { } /// Removes a relayer from the set + // SBP-M1 review: reduce visibility pub fn unregister_relayer(relayer: T::AccountId) -> DispatchResult { ensure!(Self::is_relayer(&relayer), Error::::RelayerInvalid); Relayers::::remove(&relayer); + // SBP-M1 review: use safe math RelayerCount::::mutate(|i| *i -= 1); Self::deposit_event(Event::RelayerRemoved(relayer)); Ok(()) @@ -469,16 +533,20 @@ impl Pallet { // *** Proposal voting and execution methods *** /// Commits a vote for a proposal. If the proposal doesn't exist it will be created. + // SBP-M1 review: too many lines, refactor fn commit_vote( + // SBP-M1 review: not consumed, consider borrow who: T::AccountId, nonce: DepositNonce, src_id: ChainId, + // SBP-M1 review: not consumed, consider borrow prop: Box, in_favour: bool, ) -> DispatchResult { let now = >::block_number(); let encoded_call = prop.encode(); let call_hash = ::Hashing::hash(&encoded_call[..]); + // SBP-M1 review: consider >::try_mutate(.. -> DispatchResult) or .map_or_else(..) let mut votes = match >::get(src_id, (nonce, call_hash)) { Some(v) => v, None => { @@ -488,6 +556,8 @@ impl Pallet { status: ProposalStatus::Initiated, expiry: T::BlockNumber::default(), }; + // SBP-M1 review: move to initializer, negating need for mut + // SBP-M1 review: use safe math v.expiry = now + T::ProposalLifetime::get(); v } @@ -505,19 +575,24 @@ impl Pallet { ); if in_favour { + // SBP-M1 review: .ok_or()? another approach ensure!( votes.votes_for.try_push(who.clone()).is_ok(), Error::::MaxVotesReached ); + // SBP-M1 review: unnecessary clone Self::deposit_event(Event::VoteFor(src_id, nonce, who.clone())); } else { + // SBP-M1 review: .ok_or()? another approach ensure!( votes.votes_against.try_push(who.clone()).is_ok(), Error::::MaxVotesReached ); + // SBP-M1 review: unnecessary clone Self::deposit_event(Event::VoteAgainst(src_id, nonce, who.clone())); } + // SBP-M1 review: unnecessary clone >::insert(src_id, (nonce, call_hash), votes.clone()); Ok(()) @@ -525,6 +600,7 @@ impl Pallet { /// Attempts to mark the proposal as approve or rejected. /// Returns true if the status changes from active. + // SBP-M1 review: consider moving to ProposalVotes struct impl as method fn try_to_complete( votes: &mut ProposalVotes>, threshold: u32, @@ -533,6 +609,7 @@ impl Pallet { if votes.votes_for.len() >= threshold as usize { votes.status = ProposalStatus::Approved; ProposalStatus::Approved + // SBP-M1 review: use safe math and cast may truncate } else if total >= threshold && votes.votes_against.len() as u32 + threshold > total { votes.status = ProposalStatus::Rejected; ProposalStatus::Rejected @@ -542,11 +619,13 @@ impl Pallet { } /// Returns true if the proposal has been rejected or approved, otherwise false. + // SBP-M1 review: consider moving to ProposalVotes struct impl as method fn is_complete(votes: &ProposalVotes>) -> bool { votes.status != ProposalStatus::Initiated } /// Return true if the expiry time has been reached + // SBP-M1 review: consider moving to ProposalVotes struct impl as method fn is_expired( votes: &ProposalVotes>, now: T::BlockNumber, @@ -555,7 +634,9 @@ impl Pallet { } /// Returns true if `who` has voted for or against the proposal + // SBP-M1 review: consider moving to ProposalVotes struct impl as method fn has_voted(votes: &ProposalVotes>, who: &T::AccountId) -> bool { + // SBP-M1 review: needless borrows votes.votes_for.contains(&who) || votes.votes_against.contains(&who) } @@ -567,6 +648,7 @@ impl Pallet { ) -> DispatchResult { let encoded_call = prop.encode(); let call_hash = ::Hashing::hash(&encoded_call[..]); + // SBP-M1 review: consider >::try_mutate(..) or let-else { return Err(..) } if let Some(mut votes) = >::get(src_id, (nonce, call_hash)) { let now = >::block_number(); ensure!( @@ -585,9 +667,11 @@ impl Pallet { match status { ProposalStatus::Approved => Self::finalize_execution(src_id, nonce, prop), ProposalStatus::Rejected => Self::cancel_execution(src_id, nonce), + // SBP-M1 review: handle remaining variants explicitly, wildcard will match future added variants _ => Ok(()), } } else { + // SBP-M1 review: use 'return Err(..)' syntax instead Err(Error::::ProposalDoesNotExist)? } } @@ -630,12 +714,16 @@ impl Pallet { } /// Cancels a proposal. + // SBP-M1 review: return value unnecessary fn cancel_execution(src_id: ChainId, nonce: DepositNonce) -> DispatchResult { Self::deposit_event(Event::ProposalRejected(src_id, nonce)); Ok(()) } /// Initiates a transfer of a fungible asset out of the chain. This should be called by another pallet. + // SBP-M1 review: doesnt seem to initiate any transfer, just increments nonce and emits event + // SBP-M1 review: not used beyond test + // SBP-M1 review: reduce visibility pub fn transfer_fungible( dest_id: ChainId, resource_id: ResourceId, @@ -658,6 +746,9 @@ impl Pallet { } /// Initiates a transfer of a nonfungible asset out of the chain. This should be called by another pallet. + // SBP-M1 review: doesnt seem to initiate any transfer, just increments nonce and emits event + // SBP-M1 review: not used beyond test + // SBP-M1 review: reduce visibility pub fn transfer_nonfungible( dest_id: ChainId, resource_id: ResourceId, @@ -682,6 +773,7 @@ impl Pallet { } /// Initiates a transfer of generic data out of the chain. This should be called by another pallet. + // SBP-M1 review: reduce visibility pub fn transfer_generic( dest_id: ChainId, resource_id: ResourceId, @@ -707,6 +799,7 @@ pub struct EnsureBridge(sp_std::marker::PhantomData); impl EnsureOrigin for EnsureBridge { type Success = T::AccountId; fn try_origin(o: T::RuntimeOrigin) -> Result { + // SBP-M1 review: use >::account_id() for consistency let bridge_id = ::PalletId::get().into_account_truncating(); o.into().and_then(|o| match o { frame_system::RawOrigin::Signed(who) if who == bridge_id => Ok(bridge_id), @@ -718,6 +811,7 @@ impl EnsureOrigin for EnsureBridge { /// /// ** Should be used for benchmarking only!!! ** #[cfg(feature = "runtime-benchmarks")] + // SBP-M1 review: should by try_successful_origin, assume this wasn't updated after updating Substrate fn successful_origin() -> T::RuntimeOrigin { T::RuntimeOrigin::from(frame_system::RawOrigin::Signed(>::account_id())) } diff --git a/pallets/bridge/src/tests.rs b/pallets/bridge/src/tests.rs index 18c91a3..d973b41 100644 --- a/pallets/bridge/src/tests.rs +++ b/pallets/bridge/src/tests.rs @@ -1,3 +1,4 @@ +// SBP-M1 review: not used by runtime, review is not exhaustive #![cfg(test)] use super::mock::{ @@ -8,6 +9,9 @@ use super::*; use crate::mock::new_test_ext_initialized; use frame_support::{assert_noop, assert_ok, bounded_vec, BoundedVec}; +// SBP-M1 review: coverage shows missing ProposalFailed event assertion +// SBP-M1 review: coverage shows missing error assertions of ChainAlreadyWhitelisted, ChainNotWhitelisted, ResourceDoesNotExist, ProposalAlreadyComplete, RelayerAlreadyVoted, MaxVotesReached, ProposalDoesNotExist + #[test] fn derive_ids() { let chain = 1; @@ -126,6 +130,7 @@ fn set_get_threshold() { assert_eq!(RelayerThreshold::::get(), 5); assert_events(vec![ + // SBP-M1 review: unnecessary qualification RuntimeEvent::Bridge(crate::Event::RelayerThresholdChanged(TEST_THRESHOLD)), RuntimeEvent::Bridge(crate::Event::RelayerThresholdChanged(5)), ]); @@ -261,6 +266,7 @@ fn make_proposal(r: Vec) -> mock::RuntimeCall { } #[test] +// SBP-M1 review: typo > successful fn create_sucessful_proposal() { let src_id = 1; let r_id = derive_resource_id(src_id, b"remark"); @@ -334,6 +340,7 @@ fn create_sucessful_proposal() { } #[test] +// SBP-M1 review: typo > unsuccessful fn create_unsucessful_proposal() { let src_id = 1; let r_id = derive_resource_id(src_id, b"transfer"); diff --git a/pallets/dao/Cargo.toml b/pallets/dao/Cargo.toml index e10dd63..83f3364 100644 --- a/pallets/dao/Cargo.toml +++ b/pallets/dao/Cargo.toml @@ -3,7 +3,9 @@ name = 'sugarfunge-dao' version = "0.1.0" authors = ["SugarFunge Developers"] edition = "2021" +#SBP-M1 review: ensure that licenses satisfy the requirements of all dependencies license = "Proprietary" +#SBP-M1 review: no description, repository [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/dao/src/lib.rs b/pallets/dao/src/lib.rs index 1d03546..a2774b5 100644 --- a/pallets/dao/src/lib.rs +++ b/pallets/dao/src/lib.rs @@ -1,3 +1,4 @@ +// SBP-M1 review: appears to be pallet_template, not reviewed #![cfg_attr(not(feature = "std"), no_std)] /// Edit this file to define custom logic or remove it if it is not needed. diff --git a/pallets/exgine/Cargo.toml b/pallets/exgine/Cargo.toml index 419a751..bca5a65 100644 --- a/pallets/exgine/Cargo.toml +++ b/pallets/exgine/Cargo.toml @@ -3,7 +3,9 @@ name = 'sugarfunge-exgine' version = "0.1.0" authors = ["SugarFunge Developers"] edition = "2021" +#SBP-M1 review: ensure that licenses satisfy the requirements of all dependencies license = "Proprietary" +#SBP-M1 review: no description, repository [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/pallets/exgine/src/lib.rs b/pallets/exgine/src/lib.rs index 93bc467..c084157 100644 --- a/pallets/exgine/src/lib.rs +++ b/pallets/exgine/src/lib.rs @@ -1,3 +1,5 @@ +// SBP-M1 review: appears to be pallet_template, not reviewed + #![cfg_attr(not(feature = "std"), no_std)] /// Edit this file to define custom logic or remove it if it is not needed. diff --git a/pallets/market/Cargo.toml b/pallets/market/Cargo.toml index fb4d3b1..6eb2f61 100644 --- a/pallets/market/Cargo.toml +++ b/pallets/market/Cargo.toml @@ -1,9 +1,12 @@ [package] +#SBP-M1 review: use double quotes name = 'sugarfunge-market' version = "0.1.0" authors = ["SugarFunge Developers"] edition = "2021" +#SBP-M1 review: ensure that licenses satisfy the requirements of all dependencies license = "Proprietary" +#SBP-M1 review: no description, repository [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] @@ -21,16 +24,22 @@ sugarfunge-primitives = { git = "https://github.com/SugarFunge/sugarfunge-primit sugarfunge-asset = { git = "https://github.com/SugarFunge/sugarfunge-asset", branch = "fula/release", default-features = false } sugarfunge-bundle = { git = "https://github.com/SugarFunge/sugarfunge-bundle", branch = "fula/release", default-features = false } +#SBP-M1 review: external dependencies not reviewed, but quick glance shows issues such as no benchmarks, invalid weights, unnecessary cargo.lock, minimal tests +#SBP-M1 review: appears to only be used in mock, either remove if not actually required or move to dev-dependencies +#SBP-M1 review: use single line + codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } scale-info = { version = "2.5.0", default-features = false, features = ["derive"] } + [dev-dependencies] sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } +#SBP-M1 review: appears to only be used in mock, either remove if not actually required or move to dev-dependencies pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } [features] @@ -46,6 +55,7 @@ std = [ 'frame-benchmarking/std', 'sugarfunge-primitives/std', 'sugarfunge-asset/std', + #SBP-M1 review: 'pallet-balances/std' missing ] runtime-benchmarks = ["frame-benchmarking"] diff --git a/pallets/market/README.md b/pallets/market/README.md index 8d751a4..e75d33e 100644 --- a/pallets/market/README.md +++ b/pallets/market/README.md @@ -1 +1,4 @@ -License: Unlicense \ No newline at end of file +[//]: # (SBP-M1 review: license does not match cargo.toml) +License: Unlicense + +[//]: # (SBP-M1 review: missing documentation - should include overview, terminology, usage flows, dispatchable functions etc.) \ No newline at end of file diff --git a/pallets/market/src/benchmarking.rs b/pallets/market/src/benchmarking.rs index f490cf5..e082ed0 100644 --- a/pallets/market/src/benchmarking.rs +++ b/pallets/market/src/benchmarking.rs @@ -8,10 +8,13 @@ use crate::Pallet as Market; use frame_benchmarking::v2::*; use frame_system::RawOrigin; +// SBP-M1 review: missing benchmarks for dispatchable functions +// SBP-M1 review: add ci to require successful benchmark tests before merging #[benchmarks] mod benchmarks { use super::*; + // SBP-M1 review: remove sample benchmark #[benchmark] fn do_something() { let value = 100u32.into(); @@ -21,6 +24,7 @@ mod benchmarks { assert_eq!(Something::::get(), Some(value)); } + // SBP-M1 review: remove sample benchmark #[benchmark] fn verify() { assert_eq!(Something::::get(), Some(s)); diff --git a/pallets/market/src/lib.rs b/pallets/market/src/lib.rs index b20d600..c79bfad 100644 --- a/pallets/market/src/lib.rs +++ b/pallets/market/src/lib.rs @@ -1,3 +1,4 @@ +// SBP-M1 review: use cargo fmt #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode, HasCompact, MaxEncodedLen}; @@ -14,6 +15,7 @@ use sp_runtime::{ RuntimeDebug, }; use sp_std::{collections::btree_map::BTreeMap, prelude::*}; +// SBP-M1 review: should amount not be a u128 rather than signed? use sugarfunge_primitives::{Amount, Balance}; pub use pallet::*; @@ -27,6 +29,9 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +// SBP-M1 review: consider moving types to separate module +// SBP-M1 review: add doc comments + #[derive( Encode, Decode, @@ -40,6 +45,7 @@ mod benchmarking; TypeInfo, MaxEncodedLen, )] +// SBP-M1 review: consider pub(crate) or less, depending on usage pub enum AmountOp { Equal, LessThan, @@ -61,6 +67,7 @@ pub enum AmountOp { TypeInfo, MaxEncodedLen, )] +// SBP-M1 review: consider pub(crate) or less, depending on usage pub enum AMM { Constant, } @@ -78,6 +85,7 @@ pub enum AMM { TypeInfo, MaxEncodedLen, )] +// SBP-M1 review: consider pub(crate) or less, depending on usage pub enum RateAction { Transfer(Amount), MarketTransfer(AMM, ClassId, AssetId), @@ -89,9 +97,12 @@ pub enum RateAction { impl RateAction { fn get_amount(&self) -> Amount { match *self { + // SBP-M1 review: merge arm patterns with same body + // SBP-M1 review: use Self instead of RateAction RateAction::Burn(amount) => amount, RateAction::Mint(amount) => amount, RateAction::Transfer(amount) => amount, + // SBP-M1 review: explicit variant handling preferred > 'RateAction::MarketTransfer(..) | RateAction::Has(..) => 0,' _ => 0 as Amount, } } @@ -110,6 +121,7 @@ impl RateAction { TypeInfo, MaxEncodedLen, )] +// SBP-M1 review: consider pub(crate) or less, depending on usage pub enum RateAccount { Market, Account(AccountId), @@ -129,6 +141,8 @@ pub enum RateAccount { TypeInfo, MaxEncodedLen, )] +// SBP-M1 review: consider pub(crate) or less, depending on usage +// SBP-M1 review: name misleading, consider renaming to something like Instruction based on description in simple_market_rates() test helper pub struct AssetRate { class_id: ClassId, asset_id: AssetId, @@ -137,6 +151,7 @@ pub struct AssetRate { to: RateAccount, } +// SBP-M1 review: consider pub(crate) or less, depending on usage pub type Rates = BoundedVec< AssetRate< ::AccountId, @@ -146,6 +161,7 @@ pub type Rates = BoundedVec< ::MaxRates, >; +// SBP-M1 review: consider pub(crate) or less, depending on usage pub type RateBalances = BTreeMap< AssetRate< ::AccountId, @@ -158,6 +174,7 @@ pub type RateBalances = BTreeMap< type TransactionBalances = BTreeMap< ( RateAccount<::AccountId>, + // SBP-M1 review: consider defining these types on Config type of this pallet, configured via runtime ::ClassId, ::AssetId, ), @@ -165,6 +182,7 @@ type TransactionBalances = BTreeMap< >; #[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo)] +// SBP-M1 review: consider pub(crate) or less, depending on usage pub struct RateBalance { rate: AssetRate, balance: Amount, @@ -176,15 +194,19 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; + // SBP-M1 review: remove comment /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] + // SBP-M1 review: loose pallet coupling preferable, can sugarfunge_asset dependency be brought in via trait (associated type on this pallets Config trait)? pub trait Config: frame_system::Config + sugarfunge_asset::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; + // SBP-M1 review: missing doc comment #[pallet::constant] type PalletId: Get; + // SBP-M1 review: missing doc comment type MarketId: Member + Parameter + HasCompact @@ -196,6 +218,7 @@ pub mod pallet { + Into + MaxEncodedLen; + // SBP-M1 review: missing doc comment type MarketRateId: Member + Parameter + HasCompact @@ -246,6 +269,7 @@ pub mod pallet { BoundedVec::MaxMetadata>, >; + // SBP-M1 review: add doc comments #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { @@ -292,8 +316,10 @@ pub mod pallet { }, } + // SBP-M1 review: add doc comments #[pallet::error] pub enum Error { + // SBP-M1 review: can use ArithmeticError::Overflow instead of custom overflow type Overflow, InsufficientAmount, InsufficientLiquidity, @@ -315,71 +341,99 @@ pub mod pallet { InvalidArrayLength, } + // SBP-M1 review: remove template comment // Dispatchable functions allows users to interact with the pallet and invoke state changes. // These functions materialize as "extrinsics", which are often compared to transactions. // Dispatchable functions must be annotated with a weight and must return a DispatchResult. #[pallet::call] impl Pallet { + // SBP-M1 review: add doc comments #[pallet::call_index(0)] + // SBP-M1 review: implement benchmark and use resulting weight function - static weight definition probably underweight and no proof_size, necessary when parachain + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn create_market( origin: OriginFor, market_id: T::MarketId, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: how are markets removed? Can a deposit be taken to create a market to incentivize owner to remove market when no longer required? + // SBP-M1 review: market rate removal also needs consideration + // SBP-M1 review: could simplify and just return value from Self::do_create_market(..) Self::do_create_market(&who, market_id)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } + // SBP-M1 review: add doc comments #[pallet::call_index(1)] + // SBP-M1 review: implement benchmark and use resulting weight function - static weight definition probably underweight and no proof_size, necessary when parachain + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn create_market_rate( origin: OriginFor, market_id: T::MarketId, market_rate_id: T::MarketRateId, rates: Rates, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: could simplify and just return value from Self::do_create_market_rate(..) Self::do_create_market_rate(&who, market_id, market_rate_id, &rates)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } + // SBP-M1 review: add doc comments #[pallet::call_index(2)] + // SBP-M1 review: implement benchmark and use resulting weight function - static weight definition probably underweight and no proof_size, necessary when parachain + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn deposit( origin: OriginFor, market_id: T::MarketId, market_rate_id: T::MarketRateId, amount: Balance, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: could simplify and just return value from Self::do_deposit(..) Self::do_deposit(&who, market_id, market_rate_id, amount)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } + // SBP-M1 review: add doc comments #[pallet::call_index(3)] + // SBP-M1 review: implement benchmark and use resulting weight function - static weight definition probably underweight and no proof_size, necessary when parachain + // SBP-M1 review: unnecessary cast #[pallet::weight(Weight::from_parts(10_000 as u64, 0))] pub fn exchange_assets( origin: OriginFor, market_id: T::MarketId, market_rate_id: T::MarketRateId, amount: Balance, + // SBP-M1 review: can just be DispatchResult as no PostDispatchInfo used ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; + // SBP-M1 review: could simplify and just return value from Self::do_exchange_assets(..) Self::do_exchange_assets(&who, market_id, market_rate_id, amount)?; + // SBP-M1 review: unnecessary .into() once return type changed Ok(().into()) } } } +// SBP-M1 review: add doc comment and consider relocating closer to other structs #[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct Market { /// The owner of the market @@ -388,13 +442,17 @@ pub struct Market { pub vault: AccountId, } +// SBP-M1 review: verify pub visibility on all functions. Wrap in traits to signal if they should be accessible to other pallets impl Pallet { + // SBP-M1 review: probably doesnt need to be public, consider pub(crate), pub(super)... pub fn do_create_market(who: &T::AccountId, market_id: T::MarketId) -> DispatchResult { ensure!( !Markets::::contains_key(market_id), Error::::MarketExists ); + // SBP-M1 review: vault account may require existential deposit (especially for native currency), could take from owner here at creation and return once market removed/closed + // SBP-M1 review: may apply for each asset depending on implementation in asset pallet let vault: T::AccountId = ::PalletId::get().into_sub_account_truncating(market_id); @@ -408,6 +466,7 @@ impl Pallet { Self::deposit_event(Event::Created { market_id, + // SBP-M1 review: unnecessary clone who: who.clone(), }); @@ -420,6 +479,7 @@ impl Pallet { market_rate_id: T::MarketRateId, rates: &Rates, ) -> DispatchResult { + // SBP-M1 review: can market not be auto-created if it doesnt exist? Currently requires one transaction to create market and then another to submit rates let market = Markets::::get(market_id).ok_or(Error::::InvalidMarket)?; ensure!(*who == market.owner, Error::::InvalidMarketOwner); @@ -430,12 +490,17 @@ impl Pallet { // Ensure rates are valid for asset_rate in rates.iter() { + // SBP-M1 review: duplicate code, use asset_rate.action.get_amount() let amount = match asset_rate.action { + // SBP-M1 review: merge arms > RateAction::Burn(amount) | RateAction::Mint(amount) ... RateAction::Burn(amount) => amount, RateAction::Mint(amount) => amount, RateAction::Transfer(amount) => amount, + // SBP-M1 review: wildcard match will also match any future variants, prefer being explicit _ => 0 as Amount, }; + // SBP-M1 review: can be simplified to ensure!(asset_rate.action.get_amount() >= 0,...) + // SBP-M1 review: Amount type being signed is questionable, using u128 removes the need for this check ensure!(amount >= 0, Error::::InvalidRateAmount); } @@ -444,24 +509,31 @@ impl Pallet { Self::deposit_event(Event::RateCreated { market_id, market_rate_id, + // SBP-M1 review: unnecessary clone who: who.clone(), }); Ok(()) } + // SBP-M1 review: too many lines, refactor + // SBP-M1 review: who uses this? Appears to be no usage in project. Wrap in a well documented trait so other pallets can call via trait pub fn add_liquidity( who: &T::AccountId, market_id: T::MarketId, market_rate_id: T::MarketRateId, + // SBP-M1 review: vectors should be bounded + // SBP-M1 review: use Vec<(T::ClassId, Vec, Vec)> to avoid needing to check sizes of each vector match class_ids: Vec, asset_ids: Vec>, amounts: Vec>, ) -> DispatchResult { let market = Markets::::get(market_id).ok_or(Error::::InvalidMarket)?; + // SBP-M1 review: value not used, used .contains_key() with ensure! let _market_rate = MarketRates::::get((market_id, market_rate_id)) .ok_or(Error::::InvalidMarketRate)?; + // SBP-M1 review: move above market rate check to prevent unnecessary read if caller is not market owner ensure!(*who == market.owner, Error::::InvalidMarketOwner); ensure!( @@ -475,21 +547,25 @@ impl Pallet { for (idx, class_id) in class_ids.iter().enumerate() { ensure!( + // SBP-M1 review: whilst size checked above, using .get() is preferred over indexing due to possibility of panic asset_ids[idx].len() == amounts[idx].len(), Error::::InvalidArrayLength ); + // SBP-M1 review: should use trait, defined as associated type on Config trait of pallet (loose coupling) sugarfunge_asset::Pallet::::do_batch_transfer_from( &market.owner, &market.owner, &market.vault, *class_id, + // SBP-M1 review: indexing may panic, consider .get() instead asset_ids[idx].clone(), amounts[idx].clone(), )?; } Self::deposit_event(Event::LiquidityAdded { + // SBP-M1 review: unnecessary clone who: who.clone(), market_id, market_rate_id, @@ -498,21 +574,28 @@ impl Pallet { amounts, }); + // SBP-M1 review: unnecessary .into() Ok(().into()) } + // SBP-M1 review: too many lines, refactor + // SBP-M1 review: who uses this? Appears to be no usage in project. Wrap in a well documented trait so other pallets can call via trait pub fn remove_liquidity( who: &T::AccountId, market_id: T::MarketId, market_rate_id: T::MarketRateId, + // SBP-M1 review: vectors should be bounded + // SBP-M1 review: use Vec<(T::ClassId, Vec, Vec)> to avoid needing to check sizes of each vector match class_ids: Vec, asset_ids: Vec>, amounts: Vec>, ) -> DispatchResult { let market = Markets::::get(market_id).ok_or(Error::::InvalidMarket)?; + // SBP-M1 review: value not used, used .contains_key() with ensure! let _market_rate = MarketRates::::get((market_id, market_rate_id)) .ok_or(Error::::InvalidMarketRate)?; + // SBP-M1 review: move above market rate check to prevent unnecessary read if caller is not market owner ensure!(*who == market.owner, Error::::InvalidMarketOwner); ensure!( @@ -526,21 +609,25 @@ impl Pallet { for (idx, class_id) in class_ids.iter().enumerate() { ensure!( + // SBP-M1 review: whilst size checked above, using .get() is preferred over indexing due to possibility of panic asset_ids[idx].len() == amounts[idx].len(), Error::::InvalidArrayLength ); + // SBP-M1 review: should use trait, defined as associated type on Config trait of pallet (loose coupling) sugarfunge_asset::Pallet::::do_batch_transfer_from( &market.owner, &market.vault, &market.owner, *class_id, + // SBP-M1 review: indexing may panic, consider .get() instead asset_ids[idx].clone(), amounts[idx].clone(), )?; } Self::deposit_event(Event::LiquidityRemoved { + // SBP-M1 review: unnecessary clone who: who.clone(), market_id, market_rate_id, @@ -549,34 +636,44 @@ impl Pallet { amounts, }); + // SBP-M1 review: unnecessary .into() Ok(().into()) } + // SBP-M1 review: too many lines, refactor pub fn do_quote_deposit( who: &T::AccountId, market_id: T::MarketId, market_rate_id: T::MarketRateId, amount: Balance, + // SBP-M1 review: consider changing to Result, DispatchError> and simply returning error if !can_do_deposit ) -> Result<(bool, RateBalances), DispatchError> { let market = Markets::::get(market_id).ok_or(Error::::InvalidMarket)?; let rates = MarketRates::::get((market_id, market_rate_id)) .ok_or(Error::::InvalidMarketRate)?; + // SBP-M1 review: move above rates check, inefficient to read all rates to then find caller is not owner when that data already in memory from previous call ensure!(*who == market.owner, Error::::InvalidMarketOwner); let mut deposit_balances = BTreeMap::new(); + // SBP-M1 review: consider grouping each 'phase' of algorithm into blocks: aggregate, compute burns, compute transfers // RateAction::Transfer|Burn - Aggregate transferable prices and balances let mut balances: TransactionBalances = BTreeMap::new(); let mut prices: TransactionBalances = BTreeMap::new(); + // SBP-M1 review: why use a signed integer? let total_amount: i128 = amount.try_into().map_err(|_| Error::::Overflow)?; + // SBP-M1 review: filter and collect in single statement > rates.into_iter().filter(..).collect(); let asset_rates = rates.into_iter().filter(|asset_rate| { + // SBP-M1 review: refactor into .quotable() function on enum to simplify to asset_rate.from == RateAccount::Market && asset_rate.action.quotable() + // SBP-M1 review: alternatively use matches! let quotable = match asset_rate.action { RateAction::Transfer(_) | RateAction::Burn(_) => true, + // SBP-M1 review: wildcard will match future added variants _ => false, }; asset_rate.from == RateAccount::Market && quotable @@ -606,6 +703,8 @@ impl Pallet { .get_amount() .checked_mul(total_amount) .ok_or(Error::::Overflow)?; + // SBP-M1 review: duplicate code, refactor into reusable function + // SBP-M1 review: consider BTreeMap.entry() api if let Some(price) = prices.get_mut(&( asset_rate.from.clone(), asset_rate.class_id, @@ -627,6 +726,7 @@ impl Pallet { // RateAction::Burn - Compute total burns for asset_rate in &asset_rates { + // SBP-M1 review: use let-else with continue to reduce nesting if let RateAction::Burn(_) = asset_rate.action { let price = prices .get(&( @@ -635,6 +735,7 @@ impl Pallet { asset_rate.asset_id, )) .ok_or(Error::::InvalidBurnPrice)?; + // SBP-M1 review: consider .entry() api let balance = balances .get_mut(&( asset_rate.from.clone(), @@ -654,6 +755,7 @@ impl Pallet { // RateAction::Transfer - Compute total transfers for asset_rate in &asset_rates { + // SBP-M1 review: use let-else with continue to reduce nesting if let RateAction::Transfer(_) = asset_rate.action { let price = prices .get(&( @@ -662,6 +764,7 @@ impl Pallet { asset_rate.asset_id, )) .ok_or(Error::::InvalidTransferPrice)?; + // SBP-M1 review: consider .entry() api let balance = balances .get_mut(&( asset_rate.from.clone(), @@ -680,16 +783,20 @@ impl Pallet { let mut can_do_deposit = true; + // SBP-M1 review: use deposit_balances.values() for (_, deposit_balance) in &deposit_balances { if *deposit_balance < 0 { + // SBP-M1 review: consider return Err(Error::CannotDeposit); can_do_deposit = false; break; } } + // SBP-M1 review: consider Ok(deposit_balances) Ok((can_do_deposit, deposit_balances)) } + // SBP-M1 review: too many lines, refactor pub fn do_deposit( who: &T::AccountId, market_id: T::MarketId, @@ -697,6 +804,7 @@ impl Pallet { amount: Balance, ) -> DispatchResult { let market = Markets::::get(market_id).ok_or(Error::::InvalidMarket)?; + // SBP-M1 review: value not used therefore inefficient, use .contains_key() with ensure! let _market_rate = MarketRates::::get((market_id, market_rate_id)) .ok_or(Error::::InvalidMarketRate)?; @@ -705,7 +813,9 @@ impl Pallet { let (can_do_deposit, deposit_balances) = Self::do_quote_deposit(who, market_id, market_rate_id, amount)?; + // SBP-M1 review: consider returning an error rather than signalling that caller can not deposit via success attribute of Deposit event if can_do_deposit { + // SBP-M1 review: each transfer request results in separate state change, consider grouping by class/asset if applicable for (asset_rate, amount) in &deposit_balances { let amount: u128 = (*amount).try_into().map_err(|_| Error::::Overflow)?; sugarfunge_asset::Pallet::::do_transfer_from( @@ -727,7 +837,9 @@ impl Pallet { }) .collect(); + // SBP-M1 review: consider emitting an error if the deposit could not be performed rather than success: can_do_deposit Self::deposit_event(Event::Deposit { + // SBP-M1 review: unnecessary clone() who: who.clone(), market_id, market_rate_id, @@ -736,10 +848,12 @@ impl Pallet { success: can_do_deposit, }); + // SBP-M1 review: .into() unnecessary Ok(().into()) } pub fn get_vault(market_id: T::MarketId) -> Option { + // SBP-M1 review: use .map() instead of .and_then() Markets::::get(market_id).and_then(|market| Some(market.vault)) } @@ -751,12 +865,14 @@ impl Pallet { sugarfunge_asset::Pallet::::balance_of(&market.vault, class_id, asset_id) } + // SBP-M1 review: typo - incomming > incoming /// Pricing function used for converting between outgoing asset to incomming asset. /// /// - `amount_out`: Amount of outgoing asset being bought. /// - `reserve_in`: Amount of incomming asset in reserves. /// - `reserve_out`: Amount of outgoing asset in reserves. /// Return the price Amount of incomming asset to send to vault. + // SBP-M1 review: unused, no test pub fn get_buy_price( amount_out: Balance, reserve_in: Balance, @@ -782,11 +898,13 @@ impl Pallet { Ok(amount_in) } + // SBP-M1 review: too many lines, refactor pub fn do_quote_exchange( buyer: &T::AccountId, market_id: T::MarketId, market_rate_id: T::MarketRateId, amount: Balance, + // SBP-M1 review: consider changing to Result, DispatchError> and simply returning error if !can_do_exchange ) -> Result<(bool, RateBalances), DispatchError> { ensure!(amount > 0, Error::::InsufficientAmount); @@ -798,10 +916,13 @@ impl Pallet { let mut can_do_exchange = true; + // SBP-M1 review: consider grouping each 'phase' of algorithm into blocks: prove, aggregate, burn, transfer, mint // RateAction::Has - Prove parties possess non-transferable assets for asset_rate in rates.iter() { + // SBP-M1 review: use let-else with continue to reduce nesting if let RateAction::Has(op, amount) = asset_rate.action { + // SBP-M1 review: consider .target_account() helper function on enum let target_account = match &asset_rate.from { RateAccount::Account(account) => account, RateAccount::Buyer => buyer, @@ -814,12 +935,15 @@ impl Pallet { ) .try_into() .map_err(|_| Error::::Overflow)?; + // SBP-M1 review: refactor into helper function - e.g. op.evaluate(balance, amount) let amount = match op { AmountOp::Equal => { if balance == amount { amount } else { + // SBP-M1 review: return early? can_do_exchange = false; + // SBP-M1 review: use safe math balance - amount } } @@ -827,7 +951,9 @@ impl Pallet { if balance >= amount { amount } else { + // SBP-M1 review: return early? can_do_exchange = false; + // SBP-M1 review: use safe math balance - amount } } @@ -835,7 +961,9 @@ impl Pallet { if balance > amount { amount } else { + // SBP-M1 review: return early? can_do_exchange = false; + // SBP-M1 review: use safe math balance - amount } } @@ -843,7 +971,9 @@ impl Pallet { if balance <= amount { amount } else { + // SBP-M1 review: return early? can_do_exchange = false; + // SBP-M1 review: use safe math amount - balance } } @@ -851,7 +981,9 @@ impl Pallet { if balance < amount { amount } else { + // SBP-M1 review: return early? can_do_exchange = false; + // SBP-M1 review: use safe math amount - balance } } @@ -871,6 +1003,7 @@ impl Pallet { for asset_rate in rates.iter() { let balance = match &asset_rate.action { RateAction::Transfer(_) | RateAction::Burn(_) => { + // SBP-M1 review: refactor into .target_account() helper function on enum let target_account = match &asset_rate.from { RateAccount::Account(account) => account, RateAccount::Buyer => buyer, @@ -885,6 +1018,7 @@ impl Pallet { .map_err(|_| Error::::Overflow)?; Some(balance) } + // SBP-M1 review: prefer explict matches, wildcard will match any future added variants _ => None, }; if let Some(balance) = balance { @@ -902,6 +1036,8 @@ impl Pallet { .get_amount() .checked_mul(total_amount) .ok_or(Error::::Overflow)?; + // SBP-M1 review: duplicate code, refactor into reusable function + // SBP-M1 review: consider BTreeMap.entry() api if let Some(price) = prices.get_mut(&( asset_rate.from.clone(), asset_rate.class_id, @@ -923,6 +1059,7 @@ impl Pallet { // RateAction::Burn - Compute total burns for asset_rate in rates.iter() { + // SBP-M1 review: use let-else continue to reduce nesting if let RateAction::Burn(_) = &asset_rate.action { let price = prices .get(&( @@ -939,7 +1076,9 @@ impl Pallet { )) .ok_or(Error::::InvalidBurnBalance)?; *balance = balance.checked_sub(*price).ok_or(Error::::Overflow)?; + // SBP-M1 review: duplicate code if *balance < 0 { + // SBP-M1 review: return early can_do_exchange = false; exchange_balances.insert(asset_rate.clone(), *balance); } else { @@ -951,6 +1090,7 @@ impl Pallet { // RateAction::Transfer - Compute total transfers for asset_rate in rates.iter() { + // SBP-M1 review: use let-else with continue to reduce nesting if let RateAction::Transfer(_) = &asset_rate.action { let price = prices .get(&( @@ -967,6 +1107,7 @@ impl Pallet { )) .ok_or(Error::::InvalidTransferBalance)?; *balance = balance.checked_sub(*price).ok_or(Error::::Overflow)?; + // SBP-M1 review: duplicate code if *balance < 0 { can_do_exchange = false; exchange_balances.insert(asset_rate.clone(), *balance); @@ -979,6 +1120,7 @@ impl Pallet { // RateAction::Mint - Compute total mints for asset_rate in rates.iter() { + // SBP-M1 review: use let-else with continue to reduce nesting if let RateAction::Mint(_) = &asset_rate.action { let price = prices .get(&( @@ -991,9 +1133,11 @@ impl Pallet { } } + // SBP-M1 review: consider Ok(exchange_balances), returning error early once !can_do_exchange Ok((can_do_exchange, exchange_balances)) } + // SBP-M1 review: too many lines, refactor pub fn do_exchange_assets( buyer: &T::AccountId, market_id: T::MarketId, @@ -1001,23 +1145,28 @@ impl Pallet { amount: Balance, ) -> DispatchResult { let market = Markets::::get(market_id).ok_or(Error::::InvalidMarket)?; + // SBP-M1 review: value not used therefore inefficient, use .contains_key() with ensure! let _market_rate = MarketRates::::get((market_id, market_rate_id)) .ok_or(Error::::InvalidMarketRate)?; + // SBP-M1 review: move before market rate check to avoid unnecessary read if buyer is owner/vault ensure!(*buyer != market.owner, Error::::InvalidBuyer); ensure!(*buyer != market.vault, Error::::InvalidBuyer); let (can_do_exchange, exchange_balances) = Self::do_quote_exchange(buyer, market_id, market_rate_id, amount)?; + // SBP-M1 review: consider returning an error rather than signalling that caller can not exchange via success attribute of Exchanged event if can_do_exchange { for (asset_rate, amount) in &exchange_balances { let amount: u128 = (*amount).try_into().map_err(|_| Error::::Overflow)?; + // SBP-M1 review: use .from() helper method on enum let from = match &asset_rate.from { RateAccount::Account(account) => account, RateAccount::Buyer => buyer, RateAccount::Market => &market.vault, }; + // SBP-M1 review: use .to() helper method on enum let to = match &asset_rate.to { RateAccount::Account(account) => account, RateAccount::Buyer => buyer, @@ -1046,6 +1195,7 @@ impl Pallet { asset_rate.asset_id, amount, )?, + // SBP-M1 review: use actual enum variants, wildcard will match future added variants _ => (), } } @@ -1059,7 +1209,9 @@ impl Pallet { }) .collect(); + // SBP-M1 review: consider emitting an error if the exchange could not be performed rather than success: can_do_exchange Self::deposit_event(Event::Exchanged { + // SBP-M1 review: unnecessary clone() buyer: buyer.clone(), market_id, market_rate_id, @@ -1068,6 +1220,7 @@ impl Pallet { success: can_do_exchange, }); + // SBP-M1 review: .into() unnecessary Ok(().into()) } } diff --git a/pallets/market/src/mock.rs b/pallets/market/src/mock.rs index 0043694..76cd3a0 100644 --- a/pallets/market/src/mock.rs +++ b/pallets/market/src/mock.rs @@ -143,6 +143,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } pub fn run_to_block(n: u64) { + // SBP-M1 review: market pallet doesnt implement any hooks to these seem unnecessary? while System::block_number() < n { Market::on_finalize(System::block_number()); Balances::on_finalize(System::block_number()); diff --git a/pallets/market/src/tests.rs b/pallets/market/src/tests.rs index 2a1dbf3..c23c0ff 100644 --- a/pallets/market/src/tests.rs +++ b/pallets/market/src/tests.rs @@ -4,6 +4,11 @@ use crate::{ use frame_support::{assert_noop, assert_ok, bounded_vec}; use sp_std::prelude::*; +// SBP-M1 review: tests do not run in isolation, seemingly due to pallet_balances missing from std feature in cargo.toml. Works when run from project root. +// SBP-M1 review: dispatchable functions not tested, only corresponding impls +// SBP-M1 review: missing event assertions (LiquidityAdded, LiquidityRemoved) + +// SBP-M1 review: replace with assert_last_event or assert_has_event fn last_event() -> RuntimeEvent { frame_system::Pallet::::events() .pop() @@ -12,6 +17,7 @@ fn last_event() -> RuntimeEvent { } fn simple_market_rates() -> Rates { + // SBP-M1 review: use bounded_vec![] vec![ // // Buyer wants these goods @@ -24,6 +30,7 @@ fn simple_market_rates() -> Rates { from: RateAccount::Market, to: RateAccount::Buyer, }, + // SBP-M1 review: quantity in comment does not match mint amount in action // Market will mint 100 assets of class_id: 2000 asset_id: 2 for buyer AssetRate { class_id: 2000, @@ -84,6 +91,7 @@ fn simple_market_rates() -> Rates { } fn swap_market_rates() -> Rates { + // SBP-M1 review: use bounded_vec![] vec![ // // Buyer wants these goods @@ -109,13 +117,16 @@ fn swap_market_rates() -> Rates { .unwrap() } +// SBP-M1 review: pub not required pub fn before_market() { run_to_block(10); + // SBP-M1 review: use BoundedVec::new() or BoundedVec::default() assert_ok!(Asset::do_create_class(&1, &1, 2000, bounded_vec![])); assert_ok!(Asset::do_create_class(&1, &1, 3000, bounded_vec![])); assert_ok!(Asset::do_create_class(&1, &1, 4000, bounded_vec![])); + // SBP-M1 review: use vec![] rather than [].to_vec() let asset_ids = [1, 2, 3, 4, 5].to_vec(); let amounts = [100, 200, 300, 400, 500].to_vec(); @@ -145,6 +156,7 @@ pub fn before_market() { assert_ok!(Market::do_create_market(&1, 1000)); + // SBP-M1 review: replace with assert_last_event or assert_has_event assert_eq!( last_event(), RuntimeEvent::Market(crate::Event::Created { @@ -154,6 +166,7 @@ pub fn before_market() { ); } +// SBP-M1 review: pub not required pub fn add_some_liquidity() { run_to_block(10); @@ -197,6 +210,7 @@ fn create_market_works() { assert_ok!(Market::do_create_market(&1, 1001)); + // SBP-M1 review: replace with assert_last_event or assert_has_event assert_eq!( last_event(), RuntimeEvent::Market(crate::Event::Created { @@ -216,6 +230,7 @@ fn create_market_rate_works() { assert_ok!(Market::do_create_market_rate(&1, 1000, 2, &market_rate)); + // SBP-M1 review: replace with assert_last_event or assert_has_event assert_eq!( last_event(), RuntimeEvent::Market(crate::Event::RateCreated { @@ -328,6 +343,7 @@ fn deposit_works() { assert_eq!(market_rate_id, 100); assert_eq!(amount, 4); + // SBP-M1 review: duplicate code, refactor into function let get_balance = |rate_idx: usize| { balances.iter().find_map(|RateBalance { rate, balance }| { if *rate == rates[rate_idx] { @@ -360,6 +376,7 @@ fn deposit_fails() { assert_ok!(Market::do_create_market_rate(&2, 2000, 100, &rates)); assert_ok!(Market::do_deposit(&2, 2000, 100, 100)); + // SBP-M1 review: replace with assert_last_event or assert_has_event, passing event with expected values for comparison if let RuntimeEvent::Market(crate::Event::Deposit { who, market_id, @@ -375,6 +392,7 @@ fn deposit_fails() { assert_eq!(market_rate_id, 100); assert_eq!(amount, 100); + // SBP-M1 review: duplicate code, refactor into function let get_balance = |rate_idx: usize| { balances.iter().find_map(|RateBalance { rate, balance }| { if *rate == rates[rate_idx] { @@ -506,6 +524,7 @@ fn exchange_assets_works() { assert_ok!(Market::do_exchange_assets(&3, 2000, 100, 3)); + // SBP-M1 review: replace with assert_last_event or assert_has_event, passing event with expected values for comparison if let RuntimeEvent::Market(crate::Event::Exchanged { buyer, market_id, @@ -515,6 +534,7 @@ fn exchange_assets_works() { success, }) = last_event() { + // SBP-M1 review: duplicate code, refactor into function let get_balance = |rate_idx: usize| { balances.iter().find_map(|RateBalance { rate, balance }| { if *rate == rates[rate_idx] { @@ -570,6 +590,7 @@ fn exchange_assets_fails() { assert_ok!(Market::do_exchange_assets(&3, 2000, 100, 3)); + // SBP-M1 review: replace with assert_last_event or assert_has_event, passing event with expected values for comparison if let RuntimeEvent::Market(crate::Event::Exchanged { buyer, market_id, @@ -579,6 +600,7 @@ fn exchange_assets_fails() { success, }) = last_event() { + // SBP-M1 review: duplicate code, refactor into function let get_balance = |rate_idx: usize| { balances.iter().find_map(|RateBalance { rate, balance }| { if *rate == rates[rate_idx] { diff --git a/pallets/validator-set/Cargo.toml b/pallets/validator-set/Cargo.toml index 4bd2b70..2a1c8a9 100644 --- a/pallets/validator-set/Cargo.toml +++ b/pallets/validator-set/Cargo.toml @@ -1,9 +1,12 @@ [package] +#SBP-M1 review: use double quotes name = 'sugarfunge-validator-set' version = '0.1.0' authors = ['Gautam Dhameja ', "SugarFunge Developers"] edition = '2021' +#SBP-M1 review: ensure that licenses satisfy the requirements of all dependencies license = 'Apache-2.0' +#SBP-M1 review: no description, repository [dependencies] log = { version = "0.4.17", default-features = false } @@ -20,6 +23,7 @@ sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkad pallet-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, features = ['historical'] } +#SBP-M1 review: remove as empty [dev-dependencies] [features] diff --git a/pallets/validator-set/README.md b/pallets/validator-set/README.md index b3e16ff..25f5414 100644 --- a/pallets/validator-set/README.md +++ b/pallets/validator-set/README.md @@ -196,3 +196,5 @@ When a validator goes offline, it skips its block production slot in Aura and th ## Disclaimer This code not audited and reviewed for production use cases. You can expect bugs and security vulnerabilities. Do not use it as-is in real applications. + +[//]: # (SBP-M1 review: missing license information) \ No newline at end of file diff --git a/pallets/validator-set/src/lib.rs b/pallets/validator-set/src/lib.rs index 1792049..7db4dbd 100644 --- a/pallets/validator-set/src/lib.rs +++ b/pallets/validator-set/src/lib.rs @@ -1,3 +1,4 @@ +// SBP-M1 review: cargo fmt //! # Validator Set Pallet //! //! The Validator Set Pallet allows addition and removal of @@ -23,11 +24,14 @@ use frame_support::{ BoundedVec, }; use log; +// SBP-M1 review: consider pub(crate) pub use pallet::*; use sp_runtime::traits::{Convert, Zero}; use sp_staking::offence::{Offence, OffenceError, ReportOffence}; use sp_std::{collections::btree_set::BTreeSet, prelude::*}; +// SBP-M1 review: static lifetime redundant +// SBP-M1 review: consider pub(crate) pub const LOG_TARGET: &'static str = "runtime::validator-set"; #[frame_support::pallet] @@ -38,6 +42,7 @@ pub mod pallet { /// Configure the pallet by specifying the parameters and types on which it /// depends. #[pallet::config] + // SBP-M1 review: consider loose-coupling via type ValidatorSet: ValidatorSet config item rather than pallet_session::Config pub trait Config: frame_system::Config + pallet_session::Config { /// The Event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -49,6 +54,7 @@ pub mod pallet { /// auto removal. type MinAuthorities: Get; + // SBP-M1 review: missing doc comment type MaxAuthorities: Get; } @@ -57,16 +63,19 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn validators)] + // SBP-M1 review: consider pub(super) pub type Validators = StorageValue<_, BoundedVec, ValueQuery>; #[pallet::storage] #[pallet::getter(fn approved_validators)] + // SBP-M1 review: consider pub(super) pub type ApprovedValidators = StorageValue<_, BoundedVec, ValueQuery>; #[pallet::storage] #[pallet::getter(fn validators_to_remove)] + // SBP-M1 review: consider pub(super) pub type OfflineValidators = StorageValue<_, BoundedVec, ValueQuery>; @@ -93,6 +102,7 @@ pub mod pallet { BadOrigin, } + // SBP-M1 review: not used, can be removed #[pallet::hooks] impl Hooks> for Pallet {} @@ -104,12 +114,14 @@ pub mod pallet { #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { + // SBP-M1 review: consider Vec::default() for clarity Self { initial_validators: Default::default() } } } #[pallet::genesis_build] impl GenesisBuild for GenesisConfig { + // SBP-M1 review: consider using Vec as parameter type fn build(&self) { Pallet::::initialize_validators(&self.initial_validators); } @@ -125,6 +137,7 @@ pub mod pallet { /// The origin can be configured using the `AddRemoveOrigin` type in the /// host runtime. Can also be set to sudo/root. #[pallet::call_index(0)] + // SBP-M1 review: benchmark and use proper weight function to avoid spam/DoS - use DispatchResultWithPostInfo and return Pays:No as per sudo pallet #[pallet::weight(Weight::from_parts(0, 0))] pub fn add_validator(origin: OriginFor, validator_id: T::AccountId) -> DispatchResult { T::AddRemoveOrigin::ensure_origin(origin)?; @@ -140,6 +153,7 @@ pub mod pallet { /// The origin can be configured using the `AddRemoveOrigin` type in the /// host runtime. Can also be set to sudo/root. #[pallet::call_index(1)] + // SBP-M1 review: benchmark and use proper weight function to avoid spam/DoS - use DispatchResultWithPostInfo and return Pays:No as per sudo pallet #[pallet::weight(Weight::from_parts(0, 0))] pub fn remove_validator( origin: OriginFor, @@ -148,6 +162,7 @@ pub mod pallet { T::AddRemoveOrigin::ensure_origin(origin)?; Self::do_remove_validator(validator_id.clone())?; + // SBP-M1 review: appears to have no effect Self::unapprove_validator(validator_id)?; Ok(()) @@ -157,14 +172,17 @@ pub mod pallet { /// /// For this call, the dispatch origin must be the validator itself. #[pallet::call_index(2)] + // SBP-M1 review: benchmark and use proper weight function to avoid spam/DoS - use DispatchResultWithPostInfo and return Pays:No as per sudo pallet #[pallet::weight(Weight::from_parts(0, 0))] pub fn add_validator_again( origin: OriginFor, + // SBP-M1 review: why have this parameter when it can just be obtained via ensure_signed? validator_id: T::AccountId, ) -> DispatchResult { let who = ensure_signed(origin)?; ensure!(who == validator_id, Error::::BadOrigin); + // SBP-M1 review: use BoundedVec.contains() let approved_set: BTreeSet<_> = >::get().into_iter().collect(); ensure!(approved_set.contains(&validator_id), Error::::ValidatorNotApproved); @@ -183,25 +201,32 @@ impl Pallet { ); assert!( (validators.len() as u32) < (T::MaxAuthorities::get()), + // SBP-M1 review: improve comment "Initial set of validators must be at less than T::MaxAuthorities" ); assert!(>::get().is_empty(), "Validators are already initialized!"); let validators: BoundedVec = + // SBP-M1 review: avoid unwrap (panic) validators.to_vec().try_into().unwrap(); + // SBP-M1 review: use & to avoid clone >::put(validators.clone()); >::put(validators); } fn do_add_validator(validator_id: T::AccountId) -> DispatchResult { + // SBP-M1 review: unnecessary set, use .contains() on BoundedVec let validator_set: BTreeSet<_> = >::get().into_iter().collect(); ensure!(!validator_set.contains(&validator_id), Error::::Duplicate); + // SBP-M1 review: use BoundedVec from first storage query let mut validators = >::get().to_vec(); validators.push(validator_id.clone()); let validators: BoundedVec = + // SBP-M1 review: avoid unwrap, return error validators.to_vec().try_into().unwrap(); >::put(validators); + // SBP-M1 review: unnecessary clone Self::deposit_event(Event::ValidatorAdditionInitiated(validator_id.clone())); log::debug!(target: LOG_TARGET, "Validator addition initiated."); @@ -214,6 +239,7 @@ impl Pallet { // Ensuring that the post removal, target validator count doesn't go // below the minimum. ensure!( + // SBP-M1 review: cast may truncate validators.len().saturating_sub(1) as u32 >= T::MinAuthorities::get(), Error::::TooLowValidatorCount ); @@ -222,6 +248,7 @@ impl Pallet { >::put(validators); + // SBP-M1 review: unnecessary clone Self::deposit_event(Event::ValidatorRemovalInitiated(validator_id.clone())); log::debug!(target: LOG_TARGET, "Validator removal initiated."); @@ -229,11 +256,15 @@ impl Pallet { } fn approve_validator(validator_id: T::AccountId) -> DispatchResult { + // SBP-M1 review: doesnt need to be a set to check if validator_id exists let approved_set: BTreeSet<_> = >::get().into_iter().collect(); ensure!(!approved_set.contains(&validator_id), Error::::Duplicate); + // SBP-M1 review: use .into_inner() to use existing vector let mut validators = >::get().to_vec(); + // SBP-M1 review: unnecessary clone validators.push(validator_id.clone()); + // SBP-M1 review: use BoundedVec received directly from storage, avoid unwrap, unnecessary clone let validators: BoundedVec = validators.to_vec().try_into().unwrap(); >::put(validators); @@ -241,17 +272,24 @@ impl Pallet { Ok(()) } + // SBP-M1 review: appears to have no effect as storage not updated with updated set fn unapprove_validator(validator_id: T::AccountId) -> DispatchResult { let mut approved_set = >::get(); approved_set.retain(|v| *v != validator_id); + // SBP-M1 review: return type unnecessary Ok(()) } + // SBP-M1 review: comment should be refined based on logic: validator_id added to OfflineValidators // Adds offline validators to a local cache for removal at new session. fn mark_for_removal(validator_id: T::AccountId) { + // SBP-M1 review: use .into_inner() to access inner vec rather than implicit clone let mut validators = >::get().to_vec(); + // SBP-M1 review: clone unnecessary validators.push(validator_id.clone()); + // SBP-M1 review: why not just use the BoundedVec from OfflineValidators::get() let validators: BoundedVec = + // SBP-M1 review: already its own vector, unwrap could panic validators.to_vec().try_into().unwrap(); >::put(validators); @@ -264,6 +302,7 @@ impl Pallet { // check for `MinAuthorities` here, because the offline validators will not // produce blocks and will have the same overall effect on the runtime. fn remove_offline_validators() { + // SBP-M1 review: set may be unnecessary if all OfflineValidators modifications ensure distinct items let validators_to_remove: BTreeSet<_> = >::get().into_iter().collect(); // Delete from active validator set. @@ -275,6 +314,7 @@ impl Pallet { ); // Clear the offline validator list to avoid repeated deletion. + // SBP-M1 review: use BoundedVec::new() or BoundedVec::default(), avoid .unwrap() let validators: BoundedVec = vec![].try_into().unwrap(); >::put(validators); } @@ -287,10 +327,12 @@ impl pallet_session::SessionManager for Pallet { fn new_session(_new_index: u32) -> Option> { // Remove any offline validators. This will only work when the runtime // also has the im-online pallet. + // SBP-M1 review: consider returning validator set from this function as it already reads validators state Self::remove_offline_validators(); log::debug!(target: LOG_TARGET, "New session called; updated validator set provided."); + // SBP-M1 review: use .into_inner() Some(Self::validators().to_vec()) } @@ -299,6 +341,7 @@ impl pallet_session::SessionManager for Pallet { fn start_session(_start_index: u32) {} } +// SBP-M1 review: provide justification as to why this provides default values impl EstimateNextSessionRotation for Pallet { fn average_session_length() -> T::BlockNumber { Zero::zero() @@ -306,18 +349,21 @@ impl EstimateNextSessionRotation for Pallet { fn estimate_current_session_progress( _now: T::BlockNumber, + // SBP-M1 review: unnecessary qualification ) -> (Option, frame_support::dispatch::Weight) { (None, Zero::zero()) } fn estimate_next_session_rotation( _now: T::BlockNumber, + // SBP-M1 review: unnecessary qualification ) -> (Option, frame_support::dispatch::Weight) { (None, Zero::zero()) } } // Implementation of Convert trait for mapping ValidatorId with AccountId. +// SBP-M1 review: unnecessary qualification pub struct ValidatorOf(sp_std::marker::PhantomData); impl Convert> for ValidatorOf { @@ -326,6 +372,7 @@ impl Convert> for ValidatorOf< } } +// SBP-M1 review: consider loose coupling with pallet_session injected via type with ValidatorSet trait bound on Config impl ValidatorSet for Pallet { type ValidatorId = T::ValidatorId; type ValidatorIdOf = T::ValidatorIdOf; @@ -351,7 +398,10 @@ impl> fn report_offence(_reporters: Vec, offence: O) -> Result<(), OffenceError> { let offenders = offence.offenders(); + // SBP-M1 review: simply as 'for (v, _) in offenders {}' for (v, _) in offenders.into_iter() { + // SBP-M1 review: pass offenders as parameters to process as batch + // SBP-M1 review: should timeslot be passed so that is_known_offence can be properly implemented Self::mark_for_removal(v); } @@ -361,6 +411,7 @@ impl> fn is_known_offence( _offenders: &[(T::AccountId, T::AccountId)], _time_slot: &O::TimeSlot, + // SBP-M1 review: provide justification as to why this is not implemented ) -> bool { false } diff --git a/pallets/validator-set/src/mock.rs b/pallets/validator-set/src/mock.rs index a403fe7..fd2ae95 100644 --- a/pallets/validator-set/src/mock.rs +++ b/pallets/validator-set/src/mock.rs @@ -1,3 +1,4 @@ +// SBP-M1 review: cargo fmt //! Mock helpers for Validator Set pallet. #![cfg(test)] diff --git a/pallets/validator-set/src/tests.rs b/pallets/validator-set/src/tests.rs index 568dbb9..f606d8d 100644 --- a/pallets/validator-set/src/tests.rs +++ b/pallets/validator-set/src/tests.rs @@ -1,3 +1,4 @@ +// SBP-M1 review: cargo fmt //! Tests for the Validator Set pallet. #![cfg(test)] @@ -7,6 +8,8 @@ use crate::mock::{authorities, new_test_ext, RuntimeOrigin, Session, Test, Valid use frame_support::{assert_noop, assert_ok, pallet_prelude::*}; use sp_runtime::testing::UintAuthorityId; +// SBP-M1 review: improve test coverage - add_validator_again not tested, no event assertions, limited error assertions + #[test] fn simple_setup_should_work() { new_test_ext().execute_with(|| { diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 2e96ea6..98af73b 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -5,20 +5,24 @@ authors = ["SugarFunge Developers"] edition = "2021" license = "Proprietary" build = "build.rs" +#SBP-M1 review: no description, repository [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies] # third-party dependencies +#SBP-M1 review: use single line codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [ "derive", ] } +#SBP-M1 review: use single line scale-info = { version = "2.5.0", default-features = false, features = [ "derive", ] } hex-literal = { version = "0.4.1", optional = true } log = { version = "0.4.17", default-features = false } +#SBP-M1 review: unused? getrandom = { version = "0.2", features = ["js"] } # primitives @@ -62,10 +66,11 @@ pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/parityt pallet-collective = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } # Contract +#SBP-M1 review: not used by runtime, remove pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } pallet-contracts = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } +#SBP-M1 review: remove unused dependency # pallet-contracts-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false } - # Used for runtime benchmarking frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true } frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43", default-features = false, optional = true } @@ -73,16 +78,25 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", b sugarfunge-primitives = { git = "https://github.com/SugarFunge/sugarfunge-primitives", branch = "fula/release", default-features = false } # local pallets +#SBP-M1 review: has not kept pace with forked repo (e.g. benchmarked weights at https://github.com/gautamdhameja/substrate-validator-set), consider replacing dependency +#SBP-M1 review: readme states not to use 'as-is' in real applications sugarfunge-validator-set = { default-features = false, path = "../pallets/validator-set" } +#SBP-M1 review: not used by runtime sugarfunge-bridge = { default-features = false, path = "../pallets/bridge" } + sugarfunge-asset = { git = "https://github.com/SugarFunge/sugarfunge-asset", branch = "fula/release", default-features = false } sugarfunge-dao = { default-features = false, path = "../pallets/dao" } sugarfunge-bundle = { git = "https://github.com/SugarFunge/sugarfunge-bundle", branch = "fula/release", default-features = false } + +#SBP-M1 review: not local pallet, move above +#SBP-M1 review: not local pallet, move above + sugarfunge-bag = { default-features = false, path = "../pallets/bag" } +#SBP-M1 review: pallet_template, remove from runtime until properly implemented sugarfunge-exgine = { default-features = false, path = "../pallets/exgine" } sugarfunge-market = { default-features = false, path = "../pallets/market" } -functionland-fula = { git = "https://github.com/functionland/fula-pallet" , branch = "fula/release" , default-features = false } +functionland-fula = { git = "https://github.com/functionland/fula-pallet" , branch = "main" , default-features = false } fula-pool = { git = "https://github.com/MauricinhoMorales/fula-pool" , branch = "fula/release" , default-features = false } [build-dependencies] @@ -94,6 +108,7 @@ std = [ "codec/std", "scale-info/std", "log/std", + #SBP-M1 review: remove blank line "frame-executive/std", "frame-support/std", @@ -129,6 +144,7 @@ std = [ "pallet-contracts-primitives/std", "pallet-collective/std", "pallet-node-authorization/std", + #SBP-M1 review: remove blank line "sugarfunge-validator-set/std", "sugarfunge-asset/std", diff --git a/runtime/src/constants.rs b/runtime/src/constants.rs index cf8214e..bb1d199 100644 --- a/runtime/src/constants.rs +++ b/runtime/src/constants.rs @@ -4,10 +4,12 @@ pub mod currency { use crate::Balance; + // SBP-M1 review: provide justification for values or link to source pub const MILLICENTS: Balance = 10_000_000_000_000; pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent. pub const DOLLARS: Balance = 100 * CENTS; + // SBP-M1 review: seems unused, remove pub const fn deposit(items: u32, bytes: u32) -> Balance { items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS } @@ -37,11 +39,14 @@ pub mod time { pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000; + // SBP-M1 review: copy comment from https://github.com/substrate-developer-hub/substrate-node-template/blob/e6bf90cfbf774fc284056068fe75e3e97eeb0306/runtime/src/lib.rs#L122 pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; + // SBP-M1 review: not used, remove // 1 in 4 blocks (on average, not counting collisions) will be primary BABE blocks. pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); + // SBP-M1 review: not used, remove pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES; pub const EPOCH_DURATION_IN_SLOTS: u64 = { const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 80b9649..5f412fb 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -53,6 +53,7 @@ pub use pallet_timestamp::Call as TimestampCall; pub use sp_runtime::BuildStorage; #[cfg(any(feature = "std", test))] pub use sugarfunge_bundle::Call as BundleCall; +// SBP-M1 review: pallet_template, remove from runtime until properly implemented #[cfg(any(feature = "std", test))] pub use sugarfunge_exgine::Call as ExgineCall; #[cfg(any(feature = "std", test))] @@ -117,13 +118,17 @@ pub fn native_version() -> NativeVersion { /// We assume that ~10% of the block weight is consumed by `on_initalize` handlers. /// This is used to limit the maximal weight of a single extrinsic. +// SBP-M1 review: remove as unused // const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10); /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used /// by Operational extrinsics. const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +// SBP-M1 review: remove as unused /// We allow for 2 seconds of compute with a 6 second average block time. // const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(2_000_000_000_000); +// SBP-M1 review: move closer to usage /// Maximum metadata size usually for JSON content +// SBP-M1 review: evaluate whether this is still feasible if becoming a parachain and adjust design accordingly const METADATA_SIZE: u32 = 1024 * 4; parameter_types! { @@ -134,6 +139,7 @@ parameter_types! { Weight::from_parts(2u64 * WEIGHT_REF_TIME_PER_SECOND, u64::MAX), NORMAL_DISPATCH_RATIO, ); + // SBP-M1 review: rename to BlockLength pub RuntimeBlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength ::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); pub const SS58Prefix: u8 = 42; @@ -205,6 +211,7 @@ impl pallet_aura::Config for Runtime { impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; + // SBP-M1 review: remove //type RuntimeCall = RuntimeCall; type WeightInfo = (); @@ -216,6 +223,7 @@ impl pallet_grandpa::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining to `type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;` pub const MinimumPeriod: u64 = SLOT_DURATION / 2; } @@ -232,7 +240,9 @@ pub const EXISTENTIAL_DEPOSIT: u128 = 500; parameter_types! { // For weight estimation, we assume that the most locks on an individual account will be 50. // This number may need to be adjusted in the future if this assumption no longer holds true. + // SBP-M1 review: only used once, consider inlining pub const MaxLocks: u32 = 50; + // SBP-M1 review: only used once, consider inlining pub const MaxReserves: u32 = 50; } @@ -255,7 +265,9 @@ impl pallet_balances::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const TransactionByteFee: Balance = 10 * MILLICENTS; + // SBP-M1 review: only used once, consider inlining pub OperationalFeeMultiplier: u8 = 5; } @@ -265,10 +277,13 @@ parameter_types! { impl pallet_transaction_payment::Config for Runtime { type RuntimeEvent = RuntimeEvent; + // SBP-M1 review: consider what happens with fees and provide an OnUnbalanced handler to CurrencyAdapter accordingly type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; + // SBP-M1 review: consider type WeightToFee = IdentityFee; type LengthToFee = ConstantMultiplier; + // SBP-M1 review: consider updating to SlowAdjustingFeeUpdate as per https://github.com/paritytech/polkadot/blob/6f991987c0b4cbbd7d4badc9ef08d83da5fefbfd/runtime/polkadot/src/lib.rs#L317 type FeeMultiplierUpdate = ConstFeeMultiplier; } @@ -279,12 +294,16 @@ impl pallet_sudo::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; + // SBP-M1 review: only used once, consider inlining pub const MaxScheduledPerBlock: u32 = 50; + // SBP-M1 review: not used, remove pub const NoPreimagePostponement: Option = Some(10); } +// SBP-M1 review: consider whether required impl pallet_scheduler::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; @@ -295,12 +314,16 @@ impl pallet_scheduler::Config for Runtime { type MaxScheduledPerBlock = MaxScheduledPerBlock; type WeightInfo = pallet_scheduler::weights::SubstrateWeight; type OriginPrivilegeCmp = EqualPrivilegeOnly; + // SBP-M1 review: consider adding Preimage pallet as required type Preimages = (); } parameter_types! { + // SBP-M1 review: increase to sane amount (e.g. 48 hours+) or provide justification pub const CouncilMotionDuration: BlockNumber = 3 * MINUTES; + // SBP-M1 review: only used once, consider inlining pub const CouncilMaxProposals: u32 = 100; + // SBP-M1 review: only used once, consider inlining pub const CouncilMaxMembers: u32 = 100; pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block; } @@ -325,9 +348,11 @@ type EnsureRootOrHalfCouncil = EitherOfDiverse< >; parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const MinAuthorities: u32 = 1; } +// SBP-M1 review: no benchmarks, zero weights impl validator_set::Config for Runtime { type RuntimeEvent = RuntimeEvent; type AddRemoveOrigin = EnsureRootOrHalfCouncil; @@ -336,6 +361,7 @@ impl validator_set::Config for Runtime { } parameter_types! { + // SBP-M1 review: consider increasing period (e.g. 6 hours is default within parachain template: https://github.com/paritytech/cumulus/blob/9e187970ff89169b795343d6ebcff53158b61324/parachain-template/runtime/src/lib.rs#L407) pub const Period: u32 = 2 * MINUTES; pub const Offset: u32 = 0; } @@ -353,21 +379,29 @@ impl pallet_session::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const CreateAssetClassDeposit: Balance = 500 * MILLICENTS; + // SBP-M1 review: not used, remove pub const CreateExchangeDeposit: Balance = 500 * MILLICENTS; + // SBP-M1 review: only used once, consider inlining pub const CreateBagDeposit: Balance = 500 * MILLICENTS; + // SBP-M1 review: not used, remove pub const CreateCurrencyClassDeposit: Balance = 500 * MILLICENTS; } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const MaxClassMetadata: u32 = METADATA_SIZE; + // SBP-M1 review: only used once, consider inlining pub const MaxAssetMetadata: u32 = METADATA_SIZE; } +// SBP-M1 review: no benchmarks, invalid static weights impl sugarfunge_asset::Config for Runtime { type RuntimeEvent = RuntimeEvent; type CreateAssetClassDeposit = CreateAssetClassDeposit; type Currency = Balances; + // SBP-M1 review: are these overkill for expected usage for the life of the chain? type AssetId = u64; type ClassId = u64; type MaxClassMetadata = MaxClassMetadata; @@ -380,16 +414,21 @@ parameter_types! { pub const MarketModuleId: PalletId = PalletId(*b"sug/mrkt"); } +// SBP-M1 review: does nothing, pallet template impl sugarfunge_dao::Config for Runtime { type RuntimeEvent = RuntimeEvent; } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const MaxAssets: u32 = 20; + // SBP-M1 review: only used once, consider inlining pub const MaxRates: u32 = 20; + // SBP-M1 review: only used once, consider inlining pub const MaxMetadata: u32 = METADATA_SIZE; } +// SBP-M1 review: no benchmarks, invalid static weights impl sugarfunge_bundle::Config for Runtime { type RuntimeEvent = RuntimeEvent; type PalletId = BundleModuleId; @@ -398,9 +437,11 @@ impl sugarfunge_bundle::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const MaxOwners: u32 = 20; } +// SBP-M1 review: no benchmarks, invalid static weights impl sugarfunge_bag::Config for Runtime { type RuntimeEvent = RuntimeEvent; type PalletId = BagModuleId; @@ -409,13 +450,16 @@ impl sugarfunge_bag::Config for Runtime { type MaxOwners = MaxOwners; } +// SBP-M1 review: does nothing, pallet_template, remove from runtime until properly implemented impl sugarfunge_exgine::Config for Runtime { type RuntimeEvent = RuntimeEvent; } +// SBP-M1 review: no benchmarks, invalid static weights impl sugarfunge_market::Config for Runtime { type RuntimeEvent = RuntimeEvent; type PalletId = MarketModuleId; + // SBP-M1 review: are these overkill for expected usage for the life of the chain? type MarketId = u64; type MarketRateId = u64; type MaxRates = MaxRates; @@ -423,7 +467,9 @@ impl sugarfunge_market::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const MaxManifestMetadata: u32 = 128; + // SBP-M1 review: only used once, consider inlining pub const MaxCID: u32 = 128; } @@ -435,7 +481,9 @@ impl functionland_fula::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const StringLimit: u32 = 128; + // SBP-M1 review: only used once, consider inlining pub const MaxPoolParticipants: u32 = 200; } @@ -446,7 +494,9 @@ impl fula_pool::Config for Runtime { } parameter_types! { + // SBP-M1 review: only used once, consider inlining pub const MaxWellKnownNodes: u32 = 8; + // SBP-M1 review: only used once, consider inlining pub const MaxPeerIdLength: u32 = 128; } @@ -467,6 +517,7 @@ construct_runtime!( NodeBlock = opaque::Block, UncheckedExtrinsic = UncheckedExtrinsic { + // SBP-M1 review: simplify syntax https://github.com/paritytech/substrate/blob/ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65/bin/node-template/runtime/src/lib.rs#L284 System: frame_system::{Pallet, Call, Config, Storage, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Aura: pallet_aura::{Pallet, Config}, @@ -485,6 +536,7 @@ construct_runtime!( Dao: sugarfunge_dao::{Pallet, Call, Storage, Event}, Bundle: sugarfunge_bundle::{Pallet, Call, Storage, Event}, Bag: sugarfunge_bag::{Pallet, Call, Storage, Event}, + // SBP-M1 review: does nothing, pallet_template, remove from runtime until properly implemented Exgine: sugarfunge_exgine::{Pallet, Call, Storage, Event}, Market: sugarfunge_market::{Pallet, Call, Storage, Event}, @@ -500,8 +552,10 @@ pub type Address = sp_runtime::MultiAddress; pub type Header = generic::Header; /// Block type as expected by this runtime. pub type Block = generic::Block; +// SBP-M1 review: doesnt appear to be used /// A Block signed with a Justification pub type SignedBlock = generic::SignedBlock; +// SBP-M1 review: doesnt appear to be used /// BlockId type as expected by this runtime. pub type BlockId = generic::BlockId; /// The SignedExtension to the basic transaction logic. @@ -539,7 +593,9 @@ mod benches { [frame_system, SystemBench::] [pallet_balances, Balances] [pallet_timestamp, Timestamp] + // SBP-M1 review: remove pallet_template [pallet_template, TemplateModule] + // SBP-M1 review: add all other pallets used once benchmarking implemented and then run benchmarks ); } @@ -728,6 +784,7 @@ impl_runtime_apis! { (list, storage_info) } + // SBP-M1 review: outdated implementation, align with https://github.com/paritytech/substrate/blob/ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65/bin/node-template/runtime/src/lib.rs#L530 fn dispatch_benchmark( config: frame_benchmarking::BenchmarkConfig ) -> Result, sp_runtime::RuntimeString> { @@ -736,6 +793,7 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; impl frame_system_benchmarking::Config for Runtime {} + // SBP-M1 review: remove // let whitelist: Vec = vec![ // // Block Number // hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), @@ -752,6 +810,7 @@ impl_runtime_apis! { use frame_support::traits::WhitelistedStorageKeys; let whitelist: Vec = AllPalletsWithSystem::whitelisted_storage_keys(); + // SBP-M1 review: as noted above, benchmarks are now read from add_benchmarks! and dont need to be manually defined here anymore let mut batches = Vec::::new(); let params = (&config, &whitelist);