diff --git a/Cargo.lock b/Cargo.lock index 6f88e07a41..0a232f29b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,11 +23,11 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.19.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ - "gimli 0.27.3", + "gimli 0.28.0", ] [[package]] @@ -172,18 +172,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "aho-corasick" -version = "1.0.2" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" dependencies = [ "memchr", ] @@ -287,9 +278,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -297,9 +288,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.71" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "approx" @@ -359,7 +350,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.27", ] [[package]] @@ -375,7 +366,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.27", ] [[package]] @@ -427,9 +418,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-channel" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener", @@ -450,7 +441,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.20", + "rustix 0.37.23", "slab", "socket2 0.4.9", "waker-fn", @@ -458,9 +449,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa24f727524730b077666307f2734b4a1a1c57acb79193127dcc8914d5242dd7" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ "event-listener", ] @@ -473,31 +464,31 @@ checksum = "0e97ce7de6cf12de5d7226c73f5ba9811622f4db3a5b91b55c53e987e5f91cba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] name = "async-trait" -version = "0.1.68" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] name = "asynchronous-codec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a0daa378f5fd10634e44b0a29b2a87b890657658e072a30d6f26e57ddee182" +checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" dependencies = [ "bytes", "futures-sink", "futures-util", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", ] [[package]] @@ -555,16 +546,16 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ - "addr2line 0.19.0", + "addr2line 0.21.0", "cc", "cfg-if", "libc", - "miniz_oxide 0.6.2", - "object 0.30.4", + "miniz_oxide", + "object 0.32.0", "rustc-demangle", ] @@ -649,7 +640,7 @@ version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cexpr", "clang-sys", "lazy_static", @@ -739,6 +730,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bitvec" version = "1.0.1" @@ -768,7 +765,7 @@ checksum = "3c2f0dc9a68c6317d884f97cc36cf5a3d20ba14ce404227df55e1af708ab04bc" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq", + "constant_time_eq 0.2.6", ] [[package]] @@ -779,20 +776,20 @@ checksum = "6637f448b9e61dfadbdcbae9a885fadee1f3eaffb1f8d3c1965d3ade8bdfd44f" dependencies = [ "arrayref", "arrayvec 0.7.4", - "constant_time_eq", + "constant_time_eq 0.2.6", ] [[package]] name = "blake3" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b71f35bd3fa1a4c86b85d32c8b9069ea7fe14f7a53cfabb65f62d4265b888" +checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5" dependencies = [ "arrayref", "arrayvec 0.7.4", "cc", "cfg-if", - "constant_time_eq", + "constant_time_eq 0.3.0", "digest 0.10.7", ] @@ -880,9 +877,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5" +checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" dependencies = [ "memchr", "serde", @@ -996,18 +993,18 @@ dependencies = [ [[package]] name = "camino" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" dependencies = [ "serde", ] [[package]] name = "cargo-platform" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" +checksum = "2cfa25e60aea747ec7e1124f238816749faa93759c6ff5b31f1ccdda137f4479" dependencies = [ "serde", ] @@ -1020,7 +1017,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.17", + "semver 1.0.18", "serde", "serde_json", "thiserror", @@ -1028,11 +1025,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -1179,9 +1177,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.9" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba77a07e4489fb41bd90e8d4201c3eb246b3c2c9ea2ba0bddd6c1d1df87db7d" +checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" dependencies = [ "clap_builder", "clap_derive", @@ -1190,27 +1188,26 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.3.9" +version = "4.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9b4a88bb4bc35d3d6f65a21b0f0bafe9c894fa00978de242c555ec28bea1c0" +checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex", "strsim", ] [[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.22", + "syn 2.0.29", ] [[package]] @@ -1245,7 +1242,7 @@ version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -1337,9 +1334,9 @@ dependencies = [ [[package]] name = "const-oid" -version = "0.9.2" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520fbf3c07483f94e3e3ca9d0cfd913d7718ef2483d2cfd91c0d9e91474ab913" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "constant_time_eq" @@ -1347,6 +1344,12 @@ version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21a53c0a4d288377e7415b53dcfc3c04da5cdc2cc95c8d5ac178b58f0b861ad6" +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + [[package]] name = "convert_case" version = "0.4.0" @@ -1408,9 +1411,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" dependencies = [ "libc", ] @@ -1946,7 +1949,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -2231,23 +2234,36 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.0.0-rc.1" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d4ba9852b42210c7538b75484f9daa0655e9a3ac04f693747bb0f02cf3cfe16" +checksum = "f711ade317dd348950a9910f81c5947e3d8907ebd2b83f76203ff1807e6a2bc2" dependencies = [ "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", "fiat-crypto", - "packed_simd_2", "platforms 3.0.2", + "rustc_version", "subtle", "zeroize", ] +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + [[package]] name = "cxx" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88abab2f5abbe4c56e8f1fb431b784d710b709888f35755a160e62e33fe38e8" +checksum = "28403c86fc49e3401fdf45499ba37fad6493d9329449d6449d7f0e10f4654d28" dependencies = [ "cc", "cxxbridge-flags", @@ -2257,9 +2273,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c0c11acd0e63bae27dcd2afced407063312771212b7a823b4fd72d633be30fb" +checksum = "78da94fef01786dc3e0c76eafcd187abcaa9972c78e05ff4041e24fdf059c285" dependencies = [ "cc", "codespan-reporting", @@ -2267,24 +2283,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] name = "cxxbridge-flags" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3816ed957c008ccd4728485511e3d9aaf7db419aa321e3d2c5a2f3411e36c8" +checksum = "e2a6f5e1dfb4b34292ad4ea1facbfdaa1824705b231610087b00b17008641809" [[package]] name = "cxxbridge-macro" -version = "1.0.97" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26acccf6f445af85ea056362561a24ef56cdc15fcc685f03aec50b9c702cb6d" +checksum = "50c49547d73ba8dcfd4ad7325d64c6d5391ff4224d498fc39a6f3f49825a530d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -2383,9 +2399,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.6" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56acb310e15652100da43d130af8d97b509e95af61aab1c5a7939ef24337ee17" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ "const-oid", "zeroize", @@ -2419,6 +2435,12 @@ dependencies = [ "rusticata-macros", ] +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" + [[package]] name = "derivative" version = "2.2.0" @@ -2692,7 +2714,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -2715,9 +2737,9 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" [[package]] name = "dtoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65d09067bfacaa79114679b279d7f5885b53295b1e2cfb4e79c8e4bd3d633169" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" [[package]] name = "dyn-clonable" @@ -2742,9 +2764,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" +checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" [[package]] name = "ecdsa" @@ -2760,11 +2782,11 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.7" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0997c976637b606099b9985693efa3581e84e41f5c11ba5255f88711058ad428" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ - "der 0.7.6", + "der 0.7.8", "digest 0.10.7", "elliptic-curve 0.13.5", "rfc6979 0.4.0", @@ -2811,9 +2833,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" dependencies = [ "serde", ] @@ -2854,7 +2876,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", ] @@ -2894,18 +2916,18 @@ checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] name = "enumn" -version = "0.1.8" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" +checksum = "b893c4eb2dc092c811165f84dc7447fae16fb66521717968c34c509b39b1a5c5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -2942,15 +2964,15 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "equivalent" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", @@ -3176,7 +3198,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -3224,6 +3246,12 @@ dependencies = [ "instant", ] +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + [[package]] name = "fatality" version = "0.0.6" @@ -3252,7 +3280,7 @@ dependencies = [ [[package]] name = "fc-consensus" version = "2.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "async-trait", "fp-consensus", @@ -3268,7 +3296,7 @@ dependencies = [ [[package]] name = "fc-db" version = "2.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "async-trait", "ethereum", @@ -3298,7 +3326,7 @@ dependencies = [ [[package]] name = "fc-mapping-sync" version = "2.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "fc-db", "fc-storage", @@ -3321,7 +3349,7 @@ dependencies = [ [[package]] name = "fc-rpc" version = "2.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "ethereum", "ethereum-types", @@ -3371,7 +3399,7 @@ dependencies = [ [[package]] name = "fc-rpc-core" version = "1.1.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "ethereum", "ethereum-types", @@ -3384,7 +3412,7 @@ dependencies = [ [[package]] name = "fc-storage" version = "1.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "ethereum", "ethereum-types", @@ -3474,13 +3502,13 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.2.16", + "redox_syscall 0.3.5", "windows-sys 0.48.0", ] @@ -3530,13 +3558,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide 0.7.1", + "miniz_oxide", ] [[package]] @@ -3601,7 +3629,7 @@ dependencies = [ [[package]] name = "fp-account" version = "1.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "hex", "impl-serde 0.4.0", @@ -3620,7 +3648,7 @@ dependencies = [ [[package]] name = "fp-consensus" version = "2.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "ethereum", "parity-scale-codec", @@ -3632,7 +3660,7 @@ dependencies = [ [[package]] name = "fp-ethereum" version = "1.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "ethereum", "ethereum-types", @@ -3646,7 +3674,7 @@ dependencies = [ [[package]] name = "fp-evm" version = "3.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "evm", "frame-support", @@ -3661,7 +3689,7 @@ dependencies = [ [[package]] name = "fp-rpc" version = "3.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "ethereum", "ethereum-types", @@ -3678,7 +3706,7 @@ dependencies = [ [[package]] name = "fp-self-contained" version = "1.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "frame-support", "parity-scale-codec", @@ -3690,7 +3718,7 @@ dependencies = [ [[package]] name = "fp-storage" version = "2.0.0" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "parity-scale-codec", "serde", @@ -3782,7 +3810,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -3856,7 +3884,7 @@ name = "frame-support" version = "4.0.0-dev" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "bitflags", + "bitflags 1.3.2", "environmental", "frame-metadata", "frame-support-procedural", @@ -3897,7 +3925,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -3909,7 +3937,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -3919,7 +3947,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -3994,11 +4022,11 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7672706608ecb74ab2e055c68327ffc25ae4cac1e12349204fd5fb0f3487cce2" +checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.37.20", + "rustix 0.38.8", "windows-sys 0.48.0", ] @@ -4080,12 +4108,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ - "fastrand", + "fastrand 1.9.0", "futures-core", "futures-io", "memchr", "parking", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "waker-fn", ] @@ -4097,7 +4125,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -4142,7 +4170,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "pin-utils", "slab", ] @@ -4241,9 +4269,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "glob" @@ -4253,11 +4281,11 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.10" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" dependencies = [ - "aho-corasick 0.7.20", + "aho-corasick", "bstr", "fnv", "log", @@ -4288,9 +4316,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -4397,18 +4425,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hex" @@ -4532,14 +4551,14 @@ checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", ] [[package]] name = "http-range-header" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfe8eed0a9285ef776bb792479ea3834e8b94e13d615c2f66d03dd50a435a29" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" [[package]] name = "httparse" @@ -4549,9 +4568,9 @@ checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "humantime" @@ -4575,7 +4594,7 @@ dependencies = [ "httparse", "httpdate", "itoa", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "socket2 0.4.9", "tokio", "tower-service", @@ -4754,9 +4773,9 @@ checksum = "8e04e2fd2b8188ea827b32ef11de88377086d690286ab35747ef7f9bf3ccb590" [[package]] name = "indicatif" -version = "0.17.5" +version = "0.17.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ff8cc23a7393a397ed1d7f56e6365cba772aba9f9912ab968b03043c395d057" +checksum = "0b297dc40733f23a0e52728a58fa9489a5b7638a324932de16b41adc3ef80730" dependencies = [ "console", "instant", @@ -4857,7 +4876,6 @@ dependencies = [ "polkadot-service", "redeem-rpc-runtime-api", "regex", - "replace-rpc-runtime-api", "reward-rpc-runtime-api", "runtime-common", "sc-basic-authorship", @@ -4937,7 +4955,6 @@ dependencies = [ "oracle-rpc", "pallet-transaction-payment-rpc", "redeem-rpc", - "replace-rpc", "reward-rpc", "sc-client-api", "sc-consensus-manual-seal", @@ -5063,8 +5080,6 @@ dependencies = [ "polkadot-parachain", "redeem", "redeem-rpc-runtime-api", - "replace", - "replace-rpc-runtime-api", "reward", "reward-rpc-runtime-api", "runtime-common", @@ -5104,7 +5119,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.2", "libc", "windows-sys 0.48.0", ] @@ -5135,13 +5150,12 @@ checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.1", - "io-lifetimes", - "rustix 0.37.20", + "hermit-abi 0.3.2", + "rustix 0.38.8", "windows-sys 0.48.0", ] @@ -5212,9 +5226,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.6" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" [[package]] name = "jobserver" @@ -5385,7 +5399,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" dependencies = [ "cfg-if", - "ecdsa 0.16.7", + "ecdsa 0.16.8", "elliptic-curve 0.13.5", "once_cell", "sha2 0.10.7", @@ -5489,8 +5503,6 @@ dependencies = [ "polkadot-parachain", "redeem", "redeem-rpc-runtime-api", - "replace", - "replace-rpc-runtime-api", "reward", "reward-rpc-runtime-api", "runtime-common", @@ -5697,12 +5709,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "libm" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" - [[package]] name = "libm" version = "0.2.7" @@ -6286,9 +6292,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.9" +version = "1.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" dependencies = [ "cc", "pkg-config", @@ -6297,9 +6303,9 @@ dependencies = [ [[package]] name = "link-cplusplus" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" dependencies = [ "cc", ] @@ -6321,9 +6327,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475015a7f8f017edb28d2e69813be23500ad4b32cfe3421c4148efc97324ee52" +checksum = "4de0b5f52a9f84544d268f5fabb71b38962d6aa3c6600b8bcd27d44ccf9c9c45" dependencies = [ "nalgebra", ] @@ -6340,6 +6346,12 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + [[package]] name = "loans" version = "1.9.3" @@ -6409,9 +6421,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" @@ -6487,7 +6499,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" dependencies = [ - "regex-automata", + "regex-automata 0.1.10", ] [[package]] @@ -6527,7 +6539,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix 0.37.20", + "rustix 0.37.23", ] [[package]] @@ -6601,15 +6613,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.1" @@ -6848,9 +6851,9 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.32.2" +version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d47bba83f9e2006d117a9a33af1524e655516b8919caac694427a6fb1e511" +checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" dependencies = [ "approx", "matrixmultiply", @@ -6864,9 +6867,9 @@ dependencies = [ [[package]] name = "nalgebra-macros" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d232c68884c0c99810a5a4d333ef7e47689cfd0edc85efc9e54e1e6bf5212766" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" dependencies = [ "proc-macro2", "quote", @@ -6925,7 +6928,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags", + "bitflags 1.3.2", "byteorder", "libc", "netlink-packet-core", @@ -6978,7 +6981,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.6.5", @@ -7053,9 +7056,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg 1.1.0", "num-integer", @@ -7064,9 +7067,9 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02e0d21255c828d6f128a1e41534206671e8c3ea0c62f32291e808dc82cff17d" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ "num-traits", ] @@ -7116,21 +7119,21 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg 1.1.0", - "libm 0.2.7", + "libm", ] [[package]] name = "num_cpus" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.2.6", + "hermit-abi 0.3.2", "libc", ] @@ -7152,7 +7155,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -7175,9 +7178,9 @@ dependencies = [ [[package]] name = "object" -version = "0.30.4" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" dependencies = [ "memchr", ] @@ -7220,11 +7223,11 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "openssl" -version = "0.10.55" +version = "0.10.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" +checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "foreign-types", "libc", @@ -7241,7 +7244,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -7252,9 +7255,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.90" +version = "0.9.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" +checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" dependencies = [ "cc", "libc", @@ -7547,16 +7550,6 @@ dependencies = [ "sha2 0.10.7", ] -[[package]] -name = "packed_simd_2" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1914cd452d8fccd6f9db48147b29fd4ae05bea9dc5d9ad578509f72415de282" -dependencies = [ - "cfg-if", - "libm 0.1.4", -] - [[package]] name = "pallet-aura" version = "4.0.0-dev" @@ -7665,7 +7658,7 @@ dependencies = [ [[package]] name = "pallet-base-fee" version = "1.0.0" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "fp-evm", "frame-support", @@ -7778,7 +7771,7 @@ name = "pallet-contracts" version = "4.0.0-dev" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "bitflags", + "bitflags 1.3.2", "environmental", "frame-benchmarking", "frame-support", @@ -7807,7 +7800,7 @@ name = "pallet-contracts-primitives" version = "7.0.0" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ - "bitflags", + "bitflags 1.3.2", "parity-scale-codec", "scale-info", "sp-runtime", @@ -7822,7 +7815,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -7917,7 +7910,7 @@ dependencies = [ [[package]] name = "pallet-ethereum" version = "4.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "ethereum", "ethereum-types", @@ -7940,7 +7933,7 @@ dependencies = [ [[package]] name = "pallet-evm" version = "6.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "environmental", "evm", @@ -7965,7 +7958,7 @@ dependencies = [ [[package]] name = "pallet-evm-chain-id" version = "1.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "frame-support", "frame-system", @@ -7976,7 +7969,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-dispatch" version = "2.0.0-dev" -source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech//frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "fp-evm", "frame-support", @@ -7986,7 +7979,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-modexp" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "fp-evm", "num", @@ -7995,7 +7988,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-sha3fips" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "fp-evm", "tiny-keccak", @@ -8004,7 +7997,7 @@ dependencies = [ [[package]] name = "pallet-evm-precompile-simple" version = "2.0.0-dev" -source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#1a718546085be20ce381b70e1f9e4c8b4d4b1f03" +source = "git+https://github.com/paritytech/frontier?branch=polkadot-v0.9.42#2499d18c936edbcb7fcb711827db7abb9b4f4da4" dependencies = [ "fp-evm", "ripemd", @@ -8443,7 +8436,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -8786,8 +8779,6 @@ dependencies = [ "rand 0.8.5", "redeem", "redeem-rpc-runtime-api", - "replace", - "replace-rpc-runtime-api", "reward", "reward-rpc-runtime-api", "runtime-common", @@ -8824,9 +8815,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.8" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4890dcb9556136a4ec2b0c51fa4a08c8b733b829506af8fff2e853f3a065985b" +checksum = "78f19d20a0d2cc52327a88d131fa1c4ea81ea4a04714aedcfeca2dd410049cf8" dependencies = [ "blake2", "crc32fast", @@ -8844,9 +8835,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.1" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2287753623c76f953acd29d15d8100bcab84d29db78fb6f352adb3c53e83b967" +checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" dependencies = [ "arrayvec 0.7.4", "bitvec", @@ -8859,9 +8850,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.1" +version = "3.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b6937b5e67bfba3351b87b040d48352a2fcb6ad72f81855412ce97b45c8f110" +checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -8932,14 +8923,14 @@ dependencies = [ "libc", "redox_syscall 0.3.5", "smallvec", - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pbkdf2" @@ -8991,9 +8982,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73935e4d55e2abf7f130186537b19e7a4abc886a0252380b59248af473a3fc9" +checksum = "1acb4a4365a13f749a93f1a094a7805e5cfa0955373a9de860d962eaa3a5fe5a" dependencies = [ "thiserror", "ucd-trie", @@ -9001,9 +8992,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef623c9bbfa0eedf5a0efba11a5ee83209c326653ca31ff019bec3a95bfff2b" +checksum = "666d00490d4ac815001da55838c500eafb0320019bbaa44444137c48b443a853" dependencies = [ "pest", "pest_generator", @@ -9011,22 +9002,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e8cba4ec22bada7fc55ffe51e2deb6a0e0db2d0b7ab0b103acc80d2510c190" +checksum = "68ca01446f50dbda87c1786af8770d535423fa8a53aec03b8f4e3d7eb10e0929" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] name = "pest_meta" -version = "2.7.0" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0" +checksum = "56af0a30af74d0445c0bf6d9d051c979b516a1a5af790d251daee76005420a48" dependencies = [ "once_cell", "pest", @@ -9035,32 +9026,32 @@ dependencies = [ [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap 2.0.0", ] [[package]] name = "pin-project" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c95a7476719eab1e366eaf73d0260af3021184f18177925b07f54b30089ceead" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -9071,9 +9062,9 @@ checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" [[package]] name = "pin-project-lite" -version = "0.2.9" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" +checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" [[package]] name = "pin-utils" @@ -9097,7 +9088,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.6", + "der 0.7.8", "spki 0.7.2", ] @@ -10110,7 +10101,7 @@ name = "polkadot-runtime-parachains" version = "0.9.42" source = "git+https://github.com/paritytech//polkadot?branch=release-v0.9.42#6f991987c0b4cbbd7d4badc9ef08d83da5fefbfd" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bitvec", "derive_more", "frame-benchmarking", @@ -10297,12 +10288,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg 1.1.0", - "bitflags", + "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "windows-sys 0.48.0", ] @@ -10343,9 +10334,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794" +checksum = "f32154ba0af3a075eefa1eda8bb414ee928f62303a54ea85b8d6638ff1a6ee9e" [[package]] name = "ppv-lite86" @@ -10483,14 +10474,14 @@ checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] name = "proc-macro2" -version = "1.0.63" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b368fba921b0dce7e60f5e04ec15e565b3303972b42bcfde1d0713b881959eb" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -10539,7 +10530,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e35c06b98bf36aba164cc17cb25f7e232f5c4aeea73baa14b8a9f0d92dbfa65" dependencies = [ "bit-set", - "bitflags", + "bitflags 1.3.2", "byteorder", "lazy_static", "num-traits", @@ -10656,9 +10647,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" +checksum = "f31999cfc7927c4e212e60fd50934ab40e8e8bfd2d493d6095d2d306bc0764d9" dependencies = [ "bytes", "rand 0.8.5", @@ -10674,9 +10665,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.28" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ab9c7eadfd8df19006f1cf1a4aed13540ed5cbc047010ece5826e10825488" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -10918,7 +10909,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.22", + "time 0.3.27", "x509-parser 0.13.2", "yasna", ] @@ -10931,7 +10922,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.22", + "time 0.3.27", "yasna", ] @@ -10956,6 +10947,7 @@ dependencies = [ "frame-support", "frame-system", "interbtc-primitives", + "issue", "loans", "mocktopus", "nomination", @@ -11005,7 +10997,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -11014,7 +11006,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -11043,22 +11035,22 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.16" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43faa91b1c8b36841ee70e97188a869d37ae21759da6846d4be66de5bf7b12c" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.16" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -11075,13 +11067,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.8.4" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" dependencies = [ - "aho-corasick 1.0.2", + "aho-corasick", "memchr", - "regex-syntax 0.7.2", + "regex-automata 0.3.6", + "regex-syntax 0.7.4", ] [[package]] @@ -11093,6 +11086,17 @@ dependencies = [ "regex-syntax 0.6.29", ] +[[package]] +name = "regex-automata" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.4", +] + [[package]] name = "regex-syntax" version = "0.6.29" @@ -11101,9 +11105,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" +checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" [[package]] name = "region" @@ -11111,66 +11115,12 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" dependencies = [ - "bitflags", + "bitflags 1.3.2", "libc", "mach", "winapi", ] -[[package]] -name = "replace" -version = "1.2.0" -dependencies = [ - "bitcoin 1.2.0", - "btc-relay", - "currency", - "fee", - "frame-benchmarking", - "frame-support", - "frame-system", - "interbtc-primitives", - "mocktopus", - "nomination", - "oracle", - "orml-tokens", - "orml-traits", - "pallet-timestamp", - "parity-scale-codec", - "reward", - "scale-info", - "security", - "serde", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "staking", - "vault-registry", -] - -[[package]] -name = "replace-rpc" -version = "1.2.0" -dependencies = [ - "jsonrpsee", - "parity-scale-codec", - "replace-rpc-runtime-api", - "sp-api", - "sp-blockchain", - "sp-runtime", -] - -[[package]] -name = "replace-rpc-runtime-api" -version = "1.2.0" -dependencies = [ - "frame-support", - "parity-scale-codec", - "sp-api", - "sp-std", -] - [[package]] name = "resolv-conf" version = "0.7.0" @@ -11501,7 +11451,6 @@ dependencies = [ "pallet-evm-precompile-simple", "parachain-info", "redeem", - "replace", "reward", "security", "sp-core", @@ -11539,7 +11488,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]] @@ -11553,11 +11502,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.14" +version = "0.36.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e4d67015953998ad0eb82887a0eb0129e18a7e2f3b7b0f6c422fddcd503d62" +checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -11567,11 +11516,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.20" +version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" +checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -11579,6 +11528,19 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustix" +version = "0.38.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys 0.4.5", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.19.1" @@ -11627,9 +11589,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "rusty-fork" @@ -11656,15 +11618,15 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.13" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safe_arch" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62a7484307bd40f8f7ccbacccac730108f2cae119a3b11c74485b48aa9ea650f" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" dependencies = [ "bytemuck", ] @@ -11782,7 +11744,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -12233,7 +12195,7 @@ dependencies = [ "libc", "log", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -12344,7 +12306,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "array-bytes 4.2.0", "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "futures", "futures-timer", @@ -12792,7 +12754,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -12916,9 +12878,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad560913365790f17cbf12479491169f01b9d46d29cfc7422bf8c64bdc61b731" +checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" dependencies = [ "bitvec", "cfg-if", @@ -12930,9 +12892,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19df9bd9ace6cc2fe19387c96ce677e823e07d017ceed253e7bb3d1d1bd9c73b" +checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -12942,11 +12904,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys 0.42.0", + "windows-sys 0.48.0", ] [[package]] @@ -12980,15 +12942,15 @@ dependencies = [ [[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.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1792db035ce95be60c3f8853017b3999209281c24e2ba5bc8e59bf97a0c590c1" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" [[package]] name = "sct" @@ -13038,12 +13000,12 @@ 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.6", + "der 0.7.8", "generic-array 0.14.7", "pkcs8 0.10.2", "subtle", @@ -13133,11 +13095,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -13146,9 +13108,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -13165,9 +13127,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", ] @@ -13180,29 +13142,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.164" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.164" +version = "1.0.185" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] name = "serde_json" -version = "1.0.99" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" dependencies = [ "itoa", "ryu", @@ -13347,15 +13309,15 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg 1.1.0", ] @@ -13389,9 +13351,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "snap" @@ -13401,14 +13363,14 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccba027ba85743e09d15c03296797cad56395089b832b48b5a5217880f57733" +checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" dependencies = [ "aes-gcm 0.9.4", "blake2", "chacha20poly1305", - "curve25519-dalek 4.0.0-rc.1", + "curve25519-dalek 4.0.0", "rand_core 0.6.4", "ring", "rustc_version", @@ -13484,7 +13446,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -13666,7 +13628,7 @@ version = "7.0.0" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "array-bytes 4.2.0", - "bitflags", + "bitflags 1.3.2", "blake2", "bounded-collections", "bs58", @@ -13726,7 +13688,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core-hashing", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -13754,7 +13716,7 @@ source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#f dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -13840,7 +13802,7 @@ version = "4.1.0-dev" source = "git+https://github.com/paritytech//substrate?branch=polkadot-v0.9.42#ff24c60ac7d9f87727ecdd0ded9a80c56e4f4b65" dependencies = [ "thiserror", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] @@ -13965,7 +13927,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -14133,7 +14095,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -14214,7 +14176,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" dependencies = [ "base64ct", - "der 0.7.6", + "der 0.7.8", ] [[package]] @@ -14340,9 +14302,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.40.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" +checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" dependencies = [ "Inflector", "num-format", @@ -14407,7 +14369,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -14585,7 +14547,7 @@ dependencies = [ "sp-maybe-compressed-blob", "strum", "tempfile", - "toml 0.7.5", + "toml 0.7.6", "walkdir", "wasm-opt", ] @@ -14639,9 +14601,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.22" +version = "2.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efbeae7acf4eabd6bcdcbd11c92f45231ddda7539edc7806bd1a04a03b24616" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" dependencies = [ "proc-macro2", "quote", @@ -14666,7 +14628,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "system-configuration-sys", ] @@ -14689,21 +14651,20 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.8" +version = "0.12.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" [[package]] name = "tempfile" -version = "3.6.0" +version = "3.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" dependencies = [ - "autocfg 1.1.0", "cfg-if", - "fastrand", + "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix 0.37.20", + "rustix 0.38.8", "windows-sys 0.48.0", ] @@ -14724,22 +14685,22 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978c9a314bd8dc99be594bc3c175faaa9794be04a5a5e153caba6915336cebac" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.40" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -14782,9 +14743,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-ctl" -version = "0.5.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e37706572f4b151dff7a0146e040804e9c26fe3a3118591112f05cf12a4216c1" +checksum = "619bfed27d807b54f7f776b9430d4f8060e66ee138a28632ca898584d462c31c" dependencies = [ "libc", "paste", @@ -14793,9 +14754,9 @@ dependencies = [ [[package]] name = "tikv-jemalloc-sys" -version = "0.5.3+5.3.0-patched" +version = "0.5.4+5.3.0-patched" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a678df20055b43e57ef8cddde41cdfda9a3c1a060b67f4c5836dfb1d78543ba8" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" dependencies = [ "cc", "libc", @@ -14814,10 +14775,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.22" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" +checksum = "0bb39ee79a6d8de55f48f2293a830e040392f1c5f16e336bdd1788cd0aadce07" dependencies = [ + "deranged", "itoa", "serde", "time-core", @@ -14832,9 +14794,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +checksum = "733d258752e9303d392b94b75230d07b0b9c489350c69b851fc6c065fde3e8f9" dependencies = [ "time-core", ] @@ -14894,20 +14856,19 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.29.0" +version = "1.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374442f06ee49c3a28a8fc9f01a2596fed7559c6b99b31279c3261778e77d84f" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" dependencies = [ - "autocfg 1.1.0", "backtrace", "bytes", "libc", "mio", "num_cpus", "parking_lot 0.12.1", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "signal-hook-registry", - "socket2 0.4.9", + "socket2 0.5.3", "tokio-macros", "windows-sys 0.48.0", ] @@ -14920,7 +14881,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -14941,7 +14902,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "tokio", "tokio-util", ] @@ -14956,7 +14917,7 @@ dependencies = [ "futures-core", "futures-io", "futures-sink", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "tokio", "tracing", ] @@ -14972,9 +14933,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebafdf5ad1220cb59e7d17cf4d2c72015297b75b19a10472f99b89225089240" +checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ "serde", "serde_spanned", @@ -14993,9 +14954,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.19.11" +version = "0.19.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" +checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" dependencies = [ "indexmap 2.0.0", "serde", @@ -15021,14 +14982,14 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" dependencies = [ - "bitflags", + "bitflags 1.3.2", "bytes", "futures-core", "futures-util", "http", "http-body", "http-range-header", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "tower-layer", "tower-service", ] @@ -15053,7 +15014,7 @@ checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", "log", - "pin-project-lite 0.2.9", + "pin-project-lite 0.2.12", "tracing-attributes", "tracing-core", ] @@ -15066,7 +15027,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -15109,7 +15070,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -15294,7 +15255,7 @@ dependencies = [ "sp-version", "sp-weights", "substrate-rpc-client", - "zstd 0.12.3+zstd.1.5.2", + "zstd 0.12.4", ] [[package]] @@ -15360,9 +15321,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "ucd-trie" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] name = "uint" @@ -15390,9 +15351,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.9" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unicode-normalization" @@ -15484,9 +15445,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", ] @@ -15667,7 +15628,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", "wasm-bindgen-shared", ] @@ -15701,7 +15662,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -15831,7 +15792,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" dependencies = [ "downcast-rs", - "libm 0.2.7", + "libm", "memory_units", "num-rational", "num-traits", @@ -15845,7 +15806,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624e6333e861ef49095d2d678b76ebf30b06bf37effca845be7e5b87c90071b7" dependencies = [ "downcast-rs", - "libm 0.2.7", + "libm", "num-traits", "paste", ] @@ -15918,7 +15879,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.14", + "rustix 0.36.15", "serde", "sha2 0.10.7", "toml 0.5.11", @@ -15998,7 +15959,7 @@ checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" dependencies = [ "object 0.29.0", "once_cell", - "rustix 0.36.14", + "rustix 0.36.15", ] [[package]] @@ -16029,7 +15990,7 @@ dependencies = [ "memoffset 0.6.5", "paste", "rand 0.8.5", - "rustix 0.36.14", + "rustix 0.36.15", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -16113,7 +16074,7 @@ dependencies = [ "sha2 0.10.7", "stun", "thiserror", - "time 0.3.22", + "time 0.3.27", "tokio", "turn", "url", @@ -16145,9 +16106,9 @@ dependencies = [ [[package]] name = "webrtc-dtls" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942be5bd85f072c3128396f6e5a9bfb93ca8c1939ded735d177b7bcba9a13d05" +checksum = "c4a00f4242f2db33307347bd5be53263c52a0331c96c14292118c9a6bb48d267" dependencies = [ "aes 0.6.0", "aes-gcm 0.10.2", @@ -16162,12 +16123,11 @@ dependencies = [ "hkdf", "hmac 0.12.1", "log", - "oid-registry 0.6.1", "p256", "p384", "rand 0.8.5", "rand_core 0.6.4", - "rcgen 0.9.3", + "rcgen 0.10.0", "ring", "rustls 0.19.1", "sec1 0.3.0", @@ -16180,7 +16140,7 @@ dependencies = [ "tokio", "webpki 0.21.4", "webrtc-util", - "x25519-dalek 2.0.0-pre.1", + "x25519-dalek 2.0.0", "x509-parser 0.13.2", ] @@ -16282,7 +16242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags", + "bitflags 1.3.2", "bytes", "cc", "ipnet", @@ -16415,9 +16375,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40018623e2dba2602a9790faba8d33f2ebdebf4b86561b83928db735f8784728" +checksum = "aa469ffa65ef7e0ba0f164183697b89b854253fd31aeb92358b7b6155177d62f" dependencies = [ "bytemuck", "safe_arch", @@ -16479,7 +16439,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -16512,7 +16472,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets 0.48.0", + "windows-targets 0.48.5", ] [[package]] @@ -16532,17 +16492,17 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm 0.48.0", - "windows_aarch64_msvc 0.48.0", - "windows_i686_gnu 0.48.0", - "windows_i686_msvc 0.48.0", - "windows_x86_64_gnu 0.48.0", - "windows_x86_64_gnullvm 0.48.0", - "windows_x86_64_msvc 0.48.0", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -16553,9 +16513,9 @@ checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" @@ -16571,9 +16531,9 @@ checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" @@ -16589,9 +16549,9 @@ checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" @@ -16607,9 +16567,9 @@ checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" @@ -16625,9 +16585,9 @@ checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" @@ -16637,9 +16597,9 @@ checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" @@ -16655,15 +16615,15 @@ checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.4.7" +version = "0.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" +checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] @@ -16700,12 +16660,13 @@ dependencies = [ [[package]] name = "x25519-dalek" -version = "2.0.0-pre.1" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5da623d8af10a62342bcbbb230e33e58a63255a58012f8653c578e54bab48df" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" dependencies = [ - "curve25519-dalek 3.2.0", + "curve25519-dalek 4.0.0", "rand_core 0.6.4", + "serde", "zeroize", ] @@ -16725,7 +16686,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.27", ] [[package]] @@ -16743,7 +16704,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.22", + "time 0.3.27", ] [[package]] @@ -16837,7 +16798,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -16877,7 +16838,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.22", + "time 0.3.27", ] [[package]] @@ -16897,7 +16858,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.22", + "syn 2.0.29", ] [[package]] @@ -16911,11 +16872,11 @@ dependencies = [ [[package]] name = "zstd" -version = "0.12.3+zstd.1.5.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" dependencies = [ - "zstd-safe 6.0.5+zstd.1.5.4", + "zstd-safe 6.0.6", ] [[package]] @@ -16930,9 +16891,9 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "6.0.5+zstd.1.5.4" +version = "6.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56d9e60b4b1758206c238a10165fbcae3ca37b01744e394c463463f6529d23b" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" dependencies = [ "libc", "zstd-sys", diff --git a/crates/issue/src/benchmarking.rs b/crates/issue/src/benchmarking.rs index d9cf85c747..21101b317a 100644 --- a/crates/issue/src/benchmarking.rs +++ b/crates/issue/src/benchmarking.rs @@ -27,16 +27,16 @@ fn mint_collateral(account_id: &T::AccountId, amount: BalanceO deposit_tokens::(get_native_currency_id::(), account_id, amount); } -fn get_vault_id() -> DefaultVaultId { +fn get_vault_id(name: &'static str) -> DefaultVaultId { VaultId::new( - account("Vault", 0, 0), + account(name, 0, 0), get_collateral_currency_id::(), get_wrapped_currency_id::(), ) } fn setup_chain() { - let dummy_vault = get_vault_id::(); + let dummy_vault = get_vault_id::("Vault"); Oracle::::_set_exchange_rate( get_native_currency_id::(), // for griefing collateral @@ -114,9 +114,11 @@ fn setup_issue( vin: u32, vout: u32, tx_size: u32, + setup_as_replace: bool, ) -> ChainState { let origin: T::AccountId = account("Origin", 0, 0); - let vault_id = get_vault_id::(); + let new_vault_id = get_vault_id::("Vault"); + let old_vault_id = get_vault_id::("OldVault"); let relayer_id: T::AccountId = account("Relayer", 0, 0); mint_collateral::(&origin, (1u32 << 31).into()); @@ -128,8 +130,12 @@ fn setup_issue( let issue_id = H256::zero(); let issue_request = IssueRequest { - requester: origin.clone(), - vault: vault_id.clone(), + requester: if setup_as_replace { + AccountOrVault::Vault(old_vault_id.clone()) + } else { + AccountOrVault::Account(origin.clone()) + }, + vault: new_vault_id.clone(), btc_address: vault_btc_address, amount: value.amount(), btc_height: Default::default(), @@ -159,11 +165,14 @@ fn setup_issue( let transaction = BtcRelay::::initialize_and_store_max(relayer_id.clone(), hashes, vin, outputs, tx_size as usize); - register_vault::(vault_id.clone()); + register_vault::(new_vault_id.clone()); + register_vault::(old_vault_id.clone()); + + VaultRegistry::::try_increase_to_be_issued_tokens(&new_vault_id, &value).unwrap(); + VaultRegistry::::try_increase_to_be_issued_tokens(&old_vault_id, &value).unwrap(); - VaultRegistry::::try_increase_to_be_issued_tokens(&vault_id, &value).unwrap(); - let secure_id = Security::::get_secure_id(&vault_id.account_id); - VaultRegistry::::register_deposit_address(&vault_id, secure_id).unwrap(); + let secure_id = Security::::get_secure_id(&new_vault_id.account_id); + VaultRegistry::::register_deposit_address(&new_vault_id, secure_id).unwrap(); ChainState { issue_id, @@ -180,7 +189,7 @@ pub mod benchmarks { fn request_issue() { let origin: T::AccountId = account("Origin", 0, 0); let amount = Issue::::issue_btc_dust_value(get_wrapped_currency_id::()).amount() + 1000u32.into(); - let vault_id = get_vault_id::(); + let vault_id = get_vault_id::("Vault"); let relayer_id: T::AccountId = account("Relayer", 0, 0); mint_collateral::(&origin, (1u32 << 31).into()); @@ -216,7 +225,7 @@ pub mod benchmarks { #[benchmark] fn execute_issue_exact(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<1, 10>, b: Linear<770, 2_048>) { let origin: T::AccountId = account("Origin", 0, 0); - let issue_data = setup_issue::(PaymentType::Exact, h, i, o, b); + let issue_data = setup_issue::(PaymentType::Exact, h, i, o, b, false); #[extrinsic_call] execute_issue(RawOrigin::Signed(origin), issue_data.issue_id, issue_data.transaction); @@ -225,7 +234,7 @@ pub mod benchmarks { #[benchmark] fn execute_issue_overpayment(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<1, 10>, b: Linear<770, 2_048>) { let origin: T::AccountId = account("Origin", 0, 0); - let issue_data = setup_issue::(PaymentType::Overpayment, h, i, o, b); + let issue_data = setup_issue::(PaymentType::Overpayment, h, i, o, b, false); #[extrinsic_call] execute_issue(RawOrigin::Signed(origin), issue_data.issue_id, issue_data.transaction); @@ -234,7 +243,7 @@ pub mod benchmarks { #[benchmark] fn execute_issue_underpayment(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<1, 10>, b: Linear<770, 2_048>) { let origin: T::AccountId = account("Origin", 0, 0); - let issue_data = setup_issue::(PaymentType::Underpayment, h, i, o, b); + let issue_data = setup_issue::(PaymentType::Underpayment, h, i, o, b, false); #[extrinsic_call] execute_issue(RawOrigin::Signed(origin), issue_data.issue_id, issue_data.transaction); @@ -243,7 +252,7 @@ pub mod benchmarks { #[benchmark] fn execute_expired_issue_exact(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<1, 10>, b: Linear<770, 2_048>) { let origin: T::AccountId = account("Origin", 0, 0); - let issue_data = setup_issue::(PaymentType::Exact, h, i, o, b); + let issue_data = setup_issue::(PaymentType::Exact, h, i, o, b, false); expire_issue::(&issue_data); #[extrinsic_call] @@ -253,7 +262,7 @@ pub mod benchmarks { #[benchmark] fn execute_expired_issue_overpayment(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<1, 10>, b: Linear<770, 2_048>) { let origin: T::AccountId = account("Origin", 0, 0); - let issue_data = setup_issue::(PaymentType::Overpayment, h, i, o, b); + let issue_data = setup_issue::(PaymentType::Overpayment, h, i, o, b, false); expire_issue::(&issue_data); #[extrinsic_call] @@ -263,7 +272,7 @@ pub mod benchmarks { #[benchmark] fn execute_expired_issue_underpayment(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<1, 10>, b: Linear<770, 2_048>) { let origin: T::AccountId = account("Origin", 0, 0); - let issue_data = setup_issue::(PaymentType::Underpayment, h, i, o, b); + let issue_data = setup_issue::(PaymentType::Underpayment, h, i, o, b, false); expire_issue::(&issue_data); #[extrinsic_call] @@ -274,7 +283,18 @@ pub mod benchmarks { fn cancel_issue() { let origin: T::AccountId = account("Origin", 0, 0); - let issue_data = setup_issue::(PaymentType::Exact, 2, 2, 2, 770); + let issue_data = setup_issue::(PaymentType::Exact, 2, 2, 2, 770, false); + expire_issue::(&issue_data); + + #[extrinsic_call] + cancel_issue(RawOrigin::Signed(origin), issue_data.issue_id); + } + + #[benchmark] + fn cancel_issue_for_replace() { + let origin: T::AccountId = account("Origin", 0, 0); + + let issue_data = setup_issue::(PaymentType::Exact, 2, 2, 2, 770, true); expire_issue::(&issue_data); #[extrinsic_call] diff --git a/crates/issue/src/default_weights.rs b/crates/issue/src/default_weights.rs index 54ef62854f..fb590f3517 100644 --- a/crates/issue/src/default_weights.rs +++ b/crates/issue/src/default_weights.rs @@ -2,31 +2,32 @@ //! Autogenerated weights for issue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-29, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `enterprise`, CPU: `Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz` +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet // --pallet // issue // --extrinsic // * -// --chain -// kintsugi-dev // --execution=wasm // --wasm-execution=compiled // --steps -// 50 +// 2 // --repeat -// 20 -// --output -// crates/issue/src/default_weights.rs +// 1 // --template -// .deploy/default-weight-template.hbs +// .deploy/runtime-weight-template.hbs +// --chain +// kintsugi-dev +// --output +// generated_weight_kintsugi.rs + #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -46,11 +47,13 @@ pub trait WeightInfo { fn execute_expired_issue_underpayment(h: u32, i: u32, o: u32, b: u32, ) -> Weight; fn cancel_issue() -> Weight; fn set_issue_period() -> Weight; + fn cancel_issue_for_replace() -> Weight; } /// Weights for issue using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + /// Storage: BTCRelay StartBlockHeight (r:1 w:0) /// Proof: BTCRelay StartBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) @@ -58,15 +61,15 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: Fee IssueGriefingCollateral (r:1 w:0) /// Proof: Fee IssueGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) + /// Storage: Fee IssueFee (r:1 w:0) + /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Issue IssueBtcDustValue (r:1 w:0) /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) @@ -75,8 +78,6 @@ impl WeightInfo for SubstrateWeight { /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Fee IssueFee (r:1 w:0) - /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) /// Storage: System ParentHash (r:1 w:0) @@ -88,18 +89,18 @@ impl WeightInfo for SubstrateWeight { /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Issue IssueRequests (r:0 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) - fn request_issue() -> Weight { + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + fn request_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `3572` - // Estimated: `26156` - // Minimum execution time: 450_294_000 picoseconds. - Weight::from_parts(452_439_000, 26156) - .saturating_add(T::DbWeight::get().reads(19_u64)) + // Measured: `2690` + // Estimated: `6028` + // Minimum execution time: 38_621_000_000 picoseconds. + Weight::from_parts(38_621_000_000, 6028) + .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -115,7 +116,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -126,25 +127,21 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_exact(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_issue_exact (_h: u32, i: u32, o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3435` - // Estimated: `20840` - // Minimum execution time: 142_775_000 picoseconds. - Weight::from_parts(117_261_202, 20840) - // Standard Error: 45_583 - .saturating_add(Weight::from_parts(1_682_032, 0).saturating_mul(h.into())) - // Standard Error: 41_054 - .saturating_add(Weight::from_parts(684_847, 0).saturating_mul(i.into())) - // Standard Error: 41_054 - .saturating_add(Weight::from_parts(287_609, 0).saturating_mul(o.into())) - // Standard Error: 308 - .saturating_add(Weight::from_parts(7_184, 0).saturating_mul(b.into())) + // Measured: `2448` + // Estimated: `3760` + // Minimum execution time: 206_000_000 picoseconds. + Weight::from_parts(261_839_397, 3760) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(277_777, 0).saturating_mul(i.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(166_666, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -160,11 +157,9 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: VaultStaking Nonce (r:1 w:0) @@ -183,21 +178,23 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_overpayment(h: u32, _i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_issue_overpayment (_h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `4257` - // Estimated: `32025` - // Minimum execution time: 212_556_000 picoseconds. - Weight::from_parts(219_428_668, 32025) - // Standard Error: 58_266 - .saturating_add(Weight::from_parts(901_425, 0).saturating_mul(h.into())) - // Standard Error: 394 - .saturating_add(Weight::from_parts(5_933, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(18_u64)) + // Measured: `3335` + // Estimated: `3760` + // Minimum execution time: 307_000_000 picoseconds. + Weight::from_parts(277_172_143, 3760) + // Standard Error: 1_347_150 + .saturating_add(Weight::from_parts(777_777, 0).saturating_mul(i.into())) + // Standard Error: 1_347_150 + .saturating_add(Weight::from_parts(1_000_000, 0).saturating_mul(o.into())) + // Standard Error: 9_486 + .saturating_add(Weight::from_parts(15_649, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -213,7 +210,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -226,23 +223,23 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_underpayment(h: u32, i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_issue_underpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3688` - // Estimated: `21351` - // Minimum execution time: 161_721_000 picoseconds. - Weight::from_parts(157_484_537, 21351) - // Standard Error: 51_664 - .saturating_add(Weight::from_parts(1_573_495, 0).saturating_mul(h.into())) - // Standard Error: 46_531 - .saturating_add(Weight::from_parts(703_443, 0).saturating_mul(i.into())) - // Standard Error: 349 - .saturating_add(Weight::from_parts(3_376, 0).saturating_mul(b.into())) + // Measured: `2747` + // Estimated: `3760` + // Minimum execution time: 214_000_000 picoseconds. + Weight::from_parts(184_539_123, 3760) + // Standard Error: 1_732_050 + .saturating_add(Weight::from_parts(4_250_000, 0).saturating_mul(h.into())) + // Standard Error: 1_539_600 + .saturating_add(Weight::from_parts(1_555_555, 0).saturating_mul(i.into())) + // Standard Error: 10_842 + .saturating_add(Weight::from_parts(8_607, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -258,7 +255,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -269,21 +266,25 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_exact(h: u32, _i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_exact (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `4358 + o * (8 ±0)` - // Estimated: `20840` - // Minimum execution time: 146_945_000 picoseconds. - Weight::from_parts(131_685_627, 20840) - // Standard Error: 120_641 - .saturating_add(Weight::from_parts(3_687_159, 0).saturating_mul(h.into())) - // Standard Error: 816 - .saturating_add(Weight::from_parts(15_185, 0).saturating_mul(b.into())) + // Measured: `3536` + // Estimated: `3760` + // Minimum execution time: 194_000_000 picoseconds. + Weight::from_parts(163_253_716, 3760) + // Standard Error: 974_278 + .saturating_add(Weight::from_parts(3_562_500, 0).saturating_mul(h.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(611_111, 0).saturating_mul(i.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(388_888, 0).saturating_mul(o.into())) + // Standard Error: 6_098 + .saturating_add(Weight::from_parts(6_651, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -299,11 +300,9 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: VaultStaking Nonce (r:1 w:0) @@ -322,25 +321,23 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_overpayment(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_overpayment (h: u32, i: u32, o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `5026 + i * (9 ±0)` - // Estimated: `32025` - // Minimum execution time: 219_548_000 picoseconds. - Weight::from_parts(188_635_084, 32025) - // Standard Error: 145_768 - .saturating_add(Weight::from_parts(2_393_121, 0).saturating_mul(h.into())) - // Standard Error: 131_286 - .saturating_add(Weight::from_parts(2_072_816, 0).saturating_mul(i.into())) - // Standard Error: 131_286 - .saturating_add(Weight::from_parts(81_139, 0).saturating_mul(o.into())) - // Standard Error: 986 - .saturating_add(Weight::from_parts(10_300, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(18_u64)) + // Measured: `4141 + h * (21 ±0) + i * (3 ±0) + o * (3 ±0)` + // Estimated: `3760` + // Minimum execution time: 322_000_000 picoseconds. + Weight::from_parts(316_622_652, 3760) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(937_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_055_555, 0).saturating_mul(i.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(55_555, 0).saturating_mul(o.into())) + .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -356,7 +353,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -369,19 +366,23 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_underpayment(_h: u32, _i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_underpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `4495 + h * (9 ±0) + i * (13 ±0)` - // Estimated: `21351` - // Minimum execution time: 173_639_000 picoseconds. - Weight::from_parts(195_976_912, 21351) - // Standard Error: 849 - .saturating_add(Weight::from_parts(13_647, 0).saturating_mul(b.into())) + // Measured: `3990` + // Estimated: `3760` + // Minimum execution time: 231_000_000 picoseconds. + Weight::from_parts(177_273_669, 3760) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(5_437_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_277_777, 0).saturating_mul(i.into())) + // Standard Error: 677 + .saturating_add(Weight::from_parts(16_040, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -389,30 +390,48 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - fn cancel_issue() -> Weight { + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + fn cancel_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `2583` - // Estimated: `6968` - // Minimum execution time: 78_715_000 picoseconds. - Weight::from_parts(83_016_000, 6968) + // Measured: `1505` + // Estimated: `3760` + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(89_000_000, 3760) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: Issue IssuePeriod (r:0 w:1) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_issue_period() -> Weight { + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn cancel_issue_for_replace () -> Weight { // Proof Size summary in bytes: // Measured: `1027` + // Estimated: `3760` + // Minimum execution time: 66_000_000 picoseconds. + Weight::from_parts(66_000_000, 3760) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: Issue IssuePeriod (r:0 w:1) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn set_issue_period () -> Weight { + // Proof Size summary in bytes: + // Measured: `0` // Estimated: `0` - // Minimum execution time: 21_853_000 picoseconds. - Weight::from_parts(22_510_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } // For backwards compatibility and tests impl WeightInfo for () { + /// Storage: BTCRelay StartBlockHeight (r:1 w:0) /// Proof: BTCRelay StartBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) @@ -420,15 +439,15 @@ impl WeightInfo for () { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: Fee IssueGriefingCollateral (r:1 w:0) /// Proof: Fee IssueGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) + /// Storage: Fee IssueFee (r:1 w:0) + /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Issue IssueBtcDustValue (r:1 w:0) /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) @@ -437,8 +456,6 @@ impl WeightInfo for () { /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Fee IssueFee (r:1 w:0) - /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) /// Storage: System ParentHash (r:1 w:0) @@ -450,18 +467,19 @@ impl WeightInfo for () { /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Issue IssueRequests (r:0 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) - fn request_issue() -> Weight { + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + fn request_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `3572` - // Estimated: `26156` - // Minimum execution time: 450_294_000 picoseconds. - Weight::from_parts(452_439_000, 26156) - .saturating_add(RocksDbWeight::get().reads(19_u64)) + // Measured: `2690` + // Estimated: `6028` + // Minimum execution time: 38_621_000_000 picoseconds. + Weight::from_parts(38_621_000_000, 6028) + .saturating_add(RocksDbWeight::get().reads(18_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } + /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -477,7 +495,7 @@ impl WeightInfo for () { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -488,25 +506,21 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_exact(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_issue_exact (_h: u32, i: u32, o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3435` - // Estimated: `20840` - // Minimum execution time: 142_775_000 picoseconds. - Weight::from_parts(117_261_202, 20840) - // Standard Error: 45_583 - .saturating_add(Weight::from_parts(1_682_032, 0).saturating_mul(h.into())) - // Standard Error: 41_054 - .saturating_add(Weight::from_parts(684_847, 0).saturating_mul(i.into())) - // Standard Error: 41_054 - .saturating_add(Weight::from_parts(287_609, 0).saturating_mul(o.into())) - // Standard Error: 308 - .saturating_add(Weight::from_parts(7_184, 0).saturating_mul(b.into())) + // Measured: `2448` + // Estimated: `3760` + // Minimum execution time: 206_000_000 picoseconds. + Weight::from_parts(261_839_397, 3760) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(277_777, 0).saturating_mul(i.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(166_666, 0).saturating_mul(o.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -522,11 +536,9 @@ impl WeightInfo for () { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: VaultStaking Nonce (r:1 w:0) @@ -545,21 +557,23 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_overpayment(h: u32, _i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_issue_overpayment (_h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `4257` - // Estimated: `32025` - // Minimum execution time: 212_556_000 picoseconds. - Weight::from_parts(219_428_668, 32025) - // Standard Error: 58_266 - .saturating_add(Weight::from_parts(901_425, 0).saturating_mul(h.into())) - // Standard Error: 394 - .saturating_add(Weight::from_parts(5_933, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(18_u64)) + // Measured: `3335` + // Estimated: `3760` + // Minimum execution time: 307_000_000 picoseconds. + Weight::from_parts(277_172_143, 3760) + // Standard Error: 1_347_150 + .saturating_add(Weight::from_parts(777_777, 0).saturating_mul(i.into())) + // Standard Error: 1_347_150 + .saturating_add(Weight::from_parts(1_000_000, 0).saturating_mul(o.into())) + // Standard Error: 9_486 + .saturating_add(Weight::from_parts(15_649, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(17_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -575,7 +589,7 @@ impl WeightInfo for () { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -588,23 +602,23 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_underpayment(h: u32, i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_issue_underpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3688` - // Estimated: `21351` - // Minimum execution time: 161_721_000 picoseconds. - Weight::from_parts(157_484_537, 21351) - // Standard Error: 51_664 - .saturating_add(Weight::from_parts(1_573_495, 0).saturating_mul(h.into())) - // Standard Error: 46_531 - .saturating_add(Weight::from_parts(703_443, 0).saturating_mul(i.into())) - // Standard Error: 349 - .saturating_add(Weight::from_parts(3_376, 0).saturating_mul(b.into())) + // Measured: `2747` + // Estimated: `3760` + // Minimum execution time: 214_000_000 picoseconds. + Weight::from_parts(184_539_123, 3760) + // Standard Error: 1_732_050 + .saturating_add(Weight::from_parts(4_250_000, 0).saturating_mul(h.into())) + // Standard Error: 1_539_600 + .saturating_add(Weight::from_parts(1_555_555, 0).saturating_mul(i.into())) + // Standard Error: 10_842 + .saturating_add(Weight::from_parts(8_607, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -620,7 +634,7 @@ impl WeightInfo for () { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -631,21 +645,25 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_exact(h: u32, _i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_exact (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `4358 + o * (8 ±0)` - // Estimated: `20840` - // Minimum execution time: 146_945_000 picoseconds. - Weight::from_parts(131_685_627, 20840) - // Standard Error: 120_641 - .saturating_add(Weight::from_parts(3_687_159, 0).saturating_mul(h.into())) - // Standard Error: 816 - .saturating_add(Weight::from_parts(15_185, 0).saturating_mul(b.into())) + // Measured: `3536` + // Estimated: `3760` + // Minimum execution time: 194_000_000 picoseconds. + Weight::from_parts(163_253_716, 3760) + // Standard Error: 974_278 + .saturating_add(Weight::from_parts(3_562_500, 0).saturating_mul(h.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(611_111, 0).saturating_mul(i.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(388_888, 0).saturating_mul(o.into())) + // Standard Error: 6_098 + .saturating_add(Weight::from_parts(6_651, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -661,11 +679,9 @@ impl WeightInfo for () { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: VaultStaking Nonce (r:1 w:0) @@ -684,25 +700,23 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_overpayment(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_overpayment (h: u32, i: u32, o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `5026 + i * (9 ±0)` - // Estimated: `32025` - // Minimum execution time: 219_548_000 picoseconds. - Weight::from_parts(188_635_084, 32025) - // Standard Error: 145_768 - .saturating_add(Weight::from_parts(2_393_121, 0).saturating_mul(h.into())) - // Standard Error: 131_286 - .saturating_add(Weight::from_parts(2_072_816, 0).saturating_mul(i.into())) - // Standard Error: 131_286 - .saturating_add(Weight::from_parts(81_139, 0).saturating_mul(o.into())) - // Standard Error: 986 - .saturating_add(Weight::from_parts(10_300, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(18_u64)) + // Measured: `4141 + h * (21 ±0) + i * (3 ±0) + o * (3 ±0)` + // Estimated: `3760` + // Minimum execution time: 322_000_000 picoseconds. + Weight::from_parts(316_622_652, 3760) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(937_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_055_555, 0).saturating_mul(i.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(55_555, 0).saturating_mul(o.into())) + .saturating_add(RocksDbWeight::get().reads(17_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -718,7 +732,7 @@ impl WeightInfo for () { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -731,19 +745,23 @@ impl WeightInfo for () { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_underpayment(_h: u32, _i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_underpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `4495 + h * (9 ±0) + i * (13 ±0)` - // Estimated: `21351` - // Minimum execution time: 173_639_000 picoseconds. - Weight::from_parts(195_976_912, 21351) - // Standard Error: 849 - .saturating_add(Weight::from_parts(13_647, 0).saturating_mul(b.into())) + // Measured: `3990` + // Estimated: `3760` + // Minimum execution time: 231_000_000 picoseconds. + Weight::from_parts(177_273_669, 3760) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(5_437_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_277_777, 0).saturating_mul(i.into())) + // Standard Error: 677 + .saturating_add(Weight::from_parts(16_040, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(13_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(261), added: 2736, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -751,24 +769,41 @@ impl WeightInfo for () { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - fn cancel_issue() -> Weight { + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + fn cancel_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `2583` - // Estimated: `6968` - // Minimum execution time: 78_715_000 picoseconds. - Weight::from_parts(83_016_000, 6968) + // Measured: `1505` + // Estimated: `3760` + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(89_000_000, 3760) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } - /// Storage: Issue IssuePeriod (r:0 w:1) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_issue_period() -> Weight { + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn cancel_issue_for_replace () -> Weight { // Proof Size summary in bytes: // Measured: `1027` + // Estimated: `3760` + // Minimum execution time: 66_000_000 picoseconds. + Weight::from_parts(66_000_000, 3760) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: Issue IssuePeriod (r:0 w:1) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn set_issue_period () -> Weight { + // Proof Size summary in bytes: + // Measured: `0` // Estimated: `0` - // Minimum execution time: 21_853_000 picoseconds. - Weight::from_parts(22_510_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } -} +} \ No newline at end of file diff --git a/crates/issue/src/lib.rs b/crates/issue/src/lib.rs index 509422f5ca..9aecf202d8 100644 --- a/crates/issue/src/lib.rs +++ b/crates/issue/src/lib.rs @@ -38,6 +38,7 @@ use currency::Amount; use frame_support::{dispatch::DispatchError, ensure, pallet_prelude::Weight, traits::Get, transactional, PalletId}; use frame_system::{ensure_root, ensure_signed}; pub use pallet::*; +use primitives::AccountOrVault; use sp_core::H256; use sp_runtime::traits::{AccountIdConversion, Convert, Saturating}; use sp_std::vec::Vec; @@ -153,6 +154,8 @@ pub mod pallet { InvalidExecutor, /// Issue amount is too small. AmountBelowDustAmount, + /// Replace request can't be executed as issue request. + ReplaceRequestCannotBeExecutedAsIssue, } /// Users create issue requests to issue tokens. This mapping provides access @@ -179,7 +182,7 @@ pub mod pallet { Version::V4 } - /// Build storage at V1 (requires default 0). + /// Build storage at V5 (requires default 4). #[pallet::storage] #[pallet::getter(fn storage_version)] pub(super) type StorageVersion = StorageValue<_, Version, ValueQuery, DefaultForStorageVersion>; @@ -190,6 +193,13 @@ pub mod pallet { pub issue_btc_dust_value: BalanceOf, } + #[pallet::hooks] + impl Hooks> for Pallet { + fn on_runtime_upgrade() -> Weight { + migration::v5::migrate_v4_to_v5::() + } + } + #[cfg(feature = "std")] impl Default for GenesisConfig { fn default() -> Self { @@ -232,7 +242,7 @@ pub mod pallet { vault_id: DefaultVaultId, griefing_currency: CurrencyId, ) -> DispatchResultWithPostInfo { - let requester = ensure_signed(origin)?; + let requester = AccountOrVault::Account(ensure_signed(origin)?); Self::_request_issue(requester, amount, vault_id, griefing_currency)?; Ok(().into()) } @@ -266,7 +276,10 @@ pub mod pallet { /// * `origin` - sender of the transaction /// * `issue_id` - identifier of issue request as output from request_issue #[pallet::call_index(2)] - #[pallet::weight(::WeightInfo::cancel_issue())] + #[pallet::weight( + ::WeightInfo::cancel_issue() + .max(::WeightInfo::cancel_issue_for_replace()) + )] #[transactional] pub fn cancel_issue(origin: OriginFor, issue_id: H256) -> DispatchResultWithPostInfo { let requester = ensure_signed(origin)?; @@ -301,13 +314,36 @@ impl Pallet { T::TreasuryPalletId::get().into_account_truncating() } + // Function to retrieve the vault ID associated with a given issue ID + pub fn get_vault_from_issue_id(issue_id: &H256) -> Result, DispatchError> { + // Retrieve the issue request using the provided issue_id + let issue_request = Self::get_issue_request_from_id(issue_id)?; + + // Extract and return the associated vault ID from the issue request + Ok(issue_request.vault) + } + + // Function to complete a vault issue process + pub fn _complete_vault_issue(issue_id: H256) -> Result<(), DispatchError> { + // Retrieve the issue request using the provided issue_id + let issue = Self::get_issue_request_from_id(&issue_id)?; + + // Decrease the to-be-issued tokens and increase the issued tokens for the new vault + ext::vault_registry::issue_tokens::(&issue.vault, &issue.amount())?; + + // Set the issue status to 'Completed' + Self::set_issue_status(issue_id, IssueRequestStatus::Completed); + + Ok(()) + } + /// Requests CBA issuance, returns unique tracking ID. - fn _request_issue( - requester: T::AccountId, + pub fn _request_issue( + requester: AccountOrVault, amount_requested: BalanceOf, vault_id: DefaultVaultId, griefing_currency: CurrencyId, - ) -> Result { + ) -> Result<(H256, BtcAddress), DispatchError> { let amount_requested = Amount::new(amount_requested, vault_id.wrapped_currency()); ensure!( @@ -326,10 +362,28 @@ impl Pallet { // Check that the vault is currently not banned ext::vault_registry::ensure_not_banned::(&vault_id)?; - // calculate griefing collateral based on the total amount of tokens to be issued - let amount_collateral = amount_requested.convert_to(griefing_currency)?; - let griefing_collateral = ext::fee::get_issue_griefing_collateral::(&amount_collateral)?; - griefing_collateral.lock_on(&requester)?; + // check if it's a replace request + let (griefing_collateral, fee, amount_user) = if requester.is_vault_account() { + ( + // for replace request griefing collateral remains as zero + Amount::zero(griefing_currency), + // for replace request fee remains as zero + Amount::zero(vault_id.wrapped_currency()), + // for replace amount given to old_vault should be equal to specified amount + amount_requested.clone(), + ) + } else { + // calculate griefing collateral based on the total amount of tokens to be issued + let amount_collateral = amount_requested.convert_to(griefing_currency)?; + let griefing_collateral = ext::fee::get_issue_griefing_collateral::(&amount_collateral)?; + griefing_collateral.lock_on(requester.get_account())?; + + let fee = ext::fee::get_issue_fee::(&amount_requested)?; + // calculate the amount of tokens that will be transferred to the user upon execution + let amount_user = amount_requested.checked_sub(&fee)?; + + (griefing_collateral, fee, amount_user) + }; // only continue if the payment is above the dust value ensure!( @@ -339,18 +393,14 @@ impl Pallet { ext::vault_registry::try_increase_to_be_issued_tokens::(&vault_id, &amount_requested)?; - let fee = ext::fee::get_issue_fee::(&amount_requested)?; - // calculate the amount of tokens that will be transferred to the user upon execution - let amount_user = amount_requested.checked_sub(&fee)?; - - let issue_id = ext::security::get_secure_id::(&requester); + let issue_id = ext::security::get_secure_id::(&requester.get_account()); let btc_address = ext::vault_registry::register_deposit_address::(&vault_id, issue_id)?; let btc_public_key = ext::vault_registry::get_bitcoin_public_key::(&vault_id.account_id)?; let request = IssueRequest { vault: vault_id, opentime: ext::security::active_block_number::(), - requester, + requester: requester.clone(), btc_address, btc_public_key, amount: amount_user.amount(), @@ -365,7 +415,7 @@ impl Pallet { Self::deposit_event(Event::RequestIssue { issue_id, - requester: request.requester, + requester: request.requester.get_account().clone(), amount: request.amount, fee: request.fee, griefing_collateral: request.griefing_collateral, @@ -374,7 +424,7 @@ impl Pallet { vault_address: request.btc_address, vault_public_key: request.btc_public_key, }); - Ok(issue_id) + Ok((issue_id, btc_address)) } /// Completes CBA issuance, removing request from storage and minting token. @@ -384,6 +434,13 @@ impl Pallet { unchecked_transaction: FullTransactionProof, ) -> Result<(), DispatchError> { let mut issue = Self::get_issue_request_from_id(&issue_id)?; + + // ensure that issue is not part of replace request + ensure!( + !issue.requester.is_vault_account(), + Error::::ReplaceRequestCannotBeExecutedAsIssue + ); + // allow anyone to complete issue request let requester = issue.requester.clone(); @@ -405,7 +462,7 @@ impl Pallet { ext::vault_registry::try_increase_to_be_issued_tokens::(&issue.vault, &amount_transferred)?; if amount_transferred.lt(&expected_total_amount)? { - ensure!(requester == executor, Error::::InvalidExecutor); + ensure!(requester.get_account() == &executor, Error::::InvalidExecutor); } if amount_transferred.ne(&expected_total_amount)? { // griefing collateral and to_be_issued already decreased in cancel @@ -416,7 +473,7 @@ impl Pallet { IssueRequestStatus::Pending => { let to_release_griefing_collateral = if amount_transferred.lt(&expected_total_amount)? { // only the requester of the issue can execute payments with insufficient amounts - ensure!(requester == executor, Error::::InvalidExecutor); + ensure!(requester.get_account() == &executor, Error::::InvalidExecutor); Self::decrease_issue_amount(&issue_id, &mut issue, amount_transferred, expected_total_amount)? } else { if amount_transferred.gt(&expected_total_amount)? @@ -432,7 +489,7 @@ impl Pallet { issue.griefing_collateral() }; - to_release_griefing_collateral.unlock_on(&requester)?; + to_release_griefing_collateral.unlock_on(requester.get_account())?; } } @@ -443,7 +500,7 @@ impl Pallet { ext::vault_registry::issue_tokens::(&issue.vault, &total)?; // mint issued tokens - issue_amount.mint_to(&requester)?; + issue_amount.mint_to(requester.get_account())?; // mint wrapped fees issue_fee.mint_to(&ext::fee::fee_pool_account_id::())?; @@ -455,7 +512,7 @@ impl Pallet { Self::deposit_event(Event::ExecuteIssue { issue_id, - requester, + requester: requester.get_account().clone(), vault_id: issue.vault, amount: total.amount(), fee: issue.fee, @@ -464,15 +521,25 @@ impl Pallet { } /// Cancels CBA issuance if time has expired and slashes collateral. - fn _cancel_issue(requester: T::AccountId, issue_id: H256) -> Result<(), DispatchError> { + pub fn _cancel_issue(requester: T::AccountId, issue_id: H256) -> Result<(), DispatchError> { let issue = Self::get_pending_issue(&issue_id)?; let issue_period = Self::issue_period().max(issue.period); - let to_be_slashed_collateral = - if ext::btc_relay::has_request_expired::(issue.opentime, issue.btc_height, issue_period)? { + let is_replace_request = issue.requester.is_vault_account(); + + let issue_expired = ext::btc_relay::has_request_expired::(issue.opentime, issue.btc_height, issue_period)?; + + // its a replace issue call if requester is vault + let slashed_collateral = if is_replace_request { + // only cancel replace request if issue is expired + ensure!(issue_expired, Error::::TimeNotExpired); + // for replace request griefing collateral is set as zero + issue.griefing_collateral() + } else { + let to_be_slashed_collateral = if issue_expired { // anyone can cancel the issue request once expired issue.griefing_collateral() - } else if issue.requester == requester { + } else if issue.requester.get_account() == &requester { // slash/release griefing collateral proportionally to the time elapsed // NOTE: if global issue period increases requester will get more griefing collateral let blocks_elapsed = ext::security::active_block_number::().saturating_sub(issue.opentime); @@ -503,30 +570,35 @@ impl Pallet { return Err(Error::::TimeNotExpired.into()); }; - if ext::vault_registry::is_vault_liquidated::(&issue.vault)? { - // return slashed griefing collateral if the vault is liquidated - to_be_slashed_collateral.unlock_on(&issue.requester)?; - } else { - // otherwise give slashed griefing collateral to the treasury - // since the vault may have purposely blocked minting - ext::vault_registry::transfer_funds::( - CurrencySource::UserGriefing(issue.requester.clone()), - CurrencySource::FreeBalance(Self::treasury_account_id()), - &to_be_slashed_collateral, - )?; - } + if ext::vault_registry::is_vault_liquidated::(&issue.vault)? { + // return slashed griefing collateral if the vault is liquidated + to_be_slashed_collateral.unlock_on(issue.requester.get_account())?; + } else { + // otherwise give slashed griefing collateral to the treasury + // since the vault may have purposely blocked minting + ext::vault_registry::transfer_funds::( + CurrencySource::UserGriefing(issue.requester.get_account().clone()), + CurrencySource::FreeBalance(Self::treasury_account_id()), + &to_be_slashed_collateral, + )?; + } + + // decrease to-be-issued tokens + let full_amount = issue.amount().checked_add(&issue.fee())?; + ext::vault_registry::decrease_to_be_issued_tokens::(&issue.vault, &full_amount)?; - // decrease to-be-issued tokens - let full_amount = issue.amount().checked_add(&issue.fee())?; - ext::vault_registry::decrease_to_be_issued_tokens::(&issue.vault, &full_amount)?; + to_be_slashed_collateral + }; + // Set the status of the issue request to 'Cancelled' Self::set_issue_status(issue_id, IssueRequestStatus::Cancelled); Self::deposit_event(Event::CancelIssue { issue_id, requester, - griefing_collateral: to_be_slashed_collateral.amount(), + griefing_collateral: slashed_collateral.amount(), }); + Ok(()) } @@ -548,7 +620,7 @@ impl Pallet { )?; let slashed_collateral = issue.griefing_collateral().checked_sub(&to_release_collateral)?; ext::vault_registry::transfer_funds::( - CurrencySource::UserGriefing(issue.requester.clone()), + CurrencySource::UserGriefing(issue.requester.get_account().clone()), CurrencySource::FreeBalance(Self::treasury_account_id()), &slashed_collateral, )?; @@ -588,7 +660,7 @@ impl Pallet { /// * `account_id` - user account id pub fn get_issue_requests_for_account(account_id: T::AccountId) -> Vec { >::iter() - .filter(|(_, request)| request.requester == account_id) + .filter(|(_, request)| request.requester.get_account() == &account_id) .map(|(key, _)| key) .collect() } @@ -657,7 +729,7 @@ impl Pallet { Ok(()) } - fn insert_issue_request(key: &H256, value: &DefaultIssueRequest) { + pub fn insert_issue_request(key: &H256, value: &DefaultIssueRequest) { >::insert(key, value) } diff --git a/crates/issue/src/migration.rs b/crates/issue/src/migration.rs index 216916123c..2f0dfd430c 100644 --- a/crates/issue/src/migration.rs +++ b/crates/issue/src/migration.rs @@ -3,7 +3,7 @@ use frame_support::{pallet_prelude::*, traits::OnRuntimeUpgrade}; use sp_core::H256; /// The log target. -const TARGET: &'static str = "runtime::issue::migration::v1"; +const TARGET: &'static str = "runtime::issue::migration::v5"; /// The original data layout of the democracy pallet without a specific version number. mod v0 { @@ -87,7 +87,7 @@ pub mod v1 { griefing_collateral: old.griefing_collateral, amount: old.amount, fee: old.fee, - requester: old.requester, + requester: AccountOrVault::Account(old.requester), btc_address: old.btc_address, btc_public_key: old.btc_public_key, btc_height: old.btc_height, @@ -115,6 +115,86 @@ pub mod v1 { } } +mod v4 { + use super::*; + + #[frame_support::storage_alias] + pub(super) type IssueRequests = + StorageMap, Blake2_128Concat, H256, DefaultIssueRequest, OptionQuery>; + + #[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)] + pub struct IssueRequest { + /// the vault associated with this issue request + pub vault: primitives::VaultId, + /// the *active* block height when this request was opened + pub opentime: BlockNumber, + /// the issue period when this request was opened + pub period: BlockNumber, + /// the collateral held for spam prevention + pub griefing_collateral: Balance, + /// The currency used for the griefing collateral + pub griefing_currency: CurrencyId, + /// the number of tokens that will be transferred to the user (as such, this does not include the fee) + pub amount: Balance, + /// the number of tokens that will be transferred to the fee pool + pub fee: Balance, + /// the account issuing tokens + pub requester: AccountId, + /// the vault's Bitcoin deposit address + pub btc_address: BtcAddress, + /// the vault's Bitcoin public key (when this request was made) + pub btc_public_key: BtcPublicKey, + /// the highest recorded height in the BTC-Relay (at time of opening) + pub btc_height: u32, + /// the status of this issue request + pub status: IssueRequestStatus, + } + + pub type DefaultIssueRequest = IssueRequest< + ::AccountId, + ::BlockNumber, + BalanceOf, + CurrencyId, + >; +} + +pub mod v5 { + use super::*; + + pub fn migrate_v4_to_v5() -> Weight { + let mut weight = T::DbWeight::get().reads(1); + + if !matches!(crate::StorageVersion::::get(), Version::V4) { + return T::DbWeight::get().reads(1); // already upgraded; don't run migration + } + + IssueRequests::::translate(|key, old: v4::DefaultIssueRequest| { + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); + log::info!(target: TARGET, "migrating issue #{:?}", &key); + + Some(DefaultIssueRequest:: { + vault: old.vault, + opentime: old.opentime, + period: old.period, + griefing_collateral: old.griefing_collateral, + amount: old.amount, + fee: old.fee, + requester: AccountOrVault::Account(old.requester), + btc_address: old.btc_address, + btc_public_key: old.btc_public_key, + btc_height: old.btc_height, + status: old.status, + griefing_currency: T::GetGriefingCollateralCurrencyId::get(), + }) + }); + + // update version + StorageVersion::new(5).put::>(); + + weight.saturating_add(T::DbWeight::get().reads_writes(0, 1)) + } +} + #[cfg(test)] mod test { use super::*; @@ -123,6 +203,49 @@ mod test { types::*, }; + #[test] + fn migrating_from_v4_to_v5() { + run_test(|| { + assert_eq!(crate::StorageVersion::::get(), Version::V4); + + let old = v4::DefaultIssueRequest:: { + requester: 123, + vault: DefaultVaultId::::new(123, Token(DOT), Token(IBTC)), + btc_address: BtcAddress::random(), + amount: 123, + btc_height: 234, + btc_public_key: Default::default(), + fee: 456, + griefing_collateral: 567, + opentime: 12334, + period: 12313, + status: Default::default(), + griefing_currency: ::GetGriefingCollateralCurrencyId::get(), + }; + let key = H256::zero(); + v4::IssueRequests::::insert(key, old.clone()); + + v5::migrate_v4_to_v5::(); + + assert_eq!(StorageVersion::get::>(), 5); + + let new = crate::IssueRequests::::get(key).unwrap(); + + assert!(old.requester == new.requester.get_account().clone()); + assert!(old.vault == new.vault); + assert!(old.btc_address == new.btc_address); + assert!(old.amount == new.amount); + assert!(old.btc_height == new.btc_height); + assert!(old.btc_public_key == new.btc_public_key); + assert!(old.fee == new.fee); + assert!(old.griefing_collateral == new.griefing_collateral); + assert!(old.opentime == new.opentime); + assert!(old.period == new.period); + assert!(old.status == new.status); + assert!(new.griefing_currency == ::GetGriefingCollateralCurrencyId::get()); + }); + } + #[allow(deprecated)] #[test] fn migration_works() { @@ -148,7 +271,7 @@ mod test { v1::Migration::::on_runtime_upgrade(); let new = crate::IssueRequests::::get(key).unwrap(); - assert!(old.requester == new.requester); + assert!(old.requester == new.requester.get_account().clone()); assert!(old.vault == new.vault); assert!(old.btc_address == new.btc_address); assert!(old.amount == new.amount); diff --git a/crates/issue/src/mock.rs b/crates/issue/src/mock.rs index b045e5bb67..45c808d207 100644 --- a/crates/issue/src/mock.rs +++ b/crates/issue/src/mock.rs @@ -286,7 +286,15 @@ pub const VAULT: VaultId = VaultId { wrapped: DEFAULT_WRAPPED_CURRENCY, }, }; +pub const OLD_VAULT: VaultId = VaultId { + account_id: 4, + currencies: VaultCurrencyPair { + collateral: DEFAULT_COLLATERAL_CURRENCY, + wrapped: DEFAULT_WRAPPED_CURRENCY, + }, +}; +pub const OLD_VAULT_BALANCE: u128 = 1_000_000; pub const ALICE_BALANCE: u128 = 1_000_000; pub const BOB_BALANCE: u128 = 1_000_000; @@ -345,6 +353,7 @@ impl ExtBuilder { vec![ (USER, currency_id, ALICE_BALANCE), (VAULT.account_id, currency_id, BOB_BALANCE), + (OLD_VAULT.account_id, currency_id, OLD_VAULT_BALANCE), ] }) .collect(), diff --git a/crates/issue/src/tests.rs b/crates/issue/src/tests.rs index 4f8cccd3b3..7db077e0c0 100644 --- a/crates/issue/src/tests.rs +++ b/crates/issue/src/tests.rs @@ -1,12 +1,12 @@ use crate::{ext, mock::*, Event, IssueRequest}; -use bitcoin::{merkle::PartialTransactionProof, types::FullTransactionProof}; +use bitcoin::{merkle::PartialTransactionProof, types::FullTransactionProof, Address}; use btc_relay::{BtcAddress, BtcPublicKey}; use currency::Amount; use frame_support::{assert_noop, assert_ok, dispatch::DispatchError}; use mocktopus::mocking::*; use orml_traits::MultiCurrency; -use primitives::issue::IssueRequestStatus; +use primitives::{issue::IssueRequestStatus, AccountOrVault}; use sp_arithmetic::FixedU128; use sp_core::H256; use sp_runtime::traits::One; @@ -20,22 +20,30 @@ fn wrapped(amount: u128) -> Amount { Amount::new(amount, DEFAULT_WRAPPED_CURRENCY) } -fn request_issue(origin: AccountId, amount: Balance, vault: DefaultVaultId) -> Result { +fn request_issue( + origin: AccountId, + amount: Balance, + vault: DefaultVaultId, +) -> Result<(H256, Address), DispatchError> { ext::security::get_secure_id::.mock_safe(|_| MockResult::Return(get_dummy_request_id())); ext::vault_registry::try_increase_to_be_issued_tokens::.mock_safe(|_, _| MockResult::Return(Ok(()))); ext::vault_registry::register_deposit_address:: .mock_safe(|_, _| MockResult::Return(Ok(BtcAddress::random()))); - Issue::_request_issue(origin, amount, vault, DEFAULT_NATIVE_CURRENCY) + Issue::_request_issue(AccountOrVault::Account(origin), amount, vault, DEFAULT_NATIVE_CURRENCY) } -fn request_issue_ok(origin: AccountId, amount: Balance, vault: DefaultVaultId) -> H256 { +fn request_issue_ok( + origin: AccountOrVault, + amount: Balance, + vault: DefaultVaultId, +) -> H256 { request_issue_ok_with_address(origin, amount, vault, BtcAddress::random()) } fn request_issue_ok_with_address( - origin: AccountId, + origin: AccountOrVault, amount: Balance, vault: DefaultVaultId, address: BtcAddress, @@ -51,7 +59,9 @@ fn request_issue_ok_with_address( ext::vault_registry::register_deposit_address::.mock_raw(|_, _| MockResult::Return(Ok(address))); } - Issue::_request_issue(origin, amount, vault, DEFAULT_NATIVE_CURRENCY).unwrap() + Issue::_request_issue(origin, amount, vault, DEFAULT_NATIVE_CURRENCY) + .unwrap() + .0 } fn execute_issue(origin: AccountId, issue_id: &H256) -> Result<(), DispatchError> { @@ -94,12 +104,9 @@ fn test_request_issue_banned_fails() { &VAULT, vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 0, to_be_redeemed_tokens: 0, - replace_collateral: 0, - active_replace_collateral: 0, banned_until: Some(1), secure_collateral_threshold: None, status: VaultStatus::Active(true), @@ -128,7 +135,8 @@ fn test_request_issue_succeeds() { ext::fee::get_issue_griefing_collateral:: .mock_safe(move |_| MockResult::Return(Ok(griefing(issue_griefing_collateral)))); - let issue_id = request_issue_ok_with_address(origin, amount, vault.clone(), address.clone()); + let issue_id = + request_issue_ok_with_address(AccountOrVault::Account(origin), amount, vault.clone(), address.clone()); let request_issue_event = TestEvent::Issue(Event::RequestIssue { issue_id, @@ -159,6 +167,7 @@ fn setup_execute( issue_fee: Balance, griefing_collateral: Balance, btc_transferred: Balance, + account: AccountOrVault, ) -> H256 { ext::vault_registry::get_active_vault_from_id::.mock_safe(|_| MockResult::Return(Ok(init_zero_vault(VAULT)))); ext::vault_registry::issue_tokens::.mock_safe(|_, _| MockResult::Return(Ok(()))); @@ -168,7 +177,7 @@ fn setup_execute( ext::fee::get_issue_griefing_collateral:: .mock_safe(move |_| MockResult::Return(Ok(griefing(griefing_collateral)))); - let issue_id = request_issue_ok(USER, issue_amount, VAULT); + let issue_id = request_issue_ok(account, issue_amount, VAULT); >::set_active_block_number(5); ext::btc_relay::get_and_verify_issue_payment:: @@ -180,7 +189,7 @@ fn setup_execute( #[test] fn test_execute_issue_succeeds() { run_test(|| { - let issue_id = setup_execute(3, 1, 1, 3); + let issue_id = setup_execute(3, 1, 1, 3, AccountOrVault::Account(USER)); assert_ok!(execute_issue(USER, &issue_id)); let execute_issue_event = TestEvent::Issue(Event::ExecuteIssue { @@ -208,7 +217,7 @@ fn test_execute_issue_succeeds() { #[test] fn test_execute_issue_overpayment_succeeds() { run_test(|| { - let issue_id = setup_execute(3, 0, 0, 5); + let issue_id = setup_execute(3, 0, 0, 5, AccountOrVault::Account(USER)); unsafe { let mut increase_tokens_called = false; @@ -238,7 +247,7 @@ fn test_execute_issue_overpayment_succeeds() { #[test] fn test_execute_issue_overpayment_up_to_max_succeeds() { run_test(|| { - let issue_id = setup_execute(3, 0, 0, 10); + let issue_id = setup_execute(3, 0, 0, 10, AccountOrVault::Account(USER)); unsafe { let mut increase_tokens_called = false; @@ -268,7 +277,7 @@ fn test_execute_issue_overpayment_up_to_max_succeeds() { #[test] fn test_execute_issue_underpayment_succeeds() { run_test(|| { - let issue_id = setup_execute(10, 0, 20, 1); + let issue_id = setup_execute(10, 0, 20, 1, AccountOrVault::Account(USER)); unsafe { let mut transfer_funds_called = false; ext::vault_registry::transfer_funds::.mock_raw(|from, to, amount| { @@ -319,7 +328,7 @@ fn test_cancel_issue_not_expired_and_not_requester_fails() { ext::vault_registry::get_active_vault_from_id:: .mock_safe(|_| MockResult::Return(Ok(init_zero_vault(VAULT)))); - let issue_id = request_issue_ok(USER, 3, VAULT); + let issue_id = request_issue_ok(AccountOrVault::Account(USER), 3, VAULT); // issue period is 10, we issued at block 1, so at block 5 the cancel should fail >::set_active_block_number(5); assert_noop!(cancel_issue(3, &issue_id), TestError::TimeNotExpired); @@ -335,7 +344,7 @@ fn test_cancel_issue_not_expired_and_requester_succeeds() { ext::vault_registry::is_vault_liquidated::.mock_safe(move |_| MockResult::Return(Ok(false))); ext::fee::get_issue_griefing_collateral::.mock_safe(move |_| MockResult::Return(Ok(griefing(100)))); - let issue_id = request_issue_ok(USER, 300, VAULT); + let issue_id = request_issue_ok(AccountOrVault::Account(USER), 300, VAULT); unsafe { let mut transfer_called = false; @@ -372,7 +381,7 @@ fn test_cancel_issue_expired_succeeds() { ext::fee::get_issue_griefing_collateral::.mock_safe(move |_| MockResult::Return(Ok(griefing(100)))); ext::btc_relay::has_request_expired::.mock_safe(move |_, _, _| MockResult::Return(Ok(true))); - let issue_id = request_issue_ok(USER, 300, VAULT); + let issue_id = request_issue_ok(AccountOrVault::Account(USER), 300, VAULT); unsafe { // issue period is 10, we issued at block 1, so at block 12 the request has expired @@ -403,3 +412,61 @@ fn test_set_issue_period_only_root() { assert_ok!(Issue::set_issue_period(RuntimeOrigin::root(), 1)); }) } + +#[test] +fn execute_issue_fails_for_replace_request() { + run_test(|| { + let issue_id = setup_execute(3, 1, 1, 3, AccountOrVault::Vault(OLD_VAULT)); + assert_noop!( + execute_issue(USER, &issue_id), + TestError::ReplaceRequestCannotBeExecutedAsIssue + ); + }); +} + +#[test] +fn fail_to_cancel_completed_replace_issue_request() { + run_test(|| { + let issue_id = setup_execute(3, 1, 1, 3, AccountOrVault::Vault(OLD_VAULT)); + assert_ok!(Issue::_complete_vault_issue(issue_id)); + assert_eq!( + Issue::issue_requests(&issue_id).unwrap().status, + IssueRequestStatus::Completed + ); + assert_noop!(cancel_issue(USER, &issue_id), TestError::IssueCompleted); + }); +} + +#[test] +fn cancel_replace_issue_request() { + run_test(|| { + let griefing_collateral = 10; + let issue_id = setup_execute(3, 1, griefing_collateral, 3, AccountOrVault::Vault(OLD_VAULT)); + + ext::btc_relay::has_request_expired::.mock_safe(move |_, _, _| MockResult::Return(Ok(true))); + ext::vault_registry::decrease_to_be_issued_tokens::.mock_safe(move |_, _| MockResult::Return(Ok(()))); + + assert_ok!(Issue::_cancel_issue(USER, issue_id)); + + assert_eq!( + Issue::issue_requests(&issue_id).unwrap().status, + IssueRequestStatus::Cancelled + ); + + let request_issue_event = TestEvent::Issue(Event::CancelIssue { + issue_id, + requester: USER, + griefing_collateral: 0, + }); + assert!(System::events().iter().any(|a| a.event == request_issue_event)); + }); +} + +#[test] +fn cancel_replace_issue_when_request_not_expired() { + run_test(|| { + let griefing_collateral = 10; + let issue_id = setup_execute(3, 1, griefing_collateral, 3, AccountOrVault::Vault(OLD_VAULT)); + assert_noop!(cancel_issue(USER, &issue_id), TestError::TimeNotExpired); + }); +} diff --git a/crates/issue/src/types.rs b/crates/issue/src/types.rs index d1d1cadb2c..34f7b152bf 100644 --- a/crates/issue/src/types.rs +++ b/crates/issue/src/types.rs @@ -8,7 +8,7 @@ use vault_registry::types::CurrencyId; use crate::Config; /// Storage version. -#[derive(Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +#[derive(Debug, Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum Version { /// Initial version. V0, @@ -20,6 +20,8 @@ pub enum Version { V3, /// Removed refund V4, + /// Updated `IssueRequest`, `requester` field to accept vault account + V5, } pub(crate) type BalanceOf = ::Balance; diff --git a/crates/redeem/Cargo.toml b/crates/redeem/Cargo.toml index 4853f80647..60e98ad66e 100644 --- a/crates/redeem/Cargo.toml +++ b/crates/redeem/Cargo.toml @@ -32,6 +32,7 @@ security = { path = "../security", default-features = false } vault-registry = { path = "../vault-registry", default-features = false } loans = { path = "../loans", default-features = false } primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false } +issue = { path ="../issue", default-features = false } # Orml dependencies orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false, optional = true } @@ -78,6 +79,7 @@ std = [ "nomination/std", "primitives/std", "loans/std", + "issue/std", "orml-tokens/std", "orml-traits/std", diff --git a/crates/redeem/src/benchmarking.rs b/crates/redeem/src/benchmarking.rs index afcc7ae50a..8cefb5f284 100644 --- a/crates/redeem/src/benchmarking.rs +++ b/crates/redeem/src/benchmarking.rs @@ -18,7 +18,9 @@ use vault_registry::{ // Pallets use crate::Pallet as Redeem; use btc_relay::Pallet as BtcRelay; +use issue::Pallet as Issue; use oracle::Pallet as Oracle; +use primitives::issue::IssueRequest; use security::Pallet as Security; use vault_registry::Pallet as VaultRegistry; @@ -111,6 +113,7 @@ fn test_request(vault_id: &DefaultVaultId) -> DefaultRedeem btc_address: Default::default(), btc_height: Default::default(), status: Default::default(), + issue_id: None, } } @@ -122,6 +125,163 @@ fn mint_vault_collateral(vault_id: &DefaultVau } } +fn get_vault_id(name: &'static str) -> DefaultVaultId { + VaultId::new( + account(name, 0, 0), + get_collateral_currency_id::(), + get_wrapped_currency_id::(), + ) +} + +fn register_vault(vault_id: &DefaultVaultId, issued_tokens: Amount) { + let origin = RawOrigin::Signed(vault_id.account_id.clone()); + + assert_ok!(>::deposit( + get_collateral_currency_id::(), + &vault_id.account_id, + (1u32 << 31).into() + )); + assert_ok!(>::deposit( + get_native_currency_id::(), + &vault_id.account_id, + (1u32 << 31).into() + )); + + assert_ok!(VaultRegistry::::register_public_key( + origin.into(), + BtcPublicKey::dummy() + )); + assert_ok!(VaultRegistry::::_register_vault( + vault_id.clone(), + 100000000u32.into() + )); + + VaultRegistry::::try_increase_to_be_issued_tokens(vault_id, &issued_tokens).unwrap(); + VaultRegistry::::issue_tokens(vault_id, &issued_tokens).unwrap(); +} + +struct ChainState { + old_vault_id: DefaultVaultId, + new_vault_id: DefaultVaultId, + issued_tokens: Amount, + to_be_replaced: Amount, +} + +fn setup_chain() -> ChainState { + let new_vault_id = get_vault_id::("NewVault"); + let old_vault_id = get_vault_id::("OldVault"); + + Oracle::::_set_exchange_rate( + get_native_currency_id::(), // for griefing collateral + ::UnsignedFixedPoint::one(), + ) + .unwrap(); + Oracle::::_set_exchange_rate( + old_vault_id.collateral_currency(), + ::UnsignedFixedPoint::one(), + ) + .unwrap(); + + VaultRegistry::::set_minimum_collateral( + RawOrigin::Root.into(), + old_vault_id.collateral_currency(), + 100_000u32.into(), + ) + .unwrap(); + VaultRegistry::::_set_system_collateral_ceiling(old_vault_id.currencies.clone(), 1_000_000_000u32.into()); + + VaultRegistry::::_set_secure_collateral_threshold( + old_vault_id.currencies.clone(), + ::UnsignedFixedPoint::checked_from_rational(1, 100000).unwrap(), + ); + VaultRegistry::::_set_premium_redeem_threshold( + old_vault_id.currencies.clone(), + ::UnsignedFixedPoint::checked_from_rational(1, 200000).unwrap(), + ); + VaultRegistry::::_set_liquidation_collateral_threshold( + old_vault_id.currencies.clone(), + ::UnsignedFixedPoint::checked_from_rational(1, 300000).unwrap(), + ); + + let issued_tokens = Amount::new(200000u32.into(), old_vault_id.wrapped_currency()); + let to_be_replaced = issued_tokens.clone().map(|x| x / 4u32.into()); + + register_vault(&old_vault_id, issued_tokens.clone()); + register_vault(&new_vault_id, issued_tokens.clone()); + + ChainState { + old_vault_id, + new_vault_id, + issued_tokens, + to_be_replaced, + } +} + +fn setup_replace( + old_vault_id: &DefaultVaultId, + new_vault_id: &DefaultVaultId, + to_be_replaced: Amount, + expire_redeem_request: bool, +) -> (H256, BalanceOf) +where + <::Balance as TryInto>::Error: Debug, +{ + let value: Amount = Amount::new(2u32.into(), get_wrapped_currency_id::()); + + let btc_address = if expire_redeem_request { + Default::default() + } else { + BtcAddress::dummy() + }; + + //set up redeem + let redeem_id = H256::zero(); + let mut redeem_request = test_request::(&old_vault_id); + redeem_request.redeemer = new_vault_id.account_id.clone(); + redeem_request.opentime = Security::::active_block_number(); + redeem_request.issue_id = Some(H256::zero()); + redeem_request.amount_btc = value.amount(); + redeem_request.btc_address = btc_address; + + Redeem::::insert_redeem_request(&redeem_id, &redeem_request); + + VaultRegistry::::try_increase_to_be_redeemed_tokens(&old_vault_id, &to_be_replaced).unwrap(); + VaultRegistry::::try_increase_to_be_issued_tokens(&new_vault_id, &to_be_replaced).unwrap(); + + mint_and_reserve_wrapped::(&redeem_request.redeemer, redeem_request.amount_btc); + + // expire redeem request + if expire_redeem_request { + initialize_and_mine_blocks_until_expiry::(&redeem_request); + Security::::set_active_block_number( + Security::::active_block_number() + Redeem::::redeem_period() + 100u32.into(), + ); + } + + // set up issue + let issue_id = H256::zero(); + let issue_request = IssueRequest { + requester: AccountOrVault::Vault(old_vault_id.clone()), + vault: new_vault_id.clone(), + btc_address, + amount: value.amount(), + btc_height: Default::default(), + btc_public_key: Default::default(), + fee: Default::default(), + griefing_collateral: Default::default(), + griefing_currency: get_native_currency_id::(), + opentime: Default::default(), + period: Default::default(), + status: Default::default(), + }; + Issue::::insert_issue_request(&issue_id, &issue_request); + let value: Amount = Amount::new(3u32.into(), get_wrapped_currency_id::()); + + VaultRegistry::::try_increase_to_be_issued_tokens(&new_vault_id, &value).unwrap(); + + (redeem_id, redeem_request.amount_btc) +} + #[benchmarks( where T: loans::Config, @@ -332,6 +492,44 @@ pub mod benchmarks { cancel_redeem(RawOrigin::Signed(caller), redeem_id, false); } + #[benchmark] + pub fn cancel_replace() { + let ChainState { + old_vault_id, + to_be_replaced, + new_vault_id, + .. + } = setup_chain::(); + + let (redeem_id, amount_btc) = setup_replace::(&old_vault_id, &new_vault_id, to_be_replaced, true); + + let vault_id = activate_lending_and_get_vault_id::(); + + initialize_oracle::(); + + register_public_key::(vault_id.clone()); + VaultRegistry::::insert_vault( + &vault_id, + Vault { + id: vault_id.clone(), + issued_tokens: amount_btc, + to_be_redeemed_tokens: amount_btc, + ..Vault::new(vault_id.clone()) + }, + ); + + mint_collateral::(&vault_id.account_id, 1000u32.into()); + assert_ok!(VaultRegistry::::try_deposit_collateral(&vault_id, &collateral(1000))); + + assert_ok!(Oracle::::_set_exchange_rate( + get_collateral_currency_id::(), + UnsignedFixedPoint::::one() + )); + + #[extrinsic_call] + cancel_redeem(RawOrigin::Signed(old_vault_id.account_id.clone()), redeem_id, true); + } + #[benchmark] pub fn set_redeem_period() { #[extrinsic_call] @@ -375,6 +573,99 @@ pub mod benchmarks { _(RawOrigin::Signed(caller), vault_id.currencies, amount.into()); } + #[benchmark] + pub fn request_replace() { + let ChainState { + old_vault_id, + issued_tokens, + to_be_replaced, + new_vault_id, + } = setup_chain::(); + let amount = (issued_tokens.checked_sub(&to_be_replaced).unwrap()).amount(); + let relayer_id: T::AccountId = account("Relayer", 0, 0); + initialize_oracle::(); + mint_collateral::(&relayer_id, (1u32 << 31).into()); + + // initialize relay + let init_block = BlockBuilder::new() + .with_version(4) + .with_coinbase(&BtcAddress::dummy(), 50, 3) + .with_timestamp(u32::MAX) + .mine(U256::from(2).pow(254.into())) + .unwrap(); + + BtcRelay::::_initialize(relayer_id.clone(), init_block.header, 0).unwrap(); + BtcRelay::::mine_blocks(&relayer_id, 1); + Security::::set_active_block_number( + Security::::active_block_number() + BtcRelay::::parachain_confirmations(), + ); + + #[extrinsic_call] + _( + RawOrigin::Signed(old_vault_id.account_id.clone()), + old_vault_id.currencies.clone(), + amount, + new_vault_id.clone(), + get_native_currency_id::(), + ); + } + + #[benchmark] + pub fn execute_replace(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<2, 3>, b: Linear<541, 2_048>) { + let ChainState { + old_vault_id, + to_be_replaced, + new_vault_id, + .. + } = setup_chain::(); + + let (redeem_id, amount_btc) = setup_replace::(&old_vault_id, &new_vault_id, to_be_replaced, false); + + let vault_id = activate_lending_and_get_vault_id::(); + + initialize_oracle::(); + + register_public_key::(vault_id.clone()); + VaultRegistry::::insert_vault( + &vault_id, + Vault { + id: vault_id.clone(), + issued_tokens: amount_btc, + to_be_redeemed_tokens: amount_btc, + ..Vault::new(vault_id.clone()) + }, + ); + + mint_collateral::(&vault_id.account_id, 1000u32.into()); + assert_ok!(VaultRegistry::::try_deposit_collateral(&vault_id, &collateral(1000))); + + assert_ok!(Oracle::::_set_exchange_rate( + get_collateral_currency_id::(), + UnsignedFixedPoint::::one() + )); + + let relayer_id: T::AccountId = account("Relayer", 0, 0); + + // we always need these outputs for redeem + let mut outputs = vec![ + TransactionOutput::payment(amount_btc.try_into().unwrap(), &BtcAddress::dummy()), + TransactionOutput::op_return(0, H256::zero().as_bytes()), + ]; + + // add return-to-self output + if o == 3 { + outputs.push(TransactionOutput::payment( + 2u32.into(), + &BtcAddress::P2PKH(sp_core::H160::zero()), + )); + } + + let transaction = BtcRelay::::initialize_and_store_max(relayer_id.clone(), h, i, outputs, b as usize); + + #[extrinsic_call] + execute_redeem(RawOrigin::Signed(vault_id.account_id.clone()), redeem_id, transaction); + } + impl_benchmark_test_suite!( Redeem, crate::mock::ExtBuilder::build_with(Default::default()), diff --git a/crates/redeem/src/default_weights.rs b/crates/redeem/src/default_weights.rs index 71ac5e8290..d150040f37 100644 --- a/crates/redeem/src/default_weights.rs +++ b/crates/redeem/src/default_weights.rs @@ -2,31 +2,31 @@ //! Autogenerated weights for redeem //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-12, STEPS: `100`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-29, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-hetzner-01`, CPU: `AMD EPYC 7502P 32-Core Processor` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-testnet-latest"), DB CACHE: 1024 +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet -// --chain -// kintsugi-testnet-latest -// --execution=wasm -// --wasm-execution=compiled // --pallet // redeem // --extrinsic // * +// --execution=wasm +// --wasm-execution=compiled // --steps -// 100 +// 2 // --repeat -// 10 -// --output -// ./crates/redeem/src/default_weights.rs +// 1 // --template -// .deploy/default-weight-template.hbs +// .deploy/runtime-weight-template.hbs +// --chain +// kintsugi-dev +// --output +// generated_weight_kintsugi.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -40,17 +40,21 @@ pub trait WeightInfo { fn request_redeem() -> Weight; fn liquidation_redeem() -> Weight; fn execute_redeem(h: u32, i: u32, o: u32, b: u32, ) -> Weight; + fn execute_replace(h: u32, i: u32, o: u32, b: u32, ) -> Weight; fn cancel_redeem_reimburse() -> Weight; fn cancel_redeem_retry() -> Weight; + fn cancel_replace() -> Weight; fn set_redeem_period() -> Weight; fn self_redeem() -> Weight; + fn request_replace() -> Weight; } /// Weights for redeem using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + + /// Storage: VaultRegistry Vaults (r:1 w:1) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:2 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Fee RedeemFee (r:1 w:0) @@ -59,8 +63,6 @@ impl WeightInfo for SubstrateWeight { /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) @@ -102,14 +104,14 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - fn request_redeem() -> Weight { + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `4672` - // Estimated: `47658` - // Minimum execution time: 311_664_000 picoseconds. - Weight::from_parts(315_792_000, 47658) - .saturating_add(T::DbWeight::get().reads(29_u64)) + // Measured: `3161` + // Estimated: `6260` + // Minimum execution time: 270_000_000 picoseconds. + Weight::from_parts(270_000_000, 6260) + .saturating_add(T::DbWeight::get().reads(28_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Tokens Accounts (r:3 w:3) @@ -136,17 +138,17 @@ impl WeightInfo for SubstrateWeight { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Loans AccountDeposits (r:1 w:0) /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - fn liquidation_redeem() -> Weight { + fn liquidation_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3861` - // Estimated: `40975` - // Minimum execution time: 279_078_000 picoseconds. - Weight::from_parts(282_886_000, 40975) + // Measured: `2193` + // Estimated: `8760` + // Minimum execution time: 257_000_000 picoseconds. + Weight::from_parts(257_000_000, 8760) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -166,32 +168,28 @@ impl WeightInfo for SubstrateWeight { /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. /// The range of component `b` is `[541, 2048]`. - fn execute_redeem(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_redeem (h: u32, _i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3463` - // Estimated: `18221` - // Minimum execution time: 180_491_000 picoseconds. - Weight::from_parts(156_971_337, 18221) - // Standard Error: 18_912 - .saturating_add(Weight::from_parts(1_667_781, 0).saturating_mul(h.into())) - // Standard Error: 17_010 - .saturating_add(Weight::from_parts(730_184, 0).saturating_mul(i.into())) - // Standard Error: 102_447 - .saturating_add(Weight::from_parts(810_488, 0).saturating_mul(o.into())) - // Standard Error: 103 - .saturating_add(Weight::from_parts(5_905, 0).saturating_mul(b.into())) + // Measured: `2268 + o * (1 ±0)` + // Estimated: `3743` + // Minimum execution time: 176_000_000 picoseconds. + Weight::from_parts(151_584_172, 3743) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(2_562_500, 0).saturating_mul(h.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(500_000, 0).saturating_mul(o.into())) + // Standard Error: 574 + .saturating_add(Weight::from_parts(8_958, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -199,7 +197,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -261,11 +259,11 @@ impl WeightInfo for SubstrateWeight { /// Storage: VaultRewards TotalStake (r:1 w:1) /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) /// Storage: VaultCapacity TotalStake (r:1 w:1) /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) + /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) /// Storage: Loans RewardSupplyState (r:1 w:1) /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) /// Storage: Loans RewardSupplySpeed (r:1 w:0) @@ -278,19 +276,17 @@ impl WeightInfo for SubstrateWeight { /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_reimburse() -> Weight { + fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `135176` - // Minimum execution time: 798_478_000 picoseconds. - Weight::from_parts(808_188_000, 135176) - .saturating_add(T::DbWeight::get().reads(60_u64)) + // Measured: `5403` + // Estimated: `11350` + // Minimum execution time: 782_000_000 picoseconds. + Weight::from_parts(782_000_000, 11350) + .saturating_add(T::DbWeight::get().reads(59_u64)) .saturating_add(T::DbWeight::get().writes(29_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -298,7 +294,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -360,11 +356,11 @@ impl WeightInfo for SubstrateWeight { /// Storage: VaultRewards TotalStake (r:1 w:1) /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) /// Storage: VaultCapacity TotalStake (r:1 w:1) /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) + /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) /// Storage: Loans RewardSupplyState (r:1 w:1) /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) /// Storage: Loans RewardSupplySpeed (r:1 w:0) @@ -377,46 +373,196 @@ impl WeightInfo for SubstrateWeight { /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_retry() -> Weight { + fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `132666` - // Minimum execution time: 729_751_000 picoseconds. - Weight::from_parts(738_648_000, 132666) - .saturating_add(T::DbWeight::get().reads(59_u64)) + // Measured: `5403` + // Estimated: `11350` + // Minimum execution time: 706_000_000 picoseconds. + Weight::from_parts(706_000_000, 11350) + .saturating_add(T::DbWeight::get().reads(58_u64)) .saturating_add(T::DbWeight::get().writes(28_u64)) } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: Fee PunishmentFee (r:1 w:0) + /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:1 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) + /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultCapacity Stake (r:1 w:0) + /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardPerToken (r:2 w:0) + /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardTally (r:2 w:2) + /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultCapacity TotalRewards (r:2 w:2) + /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultRewards Stake (r:1 w:0) + /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardPerToken (r:2 w:0) + /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardTally (r:2 w:2) + /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalRewards (r:2 w:2) + /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: Fee Commission (r:1 w:0) + /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) + /// Storage: VaultStaking RewardPerToken (r:2 w:2) + /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalStake (r:1 w:0) + /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalStake (r:1 w:0) + /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + fn cancel_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `4404` + // Estimated: `6364` + // Minimum execution time: 394_000_000 picoseconds. + Weight::from_parts(394_000_000, 6364) + .saturating_add(T::DbWeight::get().reads(33_u64)) + .saturating_add(T::DbWeight::get().writes(15_u64)) + } /// Storage: Redeem RedeemPeriod (r:0 w:1) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_redeem_period() -> Weight { + fn set_redeem_period () -> Weight { // Proof Size summary in bytes: - // Measured: `1025` + // Measured: `0` // Estimated: `0` - // Minimum execution time: 28_527_000 picoseconds. - Weight::from_parts(29_970_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - fn self_redeem() -> Weight { + fn self_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `2449` - // Estimated: `7835` - // Minimum execution time: 147_756_000 picoseconds. - Weight::from_parts(149_109_000, 7835) + // Measured: `1399` + // Estimated: `3677` + // Minimum execution time: 116_000_000 picoseconds. + Weight::from_parts(116_000_000, 3677) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: BTCRelay StartBlockHeight (r:1 w:0) + /// Proof: BTCRelay StartBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueBtcDustValue (r:1 w:0) + /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:2 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:2 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: Security Nonce (r:1 w:1) + /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: System ParentHash (r:1 w:0) + /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: VaultRegistry VaultBitcoinPublicKey (r:1 w:0) + /// Proof: VaultRegistry VaultBitcoinPublicKey (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Fee RedeemFee (r:1 w:0) + /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) + /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) + /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:0 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Redeem RedeemRequests (r:0 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + fn request_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `2735` + // Estimated: `6364` + // Minimum execution time: 38_446_000_000 picoseconds. + Weight::from_parts(38_446_000_000, 6364) + .saturating_add(T::DbWeight::get().reads(21_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) + /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay Chains (r:1 w:0) + /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: BTCRelay BlockHeaders (r:1 w:0) + /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) + /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// The range of component `h` is `[2, 10]`. + /// The range of component `i` is `[1, 10]`. + /// The range of component `o` is `[2, 3]`. + /// The range of component `b` is `[541, 2048]`. + fn execute_replace (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2310` + // Estimated: `6364` + // Minimum execution time: 178_000_000 picoseconds. + Weight::from_parts(108_702_702, 6364) + // Standard Error: 433_012 + .saturating_add(Weight::from_parts(3_875_000, 0).saturating_mul(h.into())) + // Standard Error: 384_900 + .saturating_add(Weight::from_parts(1_444_444, 0).saturating_mul(i.into())) + // Standard Error: 3_464_101 + .saturating_add(Weight::from_parts(8_000_000, 0).saturating_mul(o.into())) + // Standard Error: 2_298 + .saturating_add(Weight::from_parts(11_280, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } } // For backwards compatibility and tests impl WeightInfo for () { - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + + /// Storage: VaultRegistry Vaults (r:1 w:1) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:2 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Fee RedeemFee (r:1 w:0) @@ -425,8 +571,6 @@ impl WeightInfo for () { /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) @@ -468,14 +612,14 @@ impl WeightInfo for () { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) - fn request_redeem() -> Weight { + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `4672` - // Estimated: `47658` - // Minimum execution time: 311_664_000 picoseconds. - Weight::from_parts(315_792_000, 47658) - .saturating_add(RocksDbWeight::get().reads(29_u64)) + // Measured: `3161` + // Estimated: `6260` + // Minimum execution time: 270_000_000 picoseconds. + Weight::from_parts(270_000_000, 6260) + .saturating_add(RocksDbWeight::get().reads(28_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: Tokens Accounts (r:3 w:3) @@ -502,17 +646,17 @@ impl WeightInfo for () { /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) /// Storage: Loans AccountDeposits (r:1 w:0) /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) - fn liquidation_redeem() -> Weight { + fn liquidation_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3861` - // Estimated: `40975` - // Minimum execution time: 279_078_000 picoseconds. - Weight::from_parts(282_886_000, 40975) + // Measured: `2193` + // Estimated: `8760` + // Minimum execution time: 257_000_000 picoseconds. + Weight::from_parts(257_000_000, 8760) .saturating_add(RocksDbWeight::get().reads(16_u64)) .saturating_add(RocksDbWeight::get().writes(11_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -532,32 +676,28 @@ impl WeightInfo for () { /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. /// The range of component `b` is `[541, 2048]`. - fn execute_redeem(h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_redeem (h: u32, _i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3463` - // Estimated: `18221` - // Minimum execution time: 180_491_000 picoseconds. - Weight::from_parts(156_971_337, 18221) - // Standard Error: 18_912 - .saturating_add(Weight::from_parts(1_667_781, 0).saturating_mul(h.into())) - // Standard Error: 17_010 - .saturating_add(Weight::from_parts(730_184, 0).saturating_mul(i.into())) - // Standard Error: 102_447 - .saturating_add(Weight::from_parts(810_488, 0).saturating_mul(o.into())) - // Standard Error: 103 - .saturating_add(Weight::from_parts(5_905, 0).saturating_mul(b.into())) + // Measured: `2268 + o * (1 ±0)` + // Estimated: `3743` + // Minimum execution time: 176_000_000 picoseconds. + Weight::from_parts(151_584_172, 3743) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(2_562_500, 0).saturating_mul(h.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(500_000, 0).saturating_mul(o.into())) + // Standard Error: 574 + .saturating_add(Weight::from_parts(8_958, 0).saturating_mul(b.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -565,7 +705,7 @@ impl WeightInfo for () { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -627,11 +767,11 @@ impl WeightInfo for () { /// Storage: VaultRewards TotalStake (r:1 w:1) /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) /// Storage: VaultCapacity TotalStake (r:1 w:1) /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) + /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) /// Storage: Loans RewardSupplyState (r:1 w:1) /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) /// Storage: Loans RewardSupplySpeed (r:1 w:0) @@ -644,19 +784,17 @@ impl WeightInfo for () { /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_reimburse() -> Weight { + fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `135176` - // Minimum execution time: 798_478_000 picoseconds. - Weight::from_parts(808_188_000, 135176) - .saturating_add(RocksDbWeight::get().reads(60_u64)) + // Measured: `5403` + // Estimated: `11350` + // Minimum execution time: 782_000_000 picoseconds. + Weight::from_parts(782_000_000, 11350) + .saturating_add(RocksDbWeight::get().reads(59_u64)) .saturating_add(RocksDbWeight::get().writes(29_u64)) } - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -664,7 +802,7 @@ impl WeightInfo for () { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -726,11 +864,11 @@ impl WeightInfo for () { /// Storage: VaultRewards TotalStake (r:1 w:1) /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) + /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) /// Storage: VaultCapacity TotalStake (r:1 w:1) /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) + /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) /// Storage: Loans RewardSupplyState (r:1 w:1) /// Proof: Loans RewardSupplyState (max_values: None, max_size: Some(47), added: 2522, mode: MaxEncodedLen) /// Storage: Loans RewardSupplySpeed (r:1 w:0) @@ -743,38 +881,187 @@ impl WeightInfo for () { /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) /// Storage: VaultRegistry PunishmentDelay (r:1 w:0) /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn cancel_redeem_retry() -> Weight { + fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: - // Measured: `7166` - // Estimated: `132666` - // Minimum execution time: 729_751_000 picoseconds. - Weight::from_parts(738_648_000, 132666) - .saturating_add(RocksDbWeight::get().reads(59_u64)) + // Measured: `5403` + // Estimated: `11350` + // Minimum execution time: 706_000_000 picoseconds. + Weight::from_parts(706_000_000, 11350) + .saturating_add(RocksDbWeight::get().reads(58_u64)) .saturating_add(RocksDbWeight::get().writes(28_u64)) } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: Fee PunishmentFee (r:1 w:0) + /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:1 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) + /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultCapacity Stake (r:1 w:0) + /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardPerToken (r:2 w:0) + /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardTally (r:2 w:2) + /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultCapacity TotalRewards (r:2 w:2) + /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultRewards Stake (r:1 w:0) + /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardPerToken (r:2 w:0) + /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardTally (r:2 w:2) + /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalRewards (r:2 w:2) + /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: Fee Commission (r:1 w:0) + /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) + /// Storage: VaultStaking RewardPerToken (r:2 w:2) + /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalStake (r:1 w:0) + /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalStake (r:1 w:0) + /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + fn cancel_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `4404` + // Estimated: `6364` + // Minimum execution time: 394_000_000 picoseconds. + Weight::from_parts(394_000_000, 6364) + .saturating_add(RocksDbWeight::get().reads(33_u64)) + .saturating_add(RocksDbWeight::get().writes(15_u64)) + } /// Storage: Redeem RedeemPeriod (r:0 w:1) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_redeem_period() -> Weight { + fn set_redeem_period () -> Weight { // Proof Size summary in bytes: - // Measured: `1025` + // Measured: `0` // Estimated: `0` - // Minimum execution time: 28_527_000 picoseconds. - Weight::from_parts(29_970_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) - fn self_redeem() -> Weight { + fn self_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `2449` - // Estimated: `7835` - // Minimum execution time: 147_756_000 picoseconds. - Weight::from_parts(149_109_000, 7835) + // Measured: `1399` + // Estimated: `3677` + // Minimum execution time: 116_000_000 picoseconds. + Weight::from_parts(116_000_000, 3677) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } -} + /// Storage: BTCRelay StartBlockHeight (r:1 w:0) + /// Proof: BTCRelay StartBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueBtcDustValue (r:1 w:0) + /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:2 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:2 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: Security Nonce (r:1 w:1) + /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: System ParentHash (r:1 w:0) + /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: VaultRegistry VaultBitcoinPublicKey (r:1 w:0) + /// Proof: VaultRegistry VaultBitcoinPublicKey (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Fee RedeemFee (r:1 w:0) + /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) + /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) + /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:0 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Redeem RedeemRequests (r:0 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + fn request_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `2735` + // Estimated: `6364` + // Minimum execution time: 38_446_000_000 picoseconds. + Weight::from_parts(38_446_000_000, 6364) + .saturating_add(RocksDbWeight::get().reads(21_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) + /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay Chains (r:1 w:0) + /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: BTCRelay BlockHeaders (r:1 w:0) + /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) + /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// The range of component `h` is `[2, 10]`. + /// The range of component `i` is `[1, 10]`. + /// The range of component `o` is `[2, 3]`. + /// The range of component `b` is `[541, 2048]`. + fn execute_replace (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2310` + // Estimated: `6364` + // Minimum execution time: 178_000_000 picoseconds. + Weight::from_parts(108_702_702, 6364) + // Standard Error: 433_012 + .saturating_add(Weight::from_parts(3_875_000, 0).saturating_mul(h.into())) + // Standard Error: 384_900 + .saturating_add(Weight::from_parts(1_444_444, 0).saturating_mul(i.into())) + // Standard Error: 3_464_101 + .saturating_add(Weight::from_parts(8_000_000, 0).saturating_mul(o.into())) + // Standard Error: 2_298 + .saturating_add(Weight::from_parts(11_280, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } +} \ No newline at end of file diff --git a/crates/redeem/src/ext.rs b/crates/redeem/src/ext.rs index a1156eb7e9..ba51790e80 100644 --- a/crates/redeem/src/ext.rs +++ b/crates/redeem/src/ext.rs @@ -43,6 +43,22 @@ pub(crate) mod vault_registry { use frame_support::dispatch::{DispatchError, DispatchResult}; use vault_registry::types::{CurrencyId, CurrencySource, DefaultVault}; + pub fn is_vault_fully_replacing( + vault_id: &DefaultVaultId, + to_redeem_tokens: &Amount, + ) -> Result { + >::is_vault_fully_replacing(vault_id, to_redeem_tokens) + } + + pub fn cancel_replace_tokens( + old_vault_id: &DefaultVaultId, + new_vault_id: &DefaultVaultId, + redeem_tokens: &Amount, + issue_tokens: &Amount, + ) -> DispatchResult { + >::cancel_replace_tokens(old_vault_id, new_vault_id, redeem_tokens, issue_tokens) + } + pub fn get_liquidated_collateral( vault_id: &DefaultVaultId, ) -> Result, DispatchError> { @@ -159,13 +175,6 @@ pub(crate) mod vault_registry { pub fn issue_tokens(vault_id: &DefaultVaultId, amount: &Amount) -> DispatchResult { >::issue_tokens(vault_id, amount) } - - pub fn decrease_to_be_replaced_tokens( - vault_id: &DefaultVaultId, - tokens: &Amount, - ) -> Result<(Amount, Amount), DispatchError> { - >::decrease_to_be_replaced_tokens(vault_id, tokens) - } } #[cfg_attr(test, mockable)] @@ -227,3 +236,33 @@ pub(crate) mod fee { >::get_premium_redeem_fee(amount) } } + +#[cfg_attr(test, mockable)] +pub(crate) mod issue { + use crate::{types::BalanceOf, DefaultVaultId, DispatchError}; + use bitcoin::Address; + use primitives::AccountOrVault; + use sp_core::H256; + use vault_registry::types::CurrencyId; + + pub fn request_vault_issue( + requester: AccountOrVault, + amount_requested: BalanceOf, + vault_id: DefaultVaultId, + griefing_currency: CurrencyId, + ) -> Result<(H256, Address), DispatchError> { + >::_request_issue(requester, amount_requested, vault_id, griefing_currency) + } + + pub fn complete_vault_issue(issue_id: H256) -> Result<(), DispatchError> { + >::_complete_vault_issue(issue_id) + } + + pub fn get_vault_from_issue_id(issue_id: &H256) -> Result, DispatchError> { + >::get_vault_from_issue_id(issue_id) + } + + pub fn cancel_issue(issue_id: H256, redeemer: T::AccountId) -> Result<(), DispatchError> { + >::_cancel_issue(redeemer, issue_id) + } +} diff --git a/crates/redeem/src/lib.rs b/crates/redeem/src/lib.rs index ffd3acc3f3..8df47296a6 100644 --- a/crates/redeem/src/lib.rs +++ b/crates/redeem/src/lib.rs @@ -51,6 +51,22 @@ use vault_registry::{ }; pub use pallet::*; +use primitives::{AccountOrVault, VaultId}; + +fn calculate_weight( + merkle_proof_hashes: u32, + inputs_len: u32, + outputs_len: u32, + tx_encoded_len: u32, +) -> Weight { + ::WeightInfo::execute_redeem(merkle_proof_hashes, inputs_len, outputs_len, tx_encoded_len) + .saturating_add(::WeightInfo::execute_redeem( + merkle_proof_hashes, + inputs_len, + outputs_len, + tx_encoded_len, + )) +} /// Complexity: /// - `O(H + I + O + B)` where: @@ -59,18 +75,21 @@ pub use pallet::*; /// - `O` is the number of transaction outputs /// - `B` is `transaction` size in bytes (length-fee-bounded) fn weight_for_execute_redeem(proof: &FullTransactionProof) -> Weight { - ::WeightInfo::execute_redeem( + let execute_redeem_weight = calculate_weight::( + proof.user_tx_proof.merkle_proof.hashes.len() as u32, // H + proof.user_tx_proof.transaction.inputs.len() as u32, // I + proof.user_tx_proof.transaction.outputs.len() as u32, // O + proof.user_tx_proof.tx_encoded_len, + ); + + let execute_replace_weight = calculate_weight::( proof.user_tx_proof.merkle_proof.hashes.len() as u32, // H proof.user_tx_proof.transaction.inputs.len() as u32, // I proof.user_tx_proof.transaction.outputs.len() as u32, // O proof.user_tx_proof.tx_encoded_len, - ) - .saturating_add(::WeightInfo::execute_redeem( - proof.coinbase_proof.merkle_proof.hashes.len() as u32, // H - proof.coinbase_proof.transaction.inputs.len() as u32, // I - proof.coinbase_proof.transaction.outputs.len() as u32, // O - proof.coinbase_proof.tx_encoded_len, - )) + ); + + execute_redeem_weight.max(execute_replace_weight) } #[frame_support::pallet] @@ -78,13 +97,14 @@ pub mod pallet { use super::*; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; - use primitives::VaultId; use vault_registry::types::DefaultVaultCurrencyPair; /// ## Configuration /// The pallet's configuration trait. #[pallet::config] - pub trait Config: frame_system::Config + vault_registry::Config + btc_relay::Config + fee::Config { + pub trait Config: + frame_system::Config + vault_registry::Config + btc_relay::Config + fee::Config + issue::Config + { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -124,6 +144,14 @@ pub mod pallet { slashed_amount: BalanceOf, status: RedeemRequestStatus, }, + CancelReplace { + redeem_id: H256, + issue_id: H256, + old_vault: DefaultVaultId, + new_vault: DefaultVaultId, + status: RedeemRequestStatus, + punishment_fee: BalanceOf, + }, MintTokensForReimbursedRedeem { redeem_id: H256, vault_id: DefaultVaultId, @@ -159,6 +187,14 @@ pub mod pallet { TryIntoIntError, /// Redeem amount is too small. AmountBelowDustAmount, + /// Invalid Cancel request. + InvalidCancelRequest, + /// Cannot replace self. + ReplaceSelfNotAllowed, + /// Vault cannot replace different currency. + InvalidWrappedCurrency, + /// The issue id is not found for replace request + IsseeIdNotFoundForReplaceRequest, } /// The time difference in number of blocks between a redeem request is created and required completion time by a @@ -224,7 +260,11 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks for Pallet {} + impl Hooks for Pallet { + fn on_runtime_upgrade() -> frame_support::weights::Weight { + crate::types::v1::migrate_v0_to_v1::() + } + } #[pallet::pallet] pub struct Pallet(_); @@ -250,8 +290,8 @@ pub mod pallet { btc_address: BtcAddress, vault_id: DefaultVaultId, ) -> DispatchResultWithPostInfo { - let redeemer = ensure_signed(origin)?; - Self::_request_redeem(redeemer, amount_wrapped, btc_address, vault_id)?; + let redeemer = AccountOrVault::Account(ensure_signed(origin)?); + Self::_request_redeem(redeemer, amount_wrapped, btc_address, vault_id, None)?; Ok(().into()) } @@ -319,7 +359,14 @@ pub mod pallet { /// and slash the Vault, or wishes to keep the tokens (and retry /// Redeem with another Vault) #[pallet::call_index(3)] - #[pallet::weight(if *reimburse { ::WeightInfo::cancel_redeem_reimburse() } else { ::WeightInfo::cancel_redeem_retry() })] + #[pallet::weight( + ::WeightInfo::cancel_replace() + .max(if *reimburse { + ::WeightInfo::cancel_redeem_reimburse() + } else { + ::WeightInfo::cancel_redeem_retry() + }) + )] #[transactional] pub fn cancel_redeem(origin: OriginFor, redeem_id: H256, reimburse: bool) -> DispatchResultWithPostInfo { let redeemer = ensure_signed(origin)?; @@ -385,6 +432,43 @@ pub mod pallet { Ok(().into()) } + + /// Request a replace operation for a vault + /// + /// ## Parameters + /// + /// - `origin`: The origin from which the request is made, typically the vault owner. + /// - `currency_pair`: The trading pair associated with the collateral and backing assets. + /// - `amount`: The amount of backed asset to be replaced. + /// - `new_vault_id`: The identifier of the new vault that will replace the existing vault. + /// - `griefing_currency`: The currency in which a griefing deposit is required for the replace. + /// + /// ## Returns + /// + /// If the replace operation is successful, this function returns `Ok`. If the operation fails, + /// an appropriate error indicating the reason for failure is returned. + #[pallet::call_index(7)] + #[pallet::weight(::WeightInfo::request_replace())] + #[transactional] + pub fn request_replace( + origin: OriginFor, + currency_pair: DefaultVaultCurrencyPair, + amount: BalanceOf, + new_vault_id: DefaultVaultId, + griefing_currency: CurrencyId, + ) -> DispatchResultWithPostInfo { + let old_vault_account = ensure_signed(origin)?; + + Self::_request_replace( + old_vault_account, + currency_pair, + amount, + new_vault_id, + griefing_currency, + )?; + + Ok(().into()) + } } } @@ -462,61 +546,123 @@ mod self_redeem { &vault_id.account_id, )?; - Pallet::::release_replace_collateral(vault_id, consumed_issued_tokens)?; Ok(()) } } // "Internal" functions, callable by code. #[cfg_attr(test, mockable)] impl Pallet { + fn _request_replace( + old_vault_account: T::AccountId, + currency_pair: DefaultVaultCurrencyPair, + amount: BalanceOf, + new_vault_id: DefaultVaultId, + griefing_currency: CurrencyId, + ) -> Result<(), DispatchError> { + // Create VaultId for the old vault + let old_vault_id = VaultId::new( + old_vault_account.clone(), + currency_pair.collateral, + currency_pair.wrapped, + ); + + // Define old and new vault references + let old_vault = AccountOrVault::Vault(old_vault_id.clone()); + let new_vault = AccountOrVault::Vault(new_vault_id.clone()); + + // probably this check is not strictly required, but it's better to give an + // explicit error rather than insufficient balance + ensure!( + old_vault_id.wrapped_currency() == new_vault_id.wrapped_currency(), + Error::::InvalidWrappedCurrency + ); + + // don't allow vaults to replace themselves + ensure!(old_vault != new_vault, Error::::ReplaceSelfNotAllowed); + + // Initiate issue call + let (issue_id, btc_address) = + ext::issue::request_vault_issue::(old_vault, amount, new_vault_id, griefing_currency)?; + + // Initiate redeem call + Self::_request_redeem(new_vault, amount, btc_address, old_vault_id, Some(issue_id))?; + + Ok(()) + } + fn _request_redeem( - redeemer: T::AccountId, + redeemer: AccountOrVault, amount_wrapped: BalanceOf, btc_address: BtcAddress, vault_id: DefaultVaultId, + issue_id: Option, ) -> Result { let amount_wrapped = Amount::new(amount_wrapped, vault_id.wrapped_currency()); - - let redeemer_balance = ext::treasury::get_balance::(&redeemer, vault_id.wrapped_currency()); - ensure!( - amount_wrapped.le(&redeemer_balance)?, - Error::::AmountExceedsUserBalance - ); + let is_replace_request = redeemer.is_vault_account(); // We saw a user lose bitcoin when they forgot to enter the address in the polkadot-js ui. // Make sure this can't happen again. ensure!(!btc_address.is_zero(), btc_relay::Error::::InvalidBtcHash); - // todo: currently allowed to redeem from one currency to the other for free - decide if this is desirable - let fee_wrapped = if redeemer == vault_id.account_id { - Amount::zero(vault_id.wrapped_currency()) + ext::vault_registry::ensure_not_banned::(&vault_id)?; + + let (fee_wrapped, inclusion_fee, user_to_be_received_btc) = if is_replace_request { + // If vault if completely replacing the collateral then don't charge fees + let fee_wrapped = if ext::vault_registry::is_vault_fully_replacing::(&vault_id, &amount_wrapped)? { + Amount::zero(vault_id.wrapped_currency()) + } else { + ext::fee::get_redeem_fee::(&amount_wrapped)? + }; + + ( + fee_wrapped, + // the inclusion fee is paid by old vault itself hence we can set it as zero + Amount::zero(vault_id.wrapped_currency()), + // the new vault (redeemer) should receive the whole amount without deduction of fees + // as fee handling is done by old vault itself + amount_wrapped.clone(), + ) } else { - ext::fee::get_redeem_fee::(&amount_wrapped)? - }; - let inclusion_fee = Self::get_current_inclusion_fee(vault_id.wrapped_currency())?; + let redeemer_balance = + ext::treasury::get_balance::(&redeemer.get_account(), vault_id.wrapped_currency()); + ensure!( + amount_wrapped.le(&redeemer_balance)?, + Error::::AmountExceedsUserBalance, + ); + + let fee_wrapped = if redeemer.get_account().clone() == vault_id.account_id { + Amount::zero(vault_id.wrapped_currency()) + } else { + ext::fee::get_redeem_fee::(&amount_wrapped)? + }; - let vault_to_be_burned_tokens = amount_wrapped.checked_sub(&fee_wrapped)?; + let inclusion_fee = Self::get_current_inclusion_fee(vault_id.wrapped_currency())?; - // this can overflow for small requested values. As such return AmountBelowDustAmount when this happens - let user_to_be_received_btc = vault_to_be_burned_tokens - .checked_sub(&inclusion_fee) - .map_err(|_| Error::::AmountBelowDustAmount)?; + let vault_to_be_burned_tokens = amount_wrapped.checked_sub(&fee_wrapped)?; - ext::vault_registry::ensure_not_banned::(&vault_id)?; + let user_to_be_received_btc = vault_to_be_burned_tokens + .checked_sub(&inclusion_fee) + .map_err(|_| Error::::AmountBelowDustAmount)?; + + amount_wrapped.lock_on(redeemer.get_account())?; + + (fee_wrapped, inclusion_fee, user_to_be_received_btc) + }; // only allow requests of amount above above the minimum ensure!( - // this is the amount the vault will send (minus fee) + // this is the amount the vault will send user_to_be_received_btc.ge(&Self::get_dust_value(vault_id.wrapped_currency()))?, Error::::AmountBelowDustAmount ); - // vault will get rid of the btc + btc_inclusion_fee - ext::vault_registry::try_increase_to_be_redeemed_tokens::(&vault_id, &vault_to_be_burned_tokens)?; + // increased the to_be_redeem tokens by amount_wrapped - fee_wrapped + ext::vault_registry::try_increase_to_be_redeemed_tokens::( + &vault_id, + &amount_wrapped.checked_sub(&fee_wrapped)?, + )?; - // lock full amount (inc. fee) - amount_wrapped.lock_on(&redeemer)?; - let redeem_id = ext::security::get_secure_id::(&redeemer); + let redeem_id = ext::security::get_secure_id::(redeemer.get_account()); let below_premium_redeem = ext::vault_registry::is_vault_below_premium_threshold::(&vault_id)?; let currency_id = vault_id.collateral_currency(); @@ -528,8 +674,6 @@ impl Pallet { Amount::zero(currency_id) }; - Self::release_replace_collateral(&vault_id, &vault_to_be_burned_tokens)?; - Self::insert_redeem_request( &redeem_id, &RedeemRequest { @@ -540,16 +684,17 @@ impl Pallet { amount_btc: user_to_be_received_btc.amount(), premium: premium_collateral.amount(), period: Self::redeem_period(), - redeemer: redeemer.clone(), + redeemer: redeemer.get_account().clone(), btc_address, btc_height: ext::btc_relay::get_best_block_height::(), status: RedeemRequestStatus::Pending, + issue_id, }, ); Self::deposit_event(Event::::RequestRedeem { redeem_id, - redeemer, + redeemer: redeemer.get_account().clone(), amount: user_to_be_received_btc.amount(), fee: fee_wrapped.amount(), premium: premium_collateral.amount(), @@ -598,17 +743,36 @@ impl Pallet { redeem_id, )?; - // burn amount (without parachain fee, but including transfer fee) - let burn_amount = redeem.amount_btc().checked_add(&redeem.transfer_fee_btc())?; - burn_amount.burn_from(&redeem.redeemer)?; + // if redeem has issue_id its a replace request + let (fee, redeem_amount) = if let Some(issue_id) = redeem.issue_id { + let replace_fee = redeem.fee(); + + //redeem tokens for old vault + let redeem_tokens = redeem.amount_btc().checked_sub(&replace_fee)?; + + // complete_vault_issue increases issued_tokens & decreases to_be_issued for new vault + ext::issue::complete_vault_issue::(issue_id)?; + + // mint wrapped fees + replace_fee.mint_to(&ext::fee::fee_pool_account_id::())?; + + (replace_fee, redeem_tokens) + } else { + // burn amount (without parachain fee, but including transfer fee) + let burn_amount = redeem.amount_btc().checked_add(&redeem.transfer_fee_btc())?; + burn_amount.burn_from(&redeem.redeemer)?; + + // send fees to pool + let fee = redeem.fee(); + fee.unlock_on(&redeem.redeemer)?; + fee.transfer(&redeem.redeemer, &ext::fee::fee_pool_account_id::())?; + (fee, burn_amount) + }; - // send fees to pool - let fee = redeem.fee(); - fee.unlock_on(&redeem.redeemer)?; - fee.transfer(&redeem.redeemer, &ext::fee::fee_pool_account_id::())?; ext::fee::distribute_rewards::(&fee)?; - ext::vault_registry::redeem_tokens::(&redeem.vault, &burn_amount, &redeem.premium()?, &redeem.redeemer)?; + //redeem tokens for vault + ext::vault_registry::redeem_tokens::(&redeem.vault, &redeem_amount, &redeem.premium()?, &redeem.redeemer)?; Self::set_redeem_status(redeem_id, RedeemRequestStatus::Completed); Self::deposit_event(Event::::ExecuteRedeem { @@ -622,20 +786,14 @@ impl Pallet { Ok(()) } - fn _cancel_redeem(redeemer: T::AccountId, redeem_id: H256, reimburse: bool) -> DispatchResult { - let redeem = Self::get_open_redeem_request_from_id(&redeem_id)?; + fn _cancel_redeem_request( + redeem: DefaultRedeemRequest, + redeemer: T::AccountId, + redeem_id: H256, + reimburse: bool, + ) -> DispatchResult { ensure!(redeemer == redeem.redeemer, Error::::UnauthorizedRedeemer); - // only cancellable after the request has expired - ensure!( - ext::btc_relay::has_request_expired::( - redeem.opentime, - redeem.btc_height, - Self::redeem_period().max(redeem.period) - )?, - Error::::TimeNotExpired - ); - let vault = ext::vault_registry::get_vault_from_id::(&redeem.vault)?; let vault_to_be_redeemed_tokens = Amount::new(vault.to_be_redeemed_tokens, redeem.vault.wrapped_currency()); let vault_id = redeem.vault.clone(); @@ -732,6 +890,80 @@ impl Pallet { Ok(()) } + // Cancels a replace request + fn _cancel_replace_request( + redeem: DefaultRedeemRequest, + redeem_id: H256, + issue_id: H256, + redeemer: T::AccountId, + ) -> DispatchResult { + let old_vault_id = redeem.vault.clone(); + let new_vault_id = ext::issue::get_vault_from_issue_id::(&issue_id)?; + + // cancel issue request + ext::issue::cancel_issue::(issue_id, redeemer)?; + + let redeem_tokens = redeem.amount_btc().checked_sub(&redeem.fee())?; + + // decrease old-vault's to-be-redeemed tokens, and + // decrease new-vault's to-be-issued tokens + ext::vault_registry::cancel_replace_tokens::( + &old_vault_id, + &new_vault_id, + &redeem_tokens, + &redeem.amount_btc(), + )?; + + let amount_wrapped_in_collateral = redeem.amount_btc().convert_to(old_vault_id.collateral_currency())?; + + // calculate the punishment fee (e.g. 10%) + let punishment_fee = ext::fee::get_punishment_fee::(&amount_wrapped_in_collateral)?; + + ext::vault_registry::transfer_funds_saturated::( + CurrencySource::Collateral(old_vault_id.clone()), + CurrencySource::FreeBalance(new_vault_id.account_id.clone()), + &punishment_fee, + )?; + + // Set the status of the redeem request to "Cancelled" + Self::set_redeem_status(redeem_id, RedeemRequestStatus::Cancelled); + + // release event + Self::deposit_event(Event::::CancelReplace { + redeem_id, + issue_id, + old_vault: old_vault_id, + new_vault: new_vault_id, + status: RedeemRequestStatus::Cancelled, + punishment_fee: punishment_fee.amount(), + }); + + Ok(()) + } + + fn _cancel_redeem(redeemer: T::AccountId, redeem_id: H256, reimburse: bool) -> DispatchResult { + // Retrieve the redeem request associated with the redeem_id + let redeem = Self::get_open_redeem_request_from_id(&redeem_id)?; + + // only cancellable after the request has expired + ensure!( + ext::btc_relay::has_request_expired::( + redeem.opentime, + redeem.btc_height, + Self::redeem_period().max(redeem.period) + )?, + Error::::TimeNotExpired + ); + + if let Some(issue_id) = redeem.issue_id { + // Cancel the replace request using the redeem request, redeem_id and issue_id + Self::_cancel_replace_request(redeem, redeem_id, issue_id, redeemer) + } else { + // If there's no associated issue_id, cancel the redeem request + Self::_cancel_redeem_request(redeem, redeemer, redeem_id, reimburse) + } + } + fn _mint_tokens_for_reimbursed_redeem(vault_id: DefaultVaultId, redeem_id: H256) -> DispatchResult { let redeem = RedeemRequests::::try_get(&redeem_id).or(Err(Error::::RedeemIdNotFound))?; ensure!( @@ -758,24 +990,6 @@ impl Pallet { Ok(()) } - fn release_replace_collateral(vault_id: &DefaultVaultId, burned_tokens: &Amount) -> DispatchResult { - // decrease to-be-replaced tokens - when the vault requests tokens to be replaced, it - // want to get rid of tokens, and it does not matter whether this is through a redeem, - // or a replace. As such, we decrease the to-be-replaced tokens here. This call will - // never fail due to insufficient to-be-replaced tokens - let (_, griefing_collateral) = - ext::vault_registry::decrease_to_be_replaced_tokens::(&vault_id, &burned_tokens)?; - // release the griefing collateral that is locked for the replace request - if !griefing_collateral.is_zero() { - ext::vault_registry::transfer_funds( - CurrencySource::AvailableReplaceCollateral(vault_id.clone()), - CurrencySource::FreeBalance(vault_id.account_id.clone()), - &griefing_collateral, - )?; - } - Ok(()) - } - /// Insert a new redeem request into state. /// /// # Arguments @@ -850,7 +1064,7 @@ impl Pallet { match request.status { RedeemRequestStatus::Pending => Ok(request), RedeemRequestStatus::Completed => Err(Error::::RedeemCompleted.into()), - RedeemRequestStatus::Reimbursed(_) | RedeemRequestStatus::Retried => { + RedeemRequestStatus::Reimbursed(_) | RedeemRequestStatus::Retried | RedeemRequestStatus::Cancelled => { Err(Error::::RedeemCancelled.into()) } } diff --git a/crates/redeem/src/mock.rs b/crates/redeem/src/mock.rs index 1f1294819d..9c4b7ea658 100644 --- a/crates/redeem/src/mock.rs +++ b/crates/redeem/src/mock.rs @@ -15,7 +15,7 @@ pub use sp_arithmetic::{FixedI128, FixedPointNumber, FixedU128}; use sp_core::H256; use sp_runtime::{ testing::{Header, TestXt}, - traits::{BlakeTwo256, IdentityLookup, Zero}, + traits::{BlakeTwo256, Convert, IdentityLookup, Zero}, }; type TestExtrinsic = TestXt; @@ -49,6 +49,7 @@ frame_support::construct_runtime!( Currency: currency::{Pallet}, Nomination: nomination::{Pallet, Call, Config, Storage, Event}, Loans: loans::{Pallet, Storage, Call, Event, Config}, + Issue: issue::{Pallet, Call, Config, Storage, Event}, } ); @@ -269,6 +270,25 @@ impl loans::Config for Test { type OnExchangeRateChange = (); } +parameter_types! { + pub const TreasuryPalletId: PalletId = PalletId(*b"mod/trsy"); +} + +pub struct BlockNumberToBalance; + +impl Convert for BlockNumberToBalance { + fn convert(a: BlockNumber) -> Balance { + a.into() + } +} + +impl issue::Config for Test { + type TreasuryPalletId = TreasuryPalletId; + type RuntimeEvent = RuntimeEvent; + type BlockNumberToBalance = BlockNumberToBalance; + type WeightInfo = (); +} + impl Config for Test { type RuntimeEvent = RuntimeEvent; type WeightInfo = (); @@ -288,6 +308,23 @@ pub const VAULT: VaultId = VaultId { }; pub const CAROL: AccountId = 3; +pub const OLD_VAULT: VaultId = VaultId { + account_id: 4, + currencies: VaultCurrencyPair { + collateral: DEFAULT_COLLATERAL_CURRENCY, + wrapped: DEFAULT_WRAPPED_CURRENCY, + }, +}; +pub const NEW_VAULT: VaultId = VaultId { + account_id: 5, + currencies: VaultCurrencyPair { + collateral: DEFAULT_COLLATERAL_CURRENCY, + wrapped: DEFAULT_WRAPPED_CURRENCY, + }, +}; + +pub const OLD_VAULT_BALANCE: u128 = 1_000_000; +pub const NEW_VAULT_BALANCE: u128 = 1_000_000; pub const ALICE_BALANCE: u128 = 1_005_000; pub const VAULT_BALANCE: u128 = 1_005_000; pub const CAROL_BALANCE: u128 = 1_005_000; @@ -367,6 +404,8 @@ impl ExtBuilder { (USER, Token(IBTC), ALICE_BALANCE), (VAULT.account_id, Token(IBTC), VAULT_BALANCE), (CAROL, Token(IBTC), CAROL_BALANCE), + (OLD_VAULT.account_id, Token(DOT), OLD_VAULT_BALANCE), + (NEW_VAULT.account_id, Token(DOT), NEW_VAULT_BALANCE), ], }) } diff --git a/crates/redeem/src/tests.rs b/crates/redeem/src/tests.rs index c31a0afd15..5692be2f35 100644 --- a/crates/redeem/src/tests.rs +++ b/crates/redeem/src/tests.rs @@ -15,9 +15,6 @@ type Event = crate::Event; fn collateral(amount: u128) -> Amount { Amount::new(amount, DEFAULT_COLLATERAL_CURRENCY) } -fn griefing(amount: u128) -> Amount { - Amount::new(amount, DEFAULT_NATIVE_CURRENCY) -} fn wrapped(amount: u128) -> Amount { Amount::new(amount, DEFAULT_WRAPPED_CURRENCY) } @@ -43,12 +40,9 @@ fn inject_redeem_request(key: H256, value: RedeemRequest DefaultVault { vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 10, - replace_collateral: 0, to_be_redeemed_tokens: 0, - active_replace_collateral: 0, banned_until: None, secure_collateral_threshold: None, status: VaultStatus::Active(true), @@ -59,6 +53,8 @@ fn default_vault() -> DefaultVault { #[test] fn test_request_redeem_fails_with_amount_exceeds_user_balance() { run_test(|| { + ext::vault_registry::ensure_not_banned::.mock_safe(move |_vault_id| MockResult::Return(Ok(()))); + let amount = Amount::::new(2, ::GetWrappedCurrencyId::get()); amount.mint_to(&USER).unwrap(); let amount = 10_000_000; @@ -77,12 +73,9 @@ fn test_request_redeem_fails_with_amount_below_minimum() { &VAULT, vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 10, - replace_collateral: 0, to_be_redeemed_tokens: 0, - active_replace_collateral: 0, banned_until: None, secure_collateral_threshold: None, status: VaultStatus::Active(true), @@ -149,12 +142,9 @@ fn test_request_redeem_succeeds_with_normal_redeem() { &VAULT, vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 10, to_be_redeemed_tokens: 0, - replace_collateral: 0, - active_replace_collateral: 0, banned_until: None, secure_collateral_threshold: None, status: VaultStatus::Active(true), @@ -221,6 +211,7 @@ fn test_request_redeem_succeeds_with_normal_redeem() { transfer_fee_btc: Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY) .unwrap() .amount(), + issue_id: None, } ); }) @@ -254,12 +245,9 @@ fn test_request_redeem_succeeds_with_self_redeem() { &VAULT, vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 10, to_be_redeemed_tokens: 0, - active_replace_collateral: 0, - replace_collateral: 0, banned_until: None, secure_collateral_threshold: None, status: VaultStatus::Active(true), @@ -324,6 +312,7 @@ fn test_request_redeem_succeeds_with_self_redeem() { transfer_fee_btc: Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY) .unwrap() .amount(), + issue_id: None, } ); }) @@ -395,12 +384,9 @@ fn test_execute_redeem_succeeds_with_another_account() { &VAULT, vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 200, to_be_redeemed_tokens: 200, - replace_collateral: 0, - active_replace_collateral: 0, banned_until: None, secure_collateral_threshold: None, status: VaultStatus::Active(true), @@ -426,6 +412,7 @@ fn test_execute_redeem_succeeds_with_another_account() { btc_height: 0, status: RedeemRequestStatus::Pending, transfer_fee_btc: btc_fee.amount(), + issue_id: None, }, ); @@ -472,12 +459,9 @@ fn test_execute_redeem_succeeds() { &VAULT, vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 200, to_be_redeemed_tokens: 200, - replace_collateral: 0, - active_replace_collateral: 0, banned_until: None, secure_collateral_threshold: None, status: VaultStatus::Active(true), @@ -503,6 +487,7 @@ fn test_execute_redeem_succeeds() { btc_height: 0, status: RedeemRequestStatus::Pending, transfer_fee_btc: btc_fee.amount(), + issue_id: None, }, ); @@ -570,6 +555,7 @@ fn test_cancel_redeem_fails_with_time_not_expired() { transfer_fee_btc: Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY) .unwrap() .amount(), + issue_id: None, })) }); @@ -583,6 +569,7 @@ fn test_cancel_redeem_fails_with_time_not_expired() { #[test] fn test_cancel_redeem_fails_with_unauthorized_caller() { run_test(|| { + ext::btc_relay::has_request_expired::.mock_safe(|_, _, _| MockResult::Return(Ok(true))); Security::::set_active_block_number(20); Redeem::get_open_redeem_request_from_id.mock_safe(|_| { @@ -600,6 +587,7 @@ fn test_cancel_redeem_fails_with_unauthorized_caller() { transfer_fee_btc: Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY) .unwrap() .amount(), + issue_id: None, })) }); @@ -629,6 +617,7 @@ fn test_cancel_redeem_succeeds() { transfer_fee_btc: Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY) .unwrap() .amount(), + issue_id: None, }, ); @@ -685,6 +674,7 @@ fn test_mint_tokens_for_reimbursed_redeem() { btc_height: 0, status: RedeemRequestStatus::Reimbursed(false), transfer_fee_btc: 1, + issue_id: None, }; let redeem_request_clone = redeem_request.clone(); inject_redeem_request(H256([0u8; 32]), redeem_request.clone()); @@ -742,6 +732,140 @@ fn test_set_redeem_period_only_root() { }) } +mod redeem_replace_tests { + use super::*; + + fn setup_mocks() { + ext::vault_registry::ensure_not_banned::.mock_safe(|_| MockResult::Return(Ok(()))); + ext::vault_registry::transfer_funds::.mock_safe(|_, _, _| MockResult::Return(Ok(()))); + ext::vault_registry::try_increase_to_be_redeemed_tokens:: + .mock_safe(move |_vault_id, _amount| MockResult::Return(Ok(()))); + ext::security::get_secure_id::.mock_safe(move |_| MockResult::Return(H256([0; 32]))); + ext::vault_registry::is_vault_below_premium_threshold:: + .mock_safe(move |_vault_id| MockResult::Return(Ok(false))); + ext::vault_registry::is_vault_fully_replacing::.mock_safe(move |_, _| MockResult::Return(Ok(false))); + } + + fn setup_execute_redeem() { + let btc_address = BtcAddress::random(); + let request_btc_address = btc_address.clone(); + + ext::issue::request_vault_issue:: + .mock_safe(move |_, _, _, _| MockResult::Return(Ok((H256([1; 32]), request_btc_address)))); + ext::issue::complete_vault_issue::.mock_safe(move |_| MockResult::Return(Ok(()))); + ext::btc_relay::verify_and_validate_op_return_transaction:: + .mock_safe(|_, _, _, _| MockResult::Return(Ok(()))); + ext::btc_relay::has_request_expired::.mock_safe(|_, _, _| MockResult::Return(Ok(true))); + ext::issue::get_vault_from_issue_id::.mock_safe(|_| MockResult::Return(Ok(NEW_VAULT))); + ext::vault_registry::cancel_replace_tokens::.mock_safe(|_, _, _, _| MockResult::Return(Ok(()))); + ext::vault_registry::transfer_funds_saturated:: + .mock_safe(move |_, _, amount| MockResult::Return(Ok(amount.clone()))); + ext::issue::cancel_issue::.mock_safe(|_, _| MockResult::Return(Ok(()))); + + let amount = 10; + assert_ok!(Redeem::request_replace( + RuntimeOrigin::signed(OLD_VAULT.account_id), + OLD_VAULT.currencies, + amount, + NEW_VAULT, + DEFAULT_NATIVE_CURRENCY + )); + + ext::vault_registry::redeem_tokens::.mock_safe(move |vault, amount_wrapped, premium, redeemer| { + assert_eq!(vault, &OLD_VAULT); + assert_eq!(amount_wrapped, &wrapped(amount)); + assert_eq!(premium, &collateral(0)); + assert_eq!(redeemer, &NEW_VAULT.account_id); + MockResult::Return(Ok(())) + }); + } + + #[test] + fn test_request_replace() { + run_test(|| { + setup_mocks(); + let btc_address = BtcAddress::random(); + let request_btc_address = btc_address.clone(); + + ext::issue::request_vault_issue:: + .mock_safe(move |_, _, _, _| MockResult::Return(Ok((H256([1; 32]), request_btc_address)))); + + let amount = 10; + assert_ok!(Redeem::request_replace( + RuntimeOrigin::signed(OLD_VAULT.account_id), + OLD_VAULT.currencies, + amount, + NEW_VAULT, + DEFAULT_NATIVE_CURRENCY + )); + + assert_emitted!(Event::RequestRedeem { + redeem_id: H256([0; 32]), + redeemer: NEW_VAULT.account_id, + amount: amount, + fee: 0, + premium: 0, + vault_id: OLD_VAULT, + btc_address, + transfer_fee: 0 + }); + }) + } + + #[test] + fn test_execute_redeem_for_replace() { + run_test(|| { + setup_mocks(); + setup_execute_redeem(); + + // call execute redeem + assert_ok!(Redeem::_execute_redeem( + H256([0u8; 32]), + get_some_unchecked_transaction() + )); + + assert_emitted!(Event::ExecuteRedeem { + redeem_id: H256([0; 32]), + redeemer: NEW_VAULT.account_id, + vault_id: OLD_VAULT, + amount: 10, + fee: 0, + transfer_fee: 0, + }); + + assert_err!( + Redeem::get_open_redeem_request_from_id(&H256([0u8; 32])), + TestError::RedeemCompleted, + ); + }); + } + + #[test] + fn test_cancel_replace_redeem_request() { + run_test(|| { + setup_mocks(); + setup_execute_redeem(); + + // call cancel redeem + assert_ok!(Redeem::_cancel_redeem(USER, H256([0; 32]), true,)); + + assert_emitted!(Event::CancelReplace { + redeem_id: H256([0; 32]), + issue_id: H256([1; 32]), + old_vault: OLD_VAULT, + new_vault: NEW_VAULT, + status: RedeemRequestStatus::Cancelled, + punishment_fee: 1, + }); + + assert_err!( + Redeem::get_open_redeem_request_from_id(&H256([0u8; 32])), + TestError::RedeemCancelled, + ); + }) + } +} + mod spec_based_tests { use super::*; @@ -762,14 +886,6 @@ mod spec_based_tests { .mock_safe(move |_vault_id, _amount| MockResult::Return(Ok(()))); ext::vault_registry::is_vault_below_premium_threshold:: .mock_safe(move |_vault_id| MockResult::Return(Ok(false))); - let redeem_fee = Fee::get_redeem_fee(&wrapped(amount_to_redeem)).unwrap(); - let burned_tokens = wrapped(amount_to_redeem) - redeem_fee; - - ext::vault_registry::decrease_to_be_replaced_tokens::.mock_safe(move |vault_id, tokens| { - assert_eq!(vault_id, &VAULT); - assert_eq!(tokens, &burned_tokens); - MockResult::Return(Ok((wrapped(0), griefing(0)))) - }); // The returned `replaceCollateral` MUST be released currency::Amount::unlock_on.mock_safe(move |collateral_amount, vault_id| { @@ -831,11 +947,9 @@ mod spec_based_tests { &VAULT, vault_registry::Vault { id: VAULT, - to_be_replaced_tokens: 0, to_be_issued_tokens: 0, issued_tokens: 200, to_be_redeemed_tokens: 200, - replace_collateral: 0, banned_until: None, status: VaultStatus::Active(true), ..default_vault() @@ -857,6 +971,7 @@ mod spec_based_tests { btc_height: 0, status: RedeemRequestStatus::Pending, transfer_fee_btc: btc_fee.amount(), + issue_id: None, }; inject_redeem_request(H256([0u8; 32]), redeem_request.clone()); @@ -915,6 +1030,7 @@ mod spec_based_tests { transfer_fee_btc: Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY) .unwrap() .amount(), + issue_id: None, }; inject_redeem_request(H256([0u8; 32]), redeem_request.clone()); @@ -983,6 +1099,7 @@ mod spec_based_tests { transfer_fee_btc: Redeem::get_current_inclusion_fee(DEFAULT_WRAPPED_CURRENCY) .unwrap() .amount(), + issue_id: None, }; inject_redeem_request(H256([0u8; 32]), redeem_request.clone()); diff --git a/crates/redeem/src/types.rs b/crates/redeem/src/types.rs index c14ddc4c6a..f3d473d52c 100644 --- a/crates/redeem/src/types.rs +++ b/crates/redeem/src/types.rs @@ -4,15 +4,93 @@ use scale_info::TypeInfo; use sp_runtime::DispatchError; use vault_registry::types::CurrencyId; -use crate::Config; +use crate::{Config, Pallet}; +use btc_relay::BtcAddress; use codec::{Decode, Encode, MaxEncodedLen}; use currency::Amount; +use frame_support::{pallet_prelude::OptionQuery, traits::Get, Blake2_128Concat}; +use sp_core::H256; /// Storage version. -#[derive(Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +#[derive(Debug, Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum Version { /// Initial version. V0, + /// Added `issue_id` to `RedeemRequest` + V1, +} + +mod v0 { + use super::*; + + pub type DefaultRedeemRequest = RedeemRequest< + ::AccountId, + ::BlockNumber, + BalanceOf, + CurrencyId, + >; + + #[derive(Encode, Decode, Clone, PartialEq, TypeInfo, MaxEncodedLen)] + pub struct RedeemRequest { + /// the vault associated with this redeem request + pub vault: VaultId, + /// the *active* block height when this request was opened + pub opentime: BlockNumber, + /// the redeem period when this request was opened + pub period: BlockNumber, + /// total redeem fees - taken from request amount + pub fee: Balance, + /// amount the vault should spend on the bitcoin inclusion fee - taken from request amount + pub transfer_fee_btc: Balance, + /// total amount of BTC for the vault to send + pub amount_btc: Balance, + /// premium redeem amount in collateral + pub premium: Balance, + /// the account redeeming tokens (for BTC) + pub redeemer: AccountId, + /// the user's Bitcoin address for payment verification + pub btc_address: BtcAddress, + /// the highest recorded height in the BTC-Relay (at time of opening) + pub btc_height: u32, + /// the status of this redeem request + pub status: RedeemRequestStatus, + } + + #[frame_support::storage_alias] + pub(super) type RedeemRequests = + StorageMap, Blake2_128Concat, H256, DefaultRedeemRequest, OptionQuery>; +} + +pub mod v1 { + use super::*; + + pub fn migrate_v0_to_v1() -> frame_support::weights::Weight { + if !matches!(crate::StorageVersion::::get(), Version::V0) { + return T::DbWeight::get().reads(1); // already upgraded; don't run migration + } + // update vault struct to remove replace pallet fields + crate::RedeemRequests::::translate(|_key, old: v0::DefaultRedeemRequest| { + Some(crate::DefaultRedeemRequest:: { + vault: old.vault, + opentime: old.opentime, + period: old.period, + fee: old.fee, + transfer_fee_btc: old.transfer_fee_btc, + amount_btc: old.amount_btc, + premium: old.premium, + redeemer: old.redeemer, + btc_address: old.btc_address, + btc_height: old.btc_height, + status: old.status, + issue_id: None, + }) + }); + + // update version + crate::StorageVersion::::put(Version::V1); + + T::DbWeight::get().reads_writes(0, 1) + } } pub(crate) type BalanceOf = ::Balance; @@ -47,3 +125,51 @@ impl RedeemRequestExt for RedeemRequest::get(), Version::V0); + + let old = v0::DefaultRedeemRequest:: { + vault: DefaultVaultId::::new(123, Token(DOT), Token(IBTC)), + opentime: 1, + period: 12313, + fee: 456, + transfer_fee_btc: 1, + amount_btc: 100, + premium: 0, + redeemer: USER, + btc_address: BtcAddress::random(), + btc_height: 0, + status: RedeemRequestStatus::Reimbursed(false), + }; + let key = H256::zero(); + v0::RedeemRequests::::insert(key, old.clone()); + + v1::migrate_v0_to_v1::(); + + assert_eq!(crate::StorageVersion::::get(), Version::V1); + + let new = crate::RedeemRequests::::get(key).unwrap(); + + assert!(old.vault == new.vault); + assert!(old.opentime == new.opentime); + assert!(old.period == new.period); + assert!(old.fee == new.fee); + assert!(old.transfer_fee_btc == new.transfer_fee_btc); + assert!(old.amount_btc == new.amount_btc); + assert!(old.premium == new.premium); + assert!(old.redeemer == new.redeemer); + assert!(old.btc_address == new.btc_address); + assert!(old.btc_height == new.btc_height); + assert!(old.status == new.status); + assert_eq!(new.issue_id.is_none(), true); + }); + } +} diff --git a/crates/replace/Cargo.toml b/crates/replace/Cargo.toml deleted file mode 100644 index 0ec5e8595f..0000000000 --- a/crates/replace/Cargo.toml +++ /dev/null @@ -1,94 +0,0 @@ -[package] -authors = ["Interlay Ltd"] -description = "Replace module" -edition = "2021" -name = "replace" -version = "1.2.0" - -[dependencies] -serde = { version = "1.0.130", default-features = false, features = ['derive'], optional = true } -codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] } -scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } - -# Substrate dependencies -sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } - -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false, optional = true } -pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } - -# Parachain dependencies -bitcoin = { path = "../bitcoin", default-features = false } -btc-relay = { path = "../btc-relay", default-features = false } -oracle = { path = "../oracle", default-features = false } -fee = { path = "../fee", default-features = false } -security = { path = "../security", default-features = false } -currency = { path = "../currency", default-features = false } -vault-registry = { path = "../vault-registry", default-features = false } -nomination = { path = "../nomination", default-features = false } -primitives = { package = "interbtc-primitives", path = "../../primitives", default-features = false } - -# Orml dependencies -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false, optional = true } -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false, optional = true } - -[dev-dependencies] -mocktopus = "0.8.0" -frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } - -# Parachain dependencies -reward = { path = "../reward" } -staking = { path = "../staking" } -currency = { path = "../currency", features = ["testing-utils"] } - -# Orml dependencies -orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404" } -orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404" } - -[features] -default = ["std"] -std = [ - "serde", - "codec/std", - - "sp-io/std", - "sp-core/std", - "sp-std/std", - "sp-arithmetic/std", - "sp-runtime/std", - - "frame-support/std", - "frame-system/std", - "frame-benchmarking/std", - "pallet-timestamp/std", - - "bitcoin/std", - "btc-relay/std", - "oracle/std", - "fee/std", - "security/std", - "currency/std", - "vault-registry/std", - "nomination/std", - "primitives/std", - - "orml-tokens/std", - "orml-traits/std", -] -runtime-benchmarks = [ - "frame-benchmarking", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - - "bitcoin/runtime-benchmarks", - "btc-relay/runtime-benchmarks", - - "orml-tokens", - "orml-traits", -] -try-runtime = [ "frame-support/try-runtime" ] \ No newline at end of file diff --git a/crates/replace/rpc/Cargo.toml b/crates/replace/rpc/Cargo.toml deleted file mode 100644 index de81104efd..0000000000 --- a/crates/replace/rpc/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "replace-rpc" -version = "1.2.0" -authors = ["Interlay Ltd"] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5" } -jsonrpsee = { version = "0.16.2", features = ["server", "macros"] } -sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" } -replace-rpc-runtime-api = { path = "runtime-api" } diff --git a/crates/replace/rpc/runtime-api/Cargo.toml b/crates/replace/rpc/runtime-api/Cargo.toml deleted file mode 100644 index 0fd66ee779..0000000000 --- a/crates/replace/rpc/runtime-api/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "replace-rpc-runtime-api" -version = "1.2.0" -authors = ["Interlay Ltd"] -edition = "2021" - -[dependencies] -codec = { package = "parity-scale-codec", version = "3.1.5", default-features = false, features = ["derive", "max-encoded-len"] } -frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } -sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31", default-features = false } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-support/std", - "sp-api/std", - "sp-std/std", -] diff --git a/crates/replace/rpc/runtime-api/src/lib.rs b/crates/replace/rpc/runtime-api/src/lib.rs deleted file mode 100644 index e46d0d9782..0000000000 --- a/crates/replace/rpc/runtime-api/src/lib.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Runtime API definition for the Replace Module. - -#![cfg_attr(not(feature = "std"), no_std)] - -use codec::Codec; -use sp_std::vec::Vec; - -sp_api::decl_runtime_apis! { - pub trait ReplaceApi where - AccountId: Codec, - H256: Codec, - ReplaceRequest: Codec, - { - /// Get all replace requests from a particular vault - fn get_old_vault_replace_requests(vault_id: AccountId) -> Vec; - - /// Get all replace requests to a particular vault - fn get_new_vault_replace_requests(vault_id: AccountId) -> Vec; - } -} diff --git a/crates/replace/rpc/src/lib.rs b/crates/replace/rpc/src/lib.rs deleted file mode 100644 index fc9670781e..0000000000 --- a/crates/replace/rpc/src/lib.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! RPC interface for the Replace Module. - -use codec::Codec; -use jsonrpsee::{ - core::{async_trait, Error as JsonRpseeError, RpcResult}, - proc_macros::rpc, - types::error::{CallError, ErrorCode, ErrorObject}, -}; -use sp_api::ProvideRuntimeApi; -use sp_blockchain::HeaderBackend; -use sp_runtime::traits::Block as BlockT; -use std::sync::Arc; - -pub use replace_rpc_runtime_api::ReplaceApi as ReplaceRuntimeApi; - -#[rpc(client, server)] -pub trait ReplaceApi { - #[method(name = "replace_getOldVaultReplaceRequests")] - fn get_old_vault_replace_requests(&self, vault_id: AccountId, at: Option) -> RpcResult>; - - #[method(name = "replace_getNewVaultReplaceRequests")] - fn get_new_vault_replace_requests(&self, vault_id: AccountId, at: Option) -> RpcResult>; -} - -fn internal_err(message: T) -> JsonRpseeError { - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - ErrorCode::InternalError.code(), - message.to_string(), - None::<()>, - ))) -} - -/// A struct that implements the [`ReplaceApi`]. -pub struct Replace { - client: Arc, - _marker: std::marker::PhantomData, -} - -impl Replace { - /// Create new `Replace` with the given reference to the client. - pub fn new(client: Arc) -> Self { - Replace { - client, - _marker: Default::default(), - } - } -} - -#[async_trait] -impl - ReplaceApiServer<::Hash, AccountId, H256, ReplaceRequest> for Replace -where - Block: BlockT, - C: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, - C::Api: ReplaceRuntimeApi, - AccountId: Codec, - H256: Codec, - ReplaceRequest: Codec, -{ - fn get_old_vault_replace_requests( - &self, - vault_id: AccountId, - at: Option<::Hash>, - ) -> RpcResult> { - let api = self.client.runtime_api(); - let at = at.unwrap_or_else(|| self.client.info().best_hash); - - api.get_old_vault_replace_requests(at, vault_id) - .map_err(|e| internal_err(format!("Unable to fetch replace requests: {:?}", e))) - } - - fn get_new_vault_replace_requests( - &self, - vault_id: AccountId, - at: Option<::Hash>, - ) -> RpcResult> { - let api = self.client.runtime_api(); - let at = at.unwrap_or_else(|| self.client.info().best_hash); - - api.get_new_vault_replace_requests(at, vault_id) - .map_err(|e| internal_err(format!("Unable to fetch replace requests: {:?}", e))) - } -} diff --git a/crates/replace/src/benchmarking.rs b/crates/replace/src/benchmarking.rs deleted file mode 100644 index 9d523d72a6..0000000000 --- a/crates/replace/src/benchmarking.rs +++ /dev/null @@ -1,332 +0,0 @@ -use super::*; -use bitcoin::types::TransactionOutput; -use btc_relay::{BtcAddress, BtcPublicKey}; -use currency::getters::{get_relay_chain_currency_id as get_collateral_currency_id, *}; -use frame_benchmarking::v2::*; -use frame_support::assert_ok; -use frame_system::RawOrigin; -use orml_traits::MultiCurrency; -use primitives::VaultId; -use sp_core::H256; -use sp_runtime::{traits::One, FixedPointNumber}; -use sp_std::{fmt::Debug, prelude::*}; - -// Pallets -use crate::Pallet as Replace; -use btc_relay::Pallet as BtcRelay; -use oracle::Pallet as Oracle; -use security::Pallet as Security; -use vault_registry::Pallet as VaultRegistry; - -fn test_request( - new_vault_id: &DefaultVaultId, - old_vault_id: &DefaultVaultId, -) -> DefaultReplaceRequest { - ReplaceRequest { - new_vault: new_vault_id.clone(), - old_vault: old_vault_id.clone(), - period: Default::default(), - accept_time: Default::default(), - amount: Default::default(), - griefing_collateral: 12345u32.into(), // non-zero to hit additional code paths - btc_address: BtcAddress::dummy(), - collateral: Default::default(), - btc_height: Default::default(), - status: Default::default(), - } -} - -fn get_vault_id(name: &'static str) -> DefaultVaultId { - VaultId::new( - account(name, 0, 0), - get_collateral_currency_id::(), - get_wrapped_currency_id::(), - ) -} - -fn register_vault(vault_id: &DefaultVaultId, issued_tokens: Amount, to_be_replaced: Amount) { - let origin = RawOrigin::Signed(vault_id.account_id.clone()); - - assert_ok!(>::deposit( - get_collateral_currency_id::(), - &vault_id.account_id, - (1u32 << 31).into() - )); - assert_ok!(>::deposit( - get_native_currency_id::(), - &vault_id.account_id, - (1u32 << 31).into() - )); - - assert_ok!(VaultRegistry::::register_public_key( - origin.into(), - BtcPublicKey::dummy() - )); - assert_ok!(VaultRegistry::::_register_vault( - vault_id.clone(), - 100000000u32.into() - )); - - VaultRegistry::::try_increase_to_be_issued_tokens(vault_id, &issued_tokens).unwrap(); - VaultRegistry::::issue_tokens(vault_id, &issued_tokens).unwrap(); - VaultRegistry::::try_increase_to_be_replaced_tokens(vault_id, &to_be_replaced).unwrap(); -} - -struct ChainState { - old_vault_id: DefaultVaultId, - new_vault_id: DefaultVaultId, - issued_tokens: Amount, - to_be_replaced: Amount, -} - -fn setup_chain() -> ChainState { - let new_vault_id = get_vault_id::("NewVault"); - let old_vault_id = get_vault_id::("OldVault"); - - Oracle::::_set_exchange_rate( - get_native_currency_id::(), // for griefing collateral - ::UnsignedFixedPoint::one(), - ) - .unwrap(); - Oracle::::_set_exchange_rate( - old_vault_id.collateral_currency(), - ::UnsignedFixedPoint::one(), - ) - .unwrap(); - - VaultRegistry::::set_minimum_collateral( - RawOrigin::Root.into(), - old_vault_id.collateral_currency(), - 100_000u32.into(), - ) - .unwrap(); - VaultRegistry::::_set_system_collateral_ceiling(old_vault_id.currencies.clone(), 1_000_000_000u32.into()); - - VaultRegistry::::_set_secure_collateral_threshold( - old_vault_id.currencies.clone(), - ::UnsignedFixedPoint::checked_from_rational(1, 100000).unwrap(), - ); - VaultRegistry::::_set_premium_redeem_threshold( - old_vault_id.currencies.clone(), - ::UnsignedFixedPoint::checked_from_rational(1, 200000).unwrap(), - ); - VaultRegistry::::_set_liquidation_collateral_threshold( - old_vault_id.currencies.clone(), - ::UnsignedFixedPoint::checked_from_rational(1, 300000).unwrap(), - ); - - let issued_tokens = Amount::new(200000u32.into(), old_vault_id.wrapped_currency()); - let to_be_replaced = issued_tokens.clone().map(|x| x / 4u32.into()); - - register_vault(&old_vault_id, issued_tokens.clone(), to_be_replaced.clone()); - register_vault(&new_vault_id, issued_tokens.clone(), to_be_replaced.clone()); - - ChainState { - old_vault_id, - new_vault_id, - issued_tokens, - to_be_replaced, - } -} - -fn setup_replace( - old_vault_id: &DefaultVaultId, - new_vault_id: &DefaultVaultId, - to_be_replaced: Amount, - hashes: u32, - vin: u32, - vout: u32, - tx_size: u32, -) -> (H256, FullTransactionProof) -where - <::Balance as TryInto>::Error: Debug, -{ - let replace_id = H256::zero(); - let mut replace_request = test_request::(&new_vault_id, &old_vault_id); - replace_request.amount = to_be_replaced.amount(); - Replace::::insert_replace_request(&replace_id, &replace_request); - - // simulate that the request has been accepted - VaultRegistry::::try_increase_to_be_redeemed_tokens(&old_vault_id, &to_be_replaced).unwrap(); - VaultRegistry::::try_increase_to_be_issued_tokens(&new_vault_id, &to_be_replaced).unwrap(); - - VaultRegistry::::transfer_funds( - CurrencySource::FreeBalance(old_vault_id.account_id.clone()), - CurrencySource::ActiveReplaceCollateral(old_vault_id.clone()), - &Amount::new(replace_request.griefing_collateral, get_native_currency_id::()), - ) - .unwrap(); - - let relayer_id: T::AccountId = account("Relayer", 0, 0); - assert_ok!(>::deposit( - get_collateral_currency_id::(), - &relayer_id, - (1u32 << 31).into() - )); - assert_ok!(>::deposit( - get_native_currency_id::(), - &relayer_id, - (1u32 << 31).into() - )); - - // we always need these outputs for replace - let mut outputs = vec![ - TransactionOutput::payment( - to_be_replaced.amount().try_into().unwrap(), - &replace_request.btc_address, - ), - TransactionOutput::op_return(0, replace_id.as_bytes()), - ]; - - // add return-to-self output - if vout == 3 { - outputs.push(TransactionOutput::payment( - 0u32.into(), - &BtcAddress::P2PKH(sp_core::H160::zero()), - )); - } - - let transaction = - BtcRelay::::initialize_and_store_max(relayer_id.clone(), hashes, vin, outputs, tx_size as usize); - - let period = Replace::::replace_period().max(replace_request.period); - let expiry_height = BtcRelay::::bitcoin_expiry_height(replace_request.btc_height, period).unwrap(); - - BtcRelay::::mine_blocks(&relayer_id, expiry_height + 100); - Security::::set_active_block_number( - Security::::active_block_number() + Replace::::replace_period() + 100u32.into(), - ); - - (replace_id, transaction) -} - -#[benchmarks( - where - <::Balance as TryInto>::Error: Debug, -)] -pub mod benchmarks { - use super::*; - - #[benchmark] - fn request_replace() { - let ChainState { - old_vault_id, - issued_tokens, - to_be_replaced, - .. - } = setup_chain::(); - - let amount = (issued_tokens.checked_sub(&to_be_replaced).unwrap()).amount(); - - #[extrinsic_call] - request_replace( - RawOrigin::Signed(old_vault_id.account_id.clone()), - old_vault_id.currencies.clone(), - amount, - ); - } - - #[benchmark] - fn withdraw_replace() { - let ChainState { - old_vault_id, - to_be_replaced, - .. - } = setup_chain::(); - - #[extrinsic_call] - withdraw_replace( - RawOrigin::Signed(old_vault_id.account_id.clone()), - old_vault_id.currencies.clone(), - to_be_replaced.amount(), - ); - } - - #[benchmark] - fn accept_replace() { - let ChainState { - old_vault_id, - new_vault_id, - to_be_replaced, - .. - } = setup_chain::(); - - let replace_id = H256::zero(); - let mut replace_request = test_request::(&new_vault_id, &old_vault_id); - replace_request.amount = to_be_replaced.amount(); - Replace::::insert_replace_request(&replace_id, &replace_request); - - let new_vault_btc_address = BtcAddress::dummy(); - let griefing = 100000000u32.into(); - - #[extrinsic_call] - accept_replace( - RawOrigin::Signed(new_vault_id.account_id.clone()), - new_vault_id.currencies.clone(), - old_vault_id, - to_be_replaced.amount(), - griefing, - new_vault_btc_address, - ); - } - - #[benchmark] - fn execute_pending_replace(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<2, 3>, b: Linear<541, 2_048>) { - let ChainState { - old_vault_id, - new_vault_id, - to_be_replaced, - .. - } = setup_chain::(); - let (replace_id, transaction) = setup_replace::(&old_vault_id, &new_vault_id, to_be_replaced, h, i, o, b); - - #[extrinsic_call] - execute_replace(RawOrigin::Signed(old_vault_id.account_id), replace_id, transaction); - } - - #[benchmark] - fn execute_cancelled_replace(h: Linear<2, 10>, i: Linear<1, 10>, o: Linear<2, 3>, b: Linear<541, 2_048>) { - let ChainState { - old_vault_id, - new_vault_id, - to_be_replaced, - .. - } = setup_chain::(); - let (replace_id, transaction) = setup_replace::(&old_vault_id, &new_vault_id, to_be_replaced, h, i, o, b); - - assert_ok!(Pallet::::cancel_replace( - RawOrigin::Signed(new_vault_id.account_id).into(), - replace_id - )); - - #[extrinsic_call] - execute_replace(RawOrigin::Signed(old_vault_id.account_id), replace_id, transaction); - } - - #[benchmark] - fn cancel_replace() { - let ChainState { - old_vault_id, - new_vault_id, - to_be_replaced, - .. - } = setup_chain::(); - - let (replace_id, _) = setup_replace::(&old_vault_id, &new_vault_id, to_be_replaced, 2, 2, 2, 541); - - #[extrinsic_call] - cancel_replace(RawOrigin::Signed(new_vault_id.account_id), replace_id); - } - - #[benchmark] - fn set_replace_period() { - #[extrinsic_call] - set_replace_period(RawOrigin::Root, 1u32.into()); - } - - impl_benchmark_test_suite! { - Replace, - crate::mock::ExtBuilder::build_with(Default::default()), - crate::mock::Test - } -} diff --git a/crates/replace/src/default_weights.rs b/crates/replace/src/default_weights.rs deleted file mode 100644 index 98f95ae651..0000000000 --- a/crates/replace/src/default_weights.rs +++ /dev/null @@ -1,596 +0,0 @@ - -//! Autogenerated weights for replace -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `enterprise`, CPU: `Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/interbtc-parachain -// benchmark -// pallet -// --pallet -// replace -// --extrinsic -// * -// --chain -// kintsugi-dev -// --execution=wasm -// --wasm-execution=compiled -// --steps -// 50 -// --repeat -// 20 -// --output -// crates/replace/src/default_weights.rs -// --template -// .deploy/default-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for replace. -pub trait WeightInfo { - fn request_replace() -> Weight; - fn withdraw_replace() -> Weight; - fn accept_replace() -> Weight; - fn execute_pending_replace(h: u32, i: u32, o: u32, b: u32, ) -> Weight; - fn execute_cancelled_replace(h: u32, i: u32, o: u32, b: u32, ) -> Weight; - fn cancel_replace() -> Weight; - fn set_replace_period() -> Weight; -} - -/// Weights for replace using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Nomination Vaults (r:1 w:0) - /// Proof: Nomination Vaults (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Fee ReplaceGriefingCollateral (r:1 w:0) - /// Proof: Fee ReplaceGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - fn request_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `2972` - // Estimated: `11908` - // Minimum execution time: 103_625_000 picoseconds. - Weight::from_parts(104_579_000, 11908) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - fn withdraw_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `1760` - // Estimated: `2735` - // Minimum execution time: 55_362_000 picoseconds. - Weight::from_parts(56_367_000, 2735) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardTally (r:2 w:2) - /// Proof: VaultStaking RewardTally (max_values: None, max_size: Some(149), added: 2624, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRegistry SystemCollateralCeiling (r:1 w:0) - /// Proof: VaultRegistry SystemCollateralCeiling (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplaceRequests (r:0 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - fn accept_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `5415` - // Estimated: `96083` - // Minimum execution time: 417_052_000 picoseconds. - Weight::from_parts(420_396_000, 96083) - .saturating_add(T::DbWeight::get().reads(43_u64)) - .saturating_add(T::DbWeight::get().writes(26_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_pending_replace(h: u32, _i: u32, _o: u32, _b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `4990` - // Estimated: `18451` - // Minimum execution time: 143_961_000 picoseconds. - Weight::from_parts(191_182_902, 18451) - // Standard Error: 132_362 - .saturating_add(Weight::from_parts(961_843, 0).saturating_mul(h.into())) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_cancelled_replace(_h: u32, i: u32, _o: u32, b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `5335` - // Estimated: `26535` - // Minimum execution time: 177_761_000 picoseconds. - Weight::from_parts(197_448_409, 26535) - // Standard Error: 42_163 - .saturating_add(Weight::from_parts(84_783, 0).saturating_mul(i.into())) - // Standard Error: 268 - .saturating_add(Weight::from_parts(3_017, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(15_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry MinimumCollateralVault (r:1 w:0) - /// Proof: VaultRegistry MinimumCollateralVault (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:0) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:0) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:0) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - fn cancel_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `5955` - // Estimated: `89455` - // Minimum execution time: 332_975_000 picoseconds. - Weight::from_parts(340_302_000, 89455) - .saturating_add(T::DbWeight::get().reads(38_u64)) - .saturating_add(T::DbWeight::get().writes(19_u64)) - } - /// Storage: Replace ReplacePeriod (r:0 w:1) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_replace_period() -> Weight { - // Proof Size summary in bytes: - // Measured: `1027` - // Estimated: `0` - // Minimum execution time: 21_886_000 picoseconds. - Weight::from_parts(22_419_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Nomination Vaults (r:1 w:0) - /// Proof: Nomination Vaults (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Fee ReplaceGriefingCollateral (r:1 w:0) - /// Proof: Fee ReplaceGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - fn request_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `2972` - // Estimated: `11908` - // Minimum execution time: 103_625_000 picoseconds. - Weight::from_parts(104_579_000, 11908) - .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - fn withdraw_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `1760` - // Estimated: `2735` - // Minimum execution time: 55_362_000 picoseconds. - Weight::from_parts(56_367_000, 2735) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardTally (r:2 w:2) - /// Proof: VaultStaking RewardTally (max_values: None, max_size: Some(149), added: 2624, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(127), added: 2602, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRegistry SystemCollateralCeiling (r:1 w:0) - /// Proof: VaultRegistry SystemCollateralCeiling (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplaceRequests (r:0 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - fn accept_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `5415` - // Estimated: `96083` - // Minimum execution time: 417_052_000 picoseconds. - Weight::from_parts(420_396_000, 96083) - .saturating_add(RocksDbWeight::get().reads(43_u64)) - .saturating_add(RocksDbWeight::get().writes(26_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_pending_replace(h: u32, _i: u32, _o: u32, _b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `4990` - // Estimated: `18451` - // Minimum execution time: 143_961_000 picoseconds. - Weight::from_parts(191_182_902, 18451) - // Standard Error: 132_362 - .saturating_add(Weight::from_parts(961_843, 0).saturating_mul(h.into())) - .saturating_add(RocksDbWeight::get().reads(11_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_cancelled_replace(_h: u32, i: u32, _o: u32, b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `5335` - // Estimated: `26535` - // Minimum execution time: 177_761_000 picoseconds. - Weight::from_parts(197_448_409, 26535) - // Standard Error: 42_163 - .saturating_add(Weight::from_parts(84_783, 0).saturating_mul(i.into())) - // Standard Error: 268 - .saturating_add(Weight::from_parts(3_017, 0).saturating_mul(b.into())) - .saturating_add(RocksDbWeight::get().reads(15_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry MinimumCollateralVault (r:1 w:0) - /// Proof: VaultRegistry MinimumCollateralVault (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security ParachainStatus (r:1 w:0) - /// Proof: Security ParachainStatus (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:0) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:0) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:0) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - fn cancel_replace() -> Weight { - // Proof Size summary in bytes: - // Measured: `5955` - // Estimated: `89455` - // Minimum execution time: 332_975_000 picoseconds. - Weight::from_parts(340_302_000, 89455) - .saturating_add(RocksDbWeight::get().reads(38_u64)) - .saturating_add(RocksDbWeight::get().writes(19_u64)) - } - /// Storage: Replace ReplacePeriod (r:0 w:1) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_replace_period() -> Weight { - // Proof Size summary in bytes: - // Measured: `1027` - // Estimated: `0` - // Minimum execution time: 21_886_000 picoseconds. - Weight::from_parts(22_419_000, 0) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } -} diff --git a/crates/replace/src/ext.rs b/crates/replace/src/ext.rs deleted file mode 100644 index dc8d2a77d2..0000000000 --- a/crates/replace/src/ext.rs +++ /dev/null @@ -1,180 +0,0 @@ -#[cfg(test)] -use mocktopus::macros::mockable; - -#[cfg_attr(test, mockable)] -pub(crate) mod btc_relay { - use bitcoin::types::{FullTransactionProof, Value}; - use btc_relay::BtcAddress; - use frame_support::dispatch::DispatchError; - use sp_core::H256; - use sp_std::convert::TryInto; - - pub fn verify_and_validate_op_return_transaction>( - unchecked_transaction: FullTransactionProof, - recipient_btc_address: BtcAddress, - expected_btc: V, - op_return_id: H256, - ) -> Result<(), DispatchError> { - >::verify_and_validate_op_return_transaction( - unchecked_transaction, - recipient_btc_address, - expected_btc, - op_return_id, - ) - } - - pub fn get_best_block_height() -> u32 { - >::get_best_block_height() - } - - pub fn has_request_expired( - opentime: T::BlockNumber, - btc_open_height: u32, - period: T::BlockNumber, - ) -> Result { - >::has_request_expired(opentime, btc_open_height, period) - } -} - -#[cfg_attr(test, mockable)] -pub(crate) mod vault_registry { - use crate::DefaultVaultId; - use currency::Amount; - use frame_support::dispatch::{DispatchError, DispatchResult}; - use vault_registry::types::CurrencySource; - - pub fn transfer_funds( - from: CurrencySource, - to: CurrencySource, - amount: &Amount, - ) -> DispatchResult { - >::transfer_funds(from, to, amount) - } - - pub fn replace_tokens( - old_vault_id: &DefaultVaultId, - new_vault_id: &DefaultVaultId, - tokens: &Amount, - collateral: &Amount, - ) -> DispatchResult { - >::replace_tokens(old_vault_id, new_vault_id, tokens, collateral) - } - - pub fn cancel_replace_tokens( - old_vault_id: &DefaultVaultId, - new_vault_id: &DefaultVaultId, - tokens: &Amount, - ) -> DispatchResult { - >::cancel_replace_tokens(old_vault_id, new_vault_id, tokens) - } - - pub fn is_vault_liquidated(vault_id: &DefaultVaultId) -> Result { - >::is_vault_liquidated(vault_id) - } - - pub fn try_increase_to_be_redeemed_tokens( - vault_id: &DefaultVaultId, - tokens: &Amount, - ) -> DispatchResult { - >::try_increase_to_be_redeemed_tokens(vault_id, tokens) - } - - pub fn ensure_not_banned(vault_id: &DefaultVaultId) -> DispatchResult { - >::_ensure_not_banned(vault_id) - } - - pub fn try_increase_to_be_issued_tokens( - vault_id: &DefaultVaultId, - amount: &Amount, - ) -> Result<(), DispatchError> { - >::try_increase_to_be_issued_tokens(vault_id, amount) - } - - pub fn requestable_to_be_replaced_tokens( - vault_id: &DefaultVaultId, - ) -> Result, DispatchError> { - >::requestable_to_be_replaced_tokens(vault_id) - } - - pub fn try_increase_to_be_replaced_tokens( - vault_id: &DefaultVaultId, - amount: &Amount, - ) -> Result, DispatchError> { - >::try_increase_to_be_replaced_tokens(vault_id, amount) - } - - pub fn decrease_to_be_replaced_tokens( - vault_id: &DefaultVaultId, - tokens: &Amount, - ) -> Result<(Amount, Amount), DispatchError> { - >::decrease_to_be_replaced_tokens(vault_id, tokens) - } - - pub fn withdraw_replace_request( - vault_id: &DefaultVaultId, - amount: &Amount, - ) -> Result<(Amount, Amount), DispatchError> { - >::withdraw_replace_request(vault_id, amount) - } - - pub fn try_deposit_collateral( - vault_id: &DefaultVaultId, - amount: &Amount, - ) -> Result<(), DispatchError> { - >::try_deposit_collateral(vault_id, amount) - } - - pub fn force_withdraw_collateral( - vault_id: &DefaultVaultId, - amount: &Amount, - ) -> Result<(), DispatchError> { - >::force_withdraw_collateral(vault_id, amount) - } - - pub fn is_allowed_to_withdraw_collateral( - vault_id: &DefaultVaultId, - amount: Option>, - ) -> Result { - >::is_allowed_to_withdraw_collateral(vault_id, amount) - } - - pub fn calculate_collateral( - collateral: &Amount, - numerator: &Amount, - denominator: &Amount, - ) -> Result, DispatchError> { - >::calculate_collateral(collateral, numerator, denominator) - } -} - -#[cfg_attr(test, mockable)] -pub(crate) mod security { - use sp_core::H256; - - pub fn get_secure_id(id: &T::AccountId) -> H256 { - >::get_secure_id(id) - } - - pub fn active_block_number() -> T::BlockNumber { - >::active_block_number() - } -} - -#[cfg_attr(test, mockable)] -pub(crate) mod fee { - use currency::Amount; - use frame_support::dispatch::DispatchError; - - pub fn get_replace_griefing_collateral(amount: &Amount) -> Result, DispatchError> { - >::get_replace_griefing_collateral(amount) - } -} - -#[cfg_attr(test, mockable)] -pub(crate) mod nomination { - use crate::DefaultVaultId; - - pub fn is_nominatable(vault_id: &DefaultVaultId) -> bool { - >::is_opted_in(vault_id) - } -} diff --git a/crates/replace/src/lib.rs b/crates/replace/src/lib.rs deleted file mode 100644 index 3187c8d4a3..0000000000 --- a/crates/replace/src/lib.rs +++ /dev/null @@ -1,689 +0,0 @@ -//! # Replace Pallet -//! Based on the [specification](https://spec.interlay.io/spec/replace.html). - -#![deny(warnings)] -#![cfg_attr(test, feature(proc_macro_hygiene))] -#![cfg_attr(not(feature = "std"), no_std)] - -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking; - -mod default_weights; -mod ext; - -pub mod types; - -#[cfg(test)] -mod mock; - -#[cfg(test)] -mod tests; - -#[cfg(test)] -extern crate mocktopus; - -#[cfg(test)] -use mocktopus::macros::mockable; - -use crate::types::{BalanceOf, ReplaceRequestExt, Version}; -pub use crate::types::{DefaultReplaceRequest, ReplaceRequest, ReplaceRequestStatus}; -use bitcoin::types::FullTransactionProof; -use btc_relay::BtcAddress; -use currency::Amount; -pub use default_weights::WeightInfo; -use frame_support::{ - dispatch::{DispatchError, DispatchResult}, - ensure, - pallet_prelude::Weight, - traits::Get, - transactional, -}; -use frame_system::{ensure_root, ensure_signed}; -use sp_core::H256; -use sp_std::vec::Vec; -use types::DefaultVaultId; -use vault_registry::{types::CurrencyId, CurrencySource}; - -pub use pallet::*; - -/// Complexity: -/// - `O(H + I + O + B)` where: -/// - `H` is the number of hashes in the merkle tree -/// - `I` is the number of transaction inputs -/// - `O` is the number of transaction outputs -/// - `B` is `transaction` size in bytes (length-fee-bounded) -fn weight_for_execute_replace(proof: &FullTransactionProof) -> Weight { - { - let h = proof.user_tx_proof.merkle_proof.hashes.len() as u32; - let i = proof.user_tx_proof.transaction.inputs.len() as u32; - let o = proof.user_tx_proof.transaction.outputs.len() as u32; - let b = proof.user_tx_proof.tx_encoded_len; - ::WeightInfo::execute_pending_replace(h, i, o, b) - .max(::WeightInfo::execute_cancelled_replace(h, i, o, b)) - } - .saturating_add({ - let h = proof.coinbase_proof.merkle_proof.hashes.len() as u32; - let i = proof.coinbase_proof.transaction.inputs.len() as u32; - let o = proof.coinbase_proof.transaction.outputs.len() as u32; - let b = proof.coinbase_proof.tx_encoded_len; - ::WeightInfo::execute_pending_replace(h, i, o, b) - .max(::WeightInfo::execute_cancelled_replace(h, i, o, b)) - }) -} - -#[frame_support::pallet] -pub mod pallet { - use super::*; - use frame_support::pallet_prelude::*; - use frame_system::pallet_prelude::*; - use primitives::VaultId; - use vault_registry::types::DefaultVaultCurrencyPair; - - /// ## Configuration - /// The pallet's configuration trait. - #[pallet::config] - pub trait Config: - frame_system::Config - + vault_registry::Config - + btc_relay::Config - + oracle::Config - + fee::Config - + nomination::Config - { - /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; - - /// Weight information for the extrinsics in this module. - type WeightInfo: WeightInfo; - } - - #[pallet::event] - #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { - RequestReplace { - old_vault_id: DefaultVaultId, - amount: BalanceOf, - griefing_collateral: BalanceOf, - }, - WithdrawReplace { - old_vault_id: DefaultVaultId, - withdrawn_tokens: BalanceOf, - withdrawn_griefing_collateral: BalanceOf, - }, - AcceptReplace { - replace_id: H256, - old_vault_id: DefaultVaultId, - new_vault_id: DefaultVaultId, - amount: BalanceOf, - collateral: BalanceOf, - btc_address: BtcAddress, - }, - ExecuteReplace { - replace_id: H256, - old_vault_id: DefaultVaultId, - new_vault_id: DefaultVaultId, - }, - CancelReplace { - replace_id: H256, - new_vault_id: DefaultVaultId, - old_vault_id: DefaultVaultId, - griefing_collateral: BalanceOf, - }, - ReplacePeriodChange { - period: T::BlockNumber, - }, - } - - #[pallet::error] - pub enum Error { - /// Replace requires non-zero increase. - ReplaceAmountZero, - /// Replace amount is too small. - AmountBelowDustAmount, - /// No replace request found. - NoPendingRequest, - /// Unexpected vault account. - UnauthorizedVault, - /// Cannot replace self. - ReplaceSelfNotAllowed, - /// Cannot replace with nominated collateral. - VaultHasEnabledNomination, - /// Replace request has not expired. - ReplacePeriodNotExpired, - /// Replace request already completed. - ReplaceCompleted, - /// Replace request already cancelled. - ReplaceCancelled, - /// Replace request not found. - ReplaceIdNotFound, - /// Vault cannot replace different currency. - InvalidWrappedCurrency, - } - - /// Vaults create replace requests to transfer locked collateral. - /// This mapping provides access from a unique hash to a `ReplaceRequest`. - #[pallet::storage] - pub(super) type ReplaceRequests = - StorageMap<_, Blake2_128Concat, H256, DefaultReplaceRequest, OptionQuery>; - - /// The time difference in number of blocks between when a replace request is created - /// and required completion time by a vault. The replace period has an upper limit - /// to prevent griefing of vault collateral. - #[pallet::storage] - #[pallet::getter(fn replace_period)] - pub(super) type ReplacePeriod = StorageValue<_, T::BlockNumber, ValueQuery>; - - /// The minimum amount of btc that is accepted for replace requests; any lower values would - /// risk the bitcoin client to reject the payment - #[pallet::storage] - #[pallet::getter(fn replace_btc_dust_value)] - pub(super) type ReplaceBtcDustValue = StorageValue<_, BalanceOf, ValueQuery>; - - #[pallet::type_value] - pub(super) fn DefaultForStorageVersion() -> Version { - Version::V0 - } - - /// Build storage at V1 (requires default 0). - #[pallet::storage] - #[pallet::getter(fn storage_version)] - pub(super) type StorageVersion = StorageValue<_, Version, ValueQuery, DefaultForStorageVersion>; - - #[pallet::genesis_config] - pub struct GenesisConfig { - pub replace_period: T::BlockNumber, - pub replace_btc_dust_value: BalanceOf, - } - - #[cfg(feature = "std")] - impl Default for GenesisConfig { - fn default() -> Self { - Self { - replace_period: Default::default(), - replace_btc_dust_value: Default::default(), - } - } - } - - #[pallet::genesis_build] - impl GenesisBuild for GenesisConfig { - fn build(&self) { - ReplacePeriod::::put(self.replace_period); - ReplaceBtcDustValue::::put(self.replace_btc_dust_value); - } - } - - #[pallet::hooks] - impl Hooks for Pallet {} - - #[pallet::pallet] - pub struct Pallet(_); - - // The pallet's dispatchable functions. - #[pallet::call] - impl Pallet { - /// Request the replacement of a new vault ownership - /// - /// # Arguments - /// - /// * `origin` - sender of the transaction - /// * `amount` - amount of issued tokens - /// * `griefing_collateral` - amount of collateral - #[pallet::call_index(0)] - #[pallet::weight(::WeightInfo::request_replace())] - #[transactional] - pub fn request_replace( - origin: OriginFor, - currency_pair: DefaultVaultCurrencyPair, - #[pallet::compact] amount: BalanceOf, - ) -> DispatchResultWithPostInfo { - let old_vault = VaultId::new(ensure_signed(origin)?, currency_pair.collateral, currency_pair.wrapped); - Self::_request_replace(old_vault, amount)?; - Ok(().into()) - } - - /// Withdraw a request of vault replacement - /// - /// # Arguments - /// - /// * `origin` - sender of the transaction: the old vault - #[pallet::call_index(1)] - #[pallet::weight(::WeightInfo::withdraw_replace())] - #[transactional] - pub fn withdraw_replace( - origin: OriginFor, - currency_pair: DefaultVaultCurrencyPair, - #[pallet::compact] amount: BalanceOf, - ) -> DispatchResultWithPostInfo { - let old_vault = VaultId::new(ensure_signed(origin)?, currency_pair.collateral, currency_pair.wrapped); - Self::_withdraw_replace_request(old_vault, amount)?; - Ok(().into()) - } - - /// Accept request of vault replacement - /// - /// # Arguments - /// - /// * `origin` - the initiator of the transaction: the new vault - /// * `old_vault` - id of the old vault that we are (possibly partially) replacing - /// * `collateral` - the collateral for replacement - /// * `btc_address` - the address that old-vault should transfer the btc to - #[pallet::call_index(2)] - #[pallet::weight(::WeightInfo::accept_replace())] - #[transactional] - pub fn accept_replace( - origin: OriginFor, - currency_pair: DefaultVaultCurrencyPair, - old_vault: DefaultVaultId, - #[pallet::compact] amount_btc: BalanceOf, - #[pallet::compact] collateral: BalanceOf, - btc_address: BtcAddress, - ) -> DispatchResultWithPostInfo { - let new_vault = VaultId::new(ensure_signed(origin)?, currency_pair.collateral, currency_pair.wrapped); - Self::_accept_replace(old_vault, new_vault, amount_btc, collateral, btc_address)?; - Ok(().into()) - } - - /// Execute vault replacement - /// - /// # Arguments - /// - /// * `origin` - sender of the transaction: the new vault - /// * `replace_id` - the ID of the replacement request - /// * 'merkle_proof' - the merkle root of the block - /// * `raw_tx` - the transaction id in bytes - #[pallet::call_index(3)] - #[pallet::weight(weight_for_execute_replace::(unchecked_transaction))] - #[transactional] - pub fn execute_replace( - origin: OriginFor, - replace_id: H256, - unchecked_transaction: FullTransactionProof, - ) -> DispatchResultWithPostInfo { - let _ = ensure_signed(origin)?; - - Self::_execute_replace(replace_id, unchecked_transaction)?; - Ok(().into()) - } - - /// Cancel vault replacement - /// - /// # Arguments - /// - /// * `origin` - sender of the transaction: anyone - /// * `replace_id` - the ID of the replacement request - #[pallet::call_index(4)] - #[pallet::weight(::WeightInfo::cancel_replace())] - #[transactional] - pub fn cancel_replace(origin: OriginFor, replace_id: H256) -> DispatchResultWithPostInfo { - let _ = ensure_signed(origin)?; - Self::_cancel_replace(replace_id)?; - Ok(().into()) - } - - /// Set the default replace period for tx verification. - /// - /// # Arguments - /// - /// * `origin` - the dispatch origin of this call (must be _Root_) - /// * `period` - default period for new requests - /// - /// # Weight: `O(1)` - #[pallet::call_index(5)] - #[pallet::weight(::WeightInfo::set_replace_period())] - #[transactional] - pub fn set_replace_period(origin: OriginFor, period: T::BlockNumber) -> DispatchResultWithPostInfo { - ensure_root(origin)?; - >::set(period); - Self::deposit_event(Event::ReplacePeriodChange { period }); - Ok(().into()) - } - } -} - -// "Internal" functions, callable by code. -#[cfg_attr(test, mockable)] -impl Pallet { - fn _request_replace(vault_id: DefaultVaultId, amount_btc: BalanceOf) -> DispatchResult { - // check vault is not banned - ext::vault_registry::ensure_not_banned::(&vault_id)?; - - let amount_btc = Amount::new(amount_btc, vault_id.wrapped_currency()); - - ensure!( - !ext::nomination::is_nominatable::(&vault_id), - Error::::VaultHasEnabledNomination - ); - - let requestable_tokens = ext::vault_registry::requestable_to_be_replaced_tokens::(&vault_id)?; - let to_be_replaced_increase = amount_btc.min(&requestable_tokens)?; - - ensure!(!to_be_replaced_increase.is_zero(), Error::::ReplaceAmountZero); - - // increase to-be-replaced tokens. This will fail if the vault does not have enough tokens available - let total_to_be_replaced = - ext::vault_registry::try_increase_to_be_replaced_tokens::(&vault_id, &to_be_replaced_increase)?; - - // check that total-to-be-replaced is above the minimum - ensure!( - total_to_be_replaced.ge(&Self::dust_value(vault_id.wrapped_currency()))?, - Error::::AmountBelowDustAmount - ); - - // get the griefing collateral increase - let griefing_collateral = ext::fee::get_replace_griefing_collateral::( - &to_be_replaced_increase.convert_to(T::GetGriefingCollateralCurrencyId::get())?, - )?; - - // Lock the oldVault’s griefing collateral - ext::vault_registry::transfer_funds( - CurrencySource::FreeBalance(vault_id.account_id.clone()), - CurrencySource::AvailableReplaceCollateral(vault_id.clone()), - &griefing_collateral, - )?; - - // Emit RequestReplace event - Self::deposit_event(Event::::RequestReplace { - old_vault_id: vault_id, - amount: to_be_replaced_increase.amount(), - griefing_collateral: griefing_collateral.amount(), - }); - Ok(()) - } - - fn _withdraw_replace_request(vault_id: DefaultVaultId, amount: BalanceOf) -> Result<(), DispatchError> { - let amount = Amount::new(amount, vault_id.wrapped_currency()); - // decrease to-be-replaced tokens, so that the vault is free to use its issued tokens again. - let (withdrawn_tokens, to_withdraw_collateral) = - ext::vault_registry::withdraw_replace_request::(&vault_id, &amount)?; - - if withdrawn_tokens.is_zero() { - return Err(Error::::NoPendingRequest.into()); - } - - // Emit WithdrawReplaceRequest event. - Self::deposit_event(Event::::WithdrawReplace { - old_vault_id: vault_id, - withdrawn_tokens: withdrawn_tokens.amount(), - withdrawn_griefing_collateral: to_withdraw_collateral.amount(), - }); - Ok(()) - } - - fn accept_replace_tokens( - old_vault_id: &DefaultVaultId, - new_vault_id: &DefaultVaultId, - redeemable_tokens: &Amount, - ) -> DispatchResult { - // increase old-vault's to-be-redeemed tokens - this should never fail - ext::vault_registry::try_increase_to_be_redeemed_tokens::(old_vault_id, redeemable_tokens)?; - - // increase new-vault's to-be-issued tokens - this will fail if there is insufficient collateral - ext::vault_registry::try_increase_to_be_issued_tokens::(new_vault_id, redeemable_tokens)?; - - Ok(()) - } - - fn _accept_replace( - old_vault_id: DefaultVaultId, - new_vault_id: DefaultVaultId, - amount_btc: BalanceOf, - collateral: BalanceOf, - btc_address: BtcAddress, - ) -> Result<(), DispatchError> { - let new_vault_currency_id = new_vault_id.collateral_currency(); - let amount_btc = Amount::new(amount_btc, old_vault_id.wrapped_currency()); - let collateral = Amount::new(collateral, new_vault_currency_id); - - // don't allow vaults to replace themselves - ensure!(old_vault_id != new_vault_id, Error::::ReplaceSelfNotAllowed); - - // probably this check is not strictly required, but it's better to give an - // explicit error rather than insufficient balance - ensure!( - old_vault_id.wrapped_currency() == new_vault_id.wrapped_currency(), - Error::::InvalidWrappedCurrency - ); - - // Check that new vault is not currently banned - ext::vault_registry::ensure_not_banned::(&new_vault_id)?; - - // decrease old-vault's to-be-replaced tokens - let (redeemable_tokens, griefing_collateral) = - ext::vault_registry::decrease_to_be_replaced_tokens::(&old_vault_id, &amount_btc)?; - - // check amount_btc is above the minimum - ensure!( - redeemable_tokens.ge(&Self::dust_value(old_vault_id.wrapped_currency()))?, - Error::::AmountBelowDustAmount - ); - - // Calculate and lock the new-vault's additional collateral - let actual_new_vault_collateral = - ext::vault_registry::calculate_collateral::(&collateral, &redeemable_tokens, &amount_btc)?; - - ext::vault_registry::try_deposit_collateral::(&new_vault_id, &actual_new_vault_collateral)?; - - Self::accept_replace_tokens(&old_vault_id, &new_vault_id, &redeemable_tokens)?; - - ext::vault_registry::transfer_funds( - CurrencySource::AvailableReplaceCollateral(old_vault_id.clone()), - CurrencySource::ActiveReplaceCollateral(old_vault_id.clone()), - &griefing_collateral, - )?; - - let replace_id = ext::security::get_secure_id::(&old_vault_id.account_id); - - let replace = ReplaceRequest { - old_vault: old_vault_id, - new_vault: new_vault_id, - accept_time: ext::security::active_block_number::(), - collateral: actual_new_vault_collateral.amount(), - btc_address, - griefing_collateral: griefing_collateral.amount(), - amount: redeemable_tokens.amount(), - period: Self::replace_period(), - btc_height: ext::btc_relay::get_best_block_height::(), - status: ReplaceRequestStatus::Pending, - }; - - Self::insert_replace_request(&replace_id, &replace); - - // Emit AcceptReplace event - Self::deposit_event(Event::::AcceptReplace { - replace_id: replace_id, - old_vault_id: replace.old_vault, - new_vault_id: replace.new_vault, - amount: replace.amount, - collateral: replace.collateral, - btc_address: replace.btc_address, - }); - - Ok(()) - } - - fn _execute_replace(replace_id: H256, unchecked_transaction: FullTransactionProof) -> DispatchResult { - // retrieve the replace request using the id parameter - // we can still execute cancelled requests - let replace = Self::get_open_or_cancelled_replace_request(&replace_id)?; - - let griefing_collateral: Amount = replace.griefing_collateral(); - let amount = replace.amount(); - let collateral = replace.collateral()?; - - // NOTE: anyone can call this method provided the proof is correct - let new_vault_id = replace.new_vault; - let old_vault_id = replace.old_vault; - - // check the transaction inclusion and validity - ext::btc_relay::verify_and_validate_op_return_transaction::( - unchecked_transaction, - replace.btc_address, - replace.amount, - replace_id, - )?; - - // only return griefing collateral if not already slashed - let collateral = match replace.status { - ReplaceRequestStatus::Pending => { - // give old-vault the griefing collateral - ext::vault_registry::transfer_funds( - CurrencySource::ActiveReplaceCollateral(old_vault_id.clone()), - CurrencySource::FreeBalance(old_vault_id.account_id.clone()), - &griefing_collateral, - )?; - // NOTE: this is just the additional collateral already locked on accept - // it is only used in the ReplaceTokens event - collateral - } - ReplaceRequestStatus::Cancelled => { - // we need to re-accept first, this will check that the vault is over the secure threshold - Self::accept_replace_tokens(&old_vault_id, &new_vault_id, &amount)?; - // no additional collateral locked for this - Amount::zero(collateral.currency()) - } - ReplaceRequestStatus::Completed => { - // we never enter this branch as completed requests are filtered - return Err(Error::::ReplaceCompleted.into()); - } - }; - - // decrease old-vault's issued & to-be-redeemed tokens, and - // change new-vault's to-be-issued tokens to issued tokens - ext::vault_registry::replace_tokens::(&old_vault_id, &new_vault_id, &amount, &collateral)?; - - // Emit ExecuteReplace event. - Self::deposit_event(Event::::ExecuteReplace { - replace_id: replace_id, - old_vault_id: old_vault_id, - new_vault_id: new_vault_id, - }); - - // Remove replace request - Self::set_replace_status(&replace_id, ReplaceRequestStatus::Completed); - Ok(()) - } - - fn _cancel_replace(replace_id: H256) -> Result<(), DispatchError> { - // Retrieve the ReplaceRequest as per the replaceId parameter from Vaults in the VaultRegistry - let replace = Self::get_open_replace_request(&replace_id)?; - - let griefing_collateral: Amount = replace.griefing_collateral(); - let amount = replace.amount(); - let collateral = replace.collateral()?; - - // only cancellable after the request has expired - ensure!( - ext::btc_relay::has_request_expired::( - replace.accept_time, - replace.btc_height, - Self::replace_period().max(replace.period) - )?, - Error::::ReplacePeriodNotExpired - ); - - let new_vault_id = replace.new_vault; - - // decrease old-vault's to-be-redeemed tokens, and - // decrease new-vault's to-be-issued tokens - ext::vault_registry::cancel_replace_tokens::(&replace.old_vault, &new_vault_id, &amount)?; - - // slash old-vault's griefing collateral - ext::vault_registry::transfer_funds::( - CurrencySource::ActiveReplaceCollateral(replace.old_vault.clone()), - CurrencySource::FreeBalance(new_vault_id.account_id.clone()), - &griefing_collateral, - )?; - - // if the new_vault locked additional collateral especially for this replace, - // release it if it does not cause them to be undercollateralized - if !ext::vault_registry::is_vault_liquidated::(&new_vault_id)? - && ext::vault_registry::is_allowed_to_withdraw_collateral::(&new_vault_id, Some(collateral.clone()))? - { - ext::vault_registry::force_withdraw_collateral::(&new_vault_id, &collateral)?; - } - - // Remove the ReplaceRequest from ReplaceRequests - Self::set_replace_status(&replace_id, ReplaceRequestStatus::Cancelled); - - // Emit CancelReplace event. - Self::deposit_event(Event::::CancelReplace { - replace_id: replace_id, - new_vault_id: new_vault_id, - old_vault_id: replace.old_vault, - griefing_collateral: replace.griefing_collateral, - }); - Ok(()) - } - - /// Fetch all replace requests from the specified vault. - /// - /// # Arguments - /// - /// * `account_id` - user account id - pub fn get_replace_requests_for_old_vault(vault_id: T::AccountId) -> Vec { - >::iter() - .filter(|(_, request)| request.old_vault.account_id == vault_id) - .map(|(key, _)| key) - .collect::>() - } - - /// Fetch all replace requests to the specified vault. - /// - /// # Arguments - /// - /// * `account_id` - user account id - pub fn get_replace_requests_for_new_vault(vault_id: T::AccountId) -> Vec { - >::iter() - .filter(|(_, request)| request.new_vault.account_id == vault_id) - .map(|(key, _)| key) - .collect::>() - } - - /// Get a replace request by id. Completed or cancelled requests are not returned. - pub fn get_open_replace_request(replace_id: &H256) -> Result, DispatchError> { - let request = ReplaceRequests::::try_get(replace_id).or(Err(Error::::ReplaceIdNotFound))?; - - // NOTE: temporary workaround until we delete - match request.status { - ReplaceRequestStatus::Pending => Ok(request), - ReplaceRequestStatus::Completed => Err(Error::::ReplaceCompleted.into()), - ReplaceRequestStatus::Cancelled => Err(Error::::ReplaceCancelled.into()), - } - } - - /// Get a open or completed replace request by id. Cancelled requests are not returned. - pub fn get_open_or_completed_replace_request(id: &H256) -> Result, DispatchError> { - let request = >::get(id).ok_or(Error::::ReplaceIdNotFound)?; - match request.status { - ReplaceRequestStatus::Pending | ReplaceRequestStatus::Completed => Ok(request), - ReplaceRequestStatus::Cancelled => Err(Error::::ReplaceCancelled.into()), - } - } - - /// Get a open or cancelled replace request by id. Completed requests are not returned. - pub fn get_open_or_cancelled_replace_request(id: &H256) -> Result, DispatchError> { - let request = >::get(id).ok_or(Error::::ReplaceIdNotFound)?; - match request.status { - ReplaceRequestStatus::Pending | ReplaceRequestStatus::Cancelled => Ok(request), - ReplaceRequestStatus::Completed => Err(Error::::ReplaceCompleted.into()), - } - } - - fn insert_replace_request(key: &H256, value: &DefaultReplaceRequest) { - >::insert(key, value) - } - - fn set_replace_status(key: &H256, status: ReplaceRequestStatus) { - >::mutate_exists(key, |request| { - *request = request.clone().map(|request| DefaultReplaceRequest:: { - status: status.clone(), - ..request - }); - }); - } - - pub fn dust_value(currency_id: CurrencyId) -> Amount { - Amount::new(ReplaceBtcDustValue::::get(), currency_id) - } -} diff --git a/crates/replace/src/mock.rs b/crates/replace/src/mock.rs deleted file mode 100644 index ad728c297d..0000000000 --- a/crates/replace/src/mock.rs +++ /dev/null @@ -1,354 +0,0 @@ -use crate as replace; -use crate::{Config, Error}; -use currency::Amount; -use frame_support::{ - assert_ok, parameter_types, - traits::{ConstU32, Everything, GenesisBuild}, - PalletId, -}; -use mocktopus::{macros::mockable, mocking::clear_mocks}; -use orml_traits::parameter_type_with_key; -pub use primitives::{CurrencyId, CurrencyId::Token, TokenSymbol::*}; -use primitives::{VaultCurrencyPair, VaultId}; -use sp_arithmetic::{FixedI128, FixedPointNumber, FixedU128}; -use sp_core::H256; -use sp_runtime::{ - testing::{Header, TestXt}, - traits::{BlakeTwo256, IdentityLookup, One, Zero}, -}; - -type TestExtrinsic = TestXt; -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -// Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Storage, Config, Event}, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, - - // Tokens & Balances - Tokens: orml_tokens::{Pallet, Storage, Config, Event}, - - CapacityRewards: reward::::{Pallet, Call, Storage, Event}, - VaultRewards: reward::::{Pallet, Call, Storage, Event}, - VaultStaking: staking::{Pallet, Storage, Event}, - - // Operational - BTCRelay: btc_relay::{Pallet, Call, Config, Storage, Event}, - Security: security::{Pallet, Call, Storage, Event}, - VaultRegistry: vault_registry::{Pallet, Call, Config, Storage, Event}, - Oracle: oracle::{Pallet, Call, Config, Storage, Event}, - Replace: replace::{Pallet, Call, Config, Storage, Event}, - Fee: fee::{Pallet, Call, Config, Storage}, - Nomination: nomination::{Pallet, Call, Config, Storage, Event}, - Currency: currency::{Pallet}, - } -); - -pub type AccountId = u64; -pub type Balance = u128; -pub type RawAmount = i128; -pub type BlockNumber = u64; -pub type Moment = u64; -pub type Index = u64; -pub type SignedFixedPoint = FixedI128; -pub type SignedInner = i128; -pub type UnsignedFixedPoint = FixedU128; - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - -impl frame_system::Config for Test { - type BaseCallFilter = Everything; - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type Index = Index; - type BlockNumber = BlockNumber; - type Hash = H256; - type Hashing = BlakeTwo256; - type AccountId = AccountId; - type Lookup = IdentityLookup; - type Header = Header; - type RuntimeEvent = RuntimeEvent; - type BlockHashCount = BlockHashCount; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = SS58Prefix; - type OnSetCode = (); - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -pub const DEFAULT_COLLATERAL_CURRENCY: CurrencyId = Token(DOT); -pub const DEFAULT_NATIVE_CURRENCY: CurrencyId = Token(INTR); -pub const DEFAULT_WRAPPED_CURRENCY: CurrencyId = Token(IBTC); - -parameter_types! { - pub const GetCollateralCurrencyId: CurrencyId = DEFAULT_COLLATERAL_CURRENCY; - pub const GetNativeCurrencyId: CurrencyId = DEFAULT_NATIVE_CURRENCY; - pub const GetWrappedCurrencyId: CurrencyId = DEFAULT_WRAPPED_CURRENCY; - pub const MaxLocks: u32 = 50; -} - -parameter_type_with_key! { - pub ExistentialDeposits: |_currency_id: CurrencyId| -> Balance { - Zero::zero() - }; -} - -impl orml_tokens::Config for Test { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; - type Amount = RawAmount; - type CurrencyId = CurrencyId; - type WeightInfo = (); - type ExistentialDeposits = ExistentialDeposits; - type CurrencyHooks = (); - type MaxLocks = MaxLocks; - type DustRemovalWhitelist = Everything; - type MaxReserves = ConstU32<0>; // we don't use named reserves - type ReserveIdentifier = (); // we don't use named reserves -} - -type CapacityRewardsInstance = reward::Instance1; - -impl reward::Config for Test { - type RuntimeEvent = RuntimeEvent; - type SignedFixedPoint = SignedFixedPoint; - type PoolId = (); - type StakeId = CurrencyId; - type CurrencyId = CurrencyId; - type MaxRewardCurrencies = ConstU32<10>; -} - -type VaultRewardsInstance = reward::Instance2; - -impl reward::Config for Test { - type RuntimeEvent = RuntimeEvent; - type SignedFixedPoint = SignedFixedPoint; - type PoolId = CurrencyId; - type StakeId = VaultId; - type CurrencyId = CurrencyId; - type MaxRewardCurrencies = ConstU32<10>; -} - -impl staking::Config for Test { - type RuntimeEvent = RuntimeEvent; - type SignedFixedPoint = SignedFixedPoint; - type SignedInner = SignedInner; - type CurrencyId = CurrencyId; - type GetNativeCurrencyId = GetNativeCurrencyId; -} - -parameter_types! { - pub const VaultPalletId: PalletId = PalletId(*b"mod/vreg"); -} - -impl frame_system::offchain::SendTransactionTypes for Test -where - RuntimeCall: From, -{ - type OverarchingCall = RuntimeCall; - type Extrinsic = TestExtrinsic; -} -pub struct CurrencyConvert; -impl currency::CurrencyConversion, CurrencyId> for CurrencyConvert { - fn convert( - amount: ¤cy::Amount, - to: CurrencyId, - ) -> Result, sp_runtime::DispatchError> { - let amount = convert_to(to, amount.amount())?; - Ok(Amount::new(amount, to)) - } -} - -#[cfg_attr(test, mockable)] -pub fn convert_to(to: CurrencyId, amount: Balance) -> Result { - Ok(amount) // default conversion 1:1 - overwritable with mocktopus -} - -impl currency::Config for Test { - type SignedInner = SignedInner; - type SignedFixedPoint = SignedFixedPoint; - type UnsignedFixedPoint = UnsignedFixedPoint; - type Balance = Balance; - type GetNativeCurrencyId = GetNativeCurrencyId; - type GetRelayChainCurrencyId = GetCollateralCurrencyId; - type GetWrappedCurrencyId = GetWrappedCurrencyId; - type CurrencyConversion = CurrencyConvert; -} - -impl vault_registry::Config for Test { - type PalletId = VaultPalletId; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); - type GetGriefingCollateralCurrencyId = GetNativeCurrencyId; -} - -impl nomination::Config for Test { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); -} - -parameter_types! { - pub const ParachainBlocksPerBitcoinBlock: BlockNumber = 100; -} - -impl btc_relay::Config for Test { - type RuntimeEvent = RuntimeEvent; - type ParachainBlocksPerBitcoinBlock = ParachainBlocksPerBitcoinBlock; - type WeightInfo = (); -} - -impl security::Config for Test { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); -} - -parameter_types! { - pub const MinimumPeriod: Moment = 5; -} - -impl pallet_timestamp::Config for Test { - type Moment = Moment; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -impl oracle::Config for Test { - type RuntimeEvent = RuntimeEvent; - type OnExchangeRateChange = (); - type WeightInfo = (); - type MaxNameLength = ConstU32<255>; -} - -parameter_types! { - pub const FeePalletId: PalletId = PalletId(*b"mod/fees"); - pub const MaxExpectedValue: UnsignedFixedPoint = UnsignedFixedPoint::from_inner(::DIV); -} - -impl fee::Config for Test { - type FeePalletId = FeePalletId; - type WeightInfo = (); - type SignedFixedPoint = SignedFixedPoint; - type SignedInner = SignedInner; - type CapacityRewards = CapacityRewards; - type VaultRewards = VaultRewards; - type VaultStaking = VaultStaking; - type OnSweep = (); - type MaxExpectedValue = MaxExpectedValue; - type NominationApi = Nomination; -} - -impl Config for Test { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); -} - -pub type TestEvent = RuntimeEvent; -pub type TestError = Error; - -pub const OLD_VAULT: VaultId = VaultId { - account_id: 1, - currencies: VaultCurrencyPair { - collateral: DEFAULT_COLLATERAL_CURRENCY, - wrapped: DEFAULT_WRAPPED_CURRENCY, - }, -}; -pub const NEW_VAULT: VaultId = VaultId { - account_id: 2, - currencies: VaultCurrencyPair { - collateral: DEFAULT_COLLATERAL_CURRENCY, - wrapped: DEFAULT_WRAPPED_CURRENCY, - }, -}; - -pub const OLD_VAULT_BALANCE: u128 = 1_000_000; -pub const NEW_VAULT_BALANCE: u128 = 1_000_000; - -pub struct ExtBuilder; - -impl ExtBuilder { - pub fn build_with(balances: orml_tokens::GenesisConfig) -> sp_io::TestExternalities { - let mut storage = frame_system::GenesisConfig::default().build_storage::().unwrap(); - - balances.assimilate_storage(&mut storage).unwrap(); - - fee::GenesisConfig:: { - issue_fee: UnsignedFixedPoint::checked_from_rational(5, 1000).unwrap(), // 0.5% - issue_griefing_collateral: UnsignedFixedPoint::checked_from_rational(5, 100000).unwrap(), // 0.005% - redeem_fee: UnsignedFixedPoint::checked_from_rational(5, 1000).unwrap(), // 0.5% - premium_redeem_fee: UnsignedFixedPoint::checked_from_rational(5, 100).unwrap(), // 5% - punishment_fee: UnsignedFixedPoint::checked_from_rational(1, 10).unwrap(), // 10% - replace_griefing_collateral: UnsignedFixedPoint::checked_from_rational(1, 10).unwrap(), // 10% - } - .assimilate_storage(&mut storage) - .unwrap(); - - const PAIR: VaultCurrencyPair = VaultCurrencyPair { - collateral: DEFAULT_COLLATERAL_CURRENCY, - wrapped: DEFAULT_WRAPPED_CURRENCY, - }; - vault_registry::GenesisConfig:: { - minimum_collateral_vault: vec![(DEFAULT_COLLATERAL_CURRENCY, 0)], - punishment_delay: 8, - system_collateral_ceiling: vec![(PAIR, 1_000_000_000_000)], - secure_collateral_threshold: vec![(PAIR, UnsignedFixedPoint::checked_from_rational(200, 100).unwrap())], - premium_redeem_threshold: vec![(PAIR, UnsignedFixedPoint::checked_from_rational(120, 100).unwrap())], - liquidation_collateral_threshold: vec![( - PAIR, - UnsignedFixedPoint::checked_from_rational(110, 100).unwrap(), - )], - } - .assimilate_storage(&mut storage) - .unwrap(); - - replace::GenesisConfig:: { - replace_period: 10, - replace_btc_dust_value: 2, - } - .assimilate_storage(&mut storage) - .unwrap(); - - storage.into() - } - - pub fn build() -> sp_io::TestExternalities { - ExtBuilder::build_with(orml_tokens::GenesisConfig:: { - balances: vec![ - (OLD_VAULT.account_id, Token(DOT), OLD_VAULT_BALANCE), - (NEW_VAULT.account_id, Token(DOT), NEW_VAULT_BALANCE), - ], - }) - } -} - -pub fn run_test(test: T) -where - T: FnOnce(), -{ - clear_mocks(); - ExtBuilder::build().execute_with(|| { - assert_ok!(>::_set_exchange_rate( - DEFAULT_COLLATERAL_CURRENCY, - UnsignedFixedPoint::one() - )); - System::set_block_number(1); - Security::set_active_block_number(1); - test(); - }); -} diff --git a/crates/replace/src/tests.rs b/crates/replace/src/tests.rs deleted file mode 100644 index 51cf8fa241..0000000000 --- a/crates/replace/src/tests.rs +++ /dev/null @@ -1,291 +0,0 @@ -use crate::{ - mock::{CurrencyId, *}, - *, -}; - -use bitcoin::merkle::PartialTransactionProof; -use btc_relay::BtcAddress; -use currency::Amount; -use frame_support::{assert_err, assert_ok}; -use mocktopus::mocking::*; -use sp_core::H256; - -type Event = crate::Event; - -macro_rules! assert_event_matches { - ($( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => { - - assert!(System::events().iter().any(|a| { - match a.event { - TestEvent::Replace( $( $pattern )|+ ) $( if $guard )? => true, - _ => false - } - })); - } -} -fn test_request() -> ReplaceRequest { - ReplaceRequest { - period: 0, - new_vault: NEW_VAULT, - old_vault: OLD_VAULT, - accept_time: 1, - amount: 10, - griefing_collateral: 0, - btc_address: BtcAddress::random(), - collateral: 20, - btc_height: 0, - status: ReplaceRequestStatus::Pending, - } -} - -fn griefing(amount: u128) -> Amount { - Amount::new(amount, DEFAULT_NATIVE_CURRENCY) -} -fn wrapped(amount: u128) -> Amount { - Amount::new(amount, DEFAULT_WRAPPED_CURRENCY) -} - -fn get_some_unchecked_transaction() -> FullTransactionProof { - FullTransactionProof { - user_tx_proof: PartialTransactionProof { - transaction: Default::default(), - tx_encoded_len: u32::MAX, - merkle_proof: Default::default(), - }, - coinbase_proof: PartialTransactionProof { - transaction: Default::default(), - tx_encoded_len: u32::MAX, - merkle_proof: Default::default(), - }, - } -} - -mod request_replace_tests { - use super::*; - - fn setup_mocks() { - ext::vault_registry::ensure_not_banned::.mock_safe(|_| MockResult::Return(Ok(()))); - ext::vault_registry::requestable_to_be_replaced_tokens:: - .mock_safe(move |_| MockResult::Return(Ok(wrapped(1000000)))); - ext::vault_registry::try_increase_to_be_replaced_tokens:: - .mock_safe(|_, _| MockResult::Return(Ok(wrapped(2)))); - ext::fee::get_replace_griefing_collateral::.mock_safe(move |_| MockResult::Return(Ok(griefing(20)))); - ext::vault_registry::transfer_funds::.mock_safe(|_, _, _| MockResult::Return(Ok(()))); - } - - #[test] - fn test_request_replace_total_to_be_replace_above_dust_succeeds() { - run_test(|| { - setup_mocks(); - assert_ok!(Replace::_request_replace(OLD_VAULT, 1)); - assert_event_matches!(Event::RequestReplace { - old_vault_id: OLD_VAULT, - amount: 1, - .. - }); - }) - } - - #[test] - fn test_request_replace_above_requestable_succeeds() { - run_test(|| { - setup_mocks(); - ext::vault_registry::requestable_to_be_replaced_tokens:: - .mock_safe(move |_| MockResult::Return(Ok(wrapped(5)))); - assert_ok!(Replace::_request_replace(OLD_VAULT, 10)); - assert_event_matches!(Event::RequestReplace { - old_vault_id: OLD_VAULT, - amount: 5, - .. - }); - }) - } - - #[test] - fn test_request_replace_total_to_be_replace_below_dust_fails() { - run_test(|| { - setup_mocks(); - ext::vault_registry::try_increase_to_be_replaced_tokens:: - .mock_safe(|_, _| MockResult::Return(Ok(wrapped(1)))); - assert_err!( - Replace::_request_replace(OLD_VAULT, 1), - TestError::AmountBelowDustAmount - ); - }) - } - - #[test] - fn request_replace_should_fail_with_replace_amount_zero() { - run_test(|| { - setup_mocks(); - ext::vault_registry::try_increase_to_be_replaced_tokens:: - .mock_safe(|_, _| MockResult::Return(Ok(wrapped(1)))); - assert_err!(Replace::_request_replace(OLD_VAULT, 0), TestError::ReplaceAmountZero); - }) - } -} - -mod accept_replace_tests { - use super::*; - - fn setup_mocks() { - ext::vault_registry::ensure_not_banned::.mock_safe(|_| MockResult::Return(Ok(()))); - ext::vault_registry::decrease_to_be_replaced_tokens:: - .mock_safe(|_, _| MockResult::Return(Ok((wrapped(5), griefing(10))))); - ext::vault_registry::try_deposit_collateral::.mock_safe(|_, _| MockResult::Return(Ok(()))); - ext::vault_registry::try_increase_to_be_redeemed_tokens::.mock_safe(|_, _| MockResult::Return(Ok(()))); - ext::vault_registry::try_increase_to_be_issued_tokens::.mock_safe(|_, _| MockResult::Return(Ok(()))); - ext::vault_registry::transfer_funds::.mock_safe(|_, _, _| MockResult::Return(Ok(()))); - } - - #[test] - fn test_accept_replace_succeeds() { - run_test(|| { - setup_mocks(); - let btc_address = BtcAddress::random(); - assert_ok!(Replace::_accept_replace(OLD_VAULT, NEW_VAULT, 5, 10, btc_address)); - assert_event_matches!(Event::AcceptReplace{ - replace_id: _, - old_vault_id: OLD_VAULT, - new_vault_id: NEW_VAULT, - amount: 5, - collateral: 10, - btc_address: addr} if addr == btc_address); - }) - } - - #[test] - fn test_accept_replace_partial_accept_succeeds() { - run_test(|| { - // call to replace (5, 10), when there is only (4, 8) actually used - setup_mocks(); - ext::vault_registry::decrease_to_be_replaced_tokens:: - .mock_safe(|_, _| MockResult::Return(Ok((wrapped(4), griefing(8))))); - - let btc_address = BtcAddress::random(); - - assert_ok!(Replace::_accept_replace(OLD_VAULT, NEW_VAULT, 5, 10, btc_address)); - assert_event_matches!(Event::AcceptReplace{ - replace_id: _, - old_vault_id: OLD_VAULT, - new_vault_id: NEW_VAULT, - amount: 4, - collateral: 8, - btc_address: addr} if addr == btc_address); - }) - } - - #[test] - fn test_accept_replace_below_dust_fails() { - run_test(|| { - setup_mocks(); - ext::vault_registry::decrease_to_be_replaced_tokens:: - .mock_safe(|_, _| MockResult::Return(Ok((wrapped(1), griefing(10))))); - assert_err!( - Replace::_accept_replace(OLD_VAULT, NEW_VAULT, 5, 10, BtcAddress::random()), - TestError::AmountBelowDustAmount - ); - }) - } -} - -mod execute_replace_test { - use currency::Amount; - - use super::*; - - fn setup_mocks() { - ReplaceRequests::::insert(H256::zero(), { - let mut replace = test_request(); - replace.old_vault = OLD_VAULT; - replace.new_vault = NEW_VAULT; - replace - }); - - Replace::replace_period.mock_safe(|| MockResult::Return(20)); - ext::btc_relay::has_request_expired::.mock_safe(|_, _, _| MockResult::Return(Ok(false))); - ext::btc_relay::verify_and_validate_op_return_transaction:: - .mock_safe(|_, _, _, _| MockResult::Return(Ok(()))); - ext::vault_registry::replace_tokens::.mock_safe(|_, _, _, _| MockResult::Return(Ok(()))); - Amount::::unlock_on.mock_safe(|_, _| MockResult::Return(Ok(()))); - ext::vault_registry::transfer_funds::.mock_safe(|_, _, _| MockResult::Return(Ok(()))); - - ext::vault_registry::try_increase_to_be_redeemed_tokens::.mock_safe(|_, _| MockResult::Return(Ok(()))); - ext::vault_registry::try_increase_to_be_issued_tokens::.mock_safe(|_, _| MockResult::Return(Ok(()))); - } - - #[test] - fn test_execute_replace_succeeds() { - run_test(|| { - setup_mocks(); - assert_ok!(Replace::_execute_replace( - H256::zero(), - get_some_unchecked_transaction() - )); - assert_event_matches!(Event::ExecuteReplace { - replace_id: _, - old_vault_id: OLD_VAULT, - new_vault_id: NEW_VAULT - }); - }) - } - - #[test] - fn should_execute_cancelled_request() { - run_test(|| { - setup_mocks(); - - ReplaceRequests::::insert(H256::zero(), { - let mut replace = test_request(); - replace.old_vault = OLD_VAULT; - replace.new_vault = NEW_VAULT; - replace.status = ReplaceRequestStatus::Cancelled; - replace - }); - - assert_ok!(Replace::_execute_replace( - H256::zero(), - get_some_unchecked_transaction() - )); - assert_event_matches!(Event::ExecuteReplace { - replace_id: _, - old_vault_id: OLD_VAULT, - new_vault_id: NEW_VAULT - }); - }) - } -} - -mod cancel_replace_tests { - use super::*; - - fn setup_mocks() { - Replace::get_open_replace_request.mock_safe(move |_| { - let mut replace = test_request(); - replace.old_vault = OLD_VAULT; - replace.new_vault = NEW_VAULT; - MockResult::Return(Ok(replace)) - }); - - Replace::replace_period.mock_safe(|| MockResult::Return(20)); - ext::btc_relay::has_request_expired::.mock_safe(|_, _, _| MockResult::Return(Ok(true))); - ext::vault_registry::is_vault_liquidated::.mock_safe(|_| MockResult::Return(Ok(false))); - ext::vault_registry::cancel_replace_tokens::.mock_safe(|_, _, _| MockResult::Return(Ok(()))); - ext::vault_registry::transfer_funds::.mock_safe(|_, _, _| MockResult::Return(Ok(()))); - ext::vault_registry::is_allowed_to_withdraw_collateral::.mock_safe(|_, _| MockResult::Return(Ok(false))); - } - - #[test] - fn test_cancel_replace_succeeds() { - run_test(|| { - setup_mocks(); - assert_ok!(Replace::_cancel_replace(H256::zero(),)); - assert_event_matches!(Event::CancelReplace { - replace_id: _, - new_vault_id: NEW_VAULT, - old_vault_id: OLD_VAULT, - griefing_collateral: _ - }); - }) - } -} diff --git a/crates/replace/src/types.rs b/crates/replace/src/types.rs deleted file mode 100644 index 849151a643..0000000000 --- a/crates/replace/src/types.rs +++ /dev/null @@ -1,59 +0,0 @@ -use crate::Config; -use codec::{Decode, Encode, MaxEncodedLen}; -use currency::Amount; -use frame_support::traits::Get; -pub use primitives::replace::{ReplaceRequest, ReplaceRequestStatus}; -use primitives::VaultId; -use scale_info::TypeInfo; -use sp_core::H160; -use sp_runtime::DispatchError; -use vault_registry::types::CurrencyId; - -/// Storage version. -#[derive(Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] -pub enum Version { - /// Initial version. - V0, -} - -pub(crate) type BalanceOf = ::Balance; - -pub(crate) type DefaultVaultId = VaultId<::AccountId, CurrencyId>; - -#[derive(Encode, Decode, Default, Clone, PartialEq)] -pub(crate) struct ReplaceRequestV0 { - pub old_vault: AccountId, - pub open_time: BlockNumber, - pub amount: Balance, - pub griefing_collateral: Balance, - pub new_vault: Option, - pub collateral: Balance, - pub accept_time: Option, - pub btc_address: H160, - pub completed: bool, -} - -pub type DefaultReplaceRequest = ReplaceRequest< - ::AccountId, - ::BlockNumber, - BalanceOf, - CurrencyId, ->; - -pub trait ReplaceRequestExt { - fn amount(&self) -> Amount; - fn griefing_collateral(&self) -> Amount; - fn collateral(&self) -> Result, DispatchError>; -} - -impl ReplaceRequestExt for DefaultReplaceRequest { - fn amount(&self) -> Amount { - Amount::new(self.amount, self.old_vault.wrapped_currency()) - } - fn griefing_collateral(&self) -> Amount { - Amount::new(self.griefing_collateral, T::GetGriefingCollateralCurrencyId::get()) - } - fn collateral(&self) -> Result, DispatchError> { - Ok(Amount::new(self.collateral, self.new_vault.collateral_currency())) - } -} diff --git a/crates/vault-registry/src/lib.rs b/crates/vault-registry/src/lib.rs index c6321504d0..0dfd43a2ae 100644 --- a/crates/vault-registry/src/lib.rs +++ b/crates/vault-registry/src/lib.rs @@ -111,7 +111,7 @@ pub mod pallet { } fn on_runtime_upgrade() -> frame_support::weights::Weight { - crate::types::v1::migrate_v1_to_v6::() + types::v7::migrate_v6_to_v7::() } } @@ -479,10 +479,8 @@ pub mod pallet { issued_tokens: BalanceOf, to_be_issued_tokens: BalanceOf, to_be_redeemed_tokens: BalanceOf, - to_be_replaced_tokens: BalanceOf, backing_collateral: BalanceOf, status: VaultStatus, - replace_collateral: BalanceOf, }, BanVault { vault_id: DefaultVaultId, @@ -889,16 +887,6 @@ impl Pallet { ); Self::slash_backing_collateral(vault_id, amount)?; } - CurrencySource::AvailableReplaceCollateral(ref vault_id) => { - let mut vault = Self::get_active_rich_vault_from_id(&vault_id)?; - vault.decrease_available_replace_collateral(amount)?; - amount.unlock_on(&from.account_id())?; - } - CurrencySource::ActiveReplaceCollateral(ref vault_id) => { - let mut vault = Self::get_rich_vault_from_id(&vault_id)?; - vault.decrease_active_replace_collateral(amount)?; - amount.unlock_on(&from.account_id())?; - } CurrencySource::UserGriefing(_) => { amount.unlock_on(&from.account_id())?; } @@ -930,16 +918,6 @@ impl Pallet { ); Self::try_deposit_collateral(vault_id, amount)?; } - CurrencySource::AvailableReplaceCollateral(ref vault_id) => { - let mut vault = Self::get_active_rich_vault_from_id(&vault_id)?; - vault.increase_available_replace_collateral(amount)?; - amount.lock_on(&to.account_id())?; - } - CurrencySource::ActiveReplaceCollateral(ref vault_id) => { - let mut vault = Self::get_rich_vault_from_id(&vault_id)?; - vault.increase_active_replace_collateral(amount)?; - amount.lock_on(&to.account_id())?; - } CurrencySource::UserGriefing(_) => { amount.lock_on(&to.account_id())?; } @@ -998,72 +976,6 @@ impl Pallet { Ok(btc_address) } - /// returns the amount of tokens that a vault can request to be replaced on top of the - /// current to-be-replaced tokens - pub fn requestable_to_be_replaced_tokens(vault_id: &DefaultVaultId) -> Result, DispatchError> { - let vault = Self::get_active_rich_vault_from_id(&vault_id)?; - - vault - .issued_tokens() - .checked_sub(&vault.to_be_replaced_tokens())? - .checked_sub(&vault.to_be_redeemed_tokens()) - } - - /// returns the new total to-be-replaced and replace-collateral - pub fn try_increase_to_be_replaced_tokens( - vault_id: &DefaultVaultId, - tokens: &Amount, - ) -> Result, DispatchError> { - let mut vault = Self::get_active_rich_vault_from_id(&vault_id)?; - - let new_to_be_replaced = vault.to_be_replaced_tokens().checked_add(&tokens)?; - let total_decreasing_tokens = new_to_be_replaced.checked_add(&vault.to_be_redeemed_tokens())?; - - ensure!( - total_decreasing_tokens.le(&vault.issued_tokens())?, - Error::::InsufficientTokensCommitted - ); - - vault.set_to_be_replaced_amount(&new_to_be_replaced)?; - - Self::deposit_event(Event::::IncreaseToBeReplacedTokens { - vault_id: vault.id(), - increase: tokens.amount(), - }); - - Ok(new_to_be_replaced) - } - - pub fn decrease_to_be_replaced_tokens( - vault_id: &DefaultVaultId, - tokens: &Amount, - ) -> Result<(Amount, Amount), DispatchError> { - let mut vault = Self::get_rich_vault_from_id(&vault_id)?; - - let initial_to_be_replaced = Amount::new(vault.data.to_be_replaced_tokens, vault_id.wrapped_currency()); - let initial_griefing_collateral = - Amount::new(vault.data.replace_collateral, T::GetGriefingCollateralCurrencyId::get()); - - let used_tokens = tokens.min(&initial_to_be_replaced)?; - - let used_collateral = - Self::calculate_collateral(&initial_griefing_collateral, &used_tokens, &initial_to_be_replaced)?; - - // make sure we don't use too much if a rounding error occurs - let used_collateral = used_collateral.min(&initial_griefing_collateral)?; - - let new_to_be_replaced = initial_to_be_replaced.checked_sub(&used_tokens)?; - - vault.set_to_be_replaced_amount(&new_to_be_replaced)?; - - Self::deposit_event(Event::::DecreaseToBeReplacedTokens { - vault_id: vault.id(), - decrease: tokens.amount(), - }); - - Ok((used_tokens, used_collateral)) - } - /// Decreases the amount of tokens to be issued in the next issue request from the /// vault, or from the liquidation vault if the vault is liquidated /// @@ -1130,6 +1042,37 @@ impl Pallet { Ok(()) } + /// Checks if redeeming a certain amount of tokens from a vault would fully replace the vault's locked tokens. + /// + /// # Arguments + /// * `vault_id` - the id of the vault to check + /// * `to_redeem_tokens` - the amount of tokens to be redeemed + /// + /// # Errors + /// * `VaultNotFound` - if no vault exists for the given `vault_id` + /// * `InsufficientTokensCommitted` - if the amount of to-be-redeemed tokens is too low + /// + /// # Returns + /// `Ok(true)` if redeeming the specified `to_redeem_tokens` would fully replace the vault's locked tokens. + /// `Ok(false)` otherwise. + pub fn is_vault_fully_replacing( + vault_id: &DefaultVaultId, + to_redeem_tokens: &Amount, + ) -> Result { + let vault = Self::get_active_rich_vault_from_id(&vault_id)?; + let max_redeemable = vault.issued_tokens().checked_sub(&vault.to_be_redeemed_tokens())?; + ensure!( + max_redeemable.ge(&to_redeem_tokens)?, + Error::::InsufficientTokensCommitted + ); + + if to_redeem_tokens == &max_redeemable { + Ok(true) + } else { + Ok(false) + } + } + /// Subtracts an amount tokens from the to-be-redeemed tokens balance of a vault. /// /// # Arguments @@ -1359,7 +1302,8 @@ impl Pallet { pub fn cancel_replace_tokens( old_vault_id: &DefaultVaultId, new_vault_id: &DefaultVaultId, - tokens: &Amount, + redeem_tokens: &Amount, + issue_tokens: &Amount, ) -> DispatchResult { let mut old_vault = Self::get_rich_vault_from_id(&old_vault_id)?; let mut new_vault = Self::get_rich_vault_from_id(&new_vault_id)?; @@ -1367,7 +1311,7 @@ impl Pallet { if old_vault.data.is_liquidated() { let to_be_transferred = Self::calculate_collateral( &old_vault.liquidated_collateral(), - tokens, + redeem_tokens, &old_vault.to_be_redeemed_tokens(), )?; old_vault.decrease_liquidated_collateral(&to_be_transferred)?; @@ -1380,33 +1324,12 @@ impl Pallet { )?; } - old_vault.cancel_redeem_tokens(tokens)?; - new_vault.cancel_issue_tokens(tokens)?; + old_vault.cancel_redeem_tokens(redeem_tokens)?; + new_vault.cancel_issue_tokens(issue_tokens)?; Ok(()) } - /// Withdraws an `amount` of tokens that were requested for replacement by `vault_id` - /// - /// # Arguments - /// * `vault_id` - the id of the vault - /// * `amount` - the amount of tokens to be withdrawn from replace requests - pub fn withdraw_replace_request( - vault_id: &DefaultVaultId, - amount: &Amount, - ) -> Result<(Amount, Amount), DispatchError> { - let (withdrawn_tokens, to_withdraw_collateral) = Self::decrease_to_be_replaced_tokens(&vault_id, &amount)?; - - // release the used collateral - Self::transfer_funds( - CurrencySource::AvailableReplaceCollateral(vault_id.clone()), - CurrencySource::FreeBalance(vault_id.account_id.clone()), - &to_withdraw_collateral, - )?; - - Ok((withdrawn_tokens, to_withdraw_collateral)) - } - fn undercollateralized_vaults() -> impl Iterator> { >::iter().filter_map(|(vault_id, vault)| { if let Some(liquidation_threshold) = Self::liquidation_collateral_threshold(&vault.id.currencies) { @@ -1436,10 +1359,8 @@ impl Pallet { issued_tokens: vault_orig.issued_tokens, to_be_issued_tokens: vault_orig.to_be_issued_tokens, to_be_redeemed_tokens: vault_orig.to_be_redeemed_tokens, - to_be_replaced_tokens: vault_orig.to_be_replaced_tokens, backing_collateral: backing_collateral.amount(), status: VaultStatus::Liquidated, - replace_collateral: vault_orig.replace_collateral, }); Ok(to_slash) } @@ -1910,25 +1831,8 @@ impl Pallet { #[cfg(feature = "integration-tests")] pub fn collateral_integrity_check() { - let griefing_currency = T::GetGriefingCollateralCurrencyId::get(); for (vault_id, vault) in Vaults::::iter().filter(|(_, vault)| matches!(vault.status, VaultStatus::Active(_))) { - // check that there is enough griefing collateral - let active_griefing = CurrencySource::::ActiveReplaceCollateral(vault_id.clone()) - .current_balance(griefing_currency) - .unwrap(); - let available_replace_collateral = CurrencySource::::AvailableReplaceCollateral(vault_id.clone()) - .current_balance(griefing_currency) - .unwrap(); - let total_replace_collateral = active_griefing + available_replace_collateral.clone(); - let reserved_balance = ext::currency::get_reserved_balance(griefing_currency, &vault_id.account_id); - assert!(reserved_balance.ge(&total_replace_collateral).unwrap()); - - if available_replace_collateral.is_zero() { - // we can't have reserved collateral for to_be_replaced tokens if there are no to-be-replaced tokens - assert!(vault.to_be_replaced_tokens.is_zero()); - } - let liquidated_collateral = CurrencySource::::LiquidatedCollateral(vault_id.clone()) .current_balance(vault_id.collateral_currency()) .unwrap(); diff --git a/crates/vault-registry/src/mock.rs b/crates/vault-registry/src/mock.rs index dbe11826e1..15029d441b 100644 --- a/crates/vault-registry/src/mock.rs +++ b/crates/vault-registry/src/mock.rs @@ -269,7 +269,7 @@ impl traits::NominationApi, currency::Amount) -> Result<(), DispatchError> { + fn ensure_opted_in_to_nomination(_vault_id: &VaultId) -> Result<(), DispatchError> { Ok(()) } #[cfg(any(feature = "runtime-benchmarks", test))] diff --git a/crates/vault-registry/src/tests.rs b/crates/vault-registry/src/tests.rs index cd1dd05cc2..0b0ef06c64 100644 --- a/crates/vault-registry/src/tests.rs +++ b/crates/vault-registry/src/tests.rs @@ -66,10 +66,6 @@ fn amount(amount: u128) -> Amount { Amount::new(amount, DEFAULT_COLLATERAL_CURRENCY) } -fn griefing(amount: u128) -> Amount { - Amount::new(amount, DEFAULT_NATIVE_CURRENCY) -} - fn wrapped(amount: u128) -> Amount { Amount::new(amount, DEFAULT_WRAPPED_CURRENCY) } @@ -302,37 +298,6 @@ fn issue_tokens_fails_with_insufficient_tokens() { }); } -#[test] -fn try_increase_to_be_replaced_tokens_succeeds() { - run_test(|| { - let id = create_sample_vault(); - - assert_ok!(VaultRegistry::try_increase_to_be_issued_tokens(&id, &wrapped(50)),); - assert_ok!(VaultRegistry::issue_tokens(&id, &wrapped(50))); - assert_ok!(VaultRegistry::try_increase_to_be_replaced_tokens(&id, &wrapped(50))); - let vault = VaultRegistry::get_active_rich_vault_from_id(&id).unwrap(); - assert_eq!(vault.data.issued_tokens, 50); - assert_eq!(vault.data.to_be_replaced_tokens, 50); - assert_emitted!(Event::IncreaseToBeReplacedTokens { - vault_id: id, - increase: 50 - }); - }); -} - -#[test] -fn try_increase_to_be_replaced_tokens_fails_with_insufficient_tokens() { - run_test(|| { - let id = create_sample_vault(); - - // important: should not change the storage state - assert_noop!( - VaultRegistry::try_increase_to_be_replaced_tokens(&id, &wrapped(50)), - TestError::InsufficientTokensCommitted - ); - }); -} - #[test] fn try_increase_to_be_redeemed_tokens_succeeds() { run_test(|| { @@ -643,7 +608,12 @@ fn cancel_replace_tokens_succeeds() { assert_ok!(VaultRegistry::try_increase_to_be_redeemed_tokens(&old_id, &wrapped(50))); assert_ok!(VaultRegistry::try_increase_to_be_issued_tokens(&new_id, &wrapped(50))); - assert_ok!(VaultRegistry::cancel_replace_tokens(&old_id, &new_id, &wrapped(50))); + assert_ok!(VaultRegistry::cancel_replace_tokens( + &old_id, + &new_id, + &wrapped(50), + &wrapped(50) + )); let old_vault = VaultRegistry::get_active_rich_vault_from_id(&old_id).unwrap(); let new_vault = VaultRegistry::get_active_rich_vault_from_id(&new_id).unwrap(); @@ -1324,81 +1294,6 @@ mod get_vaults_with_redeemable_tokens_test { } } -#[test] -fn test_try_increase_to_be_replaced_tokens() { - run_test(|| { - let issue_tokens: u128 = 4; - let vault_id = create_sample_vault_and_issue_tokens(issue_tokens); - assert_ok!(VaultRegistry::try_increase_to_be_redeemed_tokens( - &vault_id, - &wrapped(1) - )); - - let total_wrapped = VaultRegistry::try_increase_to_be_replaced_tokens(&vault_id, &wrapped(2)).unwrap(); - assert!(total_wrapped == wrapped(2)); - - // check that we can't request more than we have issued tokens - assert_noop!( - VaultRegistry::try_increase_to_be_replaced_tokens(&vault_id, &wrapped(3)), - TestError::InsufficientTokensCommitted - ); - - // check that we can't request replacement for tokens that are marked as to-be-redeemed - assert_noop!( - VaultRegistry::try_increase_to_be_replaced_tokens(&vault_id, &wrapped(2)), - TestError::InsufficientTokensCommitted - ); - - let mut vault = VaultRegistry::get_active_rich_vault_from_id(&vault_id).unwrap(); - vault.increase_available_replace_collateral(&griefing(10)).unwrap(); - - let total_wrapped = VaultRegistry::try_increase_to_be_replaced_tokens(&vault_id, &wrapped(1)).unwrap(); - assert_eq!(total_wrapped, wrapped(3)); - - // check that to_be_replaced_tokens is was written to storage - let vault = VaultRegistry::get_active_vault_from_id(&vault_id).unwrap(); - assert_eq!(vault.to_be_replaced_tokens, 3); - }) -} - -#[test] -fn test_decrease_to_be_replaced_tokens_over_capacity() { - run_test(|| { - let issue_tokens: u128 = 4; - let vault_id = create_sample_vault_and_issue_tokens(issue_tokens); - - assert_ok!(VaultRegistry::try_increase_to_be_replaced_tokens( - &vault_id, - &wrapped(4), - )); - let mut vault = VaultRegistry::get_active_rich_vault_from_id(&vault_id).unwrap(); - vault.increase_available_replace_collateral(&griefing(10)).unwrap(); - - let (tokens, collateral) = VaultRegistry::decrease_to_be_replaced_tokens(&vault_id, &wrapped(5)).unwrap(); - assert_eq!(tokens, wrapped(4)); - assert_eq!(collateral, griefing(10)); - }) -} - -#[test] -fn test_decrease_to_be_replaced_tokens_below_capacity() { - run_test(|| { - let issue_tokens: u128 = 4; - let vault_id = create_sample_vault_and_issue_tokens(issue_tokens); - - assert_ok!(VaultRegistry::try_increase_to_be_replaced_tokens( - &vault_id, - &wrapped(4), - )); - let mut vault = VaultRegistry::get_active_rich_vault_from_id(&vault_id).unwrap(); - vault.increase_available_replace_collateral(&griefing(10)).unwrap(); - - let (tokens, collateral) = VaultRegistry::decrease_to_be_replaced_tokens(&vault_id, &wrapped(3)).unwrap(); - assert_eq!(tokens, wrapped(3)); - assert_eq!(collateral, griefing(7)); - }) -} - #[test] fn test_offchain_worker_unsigned_transaction_submission() { let mut externalities = crate::mock::ExtBuilder::build(); diff --git a/crates/vault-registry/src/types.rs b/crates/vault-registry/src/types.rs index 7570ac6c6f..22a66aa7eb 100644 --- a/crates/vault-registry/src/types.rs +++ b/crates/vault-registry/src/types.rs @@ -5,6 +5,7 @@ use frame_support::{ dispatch::{DispatchError, DispatchResult}, ensure, traits::Get, + Blake2_128Concat, }; pub use primitives::{VaultCurrencyPair, VaultId}; use scale_info::TypeInfo; @@ -20,7 +21,7 @@ use mocktopus::macros::mockable; pub use bitcoin::{Address as BtcAddress, PublicKey as BtcPublicKey}; /// Storage version. -#[derive(Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] +#[derive(Debug, Encode, Decode, Eq, PartialEq, TypeInfo, MaxEncodedLen)] pub enum Version { /// Initial version. V0, @@ -36,16 +37,16 @@ pub enum Version { V5, /// Removed wallet V6, + /// Removed replace pallet fields + /// Following fields have been removed from vault + /// `to_be_replaced_tokens`, `replace_collateral` and `active_replace_collateral` + V7, } #[derive(Debug, PartialEq)] pub enum CurrencySource { /// Used by vault to back issued tokens Collateral(DefaultVaultId), - /// Collateral put down by request_replace, but that has not been accepted yet - AvailableReplaceCollateral(DefaultVaultId), - /// Collateral that is locked, but not used to back issued tokens (e.g. griefing collateral) - ActiveReplaceCollateral(DefaultVaultId), /// User's issue griefing collateral UserGriefing(::AccountId), /// Unlocked balance @@ -61,8 +62,6 @@ impl CurrencySource { pub fn account_id(&self) -> ::AccountId { match self { CurrencySource::Collateral(DefaultVaultId:: { account_id: x, .. }) - | CurrencySource::AvailableReplaceCollateral(DefaultVaultId:: { account_id: x, .. }) - | CurrencySource::ActiveReplaceCollateral(DefaultVaultId:: { account_id: x, .. }) | CurrencySource::UserGriefing(x) | CurrencySource::FreeBalance(x) | CurrencySource::LiquidatedCollateral(DefaultVaultId:: { account_id: x, .. }) => x.clone(), @@ -73,17 +72,6 @@ impl CurrencySource { pub fn current_balance(&self, currency_id: CurrencyId) -> Result, DispatchError> { let amount = match self { CurrencySource::Collateral(vault_id) => Pallet::::get_backing_collateral(vault_id)?, - CurrencySource::AvailableReplaceCollateral(vault_id) => { - let vault = Pallet::::get_vault_from_id(vault_id)?; - Amount::new(vault.replace_collateral, T::GetGriefingCollateralCurrencyId::get()) - } - CurrencySource::ActiveReplaceCollateral(vault_id) => { - let vault = Pallet::::get_vault_from_id(vault_id)?; - Amount::new( - vault.active_replace_collateral, - T::GetGriefingCollateralCurrencyId::get(), - ) - } CurrencySource::UserGriefing(x) => ext::currency::get_reserved_balance::(currency_id, x), CurrencySource::FreeBalance(x) => ext::currency::get_free_balance::(currency_id, x), CurrencySource::LiquidatedCollateral(vault_id) => { @@ -109,18 +97,80 @@ pub type DefaultVaultId = VaultId<::AccountId, Cur pub type DefaultVaultCurrencyPair = VaultCurrencyPair>; -pub mod v1 { +mod v6 { use super::*; + pub type DefaultVault = Vault< + ::AccountId, + ::BlockNumber, + BalanceOf, + CurrencyId, + UnsignedFixedPoint, + >; + + #[derive(Encode, Decode, Clone, PartialEq, Eq, TypeInfo, MaxEncodedLen)] + #[cfg_attr(feature = "std", derive(Debug))] + pub struct Vault { + /// Account identifier of the Vault + pub id: VaultId, + /// Current status of the vault + pub status: VaultStatus, + /// Block height until which this Vault is banned from being used for + /// Issue, Redeem (except during automatic liquidation) and Replace. + pub banned_until: Option, + /// Custom secure collateral threshold + pub secure_collateral_threshold: Option, + /// Number of tokens pending issue + pub to_be_issued_tokens: Balance, + /// Number of issued tokens + pub issued_tokens: Balance, + /// Number of tokens pending redeem + pub to_be_redeemed_tokens: Balance, + /// Number of tokens that have been requested for a replace through + /// `request_replace`, but that have not been accepted yet by a new_vault. + pub to_be_replaced_tokens: Balance, + /// Amount of collateral that is available as griefing collateral to vaults accepting + /// a replace request. It is to be payed out if the old_vault fails to call execute_replace. + pub replace_collateral: Balance, + /// Amount of collateral locked for accepted replace requests. + pub active_replace_collateral: Balance, + /// Amount of collateral that is locked for remaining to_be_redeemed + /// tokens upon liquidation. + pub liquidated_collateral: Balance, + } + + #[frame_support::storage_alias] + pub(super) type Vaults = StorageMap, Blake2_128Concat, DefaultVaultId, DefaultVault>; +} +pub mod v7 { + use super::*; + + pub fn migrate_v6_to_v7() -> frame_support::weights::Weight { + let mut weight = T::DbWeight::get().reads(1); - pub fn migrate_v1_to_v6() -> frame_support::weights::Weight { - // kintsugi is on V6 but interlay is still on V1 - if !matches!(crate::StorageVersion::::get(), Version::V1) { + // kintsugi is on V6 but interlay is also on V6 + if !matches!(crate::StorageVersion::::get(), Version::V6) { log::info!("Not running vault storage migration"); - return T::DbWeight::get().reads(1); // already upgraded; don't run migration + return weight; // already upgraded; don't run migration } - // nothing to do other than update version - crate::StorageVersion::::put(Version::V6); - T::DbWeight::get().reads_writes(0, 1) + + // update vault struct to remove replace pallet fields + crate::Vaults::::translate(|_key, old: v6::DefaultVault| { + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); + Some(crate::DefaultVault:: { + id: old.id, + status: old.status, + banned_until: old.banned_until, + secure_collateral_threshold: old.secure_collateral_threshold, + to_be_issued_tokens: old.to_be_issued_tokens, + issued_tokens: old.issued_tokens, + to_be_redeemed_tokens: old.to_be_redeemed_tokens, + liquidated_collateral: old.liquidated_collateral, + }) + }); + + // update version + crate::StorageVersion::::put(Version::V7); + weight.saturating_add(T::DbWeight::get().reads_writes(0, 1)) } } @@ -157,14 +207,6 @@ pub struct Vault RichVault { Ok(Amount::new(amount, self.wrapped_currency())) } - pub(crate) fn to_be_replaced_tokens(&self) -> Amount { - Amount::new(self.data.to_be_replaced_tokens, self.wrapped_currency()) - } - pub(crate) fn to_be_redeemed_tokens(&self) -> Amount { Amount::new(self.data.to_be_redeemed_tokens, self.wrapped_currency()) } @@ -454,53 +489,6 @@ impl RichVault { self.issued_tokens().checked_sub(&self.to_be_redeemed_tokens()) } - pub(crate) fn set_to_be_replaced_amount(&mut self, tokens: &Amount) -> DispatchResult { - self.update(|v| { - v.to_be_replaced_tokens = tokens.amount(); - Ok(()) - }) - } - - pub(crate) fn increase_available_replace_collateral(&mut self, amount: &Amount) -> DispatchResult { - self.update(|v| { - v.replace_collateral = v - .replace_collateral - .checked_add(&amount.amount()) - .ok_or(ArithmeticError::Overflow)?; - Ok(()) - }) - } - - pub(crate) fn decrease_available_replace_collateral(&mut self, amount: &Amount) -> DispatchResult { - self.update(|v| { - v.replace_collateral = v - .replace_collateral - .checked_sub(&amount.amount()) - .ok_or(ArithmeticError::Underflow)?; - Ok(()) - }) - } - - pub(crate) fn increase_active_replace_collateral(&mut self, amount: &Amount) -> DispatchResult { - self.update(|v| { - v.active_replace_collateral = v - .active_replace_collateral - .checked_add(&amount.amount()) - .ok_or(ArithmeticError::Overflow)?; - Ok(()) - }) - } - - pub(crate) fn decrease_active_replace_collateral(&mut self, amount: &Amount) -> DispatchResult { - self.update(|v| { - v.active_replace_collateral = v - .active_replace_collateral - .checked_sub(&amount.amount()) - .ok_or(ArithmeticError::Underflow)?; - Ok(()) - }) - } - pub(crate) fn set_custom_secure_threshold(&mut self, threshold: Option>) -> DispatchResult { self.update(|v| { v.secure_collateral_threshold = threshold; @@ -578,8 +566,6 @@ impl RichVault { .ok_or(Error::::ThresholdNotSet)?, )?; - // Clear `to_be_replaced` tokens, since the vault will have no more `issued` or `to_be_issued` tokens. - let _ = Pallet::::withdraw_replace_request(&self.data.id, &self.to_be_replaced_tokens())?; // the vault struct was modified in the call above - we need to re-fetch, // otherwise changes get overwritten below *self = Pallet::::get_rich_vault_from_id(&vault_id)?; @@ -816,3 +802,48 @@ impl From> for RichSystemVault { RichSystemVault { data: vault } } } + +#[cfg(test)] +mod test { + use super::*; + use crate::mock::{Test as T, *}; + + #[test] + fn migrating_from_v6_to_v7() { + run_test(|| { + crate::StorageVersion::::put(Version::V6); + + let old = v6::DefaultVault:: { + id: DefaultVaultId::::new(123, Token(DOT), Token(IBTC)), + status: VaultStatus::Active(true), + banned_until: None, + secure_collateral_threshold: Default::default(), + to_be_issued_tokens: 0u32.into(), + issued_tokens: 0u32.into(), + to_be_redeemed_tokens: 0u32.into(), + to_be_replaced_tokens: 0u32.into(), + replace_collateral: 0u32.into(), + active_replace_collateral: 0u32.into(), + liquidated_collateral: 0u32.into(), + }; + let key = DefaultVaultId::::new(123, Token(DOT), Token(IBTC)); + + v6::Vaults::::insert(key.clone(), old.clone()); + + v7::migrate_v6_to_v7::(); + + assert_eq!(crate::StorageVersion::::get(), Version::V7); + + let new = crate::Vaults::::get(key).unwrap(); + + assert!(old.id == new.id); + assert!(old.status == new.status); + assert!(old.banned_until == new.banned_until); + assert!(old.secure_collateral_threshold == new.secure_collateral_threshold); + assert!(old.to_be_issued_tokens == new.to_be_issued_tokens); + assert!(old.issued_tokens == new.issued_tokens); + assert!(old.to_be_redeemed_tokens == new.to_be_redeemed_tokens); + assert!(old.liquidated_collateral == new.liquidated_collateral); + }); + } +} diff --git a/parachain/Cargo.toml b/parachain/Cargo.toml index 29e46babfc..6c1f0d2248 100644 --- a/parachain/Cargo.toml +++ b/parachain/Cargo.toml @@ -42,7 +42,6 @@ escrow-rpc-runtime-api = { path = "../crates/escrow/rpc/runtime-api" } reward-rpc-runtime-api = { path = "../crates/reward/rpc/runtime-api" } issue-rpc-runtime-api = { path = "../crates/issue/rpc/runtime-api" } redeem-rpc-runtime-api = { path = "../crates/redeem/rpc/runtime-api" } -replace-rpc-runtime-api = { path = "../crates/replace/rpc/runtime-api" } loans-rpc-runtime-api = { path = "../crates/loans/rpc/runtime-api" } dex-general-rpc-runtime-api = { path = "../crates/dex-general/rpc/runtime-api" } dex-stable-rpc-runtime-api = { path = "../crates/dex-stable/rpc/runtime-api" } diff --git a/parachain/runtime/common/Cargo.toml b/parachain/runtime/common/Cargo.toml index b66f349dcf..1ea78addcd 100644 --- a/parachain/runtime/common/Cargo.toml +++ b/parachain/runtime/common/Cargo.toml @@ -37,7 +37,6 @@ loans = { path = "../../../crates/loans", default-features = false } nomination = { path = "../../../crates/nomination", default-features = false } oracle = { path = "../../../crates/oracle", default-features = false } redeem = { path = "../../../crates/redeem", default-features = false } -replace = { path = "../../../crates/replace", default-features = false } reward = { path = "../../../crates/reward", default-features = false } security = { path = "../../../crates/security", default-features = false } staking = { path = "../../../crates/staking", default-features = false } @@ -98,7 +97,6 @@ std = [ "nomination/std", "oracle/std", "redeem/std", - "replace/std", "reward/std", "security/std", "staking/std", @@ -141,7 +139,6 @@ try-runtime = [ "nomination/try-runtime", "oracle/try-runtime", "redeem/try-runtime", - "replace/try-runtime", "reward/try-runtime", "security/try-runtime", "staking/try-runtime", diff --git a/parachain/runtime/interlay/Cargo.toml b/parachain/runtime/interlay/Cargo.toml index 43d729e0d2..89ca450d17 100644 --- a/parachain/runtime/interlay/Cargo.toml +++ b/parachain/runtime/interlay/Cargo.toml @@ -97,7 +97,6 @@ multi-transaction-payment = { path = "../../../crates/multi-transaction-payment" nomination = { path = "../../../crates/nomination", default-features = false } oracle = { path = "../../../crates/oracle", default-features = false } redeem = { path = "../../../crates/redeem", default-features = false } -replace = { path = "../../../crates/replace", default-features = false } reward = { path = "../../../crates/reward", default-features = false } security = { path = "../../../crates/security", default-features = false } staking = { path = "../../../crates/staking", default-features = false } @@ -117,7 +116,6 @@ issue-rpc-runtime-api = { path = "../../../crates/issue/rpc/runtime-api", defaul loans-rpc-runtime-api = { path = "../../../crates/loans/rpc/runtime-api", default-features = false } oracle-rpc-runtime-api = { path = "../../../crates/oracle/rpc/runtime-api", default-features = false } redeem-rpc-runtime-api = { path = "../../../crates/redeem/rpc/runtime-api", default-features = false } -replace-rpc-runtime-api = { path = "../../../crates/replace/rpc/runtime-api", default-features = false } reward-rpc-runtime-api = { path = "../../../crates/reward/rpc/runtime-api", default-features = false } vault-registry-rpc-runtime-api = { path = "../../../crates/vault-registry/rpc/runtime-api", default-features = false } @@ -235,7 +233,6 @@ std = [ "nomination/std", "oracle/std", "redeem/std", - "replace/std", "reward/std", "security/std", "staking/std", @@ -255,7 +252,6 @@ std = [ "loans-rpc-runtime-api/std", "oracle-rpc-runtime-api/std", "redeem-rpc-runtime-api/std", - "replace-rpc-runtime-api/std", "reward-rpc-runtime-api/std", "vault-registry-rpc-runtime-api/std", @@ -315,7 +311,6 @@ runtime-benchmarks = [ "nomination/runtime-benchmarks", "oracle/runtime-benchmarks", "redeem/runtime-benchmarks", - "replace/runtime-benchmarks", "security/runtime-benchmarks", "supply/runtime-benchmarks", "traits/runtime-benchmarks", @@ -376,7 +371,6 @@ try-runtime = [ "nomination/try-runtime", "oracle/try-runtime", "redeem/try-runtime", - "replace/try-runtime", "reward/try-runtime", "security/try-runtime", "staking/try-runtime", diff --git a/parachain/runtime/interlay/src/lib.rs b/parachain/runtime/interlay/src/lib.rs index ab935702a2..e179ec14a0 100644 --- a/parachain/runtime/interlay/src/lib.rs +++ b/parachain/runtime/interlay/src/lib.rs @@ -1155,13 +1155,6 @@ impl redeem::Config for Runtime { type WeightInfo = weights::redeem::WeightInfo; } -pub use replace::ReplaceRequest; - -impl replace::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::replace::WeightInfo; -} - pub use nomination::Event as NominationEvent; impl nomination::Config for Runtime { @@ -1252,7 +1245,7 @@ construct_runtime! { Oracle: oracle::{Pallet, Call, Config, Storage, Event} = 62, Issue: issue::{Pallet, Call, Config, Storage, Event} = 63, Redeem: redeem::{Pallet, Call, Config, Storage, Event} = 64, - Replace: replace::{Pallet, Call, Config, Storage, Event} = 65, + // Replace: 65 Fee: fee::{Pallet, Call, Config, Storage} = 66, // Refund: 67 Nomination: nomination::{Pallet, Call, Config, Storage, Event} = 68, @@ -1432,7 +1425,6 @@ mod benches { [nomination, Nomination] [oracle, Oracle] [redeem, Redeem] - [replace, Replace] [security, Security] [supply, Supply] [tx_pause, TxPause] @@ -1952,21 +1944,6 @@ impl_runtime_apis! { } } - impl replace_rpc_runtime_api::ReplaceApi< - Block, - AccountId, - H256, - ReplaceRequest - > for Runtime { - fn get_old_vault_replace_requests(vault_id: AccountId) -> Vec { - Replace::get_replace_requests_for_old_vault(vault_id) - } - - fn get_new_vault_replace_requests(vault_id: AccountId) -> Vec { - Replace::get_replace_requests_for_new_vault(vault_id) - } - } - #[cfg(feature = "try-runtime")] impl frame_try_runtime::TryRuntime for Runtime { fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { diff --git a/parachain/runtime/interlay/src/weights/issue.rs b/parachain/runtime/interlay/src/weights/issue.rs index fa72cf8d1c..cf0c067d1d 100644 --- a/parachain/runtime/interlay/src/weights/issue.rs +++ b/parachain/runtime/interlay/src/weights/issue.rs @@ -2,31 +2,31 @@ //! Autogenerated weights for issue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-29, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-jrrg4`, CPU: `AMD EPYC 7502P 32-Core Processor` +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("interlay-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet // --pallet -// * +// issue // --extrinsic // * -// --chain -// interlay-dev // --execution=wasm // --wasm-execution=compiled // --steps -// 50 +// 2 // --repeat -// 10 -// --output -// parachain/runtime/interlay/src/weights/ +// 1 // --template // .deploy/runtime-weight-template.hbs +// --chain +// interlay-dev +// --output +// generated_weight_interlay.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,13 +47,15 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: Fee IssueGriefingCollateral (r:1 w:0) /// Proof: Fee IssueGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) + /// Storage: Fee IssueFee (r:1 w:0) + /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Issue IssueBtcDustValue (r:1 w:0) /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) @@ -62,8 +64,6 @@ impl issue::WeightInfo for WeightInfo { /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Fee IssueFee (r:1 w:0) - /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) /// Storage: System ParentHash (r:1 w:0) @@ -75,18 +75,18 @@ impl issue::WeightInfo for WeightInfo { /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Issue IssueRequests (r:0 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) fn request_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `2681` + // Measured: `2633` // Estimated: `6028` - // Minimum execution time: 556_004_000 picoseconds. - Weight::from_parts(558_989_000, 6028) + // Minimum execution time: 39_089_000_000 picoseconds. + Weight::from_parts(39_089_000_000, 6028) .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -102,7 +102,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -113,23 +113,25 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_exact (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_issue_exact (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2434` - // Estimated: `3737` - // Minimum execution time: 195_191_000 picoseconds. - Weight::from_parts(33_956_966, 3737) - // Standard Error: 810_295 - .saturating_add(Weight::from_parts(10_187_551, 0).saturating_mul(h.into())) - // Standard Error: 730_159 - .saturating_add(Weight::from_parts(7_188_076, 0).saturating_mul(i.into())) - // Standard Error: 5_239 - .saturating_add(Weight::from_parts(34_842, 0).saturating_mul(b.into())) + // Measured: `2428` + // Estimated: `3760` + // Minimum execution time: 193_000_000 picoseconds. + Weight::from_parts(160_513_301, 3760) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_500_000, 0).saturating_mul(h.into())) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_333_333, 0).saturating_mul(i.into())) + // Standard Error: 0 + .saturating_add(Weight::from_parts(333_333, 0).saturating_mul(o.into())) + // Standard Error: 0 + .saturating_add(Weight::from_parts(6_259, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -145,7 +147,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -166,19 +168,25 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_overpayment (h: u32, _i: u32, _o: u32, _b: u32, ) -> Weight { + fn execute_issue_overpayment (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3248` - // Estimated: `3737` - // Minimum execution time: 313_197_000 picoseconds. - Weight::from_parts(676_783_389, 3737) - // Standard Error: 967_719 - .saturating_add(Weight::from_parts(1_294_288, 0).saturating_mul(h.into())) + // Measured: `3278` + // Estimated: `3760` + // Minimum execution time: 305_000_000 picoseconds. + Weight::from_parts(260_494_913, 3760) + // Standard Error: 216_506 + .saturating_add(Weight::from_parts(2_125_000, 0).saturating_mul(h.into())) + // Standard Error: 192_450 + .saturating_add(Weight::from_parts(555_555, 0).saturating_mul(i.into())) + // Standard Error: 192_450 + .saturating_add(Weight::from_parts(444_444, 0).saturating_mul(o.into())) + // Standard Error: 1_355 + .saturating_add(Weight::from_parts(17_214, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -194,7 +202,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -207,23 +215,23 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_underpayment (h: u32, _i: u32, o: u32, b: u32, ) -> Weight { + fn execute_issue_underpayment (h: u32, i: u32, o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2739` - // Estimated: `3737` - // Minimum execution time: 231_854_000 picoseconds. - Weight::from_parts(253_010_791, 3737) - // Standard Error: 189_488 - .saturating_add(Weight::from_parts(3_800_800, 0).saturating_mul(h.into())) - // Standard Error: 170_748 - .saturating_add(Weight::from_parts(167_716, 0).saturating_mul(o.into())) - // Standard Error: 1_225 - .saturating_add(Weight::from_parts(6_220, 0).saturating_mul(b.into())) + // Measured: `2727` + // Estimated: `3760` + // Minimum execution time: 220_000_000 picoseconds. + Weight::from_parts(220_934_076, 3760) + // Standard Error: 1_840_303 + .saturating_add(Weight::from_parts(3_437_500, 0).saturating_mul(h.into())) + // Standard Error: 1_635_825 + .saturating_add(Weight::from_parts(611_111, 0).saturating_mul(i.into())) + // Standard Error: 1_635_825 + .saturating_add(Weight::from_parts(611_111, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -239,7 +247,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -250,25 +258,21 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_exact (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_exact (h: u32, _i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3363` - // Estimated: `3737` - // Minimum execution time: 201_924_000 picoseconds. - Weight::from_parts(139_929_561, 3737) - // Standard Error: 194_156 - .saturating_add(Weight::from_parts(3_652_125, 0).saturating_mul(h.into())) - // Standard Error: 174_955 - .saturating_add(Weight::from_parts(1_547_829, 0).saturating_mul(i.into())) - // Standard Error: 174_955 - .saturating_add(Weight::from_parts(1_815_584, 0).saturating_mul(o.into())) - // Standard Error: 1_255 - .saturating_add(Weight::from_parts(16_572, 0).saturating_mul(b.into())) + // Measured: `3287` + // Estimated: `3760` + // Minimum execution time: 193_000_000 picoseconds. + Weight::from_parts(223_547_730, 3760) + // Standard Error: 649_519 + .saturating_add(Weight::from_parts(4_000_000, 0).saturating_mul(h.into())) + // Standard Error: 4_065 + .saturating_add(Weight::from_parts(9_389, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -284,7 +288,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -305,25 +309,23 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_overpayment (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_overpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3947 + h * (1 ±0) + i * (1 ±0)` - // Estimated: `3737` - // Minimum execution time: 319_510_000 picoseconds. - Weight::from_parts(297_484_836, 3737) - // Standard Error: 93_915 - .saturating_add(Weight::from_parts(3_775_028, 0).saturating_mul(h.into())) - // Standard Error: 84_627 - .saturating_add(Weight::from_parts(1_330_041, 0).saturating_mul(i.into())) - // Standard Error: 84_627 - .saturating_add(Weight::from_parts(179_165, 0).saturating_mul(o.into())) - // Standard Error: 607 - .saturating_add(Weight::from_parts(2_628, 0).saturating_mul(b.into())) + // Measured: `4018 + h * (9 ±0) + i * (4 ±0)` + // Estimated: `3760` + // Minimum execution time: 314_000_000 picoseconds. + Weight::from_parts(269_041_862, 3760) + // Standard Error: 3_031_088 + .saturating_add(Weight::from_parts(2_875_000, 0).saturating_mul(h.into())) + // Standard Error: 2_694_301 + .saturating_add(Weight::from_parts(1_555_555, 0).saturating_mul(i.into())) + // Standard Error: 18_973 + .saturating_add(Weight::from_parts(16_431, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -339,7 +341,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -352,23 +354,25 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_underpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_underpayment (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3653` - // Estimated: `3737` - // Minimum execution time: 241_423_000 picoseconds. - Weight::from_parts(228_353_888, 3737) - // Standard Error: 69_658 - .saturating_add(Weight::from_parts(3_202_457, 0).saturating_mul(h.into())) - // Standard Error: 62_769 - .saturating_add(Weight::from_parts(689_283, 0).saturating_mul(i.into())) - // Standard Error: 450 - .saturating_add(Weight::from_parts(3_239, 0).saturating_mul(b.into())) + // Measured: `4257` + // Estimated: `3760` + // Minimum execution time: 225_000_000 picoseconds. + Weight::from_parts(169_911_776, 3760) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(4_312_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(2_166_666, 0).saturating_mul(i.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_277_777, 0).saturating_mul(o.into())) + // Standard Error: 677 + .saturating_add(Weight::from_parts(5_868, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -376,24 +380,41 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) fn cancel_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `1495` - // Estimated: `3737` - // Minimum execution time: 89_729_000 picoseconds. - Weight::from_parts(90_551_000, 3737) + // Measured: `1485` + // Estimated: `3760` + // Minimum execution time: 90_000_000 picoseconds. + Weight::from_parts(90_000_000, 3760) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn cancel_issue_for_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `1007` + // Estimated: `3760` + // Minimum execution time: 63_000_000 picoseconds. + Weight::from_parts(63_000_000, 3760) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } /// Storage: Issue IssuePeriod (r:0 w:1) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_issue_period () -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 17_425_000 picoseconds. - Weight::from_parts(17_906_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } \ No newline at end of file diff --git a/parachain/runtime/interlay/src/weights/mod.rs b/parachain/runtime/interlay/src/weights/mod.rs index 9c557d49d7..792af080bb 100644 --- a/parachain/runtime/interlay/src/weights/mod.rs +++ b/parachain/runtime/interlay/src/weights/mod.rs @@ -34,7 +34,6 @@ pub mod pallet_xcm; pub mod pallet_xcm_benchmarks_fungible; pub mod pallet_xcm_benchmarks_generic; pub mod redeem; -pub mod replace; pub mod security; pub mod supply; pub mod tx_pause; diff --git a/parachain/runtime/interlay/src/weights/redeem.rs b/parachain/runtime/interlay/src/weights/redeem.rs index 07f30bc059..967effd348 100644 --- a/parachain/runtime/interlay/src/weights/redeem.rs +++ b/parachain/runtime/interlay/src/weights/redeem.rs @@ -2,31 +2,31 @@ //! Autogenerated weights for redeem //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-29, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-jrrg4`, CPU: `AMD EPYC 7502P 32-Core Processor` +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("interlay-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet // --pallet -// * +// redeem // --extrinsic // * -// --chain -// interlay-dev // --execution=wasm // --wasm-execution=compiled // --steps -// 50 +// 2 // --repeat -// 10 -// --output -// parachain/runtime/interlay/src/weights/ +// 1 // --template // .deploy/runtime-weight-template.hbs +// --chain +// interlay-dev +// --output +// generated_weight_interlay.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -40,6 +40,8 @@ pub struct WeightInfo(PhantomData); impl redeem::WeightInfo for WeightInfo { + /// Storage: VaultRegistry Vaults (r:1 w:1) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:2 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Fee RedeemFee (r:1 w:0) @@ -48,8 +50,6 @@ impl redeem::WeightInfo for WeightInfo { /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) @@ -91,13 +91,13 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3155` + // Measured: `3107` // Estimated: `6260` - // Minimum execution time: 310_652_000 picoseconds. - Weight::from_parts(313_168_000, 6260) + // Minimum execution time: 307_000_000 picoseconds. + Weight::from_parts(307_000_000, 6260) .saturating_add(T::DbWeight::get().reads(28_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -129,13 +129,13 @@ impl redeem::WeightInfo for WeightInfo { // Proof Size summary in bytes: // Measured: `2173` // Estimated: `8760` - // Minimum execution time: 283_197_000 picoseconds. - Weight::from_parts(284_509_000, 8760) + // Minimum execution time: 292_000_000 picoseconds. + Weight::from_parts(292_000_000, 8760) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -155,30 +155,30 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. /// The range of component `b` is `[541, 2048]`. fn execute_redeem (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2295 + o * (1 ±0)` - // Estimated: `3725` - // Minimum execution time: 183_618_000 picoseconds. - Weight::from_parts(155_534_743, 3725) - // Standard Error: 117_935 - .saturating_add(Weight::from_parts(3_687_939, 0).saturating_mul(h.into())) - // Standard Error: 106_320 - .saturating_add(Weight::from_parts(952_959, 0).saturating_mul(i.into())) - // Standard Error: 644_527 - .saturating_add(Weight::from_parts(862_990, 0).saturating_mul(o.into())) - // Standard Error: 649 - .saturating_add(Weight::from_parts(4_928, 0).saturating_mul(b.into())) + // Measured: `2248 + o * (1 ±0)` + // Estimated: `3743` + // Minimum execution time: 182_000_000 picoseconds. + Weight::from_parts(136_635_488, 3743) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(562_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_611_111, 0).saturating_mul(i.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(7_500_000, 0).saturating_mul(o.into())) + // Standard Error: 574 + .saturating_add(Weight::from_parts(7_631, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -186,7 +186,7 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -267,15 +267,15 @@ impl redeem::WeightInfo for WeightInfo { /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: - // Measured: `5396` + // Measured: `5349` // Estimated: `11350` - // Minimum execution time: 847_787_000 picoseconds. - Weight::from_parts(851_295_000, 11350) + // Minimum execution time: 753_000_000 picoseconds. + Weight::from_parts(753_000_000, 11350) .saturating_add(T::DbWeight::get().reads(59_u64)) .saturating_add(T::DbWeight::get().writes(29_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -283,7 +283,7 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -364,36 +364,183 @@ impl redeem::WeightInfo for WeightInfo { /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: - // Measured: `5396` + // Measured: `5349` // Estimated: `11350` - // Minimum execution time: 775_122_000 picoseconds. - Weight::from_parts(783_890_000, 11350) + // Minimum execution time: 724_000_000 picoseconds. + Weight::from_parts(724_000_000, 11350) .saturating_add(T::DbWeight::get().reads(58_u64)) .saturating_add(T::DbWeight::get().writes(28_u64)) } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: Fee PunishmentFee (r:1 w:0) + /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:1 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) + /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultCapacity Stake (r:1 w:0) + /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardPerToken (r:2 w:0) + /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardTally (r:2 w:2) + /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultCapacity TotalRewards (r:2 w:2) + /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultRewards Stake (r:1 w:0) + /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardPerToken (r:2 w:0) + /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardTally (r:2 w:2) + /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalRewards (r:2 w:2) + /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: Fee Commission (r:1 w:0) + /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) + /// Storage: VaultStaking RewardPerToken (r:2 w:2) + /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalStake (r:1 w:0) + /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalStake (r:1 w:0) + /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + fn cancel_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `4412` + // Estimated: `6364` + // Minimum execution time: 397_000_000 picoseconds. + Weight::from_parts(397_000_000, 6364) + .saturating_add(T::DbWeight::get().reads(33_u64)) + .saturating_add(T::DbWeight::get().writes(15_u64)) + } /// Storage: Redeem RedeemPeriod (r:0 w:1) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_redeem_period () -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_136_000 picoseconds. - Weight::from_parts(18_727_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) fn self_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `1427` - // Estimated: `3725` - // Minimum execution time: 149_329_000 picoseconds. - Weight::from_parts(152_415_000, 3725) + // Measured: `1379` + // Estimated: `3677` + // Minimum execution time: 111_000_000 picoseconds. + Weight::from_parts(111_000_000, 3677) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: BTCRelay StartBlockHeight (r:1 w:0) + /// Proof: BTCRelay StartBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueBtcDustValue (r:1 w:0) + /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:2 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:2 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: Security Nonce (r:1 w:1) + /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: System ParentHash (r:1 w:0) + /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: VaultRegistry VaultBitcoinPublicKey (r:1 w:0) + /// Proof: VaultRegistry VaultBitcoinPublicKey (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Fee RedeemFee (r:1 w:0) + /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) + /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) + /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:0 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Redeem RedeemRequests (r:0 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + fn request_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `2641` + // Estimated: `6364` + // Minimum execution time: 39_118_000_000 picoseconds. + Weight::from_parts(39_118_000_000, 6364) + .saturating_add(T::DbWeight::get().reads(21_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) + /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay Chains (r:1 w:0) + /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: BTCRelay BlockHeaders (r:1 w:0) + /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) + /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// The range of component `h` is `[2, 10]`. + /// The range of component `i` is `[1, 10]`. + /// The range of component `o` is `[2, 3]`. + /// The range of component `b` is `[541, 2048]`. + fn execute_replace (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2286` + // Estimated: `6364` + // Minimum execution time: 172_000_000 picoseconds. + Weight::from_parts(166_279_897, 6364) + // Standard Error: 216_506 + .saturating_add(Weight::from_parts(3_125_000, 0).saturating_mul(h.into())) + // Standard Error: 192_450 + .saturating_add(Weight::from_parts(111_111, 0).saturating_mul(i.into())) + // Standard Error: 1_149 + .saturating_add(Weight::from_parts(663, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } } \ No newline at end of file diff --git a/parachain/runtime/interlay/src/weights/replace.rs b/parachain/runtime/interlay/src/weights/replace.rs deleted file mode 100644 index 4e9c7c0970..0000000000 --- a/parachain/runtime/interlay/src/weights/replace.rs +++ /dev/null @@ -1,315 +0,0 @@ - -//! Autogenerated weights for replace -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-jrrg4`, CPU: `AMD EPYC 7502P 32-Core Processor` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("interlay-dev"), DB CACHE: 1024 - -// Executed Command: -// target/release/interbtc-parachain -// benchmark -// pallet -// --pallet -// * -// --extrinsic -// * -// --chain -// interlay-dev -// --execution=wasm -// --wasm-execution=compiled -// --steps -// 50 -// --repeat -// 10 -// --output -// parachain/runtime/interlay/src/weights/ -// --template -// .deploy/runtime-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weights for replace using the Substrate node and recommended hardware. -pub struct WeightInfo(PhantomData); - -impl replace::WeightInfo for WeightInfo { - - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Nomination Vaults (r:1 w:0) - /// Proof: Nomination Vaults (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Fee ReplaceGriefingCollateral (r:1 w:0) - /// Proof: Fee ReplaceGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - fn request_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `2035` - // Estimated: `3725` - // Minimum execution time: 131_042_000 picoseconds. - Weight::from_parts(135_822_000, 3725) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - fn withdraw_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `701` - // Estimated: `3725` - // Minimum execution time: 55_932_000 picoseconds. - Weight::from_parts(58_086_000, 3725) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardTally (r:2 w:2) - /// Proof: VaultStaking RewardTally (max_values: None, max_size: Some(149), added: 2624, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRegistry SystemCollateralCeiling (r:1 w:0) - /// Proof: VaultRegistry SystemCollateralCeiling (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplaceRequests (r:0 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - fn accept_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `4306` - // Estimated: `6460` - // Minimum execution time: 623_749_000 picoseconds. - Weight::from_parts(628_388_000, 6460) - .saturating_add(T::DbWeight::get().reads(42_u64)) - .saturating_add(T::DbWeight::get().writes(26_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_pending_replace (h: u32, i: u32, o: u32, b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `3962` - // Estimated: `6460` - // Minimum execution time: 201_203_000 picoseconds. - Weight::from_parts(166_625_346, 6460) - // Standard Error: 77_399 - .saturating_add(Weight::from_parts(3_797_260, 0).saturating_mul(h.into())) - // Standard Error: 69_776 - .saturating_add(Weight::from_parts(1_249_996, 0).saturating_mul(i.into())) - // Standard Error: 422_991 - .saturating_add(Weight::from_parts(3_113_568, 0).saturating_mul(o.into())) - // Standard Error: 426 - .saturating_add(Weight::from_parts(3_662, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_cancelled_replace (h: u32, i: u32, o: u32, b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `4084` - // Estimated: `6460` - // Minimum execution time: 244_751_000 picoseconds. - Weight::from_parts(221_003_188, 6460) - // Standard Error: 69_845 - .saturating_add(Weight::from_parts(3_504_737, 0).saturating_mul(h.into())) - // Standard Error: 62_966 - .saturating_add(Weight::from_parts(526_198, 0).saturating_mul(i.into())) - // Standard Error: 381_710 - .saturating_add(Weight::from_parts(2_470_971, 0).saturating_mul(o.into())) - // Standard Error: 384 - .saturating_add(Weight::from_parts(4_539, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(14_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry MinimumCollateralVault (r:1 w:0) - /// Proof: VaultRegistry MinimumCollateralVault (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:0) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:0) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:0) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - fn cancel_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `4744` - // Estimated: `6460` - // Minimum execution time: 499_671_000 picoseconds. - Weight::from_parts(507_496_000, 6460) - .saturating_add(T::DbWeight::get().reads(37_u64)) - .saturating_add(T::DbWeight::get().writes(19_u64)) - } - /// Storage: Replace ReplacePeriod (r:0 w:1) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_replace_period () -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 17_806_000 picoseconds. - Weight::from_parts(18_467_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} \ No newline at end of file diff --git a/parachain/runtime/interlay/src/xcm_config.rs b/parachain/runtime/interlay/src/xcm_config.rs index 1cb0f0e598..26bda8bc07 100644 --- a/parachain/runtime/interlay/src/xcm_config.rs +++ b/parachain/runtime/interlay/src/xcm_config.rs @@ -180,7 +180,7 @@ impl Contains for SafeCallFilter { // these calls can recurse - disallow false } - RuntimeCall::Issue(..) | RuntimeCall::Replace(..) | RuntimeCall::Redeem(..) | RuntimeCall::BTCRelay(..) => { + RuntimeCall::Issue(..) | RuntimeCall::Redeem(..) | RuntimeCall::BTCRelay(..) => { // disallow anything to do with btc transactions since btc tx may be unbounded false } diff --git a/parachain/runtime/kintsugi/Cargo.toml b/parachain/runtime/kintsugi/Cargo.toml index 2ef39bee03..3a23543600 100644 --- a/parachain/runtime/kintsugi/Cargo.toml +++ b/parachain/runtime/kintsugi/Cargo.toml @@ -101,7 +101,6 @@ multi-transaction-payment = { path = "../../../crates/multi-transaction-payment" nomination = { path = "../../../crates/nomination", default-features = false } oracle = { path = "../../../crates/oracle", default-features = false } redeem = { path = "../../../crates/redeem", default-features = false } -replace = { path = "../../../crates/replace", default-features = false } reward = { path = "../../../crates/reward", default-features = false } security = { path = "../../../crates/security", default-features = false } staking = { path = "../../../crates/staking", default-features = false } @@ -121,7 +120,6 @@ issue-rpc-runtime-api = { path = "../../../crates/issue/rpc/runtime-api", defaul loans-rpc-runtime-api = { path = "../../../crates/loans/rpc/runtime-api", default-features = false } oracle-rpc-runtime-api = { path = "../../../crates/oracle/rpc/runtime-api", default-features = false } redeem-rpc-runtime-api = { path = "../../../crates/redeem/rpc/runtime-api", default-features = false } -replace-rpc-runtime-api = { path = "../../../crates/replace/rpc/runtime-api", default-features = false } reward-rpc-runtime-api = { path = "../../../crates/reward/rpc/runtime-api", default-features = false } vault-registry-rpc-runtime-api = { path = "../../../crates/vault-registry/rpc/runtime-api", default-features = false } @@ -245,7 +243,6 @@ std = [ "nomination/std", "oracle/std", "redeem/std", - "replace/std", "reward/std", "security/std", "staking/std", @@ -265,7 +262,6 @@ std = [ "loans-rpc-runtime-api/std", "oracle-rpc-runtime-api/std", "redeem-rpc-runtime-api/std", - "replace-rpc-runtime-api/std", "reward-rpc-runtime-api/std", "vault-registry-rpc-runtime-api/std", @@ -325,7 +321,6 @@ runtime-benchmarks = [ "nomination/runtime-benchmarks", "oracle/runtime-benchmarks", "redeem/runtime-benchmarks", - "replace/runtime-benchmarks", "security/runtime-benchmarks", "supply/runtime-benchmarks", "traits/runtime-benchmarks", @@ -387,7 +382,6 @@ try-runtime = [ "nomination/try-runtime", "oracle/try-runtime", "redeem/try-runtime", - "replace/try-runtime", "reward/try-runtime", "security/try-runtime", "staking/try-runtime", diff --git a/parachain/runtime/kintsugi/src/lib.rs b/parachain/runtime/kintsugi/src/lib.rs index 44761fc66c..c7bab6811b 100644 --- a/parachain/runtime/kintsugi/src/lib.rs +++ b/parachain/runtime/kintsugi/src/lib.rs @@ -1156,13 +1156,6 @@ impl redeem::Config for Runtime { type WeightInfo = weights::redeem::WeightInfo; } -pub use replace::ReplaceRequest; - -impl replace::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type WeightInfo = weights::replace::WeightInfo; -} - pub use nomination::Event as NominationEvent; impl nomination::Config for Runtime { @@ -1254,7 +1247,7 @@ construct_runtime! { Oracle: oracle::{Pallet, Call, Config, Storage, Event} = 62, Issue: issue::{Pallet, Call, Config, Storage, Event} = 63, Redeem: redeem::{Pallet, Call, Config, Storage, Event} = 64, - Replace: replace::{Pallet, Call, Config, Storage, Event} = 65, + // Replace: 65 Fee: fee::{Pallet, Call, Config, Storage} = 66, // Refund: 67 Nomination: nomination::{Pallet, Call, Config, Storage, Event} = 68, @@ -1435,7 +1428,6 @@ mod benches { [nomination, Nomination] [oracle, Oracle] [redeem, Redeem] - [replace, Replace] [security, Security] [supply, Supply] [tx_pause, TxPause] @@ -1820,21 +1812,6 @@ impl_runtime_apis! { } } - impl replace_rpc_runtime_api::ReplaceApi< - Block, - AccountId, - H256, - ReplaceRequest - > for Runtime { - fn get_old_vault_replace_requests(vault_id: AccountId) -> Vec { - Replace::get_replace_requests_for_old_vault(vault_id) - } - - fn get_new_vault_replace_requests(vault_id: AccountId) -> Vec { - Replace::get_replace_requests_for_new_vault(vault_id) - } - } - impl loans_rpc_runtime_api::LoansApi< Block, AccountId, diff --git a/parachain/runtime/kintsugi/src/weights/issue.rs b/parachain/runtime/kintsugi/src/weights/issue.rs index 10f28c57a2..eeeded9f67 100644 --- a/parachain/runtime/kintsugi/src/weights/issue.rs +++ b/parachain/runtime/kintsugi/src/weights/issue.rs @@ -2,31 +2,31 @@ //! Autogenerated weights for issue //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-29, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-kcxvd`, CPU: `AMD EPYC 7502P 32-Core Processor` +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet // --pallet -// * +// issue // --extrinsic // * -// --chain -// kintsugi-dev // --execution=wasm // --wasm-execution=compiled // --steps -// 50 +// 2 // --repeat -// 10 -// --output -// parachain/runtime/kintsugi/src/weights/ +// 1 // --template // .deploy/runtime-weight-template.hbs +// --chain +// kintsugi-dev +// --output +// generated_weight_kintsugi.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -47,13 +47,15 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) /// Storage: Fee IssueGriefingCollateral (r:1 w:0) /// Proof: Fee IssueGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) + /// Storage: Fee IssueFee (r:1 w:0) + /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Issue IssueBtcDustValue (r:1 w:0) /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) @@ -62,8 +64,6 @@ impl issue::WeightInfo for WeightInfo { /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: Fee IssueFee (r:1 w:0) - /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) /// Storage: System ParentHash (r:1 w:0) @@ -75,18 +75,18 @@ impl issue::WeightInfo for WeightInfo { /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Issue IssueRequests (r:0 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) fn request_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `2718` + // Measured: `2690` // Estimated: `6028` - // Minimum execution time: 558_298_000 picoseconds. - Weight::from_parts(565_393_000, 6028) + // Minimum execution time: 38_621_000_000 picoseconds. + Weight::from_parts(38_621_000_000, 6028) .saturating_add(T::DbWeight::get().reads(18_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -102,7 +102,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -113,25 +113,21 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_exact (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_issue_exact (_h: u32, i: u32, o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2434` - // Estimated: `3737` - // Minimum execution time: 198_538_000 picoseconds. - Weight::from_parts(171_478_384, 3737) - // Standard Error: 67_279 - .saturating_add(Weight::from_parts(3_496_696, 0).saturating_mul(h.into())) - // Standard Error: 60_626 - .saturating_add(Weight::from_parts(794_967, 0).saturating_mul(i.into())) - // Standard Error: 60_626 - .saturating_add(Weight::from_parts(420_219, 0).saturating_mul(o.into())) - // Standard Error: 435 - .saturating_add(Weight::from_parts(5_157, 0).saturating_mul(b.into())) + // Measured: `2448` + // Estimated: `3760` + // Minimum execution time: 206_000_000 picoseconds. + Weight::from_parts(261_839_397, 3760) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(277_777, 0).saturating_mul(i.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(166_666, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -147,7 +143,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -168,25 +164,23 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_overpayment (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_issue_overpayment (_h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3285` - // Estimated: `3737` - // Minimum execution time: 316_013_000 picoseconds. - Weight::from_parts(296_206_373, 3737) - // Standard Error: 170_956 - .saturating_add(Weight::from_parts(3_648_998, 0).saturating_mul(h.into())) - // Standard Error: 154_049 - .saturating_add(Weight::from_parts(965_687, 0).saturating_mul(i.into())) - // Standard Error: 154_049 - .saturating_add(Weight::from_parts(440_368, 0).saturating_mul(o.into())) - // Standard Error: 1_105 - .saturating_add(Weight::from_parts(1_242, 0).saturating_mul(b.into())) + // Measured: `3335` + // Estimated: `3760` + // Minimum execution time: 307_000_000 picoseconds. + Weight::from_parts(277_172_143, 3760) + // Standard Error: 1_347_150 + .saturating_add(Weight::from_parts(777_777, 0).saturating_mul(i.into())) + // Standard Error: 1_347_150 + .saturating_add(Weight::from_parts(1_000_000, 0).saturating_mul(o.into())) + // Standard Error: 9_486 + .saturating_add(Weight::from_parts(15_649, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -202,7 +196,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -215,23 +209,23 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_issue_underpayment (h: u32, i: u32, o: u32, _b: u32, ) -> Weight { + fn execute_issue_underpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2739` - // Estimated: `3737` - // Minimum execution time: 236_814_000 picoseconds. - Weight::from_parts(218_087_002, 3737) - // Standard Error: 143_849 - .saturating_add(Weight::from_parts(3_739_468, 0).saturating_mul(h.into())) - // Standard Error: 129_622 - .saturating_add(Weight::from_parts(1_289_008, 0).saturating_mul(i.into())) - // Standard Error: 129_622 - .saturating_add(Weight::from_parts(452_541, 0).saturating_mul(o.into())) + // Measured: `2747` + // Estimated: `3760` + // Minimum execution time: 214_000_000 picoseconds. + Weight::from_parts(184_539_123, 3760) + // Standard Error: 1_732_050 + .saturating_add(Weight::from_parts(4_250_000, 0).saturating_mul(h.into())) + // Standard Error: 1_539_600 + .saturating_add(Weight::from_parts(1_555_555, 0).saturating_mul(i.into())) + // Standard Error: 10_842 + .saturating_add(Weight::from_parts(8_607, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -247,7 +241,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) @@ -260,23 +254,23 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `b` is `[770, 2048]`. fn execute_expired_issue_exact (h: u32, i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3567` - // Estimated: `3737` - // Minimum execution time: 206_463_000 picoseconds. - Weight::from_parts(179_023_981, 3737) - // Standard Error: 118_695 - .saturating_add(Weight::from_parts(3_632_454, 0).saturating_mul(h.into())) - // Standard Error: 106_956 - .saturating_add(Weight::from_parts(825_036, 0).saturating_mul(i.into())) - // Standard Error: 106_956 - .saturating_add(Weight::from_parts(185_589, 0).saturating_mul(o.into())) - // Standard Error: 767 - .saturating_add(Weight::from_parts(6_936, 0).saturating_mul(b.into())) + // Measured: `3536` + // Estimated: `3760` + // Minimum execution time: 194_000_000 picoseconds. + Weight::from_parts(163_253_716, 3760) + // Standard Error: 974_278 + .saturating_add(Weight::from_parts(3_562_500, 0).saturating_mul(h.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(611_111, 0).saturating_mul(i.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(388_888, 0).saturating_mul(o.into())) + // Standard Error: 6_098 + .saturating_add(Weight::from_parts(6_651, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -292,7 +286,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -313,25 +307,23 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_overpayment (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_overpayment (h: u32, i: u32, o: u32, _b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `4039 + h * (17 ±0) + i * (2 ±0)` - // Estimated: `3737` - // Minimum execution time: 326_534_000 picoseconds. - Weight::from_parts(312_629_634, 3737) - // Standard Error: 118_522 - .saturating_add(Weight::from_parts(3_380_960, 0).saturating_mul(h.into())) - // Standard Error: 106_800 - .saturating_add(Weight::from_parts(561_891, 0).saturating_mul(i.into())) - // Standard Error: 106_800 - .saturating_add(Weight::from_parts(164_257, 0).saturating_mul(o.into())) - // Standard Error: 766 - .saturating_add(Weight::from_parts(3_419, 0).saturating_mul(b.into())) + // Measured: `4141 + h * (21 ±0) + i * (3 ±0) + o * (3 ±0)` + // Estimated: `3760` + // Minimum execution time: 322_000_000 picoseconds. + Weight::from_parts(316_622_652, 3760) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(937_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_055_555, 0).saturating_mul(i.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(55_555, 0).saturating_mul(o.into())) .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -347,7 +339,7 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Fee IssueFee (r:1 w:0) /// Proof: Fee IssueFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) @@ -360,25 +352,23 @@ impl issue::WeightInfo for WeightInfo { /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[1, 10]`. /// The range of component `b` is `[770, 2048]`. - fn execute_expired_issue_underpayment (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_expired_issue_underpayment (h: u32, i: u32, _o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `3633 + o * (11 ±0)` - // Estimated: `3737` - // Minimum execution time: 245_292_000 picoseconds. - Weight::from_parts(218_248_263, 3737) - // Standard Error: 75_656 - .saturating_add(Weight::from_parts(3_638_323, 0).saturating_mul(h.into())) - // Standard Error: 68_174 - .saturating_add(Weight::from_parts(1_189_484, 0).saturating_mul(i.into())) - // Standard Error: 68_174 - .saturating_add(Weight::from_parts(378_537, 0).saturating_mul(o.into())) - // Standard Error: 489 - .saturating_add(Weight::from_parts(4_279, 0).saturating_mul(b.into())) + // Measured: `3990` + // Estimated: `3760` + // Minimum execution time: 231_000_000 picoseconds. + Weight::from_parts(177_273_669, 3760) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(5_437_500, 0).saturating_mul(h.into())) + // Standard Error: 96_225 + .saturating_add(Weight::from_parts(1_277_777, 0).saturating_mul(i.into())) + // Standard Error: 677 + .saturating_add(Weight::from_parts(16_040, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(13_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: Issue IssueRequests (r:1 w:1) - /// Proof: Issue IssueRequests (max_values: None, max_size: Some(272), added: 2747, mode: MaxEncodedLen) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) /// Storage: Issue IssuePeriod (r:1 w:0) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -386,24 +376,41 @@ impl issue::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) fn cancel_issue () -> Weight { // Proof Size summary in bytes: - // Measured: `1495` - // Estimated: `3737` - // Minimum execution time: 91_653_000 picoseconds. - Weight::from_parts(93_397_000, 3737) + // Measured: `1505` + // Estimated: `3760` + // Minimum execution time: 89_000_000 picoseconds. + Weight::from_parts(89_000_000, 3760) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + fn cancel_issue_for_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `1027` + // Estimated: `3760` + // Minimum execution time: 66_000_000 picoseconds. + Weight::from_parts(66_000_000, 3760) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } /// Storage: Issue IssuePeriod (r:0 w:1) /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_issue_period () -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_417_000 picoseconds. - Weight::from_parts(18_597_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } } \ No newline at end of file diff --git a/parachain/runtime/kintsugi/src/weights/mod.rs b/parachain/runtime/kintsugi/src/weights/mod.rs index 9c557d49d7..792af080bb 100644 --- a/parachain/runtime/kintsugi/src/weights/mod.rs +++ b/parachain/runtime/kintsugi/src/weights/mod.rs @@ -34,7 +34,6 @@ pub mod pallet_xcm; pub mod pallet_xcm_benchmarks_fungible; pub mod pallet_xcm_benchmarks_generic; pub mod redeem; -pub mod replace; pub mod security; pub mod supply; pub mod tx_pause; diff --git a/parachain/runtime/kintsugi/src/weights/redeem.rs b/parachain/runtime/kintsugi/src/weights/redeem.rs index ca3aee803b..dfe0a5d757 100644 --- a/parachain/runtime/kintsugi/src/weights/redeem.rs +++ b/parachain/runtime/kintsugi/src/weights/redeem.rs @@ -2,31 +2,31 @@ //! Autogenerated weights for redeem //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-08-29, STEPS: `2`, REPEAT: `1`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-kcxvd`, CPU: `AMD EPYC 7502P 32-Core Processor` +//! HOSTNAME: `Nakuls-MacBook-Pro.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 // Executed Command: -// target/release/interbtc-parachain +// ./target/release/interbtc-parachain // benchmark // pallet // --pallet -// * +// redeem // --extrinsic // * -// --chain -// kintsugi-dev // --execution=wasm // --wasm-execution=compiled // --steps -// 50 +// 2 // --repeat -// 10 -// --output -// parachain/runtime/kintsugi/src/weights/ +// 1 // --template // .deploy/runtime-weight-template.hbs +// --chain +// kintsugi-dev +// --output +// generated_weight_kintsugi.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -40,6 +40,8 @@ pub struct WeightInfo(PhantomData); impl redeem::WeightInfo for WeightInfo { + /// Storage: VaultRegistry Vaults (r:1 w:1) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:2 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Fee RedeemFee (r:1 w:0) @@ -48,8 +50,6 @@ impl redeem::WeightInfo for WeightInfo { /// Proof: Redeem RedeemTransactionSize (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:2 w:0) /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) /// Storage: Security Nonce (r:1 w:1) @@ -91,13 +91,13 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Redeem RedeemRequests (r:0 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) fn request_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `3189` + // Measured: `3161` // Estimated: `6260` - // Minimum execution time: 311_614_000 picoseconds. - Weight::from_parts(319_349_000, 6260) + // Minimum execution time: 270_000_000 picoseconds. + Weight::from_parts(270_000_000, 6260) .saturating_add(T::DbWeight::get().reads(28_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -127,15 +127,15 @@ impl redeem::WeightInfo for WeightInfo { /// Proof: Loans AccountDeposits (max_values: None, max_size: Some(91), added: 2566, mode: MaxEncodedLen) fn liquidation_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `2173` + // Measured: `2193` // Estimated: `8760` - // Minimum execution time: 287_687_000 picoseconds. - Weight::from_parts(292_145_000, 8760) + // Minimum execution time: 257_000_000 picoseconds. + Weight::from_parts(257_000_000, 8760) .saturating_add(T::DbWeight::get().reads(16_u64)) .saturating_add(T::DbWeight::get().writes(11_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) /// Storage: BTCRelay BestBlockHeight (r:1 w:0) @@ -155,30 +155,28 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// The range of component `h` is `[2, 10]`. /// The range of component `i` is `[1, 10]`. /// The range of component `o` is `[2, 3]`. /// The range of component `b` is `[541, 2048]`. - fn execute_redeem (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + fn execute_redeem (h: u32, _i: u32, o: u32, b: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2295 + o * (1 ±0)` - // Estimated: `3725` - // Minimum execution time: 184_800_000 picoseconds. - Weight::from_parts(149_034_719, 3725) - // Standard Error: 137_585 - .saturating_add(Weight::from_parts(3_833_551, 0).saturating_mul(h.into())) - // Standard Error: 124_035 - .saturating_add(Weight::from_parts(1_176_171, 0).saturating_mul(i.into())) - // Standard Error: 751_913 - .saturating_add(Weight::from_parts(1_964_806, 0).saturating_mul(o.into())) - // Standard Error: 757 - .saturating_add(Weight::from_parts(5_490, 0).saturating_mul(b.into())) + // Measured: `2268 + o * (1 ±0)` + // Estimated: `3743` + // Minimum execution time: 176_000_000 picoseconds. + Weight::from_parts(151_584_172, 3743) + // Standard Error: 108_253 + .saturating_add(Weight::from_parts(2_562_500, 0).saturating_mul(h.into())) + // Standard Error: 866_025 + .saturating_add(Weight::from_parts(500_000, 0).saturating_mul(o.into())) + // Standard Error: 574 + .saturating_add(Weight::from_parts(8_958, 0).saturating_mul(b.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -186,7 +184,7 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -267,15 +265,15 @@ impl redeem::WeightInfo for WeightInfo { /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn cancel_redeem_reimburse () -> Weight { // Proof Size summary in bytes: - // Measured: `5430` + // Measured: `5403` // Estimated: `11350` - // Minimum execution time: 850_042_000 picoseconds. - Weight::from_parts(865_223_000, 11350) + // Minimum execution time: 782_000_000 picoseconds. + Weight::from_parts(782_000_000, 11350) .saturating_add(T::DbWeight::get().reads(59_u64)) .saturating_add(T::DbWeight::get().writes(29_u64)) } /// Storage: Redeem RedeemRequests (r:1 w:1) - /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(245), added: 2720, mode: MaxEncodedLen) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) /// Storage: Redeem RedeemPeriod (r:1 w:0) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: Security ActiveBlockCount (r:1 w:0) @@ -283,7 +281,7 @@ impl redeem::WeightInfo for WeightInfo { /// Storage: BTCRelay BestBlockHeight (r:1 w:0) /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Loans UnderlyingAssetId (r:1 w:0) /// Proof: Loans UnderlyingAssetId (max_values: None, max_size: Some(38), added: 2513, mode: MaxEncodedLen) /// Storage: Oracle Aggregate (r:1 w:0) @@ -364,36 +362,185 @@ impl redeem::WeightInfo for WeightInfo { /// Proof: VaultRegistry PunishmentDelay (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn cancel_redeem_retry () -> Weight { // Proof Size summary in bytes: - // Measured: `5430` + // Measured: `5403` // Estimated: `11350` - // Minimum execution time: 773_779_000 picoseconds. - Weight::from_parts(789_120_000, 11350) + // Minimum execution time: 706_000_000 picoseconds. + Weight::from_parts(706_000_000, 11350) .saturating_add(T::DbWeight::get().reads(58_u64)) .saturating_add(T::DbWeight::get().writes(28_u64)) } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: Fee PunishmentFee (r:1 w:0) + /// Proof: Fee PunishmentFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:1 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) + /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultCapacity Stake (r:1 w:0) + /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardPerToken (r:2 w:0) + /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) + /// Storage: VaultCapacity RewardTally (r:2 w:2) + /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultCapacity TotalRewards (r:2 w:2) + /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: VaultRewards Stake (r:1 w:0) + /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardPerToken (r:2 w:0) + /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) + /// Storage: VaultRewards RewardTally (r:2 w:2) + /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalRewards (r:2 w:2) + /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + /// Storage: Fee Commission (r:1 w:0) + /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) + /// Storage: VaultStaking RewardPerToken (r:2 w:2) + /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalStake (r:1 w:0) + /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: VaultRewards TotalStake (r:1 w:0) + /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) + fn cancel_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `4404` + // Estimated: `6364` + // Minimum execution time: 394_000_000 picoseconds. + Weight::from_parts(394_000_000, 6364) + .saturating_add(T::DbWeight::get().reads(33_u64)) + .saturating_add(T::DbWeight::get().writes(15_u64)) + } /// Storage: Redeem RedeemPeriod (r:0 w:1) /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn set_redeem_period () -> Weight { // Proof Size summary in bytes: // Measured: `0` // Estimated: `0` - // Minimum execution time: 18_106_000 picoseconds. - Weight::from_parts(18_667_000, 0) + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_000_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) /// Storage: Tokens Accounts (r:1 w:1) /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) /// Storage: Tokens TotalIssuance (r:1 w:1) /// Proof: Tokens TotalIssuance (max_values: None, max_size: Some(35), added: 2510, mode: MaxEncodedLen) fn self_redeem () -> Weight { // Proof Size summary in bytes: - // Measured: `1427` - // Estimated: `3725` - // Minimum execution time: 150_121_000 picoseconds. - Weight::from_parts(151_013_000, 3725) + // Measured: `1399` + // Estimated: `3677` + // Minimum execution time: 116_000_000 picoseconds. + Weight::from_parts(116_000_000, 3677) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: BTCRelay StartBlockHeight (r:1 w:0) + /// Proof: BTCRelay StartBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueBtcDustValue (r:1 w:0) + /// Proof: Issue IssueBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) + /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Oracle Aggregate (r:1 w:0) + /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) + /// Storage: VaultStaking Nonce (r:2 w:0) + /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) + /// Storage: VaultStaking TotalCurrentStake (r:2 w:0) + /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) + /// Storage: Security Nonce (r:1 w:1) + /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: System ParentHash (r:1 w:0) + /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) + /// Storage: VaultRegistry VaultBitcoinPublicKey (r:1 w:0) + /// Proof: VaultRegistry VaultBitcoinPublicKey (max_values: None, max_size: Some(81), added: 2556, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssuePeriod (r:1 w:0) + /// Proof: Issue IssuePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Fee RedeemFee (r:1 w:0) + /// Proof: Fee RedeemFee (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: Redeem RedeemBtcDustValue (r:1 w:0) + /// Proof: Redeem RedeemBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) + /// Storage: VaultRegistry PremiumRedeemThreshold (r:1 w:0) + /// Proof: VaultRegistry PremiumRedeemThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) + /// Storage: Redeem RedeemPeriod (r:1 w:0) + /// Proof: Redeem RedeemPeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:0 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// Storage: Redeem RedeemRequests (r:0 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + fn request_replace () -> Weight { + // Proof Size summary in bytes: + // Measured: `2735` + // Estimated: `6364` + // Minimum execution time: 38_446_000_000 picoseconds. + Weight::from_parts(38_446_000_000, 6364) + .saturating_add(T::DbWeight::get().reads(21_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: Redeem RedeemRequests (r:1 w:1) + /// Proof: Redeem RedeemRequests (max_values: None, max_size: Some(278), added: 2753, mode: MaxEncodedLen) + /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) + /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) + /// Storage: BTCRelay BestBlockHeight (r:1 w:0) + /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay Chains (r:1 w:0) + /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) + /// Storage: BTCRelay BlockHeaders (r:1 w:0) + /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) + /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) + /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: Security ActiveBlockCount (r:1 w:0) + /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) + /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) + /// Storage: VaultRegistry Vaults (r:2 w:2) + /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(212), added: 2687, mode: MaxEncodedLen) + /// Storage: Issue IssueRequests (r:1 w:1) + /// Proof: Issue IssueRequests (max_values: None, max_size: Some(295), added: 2770, mode: MaxEncodedLen) + /// The range of component `h` is `[2, 10]`. + /// The range of component `i` is `[1, 10]`. + /// The range of component `o` is `[2, 3]`. + /// The range of component `b` is `[541, 2048]`. + fn execute_replace (h: u32, i: u32, o: u32, b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2310` + // Estimated: `6364` + // Minimum execution time: 178_000_000 picoseconds. + Weight::from_parts(108_702_702, 6364) + // Standard Error: 433_012 + .saturating_add(Weight::from_parts(3_875_000, 0).saturating_mul(h.into())) + // Standard Error: 384_900 + .saturating_add(Weight::from_parts(1_444_444, 0).saturating_mul(i.into())) + // Standard Error: 3_464_101 + .saturating_add(Weight::from_parts(8_000_000, 0).saturating_mul(o.into())) + // Standard Error: 2_298 + .saturating_add(Weight::from_parts(11_280, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } } \ No newline at end of file diff --git a/parachain/runtime/kintsugi/src/weights/replace.rs b/parachain/runtime/kintsugi/src/weights/replace.rs deleted file mode 100644 index f7e561380e..0000000000 --- a/parachain/runtime/kintsugi/src/weights/replace.rs +++ /dev/null @@ -1,315 +0,0 @@ - -//! Autogenerated weights for replace -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-07, STEPS: `50`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `interlay-rust-runner-2mz2v-kcxvd`, CPU: `AMD EPYC 7502P 32-Core Processor` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kintsugi-dev"), DB CACHE: 1024 - -// Executed Command: -// target/release/interbtc-parachain -// benchmark -// pallet -// --pallet -// * -// --extrinsic -// * -// --chain -// kintsugi-dev -// --execution=wasm -// --wasm-execution=compiled -// --steps -// 50 -// --repeat -// 10 -// --output -// parachain/runtime/kintsugi/src/weights/ -// --template -// .deploy/runtime-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weights for replace using the Substrate node and recommended hardware. -pub struct WeightInfo(PhantomData); - -impl replace::WeightInfo for WeightInfo { - - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Nomination Vaults (r:1 w:0) - /// Proof: Nomination Vaults (max_values: None, max_size: Some(71), added: 2546, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: Fee ReplaceGriefingCollateral (r:1 w:0) - /// Proof: Fee ReplaceGriefingCollateral (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - fn request_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `2035` - // Estimated: `3725` - // Minimum execution time: 129_860_000 picoseconds. - Weight::from_parts(130_421_000, 3725) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: VaultRegistry Vaults (r:1 w:1) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - fn withdraw_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `701` - // Estimated: `3725` - // Minimum execution time: 56_633_000 picoseconds. - Weight::from_parts(57_295_000, 3725) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Replace ReplaceBtcDustValue (r:1 w:0) - /// Proof: Replace ReplaceBtcDustValue (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:1) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:1) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:1) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardTally (r:2 w:2) - /// Proof: VaultStaking RewardTally (max_values: None, max_size: Some(149), added: 2624, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:1) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardCurrencies (r:1 w:0) - /// Proof: VaultRewards RewardCurrencies (max_values: None, max_size: Some(50), added: 2525, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalStake (r:1 w:1) - /// Proof: VaultCapacity TotalStake (max_values: None, max_size: Some(32), added: 2507, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardCurrencies (r:1 w:0) - /// Proof: VaultCapacity RewardCurrencies (max_values: None, max_size: Some(39), added: 2514, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultRegistry SystemCollateralCeiling (r:1 w:0) - /// Proof: VaultRegistry SystemCollateralCeiling (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Security Nonce (r:1 w:1) - /// Proof: Security Nonce (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: System ParentHash (r:1 w:0) - /// Proof: System ParentHash (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Replace ReplaceRequests (r:0 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - fn accept_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `4380` - // Estimated: `6460` - // Minimum execution time: 617_937_000 picoseconds. - Weight::from_parts(628_408_000, 6460) - .saturating_add(T::DbWeight::get().reads(42_u64)) - .saturating_add(T::DbWeight::get().writes(26_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:1 w:1) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_pending_replace (h: u32, i: u32, o: u32, b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `3962` - // Estimated: `6460` - // Minimum execution time: 202_806_000 picoseconds. - Weight::from_parts(166_981_824, 6460) - // Standard Error: 107_822 - .saturating_add(Weight::from_parts(3_763_037, 0).saturating_mul(h.into())) - // Standard Error: 97_203 - .saturating_add(Weight::from_parts(1_018_940, 0).saturating_mul(i.into())) - // Standard Error: 589_259 - .saturating_add(Weight::from_parts(3_102_944, 0).saturating_mul(o.into())) - // Standard Error: 593 - .saturating_add(Weight::from_parts(6_156, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: BTCRelay DisableInclusionCheck (r:1 w:0) - /// Proof: BTCRelay DisableInclusionCheck (max_values: Some(1), max_size: Some(1), added: 496, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay Chains (r:1 w:0) - /// Proof: BTCRelay Chains (max_values: None, max_size: Some(24), added: 2499, mode: MaxEncodedLen) - /// Storage: BTCRelay BlockHeaders (r:1 w:0) - /// Proof: BTCRelay BlockHeaders (max_values: None, max_size: Some(200), added: 2675, mode: MaxEncodedLen) - /// Storage: BTCRelay StableBitcoinConfirmations (r:1 w:0) - /// Proof: BTCRelay StableBitcoinConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay StableParachainConfirmations (r:1 w:0) - /// Proof: BTCRelay StableParachainConfirmations (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// The range of component `h` is `[2, 10]`. - /// The range of component `i` is `[1, 10]`. - /// The range of component `o` is `[2, 3]`. - /// The range of component `b` is `[541, 2048]`. - fn execute_cancelled_replace (h: u32, i: u32, o: u32, b: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `4121` - // Estimated: `6460` - // Minimum execution time: 248_939_000 picoseconds. - Weight::from_parts(198_920_588, 6460) - // Standard Error: 137_449 - .saturating_add(Weight::from_parts(4_042_981, 0).saturating_mul(h.into())) - // Standard Error: 123_913 - .saturating_add(Weight::from_parts(1_585_107, 0).saturating_mul(i.into())) - // Standard Error: 751_172 - .saturating_add(Weight::from_parts(5_026_953, 0).saturating_mul(o.into())) - // Standard Error: 756 - .saturating_add(Weight::from_parts(6_827, 0).saturating_mul(b.into())) - .saturating_add(T::DbWeight::get().reads(14_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: Replace ReplaceRequests (r:1 w:1) - /// Proof: Replace ReplaceRequests (max_values: None, max_size: Some(250), added: 2725, mode: MaxEncodedLen) - /// Storage: Replace ReplacePeriod (r:1 w:0) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: Security ActiveBlockCount (r:1 w:0) - /// Proof: Security ActiveBlockCount (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: BTCRelay BestBlockHeight (r:1 w:0) - /// Proof: BTCRelay BestBlockHeight (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - /// Storage: VaultRegistry Vaults (r:2 w:2) - /// Proof: VaultRegistry Vaults (max_values: None, max_size: Some(260), added: 2735, mode: MaxEncodedLen) - /// Storage: Tokens Accounts (r:2 w:2) - /// Proof: Tokens Accounts (max_values: None, max_size: Some(115), added: 2590, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:0) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - /// Storage: VaultStaking Nonce (r:1 w:0) - /// Proof: VaultStaking Nonce (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalCurrentStake (r:1 w:0) - /// Proof: VaultStaking TotalCurrentStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRegistry MinimumCollateralVault (r:1 w:0) - /// Proof: VaultRegistry MinimumCollateralVault (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRegistry SecureCollateralThreshold (r:1 w:0) - /// Proof: VaultRegistry SecureCollateralThreshold (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: Oracle Aggregate (r:1 w:0) - /// Proof: Oracle Aggregate (max_values: None, max_size: Some(44), added: 2519, mode: MaxEncodedLen) - /// Storage: VaultRegistry TotalUserVaultCollateral (r:1 w:1) - /// Proof: VaultRegistry TotalUserVaultCollateral (max_values: None, max_size: Some(54), added: 2529, mode: MaxEncodedLen) - /// Storage: VaultCapacity Stake (r:1 w:0) - /// Proof: VaultCapacity Stake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardPerToken (r:2 w:0) - /// Proof: VaultCapacity RewardPerToken (max_values: None, max_size: Some(59), added: 2534, mode: MaxEncodedLen) - /// Storage: VaultCapacity RewardTally (r:2 w:2) - /// Proof: VaultCapacity RewardTally (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultCapacity TotalRewards (r:2 w:2) - /// Proof: VaultCapacity TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: VaultRewards Stake (r:1 w:0) - /// Proof: VaultRewards Stake (max_values: None, max_size: Some(97), added: 2572, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardPerToken (r:2 w:0) - /// Proof: VaultRewards RewardPerToken (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen) - /// Storage: VaultRewards RewardTally (r:2 w:2) - /// Proof: VaultRewards RewardTally (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalRewards (r:2 w:2) - /// Proof: VaultRewards TotalRewards (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - /// Storage: Fee Commission (r:1 w:0) - /// Proof: Fee Commission (max_values: None, max_size: Some(86), added: 2561, mode: MaxEncodedLen) - /// Storage: VaultStaking RewardPerToken (r:2 w:2) - /// Proof: VaultStaking RewardPerToken (max_values: None, max_size: Some(117), added: 2592, mode: MaxEncodedLen) - /// Storage: VaultStaking Stake (r:1 w:1) - /// Proof: VaultStaking Stake (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashPerToken (r:1 w:0) - /// Proof: VaultStaking SlashPerToken (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultStaking SlashTally (r:1 w:1) - /// Proof: VaultStaking SlashTally (max_values: None, max_size: Some(138), added: 2613, mode: MaxEncodedLen) - /// Storage: VaultStaking TotalStake (r:1 w:1) - /// Proof: VaultStaking TotalStake (max_values: None, max_size: Some(106), added: 2581, mode: MaxEncodedLen) - /// Storage: VaultRewards TotalStake (r:1 w:0) - /// Proof: VaultRewards TotalStake (max_values: None, max_size: Some(43), added: 2518, mode: MaxEncodedLen) - fn cancel_replace () -> Weight { - // Proof Size summary in bytes: - // Measured: `4818` - // Estimated: `6460` - // Minimum execution time: 504_550_000 picoseconds. - Weight::from_parts(506_845_000, 6460) - .saturating_add(T::DbWeight::get().reads(37_u64)) - .saturating_add(T::DbWeight::get().writes(19_u64)) - } - /// Storage: Replace ReplacePeriod (r:0 w:1) - /// Proof: Replace ReplacePeriod (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - fn set_replace_period () -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 18_356_000 picoseconds. - Weight::from_parts(18_557_000, 0) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} \ No newline at end of file diff --git a/parachain/runtime/kintsugi/src/xcm_config.rs b/parachain/runtime/kintsugi/src/xcm_config.rs index b625e7c8e6..4e102a741a 100644 --- a/parachain/runtime/kintsugi/src/xcm_config.rs +++ b/parachain/runtime/kintsugi/src/xcm_config.rs @@ -174,7 +174,7 @@ impl Contains for SafeCallFilter { // these calls can recurse - disallow false } - RuntimeCall::Issue(..) | RuntimeCall::Replace(..) | RuntimeCall::Redeem(..) | RuntimeCall::BTCRelay(..) => { + RuntimeCall::Issue(..) | RuntimeCall::Redeem(..) | RuntimeCall::BTCRelay(..) => { // disallow anything to do with btc transactions since btc tx may be unbounded false } diff --git a/parachain/runtime/runtime-tests/Cargo.toml b/parachain/runtime/runtime-tests/Cargo.toml index c03780f265..cb1c249eaa 100644 --- a/parachain/runtime/runtime-tests/Cargo.toml +++ b/parachain/runtime/runtime-tests/Cargo.toml @@ -101,7 +101,6 @@ oracle = { path = "../../../crates/oracle", features = ["testing-utils"] } fee = { path = "../../../crates/fee" } issue = { path = "../../../crates/issue" } redeem = { path = "../../../crates/redeem" } -replace = { path = "../../../crates/replace" } nomination = { path = "../../../crates/nomination" } reward = { path = "../../../crates/reward" } staking = { path = "../../../crates/staking", features = ["integration-tests"] } @@ -130,7 +129,6 @@ oracle-rpc-runtime-api = { path = "../../../crates/oracle/rpc/runtime-api" } vault-registry-rpc-runtime-api = { path = "../../../crates/vault-registry/rpc/runtime-api" } issue-rpc-runtime-api = { path = "../../../crates/issue/rpc/runtime-api" } redeem-rpc-runtime-api = { path = "../../../crates/redeem/rpc/runtime-api" } -replace-rpc-runtime-api = { path = "../../../crates/replace/rpc/runtime-api" } reward-rpc-runtime-api = { path = "../../../crates/reward/rpc/runtime-api" } # Orml dependencies @@ -178,7 +176,6 @@ runtime-benchmarks = [ "oracle/runtime-benchmarks", "issue/runtime-benchmarks", "redeem/runtime-benchmarks", - "replace/runtime-benchmarks", "vault-registry/runtime-benchmarks", "fee/runtime-benchmarks", "security/runtime-benchmarks", diff --git a/parachain/runtime/runtime-tests/src/parachain/fee_pool.rs b/parachain/runtime/runtime-tests/src/parachain/fee_pool.rs index a6c09961c7..4dfb63db32 100644 --- a/parachain/runtime/runtime-tests/src/parachain/fee_pool.rs +++ b/parachain/runtime/runtime-tests/src/parachain/fee_pool.rs @@ -558,21 +558,7 @@ impl ConcreteAction { ConcreteAction::FailRedeem { vault_id, amount } => { expire_bans(); - let free_balance_before = CurrencySource::FreeBalance(vault_id.account_id.clone()) - .current_balance(DEFAULT_GRIEFING_CURRENCY) - .unwrap(); let redeem_id = setup_cancelable_redeem(USER, &vault_id, *amount); - let free_balance_after = CurrencySource::FreeBalance(vault_id.account_id.clone()) - .current_balance(DEFAULT_GRIEFING_CURRENCY) - .unwrap(); - - VaultRegistryPallet::transfer_funds( - CurrencySource::FreeBalance(vault_id.account_id.clone()), - CurrencySource::AvailableReplaceCollateral(vault_id.clone()), - &(free_balance_after - free_balance_before), - ) - .unwrap(); - let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); let amount_without_fee_collateral = redeem.amount_without_fee_as_collateral(vault_id.collateral_currency()); diff --git a/parachain/runtime/runtime-tests/src/parachain/issue.rs b/parachain/runtime/runtime-tests/src/parachain/issue.rs index 8e32f60bff..f08afa49af 100644 --- a/parachain/runtime/runtime-tests/src/parachain/issue.rs +++ b/parachain/runtime/runtime-tests/src/parachain/issue.rs @@ -146,6 +146,7 @@ mod expiry_test { } mod request_issue_tests { + use primitives::AccountOrVault; use sp_runtime::traits::CheckedMul; use super::{assert_eq, *}; @@ -254,8 +255,7 @@ mod request_issue_tests { // give the vault a lot of griefing collateral, to check that this isn't available for backing new tokens let vault_id = vault_id; - let mut vault_data = CoreVaultData::vault(vault_id.clone()); - vault_data.griefing_collateral += griefing(1000000); + let vault_data = CoreVaultData::vault(vault_id.clone()); CoreVaultData::force_to(&vault_id, vault_data); assert_noop!( @@ -327,8 +327,7 @@ mod request_issue_tests { // give the vault a lot of griefing collateral, to check that this isn't available for backing new tokens let vault_id = vault_id; - let mut vault_data = CoreVaultData::vault(vault_id.clone()); - vault_data.griefing_collateral += griefing(1000000); + let vault_data = CoreVaultData::vault(vault_id.clone()); CoreVaultData::force_to(&vault_id, vault_data); assert_noop!( @@ -418,7 +417,7 @@ mod request_issue_tests { griefing_currency: DEFAULT_GRIEFING_CURRENCY, amount: (amount_btc - expected_fee).amount(), fee: expected_fee.amount(), - requester: account_of(USER), + requester: AccountOrVault::Account(account_of(USER)), btc_address: expected_btc_address, btc_public_key: expected_public_key, btc_height: expected_height, @@ -901,7 +900,7 @@ mod execute_cancelled_issue_tests { ExecuteIssueBuilder::new(issue_id) .with_amount(sent_amount) - .with_submitter(issue.requester.clone(), None) + .with_submitter(issue.requester.get_account().clone(), None) .execute() .unwrap(); diff --git a/parachain/runtime/runtime-tests/src/parachain/nomination.rs b/parachain/runtime/runtime-tests/src/parachain/nomination.rs index 28b40fcbfc..a93f3808b3 100644 --- a/parachain/runtime/runtime-tests/src/parachain/nomination.rs +++ b/parachain/runtime/runtime-tests/src/parachain/nomination.rs @@ -445,29 +445,6 @@ fn integration_test_nominated_collateral_cannot_exceed_nomination_limit() { fn integration_test_nominated_collateral_prevents_replace_requests() { test_with_nomination_enabled_and_vault_opted_in(|vault_id| { assert_nominate_collateral(&vault_id, account_of(USER), default_nomination(&vault_id)); - assert_noop!( - RuntimeCall::Replace(ReplaceCall::request_replace { - currency_pair: vault_id.currencies.clone(), - amount: 0, - }) - .dispatch(origin_of(vault_id.account_id.clone())), - ReplaceError::VaultHasEnabledNomination - ); - }); -} - -#[test] -fn integration_test_vaults_with_zero_nomination_cannot_request_replacement() { - test_with_nomination_enabled_and_vault_opted_in(|vault_id| { - let amount = DEFAULT_VAULT_ISSUED - DEFAULT_VAULT_TO_BE_REDEEMED - DEFAULT_VAULT_TO_BE_REPLACED; - assert_noop!( - RuntimeCall::Replace(ReplaceCall::request_replace { - currency_pair: vault_id.currencies.clone(), - amount: amount.amount(), - }) - .dispatch(origin_of(vault_id.account_id.clone())), - ReplaceError::VaultHasEnabledNomination - ); }); } diff --git a/parachain/runtime/runtime-tests/src/parachain/redeem.rs b/parachain/runtime/runtime-tests/src/parachain/redeem.rs index d6527cf1dc..7fe7a1af7f 100644 --- a/parachain/runtime/runtime-tests/src/parachain/redeem.rs +++ b/parachain/runtime/runtime-tests/src/parachain/redeem.rs @@ -44,20 +44,6 @@ fn test_with(execute: impl Fn(VaultId) -> R) { test_with(LendToken(1), Token(IBTC), None); } -/// to-be-replaced & replace_collateral are decreased in request_redeem -fn consume_to_be_replaced(vault: &mut CoreVaultData, amount_btc: Amount) { - let to_be_replaced_decrease = amount_btc.min(&vault.to_be_replaced).unwrap(); - let released_replace_collateral = griefing( - (vault.replace_collateral.amount() * to_be_replaced_decrease.amount()) / vault.to_be_replaced.amount(), - ); - - vault.replace_collateral -= released_replace_collateral; - vault.griefing_collateral -= released_replace_collateral; - *vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += released_replace_collateral; - - vault.to_be_replaced -= to_be_replaced_decrease; -} - mod spec_based_tests { use primitives::VaultCurrencyPair; @@ -116,7 +102,6 @@ mod spec_based_tests { redeem.amount_btc() + redeem.transfer_fee_btc() + redeem.fee(); (*user.balances.get_mut(&vault_id.wrapped_currency()).unwrap()).locked += redeem.amount_btc() + redeem.transfer_fee_btc() + redeem.fee(); - consume_to_be_replaced(vault, redeem.amount_btc()); }) ); }); @@ -643,7 +628,7 @@ mod spec_based_tests { test_with(|vault_id| { set_redeem_period(1000); let redeem_id = request_redeem(&vault_id); - mine_blocks(12); + mine_blocks(100); SecurityPallet::set_active_block_number(1100); assert_noop!( RuntimeCall::Redeem(RedeemCall::cancel_redeem { @@ -871,8 +856,6 @@ mod spec_based_tests { to_be_issued: vault_id.wrapped(0), to_be_redeemed: consumed_issued_tokens * 4, backing_collateral: collateral_vault, - to_be_replaced: vault_id.wrapped(0), - replace_collateral: griefing(0), ..default_vault_state(&vault_id) }, ); @@ -938,8 +921,6 @@ mod spec_based_tests { to_be_issued: vault_id.wrapped(0), to_be_redeemed: consumed_issued_tokens * 4, backing_collateral: collateral_vault, - to_be_replaced: vault_id.wrapped(0), - replace_collateral: griefing(0), ..default_vault_state(&vault_id) }, ); @@ -1163,7 +1144,6 @@ fn integration_test_redeem_execute_succeeds() { vault.issued -= redeem.amount_btc() + redeem.transfer_fee_btc(); (*user.balances.get_mut(&vault_id.wrapped_currency()).unwrap()).free -= issued_tokens; *fee_pool.rewards_for(&vault_id) += redeem.fee(); - consume_to_be_replaced(vault, redeem.amount_btc() + redeem.transfer_fee_btc()); }) ); }); @@ -1247,7 +1227,6 @@ fn integration_test_premium_redeem_wrapped_execute() { // premium is moved from vault to user vault.backing_collateral -= redeem.premium().unwrap(); (*user.balances.get_mut(¤cy_id).unwrap()).free += redeem.premium().unwrap(); - consume_to_be_replaced(vault, burned_amount); }) ); @@ -1451,8 +1430,6 @@ fn integration_test_redeem_wrapped_cancel_reimburse_sufficient_collateral_for_wr (*user.balances.get_mut(&vault_id.wrapped_currency()).unwrap()).free -= amount_btc; *fee_pool.rewards_for(&vault_id) += redeem.fee(); - - consume_to_be_replaced(vault, redeem.amount_btc() + redeem.transfer_fee_btc()); }) ); }); @@ -1504,8 +1481,6 @@ fn integration_test_redeem_wrapped_cancel_reimburse_insufficient_collateral_for_ (*user.balances.get_mut(&vault_id.wrapped_currency()).unwrap()).free -= amount_btc; *fee_pool.rewards_for(&vault_id) += redeem.fee(); - - consume_to_be_replaced(vault, redeem.amount_btc() + redeem.transfer_fee_btc()); }) ); @@ -1563,8 +1538,6 @@ fn integration_test_redeem_wrapped_cancel_no_reimburse() { (*user.balances.get_mut(¤cy_id).unwrap()).free += punishment_fee; vault.backing_collateral -= punishment_fee; - - consume_to_be_replaced(vault, redeem.amount_btc() + redeem.transfer_fee_btc()); }) ); }); @@ -1590,8 +1563,6 @@ fn integration_test_liquidation_redeem_with_cancel_redeem() { to_be_issued: vault_id.wrapped(0), to_be_redeemed: consumed_issued_tokens, backing_collateral: collateral_vault, - to_be_replaced: vault_id.wrapped(0), - replace_collateral: griefing(0), ..default_vault_state(&vault_id) }, ); @@ -1693,8 +1664,6 @@ fn integration_test_redeem_wrapped_cancel_liquidated_no_reimburse() { to_be_issued: vault_id.wrapped(0), to_be_redeemed: consumed_issued_tokens * 4, backing_collateral: collateral_vault, - to_be_replaced: vault_id.wrapped(0), - replace_collateral: griefing(0), ..default_vault_state(&vault_id) }, ); @@ -1755,8 +1724,6 @@ fn integration_test_redeem_wrapped_cancel_liquidated_reimburse() { to_be_issued: vault_id.wrapped(0), to_be_redeemed: consumed_issued_tokens * 4, backing_collateral: collateral_vault, - to_be_replaced: vault_id.wrapped(0), - replace_collateral: griefing(0), ..default_vault_state(&vault_id) }, ); @@ -1819,8 +1786,6 @@ fn integration_test_redeem_wrapped_execute_liquidated() { to_be_issued: vault_id.wrapped(0), to_be_redeemed: consumed_issued_tokens * 4, backing_collateral: collateral_vault, - to_be_replaced: vault_id.wrapped(0), - replace_collateral: griefing(0), ..default_vault_state(&vault_id) }, ); @@ -2018,7 +1983,6 @@ mod self_redeem { vault.issued -= consumed_issued_tokens; (*vault.free_balance.get_mut(&vault_id.wrapped_currency()).unwrap()) -= issued_tokens; *fee_pool.rewards_for(&vault_id) += fee; - consume_to_be_replaced(vault, consumed_issued_tokens); }) ); }); @@ -2041,7 +2005,6 @@ mod self_redeem { ParachainState::get_default(&vault_id).with_changes(|_, vault, _, _| { vault.issued -= issued_tokens; (*vault.free_balance.get_mut(&vault_id.wrapped_currency()).unwrap()) -= issued_tokens; - consume_to_be_replaced(vault, issued_tokens); }) ); }); diff --git a/parachain/runtime/runtime-tests/src/parachain/replace.rs b/parachain/runtime/runtime-tests/src/parachain/replace.rs index 1ef849c1d0..35cb425b4f 100644 --- a/parachain/runtime/runtime-tests/src/parachain/replace.rs +++ b/parachain/runtime/runtime-tests/src/parachain/replace.rs @@ -1,14 +1,15 @@ use crate::{ - setup::{assert_eq, *}, - utils::{loans_utils::activate_lending_and_mint, replace_utils::*}, + setup::{assert_eq, issue_utils::assert_issue_request_event, redeem_utils::assert_redeem_request_event, *}, + utils::{loans_utils::activate_lending_and_mint, redeem_utils::get_punishment_fee}, }; use currency::Amount; +use issue::DefaultIssueRequest; +use redeem::DefaultRedeemRequest; use sp_core::H256; type IssueCall = issue::Call; pub type VaultRegistryError = vault_registry::Error; -pub type ReplaceError = replace::Error; const USER: [u8; 32] = ALICE; const OLD_VAULT: [u8; 32] = BOB; @@ -69,133 +70,110 @@ fn test_without_initialization(execute: impl Fn(CurrencyId) -> R) { ExtBuilder::build().execute_with(|| execute(Token(KSM))); } -pub fn withdraw_replace(old_vault_id: &VaultId, amount: Amount) -> DispatchResultWithPostInfo { - VaultRegistryPallet::collateral_integrity_check(); - - RuntimeCall::Replace(ReplaceCall::withdraw_replace { - currency_pair: old_vault_id.currencies.clone(), - amount: amount.amount(), - }) - .dispatch(origin_of(old_vault_id.account_id.clone())) -} - -pub fn assert_replace_request_event() { - let events = SystemPallet::events(); - let ids = events.iter().filter_map(|r| match r.event { - RuntimeEvent::Replace(ReplaceEvent::RequestReplace { .. }) => Some(()), - _ => None, - }); - assert_eq!(ids.count(), 1); -} - #[cfg(test)] -mod accept_replace_tests { +mod request_replace_tests { use super::{assert_eq, *}; + use crate::{setup::issue_utils::assert_issue_request_event, utils::redeem_utils::assert_redeem_request_event}; - fn assert_state_after_accept_replace_correct( + fn assert_state_after_request_replace_correct( old_vault_id: &VaultId, new_vault_id: &VaultId, - replace: &ReplaceRequest, + issue: &IssueRequest, + redeem: &RedeemRequest, ) { assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes( |old_vault, new_vault, _| { - *new_vault - .free_balance - .get_mut(&new_vault_id.collateral_currency()) - .unwrap() -= replace.collateral().unwrap(); - new_vault.backing_collateral += replace.collateral().unwrap(); - - old_vault.replace_collateral -= griefing( - (old_vault.replace_collateral.amount() * replace.amount) / old_vault.to_be_replaced.amount(), - ); - old_vault.to_be_replaced -= replace.amount(); - - old_vault.to_be_redeemed += replace.amount(); - new_vault.to_be_issued += replace.amount(); + *old_vault.free_balance.get_mut(&issue.griefing_currency).unwrap() -= + Amount::new(issue.griefing_collateral, issue.griefing_currency); + + old_vault.to_be_redeemed += redeem.amount_btc() - redeem.fee(); + new_vault.to_be_issued += redeem.amount_btc(); } ) ); } #[test] - fn integration_test_replace_accept_replace_at_capacity_succeeds() { + fn integration_test_replace_request_replace_at_capacity_succeeds() { test_with(|old_vault_id, new_vault_id| { - let accept_amount = new_vault_id.wrapped(DEFAULT_VAULT_TO_BE_REPLACED.amount()); - let new_vault_additional_collateral = Amount::new(10_000, new_vault_id.collateral_currency()); - - let (_, replace) = accept_replace( - &old_vault_id, - &new_vault_id, - accept_amount, - new_vault_additional_collateral, - Default::default(), - ) - .unwrap(); + let replace_amount = new_vault_id.wrapped(DEFAULT_VAULT_TO_BE_REPLACED.amount()); + assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: replace_amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone()))); + + let redeem_id = assert_redeem_request_event(); + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); - assert_eq!(replace.amount(), accept_amount); - assert_eq!(replace.collateral().unwrap(), new_vault_additional_collateral); - assert_eq!(replace.griefing_collateral(), DEFAULT_VAULT_REPLACE_COLLATERAL); + assert_eq!(redeem.amount_btc, replace_amount.amount()); + assert_eq!(redeem.issue_id.is_some(), true); - assert_state_after_accept_replace_correct(&old_vault_id, &new_vault_id, &replace); + let issue_id = assert_issue_request_event(); + let issue = IssuePallet::get_issue_request_from_id(&issue_id).unwrap(); + + assert_eq!(issue.griefing_collateral(), griefing(0)); + assert_state_after_request_replace_correct(&old_vault_id, &new_vault_id, &issue, &redeem); }); } #[test] - fn integration_test_replace_accept_replace_below_capacity_succeeds() { + fn integration_test_replace_request_replace_below_capacity_succeeds() { test_with(|old_vault_id, new_vault_id| { // accept only 25% - let accept_amount = DEFAULT_VAULT_TO_BE_REPLACED / 4; - let accept_amount = old_vault_id.wrapped(accept_amount.amount()); - let new_vault_additional_collateral = Amount::new(10_000, new_vault_id.collateral_currency()); + let replace_amount = DEFAULT_VAULT_TO_BE_REPLACED / 4; + let replace_amount = old_vault_id.wrapped(replace_amount.amount()); - let (_, replace) = accept_replace( - &old_vault_id, - &new_vault_id, - accept_amount, - new_vault_additional_collateral, - Default::default(), - ) - .unwrap(); + assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: replace_amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone()))); + + let redeem_id = assert_redeem_request_event(); + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + + assert_eq!(redeem.amount_btc, replace_amount.amount()); + assert_eq!(redeem.issue_id.is_some(), true); - assert_eq!(replace.amount(), accept_amount); - assert_eq!(replace.collateral().unwrap(), new_vault_additional_collateral); - assert_eq!(replace.griefing_collateral(), DEFAULT_VAULT_REPLACE_COLLATERAL / 4); + let issue_id = assert_issue_request_event(); + let issue = IssuePallet::get_issue_request_from_id(&issue_id).unwrap(); - assert_state_after_accept_replace_correct(&old_vault_id, &new_vault_id, &replace); + assert_eq!(issue.griefing_collateral(), griefing(0)); + assert_state_after_request_replace_correct(&old_vault_id, &new_vault_id, &issue, &redeem); }); } #[test] - fn integration_test_replace_accept_replace_above_capacity_succeeds() { + fn integration_test_request_replace_above_capacity_fails() { test_with(|old_vault_id, new_vault_id| { // try to accept 400% - let accept_amount = DEFAULT_VAULT_TO_BE_REPLACED * 4; - let accept_amount = old_vault_id.wrapped(accept_amount.amount()); - let new_vault_additional_collateral = Amount::new(10_000, new_vault_id.collateral_currency()); + let replace_amount = DEFAULT_VAULT_TO_BE_REPLACED * 4; + let replace_amount = old_vault_id.wrapped(replace_amount.amount()); - let (_, replace) = accept_replace( - &old_vault_id, - &new_vault_id, - accept_amount, - new_vault_additional_collateral, - Default::default(), - ) - .unwrap(); - - assert_eq!(replace.amount(), accept_amount / 4); - assert_eq!(replace.collateral().unwrap(), new_vault_additional_collateral / 4); - assert_eq!(replace.griefing_collateral(), DEFAULT_VAULT_REPLACE_COLLATERAL); - - assert_state_after_accept_replace_correct(&old_vault_id, &new_vault_id, &replace); + assert_err!( + RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: replace_amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone())), + VaultRegistryError::InsufficientTokensCommitted + ); }); } #[test] - fn integration_test_replace_accept_replace_by_vault_that_does_not_accept_issues_succeeds() { + fn integration_test_replace_request_replace_by_vault_that_does_not_accept_issues_succeeds() { test_with(|old_vault_id, new_vault_id| { assert_ok!(RuntimeCall::VaultRegistry(VaultRegistryCall::accept_new_issues { currency_pair: new_vault_id.currencies.clone(), @@ -203,75 +181,49 @@ mod accept_replace_tests { }) .dispatch(origin_of(new_vault_id.account_id.clone()))); - let (_, replace) = accept_replace( - &old_vault_id, - &new_vault_id, - old_vault_id.wrapped(1000), - griefing(1000), - Default::default(), - ) - .unwrap(); - - // Set `accept_new_issues` back to the default value so the parachain state check succeeds. - assert_ok!(RuntimeCall::VaultRegistry(VaultRegistryCall::accept_new_issues { - currency_pair: new_vault_id.currencies.clone(), - accept_new_issues: true - }) - .dispatch(origin_of(new_vault_id.account_id.clone()))); - - assert_state_after_accept_replace_correct(&old_vault_id, &new_vault_id, &replace); + assert_noop!( + RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: 1000, + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone())), + IssueError::VaultNotAcceptingNewIssues + ); }); } #[test] - fn integration_test_replace_accept_replace_below_dust_fails() { + fn integration_test_replace_request_replace_below_dust_fails() { test_with(|old_vault_id, new_vault_id| { // if the new_vault _asks_ for an amount below below DUST, it gets rejected assert_noop!( - accept_replace( - &old_vault_id, - &new_vault_id, - old_vault_id.wrapped(1), - griefing(10_000), - BtcAddress::P2PKH(H160([1; 20])) - ), - ReplaceError::AmountBelowDustAmount - ); - - // if the old_vault does not have sufficient to-be-replaced tokens, it gets rejected - CoreVaultData::force_to( - &old_vault_id, - CoreVaultData { - to_be_replaced: old_vault_id.wrapped(1), - ..default_vault_state(&old_vault_id) - }, - ); - assert_noop!( - accept_replace( - &old_vault_id, - &new_vault_id, - old_vault_id.wrapped(1), - griefing(10_000), - BtcAddress::P2PKH(H160([1; 20])) - ), - ReplaceError::AmountBelowDustAmount + RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: 1, + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone())), + IssueError::AmountBelowDustAmount ); }); } #[test] - fn integration_test_replace_accept_replace_self_fails() { + fn integration_test_replace_request_replace_self_fails() { test_with(|old_vault_id, _new_vault_id| { assert_noop!( - accept_replace( - &old_vault_id, - &old_vault_id, - DEFAULT_VAULT_TO_BE_REPLACED, - griefing(10_000), - BtcAddress::P2PKH(H160([1; 20])) - ), - ReplaceError::ReplaceSelfNotAllowed + RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: 10_000, + new_vault_id: old_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone())), + RedeemError::ReplaceSelfNotAllowed ); }); } @@ -292,366 +244,184 @@ mod accept_replace_tests { other_currency, ); CoreVaultData::force_to(&new_vault_id, default_vault_state(&new_vault_id)); - assert_noop!( - accept_replace( - &old_vault_id, - &new_vault_id, - old_vault_id.wrapped(10000), - griefing(10_000), - BtcAddress::P2PKH(H160([1; 20])) - ), - ReplaceError::InvalidWrappedCurrency - ); - }) - } -} - -mod request_replace_tests { - use super::{assert_eq, *}; - - #[test] - fn integration_test_replace_request_replace_at_capacity_succeeds() { - test_with(|old_vault_id, new_vault_id| { - let amount = DEFAULT_VAULT_ISSUED - DEFAULT_VAULT_TO_BE_REDEEMED - DEFAULT_VAULT_TO_BE_REPLACED; - let amount = old_vault_id.wrapped(amount.amount()); - let griefing_collateral = request_replace(&old_vault_id, amount); - // assert request event - assert_replace_request_event(); - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes(|old_vault, _, _| { - old_vault.to_be_replaced += amount; - old_vault.griefing_collateral += griefing_collateral; - old_vault.replace_collateral += griefing_collateral; - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() -= griefing_collateral; - }) - ); - }); - } - - #[test] - fn integration_test_replace_request_replace_above_capacity_succeeds() { - test_with(|old_vault_id, new_vault_id| { - let amount = (DEFAULT_VAULT_ISSUED - DEFAULT_VAULT_TO_BE_REDEEMED - DEFAULT_VAULT_TO_BE_REPLACED) * 2; - let amount = old_vault_id.wrapped(amount.amount()); - - let griefing_collateral = request_replace(&old_vault_id, amount); - // assert request event - assert_replace_request_event(); - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes(|old_vault, _, _| { - old_vault.to_be_replaced += amount / 2; - old_vault.griefing_collateral += griefing_collateral; - old_vault.replace_collateral += griefing_collateral; - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() -= griefing_collateral; - }) - ); - }); - } - - #[test] - fn integration_test_replace_request_replace_below_capacity_succeeds() { - test_with(|old_vault_id, new_vault_id| { - let amount = (DEFAULT_VAULT_ISSUED - DEFAULT_VAULT_TO_BE_REDEEMED - DEFAULT_VAULT_TO_BE_REPLACED) / 2; - let amount = old_vault_id.wrapped(amount.amount()); - let griefing_collateral = request_replace(&old_vault_id, amount); - - // assert request event - let _request_id = assert_replace_request_event(); - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes(|old_vault, _, _| { - old_vault.to_be_replaced += amount; - old_vault.griefing_collateral += griefing_collateral; - old_vault.replace_collateral += griefing_collateral; - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() -= griefing_collateral; - }) - ); - }); - } - - #[test] - fn integration_test_replace_request_replace_with_zero_btc_fails() { - test_with(|old_vault_id, _new_vault_id| { assert_noop!( - RuntimeCall::Replace(ReplaceCall::request_replace { + RuntimeCall::Redeem(RedeemCall::request_replace { currency_pair: old_vault_id.currencies.clone(), - amount: 0, + amount: 10000, + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY }) .dispatch(origin_of(old_vault_id.account_id.clone())), - ReplaceError::ReplaceAmountZero - ); - }); - } - - #[test] - fn integration_test_replace_request_replace_with_insufficient_collateral() { - test_with(|old_vault_id, new_vault_id| { - let amount = old_vault_id.wrapped(1000); - - CoreVaultData::force_to( - &old_vault_id, - CoreVaultData { - to_be_replaced: old_vault_id.wrapped(5_000), - replace_collateral: griefing(1), - ..default_vault_state(&old_vault_id) - }, - ); - - let pre_request_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - - // check that by locking sufficient collateral we can recover - let griefing_collateral = request_replace(&old_vault_id, amount); - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - pre_request_state.with_changes(|old_vault, _, _| { - old_vault.to_be_replaced += amount; - old_vault.griefing_collateral += griefing_collateral; - old_vault.replace_collateral += griefing_collateral; - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() -= griefing_collateral; - }) - ); - }); - } -} - -mod withdraw_replace_tests { - use super::{assert_eq, *}; - - #[test] - fn integration_test_replace_withdraw_replace_at_capacity_succeeds() { - test_with(|old_vault_id, new_vault_id| { - let amount = DEFAULT_VAULT_TO_BE_REPLACED; - let amount = old_vault_id.wrapped(amount.amount()); - - assert_ok!(withdraw_replace(&old_vault_id, amount)); - - let released_collateral = DEFAULT_VAULT_REPLACE_COLLATERAL; - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes(|old_vault, _, _| { - old_vault.to_be_replaced -= amount; - - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += released_collateral; - old_vault.griefing_collateral -= released_collateral; - old_vault.replace_collateral -= released_collateral; - }) - ); - }); - } - - #[test] - fn integration_test_replace_withdraw_replace_below_capacity_succeeds() { - test_with(|old_vault_id, new_vault_id| { - // withdraw 25% - let amount = DEFAULT_VAULT_TO_BE_REPLACED / 4; - let amount = old_vault_id.wrapped(amount.amount()); - - assert_ok!(withdraw_replace(&old_vault_id, amount)); - - let released_collateral = DEFAULT_VAULT_REPLACE_COLLATERAL / 4; - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes(|old_vault, _, _| { - old_vault.to_be_replaced -= amount; - - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += released_collateral; - old_vault.griefing_collateral -= released_collateral; - old_vault.replace_collateral -= released_collateral; - }) - ); - }); - } - - #[test] - fn integration_test_replace_withdraw_replace_above_capacity_succeeds() { - test_with(|old_vault_id, new_vault_id| { - // withdraw 200% - should just be capped to 100% - let amount = DEFAULT_VAULT_TO_BE_REPLACED * 2; - let amount = old_vault_id.wrapped(amount.amount()); - - assert_ok!(withdraw_replace(&old_vault_id, amount)); - - let released_collateral = DEFAULT_VAULT_REPLACE_COLLATERAL; - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - ParachainTwoVaultState::get_default(&old_vault_id, &new_vault_id).with_changes(|old_vault, _, _| { - old_vault.to_be_replaced -= amount / 2; - - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += released_collateral; - old_vault.griefing_collateral -= released_collateral; - old_vault.replace_collateral -= released_collateral; - }) + RedeemError::InvalidWrappedCurrency ); - }); - } - #[test] - fn integration_test_replace_withdraw_replace_with_zero_to_be_replaced_tokens_fails() { - test_with(|old_vault_id, _new_vault_id| { - CoreVaultData::force_to( - &old_vault_id, - CoreVaultData { - to_be_replaced: old_vault_id.wrapped(0), - ..default_vault_state(&old_vault_id) - }, - ); - - assert_noop!( - withdraw_replace(&old_vault_id, old_vault_id.wrapped(1000)), - ReplaceError::NoPendingRequest - ); - }); + }) } } mod expiry_test { use super::{assert_eq, *}; + use crate::{setup::redeem_utils::assert_redeem_request_event, utils::issue_utils::assert_issue_request_event}; /// test replace created by accept - fn test_with(initial_period: u32, execute: impl Fn(H256)) { + fn test_with(initial_period: u32, execute: impl Fn((H256, H256))) { let amount_btc = wrapped(5_000); - let griefing_collateral = griefing(1000); super::test_with(|old_vault_id, new_vault_id| { set_replace_period(initial_period); - let (replace_id, _replace) = accept_replace( - &old_vault_id, - &new_vault_id, - amount_btc, - griefing_collateral, - BtcAddress::P2PKH(H160([1; 20])), - ) - .unwrap(); - execute(replace_id); + assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: amount_btc.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone()))); + let redeem_id = assert_redeem_request_event(); + let issue_id = assert_issue_request_event(); + + execute((redeem_id, issue_id)); }); } fn set_replace_period(period: u32) { - assert_ok!(RuntimeCall::Replace(ReplaceCall::set_replace_period { period }).dispatch(root())); + assert_ok!(RuntimeCall::Redeem(RedeemCall::set_redeem_period { period }).dispatch(root())); } - fn cancel_replace(replace_id: H256) -> DispatchResultWithPostInfo { - RuntimeCall::Replace(ReplaceCall::cancel_replace { replace_id: replace_id }) - .dispatch(origin_of(account_of(NEW_VAULT))) + fn cancel_replace(redeem_id: H256) -> DispatchResultWithPostInfo { + RuntimeCall::Redeem(RedeemCall::cancel_redeem { + redeem_id: redeem_id, + reimburse: true, + }) + .dispatch(origin_of(account_of(NEW_VAULT))) } #[test] fn integration_test_replace_expiry_only_parachain_blocks_expired() { - test_with(1000, |replace_id| { + test_with(1000, |(redeem_id, _issue_id)| { mine_blocks(1); SecurityPallet::set_active_block_number(1500); - assert_err!(cancel_replace(replace_id), ReplaceError::ReplacePeriodNotExpired); - assert_ok!(execute_replace(replace_id)); + assert_noop!(cancel_replace(redeem_id), RedeemError::TimeNotExpired); + assert_ok!(execute_replace(redeem_id)); }); } #[test] fn integration_test_replace_expiry_only_bitcoin_blocks_expired() { - test_with(1000, |replace_id| { + test_with(1000, |(redeem_id, _issue_id)| { mine_blocks(15); SecurityPallet::set_active_block_number(500); - assert_err!(cancel_replace(replace_id), ReplaceError::ReplacePeriodNotExpired); - assert_ok!(execute_replace(replace_id)); + assert_noop!(cancel_replace(redeem_id), RedeemError::TimeNotExpired); + assert_ok!(execute_replace(redeem_id)); }); } #[test] fn integration_test_replace_expiry_no_period_change_pre_expiry() { - test_with(1000, |replace_id| { + test_with(1000, |(redeem_id, _issue_id)| { mine_blocks(7); SecurityPallet::set_active_block_number(750); - assert_err!(cancel_replace(replace_id), ReplaceError::ReplacePeriodNotExpired); - assert_ok!(execute_replace(replace_id)); + assert_noop!(cancel_replace(redeem_id), RedeemError::TimeNotExpired); + assert_ok!(execute_replace(redeem_id)); }); } #[test] fn integration_test_replace_expiry_no_period_change_post_expiry() { // can still execute after expiry - test_with(1000, |replace_id| { + test_with(1000, |(redeem_id, _issue_id)| { mine_blocks(100); SecurityPallet::set_active_block_number(1100); - assert_ok!(execute_replace(replace_id)); + assert_ok!(execute_replace(redeem_id)); }); // but new-vault can also cancel.. whoever is first wins - test_with(1000, |replace_id| { + test_with(1000, |(redeem_id, _issue_id)| { mine_blocks(100); SecurityPallet::set_active_block_number(1100); - assert_ok!(cancel_replace(replace_id)); + assert_ok!(cancel_replace(redeem_id)); }); } #[test] fn integration_test_replace_expiry_with_period_decrease() { - test_with(2000, |replace_id| { + test_with(2000, |(redeem_id, _issue_id)| { mine_blocks(15); SecurityPallet::set_active_block_number(1100); set_replace_period(1000); // request still uses period = 200, so cancel fails and execute succeeds - assert_err!(cancel_replace(replace_id), ReplaceError::ReplacePeriodNotExpired); - assert_ok!(execute_replace(replace_id)); + assert_err!(cancel_replace(redeem_id), RedeemError::TimeNotExpired); + assert_ok!(execute_replace(redeem_id)); }); } #[test] fn integration_test_replace_expiry_with_period_increase() { - test_with(1000, |replace_id| { + test_with(1000, |(redeem_id, _issue_id)| { mine_blocks(15); SecurityPallet::set_active_block_number(1100); set_replace_period(2000); // request uses period = 200, so execute succeeds and cancel fails - assert_err!(cancel_replace(replace_id), ReplaceError::ReplacePeriodNotExpired); - assert_ok!(execute_replace(replace_id)); + assert_err!(cancel_replace(redeem_id), RedeemError::TimeNotExpired); + assert_ok!(execute_replace(redeem_id)); }); } } mod execute_replace_payment_limits { use super::{assert_eq, *}; + use crate::utils::redeem_utils::assert_redeem_request_event; #[test] fn integration_test_execute_replace_with_exact_amount_succeeds() { test_with(|old_vault_id, new_vault_id| { - let (replace_id, replace) = accept_replace( - &old_vault_id, - &new_vault_id, - old_vault_id.wrapped(1000000), - DEFAULT_GRIEFING_COLLATERAL, - Default::default(), - ) - .unwrap(); - assert_ok!(execute_replace_with_amount(replace_id, replace.amount())); + let replace_amount = old_vault_id.wrapped(10000); + + assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: replace_amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone()))); + let redeem_id = assert_redeem_request_event(); + + let replace = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + + assert_ok!(execute_replace_with_amount( + redeem_id, + Amount::new(replace.amount_btc, replace.vault.currencies.wrapped) + )); }); } + #[test] fn integration_test_execute_replace_with_overpayment_fails() { test_with(|old_vault_id, new_vault_id| { - let (replace_id, replace) = accept_replace( - &old_vault_id, - &new_vault_id, - old_vault_id.wrapped(1000000), - DEFAULT_GRIEFING_COLLATERAL, - Default::default(), - ) - .unwrap(); + let replace_amount = old_vault_id.wrapped(10000); + + assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: replace_amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone()))); + + let redeem_id = assert_redeem_request_event(); + + let replace = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + assert_err!( - execute_replace_with_amount(replace_id, replace.amount().with_amount(|x| x + 1)), + execute_replace_with_amount( + redeem_id, + Amount::new(replace.amount_btc, replace.vault.currencies.wrapped).with_amount(|x| x + 1) + ), BTCRelayError::InvalidPaymentAmount ); }); @@ -659,94 +429,128 @@ mod execute_replace_payment_limits { #[test] fn integration_test_execute_replace_with_underpayment_fails() { test_with(|old_vault_id, new_vault_id| { - let (replace_id, replace) = accept_replace( - &old_vault_id, - &new_vault_id, - old_vault_id.wrapped(1000000), - DEFAULT_GRIEFING_COLLATERAL, - Default::default(), - ) - .unwrap(); + let replace_amount = old_vault_id.wrapped(10000); + + assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: replace_amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone()))); + + let redeem_id = assert_redeem_request_event(); + + let replace = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + assert_err!( - execute_replace_with_amount(replace_id, replace.amount().with_amount(|x| x - 1)), + execute_replace_with_amount( + redeem_id, + Amount::new(replace.amount_btc, replace.vault.currencies.wrapped).with_amount(|x| x - 1) + ), BTCRelayError::InvalidPaymentAmount ); }); } } +fn setup_replace( + replace_amount: Amount, + old_vault_id: &VaultId, + new_vault_id: &VaultId, +) -> (H256, DefaultRedeemRequest, H256, DefaultIssueRequest) { + assert_ok!(RuntimeCall::Redeem(RedeemCall::request_replace { + currency_pair: old_vault_id.currencies.clone(), + amount: replace_amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY + }) + .dispatch(origin_of(old_vault_id.account_id.clone()))); + let redeem_id = assert_redeem_request_event(); + let redeem = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); + + let issue_id = assert_issue_request_event(); + let issue = IssuePallet::get_issue_request_from_id(&issue_id).unwrap(); + + (redeem_id, redeem, issue_id, issue) +} + #[test] fn integration_test_replace_cancel_replace() { test_with(|old_vault_id, new_vault_id| { - let (_, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); - + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, _, _, _) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); // set block height // new_vault cancels replacement mine_blocks(2); SecurityPallet::set_active_block_number(30); - assert_ok!( - RuntimeCall::Replace(ReplaceCall::cancel_replace { replace_id: replace_id }) - .dispatch(origin_of(new_vault_id.account_id.clone())) - ); + assert_ok!(RuntimeCall::Redeem(RedeemCall::cancel_redeem { + redeem_id: redeem_id, + reimburse: true, + }) + .dispatch(origin_of(new_vault_id.account_id.clone()))); }); } // liquidation tests -fn execute_replace(replace_id: H256) -> DispatchResultWithPostInfo { - let replace = ReplacePallet::get_open_or_cancelled_replace_request(&replace_id).unwrap(); - execute_replace_with_amount(replace_id, replace.amount()) +fn execute_replace(redeem_id: H256) -> DispatchResultWithPostInfo { + let replace = RedeemPallet::get_open_redeem_request_from_id(&redeem_id)?; + execute_replace_with_amount( + redeem_id, + Amount::new(replace.amount_btc, replace.vault.currencies.wrapped), + ) } -fn execute_replace_with_amount(replace_id: H256, amount: Amount) -> DispatchResultWithPostInfo { - let replace = ReplacePallet::get_open_or_cancelled_replace_request(&replace_id).unwrap(); +fn execute_replace_with_amount(redeem_id: H256, amount: Amount) -> DispatchResultWithPostInfo { + let replace = RedeemPallet::get_open_redeem_request_from_id(&redeem_id).unwrap(); // send the btc from the old_vault to the new_vault let (_tx_id, _tx_block_height, transaction) = generate_transaction_and_mine( Default::default(), vec![], vec![(replace.btc_address, amount)], - vec![replace_id], + vec![redeem_id], ); SecurityPallet::set_active_block_number(SecurityPallet::active_block_number() + CONFIRMATIONS); - RuntimeCall::Replace(ReplaceCall::execute_replace { - replace_id, + RuntimeCall::Redeem(RedeemCall::execute_redeem { + redeem_id, unchecked_transaction: transaction, }) .dispatch(origin_of(account_of(OLD_VAULT))) } -fn cancel_replace(replace_id: H256) { +fn cancel_replace(redeem_id: H256) { // set block height mine_blocks(2); SecurityPallet::set_active_block_number(30); - assert_ok!( - RuntimeCall::Replace(ReplaceCall::cancel_replace { replace_id: replace_id }) - .dispatch(origin_of(account_of(NEW_VAULT))) - ); + assert_ok!(RuntimeCall::Redeem(RedeemCall::cancel_redeem { + redeem_id: redeem_id, + reimburse: true, + }) + .dispatch(origin_of(account_of(NEW_VAULT)))); } #[test] fn integration_test_replace_execute_replace_success() { test_with(|old_vault_id, new_vault_id| { - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); + let replace_amount = new_vault_id.wrapped(10000); - let pre_execute_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); - assert_ok!(execute_replace(replace_id)); + let pre_execute_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); + assert_ok!(execute_replace(redeem_id)); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execute_state.with_changes(|old_vault, new_vault, _| { - new_vault.to_be_issued -= old_vault_id.wrapped(1000); - new_vault.issued += old_vault_id.wrapped(1000); - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); - old_vault.issued -= old_vault_id.wrapped(1000); + old_vault.issued -= replace_amount - redeem.fee; + old_vault.to_be_redeemed -= replace_amount - redeem.fee; - old_vault.griefing_collateral -= replace.griefing_collateral(); - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); + new_vault.issued += replace_amount; + new_vault.to_be_issued -= replace_amount; }) ); }); @@ -767,8 +571,9 @@ fn calculate_replace_collateral( #[test] fn integration_test_replace_execute_replace_old_vault_liquidated() { test_with(|old_vault_id, new_vault_id| { - let replace_tokens = old_vault_id.wrapped(1000); - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, replace_tokens); + let replace_amount = new_vault_id.wrapped(10000); + + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); let old = CoreVaultData::vault(old_vault_id.clone()); @@ -776,27 +581,31 @@ fn integration_test_replace_execute_replace_old_vault_liquidated() { let pre_execution_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - assert_ok!(execute_replace(replace_id)); + assert_ok!(execute_replace(redeem_id)); - let collateral_for_replace = - calculate_replace_collateral(&old, replace.amount(), old_vault_id.collateral_currency()); + let collateral_for_replace = calculate_replace_collateral( + &old, + redeem.amount_btc().checked_sub(&redeem.fee()).unwrap(), + old_vault_id.collateral_currency(), + ); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execution_state.with_changes(|old_vault, new_vault, liquidation_vault| { let liquidation_vault = liquidation_vault.with_currency(&old_vault_id.currencies); - liquidation_vault.issued -= old_vault_id.wrapped(1000); - liquidation_vault.to_be_redeemed -= old_vault_id.wrapped(1000); + liquidation_vault.issued -= replace_amount - redeem.fee; + liquidation_vault.to_be_redeemed -= replace_amount - redeem.fee; - new_vault.to_be_issued -= old_vault_id.wrapped(1000); - new_vault.issued += old_vault_id.wrapped(1000); + new_vault.to_be_issued -= replace_amount; + new_vault.issued += replace_amount; - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); + old_vault.to_be_redeemed -= replace_amount - redeem.fee; old_vault.liquidated_collateral -= collateral_for_replace; - old_vault.backing_collateral += collateral_for_replace; // TODO: probably should be free - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); - old_vault.griefing_collateral -= replace.griefing_collateral(); + *old_vault + .free_balance + .get_mut(&old_vault_id.collateral_currency()) + .unwrap() += collateral_for_replace; }) ); }); @@ -805,26 +614,26 @@ fn integration_test_replace_execute_replace_old_vault_liquidated() { #[test] fn integration_test_replace_execute_replace_new_vault_liquidated() { test_with(|old_vault_id, new_vault_id| { - let replace_tokens = old_vault_id.wrapped(1000); - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, replace_tokens); + let replace_amount = new_vault_id.wrapped(10000); + + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); liquidate_vault(&new_vault_id); + let pre_execution_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - assert_ok!(execute_replace(replace_id)); + assert_ok!(execute_replace(redeem_id)); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execution_state.with_changes(|old_vault, _new_vault, liquidation_vault| { - let new_liquidation_vault = liquidation_vault.with_currency(&new_vault_id.currencies); - new_liquidation_vault.issued += old_vault_id.wrapped(1000); - new_liquidation_vault.to_be_issued -= old_vault_id.wrapped(1000); + let liquidation_vault = liquidation_vault.with_currency(&new_vault_id.currencies); - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); - old_vault.issued -= old_vault_id.wrapped(1000); + liquidation_vault.issued += replace_amount; + liquidation_vault.to_be_issued -= replace_amount; - old_vault.griefing_collateral -= replace.griefing_collateral(); - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); + old_vault.to_be_redeemed -= replace_amount - redeem.fee; + old_vault.issued -= replace_amount - redeem.fee; }) ); }); @@ -833,8 +642,9 @@ fn integration_test_replace_execute_replace_new_vault_liquidated() { #[test] fn integration_test_replace_execute_replace_both_vaults_liquidated() { test_with(|old_vault_id, new_vault_id| { - let replace_tokens = old_vault_id.wrapped(1000); - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, replace_tokens); + let replace_amount = new_vault_id.wrapped(10000); + + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); let old = CoreVaultData::vault(old_vault_id.clone()); @@ -843,27 +653,31 @@ fn integration_test_replace_execute_replace_both_vaults_liquidated() { let pre_execution_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - assert_ok!(execute_replace(replace_id)); + assert_ok!(execute_replace(redeem_id)); - let collateral_for_replace = - calculate_replace_collateral(&old, replace.amount(), old_vault_id.collateral_currency()); + let collateral_for_replace = calculate_replace_collateral( + &old, + redeem.amount_btc().checked_sub(&redeem.fee()).unwrap(), + old_vault_id.collateral_currency(), + ); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execution_state.with_changes(|old_vault, _new_vault, liquidation_vault| { let old_liquidation_vault = liquidation_vault.with_currency(&old_vault_id.currencies); - old_liquidation_vault.to_be_redeemed -= old_vault_id.wrapped(1000); - old_liquidation_vault.issued -= old_vault_id.wrapped(1000); + old_liquidation_vault.to_be_redeemed -= replace_amount - redeem.fee; + old_liquidation_vault.issued -= replace_amount - redeem.fee; let new_liquidation_vault = liquidation_vault.with_currency(&new_vault_id.currencies); - new_liquidation_vault.to_be_issued -= old_vault_id.wrapped(1000); - new_liquidation_vault.issued += old_vault_id.wrapped(1000); + new_liquidation_vault.to_be_issued -= replace_amount; + new_liquidation_vault.issued += replace_amount; - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); + old_vault.to_be_redeemed -= replace_amount - redeem.fee; old_vault.liquidated_collateral -= collateral_for_replace; - old_vault.backing_collateral += collateral_for_replace; // TODO: probably should be free - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); - old_vault.griefing_collateral -= replace.griefing_collateral(); + *old_vault + .free_balance + .get_mut(&old_vault_id.collateral_currency()) + .unwrap() += collateral_for_replace; }) ); }); @@ -872,86 +686,30 @@ fn integration_test_replace_execute_replace_both_vaults_liquidated() { #[test] fn integration_test_replace_execute_replace_with_cancelled() { test_with(|old_vault_id, new_vault_id| { - let issued_tokens = old_vault_id.wrapped(1000); - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, issued_tokens); - - let before = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - cancel_replace(replace_id); - assert_ok!(execute_replace(replace_id)); - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - before.with_changes(|old_vault, new_vault, _| { - new_vault.to_be_issued -= issued_tokens; - new_vault.issued += issued_tokens; - old_vault.to_be_redeemed -= issued_tokens; - old_vault.issued -= issued_tokens; - - old_vault.griefing_collateral -= replace.griefing_collateral(); - *new_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); - }) - ); - }); -} - -#[test] -fn integration_test_replace_execute_replace_with_additional_and_cancelled() { - test_with(|old_vault_id, new_vault_id| { - let issued_tokens = old_vault_id.wrapped(1000); - let collateral = old_vault_id.collateral(100000); - let (replace, replace_id) = - setup_replace_with_collateral(&old_vault_id, &new_vault_id, issued_tokens, collateral); - - let before = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - cancel_replace(replace_id); - assert_ok!(execute_replace(replace_id)); - - assert_eq!( - ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), - before.with_changes(|old_vault, new_vault, _| { - new_vault.to_be_issued -= issued_tokens; - new_vault.issued += issued_tokens; - old_vault.to_be_redeemed -= issued_tokens; - old_vault.issued -= issued_tokens; - - // griefing collateral is slashed - old_vault.griefing_collateral -= replace.griefing_collateral(); - *new_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); - - // backing collateral is returned - new_vault.backing_collateral -= replace.collateral().unwrap(); - *new_vault - .free_balance - .get_mut(&new_vault_id.collateral_currency()) - .unwrap() += replace.collateral().unwrap(); - }) - ); + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, _redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); + cancel_replace(redeem_id); + assert_err!(execute_replace(redeem_id), RedeemError::RedeemCancelled); }); } #[test] fn integration_test_replace_cancel_replace_success() { test_with(|old_vault_id, new_vault_id| { - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); - + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); let pre_cancellation_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); + cancel_replace(redeem_id); - cancel_replace(replace_id); - + let punishment_fee = get_punishment_fee(); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_cancellation_state.with_changes(|old_vault, new_vault, _| { - new_vault.to_be_issued -= old_vault_id.wrapped(1000); - new_vault.backing_collateral -= replace.collateral().unwrap(); - *new_vault - .free_balance - .get_mut(&new_vault_id.collateral_currency()) - .unwrap() += replace.collateral().unwrap(); - *new_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); - - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); + new_vault.to_be_issued -= replace_amount; + old_vault.backing_collateral -= punishment_fee; + *new_vault.free_balance.get_mut(&punishment_fee.currency()).unwrap() += punishment_fee; - old_vault.griefing_collateral -= replace.griefing_collateral(); + old_vault.to_be_redeemed -= replace_amount - redeem.fee; }) ); }); @@ -960,7 +718,8 @@ fn integration_test_replace_cancel_replace_success() { #[test] fn integration_test_replace_cancel_replace_old_vault_liquidated() { test_with(|old_vault_id, new_vault_id| { - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); let old = CoreVaultData::vault(old_vault_id.clone()); @@ -968,29 +727,25 @@ fn integration_test_replace_cancel_replace_old_vault_liquidated() { let pre_cancellation_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - cancel_replace(replace_id); + cancel_replace(redeem_id); - let collateral_for_replace = - calculate_replace_collateral(&old, replace.amount(), old_vault_id.collateral_currency()); + let collateral_for_replace = calculate_replace_collateral( + &old, + redeem.amount_btc().checked_sub(&redeem.fee()).unwrap(), + old_vault_id.collateral_currency(), + ); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_cancellation_state.with_changes(|old_vault, new_vault, liquidation_vault| { - let liquidation_vault = liquidation_vault.with_currency(&old_vault_id.currencies); - - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); - old_vault.griefing_collateral -= replace.griefing_collateral(); + old_vault.to_be_redeemed -= replace_amount - redeem.fee; old_vault.liquidated_collateral -= collateral_for_replace; - new_vault.to_be_issued -= old_vault_id.wrapped(1000); - new_vault.backing_collateral -= replace.collateral().unwrap(); - *new_vault - .free_balance - .get_mut(&new_vault_id.collateral_currency()) - .unwrap() += replace.collateral().unwrap(); - *new_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); + new_vault.to_be_issued -= replace_amount; - liquidation_vault.to_be_redeemed -= old_vault_id.wrapped(1000); + let liquidation_vault = liquidation_vault.with_currency(&old_vault_id.currencies); + + liquidation_vault.to_be_redeemed -= replace_amount - redeem.fee; liquidation_vault.collateral += collateral_for_replace; }) ); @@ -1000,24 +755,24 @@ fn integration_test_replace_cancel_replace_old_vault_liquidated() { #[test] fn integration_test_replace_cancel_replace_new_vault_liquidated() { test_with(|old_vault_id, new_vault_id| { - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); liquidate_vault(&new_vault_id); let pre_cancellation_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - cancel_replace(replace_id); - + cancel_replace(redeem_id); + let punishment_fee = get_punishment_fee(); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_cancellation_state.with_changes(|old_vault, new_vault, liquidation_vault| { - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); - old_vault.griefing_collateral -= replace.griefing_collateral(); - - *new_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); + old_vault.to_be_redeemed -= replace_amount - redeem.fee; + old_vault.backing_collateral -= punishment_fee; + *new_vault.free_balance.get_mut(&punishment_fee.currency()).unwrap() += punishment_fee; let new_liquidation_vault = liquidation_vault.with_currency(&new_vault_id.currencies); - new_liquidation_vault.to_be_issued -= old_vault_id.wrapped(1000); + new_liquidation_vault.to_be_issued -= replace_amount; }) ); }); @@ -1026,7 +781,8 @@ fn integration_test_replace_cancel_replace_new_vault_liquidated() { #[test] fn integration_test_replace_cancel_replace_both_vaults_liquidated() { test_with(|old_vault_id, new_vault_id| { - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, redeem, _issue_id, issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); let old = CoreVaultData::vault(old_vault_id.clone()); @@ -1035,26 +791,30 @@ fn integration_test_replace_cancel_replace_both_vaults_liquidated() { let pre_cancellation_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - cancel_replace(replace_id); + cancel_replace(redeem_id); - let collateral_for_replace = - calculate_replace_collateral(&old, replace.amount(), old_vault_id.collateral_currency()); + let collateral_for_replace = calculate_replace_collateral( + &old, + redeem.amount_btc().checked_sub(&redeem.fee()).unwrap(), + old_vault_id.collateral_currency(), + ); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_cancellation_state.with_changes(|old_vault, new_vault, liquidation_vault| { - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); - old_vault.griefing_collateral -= replace.griefing_collateral(); + old_vault.to_be_redeemed -= replace_amount - redeem.fee; old_vault.liquidated_collateral -= collateral_for_replace; - *new_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); + *new_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += issue.griefing_collateral(); let old_liquidation_vault = liquidation_vault.with_currency(&old_vault_id.currencies); - old_liquidation_vault.to_be_redeemed -= old_vault_id.wrapped(1000); + old_liquidation_vault.to_be_redeemed -= replace_amount; old_liquidation_vault.collateral += collateral_for_replace; let new_liquidation_vault = liquidation_vault.with_currency(&new_vault_id.currencies); - new_liquidation_vault.to_be_issued -= old_vault_id.wrapped(1000); + new_liquidation_vault.to_be_issued -= replace_amount; + let new_liquidation_vault = liquidation_vault.with_currency(&old_vault_id.currencies); + new_liquidation_vault.to_be_redeemed += redeem.fee(); //KBTC }) ); }); @@ -1083,22 +843,20 @@ fn integration_test_replace_vault_with_different_currency_succeeds() { CoreVaultData::force_to(&old_vault_id, default_vault_state(&old_vault_id)); CoreVaultData::force_to(&new_vault_id, default_vault_state(&new_vault_id)); - let (replace, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); let pre_execute_state = ParachainTwoVaultState::get(&old_vault_id, &new_vault_id); - assert_ok!(execute_replace(replace_id)); + assert_ok!(execute_replace(redeem_id)); assert_eq!( ParachainTwoVaultState::get(&old_vault_id, &new_vault_id), pre_execute_state.with_changes(|old_vault, new_vault, _| { - new_vault.to_be_issued -= old_vault_id.wrapped(1000); - new_vault.issued += old_vault_id.wrapped(1000); - old_vault.to_be_redeemed -= old_vault_id.wrapped(1000); - old_vault.issued -= old_vault_id.wrapped(1000); - - old_vault.griefing_collateral -= replace.griefing_collateral(); - *old_vault.free_balance.get_mut(&DEFAULT_GRIEFING_CURRENCY).unwrap() += replace.griefing_collateral(); + new_vault.to_be_issued -= replace_amount; + new_vault.issued += replace_amount; + old_vault.to_be_redeemed -= replace_amount - redeem.fee; + old_vault.issued -= replace_amount - redeem.fee; }) ); }); @@ -1110,42 +868,27 @@ mod oracle_down { #[test] fn no_oracle_execute_replace_succeeds() { test_with(|old_vault_id, new_vault_id| { - let (_, replace_id) = setup_replace(&old_vault_id, &new_vault_id, old_vault_id.wrapped(1000)); - - OraclePallet::expire_all(); - - assert_ok!(execute_replace(replace_id)); - }); - } + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, _redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); - #[test] - fn no_oracle_accept_replace_fails() { - test_with(|old_vault_id, new_vault_id| { OraclePallet::expire_all(); - assert_noop!( - RuntimeCall::Replace(ReplaceCall::accept_replace { - currency_pair: new_vault_id.currencies.clone(), - old_vault: old_vault_id.clone(), - amount_btc: 1000000, - collateral: DEFAULT_GRIEFING_COLLATERAL.amount(), - btc_address: Default::default(), - }) - .dispatch(origin_of(new_vault_id.account_id.clone())), - OracleError::MissingExchangeRate - ); + assert_ok!(execute_replace(redeem_id)); }); } #[test] fn no_oracle_request_replace_fails() { - test_with(|old_vault_id, _new_vault_id| { + test_with(|old_vault_id, new_vault_id| { let amount = DEFAULT_VAULT_ISSUED - DEFAULT_VAULT_TO_BE_REDEEMED - DEFAULT_VAULT_TO_BE_REPLACED; OraclePallet::expire_all(); + assert_noop!( - RuntimeCall::Replace(ReplaceCall::request_replace { + RuntimeCall::Redeem(RedeemCall::request_replace { currency_pair: old_vault_id.currencies.clone(), amount: amount.amount(), + new_vault_id: new_vault_id.clone(), + griefing_currency: DEFAULT_GRIEFING_CURRENCY }) .dispatch(origin_of(old_vault_id.account_id.clone())), OracleError::MissingExchangeRate @@ -1156,30 +899,33 @@ mod oracle_down { #[test] fn no_oracle_cancel_replace_fails() { test_with(|old_vault_id, new_vault_id| { - let issued_tokens = old_vault_id.wrapped(1000); - let (_, replace_id) = setup_replace(&old_vault_id, &new_vault_id, issued_tokens); + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, _redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); OraclePallet::expire_all(); mine_blocks(2); SecurityPallet::set_active_block_number(30); + assert_noop!( - RuntimeCall::Replace(ReplaceCall::cancel_replace { replace_id: replace_id }) - .dispatch(origin_of(account_of(NEW_VAULT))), + RuntimeCall::Redeem(RedeemCall::cancel_redeem { + redeem_id: redeem_id, + reimburse: true, + }) + .dispatch(origin_of(account_of(NEW_VAULT))), OracleError::MissingExchangeRate ); }) } #[test] - fn no_oracle_execute_cancelled_replace_fails() { + fn no_oracle_execute_cancelled_replace_succeeds() { test_with(|old_vault_id, new_vault_id| { - let issued_tokens = old_vault_id.wrapped(1000); - let (_, replace_id) = setup_replace(&old_vault_id, &new_vault_id, issued_tokens); + let replace_amount = new_vault_id.wrapped(10000); + let (redeem_id, _redeem, _issue_id, _issue) = setup_replace(replace_amount, &old_vault_id, &new_vault_id); - cancel_replace(replace_id); OraclePallet::expire_all(); - assert_err!(execute_replace(replace_id), OracleError::MissingExchangeRate); + assert_ok!(execute_replace(redeem_id)); }) } } diff --git a/parachain/runtime/runtime-tests/src/parachain/vault_registry.rs b/parachain/runtime/runtime-tests/src/parachain/vault_registry.rs index e8cdc6fbc0..3ca02d6e76 100644 --- a/parachain/runtime/runtime-tests/src/parachain/vault_registry.rs +++ b/parachain/runtime/runtime-tests/src/parachain/vault_registry.rs @@ -306,7 +306,6 @@ mod withdraw_collateral_test { fn integration_test_vault_registry_undercollateralization_liquidation() { test_with(|vault_id| { let currency_id = vault_id.collateral_currency(); - let vault_data = default_vault_state(&vault_id); liquidate_vault(&vault_id); assert_eq!( @@ -324,19 +323,12 @@ fn integration_test_vault_registry_undercollateralization_liquidation() { liquidation_vault.issued = vault_id.wrapped(DEFAULT_VAULT_ISSUED.amount()); liquidation_vault.to_be_redeemed = vault_id.wrapped(DEFAULT_VAULT_TO_BE_REDEEMED.amount()); - vault.griefing_collateral -= DEFAULT_VAULT_REPLACE_COLLATERAL; - vault.replace_collateral -= DEFAULT_VAULT_REPLACE_COLLATERAL; - vault.to_be_replaced = vault_id.wrapped(0); vault.issued = vault_id.wrapped(0); vault.to_be_issued = vault_id.wrapped(0); vault.backing_collateral = Amount::new(0, currency_id); vault.liquidated_collateral = default_vault_backing_collateral(currency_id) - liquidation_vault.collateral; vault.status = VaultStatus::Liquidated; - *vault - .free_balance - .get_mut(&vault_data.replace_collateral.currency()) - .unwrap() += vault_data.replace_collateral; }) ); }); @@ -415,8 +407,6 @@ fn integration_test_vault_registry_liquidation_recovery_fails() { fn default_liquidation_recovery_vault(vault_id: &VaultId) -> CoreVaultData { let mut vault_data = default_vault_state(&vault_id); vault_data.to_be_redeemed = vault_id.wrapped(0); - vault_data.to_be_replaced = vault_id.wrapped(0); - vault_data.replace_collateral = vault_data.replace_collateral.with_amount(|_| 0); vault_data } diff --git a/parachain/runtime/runtime-tests/src/setup.rs b/parachain/runtime/runtime-tests/src/setup.rs index 018643e590..0c9a2ca90b 100644 --- a/parachain/runtime/runtime-tests/src/setup.rs +++ b/parachain/runtime/runtime-tests/src/setup.rs @@ -155,13 +155,6 @@ impl ExtBuilder { .assimilate_storage(&mut storage) .unwrap(); - replace::GenesisConfig:: { - replace_period: 10, - replace_btc_dust_value: 2, - } - .assimilate_storage(&mut storage) - .unwrap(); - fee::GenesisConfig:: { issue_fee: FixedU128::checked_from_rational(15, 10000).unwrap(), // 0.15% issue_griefing_collateral: FixedU128::checked_from_rational(5, 100000).unwrap(), // 0.005% diff --git a/parachain/runtime/runtime-tests/src/utils.rs b/parachain/runtime/runtime-tests/src/utils.rs index de80c7b33c..1c96dcbead 100644 --- a/parachain/runtime/runtime-tests/src/utils.rs +++ b/parachain/runtime/runtime-tests/src/utils.rs @@ -26,7 +26,6 @@ pub use loans_utils::activate_lending_and_mint; pub use oracle::OracleKey; pub use redeem::{types::RedeemRequestExt, RedeemRequest}; use redeem_utils::USER_BTC_ADDRESS; -pub use replace::{types::ReplaceRequestExt, ReplaceRequest}; pub use reward::RewardsApi; pub use sp_arithmetic::{FixedI128, FixedPointNumber, FixedU128}; pub use sp_core::{H160, H256, U256}; @@ -39,7 +38,6 @@ pub mod issue_utils; pub mod loans_utils; pub mod nomination_utils; pub mod redeem_utils; -pub mod replace_utils; pub mod reward_utils; pub use itertools::Itertools; @@ -136,11 +134,6 @@ pub type RedeemPallet = redeem::Pallet; pub type RedeemError = redeem::Error; pub type RedeemEvent = redeem::Event; -pub type ReplaceCall = replace::Call; -pub type ReplaceEvent = replace::Event; -pub type ReplaceError = replace::Error; -pub type ReplacePallet = replace::Pallet; - pub type SecurityError = security::Error; pub type SecurityPallet = security::Pallet; pub type SecurityCall = security::Call; @@ -244,9 +237,6 @@ pub fn default_vault_state(vault_id: &VaultId) -> CoreVaultData { to_be_issued: vault_id.wrapped(DEFAULT_VAULT_TO_BE_ISSUED.amount()), issued: vault_id.wrapped(DEFAULT_VAULT_ISSUED.amount()), to_be_redeemed: vault_id.wrapped(DEFAULT_VAULT_TO_BE_REDEEMED.amount()), - to_be_replaced: vault_id.wrapped(DEFAULT_VAULT_TO_BE_REPLACED.amount()), - griefing_collateral: DEFAULT_VAULT_GRIEFING_COLLATERAL, - replace_collateral: DEFAULT_VAULT_REPLACE_COLLATERAL, backing_collateral: default_vault_backing_collateral(vault_id.collateral_currency()), free_balance: iter_all_currencies() .map(|x| (x, default_vault_free_balance(x))) @@ -300,6 +290,7 @@ pub fn default_redeem_request( btc_address: USER_BTC_ADDRESS, btc_height, status: RedeemRequestStatus::Pending, + issue_id: None, } } @@ -523,12 +514,9 @@ pub struct CoreVaultData { pub issued: Amount, pub to_be_redeemed: Amount, pub backing_collateral: Amount, - pub griefing_collateral: Amount, pub liquidated_collateral: Amount, // note: we use BTreeMap such that the debug print output is sorted, for easier diffing pub free_balance: BTreeMap>, - pub to_be_replaced: Amount, - pub replace_collateral: Amount, pub status: VaultStatus, } @@ -538,9 +526,6 @@ impl CoreVaultData { to_be_issued: vault_id.wrapped(0), issued: vault_id.wrapped(0), to_be_redeemed: vault_id.wrapped(0), - to_be_replaced: vault_id.wrapped(0), - griefing_collateral: griefing(0), - replace_collateral: griefing(0), backing_collateral: Amount::new(0, vault_id.collateral_currency()), free_balance: iter_all_currencies().map(|x| (x, Amount::new(0, x))).collect(), liquidated_collateral: Amount::new(0, vault_id.collateral_currency()), @@ -554,16 +539,9 @@ impl CoreVaultData { to_be_issued: Amount::new(vault.to_be_issued_tokens, vault_id.wrapped_currency()), issued: Amount::new(vault.issued_tokens, vault_id.wrapped_currency()), to_be_redeemed: Amount::new(vault.to_be_redeemed_tokens, vault_id.wrapped_currency()), - to_be_replaced: Amount::new(vault.to_be_replaced_tokens, vault_id.wrapped_currency()), backing_collateral: CurrencySource::::Collateral(vault_id.clone()) .current_balance(vault_id.currencies.collateral) .unwrap(), - griefing_collateral: CurrencySource::::ActiveReplaceCollateral(vault_id.clone()) - .current_balance(::GetGriefingCollateralCurrencyId::get()) - .unwrap() - + CurrencySource::::AvailableReplaceCollateral(vault_id.clone()) - .current_balance(vault_id.currencies.collateral) - .unwrap(), liquidated_collateral: Amount::new(vault.liquidated_collateral, vault_id.currencies.collateral), free_balance: iter_all_currencies() .map(|currency_id| { @@ -575,10 +553,6 @@ impl CoreVaultData { ) }) .collect(), - replace_collateral: Amount::new( - vault.replace_collateral, - ::GetGriefingCollateralCurrencyId::get(), - ), status: vault.status, } } @@ -600,17 +574,10 @@ impl CoreVaultData { } pub fn force_to(vault_id: &VaultId, state: CoreVaultData) { - VaultRegistryPallet::collateral_integrity_check(); - // check that all have same currency assert_eq!(vault_id.wrapped_currency(), state.to_be_issued.currency()); assert_eq!(vault_id.wrapped_currency(), state.issued.currency()); assert_eq!(vault_id.wrapped_currency(), state.to_be_redeemed.currency()); - assert_eq!(vault_id.wrapped_currency(), state.to_be_replaced.currency()); - - // replace collateral is part of griefing collateral, so it needs to smaller or equal - assert!(state.griefing_collateral >= state.replace_collateral); - assert!(state.to_be_replaced + state.to_be_redeemed <= state.issued); // register vault if not yet registered if VaultRegistryPallet::get_vault_from_id(vault_id).is_err() { @@ -623,7 +590,6 @@ impl CoreVaultData { .unwrap() .id .collateral_currency(); - VaultRegistryPallet::collateral_integrity_check(); // temporarily give vault a lot of backing collateral so we can set issued & to-be-issued to whatever we want VaultRegistryPallet::transfer_funds( @@ -632,7 +598,6 @@ impl CoreVaultData { &Amount::new(FUND_LIMIT_CEILING / 10, currency_id), ) .unwrap(); - VaultRegistryPallet::collateral_integrity_check(); let current = CoreVaultData::vault(vault_id.clone()); @@ -641,12 +606,10 @@ impl CoreVaultData { &vault_id, ¤t.to_be_issued )); - VaultRegistryPallet::collateral_integrity_check(); assert_ok!(VaultRegistryPallet::decrease_to_be_redeemed_tokens( &vault_id, ¤t.to_be_redeemed )); - VaultRegistryPallet::collateral_integrity_check(); assert_ok!(VaultRegistryPallet::try_increase_to_be_redeemed_tokens( &vault_id, ¤t.issued @@ -658,10 +621,6 @@ impl CoreVaultData { ¤t.issued, )); VaultRegistryPallet::collateral_integrity_check(); - assert_ok!(VaultRegistryPallet::decrease_to_be_replaced_tokens( - &vault_id, - ¤t.to_be_replaced, - )); VaultRegistryPallet::collateral_integrity_check(); // set to-be-issued @@ -685,10 +644,6 @@ impl CoreVaultData { )); // set to-be-replaced: VaultRegistryPallet::collateral_integrity_check(); - assert_ok!(VaultRegistryPallet::try_increase_to_be_replaced_tokens( - &vault_id, - &state.to_be_replaced, - )); // clear all balances for currency_id in iter_all_currencies() { @@ -713,24 +668,6 @@ impl CoreVaultData { .unwrap(); } - VaultRegistryPallet::transfer_funds( - CurrencySource::ActiveReplaceCollateral(vault_id.clone()), - CurrencySource::FreeBalance(account_of(FAUCET)), - &CurrencySource::::ActiveReplaceCollateral(vault_id.clone()) - .current_balance(::GetGriefingCollateralCurrencyId::get()) - .unwrap(), - ) - .unwrap(); - - VaultRegistryPallet::transfer_funds( - CurrencySource::AvailableReplaceCollateral(vault_id.clone()), - CurrencySource::FreeBalance(account_of(FAUCET)), - &CurrencySource::::AvailableReplaceCollateral(vault_id.clone()) - .current_balance(::GetGriefingCollateralCurrencyId::get()) - .unwrap(), - ) - .unwrap(); - // vault's backing collateral was temporarily increased - reset to 0 VaultRegistryPallet::transfer_funds( CurrencySource::Collateral(vault_id.clone()), @@ -748,19 +685,6 @@ impl CoreVaultData { &state.backing_collateral, ) .unwrap(); - VaultRegistryPallet::transfer_funds( - CurrencySource::FreeBalance(account_of(FAUCET)), - CurrencySource::AvailableReplaceCollateral(vault_id.clone()), - &state.replace_collateral, - ) - .unwrap(); - - VaultRegistryPallet::transfer_funds( - CurrencySource::FreeBalance(account_of(FAUCET)), - CurrencySource::ActiveReplaceCollateral(vault_id.clone()), - &(state.griefing_collateral - state.replace_collateral), - ) - .unwrap(); VaultRegistryPallet::collateral_integrity_check(); @@ -976,14 +900,6 @@ pub fn liquidate_vault(vault_id: &VaultId) { set_collateral_exchange_rate(vault_id, FixedU128::checked_from_integer(10_000_000_000u128).unwrap()); assert_ok!(VaultRegistryPallet::liquidate_vault(&vault_id)); set_collateral_exchange_rate(vault_id, FixedU128::checked_from_integer(1u128).unwrap()); - - assert_eq!( - CurrencySource::::AvailableReplaceCollateral(vault_id.clone()) - .current_balance(DEFAULT_GRIEFING_CURRENCY) - .unwrap() - .amount(), - 0 - ); } pub fn set_default_thresholds() { diff --git a/parachain/runtime/runtime-tests/src/utils/redeem_utils.rs b/parachain/runtime/runtime-tests/src/utils/redeem_utils.rs index fbb266c8fb..297e9dbe06 100644 --- a/parachain/runtime/runtime-tests/src/utils/redeem_utils.rs +++ b/parachain/runtime/runtime-tests/src/utils/redeem_utils.rs @@ -154,6 +154,27 @@ pub fn assert_redeem_request_event() -> H256 { ids.last().unwrap().clone() } +// returns punishment_fee that vault has paid for cancel replace +pub fn get_punishment_fee() -> Amount { + let events = SystemPallet::events(); + let ids = events + .iter() + .filter_map(|r| match r.event { + RuntimeEvent::Redeem(RedeemEvent::CancelReplace { + ref old_vault, + punishment_fee, + .. + }) => { + let fee = Amount::new(punishment_fee, old_vault.collateral_currency()); + Some(fee) + } + _ => None, + }) + .collect::>(); + assert!(ids.len() >= 1); + ids.last().unwrap().clone() +} + /// returns (fee, amount) pub fn assert_self_redeem_event() -> (Amount, Amount) { let events = SystemPallet::events(); diff --git a/parachain/runtime/runtime-tests/src/utils/replace_utils.rs b/parachain/runtime/runtime-tests/src/utils/replace_utils.rs deleted file mode 100644 index 4bc7c207cf..0000000000 --- a/parachain/runtime/runtime-tests/src/utils/replace_utils.rs +++ /dev/null @@ -1,90 +0,0 @@ -use crate::setup::*; -use currency::Amount; - -pub fn request_replace(old_vault_id: &VaultId, amount: Amount) -> Amount { - assert_ok!(RuntimeCall::Replace(ReplaceCall::request_replace { - currency_pair: old_vault_id.currencies.clone(), - amount: amount.amount(), - }) - .dispatch(origin_of(old_vault_id.account_id.clone()))); - griefing(assert_request_replace_event()) -} - -pub fn setup_replace( - old_vault_id: &VaultId, - new_vault_id: &VaultId, - issued_tokens: Amount, -) -> (ReplaceRequest, H256) { - setup_replace_with_collateral(old_vault_id, new_vault_id, issued_tokens, old_vault_id.collateral(0)) -} - -pub fn setup_replace_with_collateral( - old_vault_id: &VaultId, - new_vault_id: &VaultId, - issued_tokens: Amount, - collateral: Amount, -) -> (ReplaceRequest, H256) { - let new_vault_btc_address = BtcAddress::P2PKH(H160([2; 20])); - - request_replace(old_vault_id, issued_tokens); - - let (id, request) = accept_replace( - &old_vault_id, - &new_vault_id, - issued_tokens, - collateral, - new_vault_btc_address, - ) - .unwrap(); - (request, id) -} - -pub fn assert_request_replace_event() -> Balance { - SystemPallet::events() - .iter() - .rev() - .find_map(|record| match record.event { - RuntimeEvent::Replace(ReplaceEvent::RequestReplace { - griefing_collateral, .. - }) => Some(griefing_collateral), - _ => None, - }) - .unwrap() -} - -pub fn assert_accept_replace_event() -> H256 { - SystemPallet::events() - .iter() - .rev() - .find_map(|record| match record.event { - RuntimeEvent::Replace(ReplaceEvent::AcceptReplace { replace_id, .. }) => Some(replace_id), - _ => None, - }) - .unwrap() -} - -pub fn accept_replace( - old_vault_id: &VaultId, - new_vault_id: &VaultId, - amount_btc: Amount, - collateral: Amount, - btc_address: BtcAddress, -) -> Result<(H256, ReplaceRequest), sp_runtime::DispatchError> { - // assert_replace_request_event(); - - RuntimeCall::Replace(ReplaceCall::accept_replace { - currency_pair: new_vault_id.currencies.clone(), - old_vault: old_vault_id.clone(), - amount_btc: amount_btc.amount(), - collateral: collateral.amount(), - btc_address: btc_address, - }) - .dispatch(origin_of(new_vault_id.account_id.clone())) - .map_err(|err| err.error)?; - - VaultRegistryPallet::collateral_integrity_check(); - - let replace_id = assert_accept_replace_event(); - let replace = ReplacePallet::get_open_replace_request(&replace_id).unwrap(); - Ok((replace_id, replace)) -} diff --git a/parachain/src/chain_spec/interlay.rs b/parachain/src/chain_spec/interlay.rs index 827bf39191..4777a7e3db 100644 --- a/parachain/src/chain_spec/interlay.rs +++ b/parachain/src/chain_spec/interlay.rs @@ -229,10 +229,6 @@ pub fn interlay_genesis( redeem_period: interlay_runtime::DAYS * 2, redeem_btc_dust_value: DEFAULT_DUST_VALUE, }, - replace: interlay_runtime::ReplaceConfig { - replace_period: interlay_runtime::DAYS * 2, - replace_btc_dust_value: DEFAULT_DUST_VALUE, - }, vault_registry: interlay_runtime::VaultRegistryConfig { minimum_collateral_vault: vec![(Token(DOT), 30 * DOT.one())], punishment_delay: interlay_runtime::DAYS, diff --git a/parachain/src/chain_spec/kintsugi.rs b/parachain/src/chain_spec/kintsugi.rs index 822389f282..5d7275ad3f 100644 --- a/parachain/src/chain_spec/kintsugi.rs +++ b/parachain/src/chain_spec/kintsugi.rs @@ -237,10 +237,6 @@ pub fn kintsugi_genesis( redeem_period: kintsugi_runtime::DAYS * 2, redeem_btc_dust_value: DEFAULT_DUST_VALUE, }, - replace: kintsugi_runtime::ReplaceConfig { - replace_period: kintsugi_runtime::DAYS * 2, - replace_btc_dust_value: DEFAULT_DUST_VALUE, - }, vault_registry: kintsugi_runtime::VaultRegistryConfig { minimum_collateral_vault: vec![(Token(KINT), 55 * KINT.one()), (Token(KSM), 3 * KSM.one())], punishment_delay: kintsugi_runtime::DAYS, diff --git a/parachain/src/service.rs b/parachain/src/service.rs index 1b02e504f9..f13d7137ba 100644 --- a/parachain/src/service.rs +++ b/parachain/src/service.rs @@ -111,11 +111,6 @@ pub trait RuntimeApiCollection: AccountId, H256, redeem::RedeemRequest, - > + replace_rpc_runtime_api::ReplaceApi< - Block, - AccountId, - H256, - replace::ReplaceRequest, > + reward_rpc_runtime_api::RewardApi< Block, AccountId, @@ -159,11 +154,6 @@ where AccountId, H256, redeem::RedeemRequest, - > + replace_rpc_runtime_api::ReplaceApi< - Block, - AccountId, - H256, - replace::ReplaceRequest, > + reward_rpc_runtime_api::RewardApi< Block, AccountId, diff --git a/primitives/src/lib.rs b/primitives/src/lib.rs index 293e2e10ad..82b303abf9 100644 --- a/primitives/src/lib.rs +++ b/primitives/src/lib.rs @@ -84,6 +84,27 @@ pub struct VaultCurrencyPair { pub wrapped: CurrencyId, } +#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, PartialOrd, Ord, TypeInfo, MaxEncodedLen)] +#[cfg_attr(feature = "std", derive(Serialize, Deserialize, std::hash::Hash))] +pub enum AccountOrVault { + Account(AccountId), + Vault(VaultId), +} +impl AccountOrVault { + // Method to retrieve the account associated with an `AccountOrVault` instance + pub fn get_account(&self) -> &AccountId { + match self { + AccountOrVault::Account(account_id) => account_id, + AccountOrVault::Vault(vault_id) => &vault_id.account_id, + } + } + + // Method to check if the enum variant is `Vault` + pub fn is_vault_account(&self) -> bool { + matches!(self, AccountOrVault::Vault(_)) + } +} + #[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, PartialOrd, Ord, TypeInfo, MaxEncodedLen)] #[cfg_attr(feature = "std", derive(Serialize, Deserialize, std::hash::Hash))] pub struct VaultId { @@ -174,7 +195,7 @@ pub mod issue { /// the number of tokens that will be transferred to the fee pool pub fee: Balance, /// the account issuing tokens - pub requester: AccountId, + pub requester: AccountOrVault, /// the vault's Bitcoin deposit address pub btc_address: BtcAddress, /// the vault's Bitcoin public key (when this request was made) @@ -226,6 +247,8 @@ pub mod redeem { Reimbursed(bool), /// user received compensation, but is retrying the redeem with another vault Retried, + /// the redeem replace request is cancelled + Cancelled, } impl Default for RedeemRequestStatus { @@ -277,6 +300,8 @@ pub mod redeem { pub btc_height: u32, /// the status of this redeem request pub status: RedeemRequestStatus, + /// the issue id associated with replace request + pub issue_id: Option, } } diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index f09ee2ea4d..d675ee7dab 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -14,7 +14,6 @@ oracle-rpc = { path = "../crates/oracle/rpc" } vault-registry-rpc = { path = "../crates/vault-registry/rpc" } issue-rpc = { path = "../crates/issue/rpc" } redeem-rpc = { path = "../crates/redeem/rpc" } -replace-rpc = { path = "../crates/replace/rpc" } escrow-rpc = { path = "../crates/escrow/rpc" } reward-rpc = { path = "../crates/reward/rpc" } loans-rpc = { path = "../crates/loans/rpc" } diff --git a/rpc/src/lib.rs b/rpc/src/lib.rs index 764a7f69e8..edadbbe95c 100644 --- a/rpc/src/lib.rs +++ b/rpc/src/lib.rs @@ -4,8 +4,8 @@ //! capabilities that are specific to this project's runtime configuration. use primitives::{ - issue::IssueRequest, redeem::RedeemRequest, replace::ReplaceRequest, AccountId, Balance, Block, BlockNumber, - CurrencyId, H256Le, Hash, Nonce, StablePoolId, VaultId, + issue::IssueRequest, redeem::RedeemRequest, AccountId, Balance, Block, BlockNumber, CurrencyId, H256Le, Hash, + Nonce, StablePoolId, VaultId, }; use sc_consensus_manual_seal::rpc::{EngineCommand, ManualSeal, ManualSealApiServer}; pub use sc_rpc_api::DenyUnsafe; @@ -91,12 +91,6 @@ where H256, RedeemRequest, >, - C::Api: replace_rpc::ReplaceRuntimeApi< - Block, - AccountId, - H256, - ReplaceRequest, - >, C::Api: escrow_rpc::EscrowRuntimeApi, C::Api: reward_rpc::RewardRuntimeApi< Block, @@ -124,7 +118,6 @@ where use oracle_rpc::{Oracle, OracleApiServer}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; use redeem_rpc::{Redeem, RedeemApiServer}; - use replace_rpc::{Replace, ReplaceApiServer}; use reward_rpc::{Reward, RewardApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; use vault_registry_rpc::{VaultRegistry, VaultRegistryApiServer}; @@ -172,8 +165,6 @@ where module.merge(Redeem::new(client.clone()).into_rpc())?; - module.merge(Replace::new(client.clone()).into_rpc())?; - module.merge(Loans::new(client.clone()).into_rpc())?; module.merge(DexGeneral::new(client.clone()).into_rpc())?;