diff --git a/Cargo.lock b/Cargo.lock index 6d9637088a..e20719b891 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -290,9 +290,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.20" +version = "0.6.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" +checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" dependencies = [ "anstyle", "anstyle-parse", @@ -1175,7 +1175,7 @@ dependencies = [ "polling 3.11.0", "rustix 1.1.2", "slab", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -1270,7 +1270,7 @@ dependencies = [ "rustix 1.1.2", "signal-hook-registry", "slab", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -1946,9 +1946,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.23.2" +version = "1.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3995eaeebcdf32f91f980d360f78732ddc061097ab4e39991ae7a6ace9194677" +checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4" [[package]] name = "byteorder" @@ -2025,9 +2025,9 @@ checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "cc" -version = "1.2.39" +version = "1.2.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1354349954c6fc9cb0deab020f27f783cf0b604e8bb754dc4658ecf0d29c35f" +checksum = "e1d05d92f4b1fd76aad469d46cdd858ca761576082cd37df81416691e50199fb" dependencies = [ "find-msvc-tools", "jobserver", @@ -2365,9 +2365,9 @@ checksum = "2f421161cb492475f1661ddc9815a745a1c894592070661180fdec3d4872e9c3" [[package]] name = "const_format" -version = "0.2.34" +version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126f97965c8ad46d6d9163268ff28432e8f6a1196a55578867832e3049df63dd" +checksum = "7faa7469a93a566e9ccc1c73fe783b4a65c274c5ace346038dca9c39fe0030ad" dependencies = [ "const_format_proc_macros", ] @@ -2761,7 +2761,7 @@ dependencies = [ "cumulus-primitives-core", "futures", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-overseer", @@ -2789,7 +2789,7 @@ dependencies = [ "cumulus-relay-chain-interface", "futures", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-node-subsystem-util", @@ -2878,7 +2878,7 @@ dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", "futures", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-consensus", "sp-api", "sp-block-builder", @@ -2901,7 +2901,7 @@ dependencies = [ "futures", "futures-timer", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "polkadot-node-primitives", "polkadot-node-subsystem", "polkadot-parachain-primitives", @@ -3610,7 +3610,7 @@ dependencies = [ "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core 0.9.11", + "parking_lot_core 0.9.12", ] [[package]] @@ -4158,7 +4158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -4489,7 +4489,7 @@ dependencies = [ "log", "parity-db", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-client-db", "smallvec", @@ -4514,7 +4514,7 @@ dependencies = [ "futures", "futures-timer", "log", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-utils", "sp-api", @@ -4678,15 +4678,15 @@ dependencies = [ "log", "num-traits", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "scale-info", ] [[package]] name = "find-msvc-tools" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ced73b1dacfc750a6db6c0a0c3a3853c8b41997e2e2c563dc90804ae6867959" +checksum = "0399f9d26e5191ce32c498bebd31e7a3ceabc2745f0ac54af3f335126c3f24b3" [[package]] name = "fixed-hash" @@ -5368,7 +5368,7 @@ checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot 0.12.4", + "parking_lot 0.12.5", ] [[package]] @@ -5594,7 +5594,7 @@ dependencies = [ "futures-timer", "no-std-compat", "nonzero_ext", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "portable-atomic", "quanta", "rand 0.8.5", @@ -5867,7 +5867,7 @@ dependencies = [ "ipconfig", "lru-cache", "once_cell", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "resolv-conf", "smallvec", @@ -5888,7 +5888,7 @@ dependencies = [ "ipconfig", "moka", "once_cell", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.9.2", "resolv-conf", "smallvec", @@ -6118,7 +6118,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.62.1", + "windows-core 0.62.2", ] [[package]] @@ -6646,7 +6646,7 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "jsonrpsee-types", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "rand 0.8.5", "rustc-hash 2.1.1", @@ -6788,7 +6788,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf7a85fe66f9ff9cd74e169fdd2c94c6e1e74c412c99a73b4df3200b5d3760b2" dependencies = [ "kvdb", - "parking_lot 0.12.4", + "parking_lot 0.12.5", ] [[package]] @@ -6799,7 +6799,7 @@ checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" dependencies = [ "kvdb", "num_cpus", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "regex", "rocksdb", "smallvec", @@ -6927,7 +6927,7 @@ dependencies = [ "multihash 0.19.3", "multistream-select", "once_cell", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "quick-protobuf", "rand 0.8.5", @@ -6951,7 +6951,7 @@ dependencies = [ "hickory-resolver 0.24.4", "libp2p-core", "libp2p-identity", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "smallvec", "tracing", ] @@ -7122,7 +7122,7 @@ dependencies = [ "libp2p-core", "libp2p-identity", "libp2p-tls", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "quinn", "rand 0.8.5", "ring 0.17.14", @@ -7252,7 +7252,7 @@ dependencies = [ "futures-rustls", "libp2p-core", "libp2p-identity", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project-lite", "rw-stream-sink", "soketto 0.8.1", @@ -7285,7 +7285,7 @@ checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" dependencies = [ "bitflags 2.9.4", "libc", - "redox_syscall 0.5.17", + "redox_syscall 0.5.18", ] [[package]] @@ -7468,7 +7468,7 @@ dependencies = [ "multiaddr 0.17.1", "multihash 0.17.0", "network-interface", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "prost 0.13.5", "prost-build", @@ -7497,11 +7497,10 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" dependencies = [ - "autocfg", "scopeguard", ] @@ -7779,7 +7778,7 @@ dependencies = [ "hashlink 0.8.4", "lioness", "log", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "rand_chacha 0.3.1", "rand_distr", @@ -7858,7 +7857,7 @@ dependencies = [ "crossbeam-epoch", "crossbeam-utils", "equivalent", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "portable-atomic", "rustc_version 0.4.1", "smallvec", @@ -10684,6 +10683,9 @@ dependencies = [ "subtensor-runtime-common", "subtensor-swap-interface", "tle", + "tracing", + "tracing-log", + "tracing-subscriber 0.3.20", "w3f-bls 0.1.3", ] @@ -11142,7 +11144,7 @@ dependencies = [ "log", "lz4", "memmap2 0.5.10", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "siphasher 0.3.11", "snap", @@ -11203,12 +11205,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", - "parking_lot_core 0.9.11", + "parking_lot_core 0.9.12", ] [[package]] @@ -11227,15 +11229,15 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.11" +version = "0.9.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.17", + "redox_syscall 0.5.18", "smallvec", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -11305,20 +11307,19 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "pest" -version = "2.8.2" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e0a3a33733faeaf8651dfee72dd0f388f0c8e5ad496a3478fa5a922f49cfa8" +checksum = "989e7521a040efde50c3ab6bbadafbe15ab6dc042686926be59ac35d74607df4" dependencies = [ "memchr", - "thiserror 2.0.17", "ucd-trie", ] [[package]] name = "pest_derive" -version = "2.8.2" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc58706f770acb1dbd0973e6530a3cff4746fb721207feb3a8a6064cd0b6c663" +checksum = "187da9a3030dbafabbbfb20cb323b976dc7b7ce91fcd84f2f74d6e31d378e2de" dependencies = [ "pest", "pest_generator", @@ -11326,9 +11327,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.8.2" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d4f36811dfe07f7b8573462465d5cb8965fffc2e71ae377a33aecf14c2c9a2f" +checksum = "49b401d98f5757ebe97a26085998d6c0eecec4995cad6ab7fc30ffdf4b052843" dependencies = [ "pest", "pest_meta", @@ -11339,9 +11340,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.8.2" +version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42919b05089acbd0a5dcd5405fb304d17d1053847b81163d09c4ad18ce8e8420" +checksum = "72f27a2cfee9f9039c4d86faa5af122a0ac3851441a34865b8a043b46be0065a" dependencies = [ "pest", "sha2 0.10.9", @@ -11641,7 +11642,7 @@ dependencies = [ "fatality", "futures", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "polkadot-node-metrics", "polkadot-node-network-protocol", "polkadot-node-subsystem", @@ -12096,7 +12097,7 @@ dependencies = [ "kvdb", "parity-db", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "polkadot-erasure-coding", "polkadot-node-metrics", "polkadot-node-network-protocol", @@ -12623,7 +12624,7 @@ dependencies = [ "pallet-transaction-payment-rpc-runtime-api", "parity-db", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "polkadot-approval-distribution", "polkadot-availability-bitfield-distribution", "polkadot-availability-distribution", @@ -12939,7 +12940,7 @@ dependencies = [ "hermit-abi 0.5.2", "pin-project-lite", "rustix 1.1.2", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -13234,7 +13235,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "thiserror 1.0.69", ] @@ -13246,7 +13247,7 @@ checksum = "504ee9ff529add891127c4827eb481bd69dc0ebc72e9a682e187db4caa60c3ca" dependencies = [ "dtoa", "itoa", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "prometheus-client-derive-encode", ] @@ -13358,9 +13359,9 @@ dependencies = [ [[package]] name = "psm" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e944464ec8536cd1beb0bbfd96987eb5e3b72f2ecdafdc5c769a37f1fa2ae1f" +checksum = "e66fcd288453b748497d8fb18bccc83a16b0518e3906d4b8df0a8d42d93dbb1c" dependencies = [ "cc", ] @@ -13632,9 +13633,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.17" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ "bitflags 2.9.4", ] @@ -14136,7 +14137,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.11.0", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -14232,9 +14233,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "rusty-fork" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +checksum = "cc6bf79ff24e648f6da1f8d1f011e9cac26491b619e6b9280f2b47f1774e6ee2" dependencies = [ "fnv", "quick-error", @@ -14493,7 +14494,7 @@ dependencies = [ "futures", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-executor", "sc-transaction-pool-api", "sc-utils", @@ -14523,7 +14524,7 @@ dependencies = [ "log", "parity-db", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-state-db", "schnellru", @@ -14547,7 +14548,7 @@ dependencies = [ "futures", "log", "mockall", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-network-types", "sc-utils", @@ -14603,7 +14604,7 @@ dependencies = [ "num-rational", "num-traits", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-consensus", "sc-consensus-epochs", @@ -14659,7 +14660,7 @@ dependencies = [ "futures", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-consensus", "sc-network", @@ -14691,7 +14692,7 @@ dependencies = [ "jsonrpsee", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-consensus-beefy", "sc-rpc", "serde", @@ -14730,7 +14731,7 @@ dependencies = [ "futures-timer", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "sc-block-builder", "sc-chain-spec", @@ -14843,7 +14844,7 @@ version = "0.43.0" source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234#7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234" dependencies = [ "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-executor-common", "sc-executor-polkavm", "sc-executor-wasmtime", @@ -14891,7 +14892,7 @@ source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96 dependencies = [ "anyhow", "log", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rustix 0.36.17", "sc-allocator", "sc-executor-common", @@ -14922,7 +14923,7 @@ version = "36.0.0" source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234#7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234" dependencies = [ "array-bytes 6.2.3", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "serde_json", "sp-application-crypto", "sp-core", @@ -14944,7 +14945,7 @@ dependencies = [ "log", "mixnet", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-network", "sc-network-types", @@ -14980,7 +14981,7 @@ dependencies = [ "log", "mockall", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "partial_sort", "pin-project", "prost 0.12.6", @@ -15169,7 +15170,7 @@ dependencies = [ "num_cpus", "once_cell", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "rustls", "sc-client-api", @@ -15205,7 +15206,7 @@ dependencies = [ "jsonrpsee", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-block-builder", "sc-chain-spec", "sc-client-api", @@ -15285,7 +15286,7 @@ dependencies = [ "jsonrpsee", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "sc-chain-spec", "sc-client-api", @@ -15333,7 +15334,7 @@ dependencies = [ "jsonrpsee", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "rand 0.8.5", "sc-chain-spec", @@ -15391,7 +15392,7 @@ source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96 dependencies = [ "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sp-core", ] @@ -15402,7 +15403,7 @@ source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96 dependencies = [ "log", "parity-db", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-keystore", "sp-api", @@ -15475,7 +15476,7 @@ dependencies = [ "futures", "libp2p", "log", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "rand 0.8.5", "sc-utils", @@ -15496,7 +15497,7 @@ dependencies = [ "libc", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rustc-hash 1.1.0", "sc-client-api", "sc-tracing-proc-macro", @@ -15536,7 +15537,7 @@ dependencies = [ "itertools 0.11.0", "linked-hash-map", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sc-client-api", "sc-transaction-pool-api", "sc-utils", @@ -15581,7 +15582,7 @@ dependencies = [ "futures", "futures-timer", "log", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "prometheus", "sp-arithmetic", ] @@ -15727,7 +15728,7 @@ version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -16072,15 +16073,14 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c522100790450cf78eeac1507263d0a350d4d5b30df0c8e1fe051a10c22b376e" +checksum = "6093cd8c01b25262b84927e0f7151692158fab02d961e04c979d3903eba7ecc5" dependencies = [ "base64 0.22.1", "chrono", "hex", - "serde", - "serde_derive", + "serde_core", "serde_json", "serde_with_macros", "time", @@ -16088,9 +16088,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.14.1" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327ada00f7d64abaac1e55a6911e90cf665aa051b9a561c7006c157f4633135e" +checksum = "a7e6c180db0816026a61afa1cff5344fb7ebded7e4d3062772179f2501481c27" dependencies = [ "darling 0.21.3", "proc-macro2", @@ -16462,7 +16462,7 @@ dependencies = [ "log", "lru 0.11.1", "no-std-net", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "rand 0.8.5", "rand_chacha 0.3.1", @@ -16498,7 +16498,7 @@ dependencies = [ "itertools 0.13.0", "log", "lru 0.12.5", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "rand 0.8.5", "rand_chacha 0.3.1", @@ -16718,7 +16718,7 @@ source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96 dependencies = [ "futures", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "schnellru", "sp-api", "sp-consensus", @@ -16850,7 +16850,7 @@ dependencies = [ "merlin", "parity-bip39", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "paste", "primitive-types 0.13.1", "rand 0.8.5", @@ -16937,7 +16937,7 @@ version = "10.0.0" source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234#7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234" dependencies = [ "kvdb", - "parking_lot 0.12.4", + "parking_lot 0.12.5", ] [[package]] @@ -17027,7 +17027,7 @@ version = "0.43.0" source = "git+https://github.com/opentensor/polkadot-sdk.git?rev=7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234#7d1855ebff04c96bb273b43cfd5a5cf6fa2a7234" dependencies = [ "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "sp-core", "sp-externalities", ] @@ -17217,7 +17217,7 @@ dependencies = [ "hash-db", "log", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "smallvec", "sp-core", @@ -17328,7 +17328,7 @@ dependencies = [ "memory-db", "nohash-hasher", "parity-scale-codec", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "rand 0.8.5", "scale-info", "schnellru", @@ -17680,8 +17680,8 @@ dependencies = [ "bitflags 1.3.2", "cfg_aliases 0.2.1", "libc", - "parking_lot 0.12.4", - "parking_lot_core 0.9.11", + "parking_lot 0.12.5", + "parking_lot_core 0.9.12", "static_init_macro", "winapi", ] @@ -18382,7 +18382,7 @@ dependencies = [ "getrandom 0.3.3", "once_cell", "rustix 1.1.2", - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -18619,7 +18619,7 @@ dependencies = [ "io-uring", "libc", "mio", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project-lite", "signal-hook-registry", "slab", @@ -18909,7 +18909,7 @@ dependencies = [ "matchers", "nu-ansi-term", "once_cell", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "regex-automata", "sharded-slab", "smallvec", @@ -19056,9 +19056,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" [[package]] name = "unicode-xid" @@ -19795,14 +19795,14 @@ version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75c7f0ef91146ebfb530314f5f1d24528d7f0767efbfd31dce919275413e393e" dependencies = [ - "webpki-root-certs 1.0.2", + "webpki-root-certs 1.0.3", ] [[package]] name = "webpki-root-certs" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4ffd8df1c57e87c325000a3d6ef93db75279dc3a231125aac571650f22b12a" +checksum = "05d651ec480de84b762e7be71e6efa7461699c19d9e2c272c8d93455f567786e" dependencies = [ "rustls-pki-types", ] @@ -19974,7 +19974,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.1", + "windows-sys 0.61.2", ] [[package]] @@ -20024,22 +20024,22 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.62.1" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6844ee5416b285084d3d3fffd743b925a6c9385455f64f6d4fa3031c4c2749a9" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", "windows-link", - "windows-result 0.4.0", + "windows-result 0.4.1", "windows-strings", ] [[package]] name = "windows-implement" -version = "0.60.1" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb307e42a74fb6de9bf3a02d9712678b22399c87e6fa869d6dfcd8c1b7754e0" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", @@ -20048,9 +20048,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.59.2" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0abd1ddbc6964ac14db11c7213d6532ef34bd9aa042c2e5935f59d7908b46a5" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", @@ -20059,9 +20059,9 @@ dependencies = [ [[package]] name = "windows-link" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45e46c0661abb7180e7b9c281db115305d49ca1709ab8242adf09666d2173c65" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-result" @@ -20074,18 +20074,18 @@ dependencies = [ [[package]] name = "windows-result" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7084dcc306f89883455a206237404d3eaf961e5bd7e0f312f7c91f57eb44167f" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7218c655a553b0bed4426cf54b20d7ba363ef543b52d515b3e48d7fd55318dda" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ "windows-link", ] @@ -20132,14 +20132,14 @@ version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" dependencies = [ - "windows-targets 0.53.4", + "windows-targets 0.53.5", ] [[package]] name = "windows-sys" -version = "0.61.1" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f109e41dd4a3c848907eb83d5a42ea98b3769495597450cf6d153507b166f0f" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ "windows-link", ] @@ -20192,19 +20192,19 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.53.4" +version = "0.53.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d42b7b7f66d2a06854650af09cfdf8713e427a439c97ad65a6375318033ac4b" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" dependencies = [ "windows-link", - "windows_aarch64_gnullvm 0.53.0", - "windows_aarch64_msvc 0.53.0", - "windows_i686_gnu 0.53.0", - "windows_i686_gnullvm 0.53.0", - "windows_i686_msvc 0.53.0", - "windows_x86_64_gnu 0.53.0", - "windows_x86_64_gnullvm 0.53.0", - "windows_x86_64_msvc 0.53.0", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -20227,9 +20227,9 @@ checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" [[package]] name = "windows_aarch64_msvc" @@ -20251,9 +20251,9 @@ checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_aarch64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" [[package]] name = "windows_i686_gnu" @@ -20275,9 +20275,9 @@ checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" [[package]] name = "windows_i686_gnullvm" @@ -20287,9 +20287,9 @@ checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" [[package]] name = "windows_i686_msvc" @@ -20311,9 +20311,9 @@ checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_i686_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" [[package]] name = "windows_x86_64_gnu" @@ -20335,9 +20335,9 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnu" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" [[package]] name = "windows_x86_64_gnullvm" @@ -20359,9 +20359,9 @@ checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_gnullvm" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" [[package]] name = "windows_x86_64_msvc" @@ -20383,9 +20383,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "windows_x86_64_msvc" -version = "0.53.0" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" @@ -20543,7 +20543,7 @@ dependencies = [ "futures", "log", "nohash-hasher", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "rand 0.8.5", "static_assertions", @@ -20558,7 +20558,7 @@ dependencies = [ "futures", "log", "nohash-hasher", - "parking_lot 0.12.4", + "parking_lot 0.12.5", "pin-project", "rand 0.9.2", "static_assertions", diff --git a/Cargo.toml b/Cargo.toml index 1d1a144bd9..6a39a3dd36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,6 +91,9 @@ serde_bytes = { version = "0.11.14", default-features = false } serde_json = { version = "1.0.141", default-features = false } serde_with = { version = "3.14.0", default-features = false } smallvec = "1.13.2" +tracing = "0.1" +tracing-log = "0.2" +tracing-subscriber = { version = "0.3" } litep2p = { git = "https://github.com/paritytech/litep2p", tag = "v0.7.0", default-features = false } syn = { version = "2.0.106", default-features = false } quote = { version = "1", default-features = false } diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index bb53aa8af7..35601fe875 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -68,6 +68,9 @@ rand.workspace = true sp-core.workspace = true sp-std.workspace = true pallet-preimage.workspace = true +tracing.workspace = true +tracing-log.workspace = true +tracing-subscriber = { workspace = true, features = ["fmt", "env-filter"] } [features] try-runtime = [ diff --git a/pallets/subtensor/src/tests/epoch_logs.rs b/pallets/subtensor/src/tests/epoch_logs.rs new file mode 100644 index 0000000000..0c95857346 --- /dev/null +++ b/pallets/subtensor/src/tests/epoch_logs.rs @@ -0,0 +1,657 @@ +#![allow( + clippy::arithmetic_side_effects, + clippy::indexing_slicing, + clippy::unwrap_used +)] + +// Run all tests +// cargo test --package pallet-subtensor --lib -- tests::epoch_logs --show-output + +use super::mock::*; +use crate::*; +use frame_support::assert_ok; +use sp_core::U256; +use std::io::{Result as IoResult, Write}; +use std::sync::{Arc, Mutex}; +use subtensor_runtime_common::{AlphaCurrency, MechId}; +use tracing_subscriber::{EnvFilter, layer::SubscriberExt}; + +const NETUID: u16 = 1; +const TEMPO: u16 = 10; +const ACTIVITY_CUTOFF: u16 = 10; +// Coldkey is irrelevant for epoch because it operates only hotkeys. Nominators' stake is distributed downstream +// We can use a single coldkey for all tests here. +const COLDKEY: u16 = 9876; + +#[derive(Clone)] +struct Neuron { + uid: u16, + hotkey: U256, + validator: bool, + alpha_stake: u64, + registration_block: u64, + last_update: u64, +} + +impl Neuron { + fn new( + uid: u16, + hotkey: u16, + validator: bool, + alpha_stake: u64, + registration_block: u64, + last_update: u64, + ) -> Self { + Neuron { + uid, + hotkey: U256::from(hotkey), + validator, + alpha_stake, + registration_block, + last_update, + } + } +} + +fn setup_epoch(neurons: Vec, mechanism_count: u8) { + let netuid = NetUid::from(NETUID); + + // Setup subnet parameters + NetworksAdded::::insert(netuid, true); + let network_n = neurons.len() as u16; + SubnetworkN::::insert(netuid, network_n); + ActivityCutoff::::insert(netuid, ACTIVITY_CUTOFF); + Tempo::::insert(netuid, TEMPO); + SubtensorModule::set_weights_set_rate_limit(netuid, 0); + MechanismCountCurrent::::insert(netuid, MechId::from(mechanism_count)); + + // Setup neurons + let mut last_update_vec: Vec = Vec::new(); + let mut permit_vec: Vec = Vec::new(); + neurons.iter().for_each(|neuron| { + let hotkey = U256::from(neuron.hotkey); + + Keys::::insert(netuid, neuron.uid, hotkey); + Uids::::insert(netuid, hotkey, neuron.uid); + BlockAtRegistration::::insert(netuid, neuron.uid, neuron.registration_block); + last_update_vec.push(neuron.last_update); + permit_vec.push(neuron.validator); + + // Setup stake + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &hotkey, + &U256::from(COLDKEY), + netuid, + AlphaCurrency::from(neuron.alpha_stake), + ); + }); + + ValidatorPermit::::insert(netuid, permit_vec); + for m in 0..mechanism_count { + let netuid_index = SubtensorModule::get_mechanism_storage_index(netuid, m.into()); + LastUpdate::::insert(netuid_index, last_update_vec.clone()); + } +} + +fn set_weights(netuid: NetUid, weights: Vec>, indices: Vec) { + for (uid, weight) in weights.iter().enumerate() { + let hotkey = Keys::::get(netuid, uid as u16); + assert_ok!(SubtensorModule::set_weights( + RuntimeOrigin::signed(hotkey), + netuid, + indices.clone(), + weight.to_vec(), + 0 + )); + } +} + +/// Write sparse weight rows **for a specific mechanism**. +/// `rows` is a list of `(validator_uid, row)` where `row` is `[(dest_uid, weight_u16)]`. +fn set_weights_for_mech(netuid: NetUid, mecid: MechId, rows: Vec<(u16, Vec<(u16, u16)>)>) { + let netuid_index = SubtensorModule::get_mechanism_storage_index(netuid, mecid); + for (uid, sparse_row) in rows { + Weights::::insert(netuid_index, uid, sparse_row); + } +} + +/// Run `f` with a per-thread subscriber configured by `spec` and +/// return the captured log text. +pub fn with_log_capture(spec: &str, f: F) -> String +where + F: FnOnce() -> R, +{ + // ensure log::... is bridged to tracing (no-op if already set) + let _ = tracing_log::LogTracer::init(); + + // Shared buffer we'll write logs into + let buf: Arc>> = Arc::new(Mutex::new(Vec::new())); + struct Buf(Arc>>); + impl Write for Buf { + fn write(&mut self, b: &[u8]) -> IoResult { + let mut g = self.0.lock().unwrap(); + g.extend_from_slice(b); + Ok(b.len()) + } + fn flush(&mut self) -> IoResult<()> { + Ok(()) + } + } + + // Formatting layer that writes into our buffer + let fmt_layer = tracing_subscriber::fmt::layer() + .with_ansi(false) + .with_target(true) + .with_level(true) + .without_time() + .with_writer({ + let buf = buf.clone(); + move || Buf(buf.clone()) + }); + + // Parse filter spec (full RUST_LOG syntax). Fall back to "off" on error. + let filter = EnvFilter::try_new(spec).unwrap_or_else(|_| EnvFilter::new("off")); + + // Build the per-thread subscriber + let sub = tracing_subscriber::registry().with(filter).with(fmt_layer); + + // Activate just for this thread/scope and run the code + tracing::subscriber::with_default(sub, f); + + // Collect captured text + let mut g = buf.lock().unwrap(); + String::from_utf8(std::mem::take(&mut *g)).unwrap_or_default() +} + +#[test] +fn test_simple() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 1, true, 1_000_000_000, 0, 1 ), + Neuron::new( 1, 2, true, 1_000_000_000, 0, 1 ), + ]; + setup_epoch(neurons.to_vec(), 1); + + // Run epoch, watch logs + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(NetUid::from(NETUID), MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + + assert!(has("Number of Neurons in Network: 2")); + assert!(has("Inactive: [false, false]")); + assert!(has("Block at registration: [0, 0]")); + assert!(has("alpha_stake: [1000000000, 1000000000]")); + assert!(has("Filtered stake: [1000000000, 1000000000]")); + assert!(has("Normalised Stake: [0.5, 0.5]")); + assert!(has("validator_permits: [true, true]")); + assert!(has("new_validator_permits: [true, true]")); + assert!(has("Active Stake: [0.5, 0.5]")); + assert!(has("Consensus: [0, 0]")); + assert!(has("Normalized Validator Emission: [0.5, 0.5]")); + assert!(has("Normalized Combined Emission: [0.5, 0.5]")); + assert!(has( + "Combined Emission: [AlphaCurrency(500000000), AlphaCurrency(500000000)]" + )); + assert!(has("Pruning Scores: [0.5, 0.5]")); + assert!(!has("math error:")); + }); +} + +#[test] +fn test_bad_permit_vector() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 1, true, 1_000_000_000, 0, 1 ), + Neuron::new( 1, 2, true, 1_000_000_000, 0, 1 ), + ]; + setup_epoch(neurons.to_vec(), 1); + ValidatorPermit::::insert(NetUid::from(NETUID), vec![true]); + + // Run epoch, watch logs + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(NetUid::from(NETUID), MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + + assert!(has( + "math error: inplace_mask_vector input lengths are not equal" + )); + assert!(has( + "Validator Emission: [AlphaCurrency(1000000000), AlphaCurrency(0)]" + )); + }); +} + +#[test] +fn test_inactive_mask_zeroes_active_stake() { + // Big block so updated + activity_cutoff < current_block + new_test_ext(1_000_000).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 11, true, 1_000_000_000, 0, 0 ), + Neuron::new( 1, 22, true, 1_000_000_000, 0, 0 ), + ]; + setup_epoch(neurons.to_vec(), 1); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(NetUid::from(NETUID), MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + assert!(has("Number of Neurons in Network: 2")); + assert!(has("Inactive: [true, true]")); + // After masking + renormalizing, both entries are zero. + assert!(has("Active Stake: [0, 0]")); + }); +} + +#[test] +fn test_validator_permit_masks_active_stake() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 11, true, 1_000_000_000, 0, 1 ), + Neuron::new( 1, 22, true, 1_000_000_000, 0, 1 ), + ]; + setup_epoch(neurons.to_vec(), 1); + + // Forbid validator #1 + let netuid = NetUid::from(NETUID); + ValidatorPermit::::insert(netuid, vec![true, false]); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + assert!(has("validator_permits: [true, false]")); + // After masking and renormalizing, only the first stays: [1, 0] + assert!(logs.contains("Active Stake: [1, 0]")); + }); +} + +#[test] +fn yuma_emergency_mode() { + // Large block so everyone is inactive (updated + cutoff < current_block) + new_test_ext(1_000_000).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 11, true, 1_000_000_000, 0, 0 ), + Neuron::new( 1, 22, true, 1_000_000_000, 0, 0 ), + ]; + setup_epoch(neurons.to_vec(), 1); + + // No weights needed; keep defaults empty to make ranks/dividends zero. + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(NetUid::from(NETUID), MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + assert!(has("Inactive: [true, true]")); + // Because emission_sum == 0 and active_stake == 0, we expect fallback to normalized stake. + assert!(has("Normalized Combined Emission: [0.5, 0.5]")); + }); +} + +#[test] +fn epoch_uses_active_stake_when_nonzero_active() { + new_test_ext(1000).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 11, true, 1_000_000_000, 0, 999 ), // active + Neuron::new( 1, 22, true, 1_000_000_000, 0, 1 ), // inactive + ]; + setup_epoch(neurons.to_vec(), 1); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(NetUid::from(NETUID), MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + assert!(has("Inactive: [false, true]")); + // With ranks/dividends zero, fallback should mirror active_stake ~ [1, 0]. + assert!(has("Active Stake: [1, 0]")); + assert!(has("Normalized Combined Emission: [1, 0]")); + }); +} + +#[test] +fn epoch_topk_validator_permits() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 11, true, 2_000_000_000, 0, 1 ), + Neuron::new( 1, 22, true, 1_000_000_000, 0, 1 ), + ]; + setup_epoch(neurons.to_vec(), 1); + + // K = 1 (one validator allowed) + let netuid = NetUid::from(NETUID); + MaxAllowedValidators::::insert(netuid, 1u16); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + assert!( + has("Normalised Stake: [0.666"), + "sanity: asymmetric stake normalized" + ); + assert!(has("max_allowed_validators: 1")); + assert!(has("new_validator_permits: [true, false]")); + }); +} + +#[test] +fn epoch_yuma3_bonds_pipeline() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + Neuron::new(0, 11, true, 1_000_000_000, 0, 1), + Neuron::new(1, 22, true, 1_000_000_000, 0, 1), + ]; + setup_epoch(neurons.to_vec(), 1); + + let netuid = NetUid::from(NETUID); + Yuma3On::::insert(netuid, true); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + // These appear only in the Yuma3 branch: + assert!(has("Bonds: ")); + assert!(has("emaB: [")); + assert!(has("emaB norm: ")); + assert!(has("total_bonds_per_validator: ")); + }); +} + +#[test] +fn epoch_original_yuma_bonds_pipeline() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + Neuron::new(0, 11, true, 1_000_000_000, 0, 1), + Neuron::new(1, 22, true, 1_000_000_000, 0, 1), + ]; + setup_epoch(neurons.to_vec(), 1); + + let netuid = NetUid::from(NETUID); + Yuma3On::::insert(netuid, false); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + // These strings are present in the non-Yuma3 branch: + assert!(has("B (outdatedmask): ")); + assert!(has("ΔB (norm): ")); + assert!(has("Exponential Moving Average Bonds: ")); + }); +} + +#[test] +fn test_validators_weight_two_distinct_servers() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + // uid hotkey vali stake reg upd + Neuron::new( 0, 11, true, 1_000_000_000, 0, 1 ), // validator + Neuron::new( 1, 22, true, 1_000_000_000, 0, 1 ), // validator + Neuron::new( 2, 33, true, 1_000_000_000, 0, 1 ), // validator + Neuron::new( 3, 44, false, 0, 0, 1 ), // server + Neuron::new( 4, 55, false, 0, 0, 1 ), // server + ]; + setup_epoch(neurons.to_vec(), 1); + + let netuid = NetUid::from(NETUID); + + // rows are per-validator; columns correspond to server UIDs [3, 4] + // V0 -> [MAX, 0] (server 3) + // V1 -> [0, MAX] (server 4) + // V2 -> [MAX, 0] (server 3) + CommitRevealWeightsEnabled::::insert(netuid, false); + set_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, 0]], + vec![3, 4], + ); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + + // topology sanity + assert!(has("Number of Neurons in Network: 5")); + assert!(has("validator_permits: [true, true, true, false, false]")); + + // weight pipeline exercised + assert!(has("Weights: [[(3, 65535), (4, 0)], [(3, 0), (4, 65535)], [(3, 65535), (4, 0)], [], []]")); + assert!(has("Weights (permit): [[(3, 65535), (4, 0)], [(3, 0), (4, 65535)], [(3, 65535), (4, 0)], [], []]")); + assert!(has("Weights (permit+diag): [[(3, 65535), (4, 0)], [(3, 0), (4, 65535)], [(3, 65535), (4, 0)], [], []]")); + assert!(has("Weights (mask+norm): [[(3, 1), (4, 0)], [(3, 0), (4, 1)], [(3, 1), (4, 0)], [], []]")); + + // downstream signals present + assert!(has("Ranks (before): [0, 0, 0, 0.6666666665, 0.3333333333]")); + assert!(has("Consensus: [0, 0, 0, 1, 0]")); + assert!(has("Validator Trust: [1, 0, 1, 0, 0]")); + assert!(has("Ranks (after): [0, 0, 0, 0.6666666665, 0]")); + assert!(has("Trust: [0, 0, 0, 1, 0]")); + assert!(has("Dividends: [0.5, 0, 0.5, 0, 0]")); + assert!(has("Normalized Combined Emission: [0.25, 0, 0.25, 0.5, 0]")); + assert!(has("Pruning Scores: [0.25, 0, 0.25, 0.5, 0]")); + + // math is ok + assert!(!has("math error:")); + }); +} + +#[test] +fn test_validator_splits_weight_across_two_servers() { + new_test_ext(1).execute_with(|| { + let logs = with_log_capture("trace", || { + #[rustfmt::skip] + let neurons = [ + Neuron::new(0, 11, true, 1_000_000_000, 0, 1), + Neuron::new(1, 22, true, 1_000_000_000, 0, 1), + Neuron::new(2, 33, true, 1_000_000_000, 0, 1), + Neuron::new(3, 44, false, 0, 0, 1), + Neuron::new(4, 55, false, 0, 0, 1), + ]; + setup_epoch(neurons.to_vec(), 1); + + let netuid = NetUid::from(NETUID); + + // V2 splits: both entries nonzero; row normalization should make ~[0.5, 0.5] for V2 + CommitRevealWeightsEnabled::::insert(netuid, false); + set_weights( + netuid, + vec![vec![u16::MAX, 0], vec![0, u16::MAX], vec![u16::MAX, u16::MAX]], + vec![3, 4], + ); + + let emission = AlphaCurrency::from(1_000_000_000); + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), emission); + }); + + let has = |s: &str| logs.contains(s); + + assert!(has("validator_permits: [true, true, true, false, false]")); + assert!(has("Weights (mask+norm): [[(3, 1), (4, 0)], [(3, 0), (4, 1)], [(3, 0.5), (4, 0.5)], [], []]")); + assert!(has("Ranks (before): [0, 0, 0, 0.4999999998, 0.4999999998]")); + assert!(has("Ranks (after): [0, 0, 0, 0.333333333, 0.333333333]")); + assert!(has("ΔB (norm): [[(3, 0.5), (4, 0)], [(3, 0), (4, 0.5)], [(3, 0.5), (4, 0.5)], [], []]")); + assert!(has("Dividends: [0.25, 0.25, 0.5, 0, 0]")); + assert!(has("Normalized Combined Emission: [0.125, 0.125, 0.25, 0.25, 0.25]")); + assert!(!has("math error:")); + }); +} + +#[test] +fn epoch_mechanism_reads_weights_per_mechanism() { + new_test_ext(1).execute_with(|| { + let netuid = NetUid::from(NETUID); + + // 3 validators (0,1,2) and 2 servers (3,4) + #[rustfmt::skip] + let neurons = [ + Neuron::new(0, 11, true, 1_000_000_000, 0, 1), + Neuron::new(1, 22, true, 1_000_000_000, 0, 1), + Neuron::new(2, 33, true, 1_000_000_000, 0, 1), + Neuron::new(3, 44, false, 0, 0, 1), + Neuron::new(4, 55, false, 0, 0, 1), + ]; + setup_epoch(neurons.to_vec(), 2); // 2 mechanisms + + // Mech 0: V0,V2 -> server 3 ; V1 -> server 4 + set_weights_for_mech( + netuid, + MechId::from(0), + vec![ + (0, vec![(3, u16::MAX)]), + (1, vec![(4, u16::MAX)]), + (2, vec![(3, u16::MAX)]), + ], + ); + let logs_m0 = with_log_capture("trace", || { + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), AlphaCurrency::from(1_000)); + }); + + // Mech 1: flipped routing: V0,V2 -> server 4 ; V1 -> server 3 + set_weights_for_mech( + netuid, + MechId::from(1), + vec![ + (0, vec![(4, u16::MAX)]), + (1, vec![(3, u16::MAX)]), + (2, vec![(4, u16::MAX)]), + ], + ); + let logs_m1 = with_log_capture("trace", || { + SubtensorModule::epoch_mechanism(netuid, MechId::from(1), AlphaCurrency::from(1_000)); + }); + + // Both should run the full pipeline… + assert!(logs_m0.contains("Active Stake: [0.3333333333, 0.3333333333, 0.3333333333, 0, 0]")); + assert!(logs_m1.contains("Active Stake: [0.3333333333, 0.3333333333, 0.3333333333, 0, 0]")); + assert!(logs_m0.contains("Weights (mask+norm): [[(3, 1)], [(4, 1)], [(3, 1)], [], []]")); + assert!(logs_m1.contains("Weights (mask+norm): [[(4, 1)], [(3, 1)], [(4, 1)], [], []]")); + assert!(logs_m0.contains("Ranks (before): [0, 0, 0, 0.6666666665, 0.3333333333]")); + assert!(logs_m1.contains("Ranks (before): [0, 0, 0, 0.3333333333, 0.6666666665]")); + assert!(logs_m0.contains("ΔB (norm): [[(3, 0.5)], [], [(3, 0.5)], [], []]")); + assert!(logs_m1.contains("ΔB (norm): [[(4, 0.5)], [], [(4, 0.5)], [], []]")); + assert!(logs_m0.contains("Normalized Combined Emission: [0.25, 0, 0.25, 0.5, 0]")); + assert!(logs_m1.contains("Normalized Combined Emission: [0.25, 0, 0.25, 0, 0.5]")); + + // ...and produce different logs because weights differ per mechanism. + assert_ne!( + logs_m0, logs_m1, + "mechanism-specific weights should yield different outcomes/logs" + ); + }); +} + +// cargo test --package pallet-subtensor --lib -- tests::epoch_logs::epoch_mechanism_three_mechanisms_separate_state --exact --show-output +#[test] +fn epoch_mechanism_three_mechanisms_separate_state() { + new_test_ext(1).execute_with(|| { + let netuid = NetUid::from(NETUID); + + // 2 validators, 2 servers + #[rustfmt::skip] + let neurons = [ + Neuron::new(0, 11, true, 1_000_000_000, 0, 1), + Neuron::new(1, 22, true, 1_000_000_000, 0, 1), + Neuron::new(2, 44, false, 0, 0, 1), + Neuron::new(3, 55, false, 0, 0, 1), + ]; + setup_epoch(neurons.to_vec(), 3); // 3 mechanisms + + // Mech 0: all validators -> server 2 + set_weights_for_mech( + netuid, + MechId::from(0), + vec![(0, vec![(2, u16::MAX)]), (1, vec![(2, u16::MAX)])], + ); + + // Mech 1: split across both servers (two nonzero entries per row) + set_weights_for_mech( + netuid, + MechId::from(1), + vec![ + (0, vec![(2, u16::MAX), (3, u16::MAX)]), + (1, vec![(2, u16::MAX), (3, u16::MAX)]), + ], + ); + + // Mech 2: all validators -> server 3 + set_weights_for_mech( + netuid, + MechId::from(2), + vec![(0, vec![(3, u16::MAX)]), (1, vec![(3, u16::MAX)])], + ); + + let l0 = with_log_capture("trace", || { + SubtensorModule::epoch_mechanism(netuid, MechId::from(0), AlphaCurrency::from(1_000)); + }); + let l1 = with_log_capture("trace", || { + SubtensorModule::epoch_mechanism(netuid, MechId::from(1), AlphaCurrency::from(1_000)); + }); + let l2 = with_log_capture("trace", || { + SubtensorModule::epoch_mechanism(netuid, MechId::from(2), AlphaCurrency::from(1_000)); + }); + + // Check major epoch indicators + assert!(l0.contains("Weights (mask+norm): [[(2, 1)], [(2, 1)], [], []]")); + assert!(l0.contains("Ranks (before): [0, 0, 1, 0]")); + assert!(l0.contains("ΔB (norm): [[(2, 0.5)], [(2, 0.5)], [], []]")); + assert!(l0.contains("Normalized Combined Emission: [0.25, 0.25, 0.5, 0]")); + + assert!( + l1.contains( + "Weights (mask+norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []]" + ) + ); + assert!(l1.contains("Ranks (before): [0, 0, 0.5, 0.5]")); + assert!(l1.contains("ΔB (norm): [[(2, 0.5), (3, 0.5)], [(2, 0.5), (3, 0.5)], [], []]")); + assert!(l1.contains("Normalized Combined Emission: [0.25, 0.25, 0.25, 0.25]")); + + assert!(l2.contains("Weights (mask+norm): [[(3, 1)], [(3, 1)], [], []]")); + assert!(l2.contains("Ranks (before): [0, 0, 0, 1]")); + assert!(l2.contains("ΔB (norm): [[(3, 0.5)], [(3, 0.5)], [], []]")); + assert!(l2.contains("Normalized Combined Emission: [0.25, 0.25, 0, 0.5]")); + + // Distinct outcomes + assert_ne!(l0, l1); + assert_ne!(l1, l2); + assert_ne!(l0, l2); + }); +} diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 7c731b604c..644ee30ca9 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -24,9 +24,11 @@ use sp_runtime::{ BuildStorage, Percent, traits::{BlakeTwo256, IdentityLookup}, }; -use sp_std::{cell::RefCell, cmp::Ordering}; +use sp_std::{cell::RefCell, cmp::Ordering, sync::OnceLock}; +use sp_tracing::tracing_subscriber; use subtensor_runtime_common::{NetUid, TaoCurrency}; use subtensor_swap_interface::{Order, SwapHandler}; +use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt}; type Block = frame_system::mocking::MockBlock; @@ -671,10 +673,38 @@ where } } +static TEST_LOGS_INIT: OnceLock<()> = OnceLock::new(); + +pub fn init_logs_for_tests() { + if TEST_LOGS_INIT.get().is_some() { + return; + } + + // RUST_LOG (full syntax) or "off" if unset + let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("off")); + + // Bridge log -> tracing (ok if already set) + let _ = tracing_log::LogTracer::init(); + + // Simple formatter + let fmt_layer = tracing_subscriber::fmt::layer() + .with_ansi(false) + .with_target(true) + .with_level(true) + .without_time(); + + let _ = tracing_subscriber::registry() + .with(filter) + .with(fmt_layer) + .try_init(); + + let _ = TEST_LOGS_INIT.set(()); +} + #[allow(dead_code)] // Build genesis storage according to the mock runtime. pub fn new_test_ext(block_number: BlockNumber) -> sp_io::TestExternalities { - sp_tracing::try_init_simple(); + init_logs_for_tests(); let t = frame_system::GenesisConfig::::default() .build_storage() .unwrap(); @@ -685,7 +715,7 @@ pub fn new_test_ext(block_number: BlockNumber) -> sp_io::TestExternalities { #[allow(dead_code)] pub fn test_ext_with_balances(balances: Vec<(U256, u128)>) -> sp_io::TestExternalities { - sp_tracing::try_init_simple(); + init_logs_for_tests(); let mut t = frame_system::GenesisConfig::::default() .build_storage() .unwrap(); diff --git a/pallets/subtensor/src/tests/mod.rs b/pallets/subtensor/src/tests/mod.rs index a0105a6ffe..fda2f90b4d 100644 --- a/pallets/subtensor/src/tests/mod.rs +++ b/pallets/subtensor/src/tests/mod.rs @@ -8,6 +8,7 @@ mod difficulty; mod emission; mod ensure; mod epoch; +mod epoch_logs; mod evm; mod leasing; mod math; diff --git a/pallets/subtensor/src/tests/networks.rs b/pallets/subtensor/src/tests/networks.rs index 94069c633d..e4d4601451 100644 --- a/pallets/subtensor/src/tests/networks.rs +++ b/pallets/subtensor/src/tests/networks.rs @@ -4,9 +4,9 @@ use crate::*; use frame_support::{assert_err, assert_ok}; use frame_system::Config; use sp_core::U256; -use sp_std::collections::btree_map::BTreeMap; +use sp_std::collections::{btree_map::BTreeMap, vec_deque::VecDeque}; use substrate_fixed::types::{I96F32, U64F64, U96F32}; -use subtensor_runtime_common::{NetUidStorageIndex, TaoCurrency}; +use subtensor_runtime_common::{MechId, NetUidStorageIndex, TaoCurrency}; use subtensor_swap_interface::{Order, SwapHandler}; #[test] @@ -2196,3 +2196,105 @@ fn massive_dissolve_refund_and_reregistration_flow_is_lossless_and_cleans_state( ); }); } + +#[test] +fn dissolve_clears_all_mechanism_scoped_maps_for_all_mechanisms() { + new_test_ext(0).execute_with(|| { + // Create a subnet we can dissolve. + let owner_cold = U256::from(123); + let owner_hot = U256::from(456); + let net = add_dynamic_network(&owner_hot, &owner_cold); + + // We'll use two mechanisms for this subnet. + MechanismCountCurrent::::insert(net, MechId::from(2)); + let m0 = MechId::from(0u8); + let m1 = MechId::from(1u8); + + let idx0 = SubtensorModule::get_mechanism_storage_index(net, m0); + let idx1 = SubtensorModule::get_mechanism_storage_index(net, m1); + + // Minimal content to ensure each storage actually has keys for BOTH mechanisms. + + // --- Weights (DMAP: (netuid_index, uid) -> Vec<(dest_uid, weight_u16)>) + Weights::::insert(idx0, 0u16, vec![(1u16, 1u16)]); + Weights::::insert(idx1, 0u16, vec![(2u16, 1u16)]); + + // --- Bonds (DMAP: (netuid_index, uid) -> Vec<(dest_uid, weight_u16)>) + Bonds::::insert(idx0, 0u16, vec![(1u16, 1u16)]); + Bonds::::insert(idx1, 0u16, vec![(2u16, 1u16)]); + + // --- TimelockedWeightCommits (DMAP: (netuid_index, epoch) -> VecDeque<...>) + let hotkey = U256::from(1); + TimelockedWeightCommits::::insert( + idx0, + 1u64, + VecDeque::from([(hotkey, 1u64, Default::default(), Default::default())]), + ); + TimelockedWeightCommits::::insert( + idx1, + 2u64, + VecDeque::from([(hotkey, 2u64, Default::default(), Default::default())]), + ); + + // --- Incentive (MAP: netuid_index -> Vec) + Incentive::::insert(idx0, vec![1u16, 2u16]); + Incentive::::insert(idx1, vec![3u16, 4u16]); + + // --- LastUpdate (MAP: netuid_index -> Vec) + LastUpdate::::insert(idx0, vec![42u64]); + LastUpdate::::insert(idx1, vec![84u64]); + + // Sanity: keys are present before dissolve. + assert!(Weights::::contains_key(idx0, 0u16)); + assert!(Weights::::contains_key(idx1, 0u16)); + assert!(Bonds::::contains_key(idx0, 0u16)); + assert!(Bonds::::contains_key(idx1, 0u16)); + assert!(TimelockedWeightCommits::::contains_key(idx0, 1u64)); + assert!(TimelockedWeightCommits::::contains_key(idx1, 2u64)); + assert!(Incentive::::contains_key(idx0)); + assert!(Incentive::::contains_key(idx1)); + assert!(LastUpdate::::contains_key(idx0)); + assert!(LastUpdate::::contains_key(idx1)); + assert!(MechanismCountCurrent::::contains_key(net)); + + // --- Dissolve the subnet --- + assert_ok!(SubtensorModule::do_dissolve_network(net)); + + // After dissolve, ALL mechanism-scoped items must be cleared for ALL mechanisms. + + // Weights/Bonds double-maps should have no entries under either index. + assert!(Weights::::iter_prefix(idx0).next().is_none()); + assert!(Weights::::iter_prefix(idx1).next().is_none()); + assert!(Bonds::::iter_prefix(idx0).next().is_none()); + assert!(Bonds::::iter_prefix(idx1).next().is_none()); + + // WeightCommits (OptionQuery) should have no keys remaining. + assert!(WeightCommits::::iter_prefix(idx0).next().is_none()); + assert!(WeightCommits::::iter_prefix(idx1).next().is_none()); + assert!(!WeightCommits::::contains_key(idx0, owner_hot)); + assert!(!WeightCommits::::contains_key(idx1, owner_cold)); + + // TimelockedWeightCommits (ValueQuery) — ensure both prefix spaces empty and keys gone. + assert!( + TimelockedWeightCommits::::iter_prefix(idx0) + .next() + .is_none() + ); + assert!( + TimelockedWeightCommits::::iter_prefix(idx1) + .next() + .is_none() + ); + assert!(!TimelockedWeightCommits::::contains_key(idx0, 1u64)); + assert!(!TimelockedWeightCommits::::contains_key(idx1, 2u64)); + + // Single-map per-mechanism vectors cleared. + assert!(!Incentive::::contains_key(idx0)); + assert!(!Incentive::::contains_key(idx1)); + assert!(!LastUpdate::::contains_key(idx0)); + assert!(!LastUpdate::::contains_key(idx1)); + + // MechanismCountCurrent cleared + assert!(!MechanismCountCurrent::::contains_key(net)); + }); +}