diff --git a/Cargo.lock b/Cargo.lock index f7f8dd3a5..0b4537ac0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -491,9 +491,9 @@ checksum = "fbb36e985947064623dbd357f727af08ffd077f93d696782f3c56365fa2e2799" [[package]] name = "async-trait" -version = "0.1.79" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507401cad91ec6a857ed5513a2073c82a9b9048762b885bb98655b306964681" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", @@ -783,6 +783,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chacha20" version = "0.9.1" @@ -1187,6 +1193,17 @@ dependencies = [ "syn 2.0.58", ] +[[package]] +name = "derive-where" +version = "1.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.58", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1354,7 +1371,7 @@ checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" dependencies = [ "curve25519-dalek 4.1.2", "ed25519", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex", "rand_core 0.6.4", "sha2 0.10.8", @@ -1363,9 +1380,9 @@ dependencies = [ [[package]] name = "either" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "elliptic-curve" @@ -1499,6 +1516,16 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c007b1ae3abe1cb6f85a16305acd418b7ca6343b953633fee2b76d8f108b830f" +[[package]] +name = "finito" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2384245d85162258a14b43567a9ee3598f5ae746a1581fb5d3d2cb780f0dbf95" +dependencies = [ + "futures-timer", + "pin-project", +] + [[package]] name = "fixed-hash" version = "0.8.0" @@ -1950,9 +1977,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -2198,7 +2225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -2218,9 +2245,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -2280,9 +2307,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cdbb7cb6f3ba28f5b212dd250ab4483105efc3e381f5c8bb90340f14f0a2cc3" +checksum = "cfdb12a2381ea5b2e68c3469ec604a007b367778cdb14d09612c8069ebd616ad" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -2293,9 +2320,9 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab2e14e727d2faf388c99d9ca5210566ed3b044f07d92c29c3611718d178380" +checksum = "4978087a58c3ab02efc5b07c5e5e2803024536106fd5506f558db172c889b3aa" dependencies = [ "futures-util", "http", @@ -2314,12 +2341,11 @@ dependencies = [ [[package]] name = "jsonrpsee-core" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71962a1c49af43adf81d337e4ebc93f3c915faf6eccaa14d74e255107dfd7723" +checksum = "b4b257e1ec385e07b0255dde0b933f948b5c8b8c28d42afda9587c3a967b896d" dependencies = [ "anyhow", - "async-lock 3.3.0", "async-trait", "beef", "futures-timer", @@ -2338,9 +2364,9 @@ dependencies = [ [[package]] name = "jsonrpsee-http-client" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c13987da51270bda2c1c9b40c19be0fe9b225c7a0553963d8f17e683a50ce84" +checksum = "1ccf93fc4a0bfe05d851d37d7c32b7f370fe94336b52a2f0efc5f1981895c2e5" dependencies = [ "async-trait", "hyper", @@ -2358,9 +2384,9 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e53c72de6cd2ad6ac1aa6e848206ef8b736f92ed02354959130373dfa5b3cbd" +checksum = "150d6168405890a7a3231a3c74843f58b8959471f6df76078db2619ddee1d07d" dependencies = [ "anyhow", "beef", @@ -2371,9 +2397,9 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8a07ab8da9a283b906f6735ddd17d3680158bb72259e853441d1dd0167079ec" +checksum = "58b9db2dfd5bb1194b0ce921504df9ceae210a345bc2f6c5a61432089bbab070" dependencies = [ "http", "jsonrpsee-client-transport", @@ -2514,7 +2540,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -3312,9 +3338,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.84" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "ec96c6a92621310b51366f1e28d05ef11489516e93be030060e5fc12024a49d6" dependencies = [ "unicode-ident", ] @@ -3351,9 +3377,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] @@ -3406,6 +3432,22 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" +[[package]] +name = "reconnecting-jsonrpsee-ws-client" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89cc4a6f1e641017e300c050f0c4c46a198627fb39ec03e7a028d20256b5e54" +dependencies = [ + "cfg_aliases", + "finito", + "futures", + "jsonrpsee", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -3698,9 +3740,9 @@ dependencies = [ [[package]] name = "scale-bits" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "662d10dcd57b1c2a3c41c9cf68f71fb09747ada1ea932ad961aca7e2ca28315f" +checksum = "e57b1e7f6b65ed1f04e79a85a57d755ad56d76fdf1e9bddcc9ae14f71fcdcf54" dependencies = [ "parity-scale-codec", "scale-info", @@ -3710,9 +3752,9 @@ dependencies = [ [[package]] name = "scale-decode" -version = "0.11.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc79ba56a1c742f5aeeed1f1801f3edf51f7e818f0a54582cac6f131364ea7b" +checksum = "b12ebca36cec2a3f983c46295b282b35e5f8496346fb859a8776dad5389e5389" dependencies = [ "derive_more", "parity-scale-codec", @@ -3725,9 +3767,9 @@ dependencies = [ [[package]] name = "scale-decode-derive" -version = "0.11.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5398fdb3c7bea3cb419bac4983aadacae93fe1a7b5f693f4ebd98c3821aad7a5" +checksum = "06a387a62a2be6ec532eb4f9e1fc800f26d462c06b335d9c3ee54559a355b9fb" dependencies = [ "darling 0.14.4", "proc-macro2", @@ -3737,9 +3779,9 @@ dependencies = [ [[package]] name = "scale-encode" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628800925a33794fb5387781b883b5e14d130fece9af5a63613867b8de07c5c7" +checksum = "4ba0b9c48dc0eb20c60b083c29447c0c4617cb7c4a4c9fef72aa5c5bc539e15e" dependencies = [ "derive_more", "parity-scale-codec", @@ -3752,9 +3794,9 @@ dependencies = [ [[package]] name = "scale-encode-derive" -version = "0.6.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a304e1af7cdfbe7a24e08b012721456cc8cecdedadc14b3d10513eada63233c" +checksum = "82ab7e60e2d9c8d47105f44527b26f04418e5e624ffc034f6b4a86c0ba19c5bf" dependencies = [ "darling 0.14.4", "proc-macro-crate 1.3.1", @@ -3765,9 +3807,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c453e59a955f81fb62ee5d596b450383d699f152d350e9d23a0db2adb78e4c0" +checksum = "eca070c12893629e2cc820a9761bedf6ce1dcddc9852984d1dc734b8bd9bd024" dependencies = [ "bitvec", "cfg-if", @@ -3779,11 +3821,11 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.11.2" +version = "2.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18cf6c6447f813ef19eb450e985bcce6705f9ce7660db221b59093d15c79c4b7" +checksum = "2d35494501194174bda522a32605929eefc9ecf7e0a326c26db1fdd85881eb62" dependencies = [ - "proc-macro-crate 1.3.1", + "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 1.0.109", @@ -3791,9 +3833,9 @@ dependencies = [ [[package]] name = "scale-type-resolver" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10b800069bfd43374e0f96f653e0d46882a2cb16d6d961ac43bea80f26c76843" +checksum = "f0cded6518aa0bd6c1be2b88ac81bf7044992f0f154bfbabd5ad34f43512abcb" dependencies = [ "scale-info", "smallvec", @@ -3801,9 +3843,9 @@ dependencies = [ [[package]] name = "scale-typegen" -version = "0.2.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d470fa75e71b12b3244a4113adc4bc49891f3daba2054703cacd06256066397e" +checksum = "498d1aecf2ea61325d4511787c115791639c0fd21ef4f8e11e49dd09eff2bbac" dependencies = [ "proc-macro2", "quote", @@ -3814,9 +3856,9 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.14.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c07ccfee963104335c971aaf8b7b0e749be8569116322df23f1f75c4ca9e4a28" +checksum = "f2cf9738c263c665144177201126bdad39d3d62512152f178f35002228026976" dependencies = [ "base58", "blake2", @@ -3961,9 +4003,9 @@ checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -3979,9 +4021,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", @@ -3990,9 +4032,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", @@ -4172,7 +4214,7 @@ dependencies = [ "fnv", "futures-lite", "futures-util", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex", "hmac 0.12.1", "itertools 0.12.1", @@ -4222,7 +4264,7 @@ dependencies = [ "futures-channel", "futures-lite", "futures-util", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex", "itertools 0.12.1", "log", @@ -4857,14 +4899,12 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "subxt" -version = "0.35.1" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5c287b336efcb9bab54020329c48d8cc6427e1c13dcc3b4ec20c793ff8a6926" +checksum = "a160cba1edbf3ec4fbbeaea3f1a185f70448116a6bccc8276bb39adb3b3053bd" dependencies = [ "async-trait", - "base58", - "blake2", - "derivative", + "derive-where", "either", "frame-metadata 16.0.0", "futures", @@ -4874,6 +4914,7 @@ dependencies = [ "jsonrpsee", "parity-scale-codec", "primitive-types", + "reconnecting-jsonrpsee-ws-client", "scale-bits", "scale-decode", "scale-encode", @@ -4881,9 +4922,8 @@ dependencies = [ "scale-value", "serde", "serde_json", - "sp-core", "sp-crypto-hashing", - "sp-runtime", + "subxt-core", "subxt-lightclient", "subxt-macro", "subxt-metadata", @@ -4895,12 +4935,12 @@ dependencies = [ [[package]] name = "subxt-codegen" -version = "0.35.1" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31528ba082daea68850852ecb49e463022b47c14f8031874c73d04ce04d36d05" +checksum = "d703dca0905cc5272d7cc27a4ac5f37dcaae7671acc7fef0200057cc8c317786" dependencies = [ "frame-metadata 16.0.0", - "heck 0.4.1", + "heck 0.5.0", "hex", "jsonrpsee", "parity-scale-codec", @@ -4914,11 +4954,40 @@ dependencies = [ "tokio", ] +[[package]] +name = "subxt-core" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f41eb2e2eea6ed45649508cc735f92c27f1fcfb15229e75f8270ea73177345" +dependencies = [ + "base58", + "blake2", + "derive-where", + "frame-metadata 16.0.0", + "hashbrown 0.14.5", + "hex", + "impl-serde", + "parity-scale-codec", + "primitive-types", + "scale-bits", + "scale-decode", + "scale-encode", + "scale-info", + "scale-value", + "serde", + "serde_json", + "sp-core", + "sp-crypto-hashing", + "sp-runtime", + "subxt-metadata", + "tracing", +] + [[package]] name = "subxt-lightclient" -version = "0.35.1" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e4dc4cf724926d89dadeb26ecba7b8c92a3cabd04f1385ea46a927ef1508b0" +checksum = "9d9406fbdb9548c110803cb8afa750f8b911d51eefdf95474b11319591d225d9" dependencies = [ "futures", "futures-util", @@ -4933,9 +5002,9 @@ dependencies = [ [[package]] name = "subxt-macro" -version = "0.35.1" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4de9eebf532a2d28dea87e04974180842c892ca74b710cc929f3df7d3560e8" +checksum = "1c195f803d70687e409aba9be6c87115b5da8952cd83c4d13f2e043239818fcd" dependencies = [ "darling 0.20.8", "parity-scale-codec", @@ -4948,13 +5017,12 @@ dependencies = [ [[package]] name = "subxt-metadata" -version = "0.35.1" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2ed94dbebe8a093c8990bfced142ac5377a1be8e5e2c8cfa5e0d7dce851289" +checksum = "738be5890fdeff899bbffff4d9c0f244fe2a952fb861301b937e3aa40ebb55da" dependencies = [ - "derive_more", "frame-metadata 16.0.0", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "parity-scale-codec", "scale-info", "sp-crypto-hashing", @@ -5011,18 +5079,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.59" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", @@ -5126,9 +5194,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" dependencies = [ "bytes", "futures-core", @@ -5136,7 +5204,6 @@ dependencies = [ "futures-sink", "pin-project-lite", "tokio", - "tracing", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b2e8ee479..0fd72ce24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,8 @@ tokio = { version = "1.36", features = ["macros", "rt-multi-thread", "sync", "si pin-project-lite = "0.2" # subxt -scale-value = "0.14.1" -subxt = { version = "0.35.1", features = ["substrate-compat"] } +scale-value = "0.16.0" +subxt = { version = "0.37.0", features = ["substrate-compat"] } # polkadot-sdk frame-election-provider-support = "31.0.0" diff --git a/src/commands/emergency_solution.rs b/src/commands/emergency_solution.rs index 581a9f3c0..1e1722a8e 100644 --- a/src/commands/emergency_solution.rs +++ b/src/commands/emergency_solution.rs @@ -23,7 +23,7 @@ use clap::Parser; use codec::Encode; use sp_core::hexdisplay::HexDisplay; use std::io::Write; -use subxt::tx::TxPayload; +use subxt::tx::Payload; #[derive(Debug, Clone, Parser)] #[cfg_attr(test, derive(PartialEq))] @@ -88,7 +88,9 @@ where } let call = epm::set_emergency_result(supports.clone())?; - let encoded_call = call.encode_call_data(&client.chain_api().metadata())?; + let encoded_call = call + .encode_call_data(&client.chain_api().metadata()) + .map_err(|e| Error::Subxt(e.into()))?; let encoded_supports = supports.encode(); // write results to files. diff --git a/src/commands/monitor.rs b/src/commands/monitor.rs index 1d7fda934..f9e416313 100644 --- a/src/commands/monitor.rs +++ b/src/commands/monitor.rs @@ -157,7 +157,7 @@ impl FromStr for SubmissionStrategy { let percent: u32 = percent.parse().map_err(|e| format!("{:?}", e))?; Self::ClaimBetterThan(Perbill::from_percent(percent)) } else { - return Err(s.into()) + return Err(s.into()); }; Ok(res) } @@ -424,7 +424,7 @@ where e, at.number ); - return Err(e) + return Err(e); }, }; @@ -487,7 +487,7 @@ where if let Some(submission) = submission { if &submission.who == us { - return Err(Error::AlreadySubmitted) + return Err(Error::AlreadySubmitted); } } } @@ -503,7 +503,7 @@ async fn ensure_solution_passes_strategy( ) -> Result<(), Error> { // don't care about current scores. if matches!(strategy, SubmissionStrategy::Always) { - return Ok(()) + return Ok(()); } let addr = runtime::storage().election_provider_multi_phase().signed_submission_indices(); @@ -533,19 +533,19 @@ async fn submit_and_watch_solution( ) -> Result<(), Error> { let tx = epm::signed_solution(RawSolution { solution, score, round })?; - // session == epoch - let session_len = client - .chain_api() - .constants() - .at(&runtime::constants().babe().epoch_duration())?; - + // By default we are using the epoch length as the mortality length. + // If that doesn't is available then we just use the default mortality provided by subxt. + // // TODO: https://github.com/paritytech/polkadot-staking-miner/issues/730 // // The extrinsic mortality length is static and it doesn't know when the signed phase ends. - let xt_cfg = DefaultExtrinsicParamsBuilder::default() - .nonce(nonce) - .mortal(at, session_len) - .build(); + let xt_cfg = if let Ok(len) = + client.chain_api().constants().at(&runtime::constants().babe().epoch_duration()) + { + DefaultExtrinsicParamsBuilder::default().nonce(nonce).mortal(at, len).build() + } else { + DefaultExtrinsicParamsBuilder::default().nonce(nonce).build() + }; let xt = client.chain_api().tx().create_signed(&tx, &*signer, xt_cfg).await?; @@ -580,23 +580,25 @@ async fn submit_and_watch_solution( return Err(Error::Other(format!( "No SolutionStored event found at {:?}", in_block.block_hash() - ))) + ))); } }, Listen::Finalized => { - let finalized = tx_progress.wait_for_finalized_success().await?; + let finalized_block = tx_progress.wait_for_finalized().await?; + let block_hash = finalized_block.block_hash(); + let finalized_success = finalized_block.wait_for_success().await?; - let solution_stored = finalized + let solution_stored = finalized_success .find_first::( ); if let Ok(Some(_)) = solution_stored { - log::info!(target: LOG_TARGET, "Finalized at {:?}", finalized.block_hash()); + log::info!(target: LOG_TARGET, "Finalized at {:?}", block_hash); } else { return Err(Error::Other(format!( "No SolutionStored event found at {:?}", - finalized.block_hash() - ))) + block_hash, + ))); } }, }; @@ -659,7 +661,7 @@ async fn dry_run_works(rpc: &RpcClient) -> Result<(), Error> { "dry-run requires a RPC endpoint with `--rpc-methods unsafe`; \ either connect to another RPC endpoint or disable dry-run" .to_string(), - )) + )); } } } diff --git a/src/epm.rs b/src/epm.rs index d74ce57b8..1549e9e09 100644 --- a/src/epm.rs +++ b/src/epm.rs @@ -131,7 +131,7 @@ where let max_weight: Weight = T::MaxWeight::get(); if est_weight.all_lt(max_weight) { - return Ok(Self { state: State { voters, voters_by_stake }, _marker: PhantomData }) + return Ok(Self { state: State { voters, voters_by_stake }, _marker: PhantomData }); } let Some((_, idx)) = voters_by_stake.pop_first() else { break }; @@ -146,7 +146,7 @@ where targets.remove(&rm); } - return Err(Error::Feasibility("Failed to pre-trim weight < T::MaxLength".to_string())) + return Err(Error::Feasibility("Failed to pre-trim weight < T::MaxLength".to_string())); } /// Clone the state and trim it, so it get can be reverted. @@ -156,7 +156,7 @@ where for _ in 0..n { let Some((_, idx)) = voters_by_stake.pop_first() else { - return Err(Error::Feasibility("Failed to pre-trim len".to_string())) + return Err(Error::Feasibility("Failed to pre-trim len".to_string())); }; let rm = voters[idx].0.clone(); @@ -222,7 +222,8 @@ fn read_constant<'a, T: serde::Deserialize<'a>>( .constants() .at(&subxt::dynamic::constant(epm_name, constant)) .map_err(|e| invalid_metadata_error(constant.to_string(), e))? - .to_value()?; + .to_value() + .map_err(|e| Error::Subxt(e.into()))?; scale_value::serde::from_value::<_, T>(val).map_err(|e| { Error::InvalidMetadata(format!("Decoding `{}` failed {}", std::any::type_name::(), e)) @@ -390,7 +391,7 @@ where solution, score, solution_or_snapshot_size, - }) + }); } prometheus::on_trim_attempt(); @@ -513,7 +514,7 @@ fn to_scale_value(val: T) -> Result< let bytes = val.encode(); - decode_as_type(&mut bytes.as_ref(), &ty_id, &types) + decode_as_type(&mut bytes.as_ref(), ty_id, &types) .map(|v| v.remove_context()) .map_err(|e| { Error::DynamicTransaction(format!( diff --git a/src/helpers.rs b/src/helpers.rs index 76d0f69eb..253aab455 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -101,7 +101,7 @@ pub fn kill_main_task_if_critical_err(tx: &tokio::sync::mpsc::UnboundedSender) { Ok(u) => u, Err(e) => { let _ = tx.send(e.into()); - return + return; }, }; @@ -228,10 +228,10 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender) { Ok(u) => u, Err(e) => { let _ = tx.send(e.into()); - return + return; }, }; - continue + continue; }, }; @@ -240,7 +240,7 @@ async fn runtime_upgrade_task(client: ChainClient, tx: oneshot::Sender) { Ok(()) => { if let Err(e) = epm::update_metadata_constants(&client) { let _ = tx.send(e); - return + return; } prometheus::on_runtime_upgrade(); log::info!(target: LOG_TARGET, "upgrade to version: {} successful", version); diff --git a/src/static_types.rs b/src/static_types.rs index 3be783996..00454c1d6 100644 --- a/src/static_types.rs +++ b/src/static_types.rs @@ -119,7 +119,7 @@ pub mod westend { active_voters, desired_targets.try_into().expect("Desired targets < u16::MAX"), ) else { - return Weight::MAX + return Weight::MAX; }; // Mock a RawSolution to get the correct weight without having to do the heavy work. @@ -131,7 +131,7 @@ pub mod westend { if raw.solution.voter_count() != active_voters as usize || raw.solution.unique_targets().len() != desired_targets as usize { - return Weight::MAX + return Weight::MAX; } futures::executor::block_on(epm::runtime_api_solution_weight( @@ -177,7 +177,7 @@ pub mod polkadot { active_voters, desired_targets.try_into().expect("Desired targets < u16::MAX"), ) else { - return Weight::MAX + return Weight::MAX; }; // Mock a RawSolution to get the correct weight without having to do the heavy work. @@ -189,7 +189,7 @@ pub mod polkadot { if raw.solution.voter_count() != active_voters as usize || raw.solution.unique_targets().len() != desired_targets as usize { - return Weight::MAX + return Weight::MAX; } futures::executor::block_on(epm::runtime_api_solution_weight( @@ -235,7 +235,7 @@ pub mod kusama { active_voters, desired_targets.try_into().expect("Desired targets < u16::MAX"), ) else { - return Weight::MAX + return Weight::MAX; }; // Mock a RawSolution to get the correct weight without having to do the heavy work. @@ -247,7 +247,7 @@ pub mod kusama { if raw.solution.voter_count() != active_voters as usize || raw.solution.unique_targets().len() != desired_targets as usize { - return Weight::MAX + return Weight::MAX; } futures::executor::block_on(epm::runtime_api_solution_weight( diff --git a/tests/common.rs b/tests/common.rs index 29693c379..215cc4c03 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -194,7 +194,7 @@ pub async fn wait_for_mined_solution(ws_url: &str) -> anyhow::Result MAX_DURATION_FOR_SUBMIT_SOLUTION { - break + break; } let block = block?; @@ -204,7 +204,7 @@ pub async fn wait_for_mined_solution(ws_url: &str) -> anyhow::Result()? { - return Ok(solution_ev) + return Ok(solution_ev); } } } diff --git a/tests/monitor.rs b/tests/monitor.rs index d77d6856f..d56bc7d9b 100644 --- a/tests/monitor.rs +++ b/tests/monitor.rs @@ -23,7 +23,6 @@ async fn submit_monitor_works_basic() { test_submit_solution(Target::Node(Chain::Westend)).await; } -// TODO: https://github.com/paritytech/polkadot-staking-miner/issues/806 #[tokio::test] #[ignore] async fn default_trimming_works() { @@ -89,7 +88,7 @@ async fn has_trimming_output(miner: &mut KillChildOnDrop) -> bool { } if now.elapsed() > MAX_DURATION_FOR_SUBMIT_SOLUTION { - break + break; } }