diff --git a/Cargo.lock b/Cargo.lock index 4c74549d08b99..d66178b2a3857 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1414,7 +1414,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", ] [[package]] @@ -1486,7 +1486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8feb87a63249689640ac9c011742c33139204e3c134293d3054022276869133b" dependencies = [ "either", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 2.0.2", "log", "num-traits", @@ -1502,7 +1502,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" dependencies = [ "byteorder", - "rand 0.8.1", + "rand 0.8.2", "rustc-hex", "static_assertions", ] @@ -1742,9 +1742,9 @@ dependencies = [ [[package]] name = "fs-swap" -version = "0.2.5" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5839fda247e24ca4919c87c71dd5ca658f1f39e4f06829f80e3f15c3bafcfc2c" +checksum = "921d332c89b3b61a826de38c61ee5b6e02c56806cade1b0e5d81bd71f57a71bb" dependencies = [ "lazy_static", "libc", @@ -1788,9 +1788,9 @@ checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" [[package]] name = "futures" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c70be434c505aee38639abccb918163b63158a4b4bb791b45b7023044bdc3c9c" +checksum = "309f13e3f4be6d5917178c84db67c0b9a09177ac16d4f9a7313a767a68adaa77" dependencies = [ "futures-channel", "futures-core", @@ -1803,9 +1803,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f01c61843314e95f96cc9245702248733a3a3d744e43e2e755e3c7af8348a0a9" +checksum = "7a3b03bd32f6ec7885edeb99acd1e47e20e34fd4dfd3c6deed6fcac8a9d28f6a" dependencies = [ "futures-core", "futures-sink", @@ -1813,9 +1813,9 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8d3b0917ff63a2a96173133c02818fac4a746b0a57569d3baca9ec0e945e08" +checksum = "ed8aeae2b6ab243ebabe6f54cd4cf53054d98883d5d326128af7d57a9ca5cd3d" [[package]] name = "futures-cpupool" @@ -1834,7 +1834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdcef58a173af8148b182684c9f2d5250875adbcaff7b5794073894f9d8634a9" dependencies = [ "futures 0.1.30", - "futures 0.3.9", + "futures 0.3.10", "lazy_static", "log", "parking_lot 0.9.0", @@ -1845,9 +1845,9 @@ dependencies = [ [[package]] name = "futures-executor" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ee9ca2f7eb4475772cf39dd1cd06208dce2670ad38f4d9c7262b3e15f127068" +checksum = "3f7836b36b7533d16fd5937311d98ba8965ab81030de8b0024c299dd5d51fb9b" dependencies = [ "futures-core", "futures-task", @@ -1857,9 +1857,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37c1a51b037b80922864b8eed90692c5cd8abd4c71ce49b77146caa47f3253b" +checksum = "d41234e71d5e8ca73d01563974ef6f50e516d71e18f1a2f1184742e31f5d469f" [[package]] name = "futures-lite" @@ -1878,9 +1878,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f8719ca0e1f3c5e34f3efe4570ef2c0610ca6da85ae7990d472e9cbfba13664" +checksum = "3520e0eb4e704e88d771b92d51273ee212997f0d8282f17f5d8ff1cb39104e42" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -1890,15 +1890,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6adabac1290109cfa089f79192fb6244ad2c3f1cc2281f3e1dd987592b71feb" +checksum = "c72d188479368953c6c8c7140e40d7a4401674ab3b98a41e60e515d6cbdbe5de" [[package]] name = "futures-task" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92a0843a2ff66823a8f7c77bffe9a09be2b64e533562c412d63075643ec0038" +checksum = "08944cea9021170d383287169859c0ca8147d9ec285978393109954448f33cc7" dependencies = [ "once_cell", ] @@ -1921,9 +1921,9 @@ dependencies = [ [[package]] name = "futures-util" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "036a2107cdeb57f6d7322f1b6c363dad67cd63ca3b7d1b925bdf75bd5d96cda9" +checksum = "d3dd206efbe2ca683b2ce138ccdf61e1b0a63f5816dcedc9d8654c500ba0cea6" dependencies = [ "futures 0.1.30", "futures-channel", @@ -1933,7 +1933,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.0", + "pin-project-lite 0.2.4", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -1947,7 +1947,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce54d63f8b0c75023ed920d46fd71d0cbbb830b0ee012726b5b4f506fb6dea5b" dependencies = [ "bytes 0.5.6", - "futures 0.3.9", + "futures 0.3.10", "memchr", "pin-project 0.4.27", ] @@ -2429,7 +2429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16d7c5e361e6b05c882b4847dd98992534cebc6fcde7f4bc98225bcf10fd6d0d" dependencies = [ "async-io", - "futures 0.3.9", + "futures 0.3.10", "futures-lite", "if-addrs", "ipnet", @@ -2516,7 +2516,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64fa110ec7b8f493f416eed552740d10e7030ad5f63b2308f82c9608ec2df275" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "futures-timer 2.0.2", ] @@ -2787,7 +2787,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7bfe11b3202691673766b1224c432996f6b8047db17ceb743675bef3404e714" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "js-sys", "kvdb", "kvdb-memorydb", @@ -2847,7 +2847,7 @@ checksum = "2e17c636b5fe5ff900ccc2840b643074bfac321551d821243a781d0d46f06588" dependencies = [ "atomic", "bytes 0.5.6", - "futures 0.3.9", + "futures 0.3.10", "lazy_static", "libp2p-core", "libp2p-core-derive", @@ -2888,7 +2888,7 @@ dependencies = [ "ed25519-dalek", "either", "fnv", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "lazy_static", "libsecp256k1", @@ -2928,7 +2928,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3257a41f376aa23f237231971fee7e350e4d8353cfcf233aef34d6d6b638f0c" dependencies = [ "flate2", - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", ] @@ -2938,7 +2938,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e09bab25af01326b4ed9486d31325911437448edda30bc57681502542d49f20" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "log", ] @@ -2951,7 +2951,7 @@ checksum = "6fd8cdd5ef1dd0b7346975477216d752de976b92e43051bc8bd808c372ea6cec" dependencies = [ "cuckoofilter", "fnv", - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "libp2p-swarm", "log", @@ -2971,7 +2971,7 @@ dependencies = [ "byteorder", "bytes 0.5.6", "fnv", - "futures 0.3.9", + "futures 0.3.10", "futures_codec", "hex_fmt", "libp2p-core", @@ -2993,7 +2993,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c43bc51a9bc3780288c526615ba0f5f8216820ea6dcc02b89e8daee526c5fccb" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "libp2p-swarm", "log", @@ -3005,15 +3005,15 @@ dependencies = [ [[package]] name = "libp2p-kad" -version = "0.27.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a226956b49438a10f3206480b8faf5e61fc445c349ea9d9cc37766a83745fa9a" +checksum = "bfe68563ee33f3848293919afd61470ebcdea4e757a36cc2c33a5508abec2216" dependencies = [ "arrayvec 0.5.2", "bytes 0.5.6", "either", "fnv", - "futures 0.3.9", + "futures 0.3.10", "futures_codec", "libp2p-core", "libp2p-swarm", @@ -3038,7 +3038,7 @@ dependencies = [ "async-io", "data-encoding", "dns-parser", - "futures 0.3.9", + "futures 0.3.10", "if-watch", "lazy_static", "libp2p-core", @@ -3057,7 +3057,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce3200fbe6608e623bd9efa459cc8bafa0e4efbb0a2dfcdd0e1387ff4181264b" dependencies = [ "bytes 0.5.6", - "futures 0.3.9", + "futures 0.3.10", "futures_codec", "libp2p-core", "log", @@ -3076,7 +3076,7 @@ checksum = "0580e0d18019d254c9c349c03ff7b22e564b6f2ada70c045fc39738e144f2139" dependencies = [ "bytes 0.5.6", "curve25519-dalek 3.0.0", - "futures 0.3.9", + "futures 0.3.10", "lazy_static", "libp2p-core", "log", @@ -3096,7 +3096,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50b2ec86a18cbf09d7df440e7786a2409640c774e476e9a3b4d031382c3d7588" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "libp2p-swarm", "log", @@ -3112,7 +3112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a7b1bdcbe46a3a2159c231601ed29645282653c0a96ce3a2ad8352c9fbe6800" dependencies = [ "bytes 0.5.6", - "futures 0.3.9", + "futures 0.3.10", "futures_codec", "libp2p-core", "log", @@ -3128,7 +3128,7 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce3374f3b28162db9d3442c9347c4f14cb01e8290052615c7d341d40eae0599" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "log", "pin-project 1.0.2", "rand 0.7.3", @@ -3144,7 +3144,7 @@ checksum = "620e2950decbf77554b5aed3824f7d0e2c04923f28c70f9bff1a402c47ef6b1e" dependencies = [ "async-trait", "bytes 0.5.6", - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "libp2p-swarm", "log", @@ -3163,7 +3163,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf5894ee1ee63a38aa58d58a16e3dcf7ede6b59ea7b22302c00c1a41d7aec41" dependencies = [ "either", - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "log", "rand 0.7.3", @@ -3179,7 +3179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d2113a7dab2b502c55fe290910cd7399a2aa04fe70a2f5a415a87a1db600c0e" dependencies = [ "async-std", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "if-addrs", "ipnet", @@ -3195,7 +3195,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af05fe92c2a3aa320bc82a308ddb7b33bef3b060154c5a4b9fb0b01f15385fc0" dependencies = [ "async-std", - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "log", ] @@ -3206,7 +3206,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37cd44ea05a4523f40183f60ab6e6a80e400a5ddfc98b0df1c55edeb85576cd9" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "js-sys", "libp2p-core", "parity-send-wrapper", @@ -3222,7 +3222,7 @@ checksum = "270c80528e21089ea25b41dd1ab8fd834bdf093ebee422fed3b68699a857a083" dependencies = [ "async-tls", "either", - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "log", "quicksink", @@ -3240,7 +3240,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36799de9092c35782f080032eddbc8de870f94a0def87cf9f8883efccd5cacf0" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "libp2p-core", "parking_lot 0.11.1", "thiserror", @@ -3635,7 +3635,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dda822043bba2d6da31c4e14041f9794f8fb130a5959289038d0b809d8888614" dependencies = [ "bytes 0.5.6", - "futures 0.3.9", + "futures 0.3.10", "log", "pin-project 1.0.2", "smallvec 1.5.0", @@ -3709,7 +3709,7 @@ version = "0.8.0" dependencies = [ "derive_more", "fs_extra", - "futures 0.3.9", + "futures 0.3.10", "hash-db", "hex", "kvdb", @@ -3745,7 +3745,7 @@ dependencies = [ name = "node-browser-testing" version = "2.0.0" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "jsonrpc-core", "libp2p", @@ -3766,7 +3766,7 @@ dependencies = [ "frame-benchmarking-cli", "frame-support", "frame-system", - "futures 0.3.9", + "futures 0.3.10", "hex-literal", "log", "nix", @@ -4094,7 +4094,7 @@ dependencies = [ "frame-support", "frame-system", "fs_extra", - "futures 0.3.9", + "futures 0.3.10", "log", "node-executor", "node-primitives", @@ -5196,7 +5196,7 @@ dependencies = [ [[package]] name = "pallet-vesting" -version = "2.0.1" +version = "2.1.0" dependencies = [ "enumflags2", "frame-benchmarking", @@ -5229,9 +5229,9 @@ dependencies = [ [[package]] name = "parity-multiaddr" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180cd097078b337d2ba6400c6a67b181b38b611273cb1d8d12f3d8d5d8eaaacb" +checksum = "2f51a30667591b14f96068b2d12f1306d07a41ebd98239d194356d4d9707ac16" dependencies = [ "arrayref", "bs58", @@ -5606,9 +5606,9 @@ checksum = "c917123afa01924fc84bb20c4c03f004d9c38e5127e3c039bbf7f4b9c76a2f6b" [[package]] name = "pin-project-lite" -version = "0.2.0" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b063f57ec186e6140e2b8b6921e5f1bd89c7356dda5b33acc5401203ca6131c" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "pin-utils" @@ -5977,9 +5977,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c24fcd450d3fa2b592732565aa4f17a27a61c65ece4726353e000939b0edee34" +checksum = "18519b42a40024d661e1714153e9ad0c3de27cd495760ceb09710920f1098b1e" dependencies = [ "libc", "rand_chacha 0.3.0", @@ -6416,7 +6416,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "pin-project 0.4.27", "static_assertions", ] @@ -6461,7 +6461,7 @@ dependencies = [ "async-trait", "derive_more", "either", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "libp2p", "log", @@ -6489,7 +6489,7 @@ dependencies = [ name = "sc-basic-authorship" version = "0.8.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -6566,7 +6566,7 @@ dependencies = [ "atty", "chrono", "fdlimit", - "futures 0.3.9", + "futures 0.3.10", "hex", "libp2p", "log", @@ -6618,7 +6618,7 @@ version = "2.0.1" dependencies = [ "derive_more", "fnv", - "futures 0.3.9", + "futures 0.3.10", "hash-db", "kvdb", "kvdb-memorydb", @@ -6698,7 +6698,7 @@ name = "sc-consensus-aura" version = "0.8.1" dependencies = [ "derive_more", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "getrandom 0.2.1", "log", @@ -6739,7 +6739,7 @@ version = "0.8.1" dependencies = [ "derive_more", "fork-tree", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "log", "merlin", @@ -6792,7 +6792,7 @@ name = "sc-consensus-babe-rpc" version = "0.8.1" dependencies = [ "derive_more", - "futures 0.3.9", + "futures 0.3.10", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -6834,7 +6834,7 @@ version = "0.8.1" dependencies = [ "assert_matches", "derive_more", - "futures 0.3.9", + "futures 0.3.10", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -6870,7 +6870,7 @@ name = "sc-consensus-pow" version = "0.8.1" dependencies = [ "derive_more", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -6892,7 +6892,7 @@ dependencies = [ name = "sc-consensus-slots" version = "0.8.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -7022,7 +7022,7 @@ dependencies = [ "derive_more", "finality-grandpa", "fork-tree", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "log", "parity-scale-codec", @@ -7065,7 +7065,7 @@ version = "0.8.1" dependencies = [ "derive_more", "finality-grandpa", - "futures 0.3.9", + "futures 0.3.10", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7094,7 +7094,7 @@ name = "sc-informant" version = "0.8.1" dependencies = [ "ansi_term 0.12.1", - "futures 0.3.9", + "futures 0.3.10", "log", "parity-util-mem", "sc-client-api", @@ -7112,7 +7112,7 @@ version = "2.0.1" dependencies = [ "async-trait", "derive_more", - "futures 0.3.9", + "futures 0.3.10", "futures-util", "hex", "merlin", @@ -7159,7 +7159,7 @@ dependencies = [ "erased-serde", "fnv", "fork-tree", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "futures_codec", "hex", @@ -7209,7 +7209,7 @@ name = "sc-network-gossip" version = "0.8.1" dependencies = [ "async-std", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "libp2p", "log", @@ -7228,7 +7228,7 @@ name = "sc-network-test" version = "0.8.0" dependencies = [ "async-std", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "libp2p", "log", @@ -7256,7 +7256,7 @@ version = "2.0.1" dependencies = [ "bytes 0.5.6", "fnv", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "hyper 0.13.9", "hyper-rustls", @@ -7287,7 +7287,7 @@ dependencies = [ name = "sc-peerset" version = "2.0.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "libp2p", "log", "rand 0.7.3", @@ -7310,7 +7310,7 @@ version = "2.0.1" dependencies = [ "assert_matches", "futures 0.1.30", - "futures 0.3.9", + "futures 0.3.10", "hash-db", "jsonrpc-core", "jsonrpc-pubsub", @@ -7351,7 +7351,7 @@ name = "sc-rpc-api" version = "0.8.1" dependencies = [ "derive_more", - "futures 0.3.9", + "futures 0.3.10", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -7408,7 +7408,7 @@ dependencies = [ "directories 3.0.1", "exit-future", "futures 0.1.30", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "hash-db", "jsonrpc-core", @@ -7476,7 +7476,7 @@ version = "2.0.0" dependencies = [ "fdlimit", "futures 0.1.30", - "futures 0.3.9", + "futures 0.3.10", "hex-literal", "log", "parity-scale-codec", @@ -7543,7 +7543,7 @@ dependencies = [ name = "sc-telemetry" version = "2.0.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "libp2p", "log", @@ -7589,7 +7589,7 @@ dependencies = [ "assert_matches", "criterion", "derive_more", - "futures 0.3.9", + "futures 0.3.10", "linked-hash-map", "log", "parity-scale-codec", @@ -7612,7 +7612,7 @@ name = "sc-transaction-pool" version = "2.0.1" dependencies = [ "assert_matches", - "futures 0.3.9", + "futures 0.3.10", "futures-diagnose", "hex", "intervalier", @@ -7799,9 +7799,9 @@ checksum = "930c0acf610d3fdb5e2ab6213019aaa04e227ebe9547b0649ba599b16d788bd7" [[package]] name = "serde" -version = "1.0.119" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bdd36f49e35b61d49efd8aa7fc068fd295961fd2286d0b2ee9a4c7a14e99cc3" +checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" dependencies = [ "serde_derive", ] @@ -7818,9 +7818,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.119" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "552954ce79a059ddd5fd68c271592374bd15cab2274970380c000118aeffe1cd" +checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" dependencies = [ "proc-macro2", "quote", @@ -8047,7 +8047,7 @@ dependencies = [ "base64 0.12.3", "bytes 0.5.6", "flate2", - "futures 0.3.9", + "futures 0.3.10", "httparse", "log", "rand 0.7.3", @@ -8197,7 +8197,7 @@ dependencies = [ name = "sp-blockchain" version = "2.0.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "log", "lru", "parity-scale-codec", @@ -8222,7 +8222,7 @@ dependencies = [ name = "sp-consensus" version = "0.8.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "libp2p", "log", @@ -8316,7 +8316,7 @@ dependencies = [ "criterion", "dyn-clonable", "ed25519-dalek", - "futures 0.3.9", + "futures 0.3.10", "hash-db", "hash256-std-hasher", "hex", @@ -8413,7 +8413,7 @@ dependencies = [ name = "sp-io" version = "2.0.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "hash-db", "libsecp256k1", "log", @@ -8448,7 +8448,7 @@ version = "0.8.0" dependencies = [ "async-trait", "derive_more", - "futures 0.3.9", + "futures 0.3.10", "merlin", "parity-scale-codec", "parking_lot 0.11.1", @@ -8753,7 +8753,7 @@ name = "sp-transaction-pool" version = "2.0.1" dependencies = [ "derive_more", - "futures 0.3.9", + "futures 0.3.10", "log", "parity-scale-codec", "serde", @@ -8785,7 +8785,7 @@ dependencies = [ name = "sp-utils" version = "2.0.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "futures-core", "futures-timer 3.0.2", "lazy_static", @@ -8939,7 +8939,7 @@ dependencies = [ "console_error_panic_hook", "console_log", "futures 0.1.30", - "futures 0.3.9", + "futures 0.3.10", "futures-timer 3.0.2", "getrandom 0.2.1", "js-sys", @@ -8980,7 +8980,7 @@ version = "2.0.1" dependencies = [ "frame-support", "frame-system", - "futures 0.3.9", + "futures 0.3.10", "jsonrpc-client-transports", "jsonrpc-core", "parity-scale-codec", @@ -8995,7 +8995,7 @@ name = "substrate-frame-rpc-system" version = "2.0.1" dependencies = [ "frame-system-rpc-runtime-api", - "futures 0.3.9", + "futures 0.3.10", "jsonrpc-core", "jsonrpc-core-client", "jsonrpc-derive", @@ -9033,7 +9033,7 @@ name = "substrate-test-client" version = "2.0.1" dependencies = [ "futures 0.1.30", - "futures 0.3.9", + "futures 0.3.10", "hash-db", "hex", "parity-scale-codec", @@ -9102,7 +9102,7 @@ dependencies = [ name = "substrate-test-runtime-client" version = "2.0.0" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "parity-scale-codec", "sc-block-builder", "sc-client-api", @@ -9123,7 +9123,7 @@ name = "substrate-test-runtime-transaction-pool" version = "2.0.0" dependencies = [ "derive_more", - "futures 0.3.9", + "futures 0.3.10", "parity-scale-codec", "parking_lot 0.11.1", "sc-transaction-graph", @@ -9137,7 +9137,7 @@ dependencies = [ name = "substrate-test-utils" version = "2.0.1" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "sc-service", "substrate-test-utils-derive", "tokio 0.2.23", @@ -9654,7 +9654,7 @@ checksum = "9f47026cdc4080c07e49b37087de021820269d996f581aac150ef9e5583eefe3" dependencies = [ "cfg-if 1.0.0", "log", - "pin-project-lite 0.2.0", + "pin-project-lite 0.2.4", "tracing-attributes", "tracing-core", ] @@ -10148,7 +10148,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "js-sys", "parking_lot 0.11.1", "pin-utils", @@ -10483,7 +10483,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aeb8c4043cac71c3c299dff107171c220d179492350ea198e109a414981b83c" dependencies = [ - "futures 0.3.9", + "futures 0.3.10", "log", "nohash-hasher", "parking_lot 0.11.1", diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index d3cc0101e082b..d351aa9c25b14 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -81,7 +81,7 @@ pallet-treasury = { version = "2.0.0", default-features = false, path = "../../. pallet-utility = { version = "2.0.0", default-features = false, path = "../../../frame/utility" } pallet-transaction-payment = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment" } pallet-transaction-payment-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/transaction-payment/rpc/runtime-api/" } -pallet-vesting = { version = "2.0.0", default-features = false, path = "../../../frame/vesting" } +pallet-vesting = { version = "2.1.0", default-features = false, path = "../../../frame/vesting" } [build-dependencies] substrate-wasm-builder = { version = "3.0.0", path = "../../../utils/wasm-builder" } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 3e6452465831f..84fac46c74c1f 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -938,6 +938,7 @@ impl pallet_society::Config for Runtime { parameter_types! { pub const MinVestedTransfer: Balance = 100 * DOLLARS; + pub const MaxVestingSchedules: u32 = 20; } impl pallet_vesting::Config for Runtime { @@ -946,6 +947,7 @@ impl pallet_vesting::Config for Runtime { type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = pallet_vesting::weights::SubstrateWeight; + type MaxVestingSchedules = MaxVestingSchedules; } impl pallet_mmr::Config for Runtime { diff --git a/frame/vesting/Cargo.toml b/frame/vesting/Cargo.toml index a151219501559..cc85ea3490309 100644 --- a/frame/vesting/Cargo.toml +++ b/frame/vesting/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pallet-vesting" -version = "2.0.1" +version = "2.1.0" authors = ["Parity Technologies "] edition = "2018" license = "Apache-2.0" diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 5e20c863c51f3..0ff4f1321fd8f 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -38,9 +38,15 @@ //! //! ### Dispatchable Functions //! -//! - `vest` - Update the lock, reducing it in line with the amount "vested" so far. +//! - `vest` - Update the lock, reducing it in line with the amount "vested" so far for all vested +//! transfers //! - `vest_other` - Update the lock of another account, reducing it in line with the amount -//! "vested" so far. +//! "vested" so far for all vested transfers added to that account +//! - `vested_transfer` - Add a new vested transfer to the target account as long as they have not +//! already reached the maximum allowed vestings for an account. Otherwise an error +//! - `force_vested_transfer` - Add a new vested transfer to the target account from the source account +//! as long as they have not already reached the maximum allowed vestings for an account. +//! Otherwise an error. Origin must be root //! //! [`Call`]: ./enum.Call.html //! [`Config`]: ./trait.Config.html @@ -54,12 +60,13 @@ use sp_std::prelude::*; use sp_std::fmt::Debug; use codec::{Encode, Decode}; use sp_runtime::{DispatchResult, RuntimeDebug, traits::{ - StaticLookup, Zero, AtLeast32BitUnsigned, MaybeSerializeDeserialize, Convert + Saturating, StaticLookup, Zero, AtLeast32BitUnsigned, MaybeSerializeDeserialize, Convert }}; use frame_support::{decl_module, decl_event, decl_storage, decl_error, ensure}; use frame_support::traits::{ Currency, LockableCurrency, VestingSchedule, WithdrawReasons, LockIdentifier, ExistenceRequirement, Get, + {GetPalletVersion, PalletVersion}, }; use frame_system::{ensure_signed, ensure_root}; pub use weights::WeightInfo; @@ -82,6 +89,9 @@ pub trait Config: frame_system::Config { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + + /// Maximum number of vesting schedules allowed per account + type MaxVestingSchedules: Get; } const VESTING_ID: LockIdentifier = *b"vesting "; @@ -124,7 +134,7 @@ decl_storage! { /// Information regarding the vesting of a given account. pub Vesting get(fn vesting): map hasher(blake2_128_concat) T::AccountId - => Option, T::BlockNumber>>; + => Vec, T::BlockNumber>>; } add_extra_genesis { config(vesting): Vec<(T::AccountId, T::BlockNumber, T::BlockNumber, BalanceOf)>; @@ -138,18 +148,32 @@ decl_storage! { for &(ref who, begin, length, liquid) in config.vesting.iter() { let balance = T::Currency::free_balance(who); assert!(!balance.is_zero(), "Currencies must be init'd before vesting"); - // Total genesis `balance` minus `liquid` equals funds locked for vesting - let locked = balance.saturating_sub(liquid); + + // Compute unlocked balance as free balance minus sum of all locked balances of + // existing vesting schedules + let mut vesting_schedules = Vesting::::get(who); + let locked_so_far: BalanceOf = vesting_schedules.iter().fold(Zero::zero(), + | sum, vesting | sum.saturating_add(vesting.locked)); + let unlocked_balance = balance.saturating_sub(locked_so_far); + + assert!(unlocked_balance > liquid, + "Must have more balance not yet locked by other vesting schedules than requested liquidity"); + let locked = unlocked_balance.saturating_sub(liquid); + let length_as_balance = T::BlockNumberToBalance::convert(length); let per_block = locked / length_as_balance.max(sp_runtime::traits::One::one()); - Vesting::::insert(who, VestingInfo { + vesting_schedules.push(VestingInfo { locked: locked, per_block: per_block, starting_block: begin }); + Vesting::::insert(who, vesting_schedules); + + let new_balance_to_lock = locked_so_far.saturating_add(locked); + let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE; - T::Currency::set_lock(VESTING_ID, who, locked, reasons); + T::Currency::set_lock(VESTING_ID, who, new_balance_to_lock, reasons); } }) } @@ -172,9 +196,11 @@ decl_error! { /// The account given is not vesting. NotVesting, /// An existing vesting schedule already exists for this account that cannot be clobbered. - ExistingVestingSchedule, + TooManyVestingSchedules, /// Amount being transferred is too low to create a vesting schedule. AmountLow, + /// Vesting was out of range or had already begun vesting + InvalidConsolidation, } } @@ -186,6 +212,24 @@ decl_module! { /// The minimum amount to be transferred to create a new vesting schedule. const MinVestedTransfer: BalanceOf = T::MinVestedTransfer::get(); + fn on_runtime_upgrade() -> frame_support::weights::Weight { + let maybe_storage_version = ::storage_version(); + match maybe_storage_version { + Some(storage_version) if storage_version < PalletVersion::new(2, 1, 0) => { + Vesting::::translate::, T::BlockNumber>>, _>(|_: T::AccountId, value: Option, T::BlockNumber>>| { + if let Some(vesting) = value { + return Some(vec![vesting]) + } + + None + }); + + frame_support::weights::Weight::max_value() + } + _ => 0 + } + } + fn deposit_event() = default; /// Unlock any vested funds of the sender account. @@ -244,7 +288,7 @@ decl_module! { /// /// # /// - `O(1)`. - /// - DbWeight: 3 Reads, 3 Writes + /// - DbWeight: 6 Reads, 5 Writes /// - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account] /// - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account] /// # @@ -258,7 +302,8 @@ decl_module! { ensure!(schedule.locked >= T::MinVestedTransfer::get(), Error::::AmountLow); let who = T::Lookup::lookup(target)?; - ensure!(!Vesting::::contains_key(&who), Error::::ExistingVestingSchedule); + let vesting_schedules = Vesting::::get(&who); + ensure!((vesting_schedules.len() as u32) < T::MaxVestingSchedules::get(), Error::::TooManyVestingSchedules); T::Currency::transfer(&transactor, &who, schedule.locked, ExistenceRequirement::AllowDeath)?; @@ -297,7 +342,8 @@ decl_module! { let target = T::Lookup::lookup(target)?; let source = T::Lookup::lookup(source)?; - ensure!(!Vesting::::contains_key(&target), Error::::ExistingVestingSchedule); + let vesting_schedules = Vesting::::get(&target); + ensure!((vesting_schedules.len() as u32) < T::MaxVestingSchedules::get(), Error::::TooManyVestingSchedules); T::Currency::transfer(&source, &target, schedule.locked, ExistenceRequirement::AllowDeath)?; @@ -306,16 +352,68 @@ decl_module! { Ok(()) } + + /// Consolidate 2 vestings + /// + /// The dispatch origin for this call must be _Signed_ and the sender must have funds still + /// locked under this module. + /// + /// We do not record when any vesting has has had any of its funds unlocked, only when + /// any of the vest or vested_transfer extrinsics are dispatched therefor it is invalid + /// to attempt to consolidate a vesting that has already begun vesting (starting_block > + /// now) + /// + /// If the starting blocks of each vesting are different the consolidated vesting will start + /// at the later of the two. + /// + /// # + /// - `O(1)`. + /// - DbWeight: 5 Reads, 4 Writes + /// - Reads: Vesting Storage, Balances Locks, [Sender Account] + /// - Writes: Vesting Storage, Balances Locks, [Sender Account] + /// # + #[weight = T::WeightInfo::vest_other_locked(MaxLocksOf::::get()) + .max(T::WeightInfo::vest_other_unlocked(MaxLocksOf::::get())) + ] + fn consolidate_vestings(origin, first: u32, second: u32) -> DispatchResult { + let who = ensure_signed(origin)?; + let mut vesting_schedules = Vesting::::get(&who); + ensure!(first < second, Error::::InvalidConsolidation); + ensure!(vesting_schedules.len() as u32 >= first, Error::::InvalidConsolidation); + ensure!(vesting_schedules.len() as u32 >= second, Error::::InvalidConsolidation); + let now = >::block_number(); + let first_vesting = vesting_schedules.get(first as usize) + .expect("Vecs cant be sparse and we bounds checked above"); + ensure!(first_vesting.starting_block > now, Error::::InvalidConsolidation); + let second_vesting = vesting_schedules.get(second as usize) + .expect("Vecs cant be sparse and we bounds checked above"); + ensure!(second_vesting.starting_block > now, Error::::InvalidConsolidation); + let consolidated_vesting = VestingInfo { + locked: first_vesting.locked.saturating_add(second_vesting.locked), + starting_block: sp_std::cmp::max(first_vesting.starting_block, + second_vesting.starting_block), + per_block: first_vesting.per_block.saturating_add(second_vesting.per_block) + }; + vesting_schedules.remove(first as usize); + let second = second - 1; + vesting_schedules.remove(second as usize); + vesting_schedules.push(consolidated_vesting); + Vesting::::insert(who.clone(), vesting_schedules); + + Self::update_lock(who) + } } } impl Module { - /// (Re)set or remove the module's currency lock on `who`'s account in accordance with their - /// current unvested amount. + /// (Re)set or remove the module's currency lock on `who`'s account in accordance with the sum + /// of current unvested amounts in the vesting schedules fn update_lock(who: T::AccountId) -> DispatchResult { - let vesting = Self::vesting(&who).ok_or(Error::::NotVesting)?; + let vesting_schedules = Self::vesting(&who); + ensure!(vesting_schedules.len() != 0, Error::::NotVesting); + let now = >::block_number(); - let locked_now = vesting.locked_at::(now); + let locked_now: BalanceOf = vesting_schedules.iter().fold(Zero::zero(), |sum, vesting| sum.saturating_add(vesting.locked_at::(now))); if locked_now.is_zero() { T::Currency::remove_lock(VESTING_ID, &who); @@ -324,6 +422,10 @@ impl Module { } else { let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE; T::Currency::set_lock(VESTING_ID, &who, locked_now, reasons); + let remaining_schedules: Vec, T::BlockNumber>> = vesting_schedules.into_iter().filter(|vesting| vesting.locked_at::(now) != Zero::zero()).collect(); + + Vesting::::insert(&who, remaining_schedules); + Self::deposit_event(RawEvent::VestingUpdated(who, locked_now)); } Ok(()) @@ -338,13 +440,16 @@ impl VestingSchedule for Module where /// Get the amount that is currently being vested and cannot be transferred out of this account. fn vesting_balance(who: &T::AccountId) -> Option> { - if let Some(v) = Self::vesting(who) { - let now = >::block_number(); - let locked_now = v.locked_at::(now); - Some(T::Currency::free_balance(who).min(locked_now)) - } else { - None + let now = >::block_number(); + let vesting_schedules = Self::vesting(who); + if vesting_schedules.len() == 0 { + return None } + + let total_vested: BalanceOf = vesting_schedules.iter().fold(Zero::zero(), + |sum, vesting| sum.saturating_add(vesting.locked_at::(now))); + + return Some(T::Currency::free_balance(who).min(total_vested)) } /// Adds a vesting schedule to a given account. @@ -364,15 +469,18 @@ impl VestingSchedule for Module where starting_block: T::BlockNumber ) -> DispatchResult { if locked.is_zero() { return Ok(()) } - if Vesting::::contains_key(who) { - Err(Error::::ExistingVestingSchedule)? + let mut vesting_schedules = Vesting::::get(who); + if vesting_schedules.len() as u32 >= T::MaxVestingSchedules::get() { + Err(Error::::TooManyVestingSchedules)? } let vesting_schedule = VestingInfo { locked, per_block, starting_block }; - Vesting::::insert(who, vesting_schedule); + vesting_schedules.push(vesting_schedule); + Vesting::::insert(who, vesting_schedules); + // it can't fail, but even if somehow it did, we don't really care. let _ = Self::update_lock(who.clone()); Ok(()) @@ -448,6 +556,7 @@ mod tests { type WeightInfo = (); } parameter_types! { + pub const MaxVestingSchedules: u32 = 2; pub const MinVestedTransfer: u64 = 256 * 2; pub static ExistentialDeposit: u64 = 0; } @@ -457,6 +566,7 @@ mod tests { type BlockNumberToBalance = Identity; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = (); + type MaxVestingSchedules = MaxVestingSchedules; } type System = frame_system::Module; type Balances = pallet_balances::Module; @@ -487,14 +597,24 @@ mod tests { (2, 20 * self.existential_deposit), (3, 30 * self.existential_deposit), (4, 40 * self.existential_deposit), - (12, 10 * self.existential_deposit) + (12, 10 * self.existential_deposit), + // Accounts with multiple vestings + (100, 20 * self.existential_deposit), + (101, 20 * self.existential_deposit), + (200, 750 * self.existential_deposit) ], }.assimilate_storage(&mut t).unwrap(); GenesisConfig:: { vesting: vec![ (1, 0, 10, 5 * self.existential_deposit), (2, 10, 20, 0), - (12, 10, 20, 5 * self.existential_deposit) + (12, 10, 20, 5 * self.existential_deposit), + (100, 0, 10, 10), + (100, 0, 10, 0), + (101, 0, 10, 10), + (101, 20, 5, 0), + (200, 10, 10, 250), + (200, 15, 10, 0) ], }.assimilate_storage(&mut t).unwrap(); let mut ext = sp_io::TestExternalities::new(t); @@ -503,6 +623,64 @@ mod tests { } } + #[test] + fn consolidate_vestings_invalid_vestings() { + ExtBuilder::default() + .existential_deposit(1) + .build() + .execute_with(|| { + let vestings = Vesting::vesting(&200); + assert_eq!(vestings.len(), 2); // Account has 2 vesting schedules + + // first vesting must come before second vesting + assert_noop!(Vesting::consolidate_vestings(Some(200).into(), 1, 0), + Error::::InvalidConsolidation); + // vestings must be in range + assert_noop!(Vesting::consolidate_vestings(Some(200).into(), 1, 3), + Error::::InvalidConsolidation); + + // Start first vesting + System::set_block_number(10); + assert_eq!(System::block_number(), 10); + // cannot consolidate when vesting has started + assert_noop!(Vesting::consolidate_vestings(Some(200).into(), 0, 1), + Error::::InvalidConsolidation); + }) + } + + #[test] + fn consolidate_vestings_valid_vestings() { + ExtBuilder::default() + .existential_deposit(1) + .build() + .execute_with(|| { + let vestings = Vesting::vesting(&200); + assert_eq!(vestings.len(), 2); // Account has 2 vesting schedules + + // Before consolidation + // One vesting starts at block 10 releasing 50 per block up to a max of 500 + // The other starts at block 15 releasing 25 per block up to a max of 250 + assert_ok!(Vesting::consolidate_vestings(Some(200).into(), 0, 1)); + let vestings = Vesting::vesting(&200); + assert_eq!(vestings.len(), 1); // Account should now have one vesting + + // Vesting no longer starts at block 10 + System::set_block_number(10); + assert_eq!(System::block_number(), 10); + assert_eq!(Vesting::vesting_balance(&200), Some(75 * 10)); + + System::set_block_number(16); + assert_eq!(System::block_number(), 16); + // The consolidated vesting should have vested 1 block at the consolidated 75 per + // block + assert_eq!(Vesting::vesting_balance(&200), Some(75 * 9)); + + System::set_block_number(25); + // The consolidated vesting should have fully vested + assert_eq!(Vesting::vesting_balance(&200), Some(0)); + }) + } + #[test] fn check_vesting_status() { ExtBuilder::default() @@ -530,9 +708,9 @@ mod tests { per_block: 64, // Vesting over 20 blocks starting_block: 10, }; - assert_eq!(Vesting::vesting(&1), Some(user1_vesting_schedule)); // Account 1 has a vesting schedule - assert_eq!(Vesting::vesting(&2), Some(user2_vesting_schedule)); // Account 2 has a vesting schedule - assert_eq!(Vesting::vesting(&12), Some(user12_vesting_schedule)); // Account 12 has a vesting schedule + assert_eq!(Vesting::vesting(&1).last(), Some(&user1_vesting_schedule)); // Account 1 has a vesting schedule + assert_eq!(Vesting::vesting(&2).last(), Some(&user2_vesting_schedule)); // Account 2 has a vesting schedule + assert_eq!(Vesting::vesting(&12).last(), Some(&user12_vesting_schedule)); // Account 12 has a vesting schedule // Account 1 has only 128 units vested from their illiquid 256 * 5 units at block 1 assert_eq!(Vesting::vesting_balance(&1), Some(128 * 9)); @@ -561,6 +739,69 @@ mod tests { }); } + #[test] + fn check_multiple_vesting_schedules_with_same_per_block_and_amount_locked() { + ExtBuilder::default() + .existential_deposit(1) + .build() + .execute_with(|| { + let vestings = Vesting::vesting(&100); + assert_eq!(vestings.len(), 2); // Account has 2 vesting schedules + + // Vesting schedules are the same: unlocking 1 per block up to a total of 10 + assert_eq!(Vesting::vesting_balance(&100), Some(2 * 9)); + + System::set_block_number(5); + assert_eq!(System::block_number(), 5); + assert_eq!(Vesting::vesting_balance(&100), Some(2 * 5)); + + System::set_block_number(10); + assert_eq!(System::block_number(), 10); + + // Account has fully vested by block 10 + assert_eq!(Vesting::vesting_balance(&100), Some(0)); + }); + } + + #[test] + fn check_multiple_disjoint_vesting_schedules() { + ExtBuilder::default() + .existential_deposit(1) + .build() + .execute_with(|| { + let vestings = Vesting::vesting(&101); + assert_eq!(vestings.len(), 2); // Account has 2 vesting schedules + + // Vesting schedule 1 starts at block 0 unlocking 1 per block up to a total of 10 + // Vesting schedule 2 starts at block 20 unlocking 2 per block up to a total of 5 + assert_eq!(Vesting::vesting_balance(&101), Some(9 + 10)); + + System::set_block_number(10); + assert_eq!(System::block_number(), 10); + assert_eq!(Vesting::vesting_balance(&101), Some(10)); + + // vest prunes finished schedule + assert_ok!(Vesting::vest(Some(101).into())); + let vestings = Vesting::vesting(&101); + assert_eq!(vestings.len(), 1); // Account now only has 1 vesting schedule + + // first block of second schedule unlocks 2 + System::set_block_number(21); + assert_eq!(System::block_number(), 21); + assert_eq!(Vesting::vesting_balance(&101), Some(10 - 2)); + + // Account has fully vested by block 25 + System::set_block_number(25); + assert_eq!(System::block_number(), 25); + assert_eq!(Vesting::vesting_balance(&101), Some(0)); + // + // vest removes last schedule + assert_ok!(Vesting::vest(Some(101).into())); + let vestings = Vesting::vesting(&101); + assert_eq!(vestings.len(), 0); // Account now only has 1 vesting schedule + }); + } + #[test] fn unvested_balance_should_not_transfer() { ExtBuilder::default() @@ -653,7 +894,7 @@ mod tests { per_block: 64, // Vesting over 20 blocks starting_block: 10, }; - assert_eq!(Vesting::vesting(&12), Some(user12_vesting_schedule)); + assert_eq!(Vesting::vesting(&12).last(), Some(&user12_vesting_schedule)); // Account 12 can still send liquid funds assert_ok!(Balances::transfer(Some(12).into(), 3, 256 * 5)); @@ -671,7 +912,7 @@ mod tests { assert_eq!(user3_free_balance, 256 * 30); assert_eq!(user4_free_balance, 256 * 40); // Account 4 should not have any vesting yet. - assert_eq!(Vesting::vesting(&4), None); + assert_eq!(Vesting::vesting(&4).last(), None); // Make the schedule for the new transfer. let new_vesting_schedule = VestingInfo { locked: 256 * 5, @@ -680,7 +921,7 @@ mod tests { }; assert_ok!(Vesting::vested_transfer(Some(3).into(), 4, new_vesting_schedule)); // Now account 4 should have vesting. - assert_eq!(Vesting::vesting(&4), Some(new_vesting_schedule)); + assert_eq!(Vesting::vesting(&4).last(), Some(&new_vesting_schedule)); // Ensure the transfer happened correctly. let user3_free_balance_updated = Balances::free_balance(&3); assert_eq!(user3_free_balance_updated, 256 * 25); @@ -719,17 +960,25 @@ mod tests { per_block: 256, // Vesting over 20 blocks starting_block: 10, }; - assert_eq!(Vesting::vesting(&2), Some(user2_vesting_schedule)); + assert_eq!(Vesting::vesting(&2).last(), Some(&user2_vesting_schedule)); - // The vesting schedule we will try to create, fails due to pre-existence of schedule. + // The first vesting schedule we will try to create is ok as we can have at most + // 2 vesting schedules per account let new_vesting_schedule = VestingInfo { locked: 256 * 5, per_block: 64, // Vesting over 20 blocks starting_block: 10, }; + Vesting::vested_transfer(Some(4).into(), 2, new_vesting_schedule) + .expect("Should be happy to add second vesting schedule"); + assert_eq!(Vesting::vesting(&2).last(), Some(&new_vesting_schedule)); + assert_eq!(Vesting::vesting(&2).len(), 2); + + // The second vesting schedule we will try to create should fail as we can have at + // most 2 vesting schedules per account assert_noop!( Vesting::vested_transfer(Some(4).into(), 2, new_vesting_schedule), - Error::::ExistingVestingSchedule, + Error::::TooManyVestingSchedules, ); // Fails due to too low transfer amount. @@ -760,7 +1009,7 @@ mod tests { assert_eq!(user3_free_balance, 256 * 30); assert_eq!(user4_free_balance, 256 * 40); // Account 4 should not have any vesting yet. - assert_eq!(Vesting::vesting(&4), None); + assert_eq!(Vesting::vesting(&4).last(), None); // Make the schedule for the new transfer. let new_vesting_schedule = VestingInfo { locked: 256 * 5, @@ -770,7 +1019,7 @@ mod tests { assert_noop!(Vesting::force_vested_transfer(Some(4).into(), 3, 4, new_vesting_schedule), BadOrigin); assert_ok!(Vesting::force_vested_transfer(RawOrigin::Root.into(), 3, 4, new_vesting_schedule)); // Now account 4 should have vesting. - assert_eq!(Vesting::vesting(&4), Some(new_vesting_schedule)); + assert_eq!(Vesting::vesting(&4).last(), Some(&new_vesting_schedule)); // Ensure the transfer happened correctly. let user3_free_balance_updated = Balances::free_balance(&3); assert_eq!(user3_free_balance_updated, 256 * 25); @@ -809,17 +1058,21 @@ mod tests { per_block: 256, // Vesting over 20 blocks starting_block: 10, }; - assert_eq!(Vesting::vesting(&2), Some(user2_vesting_schedule)); + assert_eq!(Vesting::vesting(&2).last(), Some(&user2_vesting_schedule)); - // The vesting schedule we will try to create, fails due to pre-existence of schedule. + // The first vesting schedule we will try to create will be ok, but the second fails + // as we can only have a maximum of 2 vesting schedules let new_vesting_schedule = VestingInfo { locked: 256 * 5, per_block: 64, // Vesting over 20 blocks starting_block: 10, }; + Vesting::force_vested_transfer(RawOrigin::Root.into(), 4, 2, new_vesting_schedule) + .expect("Should be happy to add a second vesting schedules"); + assert_noop!( Vesting::force_vested_transfer(RawOrigin::Root.into(), 4, 2, new_vesting_schedule), - Error::::ExistingVestingSchedule, + Error::::TooManyVestingSchedules, ); // Fails due to too low transfer amount. diff --git a/frame/vesting/src/weights.rs b/frame/vesting/src/weights.rs index f4a1ee3669101..751169f85f677 100644 --- a/frame/vesting/src/weights.rs +++ b/frame/vesting/src/weights.rs @@ -15,13 +15,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -//! Weights for pallet_vesting +//! Autogenerated weights for pallet_vesting +//! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0 -//! DATE: 2020-10-27, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: [] +//! DATE: 2020-12-10, STEPS: [50, ], REPEAT: 20, LOW RANGE: [], HIGH RANGE: [] //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: -// target/release/substrate +// ./target/debug/substrate // benchmark // --chain=dev // --steps=50 @@ -49,100 +50,93 @@ pub trait WeightInfo { fn vest_other_unlocked(l: u32, ) -> Weight; fn vested_transfer(l: u32, ) -> Weight; fn force_vested_transfer(l: u32, ) -> Weight; - } /// Weights for pallet_vesting using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn vest_locked(l: u32, ) -> Weight { - (57_472_000 as Weight) - .saturating_add((155_000 as Weight).saturating_mul(l as Weight)) + (2_481_474_000 as Weight) + // Standard Error: 33_000 + .saturating_add((1_414_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - + .saturating_add(T::DbWeight::get().writes(2 as Weight)) } - fn vest_unlocked(l: u32, ) -> Weight { - (61_681_000 as Weight) - .saturating_add((138_000 as Weight).saturating_mul(l as Weight)) + fn vest_unlocked(_l: u32, ) -> Weight { + (2_423_291_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } fn vest_other_locked(l: u32, ) -> Weight { - (56_910_000 as Weight) - .saturating_add((160_000 as Weight).saturating_mul(l as Weight)) + (2_480_934_000 as Weight) + // Standard Error: 73_000 + .saturating_add((841_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn vest_other_unlocked(l: u32, ) -> Weight { - (61_319_000 as Weight) - .saturating_add((144_000 as Weight).saturating_mul(l as Weight)) + (2_343_438_000 as Weight) + // Standard Error: 134_000 + .saturating_add((1_111_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } fn vested_transfer(l: u32, ) -> Weight { - (124_996_000 as Weight) - .saturating_add((209_000 as Weight).saturating_mul(l as Weight)) + (5_435_085_000 as Weight) + // Standard Error: 489_000 + .saturating_add((1_016_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } fn force_vested_transfer(l: u32, ) -> Weight { - (123_911_000 as Weight) - .saturating_add((213_000 as Weight).saturating_mul(l as Weight)) + (5_275_174_000 as Weight) + // Standard Error: 439_000 + .saturating_add((3_415_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) - } - } // For backwards compatibility and tests impl WeightInfo for () { fn vest_locked(l: u32, ) -> Weight { - (57_472_000 as Weight) - .saturating_add((155_000 as Weight).saturating_mul(l as Weight)) + (2_481_474_000 as Weight) + // Standard Error: 33_000 + .saturating_add((1_414_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - + .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } - fn vest_unlocked(l: u32, ) -> Weight { - (61_681_000 as Weight) - .saturating_add((138_000 as Weight).saturating_mul(l as Weight)) + fn vest_unlocked(_l: u32, ) -> Weight { + (2_423_291_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } fn vest_other_locked(l: u32, ) -> Weight { - (56_910_000 as Weight) - .saturating_add((160_000 as Weight).saturating_mul(l as Weight)) + (2_480_934_000 as Weight) + // Standard Error: 73_000 + .saturating_add((841_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn vest_other_unlocked(l: u32, ) -> Weight { - (61_319_000 as Weight) - .saturating_add((144_000 as Weight).saturating_mul(l as Weight)) + (2_343_438_000 as Weight) + // Standard Error: 134_000 + .saturating_add((1_111_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } fn vested_transfer(l: u32, ) -> Weight { - (124_996_000 as Weight) - .saturating_add((209_000 as Weight).saturating_mul(l as Weight)) + (5_435_085_000 as Weight) + // Standard Error: 489_000 + .saturating_add((1_016_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } fn force_vested_transfer(l: u32, ) -> Weight { - (123_911_000 as Weight) - .saturating_add((213_000 as Weight).saturating_mul(l as Weight)) + (5_275_174_000 as Weight) + // Standard Error: 439_000 + .saturating_add((3_415_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - } - }