From 1339209477e55eb52885c905df9475ab2bd871c3 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:11:04 +0200 Subject: [PATCH 01/19] update ibc-rs rev --- Cargo.lock | 372 ++++++++++++++++++++++++++++------------------------- Cargo.toml | 4 +- 2 files changed, 200 insertions(+), 176 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1db5ba1..3b86a62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "anstream" @@ -68,21 +68,21 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-stream" @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", @@ -131,9 +131,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "axum" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" dependencies = [ "async-trait", "axum-core", @@ -151,16 +151,16 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 1.0.1", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", "bytes", @@ -171,24 +171,24 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", ] [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -271,7 +271,7 @@ dependencies = [ "tendermint-abci", "tendermint-proto", "tonic", - "tower", + "tower 0.4.13", "tower-abci", "tracing", ] @@ -409,9 +409,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", "arrayvec", @@ -461,18 +461,21 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] [[package]] name = "cc" -version = "1.1.8" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504bdec147f2cc13c8b57ed9401fd8a147cc66b67ad5cb241394244f2c947549" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -482,9 +485,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.14" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c937d4061031a6d0c8da4b9a4f98a172fc2976dfb1c19213a9cf7d0d3c837e36" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -492,9 +495,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.14" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85379ba512b21a328adf887e85f7742d12e96eb31f3ef077df4ffc26b506ffed" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -505,9 +508,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -535,9 +538,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "core-foundation" @@ -551,9 +554,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cosmos-sdk-proto" @@ -588,9 +591,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -953,9 +956,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "group" @@ -980,18 +983,18 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.3.0", + "indexmap 2.5.0", "slab", "tokio", - "tokio-util 0.7.11", + "tokio-util 0.7.12", "tracing", ] [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -999,10 +1002,10 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.3.0", + "indexmap 2.5.0", "slab", "tokio", - "tokio-util 0.7.11", + "tokio-util 0.7.12", "tracing", ] @@ -1180,7 +1183,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -1221,9 +1224,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1234,7 +1237,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -1242,7 +1244,7 @@ dependencies = [ [[package]] name = "ibc" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-apps", "ibc-clients", @@ -1255,7 +1257,7 @@ dependencies = [ [[package]] name = "ibc-app-transfer" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-app-transfer-types", "ibc-core", @@ -1265,7 +1267,7 @@ dependencies = [ [[package]] name = "ibc-app-transfer-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1279,7 +1281,7 @@ dependencies = [ [[package]] name = "ibc-apps" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-app-transfer", ] @@ -1287,7 +1289,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "ibc-client-tendermint-types", @@ -1304,7 +1306,7 @@ dependencies = [ [[package]] name = "ibc-client-tendermint-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "displaydoc", "ibc-core-client-types", @@ -1321,7 +1323,7 @@ dependencies = [ [[package]] name = "ibc-client-wasm-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "base64 0.22.1", "displaydoc", @@ -1335,7 +1337,7 @@ dependencies = [ [[package]] name = "ibc-clients" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-client-tendermint", "ibc-client-wasm-types", @@ -1344,7 +1346,7 @@ dependencies = [ [[package]] name = "ibc-core" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -1360,13 +1362,12 @@ dependencies = [ [[package]] name = "ibc-core-channel" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-core-channel-types", "ibc-core-client", "ibc-core-commitment-types", "ibc-core-connection", - "ibc-core-connection-types", "ibc-core-handler-types", "ibc-core-host", "ibc-core-router", @@ -1376,7 +1377,7 @@ dependencies = [ [[package]] name = "ibc-core-channel-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1395,7 +1396,7 @@ dependencies = [ [[package]] name = "ibc-core-client" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-core-client-context", "ibc-core-client-types", @@ -1408,7 +1409,7 @@ dependencies = [ [[package]] name = "ibc-core-client-context" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1424,7 +1425,7 @@ dependencies = [ [[package]] name = "ibc-core-client-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1440,7 +1441,7 @@ dependencies = [ [[package]] name = "ibc-core-commitment-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1455,7 +1456,7 @@ dependencies = [ [[package]] name = "ibc-core-connection" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-core-client", "ibc-core-connection-types", @@ -1467,7 +1468,7 @@ dependencies = [ [[package]] name = "ibc-core-connection-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1484,7 +1485,7 @@ dependencies = [ [[package]] name = "ibc-core-handler" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "ibc-core-channel", "ibc-core-client", @@ -1499,7 +1500,7 @@ dependencies = [ [[package]] name = "ibc-core-handler-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1519,7 +1520,7 @@ dependencies = [ [[package]] name = "ibc-core-host" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1537,7 +1538,7 @@ dependencies = [ [[package]] name = "ibc-core-host-cosmos" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1560,18 +1561,20 @@ dependencies = [ [[package]] name = "ibc-core-host-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ + "base64 0.22.1", "derive_more", "displaydoc", "ibc-primitives", + "prost", "serde", ] [[package]] name = "ibc-core-router" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1585,7 +1588,7 @@ dependencies = [ [[package]] name = "ibc-core-router-types" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1600,7 +1603,7 @@ dependencies = [ [[package]] name = "ibc-derive" version = "0.8.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "proc-macro2", "quote", @@ -1610,7 +1613,7 @@ dependencies = [ [[package]] name = "ibc-primitives" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "derive_more", "displaydoc", @@ -1623,9 +1626,9 @@ dependencies = [ [[package]] name = "ibc-proto" -version = "0.47.0" +version = "0.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1678333cf68c9094ca66aaf9a271269f1f6bf5c26881161def8bd88cee831a23" +checksum = "c852d22b782d2d793f4a646f968de419be635e02bc8798d5d74a6e44eef27733" dependencies = [ "base64 0.22.1", "bytes", @@ -1642,7 +1645,7 @@ dependencies = [ [[package]] name = "ibc-query" version = "0.54.0" -source = "git+https://github.com/cosmos/ibc-rs.git?rev=474909d#474909dfc454713d033a6bf2442ae55099796244" +source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "displaydoc", "ibc", @@ -1706,9 +1709,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.3.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -1726,9 +1729,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is_terminal_polyfill" @@ -1753,18 +1756,18 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -1789,9 +1792,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "linux-raw-sys" @@ -1835,18 +1838,18 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi", "libc", @@ -1881,9 +1884,9 @@ dependencies = [ [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -2062,9 +2065,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", "prost-derive", @@ -2072,9 +2075,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", "itertools", @@ -2085,18 +2088,18 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.13.1" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ "prost", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -2133,9 +2136,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "62871f2d65009c0256aed1b9cfeeb8ac272833c404e13d53d400cd0dad7a2ac0" dependencies = [ "bitflags 2.6.0", ] @@ -2229,9 +2232,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -2306,11 +2309,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2345,9 +2348,9 @@ dependencies = [ [[package]] name = "secp256k1" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0cc0f1cf93f4969faf3ea1c7d8a9faed25918d96affa959720823dfe86d4f3" +checksum = "9465315bc9d4566e1724f0fffcbcc446268cb522e60f9a27bcded6b19c108113" dependencies = [ "bitcoin_hashes", "rand", @@ -2357,9 +2360,9 @@ dependencies = [ [[package]] name = "secp256k1-sys" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1433bd67156263443f14d603720b082dd3121779323fce20cba2aa07b874bc1b" +checksum = "d4387882333d3aa8cb20530a17c69a3752e97837832f34f6dccc760e715001d9" dependencies = [ "cc", ] @@ -2379,9 +2382,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -2395,9 +2398,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.205" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -2422,9 +2425,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.205" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -2433,9 +2436,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -2518,6 +2521,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -2613,9 +2622,9 @@ checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" [[package]] name = "syn" -version = "2.0.72" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -2787,18 +2796,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -2881,9 +2890,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -2920,9 +2929,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -2945,9 +2954,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -2979,11 +2988,11 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", @@ -2992,16 +3001,16 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", "axum", "base64 0.22.1", "bytes", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "http-body-util", @@ -3014,7 +3023,7 @@ dependencies = [ "socket2", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -3022,9 +3031,9 @@ dependencies = [ [[package]] name = "tonic-reflection" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b742c83ad673e9ab5b4ce0981f7b9e8932be9d60e8682cbf9120494764dbc173" +checksum = "7b56b874eedb04f89907573b408eab1e87c1c1dce43aac6ad63742f57faa99ff" dependencies = [ "prost", "prost-types", @@ -3048,12 +3057,26 @@ dependencies = [ "rand", "slab", "tokio", - "tokio-util 0.7.11", + "tokio-util 0.7.12", "tower-layer", "tower-service", "tracing", ] +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tower-layer", + "tower-service", +] + [[package]] name = "tower-abci" version = "0.16.0" @@ -3068,21 +3091,21 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util 0.6.10", - "tower", + "tower 0.4.13", "tracing", ] [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -3174,15 +3197,15 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -3255,19 +3278,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -3280,9 +3304,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -3292,9 +3316,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3302,9 +3326,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -3315,15 +3339,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -3510,9 +3534,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "c52ac009d615e79296318c1bcce2d422aaca15ad08515e344feeda07df67a587" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 0aec73f..8a16311 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,8 +45,8 @@ tendermint-rpc = { version = "0.38", default-features = false } tower-abci = { version = "0.16" } [patch.crates-io] -ibc = { git = "https://github.com/cosmos/ibc-rs.git", rev = "474909d" } -ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "474909d" } +ibc = { git = "https://github.com/cosmos/ibc-rs.git", rev = "cfb707e" } +ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "cfb707e" } # for tendermint 0.38 tower-abci = { git = "https://github.com/informalsystems/tower-abci", rev = "0992541" } From 80286df795159d7ccca669588398dea5870d7be1 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:07:50 +0200 Subject: [PATCH 02/19] new error variant for Gov --- basecoin/modules/src/gov/error.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/basecoin/modules/src/gov/error.rs b/basecoin/modules/src/gov/error.rs index dcab388..0cc71e2 100644 --- a/basecoin/modules/src/gov/error.rs +++ b/basecoin/modules/src/gov/error.rs @@ -6,6 +6,10 @@ pub use crate::error::Error as AppError; pub enum Error { /// invalid proposal: `{reason}` InvalidProposal { reason: String }, + /// failed to validate: `{reason}` + ValidationFailure { reason: String }, + /// failed to execute: `{reason}` + ExecutionFailure { reason: String }, } impl From for AppError { From e2a7ee9161005228abb010d959c2ec72b47fc8bd Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:09:03 +0200 Subject: [PATCH 03/19] update AnyClientState and AnyConsensusState impls --- basecoin/modules/src/ibc/impls.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/basecoin/modules/src/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs index f6bc60a..a62a36a 100644 --- a/basecoin/modules/src/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -33,6 +33,7 @@ use ibc::core::entrypoint::dispatch; use ibc::core::handler::types::error::ContextError; use ibc::core::handler::types::events::IbcEvent; use ibc::core::handler::types::msgs::MsgEnvelope; +use ibc::core::host::types::error::{DecodingError, HostError}; use ibc::core::host::types::identifiers::{ClientId, ConnectionId, Sequence}; use ibc::core::host::types::path::{ AckPath, ChannelEndPath, ClientConnectionPath, ClientConsensusStatePath, ClientStatePath, @@ -102,14 +103,13 @@ impl From for Any { } impl TryFrom for AnyClientState { - type Error = ClientError; + type Error = DecodingError; - fn try_from(value: Any) -> Result { - match value.type_url.as_str() { - TENDERMINT_CLIENT_STATE_TYPE_URL => Ok(AnyClientState::Tendermint(value.try_into()?)), - _ => Err(ClientError::Other { - description: "Unknown client state type".into(), - }), + fn try_from(raw: Any) -> Result { + if let TENDERMINT_CLIENT_STATE_TYPE_URL = raw.type_url.as_str() { + Ok(AnyClientState::Tendermint(raw.try_into()?)) + } else { + Err(DecodingError::UnknownTypeUrl(raw.type_url)) } } } @@ -129,7 +129,7 @@ impl From for AnyConsensusState { } impl TryFrom for ConsensusStateType { - type Error = ClientError; + type Error = DecodingError; fn try_from(value: AnyConsensusState) -> Result { match value { @@ -149,16 +149,13 @@ impl From for Any { } impl TryFrom for AnyConsensusState { - type Error = ClientError; + type Error = DecodingError; fn try_from(value: Any) -> Result { - match value.type_url.as_str() { - TENDERMINT_CONSENSUS_STATE_TYPE_URL => { - Ok(AnyConsensusState::Tendermint(value.try_into()?)) - } - _ => Err(ClientError::Other { - description: "Unknown consensus state type".into(), - }), + if let TENDERMINT_CONSENSUS_STATE_TYPE_URL = value.type_url.as_str() { + Ok(AnyConsensusState::Tendermint(value.try_into()?)) + } else { + Err(DecodingError::UnknownTypeUrl(value.type_url)) } } } From df9e071ae4c62e2ef1a0278510a2aae0db3f147c Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:10:11 +0200 Subject: [PATCH 04/19] refactor for new ibc-rs error types --- basecoin/modules/src/gov/impls.rs | 17 +- basecoin/modules/src/ibc/client_contexts.rs | 105 +++---- basecoin/modules/src/ibc/error.rs | 4 +- basecoin/modules/src/ibc/impls.rs | 288 +++++++++----------- basecoin/modules/src/ibc/router.rs | 4 +- basecoin/modules/src/ibc/transfer.rs | 101 ++++--- basecoin/modules/src/upgrade/impls.rs | 56 ++-- basecoin/modules/src/upgrade/service.rs | 2 +- 8 files changed, 279 insertions(+), 298 deletions(-) diff --git a/basecoin/modules/src/gov/impls.rs b/basecoin/modules/src/gov/impls.rs index f46a03b..a894d83 100644 --- a/basecoin/modules/src/gov/impls.rs +++ b/basecoin/modules/src/gov/impls.rs @@ -19,6 +19,7 @@ use ibc_proto::Protobuf; use tendermint::abci::Event; use tracing::debug; +use super::error::Error as GovError; use super::path::ProposalPath; use super::proposal::Proposal; use super::service::GovernanceService; @@ -104,8 +105,16 @@ where let mut ibc_ctx = self.ibc_ctx.write_access(); - recover_client::validate(&ibc_ctx.ctx, msg_recover_client.clone())?; - recover_client::execute(&mut ibc_ctx.ctx, msg_recover_client)?; + recover_client::validate(&ibc_ctx.ctx, msg_recover_client.clone()).map_err( + |e| GovError::ValidationFailure { + reason: format!("Error validating client recovery message: {:?}", e), + }, + )?; + recover_client::execute(&mut ibc_ctx.ctx, msg_recover_client).map_err(|e| { + GovError::ValidationFailure { + reason: format!("Error executing client recovery message: {:?}", e), + } + })?; // client recovery operation does not return an event // https://github.com/cosmos/ibc-go/blob/4c1aae32/modules/light-clients/07-tendermint/light_client_module.go#L249 @@ -125,7 +134,7 @@ where _height: Height, _prove: bool, ) -> Result { - let path = path.ok_or(AppError::NotHandled)?; + let path = path.ok_or_else(|| AppError::NotHandled)?; if path.to_string() != "/cosmos.gov.v1beta1.Query/Proposal" { return Err(AppError::NotHandled); @@ -134,7 +143,7 @@ where let data = self .store .get(Height::Pending, &Path::from(ProposalPath::sdk_path())) - .ok_or(AppError::Custom { + .ok_or_else(|| AppError::Custom { reason: "Data not found".to_string(), })?; diff --git a/basecoin/modules/src/ibc/client_contexts.rs b/basecoin/modules/src/ibc/client_contexts.rs index d3fbbe0..8f282ee 100644 --- a/basecoin/modules/src/ibc/client_contexts.rs +++ b/basecoin/modules/src/ibc/client_contexts.rs @@ -5,9 +5,8 @@ use basecoin_store::types::Height; use ibc::core::client::context::{ ClientExecutionContext, ClientValidationContext, ExtClientValidationContext, }; -use ibc::core::client::types::error::ClientError; use ibc::core::client::types::Height as IbcHeight; -use ibc::core::handler::types::error::ContextError; +use ibc::core::host::types::error::HostError; use ibc::core::host::types::identifiers::ClientId; use ibc::core::host::types::path::{ ClientConsensusStatePath, ClientStatePath, ClientUpdateHeightPath, ClientUpdateTimePath, Path, @@ -25,28 +24,31 @@ where type ClientStateRef = AnyClientState; type ConsensusStateRef = AnyConsensusState; - fn client_state(&self, client_id: &ClientId) -> Result { - Ok(self - .client_state_store + fn client_state(&self, client_id: &ClientId) -> Result { + self.client_state_store .get(Height::Pending, &ClientStatePath(client_id.clone())) - .ok_or(ClientError::MissingClientState(client_id.clone()))?) + .ok_or_else(|| { + HostError::missing_state(format!("client state for client_id {client_id}")) + }) } fn consensus_state( &self, client_cons_state_path: &ClientConsensusStatePath, - ) -> Result { + ) -> Result { let height = IbcHeight::new( client_cons_state_path.revision_number, client_cons_state_path.revision_height, ) - .map_err(|_| ClientError::InvalidHeight)?; + .map_err(|e| HostError::invalid_state(format!("consensus state height: {e:?}")))?; let consensus_state = self .consensus_state_store .get(Height::Pending, client_cons_state_path) - .ok_or(ClientError::MissingConsensusState { - client_id: client_cons_state_path.client_id.clone(), - height, + .ok_or_else(|| { + HostError::missing_state(format!( + "consensus state for client_id {} at height {height}", + client_cons_state_path.client_id + )) })?; Ok(consensus_state) @@ -58,7 +60,7 @@ where &self, client_id: &ClientId, height: &IbcHeight, - ) -> Result<(Timestamp, IbcHeight), ContextError> { + ) -> Result<(Timestamp, IbcHeight), HostError> { let client_update_time_path = ClientUpdateTimePath::new( client_id.clone(), height.revision_number(), @@ -67,9 +69,10 @@ where let processed_timestamp = self .client_processed_times .get(Height::Pending, &client_update_time_path) - .ok_or(ClientError::MissingUpdateMetaData { - client_id: client_id.clone(), - height: *height, + .ok_or_else(|| { + HostError::missing_state(format!( + "update time for client_id {client_id} at height {height}" + )) })?; let client_update_height_path = ClientUpdateHeightPath::new( client_id.clone(), @@ -79,9 +82,10 @@ where let processed_height = self .client_processed_heights .get(Height::Pending, &client_update_height_path) - .ok_or(ClientError::MissingUpdateMetaData { - client_id: client_id.clone(), - height: *height, + .ok_or_else(|| { + HostError::missing_state(format!( + "update height for client_id {client_id} at height {height}" + )) })?; Ok((processed_timestamp, processed_height)) @@ -99,13 +103,10 @@ where &mut self, client_state_path: ClientStatePath, client_state: Self::ClientStateMut, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.client_state_store .set(client_state_path, client_state) - .map(|_| ()) - .map_err(|_| ClientError::Other { - description: "Client state store error".to_string(), - })?; + .map_err(|e| HostError::failed_to_store(format!("client state: {e:?}")))?; Ok(()) } @@ -114,19 +115,17 @@ where &mut self, consensus_state_path: ClientConsensusStatePath, consensus_state: Self::ConsensusStateRef, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.consensus_state_store .set(consensus_state_path, consensus_state) - .map_err(|_| ClientError::Other { - description: "Consensus state store error".to_string(), - })?; + .map_err(|e| HostError::failed_to_store(format!("consensus state: {e:?}")))?; Ok(()) } fn delete_consensus_state( &mut self, consensus_state_path: ClientConsensusStatePath, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.consensus_state_store.delete(consensus_state_path); Ok(()) } @@ -140,7 +139,7 @@ where height: IbcHeight, host_timestamp: Timestamp, host_height: IbcHeight, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { let client_update_time_path = ClientUpdateTimePath::new( client_id.clone(), height.revision_number(), @@ -148,8 +147,10 @@ where ); self.client_processed_times .set(client_update_time_path, host_timestamp) - .map_err(|_| ClientError::Other { - description: "store update error".into(), + .map_err(|e| { + HostError::failed_to_store(format!( + "update time for client {client_id} as height {height}: {e:?}" + )) })?; let client_update_height_path = ClientUpdateHeightPath::new( client_id.clone(), @@ -158,8 +159,10 @@ where ); self.client_processed_heights .set(client_update_height_path, host_height) - .map_err(|_| ClientError::Other { - description: "store update error".into(), + .map_err(|e| { + HostError::failed_to_store(format!( + "update height for client {client_id} as height {height}: {e:?}" + )) })?; Ok(()) } @@ -170,7 +173,7 @@ where &mut self, client_id: ClientId, height: IbcHeight, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { let client_update_time_path = ClientUpdateTimePath::new( client_id.clone(), height.revision_number(), @@ -192,23 +195,18 @@ impl ExtClientValidationContext for IbcContext where S: Store + Debug, { - fn host_timestamp(&self) -> Result { + fn host_timestamp(&self) -> Result { ValidationContext::host_timestamp(self) } - fn host_height(&self) -> Result { + fn host_height(&self) -> Result { ValidationContext::host_height(self) } - fn consensus_state_heights( - &self, - client_id: &ClientId, - ) -> Result, ContextError> { + fn consensus_state_heights(&self, client_id: &ClientId) -> Result, HostError> { let path = format!("clients/{}/consensusStates", client_id) .try_into() - .map_err(|_| ClientError::Other { - description: "Invalid consensus state path".into(), - })?; + .map_err(|e| HostError::invalid_state(format!("consensus state path: {e:?}")))?; self.consensus_state_store .get_keys(&path) @@ -224,7 +222,8 @@ where let height = IbcHeight::new( consensus_path.revision_number, consensus_path.revision_height, - )?; + ) + .map_err(|e| HostError::invalid_state(format!("consensus state height: {e:?}")))?; Ok(height) }) .collect() @@ -234,7 +233,7 @@ where &self, client_id: &ClientId, height: &IbcHeight, - ) -> Result, ContextError> { + ) -> Result, HostError> { let path = format!("clients/{client_id}/consensusStates") .try_into() .unwrap(); // safety - path must be valid since ClientId and height are valid Identifiers @@ -253,9 +252,10 @@ where let consensus_state = self .consensus_state_store .get(Height::Pending, &path) - .ok_or(ClientError::MissingConsensusState { - client_id: client_id.clone(), - height: *height, + .ok_or_else(|| { + HostError::missing_state(format!( + "consensus state for client_id {client_id} at height {height}" + )) })?; Ok(Some(consensus_state)) @@ -268,7 +268,7 @@ where &self, client_id: &ClientId, height: &IbcHeight, - ) -> Result, ContextError> { + ) -> Result, HostError> { let path = format!("clients/{client_id}/consensusStates") .try_into() .unwrap(); // safety - path must be valid since ClientId and height are valid Identifiers @@ -291,9 +291,10 @@ where let consensus_state = self .consensus_state_store .get(Height::Pending, &prev_path) - .ok_or(ClientError::MissingConsensusState { - client_id: client_id.clone(), - height: *height, + .ok_or_else(|| { + HostError::missing_state(format!( + "consensus state for client_id {client_id} at height {height}" + )) })?; return Ok(Some(consensus_state)); } diff --git a/basecoin/modules/src/ibc/error.rs b/basecoin/modules/src/ibc/error.rs index 5b9d4d3..ee6cdd0 100644 --- a/basecoin/modules/src/ibc/error.rs +++ b/basecoin/modules/src/ibc/error.rs @@ -1,8 +1,8 @@ -use ibc::core::handler::types::error::ContextError; +use ibc::core::handler::types::error::HandlerError; pub use crate::error::Error as AppError; -pub type Error = ContextError; +pub type Error = HandlerError; impl From for AppError { fn from(e: Error) -> Self { diff --git a/basecoin/modules/src/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs index a62a36a..2657520 100644 --- a/basecoin/modules/src/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -21,16 +21,13 @@ use ibc::clients::tendermint::types::{ }; use ibc::core::channel::types::channel::{ChannelEnd, IdentifiedChannelEnd}; use ibc::core::channel::types::commitment::{AcknowledgementCommitment, PacketCommitment}; -use ibc::core::channel::types::error::{ChannelError, PacketError}; use ibc::core::channel::types::packet::{PacketState, Receipt}; use ibc::core::client::types::error::ClientError; use ibc::core::client::types::Height as IbcHeight; use ibc::core::commitment_types::commitment::{CommitmentPrefix, CommitmentRoot}; -use ibc::core::connection::types::error::ConnectionError; use ibc::core::connection::types::version::Version as ConnectionVersion; use ibc::core::connection::types::{ConnectionEnd, IdentifiedConnectionEnd}; use ibc::core::entrypoint::dispatch; -use ibc::core::handler::types::error::ContextError; use ibc::core::handler::types::events::IbcEvent; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::error::{DecodingError, HostError}; @@ -281,7 +278,7 @@ where height: Height, prove: bool, ) -> Result { - let path = path.ok_or(AppError::NotHandled)?; + let path = path.ok_or_else(|| AppError::NotHandled)?; if path.to_string() != IBC_QUERY_PATH { return Err(AppError::NotHandled); } @@ -303,9 +300,11 @@ where ); let proof = if prove { - let proof = self.get_proof(height, &path).ok_or(AppError::Custom { - reason: "Proof not found".to_string(), - })?; + let proof = self + .get_proof(height, &path) + .ok_or_else(|| AppError::Custom { + reason: "Proof not found".to_string(), + })?; Some(vec![ProofOp { field_type: "".to_string(), key: path.to_string().into_bytes(), @@ -315,9 +314,13 @@ where None }; - let data = self.ctx.store.get(height, &path).ok_or(AppError::Custom { - reason: "Data not found".to_string(), - })?; + let data = self + .ctx + .store + .get(height, &path) + .ok_or_else(|| AppError::Custom { + reason: "Data not found".to_string(), + })?; Ok(QueryResult { data, proof }) } @@ -470,56 +473,49 @@ where self } - fn host_height(&self) -> Result { - Ok(IbcHeight::new( - CHAIN_REVISION_NUMBER, - self.store.current_height(), - )?) + fn host_height(&self) -> Result { + IbcHeight::new(CHAIN_REVISION_NUMBER, self.store.current_height()) + .map_err(HostError::invalid_state) } - fn host_timestamp(&self) -> Result { + fn host_timestamp(&self) -> Result { let host_height = self.host_height()?; let host_cons_state = self.host_consensus_state(&host_height)?; - Ok(host_cons_state + host_cons_state .timestamp() .try_into() - .map_err(|_| ClientError::Other { - description: "Invalid timestamp".into(), - })?) + .map_err(HostError::invalid_state) } fn host_consensus_state( &self, height: &IbcHeight, - ) -> Result { + ) -> Result { let consensus_states_binding = self.consensus_states.read().expect("lock is poisoned"); let consensus_state = consensus_states_binding .get(&height.revision_height()) - .ok_or(ClientError::MissingLocalConsensusState(*height))?; + .ok_or_else(|| ClientError::MissingLocalConsensusState(*height)) + .map_err(HostError::missing_state)?; Ok(consensus_state.clone()) } - fn client_counter(&self) -> Result { - Ok(self - .client_counter + fn client_counter(&self) -> Result { + self.client_counter .get(Height::Pending, &NextClientSequencePath) - .ok_or(ClientError::Other { - description: "client counter not found".into(), - })?) + .ok_or_else(|| HostError::missing_state("client counter")) } - fn connection_end(&self, conn_id: &ConnectionId) -> Result { - Ok(self - .connection_end_store + fn connection_end(&self, conn_id: &ConnectionId) -> Result { + self.connection_end_store .get(Height::Pending, &ConnectionPath::new(conn_id)) - .ok_or(ConnectionError::MissingConnection(conn_id.clone()))?) + .ok_or_else(|| HostError::failed_to_retrieve(format!("connection end: {}", conn_id))) } fn validate_self_client( &self, _counterparty_client_state: Self::HostClientState, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { Ok(()) } @@ -528,76 +524,62 @@ where CommitmentPrefix::from(IbcPrefix {}.identifier().as_bytes().to_vec()) } - fn connection_counter(&self) -> Result { - Ok(self - .conn_counter + fn connection_counter(&self) -> Result { + self.conn_counter .get(Height::Pending, &NextConnectionSequencePath) - .ok_or(ConnectionError::MissingConnectionCounter)?) + .ok_or_else(|| HostError::missing_state("connection counter")) } fn get_compatible_versions(&self) -> Vec { ConnectionVersion::compatibles() } - fn channel_end(&self, channel_end_path: &ChannelEndPath) -> Result { - let channel_end = self - .channel_end_store + fn channel_end(&self, channel_end_path: &ChannelEndPath) -> Result { + self.channel_end_store .get( Height::Pending, &ChannelEndPath::new(&channel_end_path.0, &channel_end_path.1), ) - .ok_or(ChannelError::NonexistentChannel { - port_id: channel_end_path.0.clone(), - channel_id: channel_end_path.1.clone(), - })?; - Ok(channel_end) + .ok_or_else(|| { + HostError::missing_state(format!( + "port: {}, channel_id: {}", + channel_end_path.0, channel_end_path.1 + )) + }) } - fn get_next_sequence_send( - &self, - seq_send_path: &SeqSendPath, - ) -> Result { - let seq_send = self - .send_sequence_store + fn get_next_sequence_send(&self, seq_send_path: &SeqSendPath) -> Result { + self.send_sequence_store .get( Height::Pending, &SeqSendPath::new(&seq_send_path.0, &seq_send_path.1), ) - .ok_or(PacketError::ImplementationSpecific)?; - Ok(seq_send) + .ok_or_else(|| HostError::missing_state("sequence send")) } - fn get_next_sequence_recv( - &self, - seq_recv_path: &SeqRecvPath, - ) -> Result { - let seq_recv = self - .recv_sequence_store + fn get_next_sequence_recv(&self, seq_recv_path: &SeqRecvPath) -> Result { + self.recv_sequence_store .get( Height::Pending, &SeqRecvPath::new(&seq_recv_path.0, &seq_recv_path.1), ) - .ok_or(PacketError::ImplementationSpecific)?; - Ok(seq_recv) + .ok_or_else(|| HostError::missing_state("sequence recv")) } - fn get_next_sequence_ack(&self, seq_ack_path: &SeqAckPath) -> Result { - let seq_ack = self - .ack_sequence_store + fn get_next_sequence_ack(&self, seq_ack_path: &SeqAckPath) -> Result { + self.ack_sequence_store .get( Height::Pending, &SeqAckPath::new(&seq_ack_path.0, &seq_ack_path.1), ) - .ok_or(PacketError::ImplementationSpecific)?; - Ok(seq_ack) + .ok_or_else(|| HostError::missing_state("sequence ack")) } fn get_packet_commitment( &self, commitment_path: &CommitmentPath, - ) -> Result { - let commitment = self - .packet_commitment_store + ) -> Result { + self.packet_commitment_store .get( Height::Pending, &CommitmentPath::new( @@ -606,13 +588,11 @@ where commitment_path.sequence, ), ) - .ok_or(PacketError::ImplementationSpecific)?; - Ok(commitment) + .ok_or_else(|| HostError::failed_to_retrieve("packet commitment")) } - fn get_packet_receipt(&self, receipt_path: &ReceiptPath) -> Result { - let receipt = self - .packet_receipt_store + fn get_packet_receipt(&self, receipt_path: &ReceiptPath) -> Result { + self.packet_receipt_store .is_path_set( Height::Pending, &ReceiptPath::new( @@ -622,32 +602,30 @@ where ), ) .then_some(Receipt::Ok) - .ok_or(PacketError::MissingPacketReceipt(receipt_path.sequence))?; - Ok(receipt) + .ok_or_else(|| HostError::failed_to_retrieve("packet receipt")) } fn get_packet_acknowledgement( &self, ack_path: &AckPath, - ) -> Result { - let ack = self - .packet_ack_store + ) -> Result { + self.packet_ack_store .get( Height::Pending, &AckPath::new(&ack_path.port_id, &ack_path.channel_id, ack_path.sequence), ) - .ok_or(PacketError::MissingPacketAcknowledgment(ack_path.sequence))?; - Ok(ack) + .ok_or_else(|| { + HostError::failed_to_retrieve(format!("packet ack: {:?}", ack_path.sequence)) + }) } /// Returns a counter on the number of channel ids have been created thus far. /// The value of this counter should increase only via method /// `ChannelKeeper::increase_channel_counter`. - fn channel_counter(&self) -> Result { - Ok(self - .channel_counter + fn channel_counter(&self) -> Result { + self.channel_counter .get(Height::Pending, &NextChannelSequencePath) - .ok_or(ChannelError::MissingCounter)?) + .ok_or_else(|| HostError::missing_state("channel counter")) } /// Returns the maximum expected time per block @@ -655,7 +633,7 @@ where Duration::from_secs(8) } - fn validate_message_signer(&self, _signer: &Signer) -> Result<(), ContextError> { + fn validate_message_signer(&self, _signer: &Signer) -> Result<(), HostError> { Ok(()) } } @@ -679,7 +657,7 @@ where S: ProvableStore + Debug, { /// Returns the list of all client states. - fn client_states(&self) -> Result)>, ContextError> { + fn client_states(&self) -> Result)>, HostError> { let path = "clients".to_owned().into(); self.client_state_store @@ -696,7 +674,9 @@ where let client_state = self .client_state_store .get(Height::Pending, &client_state_path) - .ok_or_else(|| ClientError::MissingClientState(client_state_path.0.clone()))?; + .ok_or_else(|| { + HostError::missing_state(format!("client state: {:?}", client_state_path.0)) + })?; Ok((client_state_path.0, client_state)) }) .collect() @@ -706,12 +686,10 @@ where fn consensus_states( &self, client_id: &ClientId, - ) -> Result)>, ContextError> { + ) -> Result)>, HostError> { let path = format!("clients/{}/consensusStates", client_id) .try_into() - .map_err(|_| ClientError::Other { - description: "Invalid consensus state path".into(), - })?; + .map_err(HostError::invalid_state)?; self.consensus_state_store .get_keys(&path) @@ -727,15 +705,16 @@ where let height = IbcHeight::new( consensus_path.revision_number, consensus_path.revision_height, - )?; + ) + .map_err(HostError::invalid_state)?; let client_state = self .consensus_state_store .get(Height::Pending, &consensus_path) - .ok_or({ - ClientError::MissingConsensusState { - client_id: consensus_path.client_id, - height, - } + .ok_or_else(|| { + HostError::missing_state(format!( + "consensus state for client {} at height {:?}", + client_id, height + )) })?; Ok((height, client_state)) }) @@ -743,15 +722,10 @@ where } /// Returns the list of heights at which the consensus state of the given client was updated. - fn consensus_state_heights( - &self, - client_id: &ClientId, - ) -> Result, ContextError> { + fn consensus_state_heights(&self, client_id: &ClientId) -> Result, HostError> { let path = format!("clients/{}/consensusStates", client_id) .try_into() - .map_err(|_| ClientError::Other { - description: "Invalid consensus state path".into(), - })?; + .map_err(HostError::invalid_state)?; self.consensus_state_store .get_keys(&path) @@ -764,16 +738,17 @@ where } }) .map(|consensus_path| { - Ok(IbcHeight::new( + IbcHeight::new( consensus_path.revision_number, consensus_path.revision_height, - )?) + ) + .map_err(HostError::invalid_state) }) .collect::, _>>() } /// Connections queries all the IBC connections of a chain. - fn connection_ends(&self) -> Result, ContextError> { + fn connection_ends(&self) -> Result, HostError> { let path = "connections".to_owned().into(); self.connection_end_store @@ -790,7 +765,9 @@ where let connection_end = self .connection_end_store .get(Height::Pending, &connection_path) - .ok_or_else(|| ConnectionError::MissingConnection(connection_path.0.clone()))?; + .ok_or_else(|| { + HostError::missing_state(format!("connection: {:?}", connection_path.0)) + })?; Ok(IdentifiedConnectionEnd { connection_id: connection_path.0, connection_end, @@ -800,10 +777,7 @@ where } /// ClientConnections queries all the connection paths associated with a client. - fn client_connection_ends( - &self, - client_id: &ClientId, - ) -> Result, ContextError> { + fn client_connection_ends(&self, client_id: &ClientId) -> Result, HostError> { let client_connection_path = ClientConnectionPath::new(client_id.clone()); Ok(self @@ -813,7 +787,7 @@ where } /// Channels queries all the IBC channels of a chain. - fn channel_ends(&self) -> Result, ContextError> { + fn channel_ends(&self) -> Result, HostError> { let path = "channelEnds".to_owned().into(); self.channel_end_store @@ -830,9 +804,11 @@ where let channel_end = self .channel_end_store .get(Height::Pending, &channel_path) - .ok_or_else(|| ChannelError::NonexistentChannel { - port_id: channel_path.0.clone(), - channel_id: channel_path.1.clone(), + .ok_or_else(|| { + HostError::missing_state(format!( + "port: {}, channel_id: {}", + channel_path.0, channel_path.1 + )) })?; Ok(IdentifiedChannelEnd { port_id: channel_path.0, @@ -847,7 +823,7 @@ where fn packet_commitments( &self, channel_end_path: &ChannelEndPath, - ) -> Result, ContextError> { + ) -> Result, HostError> { let path_prefix = format!( "commitments/ports/{}/channels/{}/sequences", channel_end_path.0, channel_end_path.1 @@ -887,7 +863,7 @@ where &self, channel_end_path: &ChannelEndPath, sequences: impl ExactSizeIterator, - ) -> Result, ContextError> { + ) -> Result, HostError> { let collected_paths: Vec<_> = if sequences.len() == 0 { // if sequences is empty, return all the acks let ack_path_prefix = format!( @@ -939,7 +915,7 @@ where &self, channel_end_path: &ChannelEndPath, sequences: impl ExactSizeIterator, - ) -> Result, ContextError> { + ) -> Result, HostError> { // QUESTION. Currently only works for unordered channels; ordered channels // don't use receipts. However, ibc-go does it this way. Investigate if // this query only ever makes sense on unordered channels. @@ -962,7 +938,7 @@ where &self, channel_end_path: &ChannelEndPath, sequences: impl ExactSizeIterator, - ) -> Result, ContextError> { + ) -> Result, HostError> { let collected_paths: Vec<_> = if sequences.len() == 0 { // if sequences is empty, return all the acks let commitment_path_prefix = format!( @@ -1014,19 +990,15 @@ where /// Called upon client creation. /// Increases the counter which keeps track of how many clients have been created. /// Should never fail. - fn increase_client_counter(&mut self) -> Result<(), ContextError> { + fn increase_client_counter(&mut self) -> Result<(), HostError> { let current_sequence = self .client_counter .get(Height::Pending, &NextClientSequencePath) - .ok_or(ClientError::Other { - description: "client counter not found".into(), - })?; + .ok_or_else(|| HostError::missing_state("client counter"))?; self.client_counter .set(NextClientSequencePath, current_sequence + 1) - .map_err(|e| ClientError::Other { - description: format!("client counter update failed: {e:?}"), - })?; + .map_err(|e| HostError::failed_to_store(format!("client counter: {e:?}")))?; Ok(()) } @@ -1036,10 +1008,10 @@ where &mut self, connection_path: &ConnectionPath, connection_end: ConnectionEnd, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.connection_end_store .set(connection_path.clone(), connection_end) - .map_err(|_| ConnectionError::FailedToStoreConnectionEnd)?; + .map_err(|e| HostError::failed_to_store(format!("connection end: {e:?}")))?; Ok(()) } @@ -1048,7 +1020,7 @@ where &mut self, client_connection_path: &ClientConnectionPath, conn_id: ConnectionId, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { let mut conn_ids: Vec = self .connection_ids_store .get(Height::Pending, client_connection_path) @@ -1056,22 +1028,22 @@ where conn_ids.push(conn_id); self.connection_ids_store .set(client_connection_path.clone(), conn_ids) - .map_err(|_| ConnectionError::FailedToStoreConnectionIds)?; + .map_err(|e| HostError::failed_to_store(format!("connection ids: {e:?}")))?; Ok(()) } /// Called upon connection identifier creation (Init or Try process). /// Increases the counter which keeps track of how many connections have been created. /// Should never fail. - fn increase_connection_counter(&mut self) -> Result<(), ContextError> { + fn increase_connection_counter(&mut self) -> Result<(), HostError> { let current_sequence = self .conn_counter .get(Height::Pending, &NextConnectionSequencePath) - .ok_or(ConnectionError::MissingConnectionCounter)?; + .ok_or_else(|| HostError::missing_state("connection counter"))?; self.conn_counter .set(NextConnectionSequencePath, current_sequence + 1) - .map_err(|_| ConnectionError::FailedToUpdateConnectionCounter)?; + .map_err(|e| HostError::failed_to_store(format!("connection counter: {e:?}")))?; Ok(()) } @@ -1080,14 +1052,14 @@ where &mut self, commitment_path: &CommitmentPath, commitment: PacketCommitment, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.packet_commitment_store .set(commitment_path.clone(), commitment) - .map_err(|_| PacketError::ImplementationSpecific)?; + .map_err(|e| HostError::failed_to_store(format!("packet commitment: {e:?}")))?; Ok(()) } - fn delete_packet_commitment(&mut self, key: &CommitmentPath) -> Result<(), ContextError> { + fn delete_packet_commitment(&mut self, key: &CommitmentPath) -> Result<(), HostError> { self.packet_commitment_store.delete(key.clone()); Ok(()) } @@ -1096,10 +1068,10 @@ where &mut self, receipt_path: &ReceiptPath, _receipt: Receipt, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.packet_receipt_store .set_path(receipt_path.clone()) - .map_err(|_| PacketError::ImplementationSpecific)?; + .map_err(|e| HostError::failed_to_store(format!("packet receipt: {e:?}")))?; Ok(()) } @@ -1107,14 +1079,14 @@ where &mut self, ack_path: &AckPath, ack_commitment: AcknowledgementCommitment, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.packet_ack_store .set(ack_path.clone(), ack_commitment) - .map_err(|_| PacketError::ImplementationSpecific)?; + .map_err(|e| HostError::failed_to_store(format!("packet ack: {e:?}")))?; Ok(()) } - fn delete_packet_acknowledgement(&mut self, ack_path: &AckPath) -> Result<(), ContextError> { + fn delete_packet_acknowledgement(&mut self, ack_path: &AckPath) -> Result<(), HostError> { self.packet_ack_store.delete(ack_path.clone()); Ok(()) } @@ -1124,12 +1096,10 @@ where &mut self, channel_end_path: &ChannelEndPath, channel_end: ChannelEnd, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.channel_end_store .set(channel_end_path.clone(), channel_end) - .map_err(|e| ChannelError::FailedToStoreChannel { - description: format!("{e:?}"), - })?; + .map_err(|e| HostError::failed_to_store(format!("channel end: {e:?}")))?; Ok(()) } @@ -1137,10 +1107,10 @@ where &mut self, seq_send_path: &SeqSendPath, seq: Sequence, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.send_sequence_store .set(seq_send_path.clone(), seq) - .map_err(|_| PacketError::ImplementationSpecific)?; + .map_err(|e| HostError::failed_to_store(format!("sequence send: {e:?}")))?; Ok(()) } @@ -1148,10 +1118,10 @@ where &mut self, seq_recv_path: &SeqRecvPath, seq: Sequence, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.recv_sequence_store .set(seq_recv_path.clone(), seq) - .map_err(|_| PacketError::ImplementationSpecific)?; + .map_err(|e| HostError::failed_to_store(format!("sequence recv: {e:?}")))?; Ok(()) } @@ -1159,34 +1129,32 @@ where &mut self, seq_ack_path: &SeqAckPath, seq: Sequence, - ) -> Result<(), ContextError> { + ) -> Result<(), HostError> { self.ack_sequence_store .set(seq_ack_path.clone(), seq) - .map_err(|_| PacketError::ImplementationSpecific)?; + .map_err(|e| HostError::failed_to_store(format!("sequence ack: {e:?}")))?; Ok(()) } - fn increase_channel_counter(&mut self) -> Result<(), ContextError> { + fn increase_channel_counter(&mut self) -> Result<(), HostError> { let current_sequence = self .channel_counter .get(Height::Pending, &NextChannelSequencePath) - .ok_or(ChannelError::MissingCounter)?; + .ok_or_else(|| HostError::missing_state("channel counter"))?; self.channel_counter .set(NextChannelSequencePath, current_sequence + 1) - .map_err(|e| ChannelError::FailedToUpdateCounter { - description: format!("{e:?}"), - })?; + .map_err(|e| HostError::failed_to_store(format!("channel counter: {e:?}")))?; Ok(()) } - fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), ContextError> { + fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), HostError> { self.events.push(event); Ok(()) } - fn log_message(&mut self, message: String) -> Result<(), ContextError> { + fn log_message(&mut self, message: String) -> Result<(), HostError> { self.logs.push(message); Ok(()) } diff --git a/basecoin/modules/src/ibc/router.rs b/basecoin/modules/src/ibc/router.rs index 4c28b6d..c42320c 100644 --- a/basecoin/modules/src/ibc/router.rs +++ b/basecoin/modules/src/ibc/router.rs @@ -4,10 +4,10 @@ use std::fmt::Debug; use basecoin_store::context::Store; use ibc::apps::transfer::types::MODULE_ID_STR as IBC_TRANSFER_MODULE_ID; +use ibc::core::host::types::error::HostError; use ibc::core::host::types::identifiers::PortId; use ibc::core::router::module::Module as IbcModule; use ibc::core::router::router::Router; -use ibc::core::router::types::error::RouterError; use ibc::core::router::types::module::ModuleId; use crate::bank::BankBalanceKeeper; @@ -67,7 +67,7 @@ where fn lookup_module(&self, port_id: &PortId) -> Option { self.port_to_module_map .get(port_id) - .ok_or(RouterError::UnknownPort(port_id.clone())) + .ok_or_else(|| HostError::missing_state(format!("missing port_id: {port_id}"))) .cloned() .ok() } diff --git a/basecoin/modules/src/ibc/transfer.rs b/basecoin/modules/src/ibc/transfer.rs index 67344fc..6f99fac 100644 --- a/basecoin/modules/src/ibc/transfer.rs +++ b/basecoin/modules/src/ibc/transfer.rs @@ -12,10 +12,11 @@ use ibc::apps::transfer::types::error::TokenTransferError; use ibc::apps::transfer::types::{Memo, PrefixedCoin, VERSION}; use ibc::core::channel::types::acknowledgement::Acknowledgement; use ibc::core::channel::types::channel::{Counterparty, Order}; -use ibc::core::channel::types::error::{ChannelError, PacketError}; +use ibc::core::channel::types::error::ChannelError; use ibc::core::channel::types::packet::Packet; use ibc::core::channel::types::Version as ChannelVersion; use ibc::core::handler::types::events::IbcEvent; +use ibc::core::host::types::error::HostError; use ibc::core::host::types::identifiers::{ChannelId, ConnectionId, PortId}; use ibc::core::router::module::Module as IbcModule; use ibc::core::router::types::module::ModuleExtras; @@ -89,7 +90,7 @@ where counterparty, version, ) - .map_err(|e: TokenTransferError| ChannelError::AppModule { + .map_err(|e: TokenTransferError| ChannelError::AppSpecific { description: e.to_string(), })?; Ok(ChannelVersion::new(VERSION.to_string())) @@ -113,7 +114,7 @@ where counterparty, version, ) - .map_err(|e: TokenTransferError| ChannelError::AppModule { + .map_err(|e: TokenTransferError| ChannelError::AppSpecific { description: e.to_string(), }) } @@ -136,7 +137,7 @@ where counterparty, counterparty_version, ) - .map_err(|e: TokenTransferError| ChannelError::AppModule { + .map_err(|e: TokenTransferError| ChannelError::AppSpecific { description: e.to_string(), })?; Ok(ChannelVersion::new(VERSION.to_string())) @@ -160,7 +161,7 @@ where counterparty, counterparty_version, ) - .map_err(|e: TokenTransferError| ChannelError::AppModule { + .map_err(|e: TokenTransferError| ChannelError::AppSpecific { description: e.to_string(), }) } @@ -172,7 +173,7 @@ where counterparty_version: &ChannelVersion, ) -> Result<(), ChannelError> { on_chan_open_ack_validate(self, port_id, channel_id, counterparty_version).map_err( - |e: TokenTransferError| ChannelError::AppModule { + |e: TokenTransferError| ChannelError::AppSpecific { description: e.to_string(), }, ) @@ -193,7 +194,7 @@ where channel_id: &ChannelId, ) -> Result<(), ChannelError> { on_chan_open_confirm_validate(self, port_id, channel_id).map_err(|e: TokenTransferError| { - ChannelError::AppModule { + ChannelError::AppSpecific { description: e.to_string(), } }) @@ -252,9 +253,9 @@ where packet: &Packet, acknowledgement: &Acknowledgement, relayer: &Signer, - ) -> Result<(), PacketError> { + ) -> Result<(), ChannelError> { on_acknowledgement_packet_validate(self, packet, acknowledgement, relayer).map_err( - |e: TokenTransferError| PacketError::AppModule { + |e: TokenTransferError| ChannelError::AppSpecific { description: e.to_string(), }, ) @@ -265,7 +266,7 @@ where _packet: &Packet, _acknowledgement: &Acknowledgement, _relayer: &Signer, - ) -> (ModuleExtras, Result<(), PacketError>) { + ) -> (ModuleExtras, Result<(), ChannelError>) { (ModuleExtras::empty(), Ok(())) } @@ -274,9 +275,9 @@ where &self, packet: &Packet, relayer: &Signer, - ) -> Result<(), PacketError> { + ) -> Result<(), ChannelError> { on_timeout_packet_validate(self, packet, relayer).map_err(|e: TokenTransferError| { - PacketError::AppModule { + ChannelError::AppSpecific { description: e.to_string(), } }) @@ -287,12 +288,12 @@ where &mut self, packet: &Packet, relayer: &Signer, - ) -> (ModuleExtras, Result<(), PacketError>) { + ) -> (ModuleExtras, Result<(), ChannelError>) { let res = on_timeout_packet_execute(self, packet, relayer); ( res.0, res.1 - .map_err(|e: TokenTransferError| PacketError::AppModule { + .map_err(|e: TokenTransferError| ChannelError::AppSpecific { description: e.to_string(), }), ) @@ -305,7 +306,7 @@ where { type AccountId = Signer; - fn get_port(&self) -> Result { + fn get_port(&self) -> Result { Ok(PortId::transfer()) } @@ -313,7 +314,7 @@ where &self, _account: &Self::AccountId, _coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { + ) -> Result<(), HostError> { // Architectures that don't use `dispatch()` and care about the // distinction between `validate()` and `execute()` would want to check // that we can also send the coins between the 2 accounts. @@ -326,7 +327,7 @@ where _account: &Self::AccountId, _coin: &PrefixedCoin, _memo: &Memo, - ) -> Result<(), TokenTransferError> { + ) -> Result<(), HostError> { // Architectures that don't use `dispatch()` and care about the // distinction between `validate()` and `execute()` would want to check // that we can also send the coins between the 2 accounts. @@ -334,11 +335,11 @@ where Ok(()) } - fn can_send_coins(&self) -> Result<(), TokenTransferError> { + fn can_send_coins(&self) -> Result<(), HostError> { Ok(()) } - fn can_receive_coins(&self) -> Result<(), TokenTransferError> { + fn can_receive_coins(&self) -> Result<(), HostError> { Ok(()) } @@ -349,7 +350,7 @@ where _channel_id: &ChannelId, _coin: &PrefixedCoin, _memo: &Memo, - ) -> Result<(), TokenTransferError> { + ) -> Result<(), HostError> { Ok(()) } @@ -359,7 +360,7 @@ where _port_id: &PortId, _channel_id: &ChannelId, _coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { + ) -> Result<(), HostError> { Ok(()) } } @@ -375,16 +376,24 @@ where channel_id: &ChannelId, coin: &PrefixedCoin, _memo: &Memo, - ) -> Result<(), TokenTransferError> { + ) -> Result<(), HostError> { let from = from_account .to_string() .parse() - .map_err(|_| TokenTransferError::FailedToParseAccount)?; + .map_err(|_| HostError::Other { + description: TokenTransferError::FailedToParseAccount.to_string(), + })?; let to = self - .get_escrow_account(port_id, channel_id)? - .to_string() - .parse() - .map_err(|_| TokenTransferError::FailedToParseAccount)?; + .get_escrow_account(port_id, channel_id) + .and_then(|account| { + account + .to_string() + .parse() + .map_err(|_| TokenTransferError::FailedToParseAccount) + }) + .map_err(|e| HostError::Other { + description: e.to_string(), + })?; let coins = vec![Coin { denom: Denom(coin.denom.to_string()), amount: coin.amount.into(), @@ -399,16 +408,24 @@ where port_id: &PortId, channel_id: &ChannelId, coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { + ) -> Result<(), HostError> { let from = self - .get_escrow_account(port_id, channel_id)? - .to_string() - .parse() - .map_err(|_| TokenTransferError::FailedToParseAccount)?; + .get_escrow_account(port_id, channel_id) + .and_then(|account| { + account + .to_string() + .parse() + .map_err(|_| TokenTransferError::FailedToParseAccount) + }) + .map_err(|e| HostError::Other { + description: e.to_string(), + })?; let to = to_account .to_string() .parse() - .map_err(|_| TokenTransferError::FailedToParseAccount)?; + .map_err(|_| HostError::Other { + description: TokenTransferError::FailedToParseAccount.to_string(), + })?; let coins = vec![Coin { denom: Denom(coin.denom.to_string()), amount: coin.amount.into(), @@ -421,11 +438,10 @@ where &mut self, account: &Self::AccountId, amt: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { - let account = account - .to_string() - .parse() - .map_err(|_| TokenTransferError::FailedToParseAccount)?; + ) -> Result<(), HostError> { + let account = account.to_string().parse().map_err(|_| HostError::Other { + description: TokenTransferError::FailedToParseAccount.to_string(), + })?; let coins = vec![Coin { denom: Denom(amt.denom.to_string()), amount: amt.amount.into(), @@ -439,11 +455,10 @@ where account: &Self::AccountId, amt: &PrefixedCoin, _memo: &Memo, - ) -> Result<(), TokenTransferError> { - let account = account - .to_string() - .parse() - .map_err(|_| TokenTransferError::FailedToParseAccount)?; + ) -> Result<(), HostError> { + let account = account.to_string().parse().map_err(|_| HostError::Other { + description: TokenTransferError::FailedToParseAccount.to_string(), + })?; let coins = vec![Coin { denom: Denom(amt.denom.to_string()), amount: amt.amount.into(), diff --git a/basecoin/modules/src/upgrade/impls.rs b/basecoin/modules/src/upgrade/impls.rs index e8abe7f..3e936c2 100644 --- a/basecoin/modules/src/upgrade/impls.rs +++ b/basecoin/modules/src/upgrade/impls.rs @@ -6,9 +6,9 @@ use basecoin_store::types::{Height, Path, ProtobufStore, TypedStore}; use cosmrs::AccountId; use ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusState; use ibc::clients::tendermint::types::ConsensusState as ConsensusStateType; -use ibc::core::client::types::error::UpgradeClientError; use ibc::core::client::types::Height as IbcHeight; use ibc::core::commitment_types::commitment::CommitmentRoot; +use ibc::core::host::types::error::HostError; use ibc::core::host::types::path::{ Path as IbcPath, UpgradeClientStatePath, UpgradeConsensusStatePath, }; @@ -100,7 +100,7 @@ where height: Height, prove: bool, ) -> Result { - let path = path.ok_or(AppError::NotHandled)?; + let path = path.ok_or_else(||AppError::NotHandled)?; if path.to_string() == SDK_UPGRADE_QUERY_PATH { let path: Path = String::from_utf8(data.to_vec()) .map_err(|_| AppError::Custom { @@ -115,7 +115,7 @@ where ); let proof = if prove { - let proof = self.get_proof(height, &path).ok_or(AppError::Custom { + let proof = self.get_proof(height, &path).ok_or_else(||AppError::Custom { reason: "Proof not found".to_string(), })?; Some(vec![ProofOp { @@ -127,7 +127,7 @@ where None }; - let data = self.store.get(height, &path).ok_or(AppError::Custom { + let data = self.store.get(height, &path).ok_or_else(||AppError::Custom { reason: "Data not found".to_string(), })?; return Ok(QueryResult { data, proof }); @@ -137,7 +137,7 @@ where let plan: Any = self .upgrade_plan .get(Height::Pending, &UpgradePlanPath::sdk_pending_path()) - .ok_or(AppError::Custom { + .ok_or_else(||AppError::Custom { reason: "Data not found".to_string(), })? .into(); @@ -228,35 +228,33 @@ where { type V = IbcContext; - fn upgrade_plan(&self) -> Result { + fn upgrade_plan(&self) -> Result { let upgrade_plan = self .upgrade_plan .get(Height::Pending, &UpgradePlanPath::sdk_pending_path()) - .ok_or(UpgradeClientError::InvalidUpgradePlan { - description: "No upgrade plan set".to_string(), - })?; + .ok_or_else(||HostError::invalid_state("No UpgradePlan"))?; Ok(upgrade_plan) } fn upgraded_client_state( &self, upgrade_path: &UpgradeClientStatePath, - ) -> Result { + ) -> Result { let upgraded_tm_client_state = self .upgraded_client_state_store .get(Height::Pending, upgrade_path) - .ok_or(UpgradeClientError::MissingUpgradedClientState)?; + .ok_or_else(||HostError::missing_state("Upgraded ClientState"))?; Ok(upgraded_tm_client_state) } fn upgraded_consensus_state( &self, upgrade_path: &UpgradeConsensusStatePath, - ) -> Result, UpgradeClientError> { + ) -> Result, HostError> { let upgraded_tm_consensus_state = self .upgraded_consensus_state_store .get(Height::Pending, upgrade_path) - .ok_or(UpgradeClientError::MissingUpgradedConsensusState)?; + .ok_or_else(||HostError::missing_state("Upgraded ConsensusState"))?; Ok(upgraded_tm_consensus_state) } } @@ -265,13 +263,13 @@ impl UpgradeExecutionContext for Upgrade where S: 'static + Store + Send + Sync + Debug, { - fn schedule_upgrade(&mut self, plan: Plan) -> Result<(), UpgradeClientError> { + fn schedule_upgrade(&mut self, plan: Plan) -> Result<(), HostError> { let host_height = self.store.current_height(); if plan.height < host_height { - return Err(UpgradeClientError::InvalidUpgradeProposal { - description: "upgrade plan height is in the past".to_string(), - })?; + return Err(HostError::invalid_state( + "Upgrade plan height is in the past", + )); } if self.upgrade_plan().is_ok() { @@ -280,21 +278,17 @@ where self.upgrade_plan .set(UpgradePlanPath::sdk_pending_path(), plan) - .map_err(|e| UpgradeClientError::FailedToStoreUpgradePlan { - description: format!("{e:?}"), - })?; + .map_err(|e| HostError::failed_to_store(format!("UpgradePlan: {e:?}")))?; Ok(()) } - fn clear_upgrade_plan(&mut self, plan_height: u64) -> Result<(), UpgradeClientError> { + fn clear_upgrade_plan(&mut self, plan_height: u64) -> Result<(), HostError> { let path = UpgradePlanPath::sdk_pending_path(); let upgrade_plan = self.upgrade_plan.get(Height::Pending, &path); if upgrade_plan.is_none() { - return Err(UpgradeClientError::InvalidUpgradePlan { - description: "No upgrade plan set".to_string(), - }); + return Err(HostError::invalid_state("No upgrade plan set")); } let upgraded_client_state_path = UpgradeClientStatePath::new_with_default_path(plan_height); @@ -317,12 +311,10 @@ where &mut self, upgrade_path: UpgradeClientStatePath, client_state: AnyClientState, - ) -> Result<(), UpgradeClientError> { + ) -> Result<(), HostError> { self.upgraded_client_state_store .set(upgrade_path, client_state) - .map_err(|e| UpgradeClientError::FailedToStoreUpgradedClientState { - description: format!("{e:?}"), - })?; + .map_err(|e| HostError::failed_to_store(format!("UpgradedClientState: {e:?}")))?; Ok(()) } @@ -331,14 +323,10 @@ where &mut self, upgrade_path: UpgradeConsensusStatePath, consensus_state: AnyConsensusState, - ) -> Result<(), UpgradeClientError> { + ) -> Result<(), HostError> { self.upgraded_consensus_state_store .set(upgrade_path, consensus_state) - .map_err( - |e| UpgradeClientError::FailedToStoreUpgradedConsensusState { - description: format!("{e:?}"), - }, - )?; + .map_err(|e| HostError::failed_to_store(format!("UpgradeConsensusState: {e:?}")))?; Ok(()) } diff --git a/basecoin/modules/src/upgrade/service.rs b/basecoin/modules/src/upgrade/service.rs index 3654cae..871b86b 100644 --- a/basecoin/modules/src/upgrade/service.rs +++ b/basecoin/modules/src/upgrade/service.rs @@ -66,7 +66,7 @@ impl UpgradeQuery for UpgradeService { let upgraded_consensus_state = self .upgraded_consensus_state_store .get(Height::Pending, &upgraded_consensus_state_path) - .ok_or(Status::not_found( + .ok_or_else(||Status::not_found( "upgraded consensus state not found".to_string(), ))?; From ce46ae1d5fc688d090915e4dc91075459e53b79e Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:09:31 +0200 Subject: [PATCH 05/19] fix deprecated warning --- basecoin/src/runner.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/basecoin/src/runner.rs b/basecoin/src/runner.rs index 5740b33..ca5c6f0 100644 --- a/basecoin/src/runner.rs +++ b/basecoin/src/runner.rs @@ -97,7 +97,7 @@ pub async fn default_app_runner(server_cfg: ServerConfig) { // the gRPC reflection service let service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(ibc_proto::FILE_DESCRIPTOR_SET) - .build() + .build_v1() .unwrap(); // run the gRPC server From 9eb89c9068fc1b8550cd4e71bb05d594434f69d6 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:18:17 +0200 Subject: [PATCH 06/19] fix use_self --- basecoin/modules/src/auth/account.rs | 6 ++-- basecoin/modules/src/bank/error.rs | 2 +- basecoin/modules/src/gov/error.rs | 2 +- basecoin/modules/src/gov/msg.rs | 2 +- basecoin/modules/src/gov/proposal.rs | 2 +- basecoin/modules/src/ibc/error.rs | 2 +- basecoin/modules/src/ibc/impls.rs | 8 +++--- basecoin/modules/src/ibc/router.rs | 2 +- basecoin/src/config.rs | 10 +++---- basecoin/src/tx/key_pair.rs | 2 +- basecoin/store/src/avl/node.rs | 2 +- basecoin/store/src/avl/tree.rs | 42 ++++++++++++++-------------- basecoin/store/src/types/height.rs | 4 +-- 13 files changed, 43 insertions(+), 43 deletions(-) diff --git a/basecoin/modules/src/auth/account.rs b/basecoin/modules/src/auth/account.rs index 32dcb53..c43fe75 100644 --- a/basecoin/modules/src/auth/account.rs +++ b/basecoin/modules/src/auth/account.rs @@ -60,7 +60,7 @@ impl TryFrom for AuthAccount { type Error = String; fn try_from(account: BaseAccount) -> Result { - Ok(AuthAccount { + Ok(Self { address: account .address .parse() @@ -73,7 +73,7 @@ impl TryFrom for AuthAccount { impl From for BaseAccount { fn from(account: AuthAccount) -> Self { - BaseAccount { + Self { address: account.address.to_string(), pub_key: None, account_number: account.number, @@ -85,7 +85,7 @@ impl From for BaseAccount { impl From for Any { fn from(account: AuthAccount) -> Self { let account = BaseAccount::from(account); - Any { + Self { type_url: "/cosmos.auth.v1beta1.BaseAccount".to_string(), value: account.encode_to_vec(), } diff --git a/basecoin/modules/src/bank/error.rs b/basecoin/modules/src/bank/error.rs index b8af9b5..d65e4db 100644 --- a/basecoin/modules/src/bank/error.rs +++ b/basecoin/modules/src/bank/error.rs @@ -21,6 +21,6 @@ pub enum Error { impl From for AppError { fn from(e: Error) -> Self { - AppError::Bank(e) + Self::Bank(e) } } diff --git a/basecoin/modules/src/gov/error.rs b/basecoin/modules/src/gov/error.rs index 0cc71e2..4ed6735 100644 --- a/basecoin/modules/src/gov/error.rs +++ b/basecoin/modules/src/gov/error.rs @@ -14,6 +14,6 @@ pub enum Error { impl From for AppError { fn from(e: Error) -> Self { - AppError::Gov(e) + Self::Gov(e) } } diff --git a/basecoin/modules/src/gov/msg.rs b/basecoin/modules/src/gov/msg.rs index 3d54e8b..22450bc 100644 --- a/basecoin/modules/src/gov/msg.rs +++ b/basecoin/modules/src/gov/msg.rs @@ -63,7 +63,7 @@ impl TryFrom for MsgSubmitProposal { fn try_from(raw: Any) -> Result { match raw.type_url.as_str() { - TYPE_URL => MsgSubmitProposal::decode_vec(&raw.value).map_err(|e| Error::Custom { + TYPE_URL => Self::decode_vec(&raw.value).map_err(|e| Error::Custom { reason: e.to_string(), }), _ => Err(Error::Custom { diff --git a/basecoin/modules/src/gov/proposal.rs b/basecoin/modules/src/gov/proposal.rs index 2901585..2810f97 100644 --- a/basecoin/modules/src/gov/proposal.rs +++ b/basecoin/modules/src/gov/proposal.rs @@ -43,7 +43,7 @@ impl TryFrom for Proposal { }) } }; - Ok(Proposal { + Ok(Self { proposal_id: raw.proposal_id, content: raw.content.unwrap(), status, diff --git a/basecoin/modules/src/ibc/error.rs b/basecoin/modules/src/ibc/error.rs index ee6cdd0..4bbff95 100644 --- a/basecoin/modules/src/ibc/error.rs +++ b/basecoin/modules/src/ibc/error.rs @@ -6,6 +6,6 @@ pub type Error = HandlerError; impl From for AppError { fn from(e: Error) -> Self { - AppError::Ibc(e) + Self::Ibc(e) } } diff --git a/basecoin/modules/src/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs index 2657520..a865548 100644 --- a/basecoin/modules/src/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -77,7 +77,7 @@ pub enum AnyClientState { impl From for AnyClientState { fn from(value: ClientStateType) -> Self { - AnyClientState::Tendermint(value.into()) + Self::Tendermint(value.into()) } } @@ -104,7 +104,7 @@ impl TryFrom for AnyClientState { fn try_from(raw: Any) -> Result { if let TENDERMINT_CLIENT_STATE_TYPE_URL = raw.type_url.as_str() { - Ok(AnyClientState::Tendermint(raw.try_into()?)) + Ok(Self::Tendermint(raw.try_into()?)) } else { Err(DecodingError::UnknownTypeUrl(raw.type_url)) } @@ -121,7 +121,7 @@ pub enum AnyConsensusState { impl From for AnyConsensusState { fn from(value: ConsensusStateType) -> Self { - AnyConsensusState::Tendermint(value.into()) + Self::Tendermint(value.into()) } } @@ -150,7 +150,7 @@ impl TryFrom for AnyConsensusState { fn try_from(value: Any) -> Result { if let TENDERMINT_CONSENSUS_STATE_TYPE_URL = value.type_url.as_str() { - Ok(AnyConsensusState::Tendermint(value.try_into()?)) + Ok(Self::Tendermint(value.try_into()?)) } else { Err(DecodingError::UnknownTypeUrl(value.type_url)) } diff --git a/basecoin/modules/src/ibc/router.rs b/basecoin/modules/src/ibc/router.rs index c42320c..a4532c7 100644 --- a/basecoin/modules/src/ibc/router.rs +++ b/basecoin/modules/src/ibc/router.rs @@ -33,7 +33,7 @@ where let transfer_module_id: ModuleId = ModuleId::new(IBC_TRANSFER_MODULE_ID.to_string()); port_to_module_map.insert(PortId::transfer(), transfer_module_id); - IbcRouter { + Self { transfer, port_to_module_map, } diff --git a/basecoin/src/config.rs b/basecoin/src/config.rs index ab5e835..69e452a 100644 --- a/basecoin/src/config.rs +++ b/basecoin/src/config.rs @@ -29,11 +29,11 @@ pub enum LogLevel { impl From for LevelFilter { fn from(level: LogLevel) -> Self { match level { - LogLevel::Trace => LevelFilter::TRACE, - LogLevel::Debug => LevelFilter::DEBUG, - LogLevel::Info => LevelFilter::INFO, - LogLevel::Warn => LevelFilter::WARN, - LogLevel::Error => LevelFilter::ERROR, + LogLevel::Trace => Self::TRACE, + LogLevel::Debug => Self::DEBUG, + LogLevel::Info => Self::INFO, + LogLevel::Warn => Self::WARN, + LogLevel::Error => Self::ERROR, } } } diff --git a/basecoin/src/tx/key_pair.rs b/basecoin/src/tx/key_pair.rs index 7ea8545..8313fc7 100644 --- a/basecoin/src/tx/key_pair.rs +++ b/basecoin/src/tx/key_pair.rs @@ -70,7 +70,7 @@ impl KeyPair { let public_key = derived_pubkey.public_key; let private_key = private_key.private_key; - Ok(KeyPair::new(public_key, private_key, account, address)) + Ok(Self::new(public_key, private_key, account, address)) } pub fn sign(&self, message: &[u8]) -> Result, Error> { diff --git a/basecoin/store/src/avl/node.rs b/basecoin/store/src/avl/node.rs index 59199a0..b5599ac 100644 --- a/basecoin/store/src/avl/node.rs +++ b/basecoin/store/src/avl/node.rs @@ -51,7 +51,7 @@ where let merkle_hash = Hash::from_bytes(HASH_ALGO, &merkle_hash).unwrap(); let hash = Hash::from_bytes(HASH_ALGO, &hash).unwrap(); - AvlNode { + Self { key, value, hash, diff --git a/basecoin/store/src/avl/tree.rs b/basecoin/store/src/avl/tree.rs index 3333dd6..351c92b 100644 --- a/basecoin/store/src/avl/tree.rs +++ b/basecoin/store/src/avl/tree.rs @@ -20,7 +20,7 @@ pub struct AvlTree { impl> AvlTree { /// Return an empty AVL tree. pub fn new() -> Self { - AvlTree { root: None } + Self { root: None } } /// Return the hash of the merkle tree root, if it has at least one node. @@ -48,21 +48,21 @@ impl> AvlTree { /// Insert a value into the AVL tree, this operation runs in amortized O(log(n)). pub fn insert(&mut self, key: K, value: V) -> Option { let node_ref = &mut self.root; - AvlTree::insert_rec(node_ref, key, value) + Self::insert_rec(node_ref, key, value) } /// Insert a value in the tree. fn insert_rec(node_ref: &mut NodeRef, key: K, value: V) -> Option { if let Some(node) = node_ref { let old_value = match node.key.cmp(&key) { - Ordering::Greater => AvlTree::insert_rec(&mut node.left, key, value), - Ordering::Less => AvlTree::insert_rec(&mut node.right, key, value), + Ordering::Greater => Self::insert_rec(&mut node.left, key, value), + Ordering::Less => Self::insert_rec(&mut node.right, key, value), Ordering::Equal => Some(node.set_value(value)), }; node.update(); // Note: when old_value is None, balancing not necessary. // But we do it anyway as general rule. - AvlTree::balance_node(node_ref); + Self::balance_node(node_ref); old_value } else { *node_ref = as_node_ref(key, value); @@ -73,7 +73,7 @@ impl> AvlTree { /// Remove a value from the AVL tree, this operation runs in amortized O(log(n)). pub fn remove(&mut self, key: K) -> Option { let node_ref = &mut self.root; - AvlTree::remove_rec(node_ref, key).map(|node| node.value) + Self::remove_rec(node_ref, key).map(|node| node.value) } /// Remove a value from the tree. @@ -83,9 +83,9 @@ impl> AvlTree { let node = node_ref.as_deref_mut()?; let removed_value = match node.key.cmp(&key) { - Ordering::Greater => AvlTree::remove_rec(&mut node.left, key), - Ordering::Less => AvlTree::remove_rec(&mut node.right, key), - Ordering::Equal => AvlTree::remove_root(node_ref), + Ordering::Greater => Self::remove_rec(&mut node.left, key), + Ordering::Less => Self::remove_rec(&mut node.right, key), + Ordering::Equal => Self::remove_root(node_ref), }; if let Some(node) = node_ref { @@ -94,7 +94,7 @@ impl> AvlTree { // Note: if removed_value is None, nothing is removed. // So no need to update and balance. node.update(); - AvlTree::balance_node(node_ref); + Self::balance_node(node_ref); } } @@ -130,7 +130,7 @@ impl> AvlTree { // removing from right subtree is better. // Remove the leftmost node in the right subtree and replace the current. - let mut leftmost_node_ref = AvlTree::remove_leftmost(&mut node.right); + let mut leftmost_node_ref = Self::remove_leftmost(&mut node.right); // leftmost_node_ref.right <- node_ref.right // leftmost_node_ref.left <- node_ref.left if let Some(leftmost_node) = leftmost_node_ref.as_mut() { @@ -149,7 +149,7 @@ impl> AvlTree { // removing from left subtree is better. // Remove the rightmost node in the left subtree and replace the current. - let mut rightmost_node_ref = AvlTree::remove_rightmost(&mut node.left); + let mut rightmost_node_ref = Self::remove_rightmost(&mut node.left); // rightmost_node_ref.right <- node_ref.right // rightmost_node_ref.left <- node_ref.left if let Some(rightmost_node) = rightmost_node_ref.as_mut() { @@ -169,7 +169,7 @@ impl> AvlTree { if let Some(node) = node_ref { // need to update, as top node is replaced node.update(); - AvlTree::balance_node(node_ref); + Self::balance_node(node_ref); } removed_node @@ -186,11 +186,11 @@ impl> AvlTree { // no need to update, as the new node (right_node) is already updated } else { - let removed_node = AvlTree::remove_leftmost(&mut node.left); + let removed_node = Self::remove_leftmost(&mut node.left); // need to update, as left node is updated node.update(); - AvlTree::balance_node(node_ref); + Self::balance_node(node_ref); removed_node } @@ -207,11 +207,11 @@ impl> AvlTree { // no need to update, as the new node (left_node) is already updated } else { - let removed_node = AvlTree::remove_rightmost(&mut node.right); + let removed_node = Self::remove_rightmost(&mut node.right); // need to update, as right node is updated node.update(); - AvlTree::balance_node(node_ref); + Self::balance_node(node_ref); removed_node } @@ -338,18 +338,18 @@ impl> AvlTree { .as_mut() .expect("[AVL]: Unexpected empty left node"); if left.balance_factor() < 1 { - AvlTree::rotate_left(&mut node.left); + Self::rotate_left(&mut node.left); } - AvlTree::rotate_right(node_ref); + Self::rotate_right(node_ref); } else if balance_factor <= -2 { let right = node .right .as_mut() .expect("[AVL]: Unexpected empty right node"); if right.balance_factor() > -1 { - AvlTree::rotate_right(&mut node.right); + Self::rotate_right(&mut node.right); } - AvlTree::rotate_left(node_ref); + Self::rotate_left(node_ref); } } diff --git a/basecoin/store/src/types/height.rs b/basecoin/store/src/types/height.rs index 3ca399c..54bcedc 100644 --- a/basecoin/store/src/types/height.rs +++ b/basecoin/store/src/types/height.rs @@ -12,8 +12,8 @@ pub enum Height { impl From for Height { fn from(value: u64) -> Self { match value { - 0 => Height::Latest, // see https://docs.tendermint.com/master/spec/abci/abci.html#query - _ => Height::Stable(value), + 0 => Self::Latest, // see https://docs.tendermint.com/master/spec/abci/abci.html#query + _ => Self::Stable(value), } } } From 4eb2aa7583b8bbbdb7d0498cc2ae2cb21ac5db36 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:19:06 +0200 Subject: [PATCH 07/19] short first doc paragraph --- basecoin/store/src/impls/growing.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/basecoin/store/src/impls/growing.rs b/basecoin/store/src/impls/growing.rs index 6daeb6f..3ba6cdb 100644 --- a/basecoin/store/src/impls/growing.rs +++ b/basecoin/store/src/impls/growing.rs @@ -4,6 +4,7 @@ use crate::context::{ProvableStore, Store}; use crate::types::{Height, Path}; /// GrowingStore does not prune any path. +/// /// If the path is set to v, the stored value is v /// If the path is deleted, the stored value is [] /// Note: we should not allow empty vec to store as From 633601c1fd0889c9d6581cb9ce42973557951597 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:20:52 +0200 Subject: [PATCH 08/19] fix redundant_clone --- basecoin/modules/src/ibc/client_contexts.rs | 2 +- basecoin/src/tx/mod.rs | 2 +- basecoin/store/src/impls/in_memory.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/basecoin/modules/src/ibc/client_contexts.rs b/basecoin/modules/src/ibc/client_contexts.rs index 8f282ee..002bebe 100644 --- a/basecoin/modules/src/ibc/client_contexts.rs +++ b/basecoin/modules/src/ibc/client_contexts.rs @@ -181,7 +181,7 @@ where ); self.client_processed_times.delete(client_update_time_path); let client_update_height_path = ClientUpdateHeightPath::new( - client_id.clone(), + client_id, height.revision_number(), height.revision_height(), ); diff --git a/basecoin/src/tx/mod.rs b/basecoin/src/tx/mod.rs index 6d6723e..bdd1627 100644 --- a/basecoin/src/tx/mod.rs +++ b/basecoin/src/tx/mod.rs @@ -56,7 +56,7 @@ pub fn sign_tx( account_info.account_number, )?; - let (_, tx_bytes) = encode_tx(body_bytes, auth_info_bytes, signature_bytes.clone())?; + let (_, tx_bytes) = encode_tx(body_bytes, auth_info_bytes, signature_bytes)?; Ok(tx_bytes) } diff --git a/basecoin/store/src/impls/in_memory.rs b/basecoin/store/src/impls/in_memory.rs index d02ddb8..64ae5b0 100644 --- a/basecoin/store/src/impls/in_memory.rs +++ b/basecoin/store/src/impls/in_memory.rs @@ -115,7 +115,7 @@ impl Default for InMemoryStore { let store = PrunedVec::default(); let staged = genesis_state.clone(); - let pending = genesis_state.clone(); + let pending = genesis_state; Self { store, @@ -267,8 +267,8 @@ mod tests { assert_eq!(store.get(Height::Pending, &path), Some(value2.clone())); assert_eq!(store.get(Height::Latest, &path), Some(value2.clone())); - assert_eq!(store.get(Height::Stable(1), &path), Some(value1.clone())); - assert_eq!(store.get(Height::Stable(2), &path), Some(value2.clone())); + assert_eq!(store.get(Height::Stable(1), &path), Some(value1)); + assert_eq!(store.get(Height::Stable(2), &path), Some(value2)); assert_eq!(store.get(Height::Stable(3), &path), None); assert_eq!(store.current_height(), 2); assert!(!store.root_hash().is_empty()); From 5a061e70e51af93b8e8c04d4a6257bd99732f34d Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:22:32 +0200 Subject: [PATCH 09/19] fix empty_line_after_outer_attr --- basecoin/store/src/types/path.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/basecoin/store/src/types/path.rs b/basecoin/store/src/types/path.rs index c843e54..01a7892 100644 --- a/basecoin/store/src/types/path.rs +++ b/basecoin/store/src/types/path.rs @@ -16,7 +16,6 @@ pub enum Error { /// A new type representing a valid ICS024 `Path`. #[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone)] - pub struct Path(Vec); impl Path { From e211eed8e10fb27e020ceb6deaee696ff8a53360 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:24:17 +0200 Subject: [PATCH 10/19] fix needless_collect --- basecoin/modules/src/bank/impls.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/basecoin/modules/src/bank/impls.rs b/basecoin/modules/src/bank/impls.rs index e71f881..50f77a2 100644 --- a/basecoin/modules/src/bank/impls.rs +++ b/basecoin/modules/src/bank/impls.rs @@ -297,8 +297,7 @@ where account_id, balances .into_iter() - .map(|b| b.into()) - .collect::>(), + .map(|b| b.into()), ) .unwrap(); } From fa057110b9199bc273cc57852a02de63d197e57f Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:42:13 +0200 Subject: [PATCH 11/19] update deps --- Cargo.toml | 13 +++++++------ basecoin/Cargo.toml | 8 ++++---- basecoin/app/Cargo.toml | 2 +- basecoin/modules/Cargo.toml | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8a16311..9ab71a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,23 +16,24 @@ authors = [ "Informal Systems " ] [workspace.dependencies] # external dependencies base64 = { version = "0.22.1", default-features = false, features = [ "alloc" ] } -cosmrs = { version = "0.18.0" } +cosmrs = { version = "0.20.0" } displaydoc = { version = "0.2", default-features = false } -derive_more = { version = "0.99.18", default-features = false, features = [ "from", "into", "display" ] } +derive_more = { version = "1.0.0", default-features = false, features = [ "from", "into", "try_into", "display" ] } ed25519 = { version = "2.2.3", default-features = false } -prost = { version = "0.13.1", default-features = false } +prost = { version = "0.13.3", default-features = false } +serde_derive = { version = "1.0", default-features = false } serde = "1.0" serde_json = "1.0" sha2 = "0.10.8" -tonic = "0.12.1" -tonic-reflection = "0.12.1" +tonic = "0.12.2" +tonic-reflection = "0.12.2" tracing = "0.1.40" tracing-subscriber = "0.3.18" # ibc dependencies ibc = { version = "0.54.0", default-features = false, features = [ "serde" ] } ibc-query = { version = "0.54.0", default-features = false } -ibc-proto = { version = "0.47.0", default-features = false } +ibc-proto = { version = "0.47.1", default-features = false } ics23 = { version = "0.12", default-features = false } # tendermint dependencies diff --git a/basecoin/Cargo.toml b/basecoin/Cargo.toml index 480cf78..c40c51f 100644 --- a/basecoin/Cargo.toml +++ b/basecoin/Cargo.toml @@ -20,14 +20,14 @@ tiny-bip39 = { version = "1" } digest = { version = "0.10.7" } bitcoin = { version = "0.32.2" } hdpath = { version = "0.6.3" } -clap = { version = "4.5.7", features = [ "derive", "wrap_help" ] } +clap = { version = "4.5", features = [ "derive", "wrap_help" ] } prost = { workspace = true } serde = { workspace = true } -serde_derive = { version = "1.0.203", default-features = false } +serde_derive = { workspace = true } serde_json = { workspace = true } -secp256k1 = { version = "0.29.0", features = [ "serde", "rand-std" ] } +secp256k1 = { version = "0.29", features = [ "serde", "rand-std" ] } sha2 = { workspace = true } -tokio = { version = "1.38", features = [ "macros", "rt-multi-thread" ] } +tokio = { version = "1.40", features = [ "macros", "rt-multi-thread" ] } tonic = { workspace = true } tonic-reflection = { workspace = true } toml = { version = "0.8" } diff --git a/basecoin/app/Cargo.toml b/basecoin/app/Cargo.toml index fb35310..c41b1a1 100644 --- a/basecoin/app/Cargo.toml +++ b/basecoin/app/Cargo.toml @@ -26,7 +26,7 @@ prost = { workspace = true } serde_json = { workspace = true } tonic = { workspace = true } tracing = { workspace = true } -tower = { version = "0.4", features = [ "full" ], optional = true } +tower = { version = "0.5", features = [ "full" ], optional = true } # tedermint dependencies tendermint = { workspace = true } diff --git a/basecoin/modules/Cargo.toml b/basecoin/modules/Cargo.toml index 68e9303..199be99 100644 --- a/basecoin/modules/Cargo.toml +++ b/basecoin/modules/Cargo.toml @@ -17,7 +17,7 @@ derive_more = { workspace = true } primitive-types = { version = "0.12.2", default-features = false, features = [ "serde_no_std" ] } prost = { workspace = true } serde = { workspace = true } -serde_derive = { version = "1.0.203", default-features = false } +serde_derive = { workspace = true } serde_json = { workspace = true } sha2 = { workspace = true } tonic = { workspace = true } From 1789d2ff241ab11d2fc3b16d5fbf8747a9cb415c Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:44:46 +0200 Subject: [PATCH 12/19] update msrv to 1.75 for derive_more --- Cargo.toml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9ab71a4..9bc8af9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ members = [ "basecoin", "basecoin/app", "basecoin/modules", "basecoin/store" ] version = "0.2.0" license = "Apache-2.0" edition = "2021" -rust-version = "1.64" +rust-version = "1.75" readme = "README.md" repository = "https://github.com/informalsystems/basecoin-rs" authors = [ "Informal Systems " ] diff --git a/README.md b/README.md index 25afe51..a629c80 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ of the ibc-rs modules. ## Requirements So far this app has been tested with: -* Rust > v1.64 +* Rust > v1.75 * CometBFT v0.37 ## How to integrate ibc-rs changes into basecoin From d9915ad69cf6b3c57ec94fbb13e9294f27d29ac7 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:46:27 +0200 Subject: [PATCH 13/19] update cargo lockfile --- Cargo.lock | 185 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 130 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b86a62..0cd0055 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -267,11 +267,11 @@ dependencies = [ "ibc-proto", "prost", "serde_json", - "tendermint", + "tendermint 0.38.1", "tendermint-abci", - "tendermint-proto", + "tendermint-proto 0.38.1", "tonic", - "tower 0.4.13", + "tower 0.5.1", "tower-abci", "tracing", ] @@ -283,7 +283,7 @@ dependencies = [ "base64 0.22.1", "basecoin-store", "cosmrs", - "derive_more", + "derive_more 1.0.0", "displaydoc", "ibc", "ibc-proto", @@ -295,7 +295,7 @@ dependencies = [ "serde_derive", "serde_json", "sha2 0.10.8", - "tendermint", + "tendermint 0.38.1", "tendermint-rpc", "tonic", "tracing", @@ -312,7 +312,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "tendermint", + "tendermint 0.38.1", "tracing", ] @@ -560,20 +560,19 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cosmos-sdk-proto" -version = "0.23.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2f63ab112b8c8e7b8a29c891adc48f43145beb21c0bfbf562957072c1e0beb" +checksum = "e8ce7f4797cdf5cd18be6555ff3f0a8d37023c2d60f3b2708895d601b85c1c46" dependencies = [ "prost", - "prost-types", - "tendermint-proto", + "tendermint-proto 0.39.1", ] [[package]] name = "cosmrs" -version = "0.18.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f21bb63ec6a903510a3d01f44735dd4914724e5eccbe409e6da6833d17c7829" +checksum = "09f90935b72d9fa65a2a784e09f25778637b7e88e9d6f87c717081470f7fa726" dependencies = [ "bip32", "cosmos-sdk-proto", @@ -585,7 +584,7 @@ dependencies = [ "serde_json", "signature", "subtle-encoding", - "tendermint", + "tendermint 0.39.1", "thiserror", ] @@ -669,6 +668,27 @@ dependencies = [ "syn", ] +[[package]] +name = "derive_more" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + [[package]] name = "digest" version = "0.9.0" @@ -1269,7 +1289,7 @@ name = "ibc-app-transfer-types" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core", "ibc-proto", @@ -1291,7 +1311,7 @@ name = "ibc-client-tendermint" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "ibc-client-tendermint-types", "ibc-core-client", "ibc-core-commitment-types", @@ -1299,7 +1319,7 @@ dependencies = [ "ibc-core-host", "ibc-primitives", "serde", - "tendermint", + "tendermint 0.38.1", "tendermint-light-client-verifier", ] @@ -1315,9 +1335,9 @@ dependencies = [ "ibc-primitives", "ibc-proto", "serde", - "tendermint", + "tendermint 0.38.1", "tendermint-light-client-verifier", - "tendermint-proto", + "tendermint-proto 0.38.1", ] [[package]] @@ -1379,7 +1399,7 @@ name = "ibc-core-channel-types" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-client-types", "ibc-core-commitment-types", @@ -1390,7 +1410,7 @@ dependencies = [ "serde", "sha2 0.10.8", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", ] [[package]] @@ -1411,7 +1431,7 @@ name = "ibc-core-client-context" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-client-types", "ibc-core-commitment-types", @@ -1419,7 +1439,7 @@ dependencies = [ "ibc-core-host-types", "ibc-primitives", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", ] [[package]] @@ -1427,7 +1447,7 @@ name = "ibc-core-client-types" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-commitment-types", "ibc-core-host-types", @@ -1435,7 +1455,7 @@ dependencies = [ "ibc-proto", "serde", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", ] [[package]] @@ -1443,7 +1463,7 @@ name = "ibc-core-commitment-types" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-host-types", "ibc-primitives", @@ -1470,7 +1490,7 @@ name = "ibc-core-connection-types" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-client-types", "ibc-core-commitment-types", @@ -1479,7 +1499,7 @@ dependencies = [ "ibc-proto", "serde", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", ] [[package]] @@ -1502,7 +1522,7 @@ name = "ibc-core-handler-types" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-channel-types", "ibc-core-client-types", @@ -1514,7 +1534,7 @@ dependencies = [ "ibc-proto", "serde", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", ] [[package]] @@ -1522,7 +1542,7 @@ name = "ibc-core-host" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-channel-types", "ibc-core-client-context", @@ -1540,7 +1560,7 @@ name = "ibc-core-host-cosmos" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-app-transfer-types", "ibc-client-tendermint", @@ -1555,7 +1575,7 @@ dependencies = [ "serde", "sha2 0.10.8", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", ] [[package]] @@ -1564,7 +1584,7 @@ version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ "base64 0.22.1", - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-primitives", "prost", @@ -1576,7 +1596,7 @@ name = "ibc-core-router" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-channel-types", "ibc-core-host-types", @@ -1590,14 +1610,14 @@ name = "ibc-core-router-types" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-core-host-types", "ibc-primitives", "ibc-proto", "serde", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", ] [[package]] @@ -1615,12 +1635,12 @@ name = "ibc-primitives" version = "0.54.0" source = "git+https://github.com/cosmos/ibc-rs.git?rev=cfb707e#cfb707eaee2c3cd8e04378ba3eee033ec73fd4f9" dependencies = [ - "derive_more", + "derive_more 0.99.18", "displaydoc", "ibc-proto", "prost", "serde", - "tendermint", + "tendermint 0.38.1", "time", ] @@ -1638,7 +1658,7 @@ dependencies = [ "prost", "serde", "subtle-encoding", - "tendermint-proto", + "tendermint-proto 0.38.1", "tonic", ] @@ -2136,9 +2156,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62871f2d65009c0256aed1b9cfeeb8ac272833c404e13d53d400cd0dad7a2ac0" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags 2.6.0", ] @@ -2459,9 +2479,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -2676,11 +2696,39 @@ dependencies = [ "ed25519-consensus", "flex-error", "futures", - "k256", "num-traits", "once_cell", "prost", "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.8", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto 0.38.1", + "time", + "zeroize", +] + +[[package]] +name = "tendermint" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3afea7809ffaaf1e5d9c3c9997cb3a834df7e94fbfab2fad2bc4577f1cde41" +dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "k256", + "num-traits", + "once_cell", + "prost", "ripemd", "serde", "serde_bytes", @@ -2690,7 +2738,7 @@ dependencies = [ "signature", "subtle", "subtle-encoding", - "tendermint-proto", + "tendermint-proto 0.39.1", "time", "zeroize", ] @@ -2704,7 +2752,7 @@ dependencies = [ "bytes", "flex-error", "prost", - "tendermint-proto", + "tendermint-proto 0.38.1", "tracing", ] @@ -2717,7 +2765,7 @@ dependencies = [ "flex-error", "serde", "serde_json", - "tendermint", + "tendermint 0.38.1", "toml", "url", ] @@ -2728,10 +2776,10 @@ version = "0.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2674adbf0dc51aa0c8eaf8462c7d6692ec79502713e50ed5432a442002be90" dependencies = [ - "derive_more", + "derive_more 0.99.18", "flex-error", "serde", - "tendermint", + "tendermint 0.38.1", "time", ] @@ -2751,6 +2799,21 @@ dependencies = [ "time", ] +[[package]] +name = "tendermint-proto" +version = "0.39.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf3abf34ecf33125621519e9952688e7a59a98232d51538037ba21fbe526a802" +dependencies = [ + "bytes", + "flex-error", + "prost", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + [[package]] name = "tendermint-rpc" version = "0.38.1" @@ -2772,9 +2835,9 @@ dependencies = [ "serde_json", "subtle", "subtle-encoding", - "tendermint", + "tendermint 0.38.1", "tendermint-config", - "tendermint-proto", + "tendermint-proto 0.38.1", "thiserror", "time", "tokio", @@ -3071,10 +3134,16 @@ checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" dependencies = [ "futures-core", "futures-util", + "hdrhistogram", + "indexmap 2.5.0", "pin-project-lite", + "slab", "sync_wrapper 0.1.2", + "tokio", + "tokio-util 0.7.12", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -3086,8 +3155,8 @@ dependencies = [ "futures", "pin-project", "prost", - "tendermint", - "tendermint-proto", + "tendermint 0.38.1", + "tendermint-proto 0.38.1", "tokio", "tokio-stream", "tokio-util 0.6.10", @@ -3210,6 +3279,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + [[package]] name = "untrusted" version = "0.9.0" @@ -3534,9 +3609,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.19" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c52ac009d615e79296318c1bcce2d422aaca15ad08515e344feeda07df67a587" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] From 3b64a6127f7a2137f4e842da7c55439d33caaa1e Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 11:48:47 +0200 Subject: [PATCH 14/19] fmt --- basecoin/modules/src/bank/impls.rs | 7 +------ basecoin/modules/src/upgrade/impls.rs | 27 +++++++++++++++---------- basecoin/modules/src/upgrade/service.rs | 4 +--- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/basecoin/modules/src/bank/impls.rs b/basecoin/modules/src/bank/impls.rs index 50f77a2..787cfb4 100644 --- a/basecoin/modules/src/bank/impls.rs +++ b/basecoin/modules/src/bank/impls.rs @@ -293,12 +293,7 @@ where let account_id = AccountId::from_str(&account).unwrap(); self.balance_keeper - .mint_coins( - account_id, - balances - .into_iter() - .map(|b| b.into()), - ) + .mint_coins(account_id, balances.into_iter().map(|b| b.into())) .unwrap(); } } diff --git a/basecoin/modules/src/upgrade/impls.rs b/basecoin/modules/src/upgrade/impls.rs index 3e936c2..3e33c37 100644 --- a/basecoin/modules/src/upgrade/impls.rs +++ b/basecoin/modules/src/upgrade/impls.rs @@ -100,7 +100,7 @@ where height: Height, prove: bool, ) -> Result { - let path = path.ok_or_else(||AppError::NotHandled)?; + let path = path.ok_or_else(|| AppError::NotHandled)?; if path.to_string() == SDK_UPGRADE_QUERY_PATH { let path: Path = String::from_utf8(data.to_vec()) .map_err(|_| AppError::Custom { @@ -115,9 +115,11 @@ where ); let proof = if prove { - let proof = self.get_proof(height, &path).ok_or_else(||AppError::Custom { - reason: "Proof not found".to_string(), - })?; + let proof = self + .get_proof(height, &path) + .ok_or_else(|| AppError::Custom { + reason: "Proof not found".to_string(), + })?; Some(vec![ProofOp { field_type: "".to_string(), key: path.to_string().into_bytes(), @@ -127,9 +129,12 @@ where None }; - let data = self.store.get(height, &path).ok_or_else(||AppError::Custom { - reason: "Data not found".to_string(), - })?; + let data = self + .store + .get(height, &path) + .ok_or_else(|| AppError::Custom { + reason: "Data not found".to_string(), + })?; return Ok(QueryResult { data, proof }); } @@ -137,7 +142,7 @@ where let plan: Any = self .upgrade_plan .get(Height::Pending, &UpgradePlanPath::sdk_pending_path()) - .ok_or_else(||AppError::Custom { + .ok_or_else(|| AppError::Custom { reason: "Data not found".to_string(), })? .into(); @@ -232,7 +237,7 @@ where let upgrade_plan = self .upgrade_plan .get(Height::Pending, &UpgradePlanPath::sdk_pending_path()) - .ok_or_else(||HostError::invalid_state("No UpgradePlan"))?; + .ok_or_else(|| HostError::invalid_state("No UpgradePlan"))?; Ok(upgrade_plan) } @@ -243,7 +248,7 @@ where let upgraded_tm_client_state = self .upgraded_client_state_store .get(Height::Pending, upgrade_path) - .ok_or_else(||HostError::missing_state("Upgraded ClientState"))?; + .ok_or_else(|| HostError::missing_state("Upgraded ClientState"))?; Ok(upgraded_tm_client_state) } @@ -254,7 +259,7 @@ where let upgraded_tm_consensus_state = self .upgraded_consensus_state_store .get(Height::Pending, upgrade_path) - .ok_or_else(||HostError::missing_state("Upgraded ConsensusState"))?; + .ok_or_else(|| HostError::missing_state("Upgraded ConsensusState"))?; Ok(upgraded_tm_consensus_state) } } diff --git a/basecoin/modules/src/upgrade/service.rs b/basecoin/modules/src/upgrade/service.rs index 871b86b..9fd365f 100644 --- a/basecoin/modules/src/upgrade/service.rs +++ b/basecoin/modules/src/upgrade/service.rs @@ -66,9 +66,7 @@ impl UpgradeQuery for UpgradeService { let upgraded_consensus_state = self .upgraded_consensus_state_store .get(Height::Pending, &upgraded_consensus_state_path) - .ok_or_else(||Status::not_found( - "upgraded consensus state not found".to_string(), - ))?; + .ok_or_else(|| Status::not_found("upgraded consensus state not found".to_string()))?; let any_cons_state = Any::from(upgraded_consensus_state); let mut cons_state_value = Vec::new(); From b4b9c64dcf55670fd0b3eeb827a987cb4546acae Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 14:54:12 +0200 Subject: [PATCH 15/19] fix significant_drop_tightening --- basecoin/modules/src/gov/impls.rs | 14 +++++++------- basecoin/modules/src/ibc/impls.rs | 7 +++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/basecoin/modules/src/gov/impls.rs b/basecoin/modules/src/gov/impls.rs index a894d83..270342c 100644 --- a/basecoin/modules/src/gov/impls.rs +++ b/basecoin/modules/src/gov/impls.rs @@ -79,13 +79,13 @@ where let upgrade_proposal = UpgradeProposal::decode_vec(message.content.value.as_slice()).unwrap(); - let mut upgrade_ctx = self.upgrade_ctx.write_access(); - - let event = - execute_upgrade_client_proposal(upgrade_ctx.deref_mut(), upgrade_proposal) - .map_err(|e| AppError::Custom { - reason: format!("Error handling upgrade proposal: {:?}", e), - })?; + let event = execute_upgrade_client_proposal( + self.upgrade_ctx.write_access().deref_mut(), + upgrade_proposal, + ) + .map_err(|e| AppError::Custom { + reason: format!("Error handling upgrade proposal: {:?}", e), + })?; let proposal = message.proposal(self.proposal_counter); diff --git a/basecoin/modules/src/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs index a865548..7d659ca 100644 --- a/basecoin/modules/src/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -492,12 +492,11 @@ where height: &IbcHeight, ) -> Result { let consensus_states_binding = self.consensus_states.read().expect("lock is poisoned"); - let consensus_state = consensus_states_binding + Ok(consensus_states_binding .get(&height.revision_height()) .ok_or_else(|| ClientError::MissingLocalConsensusState(*height)) - .map_err(HostError::missing_state)?; - - Ok(consensus_state.clone()) + .map_err(HostError::missing_state)? + .clone()) } fn client_counter(&self) -> Result { From 4414fd459208d8d2fd4ca84eafd82abd67461afd Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 14:54:52 +0200 Subject: [PATCH 16/19] fix equatable_if_let --- basecoin/modules/src/ibc/impls.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basecoin/modules/src/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs index 7d659ca..2f8f8ac 100644 --- a/basecoin/modules/src/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -103,7 +103,7 @@ impl TryFrom for AnyClientState { type Error = DecodingError; fn try_from(raw: Any) -> Result { - if let TENDERMINT_CLIENT_STATE_TYPE_URL = raw.type_url.as_str() { + if raw.type_url.as_str() == TENDERMINT_CLIENT_STATE_TYPE_URL { Ok(Self::Tendermint(raw.try_into()?)) } else { Err(DecodingError::UnknownTypeUrl(raw.type_url)) @@ -149,7 +149,7 @@ impl TryFrom for AnyConsensusState { type Error = DecodingError; fn try_from(value: Any) -> Result { - if let TENDERMINT_CONSENSUS_STATE_TYPE_URL = value.type_url.as_str() { + if value.type_url.as_str() == TENDERMINT_CONSENSUS_STATE_TYPE_URL { Ok(Self::Tendermint(value.try_into()?)) } else { Err(DecodingError::UnknownTypeUrl(value.type_url)) From 97db90550ccb58fec3afb50404e694da04213134 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 14:56:00 +0200 Subject: [PATCH 17/19] fix string_lit_as_bytes --- basecoin/store/src/avl/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/basecoin/store/src/avl/tests.rs b/basecoin/store/src/avl/tests.rs index 2e5c96e..a1fffd2 100644 --- a/basecoin/store/src/avl/tests.rs +++ b/basecoin/store/src/avl/tests.rs @@ -151,7 +151,7 @@ fn proof() { .expect("There should be a leaf in the proof"); let mut sha = Sha256::new(); sha.update(&leaf.prefix); - sha.update("B".as_bytes()); + sha.update(b"B"); sha.update([1]); let child_hash = sha.finalize(); // Apply first inner node transformations @@ -176,7 +176,7 @@ fn proof() { &ics_proof, &spec, &root.as_bytes().to_vec(), - "B".as_bytes(), + b"B", &[1] )); } From 4ebacf0e0716a0505b7f8111242c484b93349b6c Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Thu, 26 Sep 2024 17:14:46 +0200 Subject: [PATCH 18/19] use ok_or --- basecoin/modules/src/gov/impls.rs | 2 +- basecoin/modules/src/ibc/impls.rs | 2 +- basecoin/modules/src/upgrade/impls.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/basecoin/modules/src/gov/impls.rs b/basecoin/modules/src/gov/impls.rs index 270342c..388be43 100644 --- a/basecoin/modules/src/gov/impls.rs +++ b/basecoin/modules/src/gov/impls.rs @@ -134,7 +134,7 @@ where _height: Height, _prove: bool, ) -> Result { - let path = path.ok_or_else(|| AppError::NotHandled)?; + let path = path.ok_or(AppError::NotHandled)?; if path.to_string() != "/cosmos.gov.v1beta1.Query/Proposal" { return Err(AppError::NotHandled); diff --git a/basecoin/modules/src/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs index 2f8f8ac..31d7450 100644 --- a/basecoin/modules/src/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -278,7 +278,7 @@ where height: Height, prove: bool, ) -> Result { - let path = path.ok_or_else(|| AppError::NotHandled)?; + let path = path.ok_or(AppError::NotHandled)?; if path.to_string() != IBC_QUERY_PATH { return Err(AppError::NotHandled); } diff --git a/basecoin/modules/src/upgrade/impls.rs b/basecoin/modules/src/upgrade/impls.rs index 3e33c37..f94ad6f 100644 --- a/basecoin/modules/src/upgrade/impls.rs +++ b/basecoin/modules/src/upgrade/impls.rs @@ -100,7 +100,7 @@ where height: Height, prove: bool, ) -> Result { - let path = path.ok_or_else(|| AppError::NotHandled)?; + let path = path.ok_or(AppError::NotHandled)?; if path.to_string() == SDK_UPGRADE_QUERY_PATH { let path: Path = String::from_utf8(data.to_vec()) .map_err(|_| AppError::Custom { From 12455e6ec508a05c71d90c404bdc2c38f3e14ed9 Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Thu, 26 Sep 2024 11:02:13 -0700 Subject: [PATCH 19/19] fix: use missing_state everywhere storage call returns None --- basecoin/modules/src/ibc/impls.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/basecoin/modules/src/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs index 31d7450..a8a47ad 100644 --- a/basecoin/modules/src/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -508,7 +508,7 @@ where fn connection_end(&self, conn_id: &ConnectionId) -> Result { self.connection_end_store .get(Height::Pending, &ConnectionPath::new(conn_id)) - .ok_or_else(|| HostError::failed_to_retrieve(format!("connection end: {}", conn_id))) + .ok_or_else(|| HostError::missing_state(format!("connection end: {}", conn_id))) } fn validate_self_client( @@ -587,7 +587,7 @@ where commitment_path.sequence, ), ) - .ok_or_else(|| HostError::failed_to_retrieve("packet commitment")) + .ok_or_else(|| HostError::missing_state("packet commitment")) } fn get_packet_receipt(&self, receipt_path: &ReceiptPath) -> Result { @@ -601,7 +601,7 @@ where ), ) .then_some(Receipt::Ok) - .ok_or_else(|| HostError::failed_to_retrieve("packet receipt")) + .ok_or_else(|| HostError::missing_state("packet receipt")) } fn get_packet_acknowledgement( @@ -613,9 +613,7 @@ where Height::Pending, &AckPath::new(&ack_path.port_id, &ack_path.channel_id, ack_path.sequence), ) - .ok_or_else(|| { - HostError::failed_to_retrieve(format!("packet ack: {:?}", ack_path.sequence)) - }) + .ok_or_else(|| HostError::missing_state(format!("packet ack: {:?}", ack_path.sequence))) } /// Returns a counter on the number of channel ids have been created thus far.