From 434dc1d9b8c992c5c71b486f84e550f14d83bc27 Mon Sep 17 00:00:00 2001 From: Nakul Date: Wed, 19 Jul 2023 13:34:48 +0530 Subject: [PATCH] chore: upgraded subxt version (#483) * chore: upgrade subxt dependency to 0.29.0 --- Cargo.lock | 641 ++++++++++++++----------- faucet/src/http.rs | 36 +- oracle/src/feeds/dia.rs | 3 +- runner/Cargo.toml | 2 +- runner/src/runner.rs | 8 +- runtime/Cargo.toml | 9 +- runtime/client/Cargo.toml | 8 +- runtime/src/assets.rs | 2 +- runtime/src/cli.rs | 10 +- runtime/src/error.rs | 25 +- runtime/src/integration/mod.rs | 2 +- runtime/src/lib.rs | 170 ++++--- runtime/src/rpc.rs | 257 +++++----- runtime/src/tests.rs | 27 +- runtime/src/types.rs | 79 ++- runtime/src/utils/account_id.rs | 202 ++++++++ runtime/src/utils/mod.rs | 3 + runtime/src/utils/multi_signature.rs | 48 ++ runtime/src/utils/signer.rs | 71 +++ vault/src/cancellation.rs | 13 +- vault/src/delay.rs | 6 +- vault/src/execution.rs | 31 +- vault/src/issue.rs | 19 +- vault/src/main.rs | 7 +- vault/src/metrics.rs | 7 +- vault/src/redeem.rs | 9 +- vault/src/replace.rs | 12 +- vault/tests/vault_integration_tests.rs | 17 +- 28 files changed, 1097 insertions(+), 627 deletions(-) create mode 100644 runtime/src/utils/account_id.rs create mode 100644 runtime/src/utils/mod.rs create mode 100644 runtime/src/utils/multi_signature.rs create mode 100644 runtime/src/utils/signer.rs diff --git a/Cargo.lock b/Cargo.lock index a8978f815..c021f8596 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -216,7 +216,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -279,9 +279,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" [[package]] name = "approx" @@ -455,7 +455,7 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -466,7 +466,7 @@ checksum = "a564d521dd56509c4c47480d00b80ee55f7e385ae48db5744c67ad50c92d2ebf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -552,6 +552,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" +[[package]] +name = "base58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" + [[package]] name = "base64" version = "0.13.1" @@ -671,7 +677,7 @@ dependencies = [ "serde", "sha2 0.8.2", "sp-core", - "sp-std", + "sp-std 5.0.0", "spin 0.7.1", ] @@ -896,7 +902,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -920,7 +926,7 @@ dependencies = [ "frame-support", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -1005,7 +1011,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.17", + "semver 1.0.18", "serde", "serde_json", "thiserror", @@ -1170,9 +1176,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.11" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1640e5cc7fb47dbb8338fd471b105e7ed6c3cb2aeb00c2e067127ffd3764a05d" +checksum = "3eab9e8ceb9afdade1ab3f0fd8dbce5b1b2f468ad653baf10e771781b2b67b73" dependencies = [ "clap_builder", "clap_derive", @@ -1181,9 +1187,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.11" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98c59138d527eeaf9b53f35a77fcc1fad9d883116070c63d5de1c7dc7b00c72b" +checksum = "9f2763db829349bf00cfc06251268865ed4363b93a943174f638daf3ecdba2cd" dependencies = [ "anstream", "anstyle", @@ -1193,14 +1199,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.2" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8cd2b2a819ad6eec39e8f1d6b53001af1e5469f8c177579cdaeb313115b825f" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -1226,7 +1232,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -1268,7 +1274,7 @@ dependencies = [ "serde", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -1851,7 +1857,7 @@ dependencies = [ "sp-application-crypto", "sp-consensus-aura", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -1867,7 +1873,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", ] @@ -1894,7 +1900,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 5.0.0", "sp-trie", "sp-version", "xcm", @@ -1908,7 +1914,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -1923,7 +1929,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", ] @@ -1942,7 +1948,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-executor", ] @@ -1959,7 +1965,7 @@ dependencies = [ "scale-info", "sp-api", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-trie", "xcm", ] @@ -1981,7 +1987,7 @@ dependencies = [ "sp-inherents", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 5.0.0", "sp-storage", "sp-trie", "tracing", @@ -1996,7 +2002,7 @@ dependencies = [ "futures 0.3.28", "parity-scale-codec", "sp-inherents", - "sp-std", + "sp-std 5.0.0", "sp-timestamp", ] @@ -2012,7 +2018,7 @@ dependencies = [ "polkadot-runtime-common", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-builder", "xcm-executor", @@ -2139,7 +2145,7 @@ dependencies = [ "polkadot-primitives", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -2158,7 +2164,7 @@ dependencies = [ "serde", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "traits", ] @@ -2226,7 +2232,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2243,7 +2249,7 @@ checksum = "81b2dab6991c7ab1572fea8cb049db819b1aeea1e2dac74c0869f244d9f21a7c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2252,8 +2258,18 @@ version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + +[[package]] +name = "darling" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" +dependencies = [ + "darling_core 0.20.3", + "darling_macro 0.20.3", ] [[package]] @@ -2270,17 +2286,42 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "darling_core" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.26", +] + [[package]] name = "darling_macro" version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ - "darling_core", + "darling_core 0.14.4", "quote", "syn 1.0.109", ] +[[package]] +name = "darling_macro" +version = "0.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" +dependencies = [ + "darling_core 0.20.3", + "quote", + "syn 2.0.26", +] + [[package]] name = "dashmap" version = "5.5.0" @@ -2337,7 +2378,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -2426,7 +2467,7 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" dependencies = [ - "darling", + "darling 0.14.4", "proc-macro2", "quote", "syn 1.0.109", @@ -2472,7 +2513,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -2498,7 +2539,7 @@ dependencies = [ "dex-general", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -2517,7 +2558,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -2542,7 +2583,7 @@ dependencies = [ "dex-stable", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -2561,7 +2602,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -2655,7 +2696,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2678,9 +2719,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "519b83cd10f5f6e969625a409f735182bea5558cd8b64c655806ceaae36f1999" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" @@ -2705,9 +2746,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "304e6508efa593091e97a9abbc10f90aa7ca635b6d2784feff3c89d41dd12272" [[package]] name = "ecdsa" @@ -2814,7 +2855,7 @@ dependencies = [ "group 0.13.0", "pkcs8 0.10.2", "rand_core 0.6.4", - "sec1 0.7.2", + "sec1 0.7.3", "subtle", "zeroize", ] @@ -2863,7 +2904,7 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2874,7 +2915,7 @@ checksum = "c9838a970f5de399d3070ae1739e131986b2f5dcc223c7423ca0927e3a878522" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -2979,7 +3020,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -3068,7 +3109,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -3102,7 +3143,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -3194,7 +3235,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "staking", "traits", ] @@ -3393,7 +3434,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-runtime-interface", - "sp-std", + "sp-std 5.0.0", "sp-storage", "static_assertions", ] @@ -3438,7 +3479,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 5.0.0", "sp-storage", "sp-trie", "thiserror", @@ -3453,7 +3494,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -3470,7 +3511,7 @@ dependencies = [ "sp-core", "sp-npos-elections", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -3485,7 +3526,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-tracing", ] @@ -3548,7 +3589,7 @@ dependencies = [ "sp-runtime", "sp-staking", "sp-state-machine", - "sp-std", + "sp-std 5.0.0", "sp-tracing", "sp-weights", "tt-call", @@ -3567,7 +3608,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -3579,7 +3620,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -3589,7 +3630,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -3605,7 +3646,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-version", "sp-weights", ] @@ -3622,7 +3663,7 @@ dependencies = [ "scale-info", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -3643,7 +3684,7 @@ dependencies = [ "parity-scale-codec", "sp-api", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -3762,7 +3803,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -4661,13 +4702,13 @@ dependencies = [ "bitcoin 1.2.0", "bstringify", "parity-scale-codec", - "scale-decode 0.7.0", + "scale-decode", "scale-encode", "scale-info", "serde", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", ] @@ -4818,7 +4859,7 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std", + "sp-std 5.0.0", "sp-transaction-pool", "sp-version", "sp-weights", @@ -4907,7 +4948,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "traits", "vault-registry", ] @@ -4933,7 +4974,7 @@ dependencies = [ "frame-support", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -4947,9 +4988,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b02a5381cc465bd3041d84623d0fa3b66738b52b8e2fc3bab8ad63ab032f4a" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" @@ -5353,7 +5394,7 @@ dependencies = [ "sp-offchain", "sp-runtime", "sp-session", - "sp-std", + "sp-std 5.0.0", "sp-transaction-pool", "sp-version", "sp-weights", @@ -6058,7 +6099,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "traits", ] @@ -6454,7 +6495,7 @@ dependencies = [ "scale-info", "serde", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "traits", ] @@ -6793,7 +6834,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "staking", "traits", "vault-registry", @@ -7056,7 +7097,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -7118,7 +7159,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "staking", "traits", ] @@ -7146,7 +7187,7 @@ dependencies = [ "scale-info", "serde", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7203,7 +7244,7 @@ dependencies = [ "scale-info", "serde", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-builder", "xcm-executor", @@ -7224,7 +7265,7 @@ dependencies = [ "sp-application-crypto", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7240,7 +7281,7 @@ dependencies = [ "serde", "sp-arithmetic", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7258,7 +7299,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", ] @@ -7273,7 +7314,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-std", + "sp-std 5.0.0", "xcm", ] @@ -7288,7 +7329,7 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7303,7 +7344,7 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7315,7 +7356,7 @@ dependencies = [ "orml-traits", "parity-scale-codec", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-executor", ] @@ -7336,7 +7377,7 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-executor", ] @@ -7386,7 +7427,7 @@ dependencies = [ "sp-application-crypto", "sp-consensus-aura", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7402,7 +7443,7 @@ dependencies = [ "sp-application-crypto", "sp-authority-discovery", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7416,7 +7457,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7440,7 +7481,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7459,7 +7500,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-tracing", ] @@ -7475,7 +7516,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7493,7 +7534,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7512,7 +7553,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7529,7 +7570,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7546,7 +7587,7 @@ dependencies = [ "serde", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7564,7 +7605,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7586,7 +7627,7 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "strum", ] @@ -7618,7 +7659,7 @@ dependencies = [ "sp-io", "sp-npos-elections", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7636,7 +7677,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7659,7 +7700,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7675,7 +7716,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7695,7 +7736,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7712,7 +7753,7 @@ dependencies = [ "sp-io", "sp-keyring", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7729,7 +7770,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7745,7 +7786,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7762,7 +7803,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7773,7 +7814,7 @@ dependencies = [ "pallet-nomination-pools", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7790,7 +7831,7 @@ dependencies = [ "serde", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7807,7 +7848,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7822,7 +7863,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7840,7 +7881,7 @@ dependencies = [ "sp-arithmetic", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7856,7 +7897,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-weights", ] @@ -7877,7 +7918,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 5.0.0", "sp-trie", ] @@ -7892,7 +7933,7 @@ dependencies = [ "rand_chacha 0.2.2", "scale-info", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7914,7 +7955,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7925,7 +7966,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -7957,7 +7998,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -7974,7 +8015,7 @@ dependencies = [ "sp-inherents", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-timestamp", ] @@ -7994,7 +8035,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -8010,7 +8051,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -8055,7 +8096,7 @@ dependencies = [ "scale-info", "serde", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -8071,7 +8112,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -8086,7 +8127,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -8101,7 +8142,7 @@ dependencies = [ "scale-info", "sp-api", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -8120,7 +8161,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-executor", ] @@ -8138,7 +8179,7 @@ dependencies = [ "scale-info", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-builder", "xcm-executor", @@ -8271,9 +8312,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" @@ -8331,9 +8372,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73935e4d55e2abf7f130186537b19e7a4abc886a0252380b59248af473a3fc9" +checksum = "0d2d1d55045829d65aad9d389139882ad623b33b904e7c9f1b10c5b8927298e5" dependencies = [ "thiserror", "ucd-trie", @@ -8341,9 +8382,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef623c9bbfa0eedf5a0efba11a5ee83209c326653ca31ff019bec3a95bfff2b" +checksum = "5f94bca7e7a599d89dea5dfa309e217e7906c3c007fb9c3299c40b10d6a315d3" dependencies = [ "pest", "pest_generator", @@ -8351,22 +8392,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e8cba4ec22bada7fc55ffe51e2deb6a0e0db2d0b7ab0b103acc80d2510c190" +checksum = "99d490fe7e8556575ff6911e45567ab95e71617f43781e5c05490dc8d75c965c" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] name = "pest_meta" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0" +checksum = "2674c66ebb4b4d9036012091b537aae5878970d6999f81a265034d85b136b341" dependencies = [ "once_cell", "pest", @@ -8400,7 +8441,7 @@ checksum = "ec2e072ecce94ec471b13398d5402c188e76ac03cf74dd1a975161b23a3f6d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -8677,7 +8718,7 @@ dependencies = [ "scale-info", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -9274,7 +9315,7 @@ dependencies = [ "serde", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -9300,7 +9341,7 @@ dependencies = [ "sp-keystore", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -9412,7 +9453,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 5.0.0", "sp-transaction-pool", "sp-version", "static_assertions", @@ -9461,7 +9502,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 5.0.0", "static_assertions", "xcm", ] @@ -9488,7 +9529,7 @@ dependencies = [ "bs58", "parity-scale-codec", "polkadot-primitives", - "sp-std", + "sp-std 5.0.0", "sp-tracing", ] @@ -9528,7 +9569,7 @@ dependencies = [ "sp-runtime", "sp-session", "sp-staking", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-executor", ] @@ -9723,9 +9764,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d220334a184db82b31b83f5ff093e3315280fb2b6bbc032022b2304a509aab7a" +checksum = "edc55135a600d700580e406b4de0d59cb9ad25e344a3a091a97ded2622ec4ec6" [[package]] name = "ppv-lite86" @@ -9863,14 +9904,14 @@ checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] name = "proc-macro2" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -10087,9 +10128,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.29" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "573015e8ab27661678357f27dc26460738fd2b6c86e46f386fde94cb5d913105" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" dependencies = [ "proc-macro2", ] @@ -10315,7 +10356,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "vault-registry", ] @@ -10340,7 +10381,7 @@ dependencies = [ "frame-support", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -10402,7 +10443,7 @@ checksum = "68bf53dad9b6086826722cdc99140793afd9f62faa14a1ad07eb4f955e7a7216" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -10508,7 +10549,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "vault-registry", ] @@ -10533,7 +10574,7 @@ dependencies = [ "frame-support", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -10600,7 +10641,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -10769,8 +10810,10 @@ version = "1.1.0" dependencies = [ "async-trait", "backoff", + "base58", "bitcoin 1.1.0", "bitcoin 1.2.0", + "blake2", "btc-relay", "cfg-if 1.0.0", "clap", @@ -10788,9 +10831,12 @@ dependencies = [ "prometheus 0.12.0", "rand 0.7.3", "runtime", + "scale-decode", + "scale-encode", "serde", "serde_json", "sp-arithmetic", + "sp-core", "sp-keyring", "sp-runtime", "subxt", @@ -10836,7 +10882,7 @@ dependencies = [ "reward", "security", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "staking", "supply", "traits", @@ -10869,7 +10915,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.17", + "semver 1.0.18", ] [[package]] @@ -10970,9 +11016,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc31bd9b61a32c31f9650d18add92aa83a49ba979c143eefd27fe7177b05bd5f" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "rw-stream-sink" @@ -10987,9 +11033,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe232bdf6be8c8de797b22184ee71118d63780ea42ac85b61d1baa6d3b782ae9" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safe_arch" @@ -11113,7 +11159,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -12062,7 +12108,7 @@ dependencies = [ "serde_json", "sp-core", "sp-io", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -12123,7 +12169,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -12193,18 +12239,6 @@ dependencies = [ "serde", ] -[[package]] -name = "scale-decode" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d823d4be477fc33321f93d08fb6c2698273d044f01362dc27573a750deb7c233" -dependencies = [ - "parity-scale-codec", - "scale-bits", - "scale-info", - "thiserror", -] - [[package]] name = "scale-decode" version = "0.7.0" @@ -12212,6 +12246,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0459d00b0dbd2e765009924a78ef36b2ff7ba116292d732f00eb0ed8e465d15" dependencies = [ "parity-scale-codec", + "primitive-types", "scale-bits", "scale-decode-derive", "scale-info", @@ -12225,7 +12260,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4391f0dfbb6690f035f6d2a15d6a12f88cc5395c36bcc056db07ffa2a90870ec" dependencies = [ - "darling", + "darling 0.14.4", "proc-macro-crate", "proc-macro2", "quote", @@ -12239,6 +12274,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0401b7cdae8b8aa33725f3611a051358d5b32887ecaa0fda5953a775b2d4d76" dependencies = [ "parity-scale-codec", + "primitive-types", + "scale-bits", "scale-encode-derive", "scale-info", "smallvec", @@ -12251,7 +12288,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "316e0fb10ec0fee266822bd641bab5e332a4ab80ef8c5b5ff35e5401a394f5a6" dependencies = [ - "darling", + "darling 0.14.4", "proc-macro-crate", "proc-macro2", "quote", @@ -12286,15 +12323,18 @@ dependencies = [ [[package]] name = "scale-value" -version = "0.6.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a5e7810815bd295da73e4216d1dfbced3c7c7c7054d70fa5f6e4c58123fff4" +checksum = "f2096d36e94ce9bf87d8addb752423b6b19730dc88edd7cc452bb2b90573f7a7" dependencies = [ + "base58", + "blake2", "either", "frame-metadata", "parity-scale-codec", "scale-bits", - "scale-decode 0.4.0", + "scale-decode", + "scale-encode", "scale-info", "serde", "thiserror", @@ -12347,15 +12387,15 @@ checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "scratch" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "764cad9e7e1ca5fe15b552859ff5d96a314e6ed2934f2260168cd5dfa5891409" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" @@ -12405,9 +12445,9 @@ dependencies = [ [[package]] name = "sec1" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0aec48e813d6b90b15f0b8948af3c63483992dee44c03e9930b3eebdabe046e" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct 0.2.0", "der 0.7.7", @@ -12477,7 +12517,7 @@ dependencies = [ "sha2 0.8.2", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -12514,9 +12554,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" +checksum = "b0293b4b29daaf487284529cc2f5675b8e57c61f70167ba415a463651fd6a918" dependencies = [ "serde", ] @@ -12550,14 +12590,14 @@ checksum = "389894603bd18c46fa56231694f8d827779c0951a667087194cf9de94ed24682" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] name = "serde_json" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5062a995d481b2308b6064e9af76011f2921c35f97b0468811ed9f6cd91dfed" +checksum = "d03b412469450d4404fe8499a268edd7f8b79fecb074b0d812ad64ca21f4031b" dependencies = [ "itoa", "ryu", @@ -12633,7 +12673,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -12746,9 +12786,9 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "signal-hook" -version = "0.3.15" +version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732768f1176d21d09e076c23a93123d40bba92d50c4058da34d45c8de8e682b9" +checksum = "b824b6e687aff278cdbf3b36f07aa52d4bd4099699324d5da86a2ebce3aa00b3" dependencies = [ "libc", "signal-hook-registry", @@ -12866,7 +12906,7 @@ dependencies = [ "parity-scale-codec", "paste", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -12958,7 +12998,7 @@ dependencies = [ "sp-metadata-ir", "sp-runtime", "sp-state-machine", - "sp-std", + "sp-std 5.0.0", "sp-trie", "sp-version", "thiserror", @@ -12975,7 +13015,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -12988,7 +13028,7 @@ dependencies = [ "serde", "sp-core", "sp-io", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13001,7 +13041,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-std", + "sp-std 5.0.0", "static_assertions", ] @@ -13015,7 +13055,7 @@ dependencies = [ "sp-api", "sp-application-crypto", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13027,7 +13067,7 @@ dependencies = [ "sp-api", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13077,7 +13117,7 @@ dependencies = [ "sp-consensus-slots", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-timestamp", ] @@ -13098,7 +13138,7 @@ dependencies = [ "sp-inherents", "sp-keystore", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-timestamp", ] @@ -13117,7 +13157,7 @@ dependencies = [ "sp-io", "sp-mmr-primitives", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "strum", ] @@ -13136,7 +13176,7 @@ dependencies = [ "sp-core", "sp-keystore", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13147,7 +13187,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "serde", - "sp-std", + "sp-std 5.0.0", "sp-timestamp", ] @@ -13182,11 +13222,11 @@ dependencies = [ "secp256k1 0.24.3", "secrecy", "serde", - "sp-core-hashing", + "sp-core-hashing 5.0.0", "sp-debug-derive", "sp-externalities", "sp-runtime-interface", - "sp-std", + "sp-std 5.0.0", "sp-storage", "ss58-registry", "substrate-bip39", @@ -13205,7 +13245,22 @@ dependencies = [ "digest 0.10.7", "sha2 0.10.7", "sha3", - "sp-std", + "sp-std 5.0.0", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee599a8399448e65197f9a6cee338ad192e9023e35e31f22382964c3c174c68" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.7", + "sha2 0.10.7", + "sha3", + "sp-std 8.0.0", "twox-hash", ] @@ -13216,8 +13271,8 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "sp-core-hashing", - "syn 2.0.25", + "sp-core-hashing 5.0.0", + "syn 2.0.26", ] [[package]] @@ -13236,7 +13291,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -13246,7 +13301,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "environmental", "parity-scale-codec", - "sp-std", + "sp-std 5.0.0", "sp-storage", ] @@ -13261,7 +13316,7 @@ dependencies = [ "scale-info", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "thiserror", ] @@ -13284,7 +13339,7 @@ dependencies = [ "sp-keystore", "sp-runtime-interface", "sp-state-machine", - "sp-std", + "sp-std 5.0.0", "sp-tracing", "sp-trie", "tracing", @@ -13333,7 +13388,7 @@ dependencies = [ "frame-metadata", "parity-scale-codec", "scale-info", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13350,7 +13405,7 @@ dependencies = [ "sp-core", "sp-debug-derive", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "thiserror", ] @@ -13365,7 +13420,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13416,7 +13471,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-io", - "sp-std", + "sp-std 5.0.0", "sp-weights", ] @@ -13431,7 +13486,7 @@ dependencies = [ "primitive-types", "sp-externalities", "sp-runtime-interface-proc-macro", - "sp-std", + "sp-std 5.0.0", "sp-storage", "sp-tracing", "sp-wasm-interface", @@ -13447,7 +13502,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -13461,7 +13516,7 @@ dependencies = [ "sp-core", "sp-runtime", "sp-staking", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13474,7 +13529,7 @@ dependencies = [ "serde", "sp-core", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13491,7 +13546,7 @@ dependencies = [ "sp-core", "sp-externalities", "sp-panic-handler", - "sp-std", + "sp-std 5.0.0", "sp-trie", "thiserror", "tracing", @@ -13502,6 +13557,12 @@ name = "sp-std" version = "5.0.0" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" +[[package]] +name = "sp-std" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53458e3c57df53698b3401ec0934bea8e8cfce034816873c0b0abbd83d7bac0d" + [[package]] name = "sp-storage" version = "7.0.0" @@ -13512,7 +13573,7 @@ dependencies = [ "ref-cast", "serde", "sp-debug-derive", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13526,7 +13587,7 @@ dependencies = [ "parity-scale-codec", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "thiserror", ] @@ -13536,7 +13597,7 @@ version = "6.0.0" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "parity-scale-codec", - "sp-std", + "sp-std 5.0.0", "tracing", "tracing-core", "tracing-subscriber", @@ -13563,7 +13624,7 @@ dependencies = [ "sp-core", "sp-inherents", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-trie", ] @@ -13583,7 +13644,7 @@ dependencies = [ "scale-info", "schnellru", "sp-core", - "sp-std", + "sp-std 5.0.0", "thiserror", "tracing", "trie-db", @@ -13602,7 +13663,7 @@ dependencies = [ "serde", "sp-core-hashing-proc-macro", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-version-proc-macro", "thiserror", ] @@ -13615,7 +13676,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -13627,7 +13688,7 @@ dependencies = [ "impl-trait-for-tuples", "log", "parity-scale-codec", - "sp-std", + "sp-std 5.0.0", "wasmi", "wasmtime", ] @@ -13644,7 +13705,7 @@ dependencies = [ "sp-arithmetic", "sp-core", "sp-debug-derive", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13736,7 +13797,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -13976,26 +14037,30 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "subxt" -version = "0.25.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3cbc78fd36035a24883eada29e0205b9b1416172530a7d00a60c07d0337db0c" +checksum = "31a734d66fa935fbda56ba6a71d7e969f424c8c5608d416ba8499d71d8cbfc1f" dependencies = [ - "bitvec", + "base58", + "blake2", "derivative", + "either", "frame-metadata", "futures 0.3.28", "getrandom 0.2.10", "hex", + "impl-serde 0.4.0", "jsonrpsee", "parity-scale-codec", - "parking_lot 0.12.1", - "scale-decode 0.4.0", + "primitive-types", + "scale-bits", + "scale-decode", + "scale-encode", "scale-info", "scale-value", "serde", "serde_json", - "sp-core", - "sp-runtime", + "sp-core-hashing 9.0.0", "subxt-macro", "subxt-metadata", "thiserror", @@ -14025,47 +14090,47 @@ dependencies = [ [[package]] name = "subxt-codegen" -version = "0.25.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7722c31febf55eb300c73d977da5d65cfd6fb443419b1185b9abcdd9925fd7be" +checksum = "4e2f231d97c145c564bd544212c0cc0c29c09ff516af199f4ce00c8e055f8138" dependencies = [ - "darling", "frame-metadata", "heck", "hex", "jsonrpsee", "parity-scale-codec", - "proc-macro-error", "proc-macro2", "quote", "scale-info", "subxt-metadata", - "syn 1.0.109", + "syn 2.0.26", + "thiserror", "tokio", ] [[package]] name = "subxt-macro" -version = "0.25.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f64826f2c4ba20e3b2a86ec81a6ae8655ca6b6a4c2a6ccc888b6615efc2df14" +checksum = "e544e41e1c84b616632cd2f86862342868f62e11e4cd9062a9e3dbf5fc871f64" dependencies = [ - "darling", + "darling 0.20.3", "proc-macro-error", "subxt-codegen", - "syn 1.0.109", + "syn 2.0.26", ] [[package]] name = "subxt-metadata" -version = "0.25.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "869af75e23513538ad0af046af4a97b8d684e8d202e35ff4127ee061c1110813" +checksum = "a01ce5044c81db3404d38c56f1e69d72eff72c54e5913c9bba4c0b58d376031f" dependencies = [ "frame-metadata", "parity-scale-codec", "scale-info", - "sp-core", + "sp-core-hashing 9.0.0", + "thiserror", ] [[package]] @@ -14084,7 +14149,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -14100,9 +14165,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.25" +version = "2.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e3fc8c0c74267e2df136e5e5fb656a464158aa57624053375eb9c8c6e25ae2" +checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" dependencies = [ "proc-macro2", "quote", @@ -14240,7 +14305,7 @@ checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -14411,7 +14476,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -14530,9 +14595,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.13" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f8751d9c1b03c6500c387e96f81f815a4f8e72d142d2d4a9ffa6fedd51ddee7" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ "indexmap 2.0.0", "serde", @@ -14603,7 +14668,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -14646,7 +14711,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -14711,7 +14776,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -14894,7 +14959,7 @@ dependencies = [ "parity-scale-codec", "scale-info", "sp-runtime", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -14938,9 +15003,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22049a19f4a68748a168c0fc439f9516686aa045927ff767eca0a85101fb6e73" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -15037,9 +15102,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ "getrandom 0.2.10", ] @@ -15118,7 +15183,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "staking", "traits", ] @@ -15146,7 +15211,7 @@ dependencies = [ "oracle-rpc-runtime-api", "parity-scale-codec", "sp-api", - "sp-std", + "sp-std 5.0.0", ] [[package]] @@ -15271,7 +15336,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", "wasm-bindgen-shared", ] @@ -15305,7 +15370,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -16237,7 +16302,7 @@ dependencies = [ "sp-arithmetic", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "xcm", "xcm-executor", ] @@ -16256,7 +16321,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", - "sp-std", + "sp-std 5.0.0", "sp-weights", "xcm", ] @@ -16269,7 +16334,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] @@ -16288,9 +16353,9 @@ dependencies = [ [[package]] name = "yap" -version = "0.7.2" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc77f52dc9e9b10d55d3f4462c3b7fc393c4f17975d641542833ab2d3bc26ef" +checksum = "e2a7eb6d82a11e4d0b8e6bda8347169aff4ccd8235d039bba7c47482d977dcf7" [[package]] name = "yasna" @@ -16318,7 +16383,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.25", + "syn 2.0.26", ] [[package]] diff --git a/faucet/src/http.rs b/faucet/src/http.rs index d116a642b..a3012ead2 100644 --- a/faucet/src/http.rs +++ b/faucet/src/http.rs @@ -10,8 +10,8 @@ use lazy_static::lazy_static; use parity_scale_codec::{Decode, Encode}; use reqwest::Url; use runtime::{ - AccountId, CollateralBalancesPallet, CurrencyId, Error as RuntimeError, InterBtcParachain, RuntimeCurrencyInfo, - Ss58Codec, TryFromSymbol, VaultRegistryPallet, SS58_PREFIX, + sp_core::crypto::Ss58Codec, AccountId, CollateralBalancesPallet, CurrencyId, Error as RuntimeError, + InterBtcParachain, RuntimeCurrencyInfo, TryFromSymbol, VaultRegistryPallet, SS58_PREFIX, }; use serde::{Deserialize, Deserializer, Serialize}; use std::{net::SocketAddr, time::Duration}; @@ -225,12 +225,13 @@ struct GetSignatureData { } async fn ensure_signature_exists(auth_url: &str, account_id: &AccountId) -> Result<(), Error> { + let account_id = runtime::sp_core::crypto::AccountId32::from(account_id.0); reqwest::get(Url::parse(auth_url)?.join(&account_id.to_ss58check_with_version(SS58_PREFIX.into()))?) .await? .json::() .await? .exists - .then(|| ()) + .then_some(()) .ok_or(Error::SignatureMissing) } @@ -262,7 +263,7 @@ async fn atomic_faucet_funding( let transfers = amounts .into_iter() .map(|AllowanceAmount { symbol, amount }| { - let currency_id = CurrencyId::try_from_symbol(symbol.clone())?; + let currency_id = CurrencyId::try_from_symbol(symbol)?; log::info!( "AccountId: {}, Currency: {:?} Type: {:?}, Amount: {}", account_id, @@ -418,12 +419,12 @@ mod tests { .flat_map(|account_id| { vec![DEFAULT_TESTING_CURRENCY, DEFAULT_GOVERNANCE_CURRENCY] .into_iter() - .map(move |currency_id| (account_id.clone(), 1 << 60, 0, currency_id)) + .map(move |currency_id| (account_id.clone().into(), 1 << 60, 0, currency_id)) }) - .collect(), + .collect::>(), ) .await - .expect("Should endow accounts") + .expect("Should endow accounts"); } async fn set_exchange_rate(client: SubxtClient) { @@ -534,7 +535,7 @@ mod tests { endow_accounts(client.clone()).await; // Bob's account is prefunded with lots of DOT - let bob_account_id: AccountId = AccountKeyring::Bob.to_account_id(); + let bob_account_id: AccountId = AccountKeyring::Bob.to_account_id().into(); let user_allowance: Allowance = vec![ AllowanceAmount::new(DEFAULT_TESTING_CURRENCY.symbol().unwrap(), 100), AllowanceAmount::new(DEFAULT_GOVERNANCE_CURRENCY.symbol().unwrap(), 100), @@ -568,7 +569,7 @@ mod tests { set_exchange_rate(client.clone()).await; endow_accounts(client.clone()).await; - let bob_account_id = AccountKeyring::Bob.to_account_id(); + let bob_account_id: AccountId = AccountKeyring::Bob.to_account_id().into(); let bob_vault_id = VaultId::new( bob_account_id.clone(), DEFAULT_TESTING_CURRENCY, @@ -593,13 +594,14 @@ mod tests { let alice_provider = setup_provider(client.clone(), AccountKeyring::Alice).await; let bob_provider = setup_provider(client.clone(), AccountKeyring::Bob).await; // Drain the amount Bob was prefunded by, so he is eligible to receive Faucet funding - let bob_prefunded_amount = get_multi_currency_balance(&bob_account_id, &user_allowance, &bob_provider).await; + let bob_prefunded_amount = + get_multi_currency_balance(&bob_account_id.clone().into(), &user_allowance, &bob_provider).await; drain_multi_currency(&bob_prefunded_amount, &bob_provider, &drain_account_id, 1) .await .expect("Unable to transfer funds"); let req = FundAccountJsonRpcRequest { - account_id: bob_account_id.clone(), + account_id: bob_account_id.clone().into(), currency_id: DEFAULT_TESTING_CURRENCY, }; fund_account( @@ -614,11 +616,13 @@ mod tests { bob_provider.register_public_key(dummy_public_key()).await.unwrap(); bob_provider.register_vault(&bob_vault_id, 3 * KSM.one()).await.unwrap(); - let bob_funds_before = get_multi_currency_balance(&bob_account_id, &user_allowance, &alice_provider).await; + let bob_funds_before = + get_multi_currency_balance(&bob_account_id.clone().into(), &user_allowance, &alice_provider).await; fund_account(&Arc::from(alice_provider.clone()), req, store, allowance_config) .await .expect("Funding the account failed"); - let bob_funds_after = get_multi_currency_balance(&bob_account_id, &user_allowance, &alice_provider).await; + let bob_funds_after = + get_multi_currency_balance(&bob_account_id.clone().into(), &user_allowance, &alice_provider).await; assert_allowance_emitted(&bob_funds_before, &bob_funds_after, &vault_allowance); } @@ -677,7 +681,7 @@ mod tests { for currency_id in [Token(KINT), Token(KSM)] { kv.clear().unwrap(); - let bob_account_id: AccountId = AccountKeyring::Bob.to_account_id(); + let bob_account_id: AccountId = AccountKeyring::Bob.to_account_id().into(); let bob_vault_id = VaultId::new(bob_account_id.clone(), currency_id, DEFAULT_WRAPPED_CURRENCY); let drain_account_id: AccountId = [3; 32].into(); @@ -709,7 +713,7 @@ mod tests { let bob_funds_before = get_multi_currency_balance(&bob_account_id, &user_allowance, &bob_provider).await; let req = FundAccountJsonRpcRequest { - account_id: bob_account_id.clone(), + account_id: bob_account_id.clone().into(), currency_id, }; @@ -729,7 +733,7 @@ mod tests { set_exchange_rate(client.clone()).await; endow_accounts(client.clone()).await; - let bob_account_id: AccountId = AccountKeyring::Bob.to_account_id(); + let bob_account_id: AccountId = AccountKeyring::Bob.to_account_id().into(); let bob_vault_id = VaultId::new( bob_account_id.clone(), DEFAULT_TESTING_CURRENCY, diff --git a/oracle/src/feeds/dia.rs b/oracle/src/feeds/dia.rs index 7a26047b3..59c3b3ca3 100644 --- a/oracle/src/feeds/dia.rs +++ b/oracle/src/feeds/dia.rs @@ -1,3 +1,4 @@ +#![allow(clippy::single_char_pattern)] use super::{get_http, PriceFeed}; use crate::{config::CurrencyStore, currency::*, Error}; use async_trait::async_trait; @@ -33,7 +34,7 @@ fn extract_response(value: Value) -> Option { fn set_token_path(base: &mut Url, token_path: &str) { let base_path = base.path().trim_end_matches("/"); - let new_path = format!("{}/assetQuotation/{}", base_path, token_path); + let new_path = format!("{base_path}/assetQuotation/{token_path}"); base.set_path(&new_path); } diff --git a/runner/Cargo.toml b/runner/Cargo.toml index 61e22b8fb..28400be4f 100644 --- a/runner/Cargo.toml +++ b/runner/Cargo.toml @@ -24,7 +24,7 @@ signal-hook = "0.3.14" signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"] } futures = "0.3.21" backoff = { version = "0.3.0", features = ["tokio"] } -subxt = "0.25.0" +subxt = { version = "0.29.0", default_features = false, features = ["jsonrpsee-ws"] } sha2 = "0.8.2" [dev-dependencies] diff --git a/runner/src/runner.rs b/runner/src/runner.rs index 9499d38e5..868c99ccf 100644 --- a/runner/src/runner.rs +++ b/runner/src/runner.rs @@ -277,10 +277,12 @@ impl Runner { CURRENT_RELEASES_STORAGE_ITEM, vec![Value::from_bytes(client_type.to_string().as_bytes())], ); - let lookup_bytes = subxt::storage::utils::storage_address_bytes(&storage_address, &subxt_api.metadata())?; + let lookup_bytes = subxt_api.storage().address_bytes(&storage_address)?; let enc_res = subxt_api .storage() - .fetch_raw(&lookup_bytes, None) + .at_latest() + .await? + .fetch_raw(&lookup_bytes) .await? .map(Bytes::from); enc_res @@ -758,7 +760,7 @@ mod tests { &runner, "https://github.com/interlay/interbtc-clients/releases/download/1.17.2/vault-parachain-metadata-kintsugi", ) - .unwrap(); + .unwrap(); assert_eq!(bin_name, "vault-parachain-metadata-kintsugi"); assert_eq!(bin_path, mock_path.join(bin_name)); } diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index a476c8cc4..8dbd196b7 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -31,17 +31,22 @@ url = "2" cfg-if = "1.0" prometheus = { version = "0.12.0", features = ["process"] } lazy_static = "1.4.0" +base58 = { version = "0.2.0" } +blake2 = { version = "0.10.4", default-features = false } +scale-decode = { version = "0.7.0", features = ["derive"] } +scale-encode = { version = "0.3.0", features = ["derive"] } # Substrate dependencies sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } +sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } # Subxt dependencies -subxt = "0.25.0" +subxt = { version = "0.29.0", default_features = false, features = ["jsonrpsee-ws"] } subxt-client = { path = "./client", optional = true } -jsonrpsee = { version = "0.16.2", features = ["async-client", "client-ws-transport", "macros", "jsonrpsee-types", "client", "jsonrpsee-ws-client", "jsonrpsee-client-transport"] } +jsonrpsee = { version = "0.16", features = ["async-client", "client-ws-transport", "macros", "jsonrpsee-types", "client", "jsonrpsee-ws-client", "jsonrpsee-client-transport"] } bitcoin = { path = "../bitcoin" } diff --git a/runtime/client/Cargo.toml b/runtime/client/Cargo.toml index b2cc8ad93..e084b4e5b 100644 --- a/runtime/client/Cargo.toml +++ b/runtime/client/Cargo.toml @@ -15,9 +15,9 @@ keywords = ["parity", "substrate", "blockchain"] tokio = { version = "1.10", features = ["time", "rt-multi-thread"] } futures = { version = "0.3.9", features = ["compat"], package = "futures" } futures01 = { package = "futures", version = "0.1.29" } -jsonrpsee = "0.16.2" -jsonrpsee-types = "0.16.2" -jsonrpsee-core = { version = "0.16.2", features = ["async-client"] } +jsonrpsee = "0.16" +jsonrpsee-types = "0.16" +jsonrpsee-core = { version = "0.16", features = ["async-client"] } log = "0.4.13" serde_json = "1.0.61" @@ -29,4 +29,4 @@ sc-network-common = { git = "https://github.com/paritytech/substrate", branch = sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42", default-features = false } sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.42" } -subxt = "0.25.0" +subxt = { version = "0.29.0", default_features = false, features = ["jsonrpsee-ws"] } \ No newline at end of file diff --git a/runtime/src/assets.rs b/runtime/src/assets.rs index 75d33dce4..1b0fb13ea 100644 --- a/runtime/src/assets.rs +++ b/runtime/src/assets.rs @@ -157,7 +157,7 @@ impl TryFromSymbol for CurrencyId { fn from_lend_token_symbol(symbol: &str) -> Option { let uppercase_symbol = symbol.to_uppercase(); // Does the first character match the lend token prefix? - if uppercase_symbol.as_str().chars().next() == Some(LEND_TOKEN_SYMBOL_PREFIX) { + if uppercase_symbol.as_str().starts_with(LEND_TOKEN_SYMBOL_PREFIX) { return Self::try_from_symbol(uppercase_symbol[1..].to_string()) .ok() .and_then(|underlying_id| LendingAssets::get_lend_token_id(underlying_id).ok()); diff --git a/runtime/src/cli.rs b/runtime/src/cli.rs index 1a1a2fd8d..4b6e6e034 100644 --- a/runtime/src/cli.rs +++ b/runtime/src/cli.rs @@ -4,9 +4,9 @@ use crate::{ InterBtcParachain, InterBtcSigner, }; use clap::Parser; +use sp_core::{sr25519, Pair}; use sp_keyring::AccountKeyring; use std::{collections::HashMap, num::ParseIntError, str::FromStr, time::Duration}; -use subxt::ext::sp_core::{sr25519::Pair, Pair as _}; #[derive(Parser, Debug, Clone)] pub struct ProviderUserOpts { @@ -31,7 +31,7 @@ pub struct ProviderUserOpts { impl ProviderUserOpts { /// Get the key pair and the username, the latter of which is used for wallet selection. - pub fn get_key_pair(&self) -> Result<(Pair, String), Error> { + pub fn get_key_pair(&self) -> Result<(sr25519::Pair, String), Error> { // Load parachain credentials let (pair, user_name) = match ( self.keyfile.as_ref(), // Check if keyfile is provided @@ -66,8 +66,8 @@ impl ProviderUserOpts { /// # Arguments /// /// * `keyuri` - secret phrase to generate pair -fn get_pair_from_phrase(keyuri: &String) -> Result { - Pair::from_string(keyuri, None).map_err(KeyLoadingError::SecretStringError) +fn get_pair_from_phrase(keyuri: &str) -> Result { + sr25519::Pair::from_string(keyuri, None).map_err(KeyLoadingError::SecretStringError) } /// Loads the credentials for the given user from the keyfile @@ -76,7 +76,7 @@ fn get_pair_from_phrase(keyuri: &String) -> Result { /// /// * `file_path` - path to the json file containing the credentials /// * `keyname` - name of the key to get -fn get_credentials_from_file(file_path: &str, keyname: &str) -> Result { +fn get_credentials_from_file(file_path: &str, keyname: &str) -> Result { let file = std::fs::File::open(file_path)?; let reader = std::io::BufReader::new(file); let map: HashMap = serde_json::from_reader(reader)?; diff --git a/runtime/src/error.rs b/runtime/src/error.rs index 790948348..4ad5d6692 100644 --- a/runtime/src/error.rs +++ b/runtime/src/error.rs @@ -8,17 +8,14 @@ use jsonrpsee::{ }; use prometheus::Error as PrometheusError; use serde_json::Error as SerdeJsonError; +use sp_core::crypto::SecretStringError; use std::{array::TryFromSliceError, fmt::Debug, io::Error as IoError, num::TryFromIntError, str::Utf8Error}; -use subxt::{ - error::{DispatchError, ModuleError, TransactionError}, - ext::sp_core::crypto::SecretStringError, -}; +use subxt::error::{DispatchError, TransactionError}; +pub use subxt::{error::RpcError, Error as SubxtError}; use thiserror::Error; use tokio::time::error::Elapsed; use url::ParseError as UrlParseError; -pub use subxt::{error::RpcError, Error as SubxtError}; - #[derive(Error, Debug)] pub enum Error { #[error("Could not get exchange rate info")] @@ -103,7 +100,7 @@ pub enum Error { impl From for Error { fn from(value: module_bitcoin::Error) -> Self { - Self::BitcoinError(format!("{:?}", value)) + Self::BitcoinError(format!("{value:?}")) } } @@ -116,12 +113,12 @@ impl Error { } fn is_module_err(&self, pallet_name: &str, error_name: &str) -> bool { - matches!( - self, - Error::SubxtRuntimeError(SubxtError::Runtime(DispatchError::Module(ModuleError{ - pallet, error, .. - }))) if pallet == pallet_name && error == error_name, - ) + if let Error::SubxtRuntimeError(SubxtError::Runtime(DispatchError::Module(module_error))) = self { + if let Ok(details) = module_error.details() { + return details.pallet.name() == pallet_name && details.variant.name == error_name; + } + } + false } pub fn is_duplicate_block(&self) -> bool { @@ -203,7 +200,7 @@ impl Error { pub fn is_block_hash_not_found_error(&self) -> bool { matches!( self, - Error::SubxtRuntimeError(SubxtError::Transaction(TransactionError::BlockHashNotFound)) + Error::SubxtRuntimeError(SubxtError::Transaction(TransactionError::BlockNotFound)) ) } diff --git a/runtime/src/integration/mod.rs b/runtime/src/integration/mod.rs index db0228f64..e012d5310 100644 --- a/runtime/src/integration/mod.rs +++ b/runtime/src/integration/mod.rs @@ -133,7 +133,7 @@ pub async fn assert_issue( .unwrap(); parachain_rpc - .execute_issue(issue.issue_id, &metadata.proof, &metadata.raw_tx) + .execute_issue(*issue.issue_id, &metadata.proof, &metadata.raw_tx) .await .unwrap(); } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 10b3f4ef3..b7836b7b7 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -18,18 +18,11 @@ mod tests; #[cfg(feature = "testing-utils")] pub mod integration; - -use codec::{Decode, Encode}; -use std::marker::PhantomData; -use subxt::{ - ext::sp_runtime::{generic::Header, traits::BlakeTwo256, MultiSignature}, - subxt, - tx::PolkadotExtrinsicParams, - Config, -}; - +use subxt::config::SubstrateConfig; +pub mod utils; pub use addr::PartialAddress; pub use assets::{AssetRegistry, LendingAssets, RuntimeCurrencyInfo, TryFromSymbol}; +use codec::{Decode, Encode}; pub use error::{Error, SubxtError}; pub use primitives::CurrencyInfo; pub use prometheus; @@ -43,11 +36,11 @@ pub use rpc::{ }; pub use shutdown::{ShutdownReceiver, ShutdownSender}; pub use sp_arithmetic::{traits as FixedPointTraits, FixedI128, FixedPointNumber, FixedU128}; +pub use sp_core; pub use std::collections::btree_set::BTreeSet; -use std::time::Duration; -pub use subxt::ext::sp_core::{self, crypto::Ss58Codec, sr25519::Pair}; +use std::{marker::PhantomData, time::Duration}; +use subxt::{config::polkadot::PolkadotExtrinsicParams, subxt, Config}; pub use types::*; - pub const TX_FEES: u128 = 2000000000; pub const MILLISECS_PER_BLOCK: u64 = 12000; pub const BLOCK_INTERVAL: Duration = Duration::from_millis(MILLISECS_PER_BLOCK); @@ -68,18 +61,51 @@ pub const DISABLE_DIFFICULTY_CHECK: &str = "DisableDifficultyCheck"; subxt( runtime_metadata_path = "metadata-parachain-interlay.scale", derive_for_all_types = "Clone", - derive_for_type(type = "bitcoin::address::PublicKey", derive = "Eq, PartialEq"), - derive_for_type(type = "bitcoin::types::H256Le", derive = "Eq, PartialEq"), - derive_for_type(type = "interbtc_primitives::issue::IssueRequestStatus", derive = "Eq, PartialEq"), - derive_for_type(type = "interbtc_primitives::redeem::RedeemRequestStatus", derive = "Eq, PartialEq"), + derive_for_type(path = "bitcoin::address::PublicKey", derive = "Eq, PartialEq"), + derive_for_type(path = "bitcoin::types::H256Le", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::issue::IssueRequestStatus", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::redeem::RedeemRequestStatus", derive = "Eq, PartialEq"), derive_for_type( - type = "interbtc_primitives::replace::ReplaceRequestStatus", + path = "interbtc_primitives::replace::ReplaceRequestStatus", derive = "Eq, PartialEq" ), - derive_for_type(type = "interbtc_primitives::VaultCurrencyPair", derive = "Eq, PartialEq"), - derive_for_type(type = "interbtc_primitives::VaultId", derive = "Eq, PartialEq"), - derive_for_type(type = "security::types::ErrorCode", derive = "Eq, PartialEq, Ord, PartialOrd"), - derive_for_type(type = "security::types::StatusCode", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::VaultCurrencyPair", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::VaultId", derive = "Eq, PartialEq"), + derive_for_type(path = "security::types::ErrorCode", derive = "Eq, PartialEq, Ord, PartialOrd"), + derive_for_type(path = "security::types::StatusCode", derive = "Eq, PartialEq"), + substitute_type(path = "primitive_types::H256", with = "::subxt::utils::Static"), + substitute_type(path = "primitive_types::U256", with = "::subxt::utils::Static"), + substitute_type(path = "primitive_types::H160", with = "::subxt::utils::Static"), + substitute_type(path = "sp_core::crypto::AccountId32", with = "crate::AccountId"), + substitute_type( + path = "sp_arithmetic::fixed_point::FixedU128", + with = "::subxt::utils::Static" + ), + substitute_type( + path = "sp_arithmetic::per_things::Permill", + with = "::subxt::utils::Static" + ), + substitute_type( + path = "bitcoin::address::Address", + with = "::subxt::utils::Static" + ), + substitute_type(path = "interbtc_primitives::CurrencyId", with = "crate::CurrencyId"), + substitute_type( + path = "frame_support::traits::misc::WrapperKeepOpaque", + with = "::subxt::utils::Static" + ), + substitute_type( + path = "bitcoin::types::BlockHeader", + with = "::subxt::utils::Static<::module_bitcoin::types::BlockHeader>" + ), + substitute_type( + path = "bitcoin::merkle::MerkleProof", + with = "::subxt::utils::Static<::module_bitcoin::merkle::MerkleProof>" + ), + substitute_type( + path = "bitcoin::types::Transaction", + with = "::subxt::utils::Static<::module_bitcoin::types::Transaction>" + ), ) )] #[cfg_attr( @@ -87,60 +113,55 @@ pub const DISABLE_DIFFICULTY_CHECK: &str = "DisableDifficultyCheck"; subxt( runtime_metadata_path = "metadata-parachain-kintsugi.scale", derive_for_all_types = "Clone", - derive_for_type(type = "bitcoin::address::PublicKey", derive = "Eq, PartialEq"), - derive_for_type(type = "bitcoin::types::H256Le", derive = "Eq, PartialEq"), - derive_for_type(type = "interbtc_primitives::issue::IssueRequestStatus", derive = "Eq, PartialEq"), - derive_for_type(type = "interbtc_primitives::redeem::RedeemRequestStatus", derive = "Eq, PartialEq"), + derive_for_type(path = "bitcoin::address::PublicKey", derive = "Eq, PartialEq"), + derive_for_type(path = "bitcoin::types::H256Le", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::issue::IssueRequestStatus", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::redeem::RedeemRequestStatus", derive = "Eq, PartialEq"), derive_for_type( - type = "interbtc_primitives::replace::ReplaceRequestStatus", + path = "interbtc_primitives::replace::ReplaceRequestStatus", derive = "Eq, PartialEq" ), - derive_for_type(type = "interbtc_primitives::VaultCurrencyPair", derive = "Eq, PartialEq"), - derive_for_type(type = "interbtc_primitives::VaultId", derive = "Eq, PartialEq"), - derive_for_type(type = "security::types::ErrorCode", derive = "Eq, PartialEq, Ord, PartialOrd"), - derive_for_type(type = "security::types::StatusCode", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::VaultCurrencyPair", derive = "Eq, PartialEq"), + derive_for_type(path = "interbtc_primitives::VaultId", derive = "Eq, PartialEq"), + derive_for_type(path = "security::types::ErrorCode", derive = "Eq, PartialEq, Ord, PartialOrd"), + derive_for_type(path = "security::types::StatusCode", derive = "Eq, PartialEq"), + substitute_type(path = "primitive_types::H256", with = "::subxt::utils::Static"), + substitute_type(path = "primitive_types::U256", with = "::subxt::utils::Static"), + substitute_type(path = "primitive_types::H160", with = "::subxt::utils::Static"), + substitute_type(path = "sp_core::crypto::AccountId32", with = "crate::AccountId"), + substitute_type( + path = "sp_arithmetic::fixed_point::FixedU128", + with = "::subxt::utils::Static" + ), + substitute_type( + path = "sp_arithmetic::per_things::Permill", + with = "::subxt::utils::Static" + ), + substitute_type( + path = "bitcoin::address::Address", + with = "::subxt::utils::Static" + ), + substitute_type(path = "interbtc_primitives::CurrencyId", with = "crate::CurrencyId"), + substitute_type( + path = "frame_support::traits::misc::WrapperKeepOpaque", + with = "::subxt::utils::Static" + ), + substitute_type( + path = "bitcoin::types::BlockHeader", + with = "::subxt::utils::Static<::module_bitcoin::types::BlockHeader>" + ), + substitute_type( + path = "bitcoin::merkle::MerkleProof", + with = "::subxt::utils::Static<::module_bitcoin::merkle::MerkleProof>" + ), + substitute_type( + path = "bitcoin::types::Transaction", + with = "::subxt::utils::Static<::module_bitcoin::types::Transaction>" + ), ) )] -pub mod metadata { - #[subxt(substitute_type = "BTreeSet")] - use crate::BTreeSet; - - #[subxt(substitute_type = "primitive_types::H256")] - use crate::H256; - - #[subxt(substitute_type = "primitive_types::U256")] - use crate::U256; - - #[subxt(substitute_type = "primitive_types::H160")] - use crate::H160; - - #[subxt(substitute_type = "sp_core::crypto::AccountId32")] - use crate::AccountId; - #[subxt(substitute_type = "sp_arithmetic::fixed_point::FixedU128")] - use crate::FixedU128; - - #[subxt(substitute_type = "sp_arithmetic::per_things::Permill")] - use crate::Ratio; - - #[subxt(substitute_type = "bitcoin::address::Address")] - use crate::BtcAddress; - - #[subxt(substitute_type = "interbtc_primitives::CurrencyId")] - use crate::CurrencyId; - - #[subxt(substitute_type = "frame_support::traits::misc::WrapperKeepOpaque")] - use crate::WrapperKeepOpaque; - - #[subxt(substitute_type = "bitcoin::types::BlockHeader")] - use ::module_bitcoin::types::BlockHeader; - - #[subxt(substitute_type = "bitcoin::merkle::MerkleProof")] - use ::module_bitcoin::merkle::MerkleProof; - - #[subxt(substitute_type = "bitcoin::types::Transaction")] - use ::module_bitcoin::types::Transaction; -} +pub mod metadata {} #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Default, Clone, Decode, Encode)] pub struct WrapperKeepOpaque { @@ -152,14 +173,13 @@ pub struct WrapperKeepOpaque { pub struct InterBtcRuntime; impl Config for InterBtcRuntime { - type Index = Index; - type BlockNumber = BlockNumber; - type Hash = H256; - type Hashing = BlakeTwo256; + type Index = ::Index; + type Hash = ::Hash; type AccountId = AccountId; type Address = Self::AccountId; - type Header = Header; type Signature = MultiSignature; + type Hasher = ::Hasher; + type Header = ::Header; type ExtrinsicParams = PolkadotExtrinsicParams; } diff --git a/runtime/src/rpc.rs b/runtime/src/rpc.rs index 356b81438..d154d364c 100644 --- a/runtime/src/rpc.rs +++ b/runtime/src/rpc.rs @@ -1,3 +1,4 @@ +pub use crate::ShutdownSender; use crate::{ assets::LendingAssets, conn::{new_websocket_client, new_websocket_client_with_retry}, @@ -5,8 +6,6 @@ use crate::{ types::*, AccountId, AssetRegistry, CurrencyId, Error, InterBtcRuntime, InterBtcSigner, RetryPolicy, RichH256Le, SubxtError, }; - -pub use crate::ShutdownSender; use async_trait::async_trait; use codec::{Decode, Encode}; use futures::{future::join_all, stream::StreamExt, FutureExt, SinkExt, Stream}; @@ -17,7 +16,7 @@ use module_bitcoin::{ use module_oracle_rpc_runtime_api::BalanceWrapper; use primitives::UnsignedFixedPoint; use serde_json::Value; -use std::{collections::BTreeSet, future::Future, ops::Range, sync::Arc, time::Duration}; +use std::{future::Future, ops::Range, sync::Arc, time::Duration}; use subxt::{ blocks::ExtrinsicEvents, client::OnlineClient, @@ -26,12 +25,12 @@ use subxt::{ rpc::{rpc_params, RpcClientT}, storage::{address::Yes, StorageAddress}, tx::TxPayload, + utils::Static, }; use tokio::{ sync::RwLock, time::{sleep, timeout}, }; - // timeout before retrying parachain calls (5 minutes) const TRANSACTION_TIMEOUT: Duration = Duration::from_secs(300); @@ -165,11 +164,10 @@ impl InterBtcParachain { pub aux: ImportedAux, } - let head = self.get_finalized_block_hash().await.unwrap(); let _: CreatedBlock = self .api .rpc() - .request("engine_createBlock", rpc_params![true, true, head]) + .request("engine_createBlock", rpc_params![true, true]) .await .expect("failed to create block"); } @@ -206,15 +204,17 @@ impl InterBtcParachain { Self::new(ws_client, signer, shutdown_tx).await } - async fn get_fresh_nonce(&self) -> u32 { + async fn get_fresh_nonce(&self) -> Result { // For getting the nonce, use latest, possibly non-finalized block. // TODO: we might want to wait until the latest block is actually finalized // query account info in order to get the nonce value used for communication - let storage_key = metadata::storage().system().account(&self.account_id); + let storage_key = metadata::storage().system().account(self.get_account_id().clone()); let on_chain_nonce = self .api .storage() - .fetch(&storage_key, None) + .at_latest() + .await? + .fetch(&storage_key) .await .transpose() .and_then(|x| x.ok()) @@ -232,39 +232,30 @@ impl InterBtcParachain { *next_nonce = ret.saturating_add(1); - ret + Ok(ret) } - async fn query_finalized
( - &self, - address: Address, - ) -> Result::Target>, Error> + async fn query_finalized
(&self, address: Address) -> Result, Error> where Address: StorageAddress, { let hash = self.get_finalized_block_hash().await?; - Ok(self.api.storage().fetch(&address, hash).await?) + Ok(self.api.storage().at(hash).fetch(&address).await?) } - async fn query_finalized_or_error
( - &self, - address: Address, - ) -> Result<::Target, Error> + async fn query_finalized_or_error
(&self, address: Address) -> Result where Address: StorageAddress, { self.query_finalized(address).await?.ok_or(Error::StorageItemNotFound) } - async fn query_finalized_or_default
( - &self, - address: Address, - ) -> Result<::Target, Error> + async fn query_finalized_or_default
(&self, address: Address) -> Result where Address: StorageAddress, { let hash = self.get_finalized_block_hash().await?; - Ok(self.api.storage().fetch_or_default(&address, hash).await?) + Ok(self.api.storage().at(hash).fetch_or_default(&address).await?) } /// Gets a copy of the signer with a unique nonce @@ -274,8 +265,8 @@ impl InterBtcParachain { { notify_retry::( || async { - let nonce = self.get_fresh_nonce().await; match timeout(TRANSACTION_TIMEOUT, async { + let nonce = self.get_fresh_nonce().await?; let tx_progress = self .api .tx() @@ -320,12 +311,8 @@ impl InterBtcParachain { .await } - pub async fn get_finalized_block_hash(&self) -> Result, Error> { - if cfg!(feature = "testing-utils") { - Ok(None) - } else { - Ok(Some(self.api.rpc().finalized_head().await?)) - } + pub async fn get_finalized_block_hash(&self) -> Result { + Ok(self.api.rpc().finalized_head().await?) } /// Subscribe to new parachain blocks. @@ -443,11 +430,7 @@ impl InterBtcParachain { while let Some(result) = sub.next().fuse().await { let event_stream = result .iter() - .flat_map(|events| { - events - .iter() - .map(|x| x.and_then(|y| y.as_event::().map_err(|err| err.into()))) - }) + .flat_map(|events| events.iter().map(|x| x.and_then(|y| y.as_event::()))) .filter_map(|x| x.transpose()); for result in event_stream { match result { @@ -478,7 +461,6 @@ impl InterBtcParachain { }, ) .await?; - Ok(()) } @@ -491,7 +473,7 @@ impl InterBtcParachain { #[cfg(test)] pub async fn get_invalid_tx_error(&self, recipient: AccountId) -> Error { let call = metadata::tx().tokens().transfer(recipient, Token(DOT), 100); - let nonce = self.get_fresh_nonce().await; + let nonce = self.get_fresh_nonce().await.unwrap(); self.api .tx() @@ -517,7 +499,7 @@ impl InterBtcParachain { pub async fn get_too_low_priority_error(&self, recipient: AccountId) -> Error { let call = metadata::tx().tokens().transfer(recipient, Token(DOT), 100); - let nonce = self.get_fresh_nonce().await; + let nonce = self.get_fresh_nonce().await.unwrap(); // submit tx but don't watch self.api @@ -571,31 +553,30 @@ impl InterBtcParachain { self.with_unique_signer(metadata::tx().sudo().sudo(batch)).await?; Ok(()) } - #[cfg(test)] fn lending_mock_market_from_id(&self, id: u32) -> metadata::runtime_types::loans::types::Market { use primitives::{Rate, Ratio}; use sp_runtime::FixedPointNumber; metadata::runtime_types::loans::types::Market:: { - close_factor: Ratio::from_percent(50), - collateral_factor: Ratio::from_percent(50), - liquidation_threshold: Ratio::from_percent(55), - liquidate_incentive: Rate::from_inner(Rate::DIV / 100 * 110), + close_factor: Static(Ratio::from_percent(50)), + collateral_factor: Static(Ratio::from_percent(50)), + liquidation_threshold: Static(Ratio::from_percent(55)), + liquidate_incentive: Static(Rate::from_inner(Rate::DIV / 100 * 110)), state: metadata::runtime_types::loans::types::MarketState::Pending, rate_model: metadata::runtime_types::loans::rate_model::InterestRateModel::Jump( metadata::runtime_types::loans::rate_model::JumpModel { - base_rate: Rate::from_inner(Rate::DIV / 100 * 2), - jump_rate: Rate::from_inner(Rate::DIV / 100 * 10), - full_rate: Rate::from_inner(Rate::DIV / 100 * 32), - jump_utilization: Ratio::from_percent(80), + base_rate: Static(Rate::from_inner(Rate::DIV / 100 * 2)), + jump_rate: Static(Rate::from_inner(Rate::DIV / 100 * 10)), + full_rate: Static(Rate::from_inner(Rate::DIV / 100 * 32)), + jump_utilization: Static(Ratio::from_percent(80)), }, ), - reserve_factor: Ratio::from_percent(15), - liquidate_incentive_reserved_factor: Ratio::from_percent(3), + reserve_factor: Static(Ratio::from_percent(15)), + liquidate_incentive_reserved_factor: Static(Ratio::from_percent(3)), supply_cap: 1_000_000_000_000_000_000_000u128, borrow_cap: 1_000_000_000_000_000_000_000u128, - lend_token_id: CurrencyId::LendToken(id), + lend_token_id: LendToken(id), } } @@ -689,7 +670,7 @@ impl InterBtcParachain { |event| async move { for (key, value) in event.values { if let OracleKey::FeeEstimation = key { - let _ = self.fee_rate_update_tx.send(value); + let _ = self.fee_rate_update_tx.send(*value); } } }, @@ -710,16 +691,15 @@ impl InterBtcParachain { hasher: StorageMapHasher, ) -> Result, Error> where - T: Decode + Send + 'static, + T: Decode + Send + 'static + DecodeWithMetadata, U: Decode + Send + 'static, { let head = self.get_finalized_block_hash().await?; - let mut iter = self.api.storage().iter(key_addr, DEFAULT_PAGE_SIZE, head).await?; + let mut iter = self.api.storage().at(head).iter(key_addr, DEFAULT_PAGE_SIZE).await?; let mut ret = Vec::new(); while let Some((key, value)) = iter.next().await? { let raw_key = key.0.clone(); - // last bytes are the raw key let mut key = match hasher { StorageMapHasher::Blake2_128 => Self::strip_blake2_key_prefix(raw_key.as_slice()), @@ -803,7 +783,10 @@ impl UtilFuncs for InterBtcParachain { .await?; let ret = markets .into_iter() - .map(|(underlying_currency_id, market)| (underlying_currency_id, market.lend_token_id)) + .map(|(underlying_currency_id, market)| { + let lend_token_id = market.lend_token_id; + (underlying_currency_id, lend_token_id) + }) .collect(); Ok(ret) } @@ -835,7 +818,7 @@ impl CollateralBalancesPallet for InterBtcParachain { } async fn get_free_balance_for_id(&self, id: AccountId, currency_id: CurrencyId) -> Result { - let storage_key = metadata::storage().tokens().accounts(&id, currency_id); + let storage_key = metadata::storage().tokens().accounts(id.clone(), currency_id); Ok(self.query_finalized_or_default(storage_key).await?.free) } @@ -844,7 +827,7 @@ impl CollateralBalancesPallet for InterBtcParachain { } async fn get_reserved_balance_for_id(&self, id: AccountId, currency_id: CurrencyId) -> Result { - let storage_key = metadata::storage().tokens().accounts(&id, currency_id); + let storage_key = metadata::storage().tokens().accounts(id.clone(), currency_id); Ok(self.query_finalized_or_default(storage_key).await?.reserved) } @@ -977,7 +960,7 @@ impl ReplacePallet for InterBtcParachain { old_vault.clone(), amount_btc, collateral, - btc_address, + Static(btc_address), )) .await?; Ok(()) @@ -985,9 +968,9 @@ impl ReplacePallet for InterBtcParachain { async fn execute_replace(&self, replace_id: H256, merkle_proof: &[u8], raw_tx: &[u8]) -> Result<(), Error> { self.with_unique_signer(metadata::tx().replace().execute_replace( - replace_id, - MerkleProof::parse(merkle_proof)?, - parse_transaction(raw_tx)?, + Static(replace_id), + Static(MerkleProof::parse(merkle_proof)?), + Static(parse_transaction(raw_tx)?), raw_tx.len() as u32, )) .await?; @@ -995,7 +978,7 @@ impl ReplacePallet for InterBtcParachain { } async fn cancel_replace(&self, replace_id: H256) -> Result<(), Error> { - self.with_unique_signer(metadata::tx().replace().cancel_replace(replace_id)) + self.with_unique_signer(metadata::tx().replace().cancel_replace(Static(replace_id))) .await?; Ok(()) } @@ -1005,7 +988,7 @@ impl ReplacePallet for InterBtcParachain { &self, account_id: AccountId, ) -> Result, Error> { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: Vec = self .api .rpc() @@ -1026,7 +1009,7 @@ impl ReplacePallet for InterBtcParachain { &self, account_id: AccountId, ) -> Result, Error> { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: Vec = self .api .rpc() @@ -1048,7 +1031,7 @@ impl ReplacePallet for InterBtcParachain { } async fn get_replace_request(&self, replace_id: H256) -> Result { - self.query_finalized_or_error(metadata::storage().replace().replace_requests(replace_id)) + self.query_finalized_or_error(metadata::storage().replace().replace_requests(Static::from(replace_id))) .await } @@ -1096,12 +1079,13 @@ impl OraclePallet for InterBtcParachain { /// Returns the last exchange rate in planck per satoshis, the time at which it was set /// and the configured max delay. async fn get_exchange_rate(&self, currency_id: CurrencyId) -> Result { - self.query_finalized_or_error( - metadata::storage() - .oracle() - .aggregate(&OracleKey::ExchangeRate(currency_id)), - ) - .await + Ok(*self + .query_finalized_or_error( + metadata::storage() + .oracle() + .aggregate(&OracleKey::ExchangeRate(currency_id)), + ) + .await?) } /// Sets the current exchange rate (i.e. DOT/BTC) @@ -1109,7 +1093,11 @@ impl OraclePallet for InterBtcParachain { /// # Arguments /// * `value` - the current exchange rate async fn feed_values(&self, values: Vec<(OracleKey, FixedU128)>) -> Result<(), Error> { - self.with_unique_signer(metadata::tx().oracle().feed_values(values)) + let converted_values: Vec<(OracleKey, Static)> = values + .iter() + .map(|(key, value)| (key.clone(), Static::from(*value))) + .collect(); + self.with_unique_signer(metadata::tx().oracle().feed_values(converted_values)) .await?; Ok(()) } @@ -1123,7 +1111,7 @@ impl OraclePallet for InterBtcParachain { self.with_unique_signer( metadata::tx() .oracle() - .feed_values(vec![(OracleKey::FeeEstimation, value)]), + .feed_values(vec![(OracleKey::FeeEstimation, Static::from(value))]), ) .await?; Ok(()) @@ -1132,13 +1120,14 @@ impl OraclePallet for InterBtcParachain { /// Gets the estimated Satoshis per bytes required to get a Bitcoin transaction included in /// in the next x blocks async fn get_bitcoin_fees(&self) -> Result { - self.query_finalized_or_error(metadata::storage().oracle().aggregate(&OracleKey::FeeEstimation)) - .await + Ok(*self + .query_finalized_or_error(metadata::storage().oracle().aggregate(&OracleKey::FeeEstimation)) + .await?) } /// Converts the amount in btc to dot, based on the current set exchange rate. async fn wrapped_to_collateral(&self, amount: u128, currency_id: CurrencyId) -> Result { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: BalanceWrapper<_> = self .api .rpc() @@ -1147,13 +1136,12 @@ impl OraclePallet for InterBtcParachain { rpc_params![BalanceWrapper { amount }, currency_id, head], ) .await?; - Ok(result.amount) } /// Converts the amount in dot to btc, based on the current set exchange rate. async fn collateral_to_wrapped(&self, amount: u128, currency_id: CurrencyId) -> Result { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: BalanceWrapper<_> = self .api .rpc() @@ -1182,7 +1170,7 @@ impl OraclePallet for InterBtcParachain { pub trait SecurityPallet { async fn get_parachain_status(&self) -> Result; - async fn get_error_codes(&self) -> Result, Error>; + async fn get_error_codes(&self) -> Result, Error>; /// Gets the current active block number of the parachain async fn get_current_active_block_number(&self) -> Result; @@ -1198,7 +1186,7 @@ impl SecurityPallet for InterBtcParachain { } /// Return any `ErrorCode`s set in the security module. - async fn get_error_codes(&self) -> Result, Error> { + async fn get_error_codes(&self) -> Result, Error> { Ok(self .query_finalized_or_error(metadata::storage().security().errors()) .await? @@ -1248,9 +1236,9 @@ impl IssuePallet for InterBtcParachain { async fn execute_issue(&self, issue_id: H256, merkle_proof: &[u8], raw_tx: &[u8]) -> Result<(), Error> { self.with_unique_signer(metadata::tx().issue().execute_issue( - issue_id, - MerkleProof::parse(merkle_proof)?, - parse_transaction(raw_tx)?, + Static(issue_id), + Static(MerkleProof::parse(merkle_proof)?), + Static(parse_transaction(raw_tx)?), raw_tx.len() as u32, )) .await?; @@ -1258,13 +1246,13 @@ impl IssuePallet for InterBtcParachain { } async fn cancel_issue(&self, issue_id: H256) -> Result<(), Error> { - self.with_unique_signer(metadata::tx().issue().cancel_issue(issue_id)) + self.with_unique_signer(metadata::tx().issue().cancel_issue(Static(issue_id))) .await?; Ok(()) } async fn get_issue_request(&self, issue_id: H256) -> Result { - self.query_finalized_or_error(metadata::storage().issue().issue_requests(issue_id)) + self.query_finalized_or_error(metadata::storage().issue().issue_requests(Static::from(issue_id))) .await } @@ -1272,7 +1260,7 @@ impl IssuePallet for InterBtcParachain { &self, account_id: AccountId, ) -> Result, Error> { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: Vec = self .api .rpc() @@ -1301,7 +1289,7 @@ impl IssuePallet for InterBtcParachain { let head = self.get_finalized_block_hash().await?; let key_addr = metadata::storage().issue().issue_requests_root(); - let mut iter = self.api.storage().iter(key_addr, DEFAULT_PAGE_SIZE, head).await?; + let mut iter = self.api.storage().at(head).iter(key_addr, DEFAULT_PAGE_SIZE).await?; while let Some((issue_id, request)) = iter.next().await? { // todo: we also need to check the bitcoin height @@ -1345,19 +1333,19 @@ impl RedeemPallet for InterBtcParachain { .with_unique_signer( metadata::tx() .redeem() - .request_redeem(amount, btc_address, vault_id.clone()), + .request_redeem(amount, Static(btc_address), vault_id.clone()), ) .await? .find_first::()? .ok_or(Error::RequestRedeemIDNotFound)?; - Ok(redeem_event.redeem_id) + Ok(*redeem_event.redeem_id) } async fn execute_redeem(&self, redeem_id: H256, merkle_proof: &[u8], raw_tx: &[u8]) -> Result<(), Error> { self.with_unique_signer(metadata::tx().redeem().execute_redeem( - redeem_id, - MerkleProof::parse(merkle_proof)?, - parse_transaction(raw_tx)?, + Static(redeem_id), + Static(MerkleProof::parse(merkle_proof)?), + Static(parse_transaction(raw_tx)?), raw_tx.len() as u32, )) .await?; @@ -1365,13 +1353,13 @@ impl RedeemPallet for InterBtcParachain { } async fn cancel_redeem(&self, redeem_id: H256, reimburse: bool) -> Result<(), Error> { - self.with_unique_signer(metadata::tx().redeem().cancel_redeem(redeem_id, reimburse)) + self.with_unique_signer(metadata::tx().redeem().cancel_redeem(Static(redeem_id), reimburse)) .await?; Ok(()) } async fn get_redeem_request(&self, redeem_id: H256) -> Result { - self.query_finalized_or_error(metadata::storage().redeem().redeem_requests(redeem_id)) + self.query_finalized_or_error(metadata::storage().redeem().redeem_requests(Static::from(redeem_id))) .await } @@ -1379,7 +1367,7 @@ impl RedeemPallet for InterBtcParachain { &self, account_id: AccountId, ) -> Result, Error> { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: Vec = self .api .rpc() @@ -1434,14 +1422,16 @@ pub trait BtcRelayPallet { impl BtcRelayPallet for InterBtcParachain { /// Get the hash of the current best tip. async fn get_best_block(&self) -> Result { - self.query_finalized_or_default(metadata::storage().btc_relay().best_block()) - .await + Ok(self + .query_finalized_or_default(metadata::storage().btc_relay().best_block()) + .await?) } /// Get the current best known height. async fn get_best_block_height(&self) -> Result { - self.query_finalized_or_default(metadata::storage().btc_relay().best_block_height()) - .await + Ok(self + .query_finalized_or_default(metadata::storage().btc_relay().best_block_height()) + .await?) } /// Get the block hash for the main chain at the specified height. @@ -1449,8 +1439,9 @@ impl BtcRelayPallet for InterBtcParachain { /// # Arguments /// * `height` - chain height async fn get_block_hash(&self, height: u32) -> Result { - self.query_finalized_or_default(metadata::storage().btc_relay().chains_hashes(0, height)) - .await + Ok(self + .query_finalized_or_default(metadata::storage().btc_relay().chains_hashes(0, height)) + .await?) } /// Get the corresponding block header for the given hash. @@ -1458,8 +1449,9 @@ impl BtcRelayPallet for InterBtcParachain { /// # Arguments /// * `hash` - little endian block hash async fn get_block_header(&self, hash: H256Le) -> Result { - self.query_finalized_or_default(metadata::storage().btc_relay().block_headers(&hash)) - .await + Ok(self + .query_finalized_or_default(metadata::storage().btc_relay().block_headers(&hash)) + .await?) } /// Get the global security parameter k for stable Bitcoin transactions @@ -1499,7 +1491,7 @@ impl BtcRelayPallet for InterBtcParachain { /// check that the block with the given block is included in the main chain of the relay, with sufficient /// confirmations async fn verify_block_header_inclusion(&self, block_hash: H256Le) -> Result<(), Error> { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: Result<(), metadata::DispatchError> = self .api .rpc() @@ -1510,7 +1502,8 @@ impl BtcRelayPallet for InterBtcParachain { .await?; result.map_err(|err| { - let dispatch_error = subxt::error::DispatchError::decode_from(err.encode(), &self.api.metadata()); + let dispatch_error = subxt::error::DispatchError::decode_from(err.encode(), self.api.metadata()) + .unwrap_or(subxt::error::DispatchError::Other); Error::SubxtRuntimeError(SubxtError::Runtime(dispatch_error)) }) } @@ -1528,7 +1521,7 @@ impl BtcRelayPallet for InterBtcParachain { self.with_unique_signer( metadata::tx() .btc_relay() - .initialize(parse_block_header(&header.0)?, height), + .initialize(Static(parse_block_header(&header.0)?), height), ) .await?; Ok(()) @@ -1540,7 +1533,7 @@ impl BtcRelayPallet for InterBtcParachain { /// * `header` - raw block header async fn store_block_header(&self, header: RawBlockHeader) -> Result<(), Error> { self.with_unique_signer(metadata::tx().btc_relay().store_block_header( - parse_block_header(&header.0)?, + Static(parse_block_header(&header.0)?), self.get_chain_counter().await?.saturating_add(1), )) .await?; @@ -1562,7 +1555,7 @@ impl BtcRelayPallet for InterBtcParachain { .into_iter() .map(|block_header| { EncodedCall::BTCRelay(metadata::runtime_types::btc_relay::pallet::Call::store_block_header { - block_header, + block_header: Static(block_header), fork_bound, }) }) @@ -1622,23 +1615,22 @@ impl VaultRegistryPallet for InterBtcParachain { .query_finalized(metadata::storage().vault_registry().vaults(vault_id)) .await? { - Some(InterBtcVault { + Some(InterBtcVaultStatic { status: VaultStatus::Liquidated, .. }) => Err(Error::VaultLiquidated), - Some(vault) if &vault.id == vault_id => Ok(vault), + Some(vault) if &vault.id == vault_id => Ok(vault.into()), _ => Err(Error::VaultNotFound), } } async fn get_vaults_by_account_id(&self, account_id: &AccountId) -> Result, Error> { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result = self .api .rpc() .request("vaultRegistry_getVaultsByAccountId", rpc_params![account_id, head]) .await?; - Ok(result) } @@ -1646,10 +1638,11 @@ impl VaultRegistryPallet for InterBtcParachain { async fn get_all_vaults(&self) -> Result, Error> { let head = self.get_finalized_block_hash().await?; let key_addr = metadata::storage().vault_registry().vaults_root(); - let mut iter = self.api.storage().iter(key_addr, DEFAULT_PAGE_SIZE, head).await?; + let mut iter = self.api.storage().at(head).iter(key_addr, DEFAULT_PAGE_SIZE).await?; let mut vaults = Vec::new(); while let Some((_, account)) = iter.next().await? { + let account: InterBtcVault = account.into(); if let VaultStatus::Active(..) = account.status { vaults.push(account); } @@ -1711,7 +1704,7 @@ impl VaultRegistryPallet for InterBtcParachain { self.query_finalized( metadata::storage() .vault_registry() - .vault_bitcoin_public_key(self.get_account_id()), + .vault_bitcoin_public_key(self.get_account_id().clone()), ) .await } @@ -1735,7 +1728,7 @@ impl VaultRegistryPallet for InterBtcParachain { amount_btc: u128, collateral_currency: CurrencyId, ) -> Result { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: BalanceWrapper<_> = self .api .rpc() @@ -1751,7 +1744,7 @@ impl VaultRegistryPallet for InterBtcParachain { /// Get the amount of collateral required for the given vault to be at the /// current SecureCollateralThreshold with the current exchange rate async fn get_required_collateral_for_vault(&self, vault_id: VaultId) -> Result { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: BalanceWrapper<_> = self .api .rpc() @@ -1760,12 +1753,11 @@ impl VaultRegistryPallet for InterBtcParachain { rpc_params![vault_id, head], ) .await?; - Ok(result.amount) } async fn get_vault_total_collateral(&self, vault_id: VaultId) -> Result { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: BalanceWrapper<_> = self .api .rpc() @@ -1776,7 +1768,7 @@ impl VaultRegistryPallet for InterBtcParachain { } async fn get_collateralization_from_vault(&self, vault_id: VaultId, only_issued: bool) -> Result { - let head = self.get_finalized_block_hash().await?; + let head = Some(self.get_finalized_block_hash().await?); let result: UnsignedFixedPoint = self .api .rpc() @@ -1785,7 +1777,6 @@ impl VaultRegistryPallet for InterBtcParachain { rpc_params![vault_id, only_issued, head], ) .await?; - Ok(result.into_inner()) } @@ -1797,7 +1788,7 @@ impl VaultRegistryPallet for InterBtcParachain { async fn set_current_client_release(&self, uri: &[u8], checksum: &H256) -> Result<(), Error> { let release = ClientRelease { uri: BoundedVec(uri.to_vec()), - checksum: *checksum, + checksum: Static(*checksum), }; // TODO: uri should be client name self.with_unique_signer( @@ -1817,7 +1808,7 @@ impl VaultRegistryPallet for InterBtcParachain { async fn set_pending_client_release(&self, uri: &[u8], checksum: &H256) -> Result<(), Error> { let release = ClientRelease { uri: BoundedVec(uri.to_vec()), - checksum: *checksum, + checksum: Static(*checksum), }; self.with_unique_signer( metadata::tx() @@ -1839,18 +1830,21 @@ pub trait FeePallet { #[async_trait] impl FeePallet for InterBtcParachain { async fn get_issue_griefing_collateral(&self) -> Result { - self.query_finalized_or_error(metadata::storage().fee().issue_griefing_collateral()) - .await + Ok(*self + .query_finalized_or_error(metadata::storage().fee().issue_griefing_collateral()) + .await?) } async fn get_issue_fee(&self) -> Result { - self.query_finalized_or_error(metadata::storage().fee().issue_fee()) - .await + Ok(*self + .query_finalized_or_error(metadata::storage().fee().issue_fee()) + .await?) } async fn get_replace_griefing_collateral(&self) -> Result { - self.query_finalized_or_error(metadata::storage().fee().replace_griefing_collateral()) - .await + Ok(*self + .query_finalized_or_error(metadata::storage().fee().replace_griefing_collateral()) + .await?) } } @@ -1876,9 +1870,8 @@ impl SudoPallet for InterBtcParachain { } async fn set_storage(&self, module: &str, key: &str, value: V) -> Result<(), Error> { - let module = subxt::ext::sp_core::twox_128(module.as_bytes()); - let item = subxt::ext::sp_core::twox_128(key.as_bytes()); - + let module = sp_core::twox_128(module.as_bytes()); + let item = sp_core::twox_128(key.as_bytes()); Ok(self .sudo(EncodedCall::System( metadata::runtime_types::frame_system::pallet::Call::set_storage { diff --git a/runtime/src/tests.rs b/runtime/src/tests.rs index 66acfea9e..42d075013 100644 --- a/runtime/src/tests.rs +++ b/runtime/src/tests.rs @@ -7,7 +7,10 @@ use super::{ OraclePallet, RawBlockHeader, ReplacePallet, SecurityPallet, StatusCode, SudoPallet, Token, TryFromSymbol, VaultRegistryPallet, KBTC, KINT, KSM, }; -use crate::{integration::*, FeedValuesEvent, OracleKey, RuntimeCurrencyInfo, VaultId, H160, U256}; +use crate::{ + integration::*, utils_accountid::AccountId32, AccountId, FeedValuesEvent, OracleKey, RuntimeCurrencyInfo, VaultId, + H160, U256, +}; use module_bitcoin::{formatter::TryFormat, types::BlockBuilder}; pub use primitives::CurrencyId::ForeignAsset; use primitives::CurrencyId::LendToken; @@ -56,19 +59,25 @@ async fn test_getters() { #[tokio::test(flavor = "multi_thread")] async fn test_invalid_tx_matching() { + let bob_keyring = AccountKeyring::Bob; + let bob_substrate_account = bob_keyring.to_account_id(); + let bob = AccountId32(bob_substrate_account.clone().into()); + let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Alice).await; - let err = parachain_rpc.get_invalid_tx_error(AccountKeyring::Bob.into()).await; + let err = parachain_rpc.get_invalid_tx_error(bob.into()).await; assert!(err.is_invalid_transaction().is_some()) } #[tokio::test(flavor = "multi_thread")] async fn test_too_low_priority_matching() { + let bob_keyring = AccountKeyring::Bob; + let bob_substrate_account = bob_keyring.to_account_id(); + let bob = AccountId32(bob_substrate_account.clone().into()); + let (client, _tmp_dir) = default_provider_client(AccountKeyring::Alice).await; let parachain_rpc = setup_provider(client.clone(), AccountKeyring::Alice).await; - let err = parachain_rpc - .get_too_low_priority_error(AccountKeyring::Bob.into()) - .await; + let err = parachain_rpc.get_too_low_priority_error(bob.into()).await; assert!(err.is_pool_too_low_priority().is_some()) } @@ -106,7 +115,7 @@ async fn test_register_vault() { set_exchange_rate(client.clone()).await; parachain_rpc .set_balances(vec![( - AccountKeyring::Alice.to_account_id(), + AccountKeyring::Alice.to_account_id().into(), 1 << 60, 0, DEFAULT_TESTING_CURRENCY, @@ -114,7 +123,11 @@ async fn test_register_vault() { .await .expect("Should endow account"); - let vault_id = VaultId::new(AccountKeyring::Alice.into(), Token(KSM), Token(KBTC)); + let alice_keyring = AccountKeyring::Alice; + let alice_substrate_account = alice_keyring.to_account_id(); + let alice = AccountId32(alice_substrate_account.clone().into()); + + let vault_id = VaultId::new(alice.into(), Token(KSM), Token(KBTC)); parachain_rpc.register_public_key(dummy_public_key()).await.unwrap(); parachain_rpc.register_vault(&vault_id, 3 * KSM.one()).await.unwrap(); diff --git a/runtime/src/types.rs b/runtime/src/types.rs index 10fa6083f..b59e1ea40 100644 --- a/runtime/src/types.rs +++ b/runtime/src/types.rs @@ -1,35 +1,33 @@ -use crate::{metadata, Config, InterBtcRuntime, RuntimeCurrencyInfo, SS58_PREFIX}; +pub use crate::utils::{account_id as utils_accountid, multi_signature}; +use crate::{metadata, utils::signer::PairSigner, Config, InterBtcRuntime, RuntimeCurrencyInfo}; +pub use currency_id::CurrencyIdExt; +pub use h256_le::RichH256Le; pub use metadata_aliases::*; -pub use subxt::ext::sp_core::{crypto::Ss58Codec, sr25519::Pair as KeyPair}; -use subxt::{ - metadata::DecodeStaticType, - storage::{address::Yes, StaticStorageAddress}, -}; - +pub use module_btc_relay::{RichBlockHeader, MAIN_CHAIN_ID}; pub use primitives::{ CurrencyId, CurrencyId::{ForeignAsset, LendToken, Token}, TokenSymbol::{self, DOT, IBTC, INTR, KBTC, KINT, KSM}, }; +pub use sp_core::sr25519::Pair as KeyPair; +pub use subxt; +use subxt::storage::{address::Yes, Address}; -pub use currency_id::CurrencyIdExt; -pub use h256_le::RichH256Le; -pub use module_btc_relay::{RichBlockHeader, MAIN_CHAIN_ID}; - -pub type AccountId = subxt::ext::sp_runtime::AccountId32; +pub type AccountId = utils_accountid::AccountId32; +pub type MultiSignature = multi_signature::MultiSignature; pub type Balance = primitives::Balance; pub type Index = u32; pub type BlockNumber = u32; -pub type H160 = subxt::ext::sp_core::H160; -pub type H256 = subxt::ext::sp_core::H256; -pub type U256 = subxt::ext::sp_core::U256; +pub type H160 = sp_core::H160; +pub type H256 = sp_core::H256; +pub type U256 = sp_core::U256; pub type Ratio = primitives::Ratio; -pub type InterBtcSigner = subxt::tx::PairSigner; +pub type InterBtcSigner = PairSigner; pub type BtcAddress = module_btc_relay::BtcAddress; -pub type FixedU128 = sp_arithmetic::FixedU128; +pub type FixedU128 = crate::FixedU128; #[allow(non_camel_case_types)] pub(crate) enum StorageMapHasher { @@ -39,8 +37,8 @@ pub(crate) enum StorageMapHasher { mod metadata_aliases { use super::*; - pub use metadata::runtime_types::bitcoin::address::PublicKey as BtcPublicKey; + use subxt::{storage::address::StaticStorageMapKey, utils::Static}; pub use metadata::runtime_types::interbtc_primitives::oracle::Key as OracleKey; @@ -50,6 +48,46 @@ mod metadata_aliases { }; pub type InterBtcVault = metadata::runtime_types::vault_registry::types::Vault; + pub type InterBtcVaultStatic = metadata::runtime_types::vault_registry::types::Vault< + AccountId, + BlockNumber, + Balance, + CurrencyId, + Static, + >; + + impl From for InterBtcVault { + fn from(val: InterBtcVaultStatic) -> Self { + let InterBtcVaultStatic { + id, + status, + banned_until, + secure_collateral_threshold, + to_be_issued_tokens, + issued_tokens, + to_be_redeemed_tokens, + to_be_replaced_tokens, + replace_collateral, + active_replace_collateral, + liquidated_collateral, + } = val; + + InterBtcVault { + id, + status, + banned_until, + secure_collateral_threshold: secure_collateral_threshold.map(|static_value| *static_value), + to_be_issued_tokens, + issued_tokens, + to_be_redeemed_tokens, + to_be_replaced_tokens, + replace_collateral, + active_replace_collateral, + liquidated_collateral, + } + } + } + pub type InterBtcRichBlockHeader = metadata::runtime_types::btc_relay::types::RichBlockHeader; pub type BitcoinBlockHeight = u32; @@ -89,7 +127,7 @@ mod metadata_aliases { }; pub type AssetMetadata = GenericAssetMetadata; pub type LendingMarket = metadata::runtime_types::loans::types::Market; - pub type KeyStorageAddress = StaticStorageAddress, (), (), Yes>; + pub type KeyStorageAddress = Address; pub use metadata::runtime_types::{ btc_relay::pallet::Error as BtcRelayPalletError, frame_system::pallet::Error as SystemPalletError, @@ -173,10 +211,9 @@ pub trait PrettyPrint { mod account_id { use super::*; - impl PrettyPrint for AccountId { fn pretty_print(&self) -> String { - self.to_ss58check_with_version(SS58_PREFIX.into()) + self.to_ss58check() } } } diff --git a/runtime/src/utils/account_id.rs b/runtime/src/utils/account_id.rs new file mode 100644 index 000000000..700b515c2 --- /dev/null +++ b/runtime/src/utils/account_id.rs @@ -0,0 +1,202 @@ +//! The "default" Substrate/Polkadot AccountId. This is used in codegen, as well as signing related bits. +//! This doesn't contain much functionality itself, but is easy to convert to/from an `sp_core::AccountId32`. +//! The `sp_core::AccountId32` doesn't contain EncodeAsType and DecodeAsType traits hence added a +//! custom implementation. +use base58::{FromBase58, ToBase58}; +use blake2::{Blake2b512, Digest}; +use codec::{Decode, Encode}; +use serde::{Deserialize, Serialize}; +use std::convert::TryInto; +/// A 32-byte cryptographic identifier. This is a simplified version of Substrate's +/// `sp_core::crypto::AccountId32`. To obtain more functionality, convert this into +/// that type. +#[derive( + Hash, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Encode, + Decode, + Debug, + scale_encode::EncodeAsType, + scale_decode::DecodeAsType, + Default, +)] +pub struct AccountId32(pub [u8; 32]); + +impl AsRef<[u8]> for AccountId32 { + fn as_ref(&self) -> &[u8] { + &self.0[..] + } +} + +impl AsRef<[u8; 32]> for AccountId32 { + fn as_ref(&self) -> &[u8; 32] { + &self.0 + } +} + +impl From<[u8; 32]> for AccountId32 { + fn from(x: [u8; 32]) -> Self { + AccountId32(x) + } +} + +impl AccountId32 { + pub fn new(value: [u8; 32]) -> Self { + AccountId32(value) + } + // Return the ss58-check string for this key. Adapted from `sp_core::crypto`. + pub fn to_ss58check(&self) -> String { + // We mask out the upper two bits of the ident - SS58 Prefix currently only supports 14-bits + let ident: u16 = crate::SS58_PREFIX & 0b0011_1111_1111_1111; + let mut v = match ident { + 0..=63 => vec![ident as u8], + 64..=16_383 => { + // upper six bits of the lower byte(!) + let first = ((ident & 0b0000_0000_1111_1100) as u8) >> 2; + // lower two bits of the lower byte in the high pos, + // lower bits of the upper byte in the low pos + let second = ((ident >> 8) as u8) | ((ident & 0b0000_0000_0000_0011) as u8) << 6; + vec![first | 0b01000000, second] + } + _ => unreachable!("masked out the upper two bits; qed"), + }; + v.extend::<&[u8]>(self.as_ref()); + let r = ss58hash(&v); + v.extend(&r[0..2]); + v.to_base58() + } + + // This isn't strictly needed, but to give our AccountId32 a little more usefulness, we also + // implement the logic needed to decode an AccountId32 from an SS58 encoded string. This is exposed + // via a `FromStr` impl. + fn from_ss58check(s: &str) -> Result { + const CHECKSUM_LEN: usize = 2; + let body_len = 32; + + let data = s.from_base58().map_err(|_| FromSs58Error::BadBase58)?; + if data.len() < 2 { + return Err(FromSs58Error::BadLength); + } + let prefix_len = match data[0] { + 0..=63 => 1, + 64..=127 => 2, + _ => return Err(FromSs58Error::InvalidPrefix), + }; + if data.len() != prefix_len + body_len + CHECKSUM_LEN { + return Err(FromSs58Error::BadLength); + } + let hash = ss58hash(&data[0..body_len + prefix_len]); + let checksum = &hash[0..CHECKSUM_LEN]; + if data[body_len + prefix_len..body_len + prefix_len + CHECKSUM_LEN] != *checksum { + // Invalid checksum. + return Err(FromSs58Error::InvalidChecksum); + } + let result = data[prefix_len..body_len + prefix_len] + .try_into() + .map_err(|_| FromSs58Error::BadLength)?; + Ok(AccountId32(result)) + } +} + +/// An error obtained from trying to interpret an SS58 encoded string into an AccountId32 +#[derive(thiserror::Error, Clone, Copy, Eq, PartialEq, Debug)] +#[allow(missing_docs)] +pub enum FromSs58Error { + #[error("Base 58 requirement is violated")] + BadBase58, + #[error("Length is bad")] + BadLength, + #[error("Invalid checksum")] + InvalidChecksum, + #[error("Invalid SS58 prefix byte.")] + InvalidPrefix, +} + +// We do this just to get a checksum to help verify the validity of the address in to_ss58check +fn ss58hash(data: &[u8]) -> Vec { + const PREFIX: &[u8] = b"SS58PRE"; + let mut ctx = Blake2b512::new(); + ctx.update(PREFIX); + ctx.update(data); + ctx.finalize().to_vec() +} + +impl Serialize for AccountId32 { + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + serializer.serialize_str(&self.to_ss58check()) + } +} + +impl<'de> Deserialize<'de> for AccountId32 { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + AccountId32::from_ss58check(&String::deserialize(deserializer)?) + .map_err(|e| serde::de::Error::custom(format!("{e:?}"))) + } +} + +impl std::fmt::Display for AccountId32 { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "{}", self.to_ss58check()) + } +} + +impl std::str::FromStr for AccountId32 { + type Err = FromSs58Error; + fn from_str(s: &str) -> Result { + AccountId32::from_ss58check(s) + } +} + +impl From for AccountId32 { + fn from(value: sp_runtime::AccountId32) -> Self { + Self(value.into()) + } +} +impl From for AccountId32 { + fn from(value: sp_core::sr25519::Public) -> Self { + let acc: sp_runtime::AccountId32 = value.into(); + acc.into() + } +} +impl From for AccountId32 { + fn from(value: sp_core::ed25519::Public) -> Self { + let acc: sp_runtime::AccountId32 = value.into(); + acc.into() + } +} + +impl From for AccountId32 { + fn from(account: sp_keyring::Sr25519Keyring) -> Self { + let account = account.to_account_id(); + AccountId32(account.into()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::SS58_PREFIX; + use sp_core::crypto::Ss58Codec; + use sp_keyring::AccountKeyring; + use sp_runtime::AccountId32 as SpAccountId; + + #[test] + fn test_alice_account_conversion_to_ss58() { + let alice_utils_account_id: AccountId32 = AccountKeyring::Alice.to_account_id().into(); + let alice_sp_account_id: SpAccountId = AccountKeyring::Alice.to_account_id(); + assert_eq!( + alice_sp_account_id.to_ss58check_with_version(SS58_PREFIX.into()), + alice_utils_account_id.to_ss58check() + ); + } +} diff --git a/runtime/src/utils/mod.rs b/runtime/src/utils/mod.rs new file mode 100644 index 000000000..133a16096 --- /dev/null +++ b/runtime/src/utils/mod.rs @@ -0,0 +1,3 @@ +pub mod account_id; +pub mod multi_signature; +pub mod signer; diff --git a/runtime/src/utils/multi_signature.rs b/runtime/src/utils/multi_signature.rs new file mode 100644 index 000000000..5f7f2794e --- /dev/null +++ b/runtime/src/utils/multi_signature.rs @@ -0,0 +1,48 @@ +//! The "default" Substrate/Polkadot Signature type. This is used in codegen, as well as signing related bits. +//! This doesn't contain much functionality itself, but is easy to convert to/from an `sp_runtime::MultiSignature` +//! Custom implementation needed because as it feature gated by subxt `substrate-compat` feature +//! flag. +use codec::{Decode, Encode}; + +/// Signature container that can store known signature types. This is a simplified version of +/// `sp_runtime::MultiSignature`. To obtain more functionality, convert this into that type. +#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, Debug)] +pub enum MultiSignature { + /// An Ed25519 signature. + Ed25519([u8; 64]), + /// An Sr25519 signature. + Sr25519([u8; 64]), + /// An ECDSA/SECP256k1 signature (a 512-bit value, plus 8 bits for recovery ID). + Ecdsa([u8; 65]), +} + +impl From for MultiSignature { + fn from(value: sp_runtime::MultiSignature) -> Self { + match value { + sp_runtime::MultiSignature::Ed25519(s) => Self::Ed25519(s.0), + sp_runtime::MultiSignature::Sr25519(s) => Self::Sr25519(s.0), + sp_runtime::MultiSignature::Ecdsa(s) => Self::Ecdsa(s.0), + } + } +} + +impl From for MultiSignature { + fn from(value: sp_core::ed25519::Signature) -> Self { + let sig: sp_runtime::MultiSignature = value.into(); + sig.into() + } +} + +impl From for MultiSignature { + fn from(value: sp_core::sr25519::Signature) -> Self { + let sig: sp_runtime::MultiSignature = value.into(); + sig.into() + } +} + +impl From for MultiSignature { + fn from(value: sp_core::ecdsa::Signature) -> Self { + let sig: sp_runtime::MultiSignature = value.into(); + sig.into() + } +} diff --git a/runtime/src/utils/signer.rs b/runtime/src/utils/signer.rs new file mode 100644 index 000000000..c5e030a45 --- /dev/null +++ b/runtime/src/utils/signer.rs @@ -0,0 +1,71 @@ +//! A signer suitable for substrate based chains. This provides compatibility with Substrate +//! packages like sp_keyring and such, and so relies on sp_core and sp_runtime to be included. +//! Custom implementation needed because as it feature gated by subxt `substrate-compat` feature +//! flag. +use crate::Config; +use sp_core::Pair as PairT; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + AccountId32 as SpAccountId32, MultiSignature as SpMultiSignature, +}; + +use subxt::tx::Signer; + +/// A [`Signer`] implementation that can be constructed from an [`sp_core::Pair`]. +#[derive(Clone, Debug)] +pub struct PairSigner { + account_id: T::AccountId, + pub signer: Pair, +} + +impl PairSigner +where + T: Config, + Pair: PairT, + // We go via an sp_runtime::MultiSignature. We can probably generalise this + // by implementing some of these traits on our built-in MultiSignature and then + // requiring them on all T::Signatures, to avoid any go-between. + ::Signer: From, + T::AccountId: From, +{ + /// Creates a new [`Signer`] from an [`sp_core::Pair`]. + pub fn new(signer: Pair) -> Self + where + ::AccountId: From, + { + let account_id = ::Signer::from(signer.public()).into_account(); + Self { + account_id: account_id.into(), + signer, + } + } + + /// Returns the [`sp_core::Pair`] implementation used to construct this. + pub fn signer(&self) -> &Pair { + &self.signer + } + + /// Return the account ID. + pub fn account_id(&self) -> &T::AccountId { + &self.account_id + } +} + +impl Signer for PairSigner +where + T: Config, + Pair: PairT, + Pair::Signature: Into, +{ + fn account_id(&self) -> &T::AccountId { + &self.account_id + } + + fn address(&self) -> T::Address { + self.account_id.clone().into() + } + + fn sign(&self, signer_payload: &[u8]) -> T::Signature { + self.signer.sign(signer_payload).into() + } +} diff --git a/vault/src/cancellation.rs b/vault/src/cancellation.rs index e9c41f439..fcb7d8628 100644 --- a/vault/src/cancellation.rs +++ b/vault/src/cancellation.rs @@ -4,12 +4,10 @@ use async_trait::async_trait; use futures::{channel::mpsc::Receiver, *}; use runtime::{ AccountId, BlockNumber, Error as RuntimeError, IssuePallet, IssueRequestStatus, ReplacePallet, - ReplaceRequestStatus, SecurityPallet, UtilFuncs, + ReplaceRequestStatus, SecurityPallet, UtilFuncs, H256, }; use std::marker::{Send, Sync}; -use runtime::H256; - pub enum Event { /// new issue requested / replace accepted Opened, @@ -320,8 +318,9 @@ mod tests { use futures::channel::mpsc; use jsonrpc_core::serde_json::{Map, Value}; use runtime::{ - AccountId, AssetMetadata, BtcAddress, BtcPublicKey, CurrencyId, ErrorCode, InterBtcIssueRequest, - InterBtcReplaceRequest, IssueRequestStatus, RequestIssueEvent, StatusCode, Token, VaultId, DOT, IBTC, INTR, + subxt::utils::Static, AccountId, AssetMetadata, BtcAddress, BtcPublicKey, CurrencyId, ErrorCode, + InterBtcIssueRequest, InterBtcReplaceRequest, IssueRequestStatus, RequestIssueEvent, StatusCode, Token, + VaultId, DOT, IBTC, INTR, }; use std::collections::BTreeSet; @@ -379,7 +378,7 @@ mod tests { #[async_trait] pub trait SecurityPallet { async fn get_parachain_status(&self) -> Result; - async fn get_error_codes(&self) -> Result, RuntimeError>; + async fn get_error_codes(&self) -> Result, RuntimeError>; async fn get_current_active_block_number(&self) -> Result; } } @@ -394,7 +393,7 @@ mod tests { fn default_issue_request() -> InterBtcIssueRequest { InterBtcIssueRequest { amount: Default::default(), - btc_address: Default::default(), + btc_address: Static(Default::default()), btc_height: Default::default(), fee: Default::default(), griefing_collateral: Default::default(), diff --git a/vault/src/delay.rs b/vault/src/delay.rs index c10171513..bb58c6909 100644 --- a/vault/src/delay.rs +++ b/vault/src/delay.rs @@ -1,6 +1,8 @@ use async_trait::async_trait; use bitcoin::{sha256, Hash}; -use runtime::{AccountId, Error as RuntimeError, InterBtcParachain, UtilFuncs, VaultRegistryPallet}; +use runtime::{ + sp_core::crypto::AccountId32, AccountId, Error as RuntimeError, InterBtcParachain, UtilFuncs, VaultRegistryPallet, +}; use std::fmt; #[async_trait] @@ -48,7 +50,7 @@ impl RandomDelay for OrderedVaultsDelay { /// * `data` - the seed used as a basis for the ordering (for example, an issue_id) async fn delay(&self, seed_data: &[u8; 32]) -> Result<(), RuntimeError> { fn hash_vault(data: &[u8; 32], account_id: &AccountId) -> sha256::Hash { - let account_id: [u8; 32] = account_id.clone().into(); + let account_id: [u8; 32] = AccountId32::from(account_id.0).into(); let xor = data.zip(account_id).map(|(a, b)| a ^ b); sha256::Hash::hash(&xor) } diff --git a/vault/src/execution.rs b/vault/src/execution.rs index 07763f22d..95e5d0f14 100644 --- a/vault/src/execution.rs +++ b/vault/src/execution.rs @@ -111,7 +111,7 @@ impl Request { )?), btc_height: Some(request.btc_height), amount: request.amount_btc, - btc_address: request.btc_address, + btc_address: *request.btc_address, request_type: RequestType::Redeem, vault_id: request.vault, fee_budget: Some(request.transfer_fee_btc), @@ -134,7 +134,7 @@ impl Request { )?), btc_height: Some(request.btc_height), amount: request.amount, - btc_address: request.btc_address, + btc_address: *request.btc_address, request_type: RequestType::Replace, vault_id: request.old_vault, fee_budget: None, @@ -189,18 +189,19 @@ impl Request { auto_rbf, ) .await?; + let _ = update_bitcoin_metrics(&vault, tx_metadata.fee, self.fee_budget).await; self.execute(parachain_rpc, tx_metadata).await } /// Make a bitcoin transfer to fulfil the request #[tracing::instrument( - name = "transfer_btc", - skip(self, parachain_rpc, btc_rpc), - fields( - request_type = ?self.request_type, - request_id = ?self.hash, - ) + name = "transfer_btc", + skip(self, parachain_rpc, btc_rpc), + fields( + request_type = ?self.request_type, + request_id = ?self.hash, + ) )] async fn transfer_btc( &self, @@ -230,12 +231,12 @@ impl Request { } #[tracing::instrument( - name = "wait_for_inclusion", - skip(self, parachain_rpc, btc_rpc), - fields( - request_type = ?self.request_type, - request_id = ?self.hash, - ) + name = "wait_for_inclusion", + skip(self, parachain_rpc, btc_rpc), + fields( + request_type = ?self.request_type, + request_id = ?self.hash, + ) )] async fn wait_for_inclusion< P: OraclePallet + BtcRelayPallet + VaultRegistryPallet + UtilFuncs + Clone + Send + Sync, @@ -758,7 +759,7 @@ mod tests { #[async_trait] pub trait SecurityPallet { async fn get_parachain_status(&self) -> Result; - async fn get_error_codes(&self) -> Result, RuntimeError>; + async fn get_error_codes(&self) -> Result, RuntimeError>; async fn get_current_active_block_number(&self) -> Result; } diff --git a/vault/src/issue.rs b/vault/src/issue.rs index 4fff0ed0f..15f5c04de 100644 --- a/vault/src/issue.rs +++ b/vault/src/issue.rs @@ -32,7 +32,7 @@ pub(crate) async fn initialize_issue_set( }; for (issue_id, request) in requests.into_iter() { - issue_set.insert(issue_id, request.btc_address); + issue_set.insert(issue_id, *request.btc_address); } Ok(btc_start_height) @@ -384,17 +384,17 @@ pub async fn listen_for_issue_requests( let _ = publish_expected_bitcoin_balance(&vault, btc_parachain.clone()).await; - if let Err(e) = add_new_deposit_key(&vault.btc_rpc, event.issue_id, event.vault_public_key).await { - tracing::error!("Failed to add new deposit key #{}: {}", event.issue_id, e.to_string()); + if let Err(e) = add_new_deposit_key(&vault.btc_rpc, *event.issue_id, event.vault_public_key).await { + tracing::error!("Failed to add new deposit key #{}: {}", *event.issue_id, e.to_string()); } } tracing::trace!( "watching issue #{} for payment to {:?}", - event.issue_id, + *event.issue_id, event.vault_address ); - issue_set.insert(event.issue_id, event.vault_address).await; + issue_set.insert(*event.issue_id, *event.vault_address).await; }, |error| tracing::error!("Error reading request issue event: {}", error.to_string()), ) @@ -425,10 +425,10 @@ pub async fn listen_for_issue_executes( tracing::info!("Received execute issue event: {:?}", event); // try to send the event, but ignore the returned result since // the only way it can fail is if the channel is closed - let _ = event_channel.clone().send(Event::Executed(event.issue_id)).await; + let _ = event_channel.clone().send(Event::Executed(*event.issue_id)).await; } - tracing::trace!("issue #{} executed, no longer watching", event.issue_id); + tracing::trace!("issue #{} executed, no longer watching", *event.issue_id); issue_set.remove(&event.issue_id).await; }, |error| tracing::error!("Error reading execute issue event: {}", error.to_string()), @@ -451,7 +451,7 @@ pub async fn listen_for_issue_cancels( btc_parachain .on_event::( |event| async move { - tracing::trace!("issue #{} cancelled, no longer watching", event.issue_id); + tracing::trace!("issue #{} cancelled, no longer watching", *event.issue_id); issue_set.remove(&event.issue_id).await; }, |error| tracing::error!("Error reading cancel issue event: {}", error.to_string()), @@ -464,6 +464,7 @@ pub async fn listen_for_issue_cancels( mod tests { use super::*; use runtime::{ + subxt::utils::Static, AccountId, CurrencyId::Token, TokenSymbol::{DOT, IBTC, INTR}, @@ -476,7 +477,7 @@ mod tests { opentime, btc_height: btc_height as u32, amount: Default::default(), - btc_address: Default::default(), + btc_address: Static(Default::default()), fee: Default::default(), griefing_collateral: Default::default(), griefing_currency: Token(INTR), diff --git a/vault/src/main.rs b/vault/src/main.rs index f29493034..70dfa6c6a 100644 --- a/vault/src/main.rs +++ b/vault/src/main.rs @@ -1,7 +1,10 @@ use bitcoin::{Network, PrivateKey}; use clap::Parser; use futures::Future; -use runtime::{sp_core::crypto::Pair, InterBtcSigner, KeyPair, Ss58Codec, DEFAULT_SPEC_NAME, SS58_PREFIX}; +use runtime::{ + sp_core::crypto::{Pair, Ss58Codec}, + InterBtcSigner, KeyPair, DEFAULT_SPEC_NAME, SS58_PREFIX, +}; use secp256k1::{rand::thread_rng, SecretKey}; use service::{warp, warp::Filter, ConnectionManager, Error as ServiceError, MonitoringConfig, ServiceConfig}; use signal_hook::consts::*; @@ -258,7 +261,7 @@ mod tests { #[tokio::test] async fn test_vault_pid_file() { - let dummy_account_id = AccountId::new(Default::default()); + let dummy_account_id = AccountId::default(); let dummy_spec_name = "kintsugi".to_string(); let termination_signals = &[SIGHUP, SIGTERM, SIGINT, SIGQUIT]; let mut sys = System::new_all(); diff --git a/vault/src/metrics.rs b/vault/src/metrics.rs index 5bae2cade..30a469989 100644 --- a/vault/src/metrics.rs +++ b/vault/src/metrics.rs @@ -679,6 +679,7 @@ mod tests { use jsonrpc_core::serde_json::{Map, Value}; use runtime::{ metadata::runtime_types::interbtc_primitives::CustomMetadata, + subxt::utils::Static, AccountId, AssetMetadata, AssetRegistry, Balance, BlockNumber, BtcAddress, BtcPublicKey, CurrencyId::{self, ForeignAsset, LendToken}, Error as RuntimeError, ErrorCode, InterBtcIssueRequest, InterBtcRedeemRequest, InterBtcReplaceRequest, @@ -769,7 +770,7 @@ mod tests { pub trait SecurityPallet { async fn get_parachain_status(&self) -> Result; - async fn get_error_codes(&self) -> Result, RuntimeError>; + async fn get_error_codes(&self) -> Result, RuntimeError>; /// Gets the current active block number of the parachain async fn get_current_active_block_number(&self) -> Result; @@ -953,7 +954,7 @@ mod tests { fn dummy_issue_request(status: IssueRequestStatus, vault: VaultId) -> InterBtcIssueRequest { InterBtcIssueRequest { amount: Default::default(), - btc_address: Default::default(), + btc_address: Static(Default::default()), btc_height: Default::default(), fee: Default::default(), griefing_collateral: Default::default(), @@ -970,7 +971,7 @@ mod tests { fn dummy_redeem_request(status: RedeemRequestStatus, vault: VaultId) -> InterBtcRedeemRequest { InterBtcRedeemRequest { amount_btc: Default::default(), - btc_address: Default::default(), + btc_address: Static(Default::default()), btc_height: Default::default(), fee: Default::default(), transfer_fee_btc: Default::default(), diff --git a/vault/src/redeem.rs b/vault/src/redeem.rs index 0cf99dae6..2aa542887 100644 --- a/vault/src/redeem.rs +++ b/vault/src/redeem.rs @@ -2,7 +2,6 @@ use crate::{execution::*, metrics::publish_expected_bitcoin_balance, system::Vau use runtime::{InterBtcParachain, RedeemPallet, RequestRedeemEvent}; use service::{spawn_cancelable, Error as ServiceError, ShutdownSender}; use std::time::Duration; - /// Listen for RequestRedeemEvent directed at this vault; upon reception, transfer /// bitcoin and call execute_redeem /// @@ -41,8 +40,8 @@ pub async fn listen_for_redeem_requests( tracing::info!("Executing redeem #{:?}", event.redeem_id); let result = async { let request = Request::from_redeem_request( - event.redeem_id, - parachain_rpc.get_redeem_request(event.redeem_id).await?, + *event.redeem_id, + parachain_rpc.get_redeem_request(*event.redeem_id).await?, payment_margin, )?; request @@ -54,12 +53,12 @@ pub async fn listen_for_redeem_requests( match result { Ok(_) => tracing::info!( "Completed redeem request #{} with amount {}", - event.redeem_id, + *event.redeem_id, event.amount ), Err(e) => tracing::error!( "Failed to process redeem request #{}: {}", - event.redeem_id, + *event.redeem_id, e.to_string() ), } diff --git a/vault/src/replace.rs b/vault/src/replace.rs index cbb373de9..c3f9ef465 100644 --- a/vault/src/replace.rs +++ b/vault/src/replace.rs @@ -51,8 +51,8 @@ pub async fn listen_for_accept_replace( let result = async { let request = Request::from_replace_request( - event.replace_id, - parachain_rpc.get_replace_request(event.replace_id).await?, + *event.replace_id, + parachain_rpc.get_replace_request(*event.replace_id).await?, payment_margin, )?; request @@ -64,12 +64,12 @@ pub async fn listen_for_accept_replace( match result { Ok(_) => tracing::info!( "Completed accept replace request #{} with amount {}", - event.replace_id, + *event.replace_id, event.amount ), Err(e) => tracing::error!( "Failed to process accept replace request #{}: {}", - event.replace_id, + *event.replace_id, e.to_string() ), } @@ -192,10 +192,10 @@ pub async fn listen_for_execute_replace( .on_event::( |event| async move { if &event.new_vault_id.account_id == parachain_rpc.get_account_id() { - tracing::info!("Received event: execute replace #{:?}", event.replace_id); + tracing::info!("Received event: execute replace #{:?}", *event.replace_id); // try to send the event, but ignore the returned result since // the only way it can fail is if the channel is closed - let _ = event_channel.clone().send(Event::Executed(event.replace_id)).await; + let _ = event_channel.clone().send(Event::Executed(*event.replace_id)).await; } }, |error| tracing::error!("Error reading redeem event: {}", error.to_string()), diff --git a/vault/tests/vault_integration_tests.rs b/vault/tests/vault_integration_tests.rs index c20c49e7d..1ed336cd6 100644 --- a/vault/tests/vault_integration_tests.rs +++ b/vault/tests/vault_integration_tests.rs @@ -9,9 +9,12 @@ use futures::{ use runtime::{ integration::*, sp_core::{H160, H256}, + subxt::utils::Static, types::*, + utils::account_id::AccountId32, BtcAddress, CurrencyId, FixedPointNumber, FixedU128, InterBtcParachain, InterBtcRedeemRequest, IssuePallet, - PartialAddress, RedeemPallet, ReplacePallet, ShutdownSender, SudoPallet, UtilFuncs, VaultId, VaultRegistryPallet, + OraclePallet, PartialAddress, RedeemPallet, ReplacePallet, ShutdownSender, SudoPallet, UtilFuncs, VaultId, + VaultRegistryPallet, }; use service::DynBitcoinCoreApi; use sp_keyring::AccountKeyring; @@ -47,9 +50,9 @@ where .flat_map(|account_id| { vec![DEFAULT_TESTING_CURRENCY, DEFAULT_NATIVE_CURRENCY] .into_iter() - .map(move |currency_id| (account_id.clone(), 1 << 60, 0, currency_id)) + .map(move |currency_id| (account_id.clone().into(), 1 << 60, 0, currency_id)) }) - .collect(), + .collect::>(), ) .await .expect("Should endow accounts"); @@ -582,7 +585,7 @@ async fn test_issue_overpayment_succeeds() { } }), user_provider - .execute_issue(issue.issue_id, &metadata.proof, &metadata.raw_tx) + .execute_issue(*issue.issue_id, &metadata.proof, &metadata.raw_tx) .map(Result::unwrap), ) .await; @@ -921,7 +924,7 @@ async fn assert_redeem_event( parachain_rpc: InterBtcParachain, redeem_id: H256, ) -> ExecuteRedeemEvent { - assert_event::(duration, parachain_rpc, |x| x.redeem_id == redeem_id).await + assert_event::(duration, parachain_rpc, |x| x.redeem_id == Static(redeem_id)).await } #[async_trait] @@ -1017,7 +1020,7 @@ mod test_with_bitcoind { .unwrap(); parachain_rpc - .execute_issue(issue.issue_id, &metadata.proof, &metadata.raw_tx) + .execute_issue(*issue.issue_id, &metadata.proof, &metadata.raw_tx) .await .unwrap(); } @@ -1082,7 +1085,7 @@ mod test_with_bitcoind { tracing::trace!("Step 4: mine bitcoin block"); let block_hash = btc_rpc.mine_block().unwrap(); - tracing::trace!("Step 5: check that tx got included without changes"); + tracing::info!("Step 5: check that tx got included without changes"); btc_rpc .get_transaction(&initial_tx.txid(), Some(block_hash)) .await