diff --git a/Cargo.lock b/Cargo.lock index 8bfb53b61c..bbad0f58ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -185,9 +185,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.90" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "approx" @@ -209,7 +209,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -435,7 +435,7 @@ checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", "synstructure 0.13.1", ] @@ -458,7 +458,7 @@ checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -626,7 +626,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -684,7 +684,7 @@ checksum = "3c87f3f15e7794432337fc718554eaa4dc8f04c9677a950ffe366f20a162ae42" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -824,13 +824,13 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.24", + "prettyplease 0.2.22", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -1069,7 +1069,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", "syn_derive", ] @@ -1141,9 +1141,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.19.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -1153,9 +1153,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -1239,9 +1239,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.31" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" dependencies = [ "jobserver", "libc", @@ -1424,7 +1424,7 @@ name = "cf-runtime-macros" version = "0.1.0" dependencies = [ "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -1989,7 +1989,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2539,7 +2539,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2579,9 +2579,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.129" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbdc8cca144dce1c4981b5c9ab748761619979e515c3d53b5df385c677d1d007" +checksum = "54ccead7d199d584d139148b04b4a368d1ec7556a1d9ea2548febb1b9d49f9a4" dependencies = [ "cc", "cxxbridge-flags", @@ -2591,9 +2591,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.129" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5764c3142ab44fcf857101d12c0ddf09c34499900557c764f5ad0597159d1fc" +checksum = "c77953e99f01508f89f55c494bfa867171ef3a6c8cea03d26975368f2121a5c1" dependencies = [ "cc", "codespan-reporting", @@ -2601,24 +2601,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] name = "cxxbridge-flags" -version = "1.0.129" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d422aff542b4fa28c2ce8e5cc202d42dbf24702345c1fba3087b2d3f8a1b90ff" +checksum = "65777e06cc48f0cb0152024c77d6cf9e4bdb4408e7b48bea993d42fa0f5b02b6" [[package]] name = "cxxbridge-macro" -version = "1.0.129" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1719100f31492cd6adeeab9a0f46cdbc846e615fdb66d7b398aa46ec7fdd06f" +checksum = "98532a60dedaebc4848cb2cba5023337cc9ea3af16a5b062633fabfd9f18fb60" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2690,7 +2690,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2723,7 +2723,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core 0.20.10", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2832,7 +2832,7 @@ checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2843,7 +2843,7 @@ checksum = "62d671cc41a825ebabc75757b62d3d168c577f9149b2d49ece1dad1f72119d25" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2881,7 +2881,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -2989,7 +2989,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -3037,7 +3037,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.82", + "syn 2.0.79", "termcolor", "toml 0.8.19", "walkdir", @@ -3226,7 +3226,7 @@ dependencies = [ "engine-upgrade-utils", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -3302,7 +3302,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -3526,14 +3526,14 @@ dependencies = [ "ethers-core", "ethers-etherscan", "eyre", - "prettyplease 0.2.24", + "prettyplease 0.2.22", "proc-macro2", "quote", "regex", "reqwest", "serde", "serde_json", - "syn 2.0.82", + "syn 2.0.79", "toml 0.8.19", "walkdir", ] @@ -3551,7 +3551,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -3577,7 +3577,7 @@ dependencies = [ "serde", "serde_json", "strum 0.26.3", - "syn 2.0.82", + "syn 2.0.79", "tempfile", "thiserror", "tiny-keccak", @@ -3770,10 +3770,10 @@ dependencies = [ "blake2 0.10.6", "file-guard", "fs-err", - "prettyplease 0.2.24", + "prettyplease 0.2.22", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -4157,7 +4157,7 @@ dependencies = [ "proc-macro2", "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/chainflip-io/polkadot-sdk.git?tag=chainflip-substrate-1.15.2+2)", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -4169,7 +4169,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -4179,7 +4179,7 @@ source = "git+https://github.com/chainflip-io/polkadot-sdk.git?tag=chainflip-sub dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -4358,7 +4358,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -4988,9 +4988,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.31" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", @@ -5012,9 +5012,9 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -5039,7 +5039,7 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.30", "log", "rustls 0.21.12", "rustls-native-certs 0.6.3", @@ -5055,10 +5055,10 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.5.0", + "hyper 1.4.1", "hyper-util", "log", - "rustls 0.23.15", + "rustls 0.23.14", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -5073,7 +5073,7 @@ checksum = "6eea26c5d0b6ab9d72219f65000af310f042a740926f7b2fa3553e774036e2e7" dependencies = [ "derive_builder", "dns-lookup", - "hyper 0.14.31", + "hyper 0.14.30", "tokio", "tower-service", "tracing", @@ -5086,7 +5086,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes", - "hyper 0.14.31", + "hyper 0.14.30", "native-tls", "tokio", "tokio-native-tls", @@ -5103,7 +5103,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.4.1", "pin-project-lite", "socket2 0.5.7", "tokio", @@ -5211,7 +5211,7 @@ dependencies = [ "bytes", "futures", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.30", "log", "rand", "tokio", @@ -5572,7 +5572,7 @@ dependencies = [ "http 1.1.0", "jsonrpsee-core 0.23.2", "pin-project", - "rustls 0.23.15", + "rustls 0.23.14", "rustls-pki-types", "rustls-platform-verifier", "soketto 0.8.0", @@ -5595,7 +5595,7 @@ dependencies = [ "beef", "futures-timer", "futures-util", - "hyper 0.14.31", + "hyper 0.14.30", "jsonrpsee-types 0.22.5", "pin-project", "rustc-hash", @@ -5643,7 +5643,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ccf93fc4a0bfe05d851d37d7c32b7f370fe94336b52a2f0efc5f1981895c2e5" dependencies = [ "async-trait", - "hyper 0.14.31", + "hyper 0.14.30", "hyper-rustls 0.24.2", "jsonrpsee-core 0.22.5", "jsonrpsee-types 0.22.5", @@ -5665,12 +5665,12 @@ dependencies = [ "async-trait", "base64 0.22.1", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.4.1", "hyper-rustls 0.27.3", "hyper-util", "jsonrpsee-core 0.23.2", "jsonrpsee-types 0.23.2", - "rustls 0.23.15", + "rustls 0.23.14", "rustls-platform-verifier", "serde", "serde_json", @@ -5691,7 +5691,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -5705,7 +5705,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.4.1", "hyper-util", "jsonrpsee-core 0.23.2", "jsonrpsee-types 0.23.2", @@ -5899,9 +5899,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.161" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libloading" @@ -6250,7 +6250,7 @@ dependencies = [ "proc-macro-warning 0.4.2", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -6466,9 +6466,9 @@ dependencies = [ [[package]] name = "linregress" -version = "0.5.4" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9eda9dcf4f2a99787827661f312ac3219292549c2ee992bf9a6248ffb066bf7" +checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" dependencies = [ "nalgebra", ] @@ -6623,7 +6623,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -6637,7 +6637,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -6648,7 +6648,7 @@ checksum = "b02abfe41815b5bd98dbd4260173db2c116dda171dc0fe7838cb206333b83308" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -6659,7 +6659,7 @@ checksum = "73ea28ee64b88876bf45277ed9a5817c1817df061a74f2b988971a12570e5869" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -6919,7 +6919,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -6931,7 +6931,7 @@ dependencies = [ "cfg-if", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -7134,12 +7134,13 @@ dependencies = [ [[package]] name = "nalgebra" -version = "0.33.1" +version = "0.32.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf139e93ad757869338ad85239cb1d6c067b23b94e5846e637ca6328ee4be60" +checksum = "7b5c17de023a86f59ed79891b2e5d5a94c705dbe904a5b5c9c952ea6221b03e4" dependencies = [ "approx", "matrixmultiply", + "nalgebra-macros", "num-complex", "num-rational", "num-traits", @@ -7147,6 +7148,17 @@ dependencies = [ "typenum", ] +[[package]] +name = "nalgebra-macros" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "254a5372af8fc138e36684761d3c0cdb758a4410e938babcff1c860ce14ddbfc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "names" version = "0.14.0" @@ -7378,7 +7390,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -7449,7 +7461,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -7545,9 +7557,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.68" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -7566,7 +7578,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -7586,9 +7598,9 @@ dependencies = [ [[package]] name = "openssl-sys" -version = "0.9.104" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", @@ -8409,9 +8421,9 @@ checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42" [[package]] name = "pathdiff" -version = "0.2.2" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "pbkdf2" @@ -8459,9 +8471,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.14" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442" +checksum = "fdbef9d1d47087a895abd220ed25eb4ad973a5e26f6a4367b038c25e28dfc2d9" dependencies = [ "memchr", "thiserror", @@ -8470,9 +8482,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.14" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d214365f632b123a47fd913301e14c946c61d1c183ee245fa76eb752e59a02dd" +checksum = "4d3a6e3394ec80feb3b6393c725571754c6188490265c61aaf260810d6b95aa0" dependencies = [ "pest", "pest_generator", @@ -8480,22 +8492,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.14" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb55586734301717aea2ac313f50b2eb8f60d2fc3dc01d190eefa2e625f60c4e" +checksum = "94429506bde1ca69d1b5601962c73f4172ab4726571a59ea95931218cb0e930e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] name = "pest_meta" -version = "2.7.14" +version = "2.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75da2a70cf4d9cb76833c990ac9cd3923c9a8905a8929789ce347c84564d03d" +checksum = "ac8a071862e93690b6e34e9a5fb8e33ff3734473ac0245b27232222c4906a33f" dependencies = [ "once_cell", "pest", @@ -8552,7 +8564,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8590,7 +8602,7 @@ checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8696,7 +8708,7 @@ dependencies = [ "polkavm-common 0.8.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8708,7 +8720,7 @@ dependencies = [ "polkavm-common 0.9.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8718,7 +8730,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15e85319a0d5129dc9f021c62607e0804f5fb777a05cdda44d750ac0732def66" dependencies = [ "polkavm-derive-impl 0.8.0", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8728,7 +8740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ba81f7b5faac81e528eb6158a6f3c9e0bb1008e0ffa19653bc8dea925ecb429" dependencies = [ "polkavm-derive-impl 0.9.0", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8873,12 +8885,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.24" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "910d41a655dac3b764f1ade94821093d3610248694320cd072303a8eedcf221d" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8946,7 +8958,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -8957,14 +8969,14 @@ checksum = "834da187cfe638ae8abb0203f0b33e5ccdb02a28e7199f2f47b3e2754f50edca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -9003,7 +9015,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -9077,11 +9089,11 @@ dependencies = [ "multimap 0.10.0", "once_cell", "petgraph", - "prettyplease 0.2.24", + "prettyplease 0.2.22", "prost 0.12.6", "prost-types 0.12.6", "regex", - "syn 2.0.82", + "syn 2.0.79", "tempfile", ] @@ -9108,7 +9120,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -9148,7 +9160,7 @@ dependencies = [ "futures-core", "futures-util", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.30", "hyper-system-resolver", "pin-project-lite", "thiserror", @@ -9478,9 +9490,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.27.5" +version = "0.27.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cccf17a692ce51b86564334614d72dcae1def0fd5ecebc9f02956da74352b5" +checksum = "dc6baebe319ef5e4b470f248335620098d1c2e9261e995be05f56f719ca4bdb2" dependencies = [ "arc-swap", "async-trait", @@ -9545,7 +9557,7 @@ checksum = "bcc303e793d3734489387d205e9b186fac9c6cfacedd98cbb2e8a5943595f3e6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -9631,7 +9643,7 @@ dependencies = [ "h2 0.3.26", "http 0.2.12", "http-body 0.4.6", - "hyper 0.14.31", + "hyper 0.14.30", "hyper-rustls 0.24.2", "hyper-tls", "ipnet", @@ -9917,9 +9929,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.15" +version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" +checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" dependencies = [ "log", "once_cell", @@ -9975,9 +9987,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-platform-verifier" @@ -9990,7 +10002,7 @@ dependencies = [ "jni", "log", "once_cell", - "rustls 0.23.15", + "rustls 0.23.14", "rustls-native-certs 0.7.3", "rustls-platform-verifier-android", "rustls-webpki 0.102.8", @@ -10029,9 +10041,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.18" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ruzstd" @@ -10171,7 +10183,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -10725,7 +10737,7 @@ dependencies = [ "fnv", "futures", "futures-timer", - "hyper 0.14.31", + "hyper 0.14.30", "hyper-rustls 0.24.2", "log", "num_cpus", @@ -10820,7 +10832,7 @@ dependencies = [ "governor", "http 1.1.0", "http-body-util", - "hyper 1.5.0", + "hyper 1.4.1", "ip_network", "jsonrpsee 0.23.2", "log", @@ -11018,7 +11030,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -11143,7 +11155,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -11220,7 +11232,7 @@ dependencies = [ "proc-macro2", "quote", "scale-info", - "syn 2.0.82", + "syn 2.0.79", "thiserror", ] @@ -11506,14 +11518,14 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -11579,7 +11591,7 @@ dependencies = [ "darling 0.20.10", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -11719,9 +11731,9 @@ dependencies = [ [[package]] name = "simba" -version = "0.9.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3a386a501cd104797982c15ae17aafe8b9261315b5d07e3ec803f2ea26be0fa" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -12041,7 +12053,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -12314,7 +12326,7 @@ source = "git+https://github.com/chainflip-io/polkadot-sdk.git?tag=chainflip-sub dependencies = [ "quote", "sp-crypto-hashing 0.1.0 (git+https://github.com/chainflip-io/polkadot-sdk.git?tag=chainflip-substrate-1.15.2+2)", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -12334,7 +12346,7 @@ checksum = "48d09fa0a5f7299fb81ee25ae3853d26200f7a348148aed6de76be905c007dbe" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -12344,7 +12356,7 @@ source = "git+https://github.com/chainflip-io/polkadot-sdk.git?tag=chainflip-sub dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -12652,7 +12664,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -12665,7 +12677,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -12930,7 +12942,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -13239,7 +13251,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -13298,7 +13310,7 @@ version = "0.17.0" source = "git+https://github.com/chainflip-io/polkadot-sdk.git?tag=chainflip-substrate-1.15.2+2#d4792faaa7ab3fbb9798dcc629564d182853690e" dependencies = [ "http-body-util", - "hyper 1.5.0", + "hyper 1.4.1", "hyper-util", "log", "prometheus", @@ -13389,16 +13401,16 @@ dependencies = [ "scale-info", "scale-typegen", "subxt-metadata", - "syn 2.0.82", + "syn 2.0.79", "thiserror", "tokio", ] [[package]] name = "subxt-core" -version = "0.37.0" +version = "0.37.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f41eb2e2eea6ed45649508cc735f92c27f1fcfb15229e75f8270ea73177345" +checksum = "3af3b36405538a36b424d229dc908d1396ceb0994c90825ce928709eac1a159a" dependencies = [ "base58", "blake2 0.10.6", @@ -13452,7 +13464,7 @@ dependencies = [ "quote", "scale-typegen", "subxt-codegen", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -13501,9 +13513,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.82" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -13519,7 +13531,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -13548,7 +13560,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -13650,7 +13662,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -13788,7 +13800,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -13828,7 +13840,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.15", + "rustls 0.23.14", "rustls-pki-types", "tokio", ] @@ -13999,7 +14011,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -14356,9 +14368,12 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicase" -version = "2.8.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] [[package]] name = "unicode-bidi" @@ -14536,9 +14551,9 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "w3f-bls" -version = "0.1.6" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a48c48447120a85b0bdb897ba9426a7aa15b4229498a2e19103e8c9368dd4b2" +checksum = "9c5da5fa2c6afa2c9158eaa7cd9aee249765eb32b5fb0c63ad8b9e79336a47ec" dependencies = [ "ark-bls12-377", "ark-bls12-381", @@ -14597,7 +14612,7 @@ dependencies = [ "futures-util", "headers", "http 0.2.12", - "hyper 0.14.31", + "hyper 0.14.30", "log", "mime", "mime_guess", @@ -14649,7 +14664,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -14683,7 +14698,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -15573,7 +15588,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] @@ -15593,7 +15608,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.82", + "syn 2.0.79", ] [[package]] diff --git a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs index 20a5829256..fafbfff21b 100644 --- a/api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs +++ b/api/bin/chainflip-ingress-egress-tracker/src/witnessing/state_chain.rs @@ -147,8 +147,8 @@ impl From> for WitnessInformation { amount: value.amount.into(), asset: value.asset.into(), deposit_details: Some(DepositDetails::Bitcoin { - tx_id: value.deposit_details.utxo_id.tx_id, - vout: value.deposit_details.utxo_id.vout, + tx_id: value.deposit_details.id.tx_id, + vout: value.deposit_details.id.vout, }), } } diff --git a/engine/src/witness/btc/deposits.rs b/engine/src/witness/btc/deposits.rs index 881928b29c..8d03c4b6c8 100644 --- a/engine/src/witness/btc/deposits.rs +++ b/engine/src/witness/btc/deposits.rs @@ -19,7 +19,7 @@ use crate::{ use bitcoin::{hashes::Hash, BlockHash}; use cf_chains::{ assets::btc, - btc::{deposit_address::DepositAddress, BtcDepositDetails, UtxoId}, + btc::{deposit_address::DepositAddress, Utxo, UtxoId}, Bitcoin, }; @@ -115,12 +115,14 @@ fn deposit_witnesses( .filter(|(_vout, tx_out)| tx_out.value.to_sat() > 0) .filter_map(|(vout, tx_out)| { deposit_addresses.get(tx_out.script_pubkey.as_bytes()).map(|deposit_address| { + let amount = tx_out.value.to_sat(); DepositWitness:: { deposit_address: deposit_address.script_pubkey(), asset: btc::Asset::Btc, - amount: tx_out.value.to_sat(), - deposit_details: BtcDepositDetails { - utxo_id: UtxoId { tx_id: tx.txid.to_byte_array().into(), vout }, + amount, + deposit_details: Utxo { + id: UtxoId { tx_id: tx.txid.to_byte_array().into(), vout }, + amount, deposit_address: deposit_address.clone(), }, } diff --git a/engine/src/witness/btc/smart_contract.rs b/engine/src/witness/btc/smart_contract.rs index 0f5633c140..3032b875f6 100644 --- a/engine/src/witness/btc/smart_contract.rs +++ b/engine/src/witness/btc/smart_contract.rs @@ -3,8 +3,8 @@ use cf_amm::common::{bounded_sqrt_price, sqrt_price_to_price}; use cf_chains::{ assets::btc::Asset as BtcAsset, btc::{ - deposit_address::DepositAddress, smart_contract_encoding::UtxoEncodedData, - BtcDepositDetails, ScriptPubkey, UtxoId, + deposit_address::DepositAddress, smart_contract_encoding::UtxoEncodedData, ScriptPubkey, + Utxo, UtxoId, }, ChannelRefundParameters, ForeignChainAddress, }; @@ -134,9 +134,10 @@ pub fn try_extract_contract_call( deposit_amount, destination_address: data.output_address, tx_hash: tx_id, - deposit_details: Box::new(BtcDepositDetails { + deposit_details: Box::new(Utxo { // we require the deposit to be the first UTXO - utxo_id: UtxoId { tx_id: tx_id.into(), vout: 0 }, + id: UtxoId { tx_id: tx_id.into(), vout: 0 }, + amount: deposit_amount, deposit_address: vault_address.clone(), }), deposit_metadata: None, // No ccm for BTC (yet?) @@ -274,8 +275,9 @@ mod tests { deposit_amount: DEPOSIT_AMOUNT, destination_address: MOCK_SWAP_PARAMS.output_address.clone(), tx_hash: tx.hash.to_byte_array(), - deposit_details: Box::new(BtcDepositDetails { - utxo_id: UtxoId { tx_id: tx.txid.to_byte_array().into(), vout: 0 }, + deposit_details: Box::new(Utxo { + id: UtxoId { tx_id: tx.txid.to_byte_array().into(), vout: 0 }, + amount: DEPOSIT_AMOUNT, deposit_address: vault_deposit_address, }), broker_fees: Default::default(), diff --git a/state-chain/cf-integration-tests/src/broadcasting.rs b/state-chain/cf-integration-tests/src/broadcasting.rs index 4f1b61210f..e4b739b633 100644 --- a/state-chain/cf-integration-tests/src/broadcasting.rs +++ b/state-chain/cf-integration-tests/src/broadcasting.rs @@ -1,6 +1,6 @@ use super::*; use cf_chains::{ - btc::{deposit_address::DepositAddress, ScriptPubkey}, + btc::{deposit_address::DepositAddress, ScriptPubkey, Utxo}, AllBatch, Bitcoin, ForeignChain, TransferAssetParams, }; use cf_primitives::{chains::assets::btc, AuthorityCount, BroadcastId}; @@ -26,11 +26,11 @@ fn bitcoin_broadcast_delay_works() { let epoch = Validator::epoch_index(); let bitcoin_agg_key = BitcoinThresholdSigner::keys(epoch).unwrap().current; let egress_id = (ForeignChain::Bitcoin, 1u64); - Environment::add_bitcoin_utxo_to_list( - 1_000_000_000_000u64, - Default::default(), - DepositAddress::new(bitcoin_agg_key, 0u32), - ); + Environment::add_bitcoin_utxo_to_list(Utxo { + id: Default::default(), + amount: 1_000_000_000_000u64, + deposit_address: DepositAddress::new(bitcoin_agg_key, 0u32), + }); // Cause bitcoin vault to rotate - but stop the broadcasting. let (bitcoin_call, _egress_ids) = AllBatch::::new_unsigned( diff --git a/state-chain/cf-integration-tests/src/new_epoch.rs b/state-chain/cf-integration-tests/src/new_epoch.rs index 932bc06447..978f667ba3 100644 --- a/state-chain/cf-integration-tests/src/new_epoch.rs +++ b/state-chain/cf-integration-tests/src/new_epoch.rs @@ -238,7 +238,7 @@ fn utxo(amount: BtcAmount, salt: u32, pub_key: Option<[u8; 32]>) -> Utxo { } fn add_utxo_amount(utxo: Utxo) { - Environment::add_bitcoin_utxo_to_list(utxo.amount, utxo.id, utxo.deposit_address); + Environment::add_bitcoin_utxo_to_list(utxo); } #[test] diff --git a/state-chain/chains/src/any.rs b/state-chain/chains/src/any.rs index fea3f39ce7..2371b8264d 100644 --- a/state-chain/chains/src/any.rs +++ b/state-chain/chains/src/any.rs @@ -1,7 +1,7 @@ use crate::{ address::{ForeignChainAddress, IntoForeignChainAddress}, none::NoneChainCrypto, - Chain, FeeRefundCalculator, + Chain, DepositDetailsToTransactionInId, FeeRefundCalculator, }; use codec::{FullCodec, MaxEncodedLen}; use frame_support::Parameter; @@ -52,3 +52,5 @@ impl IntoForeignChainAddress for ForeignChainAddress { address } } + +impl DepositDetailsToTransactionInId for () {} diff --git a/state-chain/chains/src/arb/api.rs b/state-chain/chains/src/arb/api.rs index e6a177a44d..c42dda9396 100644 --- a/state-chain/chains/src/arb/api.rs +++ b/state-chain/chains/src/arb/api.rs @@ -150,6 +150,11 @@ impl From> for Arb } } +impl RejectCall for ArbitrumApi where + E: EvmEnvironmentProvider + ReplayProtectionProvider +{ +} + macro_rules! map_over_api_variants { ( $self:expr, $var:pat_param, $var_method:expr $(,)* ) => { match $self { diff --git a/state-chain/chains/src/benchmarking_value.rs b/state-chain/chains/src/benchmarking_value.rs index 0fb0fabf5f..9af451aaff 100644 --- a/state-chain/chains/src/benchmarking_value.rs +++ b/state-chain/chains/src/benchmarking_value.rs @@ -15,7 +15,7 @@ use sp_std::vec; #[cfg(feature = "runtime-benchmarks")] use crate::{ address::{EncodedAddress, ForeignChainAddress}, - btc::{BtcDepositDetails, UtxoId}, + btc::{Utxo, UtxoId}, dot::PolkadotTransactionId, evm::{DepositDetails, EvmFetchId, EvmTransactionMetadata}, }; @@ -225,10 +225,11 @@ impl BenchmarkValue for DepositDetails { } #[cfg(feature = "runtime-benchmarks")] -impl BenchmarkValue for BtcDepositDetails { +impl BenchmarkValue for Utxo { fn benchmark_value() -> Self { - BtcDepositDetails { - utxo_id: UtxoId::benchmark_value(), + Utxo { + id: UtxoId::benchmark_value(), + amount: 10_000_000, deposit_address: crate::btc::deposit_address::DepositAddress::new([0; 32], 0), } } diff --git a/state-chain/chains/src/btc.rs b/state-chain/chains/src/btc.rs index 437ef73ffd..9789ddd423 100644 --- a/state-chain/chains/src/btc.rs +++ b/state-chain/chains/src/btc.rs @@ -7,8 +7,8 @@ pub mod utxo_selection; extern crate alloc; use self::deposit_address::DepositAddress; use crate::{ - benchmarking_value::BenchmarkValue, Chain, ChainCrypto, DepositChannel, FeeEstimationApi, - FeeRefundCalculator, RetryPolicy, + benchmarking_value::BenchmarkValue, Chain, ChainCrypto, DepositChannel, + DepositDetailsToTransactionInId, FeeEstimationApi, FeeRefundCalculator, RetryPolicy, }; use alloc::{collections::VecDeque, string::String}; use arrayref::array_ref; @@ -227,12 +227,6 @@ impl BitcoinFeeInfo { } } -#[derive(Encode, Decode, TypeInfo, Clone, RuntimeDebug, PartialEq, Eq, MaxEncodedLen)] -pub struct BtcDepositDetails { - pub utxo_id: UtxoId, - pub deposit_address: DepositAddress, -} - impl Chain for Bitcoin { const NAME: &'static str = "Bitcoin"; const GAS_ASSET: Self::ChainAsset = assets::btc::Asset::Btc; @@ -250,7 +244,7 @@ impl Chain for Bitcoin { type ChainAccount = ScriptPubkey; type DepositFetchId = BitcoinFetchId; type DepositChannelState = DepositAddress; - type DepositDetails = BtcDepositDetails; + type DepositDetails = Utxo; type Transaction = BitcoinTransactionData; type TransactionMetadata = (); type TransactionRef = Hash; @@ -406,6 +400,12 @@ impl Utxo { } } +impl DepositDetailsToTransactionInId for Utxo { + fn deposit_id(&self) -> Option { + Some(self.id.tx_id) + } +} + #[derive(Encode, Decode, TypeInfo, MaxEncodedLen, Clone, RuntimeDebug, PartialEq, Eq)] pub struct BitcoinOutput { pub amount: u64, diff --git a/state-chain/chains/src/btc/api.rs b/state-chain/chains/src/btc/api.rs index 97a1f3d2d9..d45fec6936 100644 --- a/state-chain/chains/src/btc/api.rs +++ b/state-chain/chains/src/btc/api.rs @@ -4,7 +4,7 @@ use super::{ deposit_address::DepositAddress, AggKey, Bitcoin, BitcoinCrypto, BitcoinOutput, BtcAmount, Utxo, BITCOIN_DUST_LIMIT, CHANGE_ADDRESS_SALT, }; -use crate::*; +use crate::{btc::BitcoinTransaction, *}; use frame_support::{CloneNoBound, DebugNoBound, EqNoBound, Never, PartialEqNoBound}; use sp_std::marker::PhantomData; @@ -13,6 +13,7 @@ use sp_std::marker::PhantomData; #[allow(clippy::large_enum_variant)] pub enum BitcoinApi { BatchTransfer(batch_transfer::BatchTransfer), + NoChangeTransfer(BitcoinTransaction), #[doc(hidden)] #[codec(skip)] _Phantom(PhantomData, Never), @@ -146,6 +147,25 @@ impl> ExecutexSwapAndCall for Bitc } } +impl> RejectCall for BitcoinApi +where + E: ChainEnvironment + + ChainEnvironment<(), AggKey>, +{ + fn new_unsigned( + deposit_details: ::DepositDetails, + refund_address: ::ChainAccount, + refund_amount: ::ChainAmount, + ) -> Result { + let agg_key = >::lookup(()).ok_or(RejectError::Other)?; + Ok(Self::NoChangeTransfer(BitcoinTransaction::create_new_unsigned( + &agg_key, + vec![deposit_details], + vec![BitcoinOutput { amount: refund_amount, script_pubkey: refund_address }], + ))) + } +} + // transfer_fallback is unsupported for Bitcoin. impl> TransferFallback for BitcoinApi { fn new_unsigned( @@ -159,7 +179,7 @@ impl ApiCall for BitcoinApi { fn threshold_signature_payload(&self) -> ::Payload { match self { BitcoinApi::BatchTransfer(tx) => tx.threshold_signature_payload(), - + BitcoinApi::NoChangeTransfer(tx) => tx.get_signing_payloads(), BitcoinApi::_Phantom(..) => unreachable!(), } } @@ -171,6 +191,10 @@ impl ApiCall for BitcoinApi { ) -> Self { match self { BitcoinApi::BatchTransfer(call) => call.signed(threshold_signature, signer).into(), + BitcoinApi::NoChangeTransfer(mut tx) => { + tx.add_signer_and_signatures(signer, threshold_signature.clone()); + Self::NoChangeTransfer(tx) + }, BitcoinApi::_Phantom(..) => unreachable!(), } } @@ -178,7 +202,7 @@ impl ApiCall for BitcoinApi { fn chain_encoded(&self) -> Vec { match self { BitcoinApi::BatchTransfer(call) => call.chain_encoded(), - + BitcoinApi::NoChangeTransfer(call) => call.clone().finalize(), BitcoinApi::_Phantom(..) => unreachable!(), } } @@ -186,7 +210,7 @@ impl ApiCall for BitcoinApi { fn is_signed(&self) -> bool { match self { BitcoinApi::BatchTransfer(call) => call.is_signed(), - + BitcoinApi::NoChangeTransfer(call) => call.is_signed(), BitcoinApi::_Phantom(..) => unreachable!(), } } @@ -194,6 +218,7 @@ impl ApiCall for BitcoinApi { fn transaction_out_id(&self) -> ::TransactionOutId { match self { BitcoinApi::BatchTransfer(call) => call.transaction_out_id(), + BitcoinApi::NoChangeTransfer(call) => call.txid(), BitcoinApi::_Phantom(..) => unreachable!(), } } @@ -205,6 +230,8 @@ impl ApiCall for BitcoinApi { fn signer(&self) -> Option<::AggKey> { match self { BitcoinApi::BatchTransfer(call) => call.signer(), + BitcoinApi::NoChangeTransfer(call) => + call.signer_and_signatures.as_ref().map(|(signer, _)| (*signer)), BitcoinApi::_Phantom(..) => unreachable!(), } } diff --git a/state-chain/chains/src/dot.rs b/state-chain/chains/src/dot.rs index 3eb846ab1f..d69f9335cb 100644 --- a/state-chain/chains/src/dot.rs +++ b/state-chain/chains/src/dot.rs @@ -520,6 +520,8 @@ pub enum PolkadotRuntimeCall { #[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] pub enum SystemCall {} +impl DepositDetailsToTransactionInId for u32 {} + #[allow(non_camel_case_types)] #[derive(Debug, Encode, Decode, Clone, Eq, PartialEq, TypeInfo)] pub enum BalancesCall { diff --git a/state-chain/chains/src/dot/api.rs b/state-chain/chains/src/dot/api.rs index 5cd8443f2e..c8208a2d72 100644 --- a/state-chain/chains/src/dot/api.rs +++ b/state-chain/chains/src/dot/api.rs @@ -145,6 +145,11 @@ where } } +impl RejectCall for PolkadotApi where + E: PolkadotEnvironment + ReplayProtectionProvider +{ +} + #[macro_export] macro_rules! map_over_api_variants { ( $self:expr, $var:pat_param, $var_method:expr $(,)* ) => { diff --git a/state-chain/chains/src/eth/api.rs b/state-chain/chains/src/eth/api.rs index 9eb4121f57..34d8b47ffe 100644 --- a/state-chain/chains/src/eth/api.rs +++ b/state-chain/chains/src/eth/api.rs @@ -237,6 +237,11 @@ where } } +impl RejectCall for EthereumApi where + E: EvmEnvironmentProvider + ReplayProtectionProvider +{ +} + impl From> for EthereumApi { diff --git a/state-chain/chains/src/evm.rs b/state-chain/chains/src/evm.rs index c157129acc..e2227afd6e 100644 --- a/state-chain/chains/src/evm.rs +++ b/state-chain/chains/src/evm.rs @@ -21,6 +21,8 @@ use serde::{Deserialize, Serialize}; use sp_core::ConstBool; use sp_std::{convert::TryFrom, str, vec}; +use crate::DepositDetailsToTransactionInId; + #[derive(Clone, Debug, PartialEq, Eq, Encode, Decode, TypeInfo, Default)] pub struct DepositDetails { // In the case of EVM Native Deposits (ETH or arbETH), because we need to detect ingresses by @@ -650,6 +652,12 @@ pub struct TransactionFee { pub gas_used: u128, } +impl DepositDetailsToTransactionInId for DepositDetails { + fn deposit_id(&self) -> Option { + None + } +} + #[cfg(test)] pub(crate) mod tests { use super::*; diff --git a/state-chain/chains/src/lib.rs b/state-chain/chains/src/lib.rs index 2b284c2b56..ecf088d655 100644 --- a/state-chain/chains/src/lib.rs +++ b/state-chain/chains/src/lib.rs @@ -260,7 +260,10 @@ pub trait Chain: Member + Parameter + ChainInstanceAlias { type DepositChannelState: Member + Parameter + ChannelLifecycleHooks + Unpin; /// Extra data associated with a deposit. - type DepositDetails: Member + Parameter + BenchmarkValue; + type DepositDetails: Member + + Parameter + + BenchmarkValue + + DepositDetailsToTransactionInId; type Transaction: Member + Parameter + BenchmarkValue + FeeRefundCalculator; @@ -522,10 +525,26 @@ pub enum ConsolidationError { Other, } +#[derive(Debug)] +pub enum RejectError { + NotSupportedForAsset, + Other, +} + pub trait ConsolidateCall: ApiCall { fn consolidate_utxos() -> Result; } +pub trait RejectCall: ApiCall { + fn new_unsigned( + _deposit_details: C::DepositDetails, + _refund_address: C::ChainAccount, + _refund_amount: C::ChainAmount, + ) -> Result { + Err(RejectError::NotSupportedForAsset) + } +} + pub trait AllBatch: ApiCall { fn new_unsigned( fetch_params: Vec>, @@ -815,3 +834,9 @@ pub enum RequiresSignatureRefresh> { False, _Phantom(PhantomData, Never), } + +pub trait DepositDetailsToTransactionInId { + fn deposit_id(&self) -> Option { + None + } +} diff --git a/state-chain/chains/src/mocks.rs b/state-chain/chains/src/mocks.rs index b51b494cae..2566fc1514 100644 --- a/state-chain/chains/src/mocks.rs +++ b/state-chain/chains/src/mocks.rs @@ -429,3 +429,9 @@ impl, Call: ApiCall> } } } + +impl DepositDetailsToTransactionInId for [u8; 4] { + fn deposit_id(&self) -> Option<[u8; 4]> { + Some(*self) + } +} diff --git a/state-chain/chains/src/sol.rs b/state-chain/chains/src/sol.rs index 351807c50f..fa583e5762 100644 --- a/state-chain/chains/src/sol.rs +++ b/state-chain/chains/src/sol.rs @@ -6,7 +6,10 @@ use sp_std::{vec, vec::Vec}; use sol_prim::{AccountBump, SlotNumber}; -use crate::{address, assets, DepositChannel, FeeEstimationApi, FeeRefundCalculator, TypeInfo}; +use crate::{ + address, assets, DepositChannel, DepositDetailsToTransactionInId, FeeEstimationApi, + FeeRefundCalculator, TypeInfo, +}; use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; use frame_support::{sp_runtime::RuntimeDebug, Parameter}; use serde::{Deserialize, Serialize}; @@ -387,3 +390,5 @@ pub struct SolApiEnvironment { pub usdc_token_mint_pubkey: SolAddress, pub usdc_token_vault_ata: SolAddress, } + +impl DepositDetailsToTransactionInId for () {} diff --git a/state-chain/chains/src/sol/api.rs b/state-chain/chains/src/sol/api.rs index b86ead8290..174a959859 100644 --- a/state-chain/chains/src/sol/api.rs +++ b/state-chain/chains/src/sol/api.rs @@ -1,3 +1,4 @@ +use crate::RejectCall; use cf_runtime_utilities::log_or_panic; use codec::{Decode, Encode}; use core::marker::PhantomData; @@ -532,3 +533,5 @@ impl SetGovKeyWithAggKey for Solan }) } } + +impl RejectCall for SolanaApi {} diff --git a/state-chain/pallets/cf-environment/src/lib.rs b/state-chain/pallets/cf-environment/src/lib.rs index 36e279aeae..600f165278 100644 --- a/state-chain/pallets/cf-environment/src/lib.rs +++ b/state-chain/pallets/cf-environment/src/lib.rs @@ -585,12 +585,8 @@ impl Pallet { }) } - pub fn add_bitcoin_utxo_to_list( - amount: BtcAmount, - utxo_id: UtxoId, - deposit_address: DepositAddress, - ) { - BitcoinAvailableUtxos::::append(Utxo { amount, id: utxo_id, deposit_address }); + pub fn add_bitcoin_utxo_to_list(utxo: Utxo) { + BitcoinAvailableUtxos::::append(utxo); } pub fn add_bitcoin_change_utxo(amount: BtcAmount, utxo_id: UtxoId, pubkey_x: [u8; 32]) { diff --git a/state-chain/pallets/cf-environment/src/tests.rs b/state-chain/pallets/cf-environment/src/tests.rs index 49b028d80a..1badb80228 100644 --- a/state-chain/pallets/cf-environment/src/tests.rs +++ b/state-chain/pallets/cf-environment/src/tests.rs @@ -28,11 +28,11 @@ fn utxo_with_key(pub_key: [u8; 32]) -> Utxo { } fn add_utxo_amount(amount: BtcAmount, salt: u32) { - Environment::add_bitcoin_utxo_to_list( + Environment::add_bitcoin_utxo_to_list(Utxo { + id: Default::default(), amount, - Default::default(), - DepositAddress::new(Default::default(), salt), - ); + deposit_address: DepositAddress::new(Default::default(), salt), + }); } #[test] diff --git a/state-chain/pallets/cf-ingress-egress/src/benchmarking.rs b/state-chain/pallets/cf-ingress-egress/src/benchmarking.rs index e5dc6a8942..8f34aaf07d 100644 --- a/state-chain/pallets/cf-ingress-egress/src/benchmarking.rs +++ b/state-chain/pallets/cf-ingress-egress/src/benchmarking.rs @@ -528,7 +528,7 @@ mod benchmarks { fn mark_transaction_as_tainted() { let caller = T::AccountRoleRegistry::whitelisted_caller_with_role(AccountRole::Broker).unwrap(); - let tx_id = <>::TargetChain as Chain>::DepositDetails::benchmark_value(); + let tx_id: TransactionInIdFor = TransactionInIdFor::::benchmark_value(); #[block] { diff --git a/state-chain/pallets/cf-ingress-egress/src/lib.rs b/state-chain/pallets/cf-ingress-egress/src/lib.rs index 7b8388bb35..c65293795c 100644 --- a/state-chain/pallets/cf-ingress-egress/src/lib.rs +++ b/state-chain/pallets/cf-ingress-egress/src/lib.rs @@ -28,9 +28,9 @@ use cf_chains::{ assets::any::GetChainAssetMap, ccm_checker::CcmValidityCheck, AllBatch, AllBatchError, CcmAdditionalData, CcmChannelMetadata, CcmDepositMetadata, - CcmFailReason, CcmMessage, Chain, ChannelLifecycleHooks, ChannelRefundParameters, - ConsolidateCall, DepositChannel, ExecutexSwapAndCall, FetchAssetParams, ForeignChainAddress, - SwapOrigin, TransferAssetParams, + CcmFailReason, CcmMessage, Chain, ChainCrypto, ChannelLifecycleHooks, ChannelRefundParameters, + ConsolidateCall, DepositChannel, DepositDetailsToTransactionInId, ExecutexSwapAndCall, + FetchAssetParams, ForeignChainAddress, RejectCall, SwapOrigin, TransferAssetParams, }; use cf_primitives::{ Asset, AssetAmount, BasisPoints, Beneficiaries, BoostPoolTier, BroadcastId, ChannelId, @@ -145,7 +145,7 @@ pub struct TaintedTransactionDetails, I: 'static> { pub refund_address: Option, pub asset: TargetChainAsset, pub amount: TargetChainAmount, - pub tx_id: ::DepositDetails, + pub deposit_details: ::DepositDetails, } /// Cross-chain messaging requests. @@ -267,6 +267,9 @@ pub mod pallet { pub(crate) type TargetChainBlockNumber = <>::TargetChain as Chain>::ChainBlockNumber; + pub type TransactionInIdFor = + <<>::TargetChain as Chain>::ChainCrypto as ChainCrypto>::TransactionInId; + #[derive(Clone, RuntimeDebug, PartialEq, Eq, Encode, Decode, TypeInfo, MaxEncodedLen)] pub struct DepositWitness { pub deposit_address: C::ChainAccount, @@ -408,7 +411,8 @@ pub mod pallet { type ChainApiCall: AllBatch + ExecutexSwapAndCall + TransferFallback - + ConsolidateCall; + + ConsolidateCall + + RejectCall; /// Get the latest chain state of the target chain. type ChainTracking: GetBlockHeight @@ -562,7 +566,7 @@ pub mod pallet { Identity, T::AccountId, Blake2_128Concat, - ::DepositDetails, + TransactionInIdFor, TaintedTransactionStatus, OptionQuery, >; @@ -573,7 +577,7 @@ pub mod pallet { _, Twox64Concat, BlockNumberFor, - Vec<(T::AccountId, ::DepositDetails)>, + Vec<(T::AccountId, TransactionInIdFor)>, ValueQuery, >; @@ -582,6 +586,11 @@ pub mod pallet { pub(crate) type ScheduledTxForReject, I: 'static = ()> = StorageValue<_, Vec>, ValueQuery>; + /// Stores the details of the tainted transactions that failed to be rejected. + #[pallet::storage] + pub(crate) type FailedRejections, I: 'static = ()> = + StorageValue<_, Vec>, ValueQuery>; + #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { @@ -717,17 +726,24 @@ pub mod pallet { }, TaintedTransactionReportReceived { account_id: T::AccountId, - tx_id: ::DepositDetails, + tx_id: TransactionInIdFor, expires_at: BlockNumberFor, }, TaintedTransactionReportExpired { account_id: T::AccountId, - tx_id: ::DepositDetails, + tx_id: TransactionInIdFor, }, CcmFallbackScheduled { broadcast_id: BroadcastId, egress_details: ScheduledEgressDetails, }, + TaintedTransactionRejected { + broadcast_id: BroadcastId, + tx_id: ::DepositDetails, + }, + FailedToRejectTaintedTransaction { + tx_id: ::DepositDetails, + }, } #[derive(CloneNoBound, PartialEqNoBound, EqNoBound)] @@ -913,6 +929,35 @@ pub mod pallet { }, } } + + for tx in ScheduledTxForReject::::take() { + if let Some(Ok(refund_address)) = tx.refund_address.clone().map(TryInto::try_into) { + if let Ok(api_call) = + >::new_unsigned( + tx.deposit_details.clone(), + refund_address, + tx.amount + .saturating_sub(T::ChainTracking::estimate_egress_fee(tx.asset)), + ) { + let (broadcast_id, _) = + T::Broadcaster::threshold_sign_and_broadcast(api_call); + Self::deposit_event(Event::::TaintedTransactionRejected { + broadcast_id, + tx_id: tx.deposit_details, + }); + } else { + FailedRejections::::append(tx.clone()); + Self::deposit_event(Event::::FailedToRejectTaintedTransaction { + tx_id: tx.deposit_details, + }); + } + } else { + FailedRejections::::append(tx.clone()); + Self::deposit_event(Event::::FailedToRejectTaintedTransaction { + tx_id: tx.deposit_details, + }); + } + } } } @@ -1223,7 +1268,7 @@ pub mod pallet { #[pallet::weight(T::WeightInfo::mark_transaction_as_tainted())] pub fn mark_transaction_as_tainted( origin: OriginFor, - tx_id: ::DepositDetails, + tx_id: TransactionInIdFor, ) -> DispatchResult { let account_id = T::AccountRoleRegistry::ensure_broker(origin)?; ensure!(T::AllowTransactionReports::get(), Error::::UnsupportedChain); @@ -1306,7 +1351,7 @@ impl, I: 'static> IngressSink for Pallet { impl, I: 'static> Pallet { fn mark_transaction_as_tainted_inner( account_id: T::AccountId, - tx_id: ::DepositDetails, + tx_id: TransactionInIdFor, ) -> DispatchResult { TaintedTransactions::::try_mutate(&account_id, &tx_id, |opt| { const UNSEEN: TaintedTransactionStatus = TaintedTransactionStatus::Unseen; @@ -1672,26 +1717,28 @@ impl, I: 'static> Pallet { } = DepositChannelLookup::::get(&deposit_address) .ok_or(Error::::InvalidDepositAddress)?; - if TaintedTransactions::::mutate(&owner, &deposit_details, |opt| { - match opt.as_mut() { - // Transaction has been reported, mark it as pre-witnessed. - Some(status @ TaintedTransactionStatus::Unseen) => { - *status = TaintedTransactionStatus::Prewitnessed; - true - }, - // Transaction has not been reported, mark it as boosted to prevent further - // reports. - None => { - let _ = opt.insert(TaintedTransactionStatus::Boosted); - false - }, - // Pre-witnessing twice or pre-witnessing after boosting is unlikely but - // possible. Either way we don't want to change the status. - Some(TaintedTransactionStatus::Prewitnessed) | - Some(TaintedTransactionStatus::Boosted) => true, + if let Some(tx_id) = deposit_details.deposit_id() { + if TaintedTransactions::::mutate(&owner, &tx_id, |opt| { + match opt.as_mut() { + // Transaction has been reported, mark it as pre-witnessed. + Some(status @ TaintedTransactionStatus::Unseen) => { + *status = TaintedTransactionStatus::Prewitnessed; + true + }, + // Transaction has not been reported, mark it as boosted to prevent further + // reports. + None => { + let _ = opt.insert(TaintedTransactionStatus::Boosted); + false + }, + // Pre-witnessing twice or pre-witnessing after boosting is unlikely but + // possible. Either way we don't want to change the status. + Some(TaintedTransactionStatus::Prewitnessed) | + Some(TaintedTransactionStatus::Boosted) => true, + } + }) { + continue; } - }) { - continue; } let prewitnessed_deposit_id = @@ -1915,33 +1962,37 @@ impl, I: 'static> Pallet { let channel_owner = deposit_channel_details.owner.clone(); - if matches!(TaintedTransactions::::take(&channel_owner, &deposit_details), + if let Some(tx_id) = deposit_details.deposit_id() { + if matches!(TaintedTransactions::::take(&channel_owner, &tx_id), Some(status) if status != TaintedTransactionStatus::Boosted) - { - let refund_address = match deposit_channel_details.action.clone() { - ChannelAction::Swap { refund_params, .. } => - refund_params.as_ref().map(|refund_params| refund_params.refund_address.clone()), - ChannelAction::CcmTransfer { refund_params, .. } => - refund_params.as_ref().map(|refund_params| refund_params.refund_address.clone()), - ChannelAction::LiquidityProvision { refund_address, .. } => refund_address, - }; + { + let refund_address = match deposit_channel_details.action.clone() { + ChannelAction::Swap { refund_params, .. } => refund_params + .as_ref() + .map(|refund_params| refund_params.refund_address.clone()), + ChannelAction::CcmTransfer { refund_params, .. } => refund_params + .as_ref() + .map(|refund_params| refund_params.refund_address.clone()), + ChannelAction::LiquidityProvision { refund_address, .. } => refund_address, + }; - let tainted_transaction_details = TaintedTransactionDetails { - refund_address, - amount: deposit_amount, - asset, - tx_id: deposit_details.clone(), - }; - ScheduledTxForReject::::append(tainted_transaction_details); + let tainted_transaction_details = TaintedTransactionDetails { + refund_address, + amount: deposit_amount, + asset, + deposit_details: deposit_details.clone(), + }; + ScheduledTxForReject::::append(tainted_transaction_details); - Self::deposit_event(Event::::DepositIgnored { - deposit_address: Some(deposit_address), - asset, - amount: deposit_amount, - deposit_details, - reason: DepositIgnoredReason::TransactionTainted, - }); - return Ok(()) + Self::deposit_event(Event::::DepositIgnored { + deposit_address: Some(deposit_address), + asset, + amount: deposit_amount, + deposit_details, + reason: DepositIgnoredReason::TransactionTainted, + }); + return Ok(()) + } } ScheduledEgressFetchOrTransfer::::append(FetchOrTransfer::::Fetch { @@ -1953,7 +2004,7 @@ impl, I: 'static> Pallet { Self::deposit_event(Event::::DepositFetchesScheduled { channel_id, asset }); // Add the deposit to the balance. - T::DepositHandler::on_deposit_made(deposit_details.clone(), deposit_amount); + T::DepositHandler::on_deposit_made(deposit_details.clone()); // We received a deposit on a channel. If channel has been boosted earlier // (i.e. awaiting finalisation), *and* the boosted amount matches the amount @@ -2074,7 +2125,7 @@ impl, I: 'static> Pallet { return; } - T::DepositHandler::on_deposit_made(deposit_details, deposit_amount); + T::DepositHandler::on_deposit_made(deposit_details); let destination_address_internal = match T::AddressConverter::decode_and_validate_address_for_asset( diff --git a/state-chain/pallets/cf-ingress-egress/src/tests.rs b/state-chain/pallets/cf-ingress-egress/src/tests.rs index 8269f302b3..a28b0afe30 100644 --- a/state-chain/pallets/cf-ingress-egress/src/tests.rs +++ b/state-chain/pallets/cf-ingress-egress/src/tests.rs @@ -1,29 +1,28 @@ mod boost; +mod screening; use crate::{ - mock_eth::*, BoostPoolId, BoostStatus, Call as PalletCall, ChannelAction, ChannelIdCounter, + mock_eth::*, BoostStatus, Call as PalletCall, ChannelAction, ChannelIdCounter, ChannelOpeningFee, CrossChainMessage, DepositAction, DepositChannelLookup, DepositChannelPool, DepositIgnoredReason, DepositWitness, DisabledEgressAssets, EgressDustLimit, Event as PalletEvent, FailedForeignChainCall, FailedForeignChainCalls, FetchOrTransfer, MinimumDeposit, Pallet, PalletConfigUpdate, PalletSafeMode, PrewitnessedDepositIdCounter, - ReportExpiresAt, ScheduledEgressCcm, ScheduledEgressFetchOrTransfer, ScheduledTxForReject, - TaintedTransactionStatus, TaintedTransactions, TAINTED_TX_EXPIRATION_BLOCKS, + ScheduledEgressCcm, ScheduledEgressFetchOrTransfer, }; use cf_chains::{ address::{AddressConverter, EncodedAddress}, assets::eth::Asset as EthAsset, btc::{BitcoinNetwork, ScriptPubkey}, - evm::{self, DepositDetails, EvmFetchId}, + evm::{DepositDetails, EvmFetchId}, mocks::MockEthereum, CcmChannelMetadata, CcmFailReason, DepositChannel, ExecutexSwapAndCall, SwapOrigin, TransferAssetParams, }; -use cf_primitives::{AssetAmount, Beneficiaries, ChannelId, ForeignChain}; +use cf_primitives::{AssetAmount, ChannelId, ForeignChain}; use cf_test_utilities::{assert_events_eq, assert_has_event, assert_has_matching_event}; use cf_traits::{ mocks::{ self, - account_role_registry::MockAccountRoleRegistry, address_converter::MockAddressConverter, api_call::{MockEthAllBatch, MockEthereumApiCall, MockEvmEnvironment}, asset_converter::MockAssetConverter, @@ -35,17 +34,16 @@ use cf_traits::{ funding_info::MockFundingInfo, swap_request_api::{MockSwapRequest, MockSwapRequestHandler}, }, - AccountRoleRegistry, BalanceApi, DepositApi, EgressApi, EpochInfo, - FetchesTransfersLimitProvider, FundingInfo, GetBlockHeight, SafeMode, ScheduledEgressDetails, - SwapRequestType, + BalanceApi, DepositApi, EgressApi, EpochInfo, FetchesTransfersLimitProvider, FundingInfo, + GetBlockHeight, SafeMode, ScheduledEgressDetails, SwapRequestType, }; use frame_support::{ assert_err, assert_noop, assert_ok, traits::{Hooks, OriginTrait}, weights::Weight, }; -use sp_core::{H160, H256}; -use sp_runtime::{DispatchError, DispatchError::BadOrigin}; +use sp_core::H160; +use sp_runtime::DispatchError; const ALICE_ETH_ADDRESS: EthereumAddress = H160([100u8; 20]); const BOB_ETH_ADDRESS: EthereumAddress = H160([101u8; 20]); @@ -1981,289 +1979,3 @@ fn failed_ccm_deposit_can_deposit_event() { ); }); } - -#[test] -fn process_tainted_transaction_and_expect_refund() { - new_test_ext().execute_with(|| { - let (_, address) = request_address_and_deposit(BROKER, EthAsset::Eth); - let _ = DepositChannelLookup::::get(address).unwrap(); - - let deposit_details: cf_chains::evm::DepositDetails = Default::default(); - - assert_ok!(>::register_as_broker( - &BROKER, - )); - - assert_ok!(IngressEgress::mark_transaction_as_tainted( - OriginTrait::signed(BROKER), - Default::default(), - )); - - assert_ok!(IngressEgress::process_single_deposit( - address, - EthAsset::Eth, - DEFAULT_DEPOSIT_AMOUNT, - deposit_details, - Default::default() - )); - - assert_has_matching_event!( - Test, - RuntimeEvent::IngressEgress(crate::Event::::DepositIgnored { - deposit_address: _address, - asset: EthAsset::Eth, - amount: DEFAULT_DEPOSIT_AMOUNT, - deposit_details: _, - reason: DepositIgnoredReason::TransactionTainted, - }) - ); - - assert_eq!(ScheduledTxForReject::::decode_len(), Some(1)); - }); -} - -#[test] -fn only_broker_can_mark_transaction_as_tainted() { - new_test_ext().execute_with(|| { - assert_noop!( - IngressEgress::mark_transaction_as_tainted( - OriginTrait::signed(ALICE), - Default::default(), - ), - BadOrigin - ); - - assert_ok!(>::register_as_broker( - &BROKER, - )); - - assert_ok!(IngressEgress::mark_transaction_as_tainted( - OriginTrait::signed(BROKER), - Default::default(), - )); - }); -} - -#[test] -fn tainted_transactions_expire_if_not_witnessed() { - new_test_ext().execute_with(|| { - let tx_id = DepositDetails::default(); - let expiry_at = System::block_number() + TAINTED_TX_EXPIRATION_BLOCKS as u64; - - let (_, address) = request_address_and_deposit(BROKER, EthAsset::Eth); - let _ = DepositChannelLookup::::get(address).unwrap(); - - assert_ok!(>::register_as_broker( - &BROKER, - )); - - assert_ok!(IngressEgress::mark_transaction_as_tainted( - OriginTrait::signed(BROKER), - Default::default(), - )); - - System::set_block_number(expiry_at); - - IngressEgress::on_idle(expiry_at, Weight::MAX); - - assert!(!TaintedTransactions::::contains_key(BROKER, tx_id)); - - assert_has_event::(RuntimeEvent::IngressEgress( - crate::Event::TaintedTransactionReportExpired { - account_id: BROKER, - tx_id: Default::default(), - }, - )); - }); -} - -fn setup_boost_swap() -> ForeignChainAddress { - assert_ok!( - >::register_as_liquidity_provider( - &ALICE, - ) - ); - - assert_ok!(IngressEgress::create_boost_pools( - RuntimeOrigin::root(), - vec![BoostPoolId { asset: EthAsset::Eth, tier: 10 }], - )); - - ::Balance::try_credit_account(&ALICE, EthAsset::Eth.into(), 1000) - .unwrap(); - - let (_, address, _, _) = IngressEgress::request_swap_deposit_address( - EthAsset::Eth, - EthAsset::Eth.into(), - ForeignChainAddress::Eth(Default::default()), - Beneficiaries::new(), - BROKER, - None, - 10, - None, - None, - ) - .unwrap(); - - assert_ok!(IngressEgress::add_boost_funds( - RuntimeOrigin::signed(ALICE), - EthAsset::Eth, - 1000, - 10 - )); - - address -} - -#[test] -fn finalize_boosted_tx_if_tainted_after_prewitness() { - new_test_ext().execute_with(|| { - let tx_id = DepositDetails::default(); - - assert_ok!(>::register_as_broker( - &BROKER, - )); - - let address: ::ChainAccount = setup_boost_swap().try_into().unwrap(); - - let _ = IngressEgress::add_prewitnessed_deposits( - vec![DepositWitness { - deposit_address: address, - asset: EthAsset::Eth, - amount: DEFAULT_DEPOSIT_AMOUNT, - deposit_details: tx_id.clone(), - }], - 10, - ); - - assert_noop!( - IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), tx_id.clone(),), - crate::Error::::TransactionAlreadyPrewitnessed - ); - - assert_ok!(IngressEgress::process_single_deposit( - address, - EthAsset::Eth, - DEFAULT_DEPOSIT_AMOUNT, - tx_id, - Default::default() - )); - - assert_has_matching_event!( - Test, - RuntimeEvent::IngressEgress(crate::Event::DepositFinalised { - deposit_address: _, - asset: EthAsset::Eth, - .. - }) - ); - }); -} - -#[test] -fn reject_tx_if_tainted_before_prewitness() { - new_test_ext().execute_with(|| { - let tx_id = DepositDetails::default(); - - assert_ok!(>::register_as_broker( - &BROKER, - )); - - let address: ::ChainAccount = setup_boost_swap().try_into().unwrap(); - - assert_ok!(IngressEgress::mark_transaction_as_tainted( - OriginTrait::signed(BROKER), - tx_id.clone(), - )); - - let _ = IngressEgress::add_prewitnessed_deposits( - vec![DepositWitness { - deposit_address: address, - asset: EthAsset::Eth, - amount: DEFAULT_DEPOSIT_AMOUNT, - deposit_details: tx_id.clone(), - }], - 10, - ); - - assert_ok!(IngressEgress::process_single_deposit( - address, - EthAsset::Eth, - DEFAULT_DEPOSIT_AMOUNT, - tx_id, - Default::default() - )); - - assert_has_matching_event!( - Test, - RuntimeEvent::IngressEgress(crate::Event::DepositIgnored { - deposit_address: _, - asset: EthAsset::Eth, - amount: DEFAULT_DEPOSIT_AMOUNT, - deposit_details: _, - reason: DepositIgnoredReason::TransactionTainted, - }) - ); - }); -} - -#[test] -fn do_not_expire_tainted_transactions_if_prewitnessed() { - new_test_ext().execute_with(|| { - let tx_id = DepositDetails::default(); - let expiry_at = System::block_number() + TAINTED_TX_EXPIRATION_BLOCKS as u64; - - TaintedTransactions::::insert( - BROKER, - &tx_id, - TaintedTransactionStatus::Prewitnessed, - ); - - ReportExpiresAt::::insert(expiry_at, vec![(BROKER, tx_id.clone())]); - - IngressEgress::on_idle(expiry_at, Weight::MAX); - - assert!(TaintedTransactions::::contains_key(BROKER, tx_id)); - }); -} - -#[test] -fn can_not_report_transaction_after_witnessing() { - new_test_ext().execute_with(|| { - assert_ok!(>::register_as_broker( - &BROKER, - )); - let unreported = evm::DepositDetails { tx_hashes: Some(vec![H256::random()]) }; - let unseen = evm::DepositDetails { tx_hashes: Some(vec![H256::random()]) }; - let prewitnessed = evm::DepositDetails { tx_hashes: Some(vec![H256::random()]) }; - let boosted = evm::DepositDetails { tx_hashes: Some(vec![H256::random()]) }; - - TaintedTransactions::::insert(BROKER, &unseen, TaintedTransactionStatus::Unseen); - TaintedTransactions::::insert( - BROKER, - &prewitnessed, - TaintedTransactionStatus::Prewitnessed, - ); - TaintedTransactions::::insert( - BROKER, - &boosted, - TaintedTransactionStatus::Boosted, - ); - - assert_ok!(IngressEgress::mark_transaction_as_tainted( - OriginTrait::signed(BROKER), - unreported, - )); - assert_ok!( - IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), unseen,) - ); - assert_noop!( - IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), prewitnessed,), - crate::Error::::TransactionAlreadyPrewitnessed - ); - assert_noop!( - IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), boosted,), - crate::Error::::TransactionAlreadyPrewitnessed - ); - }); -} diff --git a/state-chain/pallets/cf-ingress-egress/src/tests/screening.rs b/state-chain/pallets/cf-ingress-egress/src/tests/screening.rs new file mode 100644 index 0000000000..4daf026526 --- /dev/null +++ b/state-chain/pallets/cf-ingress-egress/src/tests/screening.rs @@ -0,0 +1,375 @@ +use crate::{ + mock_btc::*, + tests::{ALICE, BROKER}, + BoostPoolId, DepositChannelLookup, DepositIgnoredReason, DepositWitness, ReportExpiresAt, + ScheduledTxForReject, TaintedTransactionDetails, TaintedTransactionStatus, TaintedTransactions, + TAINTED_TX_EXPIRATION_BLOCKS, +}; + +use frame_support::{ + assert_noop, assert_ok, + traits::{Hooks, OriginTrait}, + weights::Weight, +}; + +use cf_chains::{ + btc::{deposit_address::DepositAddress, Hash, ScriptPubkey, UtxoId}, + ForeignChainAddress, +}; + +use cf_traits::{ + mocks::account_role_registry::MockAccountRoleRegistry, AccountRoleRegistry, BalanceApi, + DepositApi, +}; + +use cf_primitives::{chains::assets::btc, Beneficiaries, ChannelId}; +use cf_test_utilities::{assert_has_event, assert_has_matching_event}; +use sp_runtime::DispatchError::BadOrigin; + +const DEFAULT_DEPOSIT_AMOUNT: u64 = 1_000; +const DEFAULT_BTC_ADDRESS: [u8; 20] = [0; 20]; + +mod helpers { + + use super::*; + use cf_chains::btc::Utxo; + + pub fn generate_btc_deposit(tx_id: Hash) -> Utxo { + Utxo { + amount: DEFAULT_DEPOSIT_AMOUNT, + id: UtxoId { tx_id, vout: 0 }, + deposit_address: DepositAddress { pubkey_x: [0; 32], script_path: None }, + } + } + + pub fn request_address_and_deposit( + who: ChannelId, + asset: btc::Asset, + deposit_details: Utxo, + ) -> (ChannelId, ::ChainAccount) { + let (id, address, ..) = IngressEgress::request_liquidity_deposit_address( + who, + asset, + 0, + ForeignChainAddress::Btc(ScriptPubkey::P2SH(DEFAULT_BTC_ADDRESS)), + ) + .unwrap(); + let address: ::ChainAccount = address.try_into().unwrap(); + assert_ok!(IngressEgress::process_single_deposit( + address.clone(), + asset, + DEFAULT_DEPOSIT_AMOUNT, + deposit_details, + Default::default() + )); + (id, address) + } + + pub fn setup_boost_swap() -> ForeignChainAddress { + assert_ok!( + >::register_as_liquidity_provider( + &ALICE, + ) + ); + + assert_ok!(IngressEgress::create_boost_pools( + RuntimeOrigin::root(), + vec![BoostPoolId { asset: btc::Asset::Btc, tier: 10 }], + )); + + ::Balance::try_credit_account(&ALICE, btc::Asset::Btc.into(), 1000) + .unwrap(); + + let (_, address, _, _) = IngressEgress::request_swap_deposit_address( + btc::Asset::Btc, + btc::Asset::Btc.into(), + ForeignChainAddress::Btc(ScriptPubkey::P2SH(DEFAULT_BTC_ADDRESS)), + Beneficiaries::new(), + BROKER, + None, + 10, + None, + None, + ) + .unwrap(); + + assert_ok!(IngressEgress::add_boost_funds( + RuntimeOrigin::signed(ALICE), + btc::Asset::Btc, + 1000, + 10 + )); + + address + } +} + +#[test] +fn process_tainted_transaction_and_expect_refund() { + new_test_ext().execute_with(|| { + let tx_in_id = Hash::random(); + let deposit_details = helpers::generate_btc_deposit(tx_in_id); + let (_, address) = + helpers::request_address_and_deposit(BROKER, btc::Asset::Btc, deposit_details.clone()); + let _ = DepositChannelLookup::::get(address.clone()).unwrap(); + + assert_ok!(>::register_as_broker( + &BROKER, + )); + + assert_ok!(IngressEgress::mark_transaction_as_tainted( + OriginTrait::signed(BROKER), + tx_in_id, + )); + + assert_ok!(IngressEgress::process_single_deposit( + address, + btc::Asset::Btc, + DEFAULT_DEPOSIT_AMOUNT, + deposit_details, + Default::default() + )); + + assert_has_matching_event!( + Test, + RuntimeEvent::IngressEgress(crate::Event::::DepositIgnored { + deposit_address: _address, + asset: btc::Asset::Btc, + amount: DEFAULT_DEPOSIT_AMOUNT, + deposit_details: _, + reason: DepositIgnoredReason::TransactionTainted, + }) + ); + + assert_eq!(ScheduledTxForReject::::decode_len(), Some(1)); + }); +} + +#[test] +fn finalize_boosted_tx_if_tainted_after_prewitness() { + new_test_ext().execute_with(|| { + let tx_id = Hash::random(); + let deposit_details = helpers::generate_btc_deposit(tx_id); + + assert_ok!(>::register_as_broker( + &BROKER, + )); + + let address: ::ChainAccount = + helpers::setup_boost_swap().try_into().unwrap(); + + let _ = IngressEgress::add_prewitnessed_deposits( + vec![DepositWitness { + deposit_address: address.clone(), + asset: btc::Asset::Btc, + amount: DEFAULT_DEPOSIT_AMOUNT, + deposit_details: deposit_details.clone(), + }], + 10, + ); + + assert_noop!( + IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), tx_id,), + crate::Error::::TransactionAlreadyPrewitnessed + ); + + assert_ok!(IngressEgress::process_single_deposit( + address, + btc::Asset::Btc, + DEFAULT_DEPOSIT_AMOUNT, + deposit_details, + Default::default() + )); + + assert_has_matching_event!( + Test, + RuntimeEvent::IngressEgress(crate::Event::DepositFinalised { + deposit_address: _, + asset: btc::Asset::Btc, + .. + }) + ); + }); +} + +#[test] +fn reject_tx_if_tainted_before_prewitness() { + new_test_ext().execute_with(|| { + let tx_id = Hash::random(); + let deposit_details = helpers::generate_btc_deposit(tx_id); + + assert_ok!(>::register_as_broker( + &BROKER, + )); + + let address: ::ChainAccount = + helpers::setup_boost_swap().try_into().unwrap(); + + assert_ok!(IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), tx_id,)); + + let _ = IngressEgress::add_prewitnessed_deposits( + vec![DepositWitness { + deposit_address: address.clone(), + asset: btc::Asset::Btc, + amount: DEFAULT_DEPOSIT_AMOUNT, + deposit_details: deposit_details.clone(), + }], + 10, + ); + + assert_ok!(IngressEgress::process_single_deposit( + address, + btc::Asset::Btc, + DEFAULT_DEPOSIT_AMOUNT, + deposit_details, + Default::default() + )); + + assert_has_matching_event!( + Test, + RuntimeEvent::IngressEgress(crate::Event::DepositIgnored { + deposit_address: _, + asset: btc::Asset::Btc, + amount: DEFAULT_DEPOSIT_AMOUNT, + deposit_details: _, + reason: DepositIgnoredReason::TransactionTainted, + }) + ); + }); +} + +#[test] +fn tainted_transactions_expire_if_not_witnessed() { + new_test_ext().execute_with(|| { + let tx_id = Hash::random(); + let deposit_details = helpers::generate_btc_deposit(tx_id); + let expiry_at = System::block_number() + TAINTED_TX_EXPIRATION_BLOCKS as u64; + + let (_, address) = + helpers::request_address_and_deposit(BROKER, btc::Asset::Btc, deposit_details); + let _ = DepositChannelLookup::::get(address).unwrap(); + + assert_ok!(>::register_as_broker( + &BROKER, + )); + + assert_ok!(IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), tx_id,)); + + System::set_block_number(expiry_at); + + IngressEgress::on_idle(expiry_at, Weight::MAX); + + assert!(!TaintedTransactions::::contains_key(BROKER, tx_id)); + + assert_has_event::(RuntimeEvent::IngressEgress( + crate::Event::TaintedTransactionReportExpired { account_id: BROKER, tx_id }, + )); + }); +} + +#[test] +fn only_broker_can_mark_transaction_as_tainted() { + new_test_ext().execute_with(|| { + assert_noop!( + IngressEgress::mark_transaction_as_tainted( + OriginTrait::signed(ALICE), + Default::default(), + ), + BadOrigin + ); + + assert_ok!(>::register_as_broker( + &BROKER, + )); + + assert_ok!(IngressEgress::mark_transaction_as_tainted( + OriginTrait::signed(BROKER), + Default::default(), + )); + }); +} + +#[test] +fn do_not_expire_tainted_transactions_if_prewitnessed() { + new_test_ext().execute_with(|| { + let tx_id = Hash::random(); + let expiry_at = System::block_number() + TAINTED_TX_EXPIRATION_BLOCKS as u64; + + TaintedTransactions::::insert( + BROKER, + tx_id, + TaintedTransactionStatus::Prewitnessed, + ); + + ReportExpiresAt::::insert(expiry_at, vec![(BROKER, tx_id)]); + + IngressEgress::on_idle(expiry_at, Weight::MAX); + + assert!(TaintedTransactions::::contains_key(BROKER, tx_id)); + }); +} + +#[test] +fn can_not_report_transaction_after_witnessing() { + new_test_ext().execute_with(|| { + assert_ok!(>::register_as_broker( + &BROKER, + )); + + let unreported = Hash::random(); + let unseen = Hash::random(); + let prewitnessed = Hash::random(); + let boosted = Hash::random(); + + TaintedTransactions::::insert(BROKER, unseen, TaintedTransactionStatus::Unseen); + TaintedTransactions::::insert( + BROKER, + prewitnessed, + TaintedTransactionStatus::Prewitnessed, + ); + TaintedTransactions::::insert(BROKER, boosted, TaintedTransactionStatus::Boosted); + + assert_ok!(IngressEgress::mark_transaction_as_tainted( + OriginTrait::signed(BROKER), + unreported, + )); + assert_ok!( + IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), unseen,) + ); + assert_noop!( + IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), prewitnessed,), + crate::Error::::TransactionAlreadyPrewitnessed + ); + assert_noop!( + IngressEgress::mark_transaction_as_tainted(OriginTrait::signed(BROKER), boosted,), + crate::Error::::TransactionAlreadyPrewitnessed + ); + }); +} + +#[test] +fn send_funds_back_after_they_have_been_rejected() { + new_test_ext().execute_with(|| { + let deposit_details = helpers::generate_btc_deposit(Hash::random()); + let tainted_tx_details = TaintedTransactionDetails { + refund_address: Some(ForeignChainAddress::Btc(ScriptPubkey::P2SH(DEFAULT_BTC_ADDRESS))), + amount: DEFAULT_DEPOSIT_AMOUNT, + asset: btc::Asset::Btc, + deposit_details, + }; + + ScheduledTxForReject::::append(tainted_tx_details); + + IngressEgress::on_finalize(1); + + assert_eq!(ScheduledTxForReject::::decode_len(), None); + + assert_has_matching_event!( + Test, + RuntimeEvent::IngressEgress(crate::Event::TaintedTransactionRejected { + broadcast_id: _, + tx_id: _, + }) + ); + }); +} diff --git a/state-chain/runtime/src/chainflip.rs b/state-chain/runtime/src/chainflip.rs index 373cef9289..35e20db33c 100644 --- a/state-chain/runtime/src/chainflip.rs +++ b/state-chain/runtime/src/chainflip.rs @@ -31,7 +31,7 @@ use cf_chains::{ assets::any::ForeignChainAndAsset, btc::{ api::{BitcoinApi, SelectedUtxosAndChangeAmount, UtxoSelectionType}, - Bitcoin, BitcoinCrypto, BitcoinFeeInfo, BitcoinTransactionData, BtcDepositDetails, UtxoId, + Bitcoin, BitcoinCrypto, BitcoinFeeInfo, BitcoinTransactionData, Utxo, UtxoId, }, dot::{ api::PolkadotApi, Polkadot, PolkadotAccountId, PolkadotCrypto, PolkadotReplayProtection, @@ -768,15 +768,8 @@ pub struct DepositHandler; impl OnDeposit for DepositHandler {} impl OnDeposit for DepositHandler {} impl OnDeposit for DepositHandler { - fn on_deposit_made( - deposit_details: BtcDepositDetails, - amount: ::ChainAmount, - ) { - Environment::add_bitcoin_utxo_to_list( - amount, - deposit_details.utxo_id, - deposit_details.deposit_address, - ) + fn on_deposit_made(utxo: Utxo) { + Environment::add_bitcoin_utxo_to_list(utxo) } } impl OnDeposit for DepositHandler {} @@ -818,29 +811,26 @@ impl OnBroadcastReady for BroadcastReadyProvider { type ApiCall = BitcoinApi; fn on_broadcast_ready(api_call: &Self::ApiCall) { - match api_call { - BitcoinApi::BatchTransfer(batch_transfer) => { - let tx_id = batch_transfer.bitcoin_transaction.txid(); - let outputs = &batch_transfer.bitcoin_transaction.outputs; - let btc_key = pallet_cf_threshold_signature::Pallet::::keys( - pallet_cf_threshold_signature::Pallet::::current_key_epoch() - .expect("We should always have an epoch set")).expect("We should always have a key set for the current epoch"); - for (i, output) in outputs.iter().enumerate() { - if [ - ScriptPubkey::Taproot(btc_key.previous.unwrap_or_default()), - ScriptPubkey::Taproot(btc_key.current), - ] - .contains(&output.script_pubkey) - { - Environment::add_bitcoin_change_utxo( - output.amount, - UtxoId { tx_id, vout: i as u32 }, - batch_transfer.change_utxo_key, - ); - } + if let BitcoinApi::BatchTransfer(batch_transfer) = api_call { + let tx_id = batch_transfer.bitcoin_transaction.txid(); + let outputs = &batch_transfer.bitcoin_transaction.outputs; + let btc_key = pallet_cf_threshold_signature::Pallet::::keys( + pallet_cf_threshold_signature::Pallet::::current_key_epoch() + .expect("We should always have an epoch set")).expect("We should always have a key set for the current epoch"); + for (i, output) in outputs.iter().enumerate() { + if [ + ScriptPubkey::Taproot(btc_key.previous.unwrap_or_default()), + ScriptPubkey::Taproot(btc_key.current), + ] + .contains(&output.script_pubkey) + { + Environment::add_bitcoin_change_utxo( + output.amount, + UtxoId { tx_id, vout: i as u32 }, + batch_transfer.change_utxo_key, + ); } - }, - _ => unreachable!(), + } } } } diff --git a/state-chain/traits/src/lib.rs b/state-chain/traits/src/lib.rs index d676d165e6..aa8679c210 100644 --- a/state-chain/traits/src/lib.rs +++ b/state-chain/traits/src/lib.rs @@ -898,7 +898,7 @@ pub trait FlipBurnInfo { /// The trait implementation is intentionally no-op by default pub trait OnDeposit { - fn on_deposit_made(_deposit_details: C::DepositDetails, _amount: C::ChainAmount) {} + fn on_deposit_made(_deposit_details: C::DepositDetails) {} } pub trait NetworkEnvironmentProvider { diff --git a/state-chain/traits/src/mocks/api_call.rs b/state-chain/traits/src/mocks/api_call.rs index 05ee49ecdc..63dbd93b6e 100644 --- a/state-chain/traits/src/mocks/api_call.rs +++ b/state-chain/traits/src/mocks/api_call.rs @@ -3,8 +3,8 @@ use core::marker::PhantomData; use cf_chains::{ btc::BitcoinCrypto, evm::EvmCrypto, AllBatch, AllBatchError, ApiCall, Bitcoin, Chain, ChainCrypto, ChainEnvironment, ConsolidationError, Ethereum, ExecutexSwapAndCall, - ExecutexSwapAndCallError, FetchAssetParams, ForeignChainAddress, TransferAssetParams, - TransferFallback, TransferFallbackError, + ExecutexSwapAndCallError, FetchAssetParams, ForeignChainAddress, RejectCall, RejectError, + TransferAssetParams, TransferFallback, TransferFallbackError, }; use cf_primitives::{chains::assets, EgressId, ForeignChain}; use codec::{Decode, Encode}; @@ -36,6 +36,7 @@ pub enum MockEthereumApiCall { AllBatch(MockEthAllBatch), ExecutexSwapAndCall(MockEthExecutexSwapAndCall), TransferFallback(MockEthTransferFallback), + RejectCall, } impl ApiCall for MockEthereumApiCall { @@ -206,6 +207,7 @@ pub enum MockBitcoinApiCall { AllBatch(MockBtcAllBatch), ExecutexSwapAndCall(MockBtcExecutexSwapAndCall), TransferFallback(MockBtcTransferFallback), + RejectCall, } impl ApiCall for MockBitcoinApiCall { @@ -335,3 +337,23 @@ impl AllBatch for MockBitcoinApiCall { } } } + +impl RejectCall for MockBitcoinApiCall { + fn new_unsigned( + _deposit_details: ::DepositDetails, + _refund_address: ::ChainAccount, + _refund_amount: ::ChainAmount, + ) -> Result { + Ok(Self::RejectCall) + } +} + +impl RejectCall for MockEthereumApiCall { + fn new_unsigned( + _deposit_details: ::DepositDetails, + _refund_address: ::ChainAccount, + _refund_amount: ::ChainAmount, + ) -> Result { + Ok(Self::RejectCall) + } +}