diff --git a/.changelog/unreleased/improvements/2062-ibc-refactoring.md b/.changelog/unreleased/improvements/2062-ibc-refactoring.md new file mode 100644 index 0000000000..f0dd83909a --- /dev/null +++ b/.changelog/unreleased/improvements/2062-ibc-refactoring.md @@ -0,0 +1,2 @@ +- refactoring IBC and remove IBC token denomination + ([\#2062](https://github.com/anoma/namada/issues/2062)) \ No newline at end of file diff --git a/.changelog/unreleased/improvements/2084-ibc-rs-0.47.md b/.changelog/unreleased/improvements/2084-ibc-rs-0.47.md new file mode 100644 index 0000000000..b33134f207 --- /dev/null +++ b/.changelog/unreleased/improvements/2084-ibc-rs-0.47.md @@ -0,0 +1,2 @@ +- Upgraded to upstream ibc-rs and tendermint-rs crates. + ([\#2084](https://github.com/anoma/namada/pull/2084)) \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9da4a10125..212ce28676 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,7 +54,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -317,7 +317,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -328,7 +328,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -381,7 +381,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "rustversion", - "serde 1.0.163", + "serde 1.0.190", "sync_wrapper", "tower", "tower-layer", @@ -495,7 +495,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -504,7 +504,7 @@ version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -525,7 +525,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -708,16 +708,6 @@ dependencies = [ "hashbrown 0.11.2", ] -[[package]] -name = "borsh" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" -dependencies = [ - "borsh-derive 0.10.3", - "hashbrown 0.12.3", -] - [[package]] name = "borsh" version = "1.0.0-alpha.4" @@ -734,21 +724,8 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal 0.9.3", - "borsh-schema-derive-internal 0.9.3", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal 0.10.3", - "borsh-schema-derive-internal 0.10.3", + "borsh-derive-internal", + "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.109", @@ -764,7 +741,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", "syn_derive", ] @@ -779,17 +756,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "borsh-ext" version = "1.0.0-alpha.4" @@ -809,17 +775,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "bs58" version = "0.4.0" @@ -864,7 +819,7 @@ version = "4.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", "utf8-width", ] @@ -902,7 +857,7 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -922,7 +877,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c530edf18f37068ac2d977409ed5cd50d53d73bc653c7647b48eb78976ac9ae2" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -931,7 +886,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbdb825da8a5df079a43676dbe042702f1707b1109f713a01420fbb4cc71fa27" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -943,7 +898,7 @@ dependencies = [ "camino", "cargo-platform", "semver 1.0.17", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "thiserror", ] @@ -965,11 +920,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", + "libc", ] [[package]] @@ -1054,7 +1010,7 @@ checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" dependencies = [ "ciborium-io", "ciborium-ll", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -1156,11 +1112,11 @@ dependencies = [ "bs58", "coins-core", "digest 0.10.6", - "getrandom 0.2.9", + "getrandom 0.2.10", "hmac 0.12.1", "k256", "lazy_static", - "serde 1.0.163", + "serde 1.0.190", "sha2 0.10.6", "thiserror", ] @@ -1173,7 +1129,7 @@ checksum = "84f4d04ee18e58356accd644896aeb2094ddeafb6a713e056cef0c0a8e468c15" dependencies = [ "bitvec 0.17.4", "coins-bip32", - "getrandom 0.2.9", + "getrandom 0.2.10", "hmac 0.12.1", "once_cell", "pbkdf2 0.12.1", @@ -1195,7 +1151,7 @@ dependencies = [ "generic-array 0.14.7", "hex", "ripemd", - "serde 1.0.163", + "serde 1.0.190", "serde_derive", "sha2 0.10.6", "sha3", @@ -1254,7 +1210,7 @@ dependencies = [ "lazy_static", "nom 5.1.3", "rust-ini", - "serde 1.0.163", + "serde 1.0.190", "serde-hjson", "serde_json", "toml 0.5.9", @@ -1427,7 +1383,7 @@ dependencies = [ "plotters", "rayon", "regex", - "serde 1.0.163", + "serde 1.0.190", "serde_derive", "serde_json", "tinytemplate", @@ -1562,15 +1518,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df" -[[package]] -name = "ct-logs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" -dependencies = [ - "sct 0.6.1", -] - [[package]] name = "ctr" version = "0.9.2" @@ -1632,7 +1579,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.15", + "strsim", + "syn 2.0.38", ] [[package]] @@ -1643,7 +1591,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -1760,7 +1708,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -1781,12 +1729,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" -[[package]] -name = "dyn-clone" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" - [[package]] name = "dynasm" version = "1.2.3" @@ -1834,10 +1776,20 @@ version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", "signature 1.6.4", ] +[[package]] +name = "ed25519" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +dependencies = [ + "pkcs8", + "signature 2.1.0", +] + [[package]] name = "ed25519-consensus" version = "1.2.1" @@ -1847,12 +1799,25 @@ dependencies = [ "curve25519-dalek-ng", "hex", "rand_core 0.6.4", - "serde 1.0.163", + "serde 1.0.190", "sha2 0.9.9", "thiserror", "zeroize", ] +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -1860,10 +1825,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", - "ed25519", + "ed25519 1.5.3", "merlin", "rand 0.7.3", - "serde 1.0.163", + "serde 1.0.190", "serde_bytes", "sha2 0.9.9", "zeroize", @@ -1917,7 +1882,7 @@ dependencies = [ "log", "rand 0.8.5", "rlp", - "serde 1.0.163", + "serde 1.0.190", "sha3", "zeroize", ] @@ -1960,7 +1925,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -1969,15 +1934,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "erased-serde" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2b0c2380453a92ea8b6c8e5f64ecaafccddde8ceab55ff7a8ac1029f894569" -dependencies = [ - "serde 1.0.163", -] - [[package]] name = "errno" version = "0.3.1" @@ -2007,7 +1963,7 @@ checksum = "f5584ba17d7ab26a8a7284f13e5bd196294dd2f2d79773cff29b9e9edef601a6" dependencies = [ "log", "once_cell", - "serde 1.0.163", + "serde 1.0.190", "serde_json", ] @@ -2025,7 +1981,7 @@ dependencies = [ "pbkdf2 0.11.0", "rand 0.8.5", "scrypt", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "sha2 0.10.6", "sha3", @@ -2043,7 +1999,7 @@ dependencies = [ "hex", "once_cell", "regex", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "sha3", "thiserror", @@ -2145,7 +2101,7 @@ checksum = "7b856b7b8ff5c961093cb8efe151fbcce724b451941ce20781de11a531ccd578" dependencies = [ "ethers-core", "once_cell", - "serde 1.0.163", + "serde 1.0.190", "serde_json", ] @@ -2163,7 +2119,7 @@ dependencies = [ "hex", "once_cell", "pin-project", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "thiserror", ] @@ -2183,9 +2139,9 @@ dependencies = [ "proc-macro2", "quote", "regex", - "serde 1.0.163", + "serde 1.0.190", "serde_json", - "syn 2.0.15", + "syn 2.0.38", "toml 0.7.6", "walkdir", ] @@ -2203,7 +2159,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -2226,10 +2182,10 @@ dependencies = [ "open-fastrlp", "rand 0.8.5", "rlp", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "strum", - "syn 2.0.15", + "syn 2.0.38", "tempfile", "thiserror", "tiny-keccak", @@ -2245,7 +2201,7 @@ dependencies = [ "ethers-core", "reqwest", "semver 1.0.17", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "thiserror", "tracing 0.1.37", @@ -2269,7 +2225,7 @@ dependencies = [ "futures-util", "instant", "reqwest", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "thiserror", "tokio", @@ -2300,7 +2256,7 @@ dependencies = [ "once_cell", "pin-project", "reqwest", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "thiserror", "tokio", @@ -2415,7 +2371,7 @@ dependencies = [ "num 0.4.0", "rand 0.7.3", "rand 0.8.5", - "serde 1.0.163", + "serde 1.0.190", "serde_bytes", "serde_json", "subproductdomain", @@ -2432,7 +2388,7 @@ dependencies = [ "ark-ec", "ark-serialize", "ark-std", - "serde 1.0.163", + "serde 1.0.190", "serde_bytes", ] @@ -2520,9 +2476,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -2619,7 +2575,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -2706,9 +2662,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3047,41 +3003,18 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-proxy" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca815a891b24fdfb243fa3239c86154392b0953ee584aa1a2a1f66d20cbe75cc" -dependencies = [ - "bytes", - "futures", - "headers", - "http", - "hyper", - "hyper-rustls", - "rustls-native-certs", - "tokio", - "tokio-rustls", - "tower-service", - "webpki 0.21.4", -] - [[package]] name = "hyper-rustls" -version = "0.22.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ - "ct-logs", "futures-util", + "http", "hyper", - "log", - "rustls 0.19.1", - "rustls-native-certs", + "rustls 0.21.8", "tokio", "tokio-rustls", - "webpki 0.21.4", - "webpki-roots 0.21.1", ] [[package]] @@ -3134,25 +3067,23 @@ dependencies = [ [[package]] name = "ibc" -version = "0.41.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs.git?rev=206cb5fa74a7ca38038b937d202ae39fbbd63c19#206cb5fa74a7ca38038b937d202ae39fbbd63c19" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "184eb22140cb4143bbcf7ddc8fdfeb9cc058ef73a6066f8ea78162e69d3565d1" dependencies = [ "bytes", - "cfg-if 1.0.0", "derive_more", "displaydoc", - "dyn-clone", - "erased-serde", + "ibc-derive", "ibc-proto", "ics23", "num-traits 0.2.15", "parking_lot", "primitive-types", - "prost", - "safe-regex", - "serde 1.0.163", + "prost 0.12.1", + "serde 1.0.190", + "serde-json-wasm", "serde_derive", - "serde_json", "sha2 0.10.6", "subtle-encoding", "tendermint", @@ -3161,37 +3092,51 @@ dependencies = [ "tendermint-testgen", "time", "tracing 0.1.37", + "typed-builder", "uint", ] +[[package]] +name = "ibc-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92f1528535e9ca495badb76c143bdd4763c1c9d987f59d1f8b47963ba0c11674" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "ibc-proto" -version = "0.30.0" -source = "git+https://github.com/heliaxdev/ibc-proto-rs.git?rev=31892ee743b2af017d5629b2af419ee20b6100c7#31892ee743b2af017d5629b2af419ee20b6100c7" +version = "0.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63042806bb2f662ca1c68026231900cfe13361136ddfd0dd09bcb315056a22b8" dependencies = [ "base64 0.21.0", - "borsh 0.10.3", "bytes", "flex-error", - "parity-scale-codec", - "prost", - "scale-info", - "serde 1.0.163", + "ics23", + "prost 0.12.1", + "serde 1.0.190", "subtle-encoding", "tendermint-proto", ] [[package]] name = "ics23" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca44b684ce1859cff746ff46f5765ab72e12e3c06f76a8356db8f9a2ecf43f17" +checksum = "661e2d6f79952a65bc92b1c81f639ebd37228dae6ff412a5aba7d474bdc4b957" dependencies = [ "anyhow", "bytes", "hex", - "prost", + "informalsystems-pbjson", + "prost 0.12.1", "ripemd", + "serde 1.0.190", "sha2 0.10.6", "sha3", ] @@ -3204,9 +3149,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -3247,7 +3192,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -3267,7 +3212,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5ad43a3f5795945459d577f6589cf62a476e92c79b75e70cd954364e14ce17b" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -3282,7 +3227,7 @@ version = "0.8.0" source = "git+https://github.com/heliaxdev/index-set?tag=v0.8.0#0c218cc300c1bb7a1acf34f21b6e9d489df5fda8" dependencies = [ "borsh 1.0.0-alpha.4", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -3293,7 +3238,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -3306,6 +3251,16 @@ dependencies = [ "hashbrown 0.14.0", ] +[[package]] +name = "informalsystems-pbjson" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eecd90f87bea412eac91c6ef94f6b1e390128290898cbe14f2b926787ae1fb" +dependencies = [ + "base64 0.13.1", + "serde 1.0.190", +] + [[package]] name = "inout" version = "0.1.3" @@ -3361,7 +3316,7 @@ checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.37.13", + "rustix 0.37.1", "windows-sys 0.48.0", ] @@ -3478,9 +3433,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libgit2-sys" @@ -3576,7 +3531,7 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -3646,7 +3601,7 @@ dependencies = [ "indexmap 1.9.3", "linked-hash-map", "regex", - "serde 1.0.163", + "serde 1.0.190", "serde_derive", "serde_yaml", ] @@ -3704,7 +3659,7 @@ dependencies = [ "blake2b_simd", "bls12_381", "directories", - "getrandom 0.2.9", + "getrandom 0.2.10", "group", "itertools 0.11.0", "jubjub", @@ -3862,20 +3817,20 @@ dependencies = [ "log", "once_cell", "rustls 0.20.8", - "webpki 0.22.0", - "webpki-roots 0.22.6", + "webpki", + "webpki-roots", ] [[package]] name = "mio" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -3953,12 +3908,12 @@ dependencies = [ "paste", "pretty_assertions", "proptest", - "prost", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "rayon", "ripemd", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "sha2 0.9.9", "slip10_ed25519", @@ -4008,7 +3963,7 @@ dependencies = [ "data-encoding", "derivative", "directories", - "ed25519-consensus", + "ed25519-consensus 1.2.1", "ethabi", "ethbridge-bridge-events", "ethbridge-events", @@ -4037,8 +3992,8 @@ dependencies = [ "orion", "pretty_assertions", "proptest", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "rayon", @@ -4048,7 +4003,7 @@ dependencies = [ "rlimit", "rocksdb", "rpassword", - "serde 1.0.163", + "serde 1.0.190", "serde_bytes", "serde_json", "sha2 0.9.9", @@ -4104,7 +4059,7 @@ dependencies = [ "chrono", "data-encoding", "derivative", - "ed25519-consensus", + "ed25519-consensus 1.2.1", "ethabi", "ethbridge-structs", "eyre", @@ -4112,6 +4067,7 @@ dependencies = [ "ferveo-common", "group-threshold-cryptography", "ibc", + "ibc-derive", "ibc-proto", "ics23", "impl-num-traits", @@ -4127,12 +4083,12 @@ dependencies = [ "pretty_assertions", "primitive-types", "proptest", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "rayon", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "sha2 0.9.9", "sparse-merkle-tree", @@ -4176,7 +4132,7 @@ dependencies = [ "namada_macros", "namada_proof_of_stake", "rand 0.8.5", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "tendermint", "tendermint-proto", @@ -4244,11 +4200,11 @@ dependencies = [ "owo-colors", "parse_duration", "paste", - "prost", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "ripemd", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "sha2 0.9.9", "slip10_ed25519", @@ -4307,10 +4263,10 @@ dependencies = [ "pretty_assertions", "proptest", "proptest-state-machine", - "prost", + "prost 0.12.1", "rand 0.8.5", "regex", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "sha2 0.9.9", "tempfile", @@ -4592,7 +4548,7 @@ dependencies = [ "num 0.4.0", "num-derive", "num-traits 0.2.15", - "serde 1.0.163", + "serde 1.0.190", "serde_derive", ] @@ -4624,7 +4580,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -4720,7 +4676,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -4748,7 +4704,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6624905ddd92e460ff0685567539ed1ac985b2dee4c92c7edcd64fce905b00c" dependencies = [ "ct-codecs", - "getrandom 0.2.9", + "getrandom 0.2.10", "subtle 2.4.1", "zeroize", ] @@ -4785,7 +4741,7 @@ dependencies = [ "byte-slice-cast", "impl-trait-for-tuples", "parity-scale-codec-derive", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -4943,9 +4899,9 @@ checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" @@ -4994,7 +4950,7 @@ checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -5124,7 +5080,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ceca8aaf45b5c46ec7ed39fff75f57290368c1846d33d24a122ca81416ab058" dependencies = [ "proc-macro2", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -5186,9 +5142,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -5229,7 +5185,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +dependencies = [ + "bytes", + "prost-derive 0.12.1", ] [[package]] @@ -5246,8 +5212,8 @@ dependencies = [ "multimap", "petgraph", "prettyplease 0.1.25", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "regex", "syn 1.0.109", "tempfile", @@ -5267,13 +5233,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +dependencies = [ + "anyhow", + "itertools 0.11.0", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", +] + +[[package]] +name = "prost-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf" +dependencies = [ + "prost 0.12.1", ] [[package]] @@ -5313,9 +5301,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.27" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -5391,7 +5379,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -5449,7 +5437,7 @@ dependencies = [ "jubjub", "pasta_curves", "rand_core 0.6.4", - "serde 1.0.163", + "serde 1.0.190", "thiserror", "zeroize", ] @@ -5462,7 +5450,7 @@ checksum = "7a60db2c3bc9c6fd1e8631fee75abc008841d27144be744951d6b9b75f9b569c" dependencies = [ "rand_core 0.6.4", "reddsa", - "serde 1.0.163", + "serde 1.0.190", "thiserror", "zeroize", ] @@ -5491,7 +5479,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] @@ -5562,9 +5550,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "base64 0.21.0", "bytes", @@ -5575,6 +5563,7 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-rustls", "hyper-tls", "ipnet", "js-sys", @@ -5584,11 +5573,16 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "serde 1.0.163", + "rustls 0.21.8", + "rustls-native-certs", + "rustls-pemfile", + "serde 1.0.190", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-native-tls", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", @@ -5617,11 +5611,25 @@ dependencies = [ "libc", "once_cell", "spin 0.5.2", - "untrusted", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom 0.2.10", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -5754,16 +5762,16 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.13" +version = "0.37.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f79bef90eb6d984c72722595b5b1348ab39275a5e5123faca6863bf07d75a4e0" +checksum = "d4790277f605573dd24b6751701e0823582a63c7cafc095e427e6c66e45dd75e" dependencies = [ "bitflags 1.2.1", "errno", "io-lifetimes", "libc", "linux-raw-sys 0.3.7", - "windows-sys 0.48.0", + "windows-sys 0.45.0", ] [[package]] @@ -5781,37 +5789,36 @@ dependencies = [ [[package]] name = "rustls" -version = "0.19.1" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ - "base64 0.13.1", "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", + "ring 0.16.20", + "sct", + "webpki", ] [[package]] name = "rustls" -version = "0.20.8" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring", - "sct 0.7.0", - "webpki 0.22.0", + "ring 0.17.5", + "rustls-webpki", + "sct", ] [[package]] name = "rustls-native-certs" -version = "0.5.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls 0.19.1", + "rustls-pemfile", "schannel", "security-framework", ] @@ -5825,6 +5832,16 @@ dependencies = [ "base64 0.21.0", ] +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.12" @@ -5849,53 +5866,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "safe-proc-macro2" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "814c536dcd27acf03296c618dab7ad62d28e70abd7ba41d3f34a2ce707a2c666" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "safe-quote" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e530f7831f3feafcd5f1aae406ac205dd998436b4007c8e80f03eca78a88f7" -dependencies = [ - "safe-proc-macro2", -] - -[[package]] -name = "safe-regex" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15289bf322e0673d52756a18194167f2378ec1a15fe884af6e2d2cb934822b0" -dependencies = [ - "safe-regex-macro", -] - -[[package]] -name = "safe-regex-compiler" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba76fae590a2aa665279deb1f57b5098cbace01a0c5e60e262fcf55f7c51542" -dependencies = [ - "safe-proc-macro2", - "safe-quote", -] - -[[package]] -name = "safe-regex-macro" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c2e96b5c03f158d1b16ba79af515137795f4ad4e8de3f790518aae91f1d127" -dependencies = [ - "safe-proc-macro2", - "safe-regex-compiler", -] - [[package]] name = "salsa20" version = "0.10.2" @@ -5971,24 +5941,14 @@ dependencies = [ "sha2 0.10.6", ] -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -6050,7 +6010,7 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -6082,9 +6042,9 @@ checksum = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] @@ -6101,13 +6061,22 @@ dependencies = [ "serde 0.8.23", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" +dependencies = [ + "serde 1.0.190", +] + [[package]] name = "serde_bytes" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -6117,18 +6086,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ "half", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -6139,7 +6108,7 @@ checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -6150,7 +6119,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -6159,7 +6128,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -6171,7 +6140,7 @@ dependencies = [ "form_urlencoded", "itoa", "ryu", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -6182,7 +6151,7 @@ checksum = "ef8099d3df28273c99a1728190c7a9f19d444c941044f64adf986bee7ec53051" dependencies = [ "dtoa", "linked-hash-map", - "serde 1.0.163", + "serde 1.0.190", "yaml-rust", ] @@ -6193,7 +6162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177" dependencies = [ "base16ct", - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -6352,7 +6321,7 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=df7ec062e7c40d5e76b136064e9aaf8bd2490750#df7ec062e7c40d5e76b136064e9aaf8bd2490750" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=aed81070ce2c83a41e1c6bada757347f33ef8eb6#aed81070ce2c83a41e1c6bada757347f33ef8eb6" dependencies = [ "blake2b-rs", "borsh 1.0.0-alpha.4", @@ -6476,9 +6445,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.15" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -6487,14 +6456,14 @@ dependencies = [ [[package]] name = "syn_derive" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae6eef0000c4a12ecdfd7873ea84a8b5aab5e44db72e38e07b028a25386f29a5" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -6517,6 +6486,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.2.1", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -6549,31 +6539,32 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.13", + "rustix 0.37.1", "windows-sys 0.45.0", ] [[package]] name = "tendermint" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc2294fa667c8b548ee27a9ba59115472d0a09c2ba255771092a7f1dcf03a789" dependencies = [ - "async-trait", "bytes", - "ed25519", - "ed25519-dalek", + "digest 0.10.6", + "ed25519 2.2.2", + "ed25519-consensus 2.1.0", "flex-error", "futures", "num-traits 0.2.15", "once_cell", - "prost", - "prost-types", - "serde 1.0.163", + "prost 0.12.1", + "prost-types 0.12.1", + "serde 1.0.190", "serde_bytes", "serde_json", "serde_repr", - "sha2 0.9.9", - "signature 1.6.4", + "sha2 0.10.6", + "signature 2.1.0", "subtle 2.4.1", "subtle-encoding", "tendermint-proto", @@ -6583,11 +6574,12 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a25dbe8b953e80f3d61789fbdb83bf9ad6c0ef16df5ca6546f49912542cc137" dependencies = [ "flex-error", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "tendermint", "toml 0.5.9", @@ -6596,49 +6588,55 @@ dependencies = [ [[package]] name = "tendermint-light-client" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94aecbdccbc4b557649b2d1b1a4bfc27ec85205e00fb8020fce044245a4c9e3f" dependencies = [ "contracts", "crossbeam-channel 0.4.4", "derive_more", "flex-error", "futures", - "serde 1.0.163", + "regex", + "serde 1.0.190", "serde_cbor", "serde_derive", + "serde_json", "static_assertions", "tendermint", "tendermint-light-client-verifier", "tendermint-rpc", "time", "tokio", + "tracing 0.1.37", ] [[package]] name = "tendermint-light-client-verifier" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74994da9de4b1144837a367ca2c60c650f5526a7c1a54760a3020959b522e474" dependencies = [ "derive_more", "flex-error", - "serde 1.0.163", + "serde 1.0.190", "tendermint", "time", ] [[package]] name = "tendermint-proto" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc728a4f9e891d71adf66af6ecaece146f9c7a11312288a3107b3e1d6979aaf" dependencies = [ "bytes", "flex-error", "num-derive", "num-traits 0.2.15", - "prost", - "prost-types", - "serde 1.0.163", + "prost 0.12.1", + "prost-types 0.12.1", + "serde 1.0.190", "serde_bytes", "subtle-encoding", "time", @@ -6646,23 +6644,23 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbf0a4753b46a190f367337e0163d0b552a2674a6bac54e74f9f2cdcde2969b" dependencies = [ "async-trait", "bytes", "flex-error", "futures", - "getrandom 0.2.9", - "http", - "hyper", - "hyper-proxy", - "hyper-rustls", + "getrandom 0.2.10", "peg", "pin-project", - "serde 1.0.163", + "reqwest", + "semver 1.0.17", + "serde 1.0.190", "serde_bytes", "serde_json", + "subtle 2.4.1", "subtle-encoding", "tendermint", "tendermint-config", @@ -6678,12 +6676,13 @@ dependencies = [ [[package]] name = "tendermint-testgen" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19d4f02b7e38ce790da973fdc9edc71a0e35340ac57737bf278c8379037c1f5" dependencies = [ - "ed25519-dalek", + "ed25519-consensus 2.1.0", "gumdrop", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "simple-error", "tempfile", @@ -6725,7 +6724,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -6755,7 +6754,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" dependencies = [ "itoa", - "serde 1.0.163", + "serde 1.0.190", "time-core", "time-macros", ] @@ -6821,7 +6820,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", "serde_json", ] @@ -6877,7 +6876,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -6892,13 +6891,12 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.19.1", + "rustls 0.21.8", "tokio", - "webpki 0.21.4", ] [[package]] @@ -6971,7 +6969,7 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -6980,7 +6978,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", "serde_spanned", "toml_datetime", "toml_edit", @@ -6992,7 +6990,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", ] [[package]] @@ -7002,7 +7000,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78" dependencies = [ "indexmap 2.0.0", - "serde 1.0.163", + "serde 1.0.190", "serde_spanned", "toml_datetime", "winnow", @@ -7028,8 +7026,8 @@ dependencies = [ "hyper-timeout", "percent-encoding", "pin-project", - "prost", - "prost-derive", + "prost 0.11.9", + "prost-derive 0.11.9", "tokio", "tokio-stream", "tokio-util 0.7.8", @@ -7077,12 +7075,12 @@ dependencies = [ [[package]] name = "tower-abci" version = "0.1.0" -source = "git+https://github.com/heliaxdev/tower-abci.git?rev=cf9573dc02eba0faf1f9807244b156630e4c18d1#cf9573dc02eba0faf1f9807244b156630e4c18d1" +source = "git+https://github.com/heliaxdev/tower-abci.git?rev=9636f0f2000ebb7da1c51e85cce2b10b2fed4f1d#9636f0f2000ebb7da1c51e85cce2b10b2fed4f1d" dependencies = [ "bytes", "futures", "pin-project", - "prost", + "prost 0.12.1", "tendermint-proto", "tokio", "tokio-stream", @@ -7166,7 +7164,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] @@ -7233,7 +7231,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" dependencies = [ - "serde 1.0.163", + "serde 1.0.190", "tracing-core 0.1.31", ] @@ -7247,7 +7245,7 @@ dependencies = [ "nu-ansi-term", "once_cell", "regex", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "sharded-slab", "thread_local", @@ -7296,6 +7294,26 @@ dependencies = [ "utf-8", ] +[[package]] +name = "typed-builder" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c6a006a6d3d6a6f143fda41cf4d1ad35110080687628c9f2117bd3cc7924f3" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa054ee5e2346187d631d2f1d1fd3b33676772d6d03a2d84e1c5213b31674ee" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "typenum" version = "1.16.0" @@ -7384,11 +7402,17 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" -version = "2.3.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -7419,8 +7443,8 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.9", - "serde 1.0.163", + "getrandom 0.2.10", + "serde 1.0.190", ] [[package]] @@ -7496,7 +7520,7 @@ dependencies = [ "pin-project", "rustls-pemfile", "scoped-tls", - "serde 1.0.163", + "serde 1.0.190", "serde_json", "serde_urlencoded", "tokio", @@ -7540,7 +7564,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -7574,7 +7598,7 @@ checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -7660,7 +7684,7 @@ dependencies = [ "enumset", "loupe", "rkyv", - "serde 1.0.163", + "serde 1.0.190", "serde_bytes", "smallvec", "target-lexicon", @@ -7729,7 +7753,7 @@ dependencies = [ "memmap2", "more-asserts", "rustc-demangle", - "serde 1.0.163", + "serde 1.0.190", "serde_bytes", "target-lexicon", "thiserror", @@ -7752,7 +7776,7 @@ dependencies = [ "loupe", "object 0.28.4", "rkyv", - "serde 1.0.163", + "serde 1.0.190", "tempfile", "tracing 0.1.37", "wasmer-artifact", @@ -7820,7 +7844,7 @@ dependencies = [ "loupe", "more-asserts", "rkyv", - "serde 1.0.163", + "serde 1.0.190", "thiserror", ] @@ -7844,7 +7868,7 @@ dependencies = [ "region", "rkyv", "scopeguard", - "serde 1.0.163", + "serde 1.0.190", "thiserror", "wasmer-artifact", "wasmer-types", @@ -7912,33 +7936,14 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" -dependencies = [ - "webpki 0.21.4", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -7947,7 +7952,7 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki", ] [[package]] @@ -8211,11 +8216,12 @@ dependencies = [ [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if 1.0.0", + "windows-sys 0.48.0", ] [[package]] @@ -8296,7 +8302,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn 2.0.38", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ae3e6ae08d..f27ec16fbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ ark-bls12-381 = {version = "0.3"} ark-serialize = {version = "0.3"} ark-std = "0.3.0" # branch = "bat/arse-merkle-tree" -arse-merkle-tree = {package = "sparse-merkle-tree", git = "https://github.com/heliaxdev/sparse-merkle-tree", rev = "df7ec062e7c40d5e76b136064e9aaf8bd2490750", default-features = false, features = ["std", "borsh"]} +arse-merkle-tree = {package = "sparse-merkle-tree", git = "https://github.com/heliaxdev/sparse-merkle-tree", rev = "aed81070ce2c83a41e1c6bada757347f33ef8eb6", default-features = false, features = ["std", "borsh"]} assert_cmd = "1.0.7" assert_matches = "1.5.0" async-trait = {version = "0.1.51"} @@ -83,7 +83,7 @@ flate2 = "1.0.22" fs_extra = "1.2.0" futures = "0.3" git2 = "0.13.25" -ics23 = "0.9.0" +ics23 = "0.11.0" index-set = {git = "https://github.com/heliaxdev/index-set", tag = "v0.8.0", features = ["serialize-borsh", "serialize-serde"]} itertools = "0.10.0" k256 = { version = "0.13.0", default-features = false, features = ["ecdsa", "pkcs8", "precomputed-tables", "serde", "std"]} @@ -105,8 +105,8 @@ pretty_assertions = "1.4.0" primitive-types = "0.12.1" proptest = "1.2.0" proptest-state-machine = "0.1.0" -prost = "0.11.6" -prost-types = "0.11.6" +prost = "0.12.0" +prost-types = "0.12.0" rand = {version = "0.8", default-features = false} rand_core = {version = "0.6", default-features = false} rayon = "=1.5.3" @@ -126,8 +126,11 @@ slip10_ed25519 = "0.1.3" sysinfo = {version = "0.27.8", default-features = false} tar = "0.4.37" tempfile = {version = "3.2.0"} -tendermint-config = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7"} -tendermint-light-client = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7"} +tendermint = "0.34.0" +tendermint-config = "0.34.0" +tendermint-light-client = "0.34.0" +tendermint-proto = "0.34.0" +tendermint-rpc = {version = "0.34.0", default-features = false} test-log = {version = "0.2.7", default-features = false, features = ["trace"]} tiny-bip39 = {git = "https://github.com/anoma/tiny-bip39.git", rev = "bf0f6d8713589b83af7a917366ec31f5275c0e57"} tiny-hderive = "0.3.0" @@ -139,7 +142,7 @@ tonic = "0.8.3" tonic-build = "0.8.4" tower = "0.4" # Also, using the same version of tendermint-rs as we do here. -tower-abci = {git = "https://github.com/heliaxdev/tower-abci.git", rev = "cf9573dc02eba0faf1f9807244b156630e4c18d1"} +tower-abci = {git = "https://github.com/heliaxdev/tower-abci.git", rev = "9636f0f2000ebb7da1c51e85cce2b10b2fed4f1d"} tracing = "0.1.30" tracing-appender = "0.2.2" tracing-log = "0.1.2" diff --git a/apps/src/lib/bench_utils.rs b/apps/src/lib/bench_utils.rs index 4f12c5b6b1..163258d55f 100644 --- a/apps/src/lib/bench_utils.rs +++ b/apps/src/lib/bench_utils.rs @@ -5,6 +5,7 @@ use std::fs::{File, OpenOptions}; use std::io::{Read, Write}; use std::ops::{Deref, DerefMut}; use std::path::PathBuf; +use std::str::FromStr; use std::sync::Once; use borsh::{BorshDeserialize, BorshSerialize}; @@ -54,6 +55,7 @@ use namada::ibc_proto::protobuf::Protobuf; use namada::ledger::dry_run_tx; use namada::ledger::gas::TxGasMeter; use namada::ledger::ibc::storage::{channel_key, connection_key}; +use namada::ledger::native_vp::ibc::get_dummy_header; use namada::ledger::queries::{ Client, EncodedResponseQuery, RequestCtx, RequestQuery, Router, RPC, }; @@ -88,8 +90,8 @@ use crate::cli::context::FromContext; use crate::cli::Context; use crate::config::global::GlobalConfig; use crate::config::TendermintMode; -use crate::facade::tendermint_proto::abci::RequestInitChain; use crate::facade::tendermint_proto::google::protobuf::Timestamp; +use crate::facade::tendermint_proto::v0_37::abci::RequestInitChain; use crate::node::ledger::shell::Shell; use crate::wallet::{defaults, CliWalletUtils}; use crate::{config, wasm_loader}; @@ -278,12 +280,15 @@ impl BenchShell { } pub fn init_ibc_channel(&mut self) { + // Set a dummy header + self.wl_storage + .storage + .set_header(get_dummy_header()) + .unwrap(); // Set connection open - let client_id = ClientId::new( - ClientType::new("01-tendermint".to_string()).unwrap(), - 1, - ) - .unwrap(); + let client_id = + ClientId::new(ClientType::new("01-tendermint").unwrap(), 1) + .unwrap(); let connection = ConnectionEnd::new( ConnectionState::Open, client_id.clone(), @@ -347,11 +352,9 @@ impl BenchShell { .unwrap(); // Set client state - let client_id = ClientId::new( - ClientType::new("01-tendermint".to_string()).unwrap(), - 1, - ) - .unwrap(); + let client_id = + ClientId::new(ClientType::new("01-tendermint").unwrap(), 1) + .unwrap(); let client_state_key = addr_key.join(&Key::from( IbcPath::ClientState( namada::ibc::core::ics24_host::path::ClientStatePath( @@ -362,7 +365,7 @@ impl BenchShell { .to_db_key(), )); let client_state = ClientState::new( - IbcChainId::from(ChainId::default().to_string()), + IbcChainId::from_str(&ChainId::default().to_string()).unwrap(), TrustThreshold::ONE_THIRD, std::time::Duration::new(1, 0), std::time::Duration::new(2, 0), @@ -672,11 +675,13 @@ impl Client for BenchShell { async fn perform( &self, _request: R, - ) -> Result + ) -> Result where R: tendermint_rpc::SimpleRequest, { - tendermint_rpc::Response::from_string("MOCK RESPONSE") + Ok(R::Output::from( + tendermint_rpc::Response::from_string("MOCK RESPONSE").unwrap(), + )) } } diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index 0231e3731d..bedd15bf8c 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -58,7 +58,7 @@ use namada_sdk::{display, display_line, edisplay_line, error, prompt, Namada}; use tokio::time::Instant; use crate::cli::{self, args}; -use crate::facade::tendermint::merkle::proof::Proof; +use crate::facade::tendermint::merkle::proof::ProofOps; use crate::facade::tendermint_rpc::error::Error as TError; /// Query the status of a given transaction. @@ -2336,7 +2336,7 @@ pub async fn query_storage_value_bytes< key: &storage::Key, height: Option, prove: bool, -) -> (Option>, Option) { +) -> (Option>, Option) { namada_sdk::rpc::query_storage_value_bytes(client, key, height, prove) .await .unwrap() diff --git a/apps/src/lib/config/mod.rs b/apps/src/lib/config/mod.rs index 735391d056..6286eb65af 100644 --- a/apps/src/lib/config/mod.rs +++ b/apps/src/lib/config/mod.rs @@ -368,6 +368,9 @@ And this is correct } "#; +// TODO: Replaced `block_sync` and `blocksync` +// with `fast_sync` and `fastsync` +// due to https://github.com/informalsystems/tendermint-rs/issues/1368 pub const DEFAULT_COMETBFT_CONFIG: &str = r#" # This is a TOML config file. @@ -395,7 +398,7 @@ moniker = "technodrome" # # Deprecated: this key will be removed and BlockSync will be enabled # unconditionally in the next major release. -block_sync = true +fast_sync = true # Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb # * goleveldb (github.com/syndtr/goleveldb - most popular implementation) @@ -736,7 +739,7 @@ chunk_fetchers = "4" ####################################################### ### Block Sync Configuration Options ### ####################################################### -[blocksync] +[fastsync] # Block Sync version to use: # diff --git a/apps/src/lib/node/ledger/broadcaster.rs b/apps/src/lib/node/ledger/broadcaster.rs index 54c7ce0899..e3b5229452 100644 --- a/apps/src/lib/node/ledger/broadcaster.rs +++ b/apps/src/lib/node/ledger/broadcaster.rs @@ -65,7 +65,7 @@ impl Broadcaster { } loop { if let Some(msg) = self.receiver.recv().await { - let _ = self.client.broadcast_tx_sync(msg.into()).await; + let _ = self.client.broadcast_tx_sync(msg).await; } } } diff --git a/apps/src/lib/node/ledger/mod.rs b/apps/src/lib/node/ledger/mod.rs index 5d4d1845a9..a2ae0cc9bd 100644 --- a/apps/src/lib/node/ledger/mod.rs +++ b/apps/src/lib/node/ledger/mod.rs @@ -30,7 +30,7 @@ use self::shims::abcipp_shim::AbciService; use crate::cli::args; use crate::config::utils::{convert_tm_addr_to_socket_addr, num_of_threads}; use crate::config::{ethereum_bridge, TendermintMode}; -use crate::facade::tendermint_proto::abci::CheckTxType; +use crate::facade::tendermint_proto::v0_37::abci::CheckTxType; use crate::facade::tower_abci::{response, split, Server}; use crate::node::ledger::broadcaster::Broadcaster; use crate::node::ledger::ethereum_oracle as oracle; @@ -143,7 +143,7 @@ impl Shell { message: msg.message, })), Request::CheckTx(tx) => { - let r#type = match CheckTxType::from_i32(tx.r#type) + let r#type = match CheckTxType::try_from(tx.r#type) .expect("received unexpected CheckTxType from ABCI") { CheckTxType::New => MempoolTxType::NewTransaction, diff --git a/apps/src/lib/node/ledger/shell/block_alloc.rs b/apps/src/lib/node/ledger/shell/block_alloc.rs index 03273194c6..feb17045b5 100644 --- a/apps/src/lib/node/ledger/shell/block_alloc.rs +++ b/apps/src/lib/node/ledger/shell/block_alloc.rs @@ -542,9 +542,9 @@ mod tests { PropTx { tendermint_max_block_space_in_bytes, max_block_gas, - protocol_txs, - encrypted_txs, - decrypted_txs, + protocol_txs: protocol_txs.into_iter().map(prost::bytes::Bytes::from).collect(), + encrypted_txs: encrypted_txs.into_iter().map(prost::bytes::Bytes::from).collect(), + decrypted_txs: decrypted_txs.into_iter().map(prost::bytes::Bytes::from).collect(), } } } diff --git a/apps/src/lib/node/ledger/shell/finalize_block.rs b/apps/src/lib/node/ledger/shell/finalize_block.rs index 2202f7a157..b9adc782a9 100644 --- a/apps/src/lib/node/ledger/shell/finalize_block.rs +++ b/apps/src/lib/node/ledger/shell/finalize_block.rs @@ -33,7 +33,7 @@ use namada::types::vote_extensions::ethereum_events::MultiSignedEthEvent; use super::governance::execute_governance_proposals; use super::*; -use crate::facade::tendermint_proto::abci::{ +use crate::facade::tendermint_proto::v0_37::abci::{ Misbehavior as Evidence, VoteInfo, }; use crate::node::ledger::shell::stats::InternalStats; @@ -960,7 +960,7 @@ fn pos_votes_from_abci( signed_last_block, }| { if let Some( - crate::facade::tendermint_proto::abci::Validator { + crate::facade::tendermint_proto::v0_37::abci::Validator { address, power, }, @@ -1070,7 +1070,7 @@ mod test_finalize_block { use test_log::test; use super::*; - use crate::facade::tendermint_proto::abci::{ + use crate::facade::tendermint_proto::v0_37::abci::{ Misbehavior, Validator, VoteInfo, }; use crate::node::ledger::oracle::control::Command; @@ -1112,7 +1112,7 @@ mod test_finalize_block { ( wrapper_tx, ProcessedTx { - tx, + tx: tx.into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -1153,7 +1153,7 @@ mod test_finalize_block { outer_tx.decrypt(::G2Affine::prime_subgroup_generator()) .expect("Test failed"); ProcessedTx { - tx: outer_tx.to_bytes(), + tx: outer_tx.to_bytes().into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -1269,7 +1269,7 @@ mod test_finalize_block { outer_tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted)); let processed_tx = ProcessedTx { - tx: outer_tx.to_bytes(), + tx: outer_tx.to_bytes().into(), result: TxResult { code: ErrorCodes::InvalidTx.into(), info: "".into(), @@ -1312,7 +1312,8 @@ mod test_finalize_block { )))); let processed_tx = ProcessedTx { tx: Tx::from_type(TxType::Decrypted(DecryptedTx::Undecryptable)) - .to_bytes(), + .to_bytes() + .into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -1439,7 +1440,7 @@ mod test_finalize_block { let req = FinalizeBlock { txs: vec![ProcessedTx { - tx, + tx: tx.into(), result: TxResult { code: ErrorCodes::InvalidTx.into(), info: Default::default(), @@ -1508,7 +1509,8 @@ mod test_finalize_block { ProcessedTx { tx: EthereumTxData::EthereumEvents(digest) .sign(&protocol_key, shell.chain_id.clone()) - .to_bytes(), + .to_bytes() + .into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -1567,7 +1569,8 @@ mod test_finalize_block { let processed_tx = ProcessedTx { tx: EthereumTxData::EthEventsVext(ext) .sign(&protocol_key, shell.chain_id.clone()) - .to_bytes(), + .to_bytes() + .into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -1626,7 +1629,7 @@ mod test_finalize_block { .expect("Test failed"); let (tx, action) = craft_tx(&mut shell); let processed_tx = ProcessedTx { - tx: tx.to_bytes(), + tx: tx.to_bytes().into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -1882,7 +1885,7 @@ mod test_finalize_block { let votes = vec![VoteInfo { validator: Some(Validator { - address: proposer_address.clone(), + address: proposer_address.clone().into(), power: u128::try_from(val_stake).expect("Test failed") as i64, }), signed_last_block: true, @@ -1984,7 +1987,7 @@ mod test_finalize_block { let votes = vec![ VoteInfo { validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake) .expect("Test failed") as i64, @@ -1993,7 +1996,7 @@ mod test_finalize_block { }, VoteInfo { validator: Some(Validator { - address: pkh2.clone(), + address: pkh2.clone().into(), power: u128::try_from(val2.bonded_stake) .expect("Test failed") as i64, @@ -2002,7 +2005,7 @@ mod test_finalize_block { }, VoteInfo { validator: Some(Validator { - address: pkh3.clone(), + address: pkh3.clone().into(), power: u128::try_from(val3.bonded_stake) .expect("Test failed") as i64, @@ -2011,7 +2014,7 @@ mod test_finalize_block { }, VoteInfo { validator: Some(Validator { - address: pkh4.clone(), + address: pkh4.clone().into(), power: u128::try_from(val4.bonded_stake) .expect("Test failed") as i64, @@ -2101,7 +2104,7 @@ mod test_finalize_block { let votes = vec![ VoteInfo { validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake) .expect("Test failed") as i64, @@ -2110,7 +2113,7 @@ mod test_finalize_block { }, VoteInfo { validator: Some(Validator { - address: pkh2, + address: pkh2.into(), power: u128::try_from(val2.bonded_stake) .expect("Test failed") as i64, @@ -2119,7 +2122,7 @@ mod test_finalize_block { }, VoteInfo { validator: Some(Validator { - address: pkh3, + address: pkh3.into(), power: u128::try_from(val3.bonded_stake) .expect("Test failed") as i64, @@ -2128,7 +2131,7 @@ mod test_finalize_block { }, VoteInfo { validator: Some(Validator { - address: pkh4, + address: pkh4.into(), power: u128::try_from(val4.bonded_stake) .expect("Test failed") as i64, @@ -2346,7 +2349,7 @@ mod test_finalize_block { // Invalid wrapper tx that should lead to a commitment of the wrapper // hash and no commitment of the inner hash let mut processed_txs = vec![ProcessedTx { - tx: invalid_wrapper_tx.to_bytes(), + tx: invalid_wrapper_tx.to_bytes().into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -2355,7 +2358,7 @@ mod test_finalize_block { // Out of gas error triggering inner hash removal and wrapper hash // insert processed_txs.push(ProcessedTx { - tx: decrypted_tx.to_bytes(), + tx: decrypted_tx.to_bytes().into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -2364,7 +2367,7 @@ mod test_finalize_block { // Wasm error that still leads to inner hash commitment and no wrapper // hash insert processed_txs.push(ProcessedTx { - tx: decrypted_tx_2.to_bytes(), + tx: decrypted_tx_2.to_bytes().into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -2487,7 +2490,7 @@ mod test_finalize_block { ))); let processed_tx = ProcessedTx { - tx: wrapper.to_bytes(), + tx: wrapper.to_bytes().into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -2581,7 +2584,7 @@ mod test_finalize_block { .unwrap(); let processed_tx = ProcessedTx { - tx: wrapper.to_bytes(), + tx: wrapper.to_bytes().into(), result: TxResult { code: ErrorCodes::Ok.into(), info: "".into(), @@ -2697,7 +2700,7 @@ mod test_finalize_block { Misbehavior { r#type: 1, validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: Default::default(), }), height: 1, @@ -2707,7 +2710,7 @@ mod test_finalize_block { Misbehavior { r#type: 2, validator: Some(Validator { - address: pkh2, + address: pkh2.into(), power: Default::default(), }), height: 1, @@ -3259,7 +3262,7 @@ mod test_finalize_block { let misbehaviors = vec![Misbehavior { r#type: 1, validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: Default::default(), }), height: height.0 as i64, @@ -3322,7 +3325,7 @@ mod test_finalize_block { Misbehavior { r#type: 1, validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: Default::default(), }), height: height.0 as i64, @@ -3332,7 +3335,7 @@ mod test_finalize_block { Misbehavior { r#type: 2, validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: Default::default(), }), height: height4.0 as i64, @@ -4018,7 +4021,7 @@ mod test_finalize_block { ); VoteInfo { validator: Some(Validator { - address: pkh, + address: pkh.into(), power: u128::try_from(val.bonded_stake).unwrap() as i64, }), signed_last_block: true, @@ -4122,7 +4125,7 @@ mod test_finalize_block { // Finalize block 2 let votes = vec![VoteInfo { validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake).expect("Test failed") as i64, }), diff --git a/apps/src/lib/node/ledger/shell/mod.rs b/apps/src/lib/node/ledger/shell/mod.rs index 4c924400fc..6765ff2028 100644 --- a/apps/src/lib/node/ledger/shell/mod.rs +++ b/apps/src/lib/node/ledger/shell/mod.rs @@ -76,11 +76,11 @@ use tokio::sync::mpsc::{Receiver, UnboundedSender}; use super::ethereum_oracle::{self as oracle, last_processed_block}; use crate::config; use crate::config::{genesis, TendermintMode}; -use crate::facade::tendermint_proto::abci::{ +use crate::facade::tendermint_proto::google::protobuf::Timestamp; +use crate::facade::tendermint_proto::v0_37::abci::{ Misbehavior as Evidence, MisbehaviorType as EvidenceType, ValidatorUpdate, }; -use crate::facade::tendermint_proto::crypto::public_key; -use crate::facade::tendermint_proto::google::protobuf::Timestamp; +use crate::facade::tendermint_proto::v0_37::crypto::public_key; use crate::facade::tower_abci::{request, response}; use crate::node::ledger::shims::abcipp_shim_types::shim; use crate::node::ledger::shims::abcipp_shim_types::shim::response::TxResult; @@ -583,7 +583,7 @@ where root, height ); - response.last_block_app_hash = root.0.to_vec(); + response.last_block_app_hash = root.0.to_vec().into(); response.last_block_height = height.try_into().expect("Invalid block height"); } @@ -694,8 +694,8 @@ where ); continue; } - let slash_type = match EvidenceType::from_i32(evidence.r#type) { - Some(r#type) => match r#type { + let slash_type = match EvidenceType::try_from(evidence.r#type) { + Ok(r#type) => match r#type { EvidenceType::DuplicateVote => { pos::types::SlashType::DuplicateVote } @@ -710,7 +710,7 @@ where continue; } }, - None => { + Err(_) => { tracing::error!( "Unexpected evidence type {}", evidence.r#type @@ -820,7 +820,7 @@ where root, self.wl_storage.storage.get_last_block_height(), ); - response.data = root.0.to_vec(); + response.data = root.0.to_vec().into(); self.bump_last_processed_eth_block(); self.broadcast_queued_txs(); @@ -1438,11 +1438,12 @@ where fn get_abci_validator_updates( &self, is_genesis: bool, - ) -> storage_api::Result> - { + ) -> storage_api::Result< + Vec, + > { use namada::ledger::pos::namada_proof_of_stake; - use crate::facade::tendermint_proto::crypto::PublicKey as TendermintPublicKey; + use crate::facade::tendermint_proto::v0_37::crypto::PublicKey as TendermintPublicKey; let (current_epoch, _gas) = self.wl_storage.storage.get_current_epoch(); let pos_params = @@ -1506,7 +1507,7 @@ mod test_utils { use namada::proof_of_stake::parameters::PosParams; use namada::proof_of_stake::validator_consensus_key_handle; use namada::proto::{Code, Data}; - use namada::tendermint_proto::abci::VoteInfo; + use namada::tendermint_proto::v0_37::abci::VoteInfo; use namada::types::address; use namada::types::chain::ChainId; use namada::types::ethereum_events::Uint; @@ -1521,11 +1522,11 @@ mod test_utils { use super::*; use crate::config::ethereum_bridge::ledger::ORACLE_CHANNEL_BUFFER_SIZE; - use crate::facade::tendermint_proto::abci::{ + use crate::facade::tendermint_proto::google::protobuf::Timestamp; + use crate::facade::tendermint_proto::v0_37::abci::{ Misbehavior, RequestInitChain, RequestPrepareProposal, RequestProcessProposal, }; - use crate::facade::tendermint_proto::google::protobuf::Timestamp; use crate::node::ledger::shims::abcipp_shim_types; use crate::node::ledger::shims::abcipp_shim_types::shim::request::{ FinalizeBlock, ProcessedTx, @@ -1728,7 +1729,12 @@ mod test_utils { req: ProcessProposal, ) -> std::result::Result, TestError> { let resp = self.shell.process_proposal(RequestProcessProposal { - txs: req.txs.clone(), + txs: req + .txs + .clone() + .into_iter() + .map(prost::bytes::Bytes::from) + .collect(), proposer_address: HEXUPPER .decode( crate::wallet::defaults::validator_keypair() @@ -1736,7 +1742,8 @@ mod test_utils { .tm_raw_hash() .as_bytes(), ) - .unwrap(), + .unwrap() + .into(), ..Default::default() }); let results = resp @@ -1745,7 +1752,7 @@ mod test_utils { .zip(req.txs.into_iter()) .map(|(res, tx_bytes)| ProcessedTx { result: res, - tx: tx_bytes, + tx: tx_bytes.into(), }) .collect(); if resp.status != 1 { @@ -1779,7 +1786,8 @@ mod test_utils { .tm_raw_hash() .as_bytes(), ) - .unwrap(); + .unwrap() + .into(); self.shell.prepare_proposal(req) } diff --git a/apps/src/lib/node/ledger/shell/prepare_proposal.rs b/apps/src/lib/node/ledger/shell/prepare_proposal.rs index 2df4b520c5..4dd5c43b2a 100644 --- a/apps/src/lib/node/ledger/shell/prepare_proposal.rs +++ b/apps/src/lib/node/ledger/shell/prepare_proposal.rs @@ -29,12 +29,12 @@ use super::block_alloc::states::{ }; use super::block_alloc::{AllocFailure, BlockAllocator, BlockResources}; #[cfg(feature = "abcipp")] -use crate::facade::tendermint_proto::abci::ExtendedCommitInfo; -use crate::facade::tendermint_proto::abci::RequestPrepareProposal; -#[cfg(feature = "abcipp")] use crate::facade::tendermint_proto::abci::{tx_record::TxAction, TxRecord}; use crate::facade::tendermint_proto::google::protobuf::Timestamp; #[cfg(feature = "abcipp")] +use crate::facade::tendermint_proto::v0_37::abci::ExtendedCommitInfo; +use crate::facade::tendermint_proto::v0_37::abci::RequestPrepareProposal; +#[cfg(feature = "abcipp")] use crate::node::ledger::shell::vote_extensions::iter_protocol_txs; use crate::node::ledger::shell::ShellMode; use crate::node::ledger::shims::abcipp_shim_types::shim::{response, TxBytes}; @@ -310,11 +310,11 @@ where )); tx }, - }.to_bytes() + }.to_bytes().into() }, ) // TODO: make sure all decrypted txs are accepted - .take_while(|tx_bytes| { + .take_while(|tx_bytes: &TxBytes| { alloc.try_alloc(&tx_bytes[..]).map_or_else( |status| match status { AllocFailure::Rejected { bin_resource_left: bin_space_left } => { @@ -634,7 +634,7 @@ mod test_prepare_proposal { let mut tx = Tx::from_type(TxType::Decrypted(DecryptedTx::Decrypted)); tx.header.chain_id = shell.chain_id.clone(); let req = RequestPrepareProposal { - txs: vec![tx.to_bytes()], + txs: vec![tx.to_bytes().into()], ..Default::default() }; assert!(shell.prepare_proposal(req).txs.is_empty()); @@ -665,7 +665,7 @@ mod test_prepare_proposal { let wrapper = wrapper.to_bytes(); #[allow(clippy::redundant_clone)] let req = RequestPrepareProposal { - txs: vec![wrapper.clone()], + txs: vec![wrapper.clone().into()], ..Default::default() }; assert!(shell.prepare_proposal(req).txs.is_empty()); @@ -871,7 +871,9 @@ mod test_prepare_proposal { should_panic(expected = "A Tendermint quorum should never") )] fn test_prepare_proposal_vext_insufficient_voting_power() { - use crate::facade::tendermint_proto::abci::{Validator, VoteInfo}; + use crate::facade::tendermint_proto::v0_37::abci::{ + Validator, VoteInfo, + }; const FIRST_HEIGHT: BlockHeight = BlockHeight(1); const LAST_HEIGHT: BlockHeight = BlockHeight(FIRST_HEIGHT.0 + 11); @@ -951,7 +953,7 @@ mod test_prepare_proposal { let votes = vec![ VoteInfo { validator: Some(Validator { - address: pkh1.clone(), + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake) .expect("Test failed") as i64, @@ -960,7 +962,7 @@ mod test_prepare_proposal { }, VoteInfo { validator: Some(Validator { - address: pkh2, + address: pkh2.into(), power: u128::try_from(val2.bonded_stake) .expect("Test failed") as i64, @@ -1049,7 +1051,7 @@ mod test_prepare_proposal { .sign(&protocol_key, shell.chain_id.clone()) .to_bytes(); let mut rsp = shell.prepare_proposal(RequestPrepareProposal { - txs: vec![vote], + txs: vec![vote.into()], ..Default::default() }); assert_eq!(rsp.txs.len(), 1); @@ -1123,7 +1125,7 @@ mod test_prepare_proposal { .unwrap(); shell.enqueue_tx(tx.clone(), gas); expected_wrapper.push(tx.clone()); - req.txs.push(tx.to_bytes()); + req.txs.push(tx.to_bytes().into()); tx.update_header(TxType::Decrypted(DecryptedTx::Decrypted)); expected_decrypted.push(tx.clone()); } @@ -1140,9 +1142,7 @@ mod test_prepare_proposal { .txs .into_iter() .map(|tx_bytes| { - Tx::try_from(tx_bytes.as_slice()) - .expect("Test failed") - .header + Tx::try_from(tx_bytes.as_ref()).expect("Test failed").header }) .collect(); // check that the order of the txs is correct @@ -1197,13 +1197,13 @@ mod test_prepare_proposal { .expect("Test failed"); let req = RequestPrepareProposal { - txs: vec![wrapper.to_bytes()], + txs: vec![wrapper.to_bytes().into()], ..Default::default() }; let received = shell.prepare_proposal(req).txs.into_iter().map(|tx_bytes| { - Tx::try_from(tx_bytes.as_slice()) + Tx::try_from(tx_bytes.as_ref()) .expect("Test failed") .data() .expect("Test failed") @@ -1239,12 +1239,12 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper.to_bytes(); 2], + txs: vec![wrapper.to_bytes().into(); 2], ..Default::default() }; let received = shell.prepare_proposal(req).txs.into_iter().map(|tx_bytes| { - Tx::try_from(tx_bytes.as_slice()) + Tx::try_from(tx_bytes.as_ref()) .expect("Test failed") .data() .expect("Test failed") @@ -1291,13 +1291,13 @@ mod test_prepare_proposal { .expect("Test failed"); let req = RequestPrepareProposal { - txs: vec![wrapper.to_bytes()], + txs: vec![wrapper.to_bytes().into()], ..Default::default() }; let received = shell.prepare_proposal(req).txs.into_iter().map(|tx_bytes| { - Tx::try_from(tx_bytes.as_slice()) + Tx::try_from(tx_bytes.as_ref()) .expect("Test failed") .data() .expect("Test failed") @@ -1353,12 +1353,12 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper.to_bytes(), new_wrapper.to_bytes()], + txs: vec![wrapper.to_bytes().into(), new_wrapper.to_bytes().into()], ..Default::default() }; let received = shell.prepare_proposal(req).txs.into_iter().map(|tx_bytes| { - Tx::try_from(tx_bytes.as_slice()) + Tx::try_from(tx_bytes.as_ref()) .expect("Test failed") .data() .expect("Test failed") @@ -1400,7 +1400,7 @@ mod test_prepare_proposal { nanos: time.0.timestamp_subsec_nanos() as i32, }; let req = RequestPrepareProposal { - txs: vec![wrapper_tx.to_bytes()], + txs: vec![wrapper_tx.to_bytes().into()], max_tx_bytes: 0, time: Some(block_time), ..Default::default() @@ -1443,7 +1443,7 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper_tx.to_bytes()], + txs: vec![wrapper_tx.to_bytes().into()], max_tx_bytes: 0, time: None, ..Default::default() @@ -1483,7 +1483,7 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper_tx.to_bytes()], + txs: vec![wrapper_tx.to_bytes().into()], max_tx_bytes: 0, time: None, ..Default::default() @@ -1524,7 +1524,7 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper_tx.to_bytes()], + txs: vec![wrapper_tx.to_bytes().into()], max_tx_bytes: 0, time: None, ..Default::default() @@ -1564,7 +1564,7 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper_tx.to_bytes()], + txs: vec![wrapper_tx.to_bytes().into()], max_tx_bytes: 0, time: None, ..Default::default() @@ -1603,7 +1603,7 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper_tx.to_bytes()], + txs: vec![wrapper_tx.to_bytes().into()], max_tx_bytes: 0, time: None, ..Default::default() @@ -1642,7 +1642,7 @@ mod test_prepare_proposal { ))); let req = RequestPrepareProposal { - txs: vec![wrapper_tx.to_bytes()], + txs: vec![wrapper_tx.to_bytes().into()], max_tx_bytes: 0, time: None, ..Default::default() diff --git a/apps/src/lib/node/ledger/shell/process_proposal.rs b/apps/src/lib/node/ledger/shell/process_proposal.rs index 4968faa050..cef017b644 100644 --- a/apps/src/lib/node/ledger/shell/process_proposal.rs +++ b/apps/src/lib/node/ledger/shell/process_proposal.rs @@ -19,7 +19,7 @@ use namada_sdk::eth_bridge::{EthBridgeQueries, SendValsetUpd}; use super::block_alloc::{BlockSpace, EncryptedTxsBins}; use super::*; use crate::facade::tendermint_proto::abci::response_process_proposal::ProposalStatus; -use crate::facade::tendermint_proto::abci::RequestProcessProposal; +use crate::facade::tendermint_proto::v0_37::abci::RequestProcessProposal; use crate::node::ledger::shell::block_alloc::{AllocFailure, TxBin}; use crate::node::ledger::shims::abcipp_shim_types::shim::response::ProcessProposal; use crate::node::ledger::shims::abcipp_shim_types::shim::TxBytes; diff --git a/apps/src/lib/node/ledger/shell/queries.rs b/apps/src/lib/node/ledger/shell/queries.rs index 28843fabc6..aad3386bae 100644 --- a/apps/src/lib/node/ledger/shell/queries.rs +++ b/apps/src/lib/node/ledger/shell/queries.rs @@ -57,7 +57,7 @@ where }; match result { Ok(ResponseQuery { data, info, proof }) => response::Query { - value: data, + value: data.into(), info, proof_ops: proof.map(Into::into), ..Default::default() @@ -146,7 +146,7 @@ mod test_queries { use namada_sdk::eth_bridge::{EthBridgeQueries, SendValsetUpd}; use super::*; - use crate::facade::tendermint_proto::abci::VoteInfo; + use crate::facade::tendermint_proto::v0_37::abci::VoteInfo; use crate::node::ledger::shell::test_utils; use crate::node::ledger::shell::test_utils::get_pkh_from_address; use crate::node::ledger::shims::abcipp_shim_types::shim::request::FinalizeBlock; @@ -243,8 +243,8 @@ mod test_queries { ); let votes = vec![VoteInfo { validator: Some( - namada::tendermint_proto::abci::Validator { - address: pkh1.clone(), + namada::tendermint_proto::v0_37::abci::Validator { + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake) .expect("Test failed") as i64, diff --git a/apps/src/lib/node/ledger/shell/testing/node.rs b/apps/src/lib/node/ledger/shell/testing/node.rs index 8e0787fcfb..0ff85ca66a 100644 --- a/apps/src/lib/node/ledger/shell/testing/node.rs +++ b/apps/src/lib/node/ledger/shell/testing/node.rs @@ -25,8 +25,8 @@ use namada::proof_of_stake::{ read_consensus_validator_set_addresses_with_stake, validator_consensus_key_handle, }; -use namada::tendermint_proto::abci::VoteInfo; -use namada::tendermint_rpc::endpoint::abci_info; +use namada::tendermint::abci::response::Info; +use namada::tendermint_proto::v0_37::abci::VoteInfo; use namada::tendermint_rpc::SimpleRequest; use namada::types::control_flow::time::Duration; use namada::types::ethereum_events::EthereumEvent; @@ -39,11 +39,10 @@ use num_traits::cast::FromPrimitive; use regex::Regex; use tokio::sync::mpsc; -use crate::facade::tendermint_proto::abci::response_process_proposal::ProposalStatus; -use crate::facade::tendermint_proto::abci::{ +use crate::facade::tendermint_proto::v0_37::abci::response_process_proposal::ProposalStatus; +use crate::facade::tendermint_proto::v0_37::abci::{ RequestPrepareProposal, RequestProcessProposal, }; -use crate::facade::tendermint_rpc::endpoint::abci_info::AbciInfo; use crate::facade::tendermint_rpc::error::Error as RpcError; use crate::facade::{tendermint, tendermint_rpc}; use crate::node::ledger::ethereum_oracle::test_tools::mock_web3_client::{ @@ -380,8 +379,8 @@ impl MockNode { let hash_string = tm_consensus_key_raw_hash(&ck); let pkh1 = HEXUPPER.decode(hash_string.as_bytes()).unwrap(); let votes = vec![VoteInfo { - validator: Some(namada::tendermint_proto::abci::Validator { - address: pkh1.clone(), + validator: Some(namada::tendermint_proto::v0_37::abci::Validator { + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake).unwrap() as i64, }), signed_last_block: true, @@ -403,7 +402,7 @@ impl MockNode { // in the finalize block request let txs = { let req = RequestPrepareProposal { - proposer_address: proposer_address.clone(), + proposer_address: proposer_address.clone().into(), ..Default::default() }; let txs = locked.prepare_proposal(req).txs; @@ -459,8 +458,8 @@ impl MockNode { let (proposer_address, votes) = self.prepare_request(); let req = RequestProcessProposal { - txs: txs.clone(), - proposer_address: proposer_address.clone(), + txs: txs.clone().into_iter().map(|tx| tx.into()).collect(), + proposer_address: proposer_address.clone().into(), ..Default::default() }; let mut locked = self.shell.lock().unwrap(); @@ -494,7 +493,10 @@ impl MockNode { txs: txs .into_iter() .zip(result.tx_results.into_iter()) - .map(|(tx, result)| ProcessedTx { tx, result }) + .map(|(tx, result)| ProcessedTx { + tx: tx.into(), + result, + }) .collect(), proposer_address, votes, @@ -604,7 +606,7 @@ impl<'a> Client for &'a MockNode { async fn perform( &self, _request: R, - ) -> std::result::Result + ) -> std::result::Result where R: SimpleRequest, { @@ -612,10 +614,10 @@ impl<'a> Client for &'a MockNode { } /// `/abci_info`: get information about the ABCI application. - async fn abci_info(&self) -> Result { + async fn abci_info(&self) -> Result { self.drive_mock_services_bg().await; let locked = self.shell.lock().unwrap(); - Ok(AbciInfo { + Ok(Info { data: "Namada".to_string(), version: "test".to_string(), app_version: 0, @@ -634,7 +636,9 @@ impl<'a> Client for &'a MockNode { .as_ref() .map(|b| b.hash.0) .unwrap_or_default() - .to_vec(), + .to_vec() + .try_into() + .unwrap(), }) } @@ -642,7 +646,7 @@ impl<'a> Client for &'a MockNode { /// from `CheckTx`. async fn broadcast_tx_sync( &self, - tx: namada::tendermint::abci::Transaction, + tx: impl Into>, ) -> Result { self.drive_mock_services_bg().await; @@ -650,26 +654,29 @@ impl<'a> Client for &'a MockNode { code: Default::default(), data: Default::default(), log: Default::default(), - hash: tendermint::abci::transaction::Hash::new([0; 32]), + hash: tendermint::Hash::default(), }; let tx_bytes: Vec = tx.into(); self.submit_txs(vec![tx_bytes]); if !self.success() { // TODO: submit_txs should return the correct error code + message - resp.code = tendermint::abci::Code::Err(1337); + resp.code = 1337.into(); return Ok(resp); } else { self.clear_results(); } let (proposer_address, _) = self.prepare_request(); let req = RequestPrepareProposal { - proposer_address, + proposer_address: proposer_address.into(), ..Default::default() }; - let txs = { + let txs: Vec> = { let locked = self.shell.lock().unwrap(); locked.prepare_proposal(req).txs - }; + } + .into_iter() + .map(|tx| tx.into()) + .collect(); if !txs.is_empty() { self.submit_txs(txs); } @@ -770,14 +777,15 @@ impl<'a> Client for &'a MockNode { None } }) - .map(|event| namada::tendermint::abci::responses::Event { - type_str: event.event_type.to_string(), + .map(|event| namada::tendermint::abci::Event { + kind: event.event_type.to_string(), attributes: event .attributes .iter() - .map(|(k, v)| namada::tendermint::abci::tag::Tag { + .map(|(k, v)| namada::tendermint::abci::EventAttribute { key: k.parse().unwrap(), value: v.parse().unwrap(), + index: true, }) .collect(), }) @@ -787,10 +795,12 @@ impl<'a> Client for &'a MockNode { Ok(tendermint_rpc::endpoint::block_results::Response { height, txs_results: None, + finalize_block_events: vec![], begin_block_events: None, end_block_events: has_events.then_some(events), validator_updates: vec![], consensus_param_updates: None, + app_hash: namada::tendermint::hash::AppHash::default(), }) } diff --git a/apps/src/lib/node/ledger/shell/vote_extensions.rs b/apps/src/lib/node/ledger/shell/vote_extensions.rs index 847a791ea0..1675179061 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions.rs @@ -416,7 +416,7 @@ where txs: &'shell [TxBytes], ) -> impl Iterator + 'shell { txs.iter().filter_map(move |tx_bytes| { - let tx = match Tx::try_from(tx_bytes.as_slice()) { + let tx = match Tx::try_from(tx_bytes.as_ref()) { Ok(tx) => tx, Err(err) => { tracing::warn!( diff --git a/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs b/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs index 2cefc82bf4..9107386f5f 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions/bridge_pool_vext.rs @@ -283,7 +283,7 @@ mod test_bp_vote_extensions { Epoch, }; use namada::proto::{SignableEthMessage, Signed}; - use namada::tendermint_proto::abci::VoteInfo; + use namada::tendermint_proto::v0_37::abci::VoteInfo; #[cfg(not(feature = "abcipp"))] use namada::types::ethereum_events::Uint; #[cfg(not(feature = "abcipp"))] @@ -362,8 +362,8 @@ mod test_bp_vote_extensions { Epoch::default(), ); let votes = vec![VoteInfo { - validator: Some(namada::tendermint_proto::abci::Validator { - address: pkh1.clone(), + validator: Some(namada::tendermint_proto::v0_37::abci::Validator { + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake).expect("Test failed") as i64, }), diff --git a/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs b/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs index 8b9c140cfc..257626c4d1 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions/eth_events.rs @@ -424,7 +424,7 @@ mod test_vote_extensions { }; #[cfg(feature = "abcipp")] use namada::proto::{SignableEthMessage, Signed}; - use namada::tendermint_proto::abci::VoteInfo; + use namada::tendermint_proto::v0_37::abci::VoteInfo; use namada::types::address::testing::gen_established_address; #[cfg(feature = "abcipp")] use namada::types::eth_abi::Encode; @@ -807,8 +807,8 @@ mod test_vote_extensions { Epoch::default(), ); let votes = vec![VoteInfo { - validator: Some(namada::tendermint_proto::abci::Validator { - address: pkh1.clone(), + validator: Some(namada::tendermint_proto::v0_37::abci::Validator { + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake).expect("Test failed") as i64, }), diff --git a/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs b/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs index ef1a3f9771..3111714c57 100644 --- a/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs +++ b/apps/src/lib/node/ledger/shell/vote_extensions/val_set_update.rs @@ -319,7 +319,7 @@ mod test_vote_extensions { }; #[cfg(feature = "abcipp")] use namada::proto::{SignableEthMessage, Signed}; - use namada::tendermint_proto::abci::VoteInfo; + use namada::tendermint_proto::v0_37::abci::VoteInfo; #[cfg(feature = "abcipp")] use namada::types::eth_abi::Encode; #[cfg(feature = "abcipp")] @@ -604,8 +604,8 @@ mod test_vote_extensions { Epoch::default(), ); let votes = vec![VoteInfo { - validator: Some(namada::tendermint_proto::abci::Validator { - address: pkh1.clone(), + validator: Some(namada::tendermint_proto::v0_37::abci::Validator { + address: pkh1.clone().into(), power: u128::try_from(val1.bonded_stake).expect("Test failed") as i64, }), diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim.rs b/apps/src/lib/node/ledger/shims/abcipp_shim.rs index 3dd5922e92..4910cf2274 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim.rs @@ -26,7 +26,7 @@ use super::abcipp_shim_types::shim::{Error, Request, Response}; use crate::config; use crate::config::{Action, ActionAtHeight}; #[cfg(not(feature = "abcipp"))] -use crate::facade::tendermint_proto::abci::{ +use crate::facade::tendermint_proto::v0_37::abci::{ RequestBeginBlock, ResponseDeliverTx, }; #[cfg(not(feature = "abcipp"))] diff --git a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs index ca7be9a9e5..f44f172369 100644 --- a/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs +++ b/apps/src/lib/node/ledger/shims/abcipp_shim_types.rs @@ -6,9 +6,14 @@ pub mod shim { use thiserror::Error; use super::{Request as Req, Response as Resp}; - #[cfg(not(feature = "abcipp"))] - use crate::facade::tendermint_proto::abci::ResponseEndBlock; + #[cfg(feature = "abcipp")] use crate::facade::tendermint_proto::abci::{ + RequestExtendVote, RequestVerifyVoteExtension, ResponseExtendVote, + ResponseVerifyVoteExtension, + }; + #[cfg(not(feature = "abcipp"))] + use crate::facade::tendermint_proto::v0_37::abci::ResponseEndBlock; + use crate::facade::tendermint_proto::v0_37::abci::{ RequestApplySnapshotChunk, RequestCheckTx, RequestCommit, RequestEcho, RequestFlush, RequestInfo, RequestInitChain, RequestListSnapshots, RequestLoadSnapshotChunk, RequestOfferSnapshot, RequestPrepareProposal, @@ -18,14 +23,9 @@ pub mod shim { ResponseLoadSnapshotChunk, ResponseOfferSnapshot, ResponseQuery, VoteInfo, }; - #[cfg(feature = "abcipp")] - use crate::facade::tendermint_proto::abci::{ - RequestExtendVote, RequestVerifyVoteExtension, ResponseExtendVote, - ResponseVerifyVoteExtension, - }; use crate::node::ledger::shell; - pub type TxBytes = Vec; + pub type TxBytes = prost::bytes::Bytes; #[derive(Error, Debug)] #[allow(clippy::large_enum_variant)] @@ -185,7 +185,7 @@ pub mod shim { use std::convert::TryFrom; #[cfg(not(feature = "abcipp"))] - use namada::tendermint_proto::abci::RequestBeginBlock; + use namada::tendermint_proto::v0_37::abci::RequestBeginBlock; use namada::types::hash::Hash; use namada::types::storage::{BlockHash, Header}; use namada::types::time::DateTimeUtc; @@ -196,7 +196,7 @@ pub mod shim { use super::VoteInfo; #[cfg(not(feature = "abcipp"))] - use crate::facade::tendermint_proto::abci::Misbehavior as Evidence; + use crate::facade::tendermint_proto::v0_37::abci::Misbehavior as Evidence; pub struct VerifyHeader; @@ -271,12 +271,12 @@ pub mod shim { #[cfg(feature = "abcipp")] use namada::ledger::events::EventLevel; - use crate::facade::tendermint_proto::abci::{ + use crate::facade::tendermint_proto::v0_37::abci::{ Event as TmEvent, ResponsePrepareProposal, ResponseProcessProposal, ValidatorUpdate, }; #[cfg(not(feature = "abcipp"))] - use crate::facade::tendermint_proto::types::ConsensusParams; + use crate::facade::tendermint_proto::v0_37::types::ConsensusParams; #[cfg(feature = "abcipp")] use crate::facade::tendermint_proto::{ abci::{ExecTxResult, ResponseFinalizeBlock}, @@ -415,7 +415,7 @@ pub mod shim { #[cfg(not(feature = "abcipp"))] impl From - for crate::facade::tendermint_proto::abci::ResponseEndBlock + for crate::facade::tendermint_proto::v0_37::abci::ResponseEndBlock { fn from(resp: FinalizeBlock) -> Self { Self { diff --git a/apps/src/lib/node/ledger/tendermint_node.rs b/apps/src/lib/node/ledger/tendermint_node.rs index 25a2b9e114..7698b4b08a 100644 --- a/apps/src/lib/node/ledger/tendermint_node.rs +++ b/apps/src/lib/node/ledger/tendermint_node.rs @@ -406,8 +406,10 @@ async fn write_tm_genesis( file.read_to_end(&mut file_contents) .await .expect("Couldn't read Tendermint genesis file"); - let mut genesis: Genesis = serde_json::from_slice(&file_contents[..]) - .expect("Couldn't deserialize the genesis file"); + // Set `Option` for the omitted `app_state` + let mut genesis: Genesis> = + serde_json::from_slice(&file_contents[..]) + .expect("Couldn't deserialize the genesis file"); genesis.chain_id = FromStr::from_str(chain_id.as_str()).expect("Invalid chain ID"); genesis.genesis_time = genesis_time @@ -422,9 +424,9 @@ async fn write_tm_genesis( // gas is metered app-side, so we disable it // at the Tendermint level max_gas: -1, + /// This parameter has no value anymore in Tendermint-core + time_iota_ms: block::Size::default_time_iota_ms(), }; - #[cfg(not(feature = "abcipp"))] - let size = Some(size); genesis.consensus_params.block = size; #[cfg(feature = "abcipp")] { diff --git a/benches/native_vps.rs b/benches/native_vps.rs index eecfbd6a32..65395fd9c7 100644 --- a/benches/native_vps.rs +++ b/benches/native_vps.rs @@ -296,7 +296,7 @@ fn ibc(c: &mut Criterion) { // Connection handshake let msg = MsgConnectionOpenInit { client_id_on_a: ClientId::new( - ClientType::new("01-tendermint".to_string()).unwrap(), + ClientType::new("01-tendermint").unwrap(), 1, ) .unwrap(), diff --git a/core/Cargo.toml b/core/Cargo.toml index 05433958e8..3721d603ad 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -28,6 +28,7 @@ wasm-runtime = [ abciplus = [ "ibc", + "ibc-derive", "ibc-proto", "tendermint", "tendermint-proto", @@ -67,9 +68,9 @@ eyre.workspace = true ferveo = {optional = true, git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"} ferveo-common = {git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"} tpke = {package = "group-threshold-cryptography", optional = true, git = "https://github.com/anoma/ferveo", rev = "e5abd0acc938da90140351a65a26472eb495ce4d"} -# TODO using the same version of tendermint-rs as we do here. -ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs.git", rev = "206cb5fa74a7ca38038b937d202ae39fbbd63c19", features = ["serde"], optional = true} -ibc-proto = {git = "https://github.com/heliaxdev/ibc-proto-rs.git", rev = "31892ee743b2af017d5629b2af419ee20b6100c7", default-features = false, optional = true} +ibc = { version = "0.47.0", default-features = false, features = ["serde"], optional = true} +ibc-derive = { version = "0.3.0", optional = true} +ibc-proto = {version = "0.37.1", default-features = false, optional = true} ics23.workspace = true impl-num-traits = "0.1.2" index-set.workspace = true @@ -90,8 +91,8 @@ rayon = {version = "=1.5.3", optional = true} serde.workspace = true serde_json.workspace = true sha2.workspace = true -tendermint = { git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", optional = true} -tendermint-proto = { git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", optional = true} +tendermint = {workspace = true, optional = true} +tendermint-proto = {workspace = true, optional = true} thiserror.workspace = true tiny-keccak = {version = "2.0.2", features = ["keccak"]} tracing.workspace = true diff --git a/core/src/ledger/ibc/context/client.rs b/core/src/ledger/ibc/context/client.rs new file mode 100644 index 0000000000..5c771a0712 --- /dev/null +++ b/core/src/ledger/ibc/context/client.rs @@ -0,0 +1,555 @@ +//! AnyClientState and AnyConsensusState for IBC context + +use ibc_derive::ConsensusState; +use prost::Message; + +use crate::ibc::clients::ics07_tendermint::client_state::ClientState as TmClientState; +use crate::ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState; +use crate::ibc::clients::ics07_tendermint::{ + CommonContext, ExecutionContext as TmExecutionContext, + ValidationContext as TmValidationContext, +}; +use crate::ibc::core::ics02_client::client_state::{ + ClientStateCommon, ClientStateExecution, ClientStateValidation, Status, + UpdateKind, +}; +use crate::ibc::core::ics02_client::client_type::ClientType; +use crate::ibc::core::ics02_client::error::ClientError; +use crate::ibc::core::ics02_client::{ + ClientExecutionContext, ClientValidationContext, +}; +use crate::ibc::core::ics23_commitment::commitment::{ + CommitmentPrefix, CommitmentProofBytes, CommitmentRoot, +}; +use crate::ibc::core::ics24_host::identifier::ClientId; +use crate::ibc::core::ics24_host::path::Path; +use crate::ibc::core::ExecutionContext; +#[cfg(feature = "ibc-mocks")] +use crate::ibc::mock::client_state::MockClientContext; +#[cfg(feature = "ibc-mocks")] +use crate::ibc::mock::client_state::MockClientState; +#[cfg(feature = "ibc-mocks")] +use crate::ibc::mock::consensus_state::MockConsensusState; +use crate::ibc::Height; +use crate::ibc_proto::google::protobuf::Any; + +// TODO: #[derive(ClientState)] doesn't support contexts with contexts generic +// for now +/// ClientState for light clients +#[derive(Debug, Clone)] +pub enum AnyClientState { + /// Tendermint client state + Tendermint(TmClientState), + + #[cfg(feature = "ibc-mocks")] + /// Mock client state for testing + Mock(MockClientState), +} + +impl From for AnyClientState { + fn from(cs: TmClientState) -> Self { + Self::Tendermint(cs) + } +} + +#[cfg(feature = "ibc-mocks")] +impl From for AnyClientState { + fn from(cs: MockClientState) -> Self { + Self::Mock(cs) + } +} + +impl From for Any { + fn from(client_state: AnyClientState) -> Self { + match client_state { + AnyClientState::Tendermint(cs) => cs.into(), + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => cs.into(), + } + } +} + +impl TryFrom for AnyClientState { + type Error = ClientError; + + fn try_from(client_state: Any) -> Result { + #[cfg(feature = "ibc-mocks")] + if let Ok(cs) = MockClientState::try_from(client_state.clone()) { + return Ok(cs.into()); + } + + let cs = TmClientState::try_from(client_state).map_err(|_| { + ClientError::ClientSpecific { + description: "Unknown client state".to_string(), + } + })?; + Ok(cs.into()) + } +} + +/// ConsensusState for light clients +#[derive(ConsensusState)] +pub enum AnyConsensusState { + /// Tendermint consensus state + Tendermint(TmConsensusState), + + #[cfg(feature = "ibc-mocks")] + /// Mock consensus state for testing + Mock(MockConsensusState), +} + +impl From for AnyConsensusState { + fn from(cs: TmConsensusState) -> Self { + Self::Tendermint(cs) + } +} + +#[cfg(feature = "ibc-mocks")] +impl From for AnyConsensusState { + fn from(cs: MockConsensusState) -> Self { + Self::Mock(cs) + } +} + +impl TryFrom for TmConsensusState { + type Error = ClientError; + + fn try_from(any: AnyConsensusState) -> Result { + match any { + AnyConsensusState::Tendermint(cs) => Ok(cs), + #[cfg(feature = "ibc-mocks")] + _ => Err(ClientError::UnknownConsensusStateType { + consensus_state_type: "Only Tendermint client state type is \ + supported" + .to_string(), + }), + } + } +} + +#[cfg(feature = "ibc-mocks")] +impl TryFrom for MockConsensusState { + type Error = ClientError; + + fn try_from(any: AnyConsensusState) -> Result { + match any { + AnyConsensusState::Mock(cs) => Ok(cs), + _ => Err(ClientError::UnknownConsensusStateType { + consensus_state_type: "The type should be MockConsensusState" + .to_string(), + }), + } + } +} + +impl TryFrom for AnyConsensusState { + type Error = ClientError; + + fn try_from(consensus_state: Any) -> Result { + #[cfg(feature = "ibc-mocks")] + if let Ok(cs) = MockConsensusState::try_from(consensus_state.clone()) { + return Ok(cs.into()); + } + + let cs = TmConsensusState::try_from(consensus_state).map_err(|_| { + ClientError::ClientSpecific { + description: "Unknown consensus state".to_string(), + } + })?; + Ok(cs.into()) + } +} + +impl TryFrom> for AnyConsensusState { + type Error = ClientError; + + fn try_from(bytes: Vec) -> Result { + Any::decode(&bytes[..]) + .map_err(ClientError::Decode)? + .try_into() + } +} + +impl ClientStateCommon for AnyClientState { + fn verify_consensus_state( + &self, + consensus_state: Any, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.verify_consensus_state(consensus_state) + } + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => { + cs.verify_consensus_state(consensus_state) + } + } + } + + fn client_type(&self) -> ClientType { + match self { + AnyClientState::Tendermint(cs) => cs.client_type(), + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => cs.client_type(), + } + } + + fn latest_height(&self) -> Height { + match self { + AnyClientState::Tendermint(cs) => cs.latest_height(), + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => cs.latest_height(), + } + } + + fn validate_proof_height( + &self, + proof_height: Height, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.validate_proof_height(proof_height) + } + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => cs.validate_proof_height(proof_height), + } + } + + fn verify_upgrade_client( + &self, + upgraded_client_state: Any, + upgraded_consensus_state: Any, + proof_upgrade_client: CommitmentProofBytes, + proof_upgrade_consensus_state: CommitmentProofBytes, + root: &CommitmentRoot, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => cs.verify_upgrade_client( + upgraded_client_state, + upgraded_consensus_state, + proof_upgrade_client, + proof_upgrade_consensus_state, + root, + ), + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => cs.verify_upgrade_client( + upgraded_client_state, + upgraded_consensus_state, + proof_upgrade_client, + proof_upgrade_consensus_state, + root, + ), + } + } + + fn verify_membership( + &self, + prefix: &CommitmentPrefix, + proof: &CommitmentProofBytes, + root: &CommitmentRoot, + path: Path, + value: Vec, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.verify_membership(prefix, proof, root, path, value) + } + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => { + cs.verify_membership(prefix, proof, root, path, value) + } + } + } + + fn verify_non_membership( + &self, + prefix: &CommitmentPrefix, + proof: &CommitmentProofBytes, + root: &CommitmentRoot, + path: Path, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.verify_non_membership(prefix, proof, root, path) + } + #[cfg(feature = "ibc-mocks")] + AnyClientState::Mock(cs) => { + cs.verify_non_membership(prefix, proof, root, path) + } + } + } +} + +#[cfg(not(feature = "ibc-mocks"))] +impl ClientStateValidation for AnyClientState +where + V: ClientValidationContext + TmValidationContext, + ClientError: From<::ConversionError>, +{ + fn verify_client_message( + &self, + ctx: &V, + client_id: &ClientId, + client_message: Any, + update_kind: &UpdateKind, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => cs.verify_client_message( + ctx, + client_id, + client_message, + update_kind, + ), + } + } + + fn check_for_misbehaviour( + &self, + ctx: &V, + client_id: &ClientId, + client_message: Any, + update_kind: &UpdateKind, + ) -> Result { + match self { + AnyClientState::Tendermint(cs) => cs.check_for_misbehaviour( + ctx, + client_id, + client_message, + update_kind, + ), + } + } + + fn status( + &self, + ctx: &V, + client_id: &ClientId, + ) -> Result { + match self { + AnyClientState::Tendermint(cs) => cs.status(ctx, client_id), + } + } +} + +#[cfg(feature = "ibc-mocks")] +impl ClientStateValidation for AnyClientState +where + V: ClientValidationContext + TmValidationContext + MockClientContext, + ClientError: From<::ConversionError> + + From< + <::AnyConsensusState as TryInto< + MockConsensusState, + >>::Error, + >, +{ + fn verify_client_message( + &self, + ctx: &V, + client_id: &ClientId, + client_message: Any, + update_kind: &UpdateKind, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => cs.verify_client_message( + ctx, + client_id, + client_message, + update_kind, + ), + AnyClientState::Mock(cs) => cs.verify_client_message( + ctx, + client_id, + client_message, + update_kind, + ), + } + } + + fn check_for_misbehaviour( + &self, + ctx: &V, + client_id: &ClientId, + client_message: Any, + update_kind: &UpdateKind, + ) -> Result { + match self { + AnyClientState::Tendermint(cs) => cs.check_for_misbehaviour( + ctx, + client_id, + client_message, + update_kind, + ), + AnyClientState::Mock(cs) => cs.check_for_misbehaviour( + ctx, + client_id, + client_message, + update_kind, + ), + } + } + + fn status( + &self, + ctx: &V, + client_id: &ClientId, + ) -> Result { + match self { + AnyClientState::Tendermint(cs) => cs.status(ctx, client_id), + AnyClientState::Mock(cs) => cs.status(ctx, client_id), + } + } +} + +#[cfg(not(feature = "ibc-mocks"))] +impl ClientStateExecution for AnyClientState +where + E: ExecutionContext + TmExecutionContext, + ::AnyClientState: From, + ::AnyConsensusState: From, +{ + fn initialise( + &self, + ctx: &mut E, + client_id: &ClientId, + consensus_state: Any, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.initialise(ctx, client_id, consensus_state) + } + } + } + + fn update_state( + &self, + ctx: &mut E, + client_id: &ClientId, + header: Any, + ) -> Result, ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.update_state(ctx, client_id, header) + } + } + } + + fn update_state_on_misbehaviour( + &self, + ctx: &mut E, + client_id: &ClientId, + client_message: Any, + update_kind: &UpdateKind, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => cs.update_state_on_misbehaviour( + ctx, + client_id, + client_message, + update_kind, + ), + } + } + + fn update_state_on_upgrade( + &self, + ctx: &mut E, + client_id: &ClientId, + upgraded_client_state: Any, + upgraded_consensus_state: Any, + ) -> Result { + match self { + AnyClientState::Tendermint(cs) => cs.update_state_on_upgrade( + ctx, + client_id, + upgraded_client_state, + upgraded_consensus_state, + ), + } + } +} + +#[cfg(feature = "ibc-mocks")] +impl ClientStateExecution for AnyClientState +where + E: ExecutionContext + TmExecutionContext + MockClientContext, + ::AnyClientState: + From + From, + ::AnyConsensusState: + From + From, +{ + fn initialise( + &self, + ctx: &mut E, + client_id: &ClientId, + consensus_state: Any, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.initialise(ctx, client_id, consensus_state) + } + AnyClientState::Mock(cs) => { + cs.initialise(ctx, client_id, consensus_state) + } + } + } + + fn update_state( + &self, + ctx: &mut E, + client_id: &ClientId, + header: Any, + ) -> Result, ClientError> { + match self { + AnyClientState::Tendermint(cs) => { + cs.update_state(ctx, client_id, header) + } + AnyClientState::Mock(cs) => cs.update_state(ctx, client_id, header), + } + } + + fn update_state_on_misbehaviour( + &self, + ctx: &mut E, + client_id: &ClientId, + client_message: Any, + update_kind: &UpdateKind, + ) -> Result<(), ClientError> { + match self { + AnyClientState::Tendermint(cs) => cs.update_state_on_misbehaviour( + ctx, + client_id, + client_message, + update_kind, + ), + AnyClientState::Mock(cs) => cs.update_state_on_misbehaviour( + ctx, + client_id, + client_message, + update_kind, + ), + } + } + + fn update_state_on_upgrade( + &self, + ctx: &mut E, + client_id: &ClientId, + upgraded_client_state: Any, + upgraded_consensus_state: Any, + ) -> Result { + match self { + AnyClientState::Tendermint(cs) => cs.update_state_on_upgrade( + ctx, + client_id, + upgraded_client_state, + upgraded_consensus_state, + ), + AnyClientState::Mock(cs) => cs.update_state_on_upgrade( + ctx, + client_id, + upgraded_client_state, + upgraded_consensus_state, + ), + } + } +} diff --git a/core/src/ledger/ibc/context/common.rs b/core/src/ledger/ibc/context/common.rs index a6018d231d..d823b005d7 100644 --- a/core/src/ledger/ibc/context/common.rs +++ b/core/src/ledger/ibc/context/common.rs @@ -1,179 +1,492 @@ //! IbcCommonContext implementation for IBC -use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; +use core::time::Duration; + use prost::Message; use sha2::Digest; +use super::client::{AnyClientState, AnyConsensusState}; use super::storage::IbcStorageContext; -use crate::ibc::clients::ics07_tendermint::client_state::ClientState as TmClientState; use crate::ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState; -use crate::ibc::core::ics02_client::client_state::ClientState; use crate::ibc::core::ics02_client::consensus_state::ConsensusState; use crate::ibc::core::ics02_client::error::ClientError; +use crate::ibc::core::ics02_client::height::Height; use crate::ibc::core::ics03_connection::connection::ConnectionEnd; use crate::ibc::core::ics03_connection::error::ConnectionError; use crate::ibc::core::ics04_channel::channel::ChannelEnd; -use crate::ibc::core::ics04_channel::commitment::PacketCommitment; +use crate::ibc::core::ics04_channel::commitment::{ + AcknowledgementCommitment, PacketCommitment, +}; use crate::ibc::core::ics04_channel::error::{ChannelError, PacketError}; -use crate::ibc::core::ics04_channel::packet::Sequence; +use crate::ibc::core::ics04_channel::packet::{Receipt, Sequence}; use crate::ibc::core::ics04_channel::timeout::TimeoutHeight; -use crate::ibc::core::ics24_host::identifier::{ClientId, ConnectionId}; -use crate::ibc::core::ics24_host::path::{ - ChannelEndPath, ClientConsensusStatePath, CommitmentPath, Path, SeqSendPath, +use crate::ibc::core::ics24_host::identifier::{ + ChannelId, ClientId, ConnectionId, PortId, }; use crate::ibc::core::timestamp::Timestamp; use crate::ibc::core::ContextError; -#[cfg(any(feature = "ibc-mocks-abcipp", feature = "ibc-mocks"))] -use crate::ibc::mock::client_state::MockClientState; -#[cfg(any(feature = "ibc-mocks-abcipp", feature = "ibc-mocks"))] -use crate::ibc::mock::consensus_state::MockConsensusState; use crate::ibc_proto::google::protobuf::Any; use crate::ibc_proto::protobuf::Protobuf; use crate::ledger::ibc::storage; -use crate::types::address::Address; -use crate::types::storage::Key; -use crate::types::token; +use crate::ledger::parameters::storage::get_max_expected_time_per_block_key; +use crate::ledger::storage_api; +use crate::tendermint::Time as TmTime; +use crate::tendermint_proto::Protobuf as TmProtobuf; +use crate::types::storage::{BlockHeight, Key}; +use crate::types::time::DurationSecs; + +/// Result of IBC common function call +pub type Result = std::result::Result; /// Context to handle typical IBC data pub trait IbcCommonContext: IbcStorageContext { /// Get the ClientState - fn client_state( - &self, - client_id: &ClientId, - ) -> Result, ContextError> { + fn client_state(&self, client_id: &ClientId) -> Result { let key = storage::client_state_key(client_id); - match self.read(&key) { - Ok(Some(value)) => { - let any = Any::decode(&value[..]).map_err(|e| { - ContextError::ClientError(ClientError::Decode(e)) - })?; - self.decode_client_state(any) + match self.read_bytes(&key)? { + Some(value) => Any::decode(&value[..]) + .map_err(ClientError::Decode)? + .try_into() + .map_err(ContextError::from), + None => Err(ClientError::ClientStateNotFound { + client_id: client_id.clone(), } - Ok(None) => Err(ContextError::ClientError( - ClientError::ClientStateNotFound { - client_id: client_id.clone(), - }, - )), - Err(_) => Err(ContextError::ClientError(ClientError::Other { - description: format!( - "Reading the client state failed: ID {}", - client_id, - ), - })), + .into()), } } + /// Store the ClientState + fn store_client_state( + &mut self, + client_id: &ClientId, + client_state: AnyClientState, + ) -> Result<()> { + let key = storage::client_state_key(client_id); + let bytes = Any::from(client_state).encode_to_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) + } + /// Get the ConsensusState fn consensus_state( &self, - client_cons_state_path: &ClientConsensusStatePath, - ) -> Result, ContextError> { - let path = Path::ClientConsensusState(client_cons_state_path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - match self.read(&key) { - Ok(Some(value)) => { - let any = Any::decode(&value[..]).map_err(|e| { - ContextError::ClientError(ClientError::Decode(e)) - })?; - self.decode_consensus_state(any) + client_id: &ClientId, + height: Height, + ) -> Result { + let key = storage::consensus_state_key(client_id, height); + match self.read_bytes(&key)? { + Some(value) => Any::decode(&value[..]) + .map_err(ClientError::Decode)? + .try_into() + .map_err(ContextError::from), + None => Err(ClientError::ConsensusStateNotFound { + client_id: client_id.clone(), + height, + } + .into()), + } + } + + /// Store the ConsensusState + fn store_consensus_state( + &mut self, + client_id: &ClientId, + height: Height, + consensus_state: AnyConsensusState, + ) -> Result<()> { + let key = storage::consensus_state_key(client_id, height); + let bytes = consensus_state.encode_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) + } + + /// Delete the ConsensusState + fn delete_consensus_state( + &mut self, + client_id: &ClientId, + height: Height, + ) -> Result<()> { + let key = storage::consensus_state_key(client_id, height); + self.delete(&key).map_err(ContextError::from) + } + + /// Decode ConsensusState from bytes + fn decode_consensus_state_value( + &self, + consensus_state: Vec, + ) -> Result { + Any::decode(&consensus_state[..]) + .map_err(ClientError::Decode)? + .try_into() + .map_err(ContextError::from) + } + + /// Get heights of all consensus states + fn consensus_state_heights( + &self, + client_id: &ClientId, + ) -> Result> { + let prefix = storage::consensus_state_prefix(client_id); + let mut iter = self.iter_prefix(&prefix)?; + let mut heights = Vec::new(); + while let Some((key, _)) = self.iter_next(&mut iter)? { + let key = Key::parse(key).expect("the key should be parsable"); + let height = storage::consensus_height(&key).map_err(|e| { + ClientError::Other { + description: e.to_string(), + } + })?; + heights.push(height); + } + Ok(heights) + } + + /// Get the next consensus state after the given height + fn next_consensus_state( + &self, + client_id: &ClientId, + height: &Height, + ) -> Result> { + let prefix = storage::consensus_state_prefix(client_id); + let mut iter = self.iter_prefix(&prefix)?; + let mut lowest_height_value = None; + while let Some((key, value)) = self.iter_next(&mut iter)? { + let key = Key::parse(key).expect("the key should be parsable"); + let consensus_height = storage::consensus_height(&key) + .expect("the key should have a height"); + if consensus_height > *height { + lowest_height_value = match lowest_height_value { + Some((lowest, _)) if consensus_height < lowest => { + Some((consensus_height, value)) + } + Some(_) => continue, + None => Some((consensus_height, value)), + }; } - Ok(None) => { - let client_id = storage::client_id(&key).expect("invalid key"); - let height = - storage::consensus_height(&key).expect("invalid key"); - Err(ContextError::ClientError( - ClientError::ConsensusStateNotFound { client_id, height }, - )) + } + lowest_height_value + .map(|(_, value)| value.try_into().map_err(ContextError::from)) + .transpose() + } + + /// Get the previous consensus state before the given height + fn prev_consensus_state( + &self, + client_id: &ClientId, + height: &Height, + ) -> Result> { + let prefix = storage::consensus_state_prefix(client_id); + // for iterator + let mut iter = self.iter_prefix(&prefix)?; + let mut highest_height_value = None; + while let Some((key, value)) = self.iter_next(&mut iter)? { + let key = Key::parse(key).expect("the key should be parsable"); + let consensus_height = storage::consensus_height(&key) + .expect("the key should have the height"); + if consensus_height < *height { + highest_height_value = match highest_height_value { + Some((highest, _)) if consensus_height > highest => { + Some((consensus_height, value)) + } + Some(_) => continue, + None => Some((consensus_height, value)), + }; } - Err(_) => Err(ContextError::ClientError(ClientError::Other { + } + highest_height_value + .map(|(_, value)| value.try_into().map_err(ContextError::from)) + .transpose() + } + + /// Get the client update time + fn client_update_time(&self, client_id: &ClientId) -> Result { + let key = storage::client_update_timestamp_key(client_id); + let value = + self.read_bytes(&key)?.ok_or(ClientError::ClientSpecific { + description: format!( + "The client update time doesn't exist: ID {client_id}", + ), + })?; + let time = + TmTime::decode_vec(&value).map_err(|_| ClientError::Other { description: format!( - "Reading the consensus state failed: Key {}", - key, + "Decoding the client update time failed: ID {client_id}", ), - })), + })?; + Ok(time.into()) + } + + /// Store the client update time + fn store_update_time( + &mut self, + client_id: &ClientId, + timestamp: Timestamp, + ) -> Result<()> { + let key = storage::client_update_timestamp_key(client_id); + let time = timestamp.into_tm_time().ok_or(ClientError::Other { + description: format!( + "The client timestamp is invalid: ID {client_id}", + ), + })?; + self.write_bytes(&key, time.encode_vec()) + .map_err(ContextError::from) + } + + /// Delete the client update time + fn delete_update_time(&mut self, client_id: &ClientId) -> Result<()> { + let key = storage::client_update_timestamp_key(client_id); + self.delete(&key).map_err(ContextError::from) + } + + /// Get the client update height + fn client_update_height(&self, client_id: &ClientId) -> Result { + let key = storage::client_update_height_key(client_id); + let value = self.read_bytes(&key)?.ok_or({ + ClientError::ClientSpecific { + description: format!( + "The client update height doesn't exist: ID {client_id}", + ), + } + })?; + Height::decode_vec(&value).map_err(|_| { + ClientError::Other { + description: format!( + "Decoding the client update height failed: ID {client_id}", + ), + } + .into() + }) + } + + /// Get the timestamp on this chain + fn host_timestamp(&self) -> Result { + let height = self.get_block_height()?; + let header = self.get_block_header(height)?.ok_or_else(|| { + ContextError::from(ClientError::Other { + description: "No host header".to_string(), + }) + })?; + let time = TmTime::try_from(header.time).map_err(|_| { + ContextError::ClientError(ClientError::Other { + description: "Converting to Tendermint time failed".to_string(), + }) + })?; + Ok(time.into()) + } + + /// Get the consensus state of this chain + fn host_consensus_state( + &self, + height: &Height, + ) -> Result { + let height = BlockHeight(height.revision_height()); + let header = self.get_block_header(height)?.ok_or_else(|| { + ContextError::from(ClientError::Other { + description: "No host header".to_string(), + }) + })?; + let commitment_root = header.hash.to_vec().into(); + let time = header + .time + .try_into() + .expect("The time should be converted"); + let next_validators_hash = header + .next_validators_hash + .try_into() + .expect("The hash should be converted"); + let consensus_state = + TmConsensusState::new(commitment_root, time, next_validators_hash); + Ok(consensus_state.into()) + } + + /// Get the max expected time per block + fn max_expected_time_per_block(&self) -> Result { + let key = get_max_expected_time_per_block_key(); + match self.read::(&key)? { + Some(duration) => Ok(duration.into()), + None => unreachable!("The parameter should be initialized"), } } + /// Store the client update height + fn store_update_height( + &mut self, + client_id: &ClientId, + host_height: Height, + ) -> Result<()> { + let key = storage::client_update_height_key(client_id); + let bytes = host_height.encode_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) + } + + /// Delete the client update height + fn delete_update_height(&mut self, client_id: &ClientId) -> Result<()> { + let key = storage::client_update_height_key(client_id); + self.delete(&key).map_err(ContextError::from) + } + /// Get the ConnectionEnd - fn connection_end( - &self, + fn connection_end(&self, conn_id: &ConnectionId) -> Result { + let key = storage::connection_key(conn_id); + let value = self.read_bytes(&key)?.ok_or( + ConnectionError::ConnectionNotFound { + connection_id: conn_id.clone(), + }, + )?; + ConnectionEnd::decode_vec(&value).map_err(|_| { + ConnectionError::Other { + description: format!( + "Decoding the connection end failed: ID {conn_id}", + ), + } + .into() + }) + } + + /// Store the ConnectionEnd + fn store_connection( + &mut self, connection_id: &ConnectionId, - ) -> Result { + connection_end: ConnectionEnd, + ) -> Result<()> { let key = storage::connection_key(connection_id); - match self.read(&key) { - Ok(Some(value)) => { - ConnectionEnd::decode_vec(&value).map_err(|_| { - ContextError::ConnectionError(ConnectionError::Other { - description: format!( - "Decoding the connection end failed: ID {}", - connection_id, - ), - }) - }) - } - Ok(None) => Err(ContextError::ConnectionError( - ConnectionError::ConnectionNotFound { - connection_id: connection_id.clone(), - }, - )), - Err(_) => { - Err(ContextError::ConnectionError(ConnectionError::Other { - description: format!( - "Reading the connection end failed: ID {}", - connection_id, - ), - })) - } - } + let bytes = connection_end.encode_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) + } + + /// Append the connection ID to the connection list of the client + fn append_connection( + &mut self, + client_id: &ClientId, + conn_id: ConnectionId, + ) -> Result<()> { + let key = storage::client_connections_key(client_id); + let list = match self.read::(&key)? { + Some(list) => format!("{list},{conn_id}"), + None => conn_id.to_string(), + }; + self.write(&key, list).map_err(ContextError::from) } /// Get the ChannelEnd fn channel_end( &self, - channel_end_path: &ChannelEndPath, - ) -> Result { - let path = Path::ChannelEnd(channel_end_path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - match self.read(&key) { - Ok(Some(value)) => ChannelEnd::decode_vec(&value).map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "Decoding the channel end failed: Key {}", - key, - ), - }) - }), - Ok(None) => { - let (port_id, channel_id) = - storage::port_channel_id(&key).expect("invalid key"); - Err(ContextError::ChannelError(ChannelError::ChannelNotFound { - channel_id, - port_id, - })) - } - Err(_) => Err(ContextError::ChannelError(ChannelError::Other { + port_id: &PortId, + channel_id: &ChannelId, + ) -> Result { + let key = storage::channel_key(port_id, channel_id); + let value = + self.read_bytes(&key)? + .ok_or(ChannelError::ChannelNotFound { + port_id: port_id.clone(), + channel_id: channel_id.clone(), + })?; + ChannelEnd::decode_vec(&value).map_err(|_| { + ChannelError::Other { description: format!( - "Reading the channel end failed: Key {}", - key, + "Decoding the channel end failed: Key {key}", ), - })), - } + } + .into() + }) + } + + /// Store the ChannelEnd + fn store_channel( + &mut self, + port_id: &PortId, + channel_id: &ChannelId, + channel_end: ChannelEnd, + ) -> Result<()> { + let key = storage::channel_key(port_id, channel_id); + let bytes = channel_end.encode_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) } /// Get the NextSequenceSend fn get_next_sequence_send( &self, - path: &SeqSendPath, - ) -> Result { - let path = Path::SeqSend(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); + port_id: &PortId, + channel_id: &ChannelId, + ) -> Result { + let key = storage::next_sequence_send_key(port_id, channel_id); + self.read_sequence(&key) + } + + /// Store the NextSequenceSend + fn store_next_sequence_send( + &mut self, + port_id: &PortId, + channel_id: &ChannelId, + seq: Sequence, + ) -> Result<()> { + let key = storage::next_sequence_send_key(port_id, channel_id); + self.store_sequence(&key, seq) + } + + /// Get the NextSequenceRecv + fn get_next_sequence_recv( + &self, + port_id: &PortId, + channel_id: &ChannelId, + ) -> Result { + let key = storage::next_sequence_recv_key(port_id, channel_id); + self.read_sequence(&key) + } + + /// Store the NextSequenceRecv + fn store_next_sequence_recv( + &mut self, + port_id: &PortId, + channel_id: &ChannelId, + seq: Sequence, + ) -> Result<()> { + let key = storage::next_sequence_recv_key(port_id, channel_id); + self.store_sequence(&key, seq) + } + + /// Get the NextSequenceAck + fn get_next_sequence_ack( + &self, + port_id: &PortId, + channel_id: &ChannelId, + ) -> Result { + let key = storage::next_sequence_ack_key(port_id, channel_id); self.read_sequence(&key) } + /// Store the NextSequenceAck + fn store_next_sequence_ack( + &mut self, + port_id: &PortId, + channel_id: &ChannelId, + seq: Sequence, + ) -> Result<()> { + let key = storage::next_sequence_ack_key(port_id, channel_id); + self.store_sequence(&key, seq) + } + + /// Read a sequence + fn read_sequence(&self, key: &Key) -> Result { + match self.read_bytes(key)? { + Some(value) => { + let value: [u8; 8] = + value.try_into().map_err(|_| ChannelError::Other { + description: format!( + "The sequence value wasn't u64: Key {key}", + ), + })?; + Ok(u64::from_be_bytes(value).into()) + } + // when the sequence has never been used, returns the initial value + None => Ok(1.into()), + } + } + + /// Store the sequence + fn store_sequence(&mut self, key: &Key, sequence: Sequence) -> Result<()> { + let bytes = u64::from(sequence).to_be_bytes().to_vec(); + self.write_bytes(key, bytes).map_err(ContextError::from) + } + /// Calculate the hash fn hash(value: &[u8]) -> Vec { sha2::Sha256::digest(value).to_vec() @@ -203,160 +516,130 @@ pub trait IbcCommonContext: IbcStorageContext { Self::hash(&hash_input).into() } - /// Decode ClientState from Any - fn decode_client_state( + /// Get the packet commitment + fn packet_commitment( &self, - client_state: Any, - ) -> Result, ContextError> { - #[cfg(any(feature = "ibc-mocks-abcipp", feature = "ibc-mocks"))] - if let Ok(cs) = MockClientState::try_from(client_state.clone()) { - return Ok(cs.into_box()); + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + ) -> Result { + let key = storage::commitment_key(port_id, channel_id, sequence); + match self.read_bytes(&key)? { + Some(value) => Ok(value.into()), + None => { + Err(PacketError::PacketCommitmentNotFound { sequence }.into()) + } } + } - if let Ok(cs) = TmClientState::try_from(client_state) { - return Ok(cs.into_box()); - } + /// Store the packet commitment + fn store_packet_commitment( + &mut self, + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + commitment: PacketCommitment, + ) -> Result<()> { + let key = storage::commitment_key(port_id, channel_id, sequence); + let bytes = commitment.into_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) + } - Err(ContextError::ClientError(ClientError::ClientSpecific { - description: "Unknown client state".to_string(), - })) + /// Delete the packet commitment + fn delete_packet_commitment( + &mut self, + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + ) -> Result<()> { + let key = storage::commitment_key(port_id, channel_id, sequence); + self.delete(&key).map_err(ContextError::from) } - /// Decode ConsensusState from Any - fn decode_consensus_state( + /// Get the packet receipt + fn packet_receipt( &self, - consensus_state: Any, - ) -> Result, ContextError> { - #[cfg(any(feature = "ibc-mocks-abcipp", feature = "ibc-mocks"))] - if let Ok(cs) = MockConsensusState::try_from(consensus_state.clone()) { - return Ok(cs.into_box()); - } - - if let Ok(cs) = TmConsensusState::try_from(consensus_state) { - return Ok(cs.into_box()); + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + ) -> Result { + let key = storage::receipt_key(port_id, channel_id, sequence); + match self.read_bytes(&key)? { + Some(_) => Ok(Receipt::Ok), + None => Err(PacketError::PacketReceiptNotFound { sequence }.into()), } - - Err(ContextError::ClientError(ClientError::ClientSpecific { - description: "Unknown consensus state".to_string(), - })) } - /// Read a counter - fn read_counter(&self, key: &Key) -> Result { - match self.read(key) { - Ok(Some(value)) => { - let value: [u8; 8] = value.try_into().map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "The counter value wasn't u64: Key {}", - key - ), - }) - })?; - Ok(u64::from_be_bytes(value)) - } - Ok(None) => unreachable!("the counter should be initialized"), - Err(_) => Err(ContextError::ClientError(ClientError::Other { - description: format!("Reading the counter failed: Key {}", key), - })), - } + /// Store the packet receipt + fn store_packet_receipt( + &mut self, + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + ) -> Result<()> { + let key = storage::receipt_key(port_id, channel_id, sequence); + // the value is the same as ibc-go + let bytes = [1_u8].to_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) } - /// Read a sequence - fn read_sequence(&self, key: &Key) -> Result { - match self.read(key) { - Ok(Some(value)) => { - let value: [u8; 8] = value.try_into().map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "The counter value wasn't u64: Key {}", - key - ), - }) - })?; - Ok(u64::from_be_bytes(value).into()) - } - // when the sequence has never been used, returns the initial value - Ok(None) => Ok(1.into()), - Err(_) => { - let sequence = storage::port_channel_sequence_id(key) - .expect("The key should have sequence") - .2; - Err(ContextError::ChannelError(ChannelError::Other { - description: format!( - "Reading the next sequence send failed: Sequence {}", - sequence - ), - })) + /// Get the packet acknowledgement + fn packet_ack( + &self, + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + ) -> Result { + let key = storage::ack_key(port_id, channel_id, sequence); + match self.read_bytes(&key)? { + Some(value) => Ok(value.into()), + None => { + Err(PacketError::PacketAcknowledgementNotFound { sequence } + .into()) } } } - /// Write the packet commitment - fn store_packet_commitment( + /// Store the packet acknowledgement + fn store_packet_ack( &mut self, - path: &CommitmentPath, - commitment: PacketCommitment, - ) -> Result<(), ContextError> { - let path = Path::Commitment(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - let bytes = commitment.into_vec(); - self.write(&key, bytes).map_err(|_| { - ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Writing the packet commitment failed: Key {}", - key - ), - }, - )) - }) + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + ack_commitment: AcknowledgementCommitment, + ) -> Result<()> { + let key = storage::ack_key(port_id, channel_id, sequence); + let bytes = ack_commitment.into_vec(); + self.write_bytes(&key, bytes).map_err(ContextError::from) } - /// Write the NextSequenceSend - fn store_next_sequence_send( + /// Delete the packet acknowledgement + fn delete_packet_ack( &mut self, - path: &SeqSendPath, - seq: Sequence, - ) -> Result<(), ContextError> { - let path = Path::SeqSend(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - self.store_sequence(&key, seq) + port_id: &PortId, + channel_id: &ChannelId, + sequence: Sequence, + ) -> Result<()> { + let key = storage::ack_key(port_id, channel_id, sequence); + self.delete(&key).map_err(ContextError::from) } - /// Increment and write the counter - fn increase_counter(&mut self, key: &Key) -> Result<(), ContextError> { - let count = self.read_counter(key)?; - self.write(key, (count + 1).to_be_bytes().to_vec()) - .map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Writing the counter failed: Key {}", - key - ), - }) - }) + /// Read a counter + fn read_counter(&self, key: &Key) -> Result { + match self.read::(key)? { + Some(counter) => Ok(counter), + None => unreachable!("the counter should be initialized"), + } } - /// Write the sequence - fn store_sequence( - &mut self, - key: &Key, - sequence: Sequence, - ) -> Result<(), ContextError> { - self.write(key, u64::from(sequence).to_be_bytes().to_vec()) - .map_err(|_| { - ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Writing the counter failed: Key {}", - key - ), - }, - )) - }) + /// Increment the counter + fn increment_counter(&mut self, key: &Key) -> Result<()> { + let count = self.read_counter(key)?; + let count = + u64::checked_add(count, 1).ok_or_else(|| ClientError::Other { + description: format!("The counter overflow: Key {key}"), + })?; + self.write(key, count).map_err(ContextError::from) } /// Write the IBC denom. The given address could be a non-Namada token. @@ -365,84 +648,32 @@ pub trait IbcCommonContext: IbcStorageContext { addr: impl AsRef, trace_hash: impl AsRef, denom: impl AsRef, - ) -> Result<(), ContextError> { + ) -> Result<()> { let key = storage::ibc_denom_key(addr, trace_hash.as_ref()); - let has_key = self.has_key(&key).map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "Reading the IBC denom failed: Key {}", - key, - ), - }) + let has_key = self.has_key(&key).map_err(|_| ChannelError::Other { + description: format!("Reading the IBC denom failed: Key {key}"), })?; if !has_key { - let bytes = denom.as_ref().serialize_to_vec(); - self.write(&key, bytes).map_err(|_| { - ContextError::ChannelError(ChannelError::Other { + self.write(&key, denom.as_ref()).map_err(|_| { + ChannelError::Other { description: format!( - "Writing the denom failed: Key {}", - key + "Writing the denom failed: Key {key}", ), - }) + } })?; } Ok(()) } +} - /// Read the token denom - fn read_token_denom( - &self, - token: &Address, - ) -> Result, ContextError> { - let key = token::denom_key(token); - let bytes = self.read(&key).map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "Reading the token denom failed: Key {}", - key - ), - }) - })?; - bytes - .map(|b| token::Denomination::try_from_slice(&b)) - .transpose() - .map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "Decoding the token denom failed: Token {}", - token - ), - }) - }) - } - - /// Write the IBC denom - fn store_token_denom( - &mut self, - token: &Address, - ) -> Result<(), ContextError> { - let key = token::denom_key(token); - let has_key = self.has_key(&key).map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "Reading the token denom failed: Key {}", - key - ), - }) - })?; - if !has_key { - // IBC denomination should be zero for U256 - let denom = token::Denomination::from(0); - let bytes = denom.serialize_to_vec(); - self.write(&key, bytes).map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "Writing the token denom failed: Key {}", - key - ), - }) - })?; +/// Convert `storage_api::Error` into `ContextError`. +/// It always returns `ClientError::Other` though the storage error could happen +/// in any storage access. +impl From for ContextError { + fn from(error: storage_api::Error) -> Self { + ClientError::Other { + description: format!("Storage error: {error}"), } - Ok(()) + .into() } } diff --git a/core/src/ledger/ibc/context/execution.rs b/core/src/ledger/ibc/context/execution.rs index 0160cb1d29..893cd67702 100644 --- a/core/src/ledger/ibc/context/execution.rs +++ b/core/src/ledger/ibc/context/execution.rs @@ -1,83 +1,74 @@ //! ExecutionContext implementation for IBC -use borsh::BorshDeserialize; -use borsh_ext::BorshSerializeExt; - -use super::super::{IbcActions, IbcCommonContext}; +use super::client::{AnyClientState, AnyConsensusState}; +use super::common::IbcCommonContext; +use super::IbcContext; use crate::ibc::core::events::IbcEvent; -use crate::ibc::core::ics02_client::client_state::ClientState; -use crate::ibc::core::ics02_client::consensus_state::ConsensusState; -use crate::ibc::core::ics02_client::error::ClientError; +use crate::ibc::core::ics02_client::ClientExecutionContext; use crate::ibc::core::ics03_connection::connection::ConnectionEnd; -use crate::ibc::core::ics03_connection::error::ConnectionError; use crate::ibc::core::ics04_channel::channel::ChannelEnd; use crate::ibc::core::ics04_channel::commitment::{ AcknowledgementCommitment, PacketCommitment, }; -use crate::ibc::core::ics04_channel::error::{ChannelError, PacketError}; use crate::ibc::core::ics04_channel::packet::{Receipt, Sequence}; use crate::ibc::core::ics24_host::identifier::{ClientId, ConnectionId}; use crate::ibc::core::ics24_host::path::{ AckPath, ChannelEndPath, ClientConnectionPath, ClientConsensusStatePath, - ClientStatePath, CommitmentPath, ConnectionPath, Path, ReceiptPath, - SeqAckPath, SeqRecvPath, SeqSendPath, + ClientStatePath, CommitmentPath, ConnectionPath, ReceiptPath, SeqAckPath, + SeqRecvPath, SeqSendPath, }; use crate::ibc::core::timestamp::Timestamp; -use crate::ibc::core::{ContextError, ExecutionContext, ValidationContext}; +use crate::ibc::core::{ContextError, ExecutionContext}; use crate::ibc::Height; -use crate::ibc_proto::protobuf::Protobuf; use crate::ledger::ibc::storage; -use crate::tendermint_proto::Protobuf as TmProtobuf; -impl ExecutionContext for IbcActions<'_, C> +impl ClientExecutionContext for IbcContext where C: IbcCommonContext, { + type AnyClientState = AnyClientState; + type AnyConsensusState = AnyConsensusState; + type V = Self; + fn store_client_state( &mut self, client_state_path: ClientStatePath, - client_state: Box, + client_state: Self::AnyClientState, ) -> Result<(), ContextError> { - let path = Path::ClientState(client_state_path); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - let bytes = client_state.encode_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Writing the client state failed: Key {}", - key - ), - }) - }) + self.inner + .borrow_mut() + .store_client_state(&client_state_path.0, client_state) } fn store_consensus_state( &mut self, consensus_state_path: ClientConsensusStatePath, - consensus_state: Box, + consensus_state: Self::AnyConsensusState, ) -> Result<(), ContextError> { - let path = Path::ClientConsensusState(consensus_state_path); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - let bytes = consensus_state.encode_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Writing the consensus state failed: Key {}", - key - ), - }) - }) + let client_id = consensus_state_path.client_id; + let height = Height::new( + consensus_state_path.epoch, + consensus_state_path.height, + )?; + self.inner.borrow_mut().store_consensus_state( + &client_id, + height, + consensus_state, + ) } - fn increase_client_counter(&mut self) { - let key = storage::client_counter_key(); - let count = self.client_counter().expect("read failed"); - self.ctx + fn delete_consensus_state( + &mut self, + consensus_state_path: ClientConsensusStatePath, + ) -> Result<(), ContextError> { + let client_id = consensus_state_path.client_id; + let height = Height::new( + consensus_state_path.epoch, + consensus_state_path.height, + )?; + self.inner .borrow_mut() - .write(&key, (count + 1).to_be_bytes().to_vec()) - .expect("write failed"); + .delete_consensus_state(&client_id, height) } fn store_update_time( @@ -86,30 +77,9 @@ where _height: Height, timestamp: Timestamp, ) -> Result<(), ContextError> { - let key = storage::client_update_timestamp_key(&client_id); - match timestamp.into_tm_time() { - Some(time) => self - .ctx - .borrow_mut() - .write( - &key, - time.encode_vec().expect("encoding shouldn't fail"), - ) - .map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Writing the consensus state failed: Key {}", - key - ), - }) - }), - None => Err(ContextError::ClientError(ClientError::Other { - description: format!( - "The client timestamp is invalid: ID {}", - client_id - ), - })), - } + self.inner + .borrow_mut() + .store_update_time(&client_id, timestamp) } fn store_update_height( @@ -118,16 +88,39 @@ where _height: Height, host_height: Height, ) -> Result<(), ContextError> { - let key = storage::client_update_height_key(&client_id); - let bytes = host_height.encode_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Writing the consensus state failed: Key {}", - key - ), - }) - }) + self.inner + .borrow_mut() + .store_update_height(&client_id, host_height) + } + + fn delete_update_time( + &mut self, + client_id: ClientId, + _height: Height, + ) -> Result<(), ContextError> { + self.inner.borrow_mut().delete_update_time(&client_id) + } + + fn delete_update_height( + &mut self, + client_id: ClientId, + _height: Height, + ) -> Result<(), ContextError> { + self.inner.borrow_mut().delete_update_height(&client_id) + } +} + +impl ExecutionContext for IbcContext +where + C: IbcCommonContext, +{ + fn get_client_execution_context(&mut self) -> &mut Self::E { + self + } + + fn increase_client_counter(&mut self) -> Result<(), ContextError> { + let key = storage::client_counter_key(); + self.inner.borrow_mut().increment_counter(&key) } fn store_connection( @@ -135,18 +128,9 @@ where connection_path: &ConnectionPath, connection_end: ConnectionEnd, ) -> Result<(), ContextError> { - let path = Path::Connection(connection_path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - let bytes = connection_end.encode_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::ConnectionError(ConnectionError::Other { - description: format!( - "Writing the connection end failed: Key {}", - key - ), - }) - }) + self.inner + .borrow_mut() + .store_connection(&connection_path.0, connection_end) } fn store_connection_to_client( @@ -154,49 +138,14 @@ where client_connection_path: &ClientConnectionPath, conn_id: ConnectionId, ) -> Result<(), ContextError> { - let path = Path::ClientConnection(client_connection_path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - let list = match self.ctx.borrow().read(&key) { - Ok(Some(value)) => { - let list = String::try_from_slice(&value).map_err(|e| { - ContextError::ConnectionError(ConnectionError::Other { - description: format!( - "Decoding the connection list failed: Key {}, \ - error {}", - key, e - ), - }) - })?; - format!("{},{}", list, conn_id) - } - Ok(None) => conn_id.to_string(), - Err(_) => { - Err(ContextError::ConnectionError(ConnectionError::Other { - description: format!( - "Reading the connection list of failed: Key {}", - key, - ), - }))? - } - }; - let bytes = list.serialize_to_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::ConnectionError(ConnectionError::Other { - description: format!( - "Writing the list of connection IDs failed: Key {}", - key - ), - }) - }) + self.inner + .borrow_mut() + .append_connection(&client_connection_path.0, conn_id) } - fn increase_connection_counter(&mut self) { + fn increase_connection_counter(&mut self) -> Result<(), ContextError> { let key = storage::connection_counter_key(); - self.ctx - .borrow_mut() - .increase_counter(&key) - .expect("Error cannot be returned"); + self.inner.borrow_mut().increment_counter(&key) } fn store_packet_commitment( @@ -204,28 +153,23 @@ where path: &CommitmentPath, commitment: PacketCommitment, ) -> Result<(), ContextError> { - self.ctx - .borrow_mut() - .store_packet_commitment(path, commitment) + self.inner.borrow_mut().store_packet_commitment( + &path.port_id, + &path.channel_id, + path.sequence, + commitment, + ) } fn delete_packet_commitment( &mut self, path: &CommitmentPath, ) -> Result<(), ContextError> { - let path = Path::Commitment(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - self.ctx.borrow_mut().delete(&key).map_err(|_| { - ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Deleting the packet commitment failed: Key {}", - key - ), - }, - )) - }) + self.inner.borrow_mut().delete_packet_commitment( + &path.port_id, + &path.channel_id, + path.sequence, + ) } fn store_packet_receipt( @@ -233,21 +177,11 @@ where path: &ReceiptPath, _receipt: Receipt, ) -> Result<(), ContextError> { - let path = Path::Receipt(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - // the value is the same as ibc-go - let bytes = [1_u8].to_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Writing the receipt failed: Key {}", - key - ), - }, - )) - }) + self.inner.borrow_mut().store_packet_receipt( + &path.port_id, + &path.channel_id, + path.sequence, + ) } fn store_packet_acknowledgement( @@ -255,39 +189,23 @@ where path: &AckPath, ack_commitment: AcknowledgementCommitment, ) -> Result<(), ContextError> { - let path = Path::Ack(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - let bytes = ack_commitment.into_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Writing the packet ack failed: Key {}", - key - ), - }, - )) - }) + self.inner.borrow_mut().store_packet_ack( + &path.port_id, + &path.channel_id, + path.sequence, + ack_commitment, + ) } fn delete_packet_acknowledgement( &mut self, path: &AckPath, ) -> Result<(), ContextError> { - let path = Path::Ack(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - self.ctx.borrow_mut().delete(&key).map_err(|_| { - ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Deleting the packet ack failed: Key {}", - key - ), - }, - )) - }) + self.inner.borrow_mut().delete_packet_ack( + &path.port_id, + &path.channel_id, + path.sequence, + ) } fn store_channel( @@ -295,18 +213,9 @@ where path: &ChannelEndPath, channel_end: ChannelEnd, ) -> Result<(), ContextError> { - let path = Path::ChannelEnd(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - let bytes = channel_end.encode_vec(); - self.ctx.borrow_mut().write(&key, bytes).map_err(|_| { - ContextError::ChannelError(ChannelError::Other { - description: format!( - "Writing the channel end failed: Key {}", - key - ), - }) - }) + self.inner + .borrow_mut() + .store_channel(&path.0, &path.1, channel_end) } fn store_next_sequence_send( @@ -314,7 +223,9 @@ where path: &SeqSendPath, seq: Sequence, ) -> Result<(), ContextError> { - self.ctx.borrow_mut().store_next_sequence_send(path, seq) + self.inner + .borrow_mut() + .store_next_sequence_send(&path.0, &path.1, seq) } fn store_next_sequence_recv( @@ -322,10 +233,9 @@ where path: &SeqRecvPath, seq: Sequence, ) -> Result<(), ContextError> { - let path = Path::SeqRecv(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - self.ctx.borrow_mut().store_sequence(&key, seq) + self.inner + .borrow_mut() + .store_next_sequence_recv(&path.0, &path.1, seq) } fn store_next_sequence_ack( @@ -333,29 +243,26 @@ where path: &SeqAckPath, seq: Sequence, ) -> Result<(), ContextError> { - let path = Path::SeqAck(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - self.ctx.borrow_mut().store_sequence(&key, seq) + self.inner + .borrow_mut() + .store_next_sequence_ack(&path.0, &path.1, seq) } - fn increase_channel_counter(&mut self) { + fn increase_channel_counter(&mut self) -> Result<(), ContextError> { let key = storage::channel_counter_key(); - self.ctx - .borrow_mut() - .increase_counter(&key) - .expect("Error cannot be returned"); + self.inner.borrow_mut().increment_counter(&key) } - fn emit_ibc_event(&mut self, event: IbcEvent) { + fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), ContextError> { let event = event.try_into().expect("The event should be converted"); - self.ctx + self.inner .borrow_mut() .emit_ibc_event(event) - .expect("Emitting an event shouldn't fail"); + .map_err(ContextError::from) } - fn log_message(&mut self, message: String) { - self.ctx.borrow_mut().log_string(message) + fn log_message(&mut self, message: String) -> Result<(), ContextError> { + self.inner.borrow().log_string(message); + Ok(()) } } diff --git a/core/src/ledger/ibc/context/mod.rs b/core/src/ledger/ibc/context/mod.rs index ef2311979a..b57819eec1 100644 --- a/core/src/ledger/ibc/context/mod.rs +++ b/core/src/ledger/ibc/context/mod.rs @@ -1,8 +1,68 @@ //! IBC Contexts +pub mod client; pub mod common; pub mod execution; pub mod router; pub mod storage; +pub mod token_transfer; pub mod transfer_mod; pub mod validation; + +use std::cell::RefCell; +use std::fmt::Debug; +use std::rc::Rc; +use std::time::Duration; + +use crate::ibc::core::ics23_commitment::specs::ProofSpecs; +use crate::ibc::core::ics24_host::identifier::ChainId as IbcChainId; + +/// IBC context to handle IBC-related data +#[derive(Debug)] +pub struct IbcContext +where + C: common::IbcCommonContext, +{ + /// Context + pub inner: Rc>, + /// Validation parameters for IBC VP + pub validation_params: ValidationParams, +} + +impl IbcContext +where + C: common::IbcCommonContext, +{ + /// Make new IBC context + pub fn new(inner: Rc>) -> Self { + Self { + inner, + validation_params: ValidationParams::default(), + } + } +} + +#[derive(Debug)] +/// Parameters for validation +pub struct ValidationParams { + /// Chain ID + pub chain_id: IbcChainId, + /// IBC proof specs + pub proof_specs: ProofSpecs, + /// Unbonding period + pub unbonding_period: Duration, + /// Upgrade path + pub upgrade_path: Vec, +} + +impl Default for ValidationParams { + fn default() -> Self { + Self { + chain_id: IbcChainId::new("non-init-chain", 0) + .expect("Convert the default chain ID shouldn't fail"), + proof_specs: ProofSpecs::default(), + unbonding_period: Duration::default(), + upgrade_path: Vec::default(), + } + } +} diff --git a/core/src/ledger/ibc/context/router.rs b/core/src/ledger/ibc/context/router.rs index dfa0d9be82..daba314a5d 100644 --- a/core/src/ledger/ibc/context/router.rs +++ b/core/src/ledger/ibc/context/router.rs @@ -1,15 +1,40 @@ //! Functions to handle IBC modules +use std::collections::HashMap; use std::rc::Rc; -use super::super::{IbcActions, IbcCommonContext}; +use super::super::ModuleWrapper; use crate::ibc::core::ics24_host::identifier::PortId; use crate::ibc::core::router::{Module, ModuleId, Router}; -impl Router for IbcActions<'_, C> -where - C: IbcCommonContext, -{ +/// IBC router +#[derive(Debug, Default)] +pub struct IbcRouter<'a> { + modules: HashMap>, + ports: HashMap, +} + +impl<'a> IbcRouter<'a> { + /// Make new Router + pub fn new() -> Self { + Self { + modules: HashMap::new(), + ports: HashMap::new(), + } + } + + /// Add TokenTransfer route + pub fn add_transfer_module( + &mut self, + module_id: ModuleId, + module: impl ModuleWrapper + 'a, + ) { + self.modules.insert(module_id.clone(), Rc::new(module)); + self.ports.insert(PortId::transfer(), module_id); + } +} + +impl<'a> Router for IbcRouter<'a> { fn get_route(&self, module_id: &ModuleId) -> Option<&dyn Module> { self.modules.get(module_id).map(|b| b.as_module()) } @@ -24,11 +49,7 @@ where .map(|b| b.as_module_mut()) } - fn has_route(&self, module_id: &ModuleId) -> bool { - self.modules.contains_key(module_id) - } - - fn lookup_module_by_port(&self, port_id: &PortId) -> Option { + fn lookup_module(&self, port_id: &PortId) -> Option { self.ports.get(port_id).cloned() } } diff --git a/core/src/ledger/ibc/context/storage.rs b/core/src/ledger/ibc/context/storage.rs index ef24cd94f2..facbb2a5c2 100644 --- a/core/src/ledger/ibc/context/storage.rs +++ b/core/src/ledger/ibc/context/storage.rs @@ -1,65 +1,22 @@ //! IBC storage context -use std::fmt::Debug; - pub use ics23::ProofSpec; -use super::super::Error; -use crate::ledger::storage_api; +use crate::ledger::storage_api::{Error, StorageRead, StorageWrite}; use crate::types::address::Address; use crate::types::ibc::{IbcEvent, IbcShieldedTransfer}; -use crate::types::storage::{BlockHeight, Header, Key}; use crate::types::token::DenominatedAmount; -// This is needed to use `ibc::Handler::Error` with `IbcActions` in -// `tx_prelude/src/ibc.rs` -impl From for storage_api::Error { - fn from(err: Error) -> Self { - storage_api::Error::new(err) - } -} - /// IBC context trait to be implemented in integration that can read and write -pub trait IbcStorageContext { - /// IBC storage error - type Error: From + Debug; - /// Storage read prefix iterator - type PrefixIter<'iter> - where - Self: 'iter; - - /// Read IBC-related data - fn read(&self, key: &Key) -> Result>, Self::Error>; - - /// Check if the given key is present - fn has_key(&self, key: &Key) -> Result; - - /// Read IBC-related data with a prefix - fn iter_prefix<'iter>( - &'iter self, - prefix: &Key, - ) -> Result, Self::Error>; - - /// next key value pair - fn iter_next<'iter>( - &'iter self, - iter: &mut Self::PrefixIter<'iter>, - ) -> Result)>, Self::Error>; - - /// Write IBC-related data - fn write(&mut self, key: &Key, value: Vec) -> Result<(), Self::Error>; - - /// Delete IBC-related data - fn delete(&mut self, key: &Key) -> Result<(), Self::Error>; - +pub trait IbcStorageContext: StorageRead + StorageWrite { /// Emit an IBC event - fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), Self::Error>; + fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), Error>; /// Get IBC events fn get_ibc_events( &self, event_type: impl AsRef, - ) -> Result, Self::Error>; + ) -> Result, Error>; /// Transfer token fn transfer_token( @@ -68,13 +25,13 @@ pub trait IbcStorageContext { dest: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error>; + ) -> Result<(), Error>; /// Handle masp tx fn handle_masp_tx( &mut self, shielded: &IbcShieldedTransfer, - ) -> Result<(), Self::Error>; + ) -> Result<(), Error>; /// Mint token fn mint_token( @@ -82,7 +39,7 @@ pub trait IbcStorageContext { target: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error>; + ) -> Result<(), Error>; /// Burn token fn burn_token( @@ -90,16 +47,7 @@ pub trait IbcStorageContext { target: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error>; - - /// Get the current height of this chain - fn get_height(&self) -> Result; - - /// Get the block header of this chain - fn get_header( - &self, - height: BlockHeight, - ) -> Result, Self::Error>; + ) -> Result<(), Error>; /// Logging fn log_string(&self, message: String); diff --git a/core/src/ledger/ibc/context/token_transfer.rs b/core/src/ledger/ibc/context/token_transfer.rs new file mode 100644 index 0000000000..4c41b8c956 --- /dev/null +++ b/core/src/ledger/ibc/context/token_transfer.rs @@ -0,0 +1,179 @@ +//! IBC token transfer context + +use std::cell::RefCell; +use std::rc::Rc; + +use super::common::IbcCommonContext; +use crate::ibc::applications::transfer::coin::PrefixedCoin; +use crate::ibc::applications::transfer::context::{ + TokenTransferExecutionContext, TokenTransferValidationContext, +}; +use crate::ibc::applications::transfer::denom::PrefixedDenom; +use crate::ibc::applications::transfer::error::TokenTransferError; +use crate::ibc::core::ics04_channel::error::ChannelError; +use crate::ibc::core::ics24_host::identifier::{ChannelId, PortId}; +use crate::ibc::core::ContextError; +use crate::ledger::ibc::storage; +use crate::ledger::storage_api::token::read_denom; +use crate::types::address::{Address, InternalAddress}; +use crate::types::token; +use crate::types::uint::Uint; + +/// Token transfer context to handle tokens +#[derive(Debug)] +pub struct TokenTransferContext +where + C: IbcCommonContext, +{ + inner: Rc>, +} + +impl TokenTransferContext +where + C: IbcCommonContext, +{ + /// Make new token transfer context + pub fn new(inner: Rc>) -> Self { + Self { inner } + } + + /// Get the token address and the amount from PrefixedCoin. If the base + /// denom is not an address, it returns `IbcToken` + fn get_token_amount( + &self, + coin: &PrefixedCoin, + ) -> Result<(Address, token::DenominatedAmount), TokenTransferError> { + let token = match Address::decode(coin.denom.base_denom.as_str()) { + Ok(token_addr) if coin.denom.trace_path.is_empty() => token_addr, + _ => storage::ibc_token(coin.denom.to_string()), + }; + + // Convert IBC amount to Namada amount for the token + let denom = read_denom(&*self.inner.borrow(), &token) + .map_err(ContextError::from)? + .unwrap_or(token::Denomination(0)); + let uint_amount = Uint(primitive_types::U256::from(coin.amount).0); + let amount = + token::Amount::from_uint(uint_amount, denom).map_err(|e| { + TokenTransferError::ContextError( + ChannelError::Other { + description: format!( + "The IBC amount is invalid: Coin {coin}, Error {e}", + ), + } + .into(), + ) + })?; + let amount = token::DenominatedAmount { amount, denom }; + + Ok((token, amount)) + } +} + +impl TokenTransferValidationContext for TokenTransferContext +where + C: IbcCommonContext, +{ + type AccountId = Address; + + fn get_port(&self) -> Result { + Ok(PortId::transfer()) + } + + fn get_escrow_account( + &self, + _port_id: &PortId, + _channel_id: &ChannelId, + ) -> Result { + Ok(Address::Internal(InternalAddress::Ibc)) + } + + fn can_send_coins(&self) -> Result<(), TokenTransferError> { + Ok(()) + } + + fn can_receive_coins(&self) -> Result<(), TokenTransferError> { + Ok(()) + } + + fn send_coins_validate( + &self, + _from: &Self::AccountId, + _to: &Self::AccountId, + _coin: &PrefixedCoin, + ) -> Result<(), TokenTransferError> { + // validated by IBC token VP + Ok(()) + } + + fn mint_coins_validate( + &self, + _account: &Self::AccountId, + _coin: &PrefixedCoin, + ) -> Result<(), TokenTransferError> { + // validated by IBC token VP + Ok(()) + } + + fn burn_coins_validate( + &self, + _account: &Self::AccountId, + _coin: &PrefixedCoin, + ) -> Result<(), TokenTransferError> { + // validated by IBC token VP + Ok(()) + } + + fn denom_hash_string(&self, denom: &PrefixedDenom) -> Option { + Some(storage::calc_hash(denom.to_string())) + } +} + +impl TokenTransferExecutionContext for TokenTransferContext +where + C: IbcCommonContext, +{ + fn send_coins_execute( + &mut self, + from: &Self::AccountId, + to: &Self::AccountId, + coin: &PrefixedCoin, + ) -> Result<(), TokenTransferError> { + // Assumes that the coin denom is prefixed with "port-id/channel-id" or + // has no prefix + let (ibc_token, amount) = self.get_token_amount(coin)?; + + self.inner + .borrow_mut() + .transfer_token(from, to, &ibc_token, amount) + .map_err(|e| ContextError::from(e).into()) + } + + fn mint_coins_execute( + &mut self, + account: &Self::AccountId, + coin: &PrefixedCoin, + ) -> Result<(), TokenTransferError> { + // The trace path of the denom is already updated if receiving the token + let (ibc_token, amount) = self.get_token_amount(coin)?; + + self.inner + .borrow_mut() + .mint_token(account, &ibc_token, amount) + .map_err(|e| ContextError::from(e).into()) + } + + fn burn_coins_execute( + &mut self, + account: &Self::AccountId, + coin: &PrefixedCoin, + ) -> Result<(), TokenTransferError> { + let (ibc_token, amount) = self.get_token_amount(coin)?; + + // The burn is "unminting" from the minted balance + self.inner + .borrow_mut() + .burn_token(account, &ibc_token, amount) + .map_err(|e| ContextError::from(e).into()) + } +} diff --git a/core/src/ledger/ibc/context/transfer_mod.rs b/core/src/ledger/ibc/context/transfer_mod.rs index 28a24f72e0..b3951e24de 100644 --- a/core/src/ledger/ibc/context/transfer_mod.rs +++ b/core/src/ledger/ibc/context/transfer_mod.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use std::rc::Rc; use super::common::IbcCommonContext; -use crate::ibc::applications::transfer::coin::PrefixedCoin; +use super::token_transfer::TokenTransferContext; use crate::ibc::applications::transfer::context::{ on_acknowledgement_packet_execute, on_acknowledgement_packet_validate, on_chan_close_confirm_execute, on_chan_close_confirm_validate, @@ -15,41 +15,20 @@ use crate::ibc::applications::transfer::context::{ on_chan_open_init_execute, on_chan_open_init_validate, on_chan_open_try_execute, on_chan_open_try_validate, on_recv_packet_execute, on_timeout_packet_execute, - on_timeout_packet_validate, TokenTransferExecutionContext, - TokenTransferValidationContext, + on_timeout_packet_validate, }; -use crate::ibc::applications::transfer::denom::PrefixedDenom; use crate::ibc::applications::transfer::error::TokenTransferError; use crate::ibc::applications::transfer::MODULE_ID_STR; -use crate::ibc::core::events::IbcEvent; -use crate::ibc::core::ics02_client::client_state::ClientState; -use crate::ibc::core::ics02_client::consensus_state::ConsensusState; -use crate::ibc::core::ics03_connection::connection::ConnectionEnd; -use crate::ibc::core::ics04_channel::channel::{ - ChannelEnd, Counterparty, Order, -}; -use crate::ibc::core::ics04_channel::commitment::PacketCommitment; -use crate::ibc::core::ics04_channel::context::{ - SendPacketExecutionContext, SendPacketValidationContext, -}; +use crate::ibc::core::ics04_channel::acknowledgement::Acknowledgement; +use crate::ibc::core::ics04_channel::channel::{Counterparty, Order}; use crate::ibc::core::ics04_channel::error::{ChannelError, PacketError}; -use crate::ibc::core::ics04_channel::packet::{ - Acknowledgement, Packet, Sequence, -}; +use crate::ibc::core::ics04_channel::packet::Packet; use crate::ibc::core::ics04_channel::Version; use crate::ibc::core::ics24_host::identifier::{ - ChannelId, ClientId, ConnectionId, PortId, -}; -use crate::ibc::core::ics24_host::path::{ - ChannelEndPath, ClientConsensusStatePath, CommitmentPath, SeqSendPath, + ChannelId, ConnectionId, PortId, }; use crate::ibc::core::router::{Module, ModuleExtras, ModuleId}; -use crate::ibc::core::ContextError; use crate::ibc::Signer; -use crate::ledger::ibc::storage; -use crate::types::address::{Address, InternalAddress}; -use crate::types::token; -use crate::types::uint::Uint; /// IBC module wrapper for getting the reference of the module pub trait ModuleWrapper: Module { @@ -67,7 +46,7 @@ where C: IbcCommonContext, { /// IBC actions - pub ctx: Rc>, + pub ctx: TokenTransferContext, } impl TransferModule @@ -76,47 +55,15 @@ where { /// Make a new module pub fn new(ctx: Rc>) -> Self { - Self { ctx } + Self { + ctx: TokenTransferContext::new(ctx), + } } /// Get the module ID pub fn module_id(&self) -> ModuleId { ModuleId::new(MODULE_ID_STR.to_string()) } - - /// Get the token address and the amount from PrefixedCoin. If the base - /// denom is not an address, it returns `IbcToken` - fn get_token_amount( - &self, - coin: &PrefixedCoin, - ) -> Result<(Address, token::DenominatedAmount), TokenTransferError> { - let token = match Address::decode(coin.denom.base_denom.as_str()) { - Ok(token_addr) if coin.denom.trace_path.is_empty() => token_addr, - _ => storage::ibc_token(coin.denom.to_string()), - }; - - // Convert IBC amount to Namada amount for the token - let denom = self - .ctx - .borrow() - .read_token_denom(&token)? - .unwrap_or(token::Denomination(0)); - let uint_amount = Uint(primitive_types::U256::from(coin.amount).0); - let amount = - token::Amount::from_uint(uint_amount, denom).map_err(|e| { - TokenTransferError::ContextError(ContextError::ChannelError( - ChannelError::Other { - description: format!( - "The IBC amount is invalid: Coin {}, Error {}", - coin, e - ), - }, - )) - })?; - let amount = token::DenominatedAmount { amount, denom }; - - Ok((token, amount)) - } } impl ModuleWrapper for TransferModule @@ -147,7 +94,7 @@ where version: &Version, ) -> Result { on_chan_open_init_validate( - self, + &self.ctx, order, connection_hops, port_id, @@ -170,7 +117,7 @@ where version: &Version, ) -> Result<(ModuleExtras, Version), ChannelError> { on_chan_open_init_execute( - self, + &mut self.ctx, order, connection_hops, port_id, @@ -192,7 +139,7 @@ where counterparty_version: &Version, ) -> Result { on_chan_open_try_validate( - self, + &self.ctx, order, connection_hops, port_id, @@ -215,7 +162,7 @@ where counterparty_version: &Version, ) -> Result<(ModuleExtras, Version), ChannelError> { on_chan_open_try_execute( - self, + &mut self.ctx, order, connection_hops, port_id, @@ -233,7 +180,7 @@ where counterparty_version: &Version, ) -> Result<(), ChannelError> { on_chan_open_ack_validate( - self, + &self.ctx, port_id, channel_id, counterparty_version, @@ -248,7 +195,7 @@ where counterparty_version: &Version, ) -> Result { on_chan_open_ack_execute( - self, + &mut self.ctx, port_id, channel_id, counterparty_version, @@ -261,7 +208,7 @@ where port_id: &PortId, channel_id: &ChannelId, ) -> Result<(), ChannelError> { - on_chan_open_confirm_validate(self, port_id, channel_id) + on_chan_open_confirm_validate(&self.ctx, port_id, channel_id) .map_err(into_channel_error) } @@ -270,7 +217,7 @@ where port_id: &PortId, channel_id: &ChannelId, ) -> Result { - on_chan_open_confirm_execute(self, port_id, channel_id) + on_chan_open_confirm_execute(&mut self.ctx, port_id, channel_id) .map_err(into_channel_error) } @@ -279,7 +226,7 @@ where port_id: &PortId, channel_id: &ChannelId, ) -> Result<(), ChannelError> { - on_chan_close_init_validate(self, port_id, channel_id) + on_chan_close_init_validate(&self.ctx, port_id, channel_id) .map_err(into_channel_error) } @@ -288,7 +235,7 @@ where port_id: &PortId, channel_id: &ChannelId, ) -> Result { - on_chan_close_init_execute(self, port_id, channel_id) + on_chan_close_init_execute(&mut self.ctx, port_id, channel_id) .map_err(into_channel_error) } @@ -297,7 +244,7 @@ where port_id: &PortId, channel_id: &ChannelId, ) -> Result<(), ChannelError> { - on_chan_close_confirm_validate(self, port_id, channel_id) + on_chan_close_confirm_validate(&self.ctx, port_id, channel_id) .map_err(into_channel_error) } @@ -306,7 +253,7 @@ where port_id: &PortId, channel_id: &ChannelId, ) -> Result { - on_chan_close_confirm_execute(self, port_id, channel_id) + on_chan_close_confirm_execute(&mut self.ctx, port_id, channel_id) .map_err(into_channel_error) } @@ -315,7 +262,7 @@ where packet: &Packet, _relayer: &Signer, ) -> (ModuleExtras, Acknowledgement) { - on_recv_packet_execute(self, packet) + on_recv_packet_execute(&mut self.ctx, packet) } fn on_acknowledgement_packet_validate( @@ -325,7 +272,7 @@ where relayer: &Signer, ) -> Result<(), PacketError> { on_acknowledgement_packet_validate( - self, + &self.ctx, packet, acknowledgement, relayer, @@ -340,7 +287,7 @@ where relayer: &Signer, ) -> (ModuleExtras, Result<(), PacketError>) { let (extras, result) = on_acknowledgement_packet_execute( - self, + &mut self.ctx, packet, acknowledgement, relayer, @@ -353,7 +300,7 @@ where packet: &Packet, relayer: &Signer, ) -> Result<(), PacketError> { - on_timeout_packet_validate(self, packet, relayer) + on_timeout_packet_validate(&self.ctx, packet, relayer) .map_err(into_packet_error) } @@ -362,223 +309,12 @@ where packet: &Packet, relayer: &Signer, ) -> (ModuleExtras, Result<(), PacketError>) { - let (extras, result) = on_timeout_packet_execute(self, packet, relayer); + let (extras, result) = + on_timeout_packet_execute(&mut self.ctx, packet, relayer); (extras, result.map_err(into_packet_error)) } } -impl SendPacketValidationContext for TransferModule -where - C: IbcCommonContext, -{ - fn channel_end( - &self, - channel_end_path: &ChannelEndPath, - ) -> Result { - self.ctx.borrow().channel_end(channel_end_path) - } - - fn connection_end( - &self, - connection_id: &ConnectionId, - ) -> Result { - self.ctx.borrow().connection_end(connection_id) - } - - fn client_state( - &self, - client_id: &ClientId, - ) -> Result, ContextError> { - self.ctx.borrow().client_state(client_id) - } - - fn client_consensus_state( - &self, - client_cons_state_path: &ClientConsensusStatePath, - ) -> Result, ContextError> { - self.ctx.borrow().consensus_state(client_cons_state_path) - } - - fn get_next_sequence_send( - &self, - seq_send_path: &SeqSendPath, - ) -> Result { - self.ctx.borrow().get_next_sequence_send(seq_send_path) - } -} - -impl TokenTransferValidationContext for TransferModule -where - C: IbcCommonContext, -{ - type AccountId = Address; - - fn get_port(&self) -> Result { - Ok(PortId::transfer()) - } - - fn get_escrow_account( - &self, - _port_id: &PortId, - _channel_id: &ChannelId, - ) -> Result { - Ok(Address::Internal(InternalAddress::Ibc)) - } - - fn can_send_coins(&self) -> Result<(), TokenTransferError> { - Ok(()) - } - - fn can_receive_coins(&self) -> Result<(), TokenTransferError> { - Ok(()) - } - - fn send_coins_validate( - &self, - _from: &Self::AccountId, - _to: &Self::AccountId, - _coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { - // validated by IBC token VP - Ok(()) - } - - fn mint_coins_validate( - &self, - _account: &Self::AccountId, - _coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { - // validated by IBC token VP - Ok(()) - } - - fn burn_coins_validate( - &self, - _account: &Self::AccountId, - _coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { - // validated by IBC token VP - Ok(()) - } - - fn denom_hash_string(&self, denom: &PrefixedDenom) -> Option { - Some(storage::calc_hash(denom.to_string())) - } -} - -impl TokenTransferExecutionContext for TransferModule -where - C: IbcCommonContext, -{ - fn send_coins_execute( - &mut self, - from: &Self::AccountId, - to: &Self::AccountId, - coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { - // Assumes that the coin denom is prefixed with "port-id/channel-id" or - // has no prefix - let (ibc_token, amount) = self.get_token_amount(coin)?; - - self.ctx - .borrow_mut() - .transfer_token(from, to, &ibc_token, amount) - .map_err(|_| { - TokenTransferError::ContextError(ContextError::ChannelError( - ChannelError::Other { - description: format!( - "Sending a coin failed: from {}, to {}, amount {}", - from, to, amount, - ), - }, - )) - }) - } - - fn mint_coins_execute( - &mut self, - account: &Self::AccountId, - coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { - // The trace path of the denom is already updated if receiving the token - let (ibc_token, amount) = self.get_token_amount(coin)?; - - self.ctx - .borrow_mut() - .mint_token(account, &ibc_token, amount) - .map_err(|_| { - TokenTransferError::ContextError(ContextError::ChannelError( - ChannelError::Other { - description: format!( - "Minting a coin failed: account {}, amount {}", - account, amount, - ), - }, - )) - }) - } - - fn burn_coins_execute( - &mut self, - account: &Self::AccountId, - coin: &PrefixedCoin, - ) -> Result<(), TokenTransferError> { - let (ibc_token, amount) = self.get_token_amount(coin)?; - - // The burn is "unminting" from the minted balance - self.ctx - .borrow_mut() - .burn_token(account, &ibc_token, amount) - .map_err(|_| { - TokenTransferError::ContextError(ContextError::ChannelError( - ChannelError::Other { - description: format!( - "Burning a coin failed: account {}, amount {}", - account, amount, - ), - }, - )) - }) - } -} - -impl SendPacketExecutionContext for TransferModule -where - C: IbcCommonContext, -{ - fn store_next_sequence_send( - &mut self, - seq_send_path: &SeqSendPath, - seq: Sequence, - ) -> Result<(), ContextError> { - self.ctx - .borrow_mut() - .store_next_sequence_send(seq_send_path, seq) - } - - fn store_packet_commitment( - &mut self, - commitment_path: &CommitmentPath, - commitment: PacketCommitment, - ) -> Result<(), ContextError> { - self.ctx - .borrow_mut() - .store_packet_commitment(commitment_path, commitment) - } - - fn emit_ibc_event(&mut self, event: IbcEvent) { - let event = event.try_into().expect("IBC event conversion failed"); - self.ctx - .borrow_mut() - .emit_ibc_event(event) - .expect("Emitting an IBC event failed") - } - - fn log_message(&mut self, message: String) { - self.ctx.borrow_mut().log_string(message) - } -} - fn into_channel_error(error: TokenTransferError) -> ChannelError { ChannelError::AppModule { description: error.to_string(), @@ -595,7 +331,8 @@ fn into_packet_error(error: TokenTransferError) -> PacketError { #[cfg(any(test, feature = "testing"))] pub mod testing { use super::*; - use crate::ibc::applications::transfer::acknowledgement::TokenTransferAcknowledgement; + use crate::ibc::applications::transfer::ack_success_b64; + use crate::ibc::core::ics04_channel::acknowledgement::AcknowledgementStatus; /// Dummy IBC module for token transfer #[derive(Debug)] @@ -742,8 +479,10 @@ pub mod testing { _packet: &Packet, _relayer: &Signer, ) -> (ModuleExtras, Acknowledgement) { - let transfer_ack = TokenTransferAcknowledgement::success(); - (ModuleExtras::empty(), transfer_ack.into()) + ( + ModuleExtras::empty(), + AcknowledgementStatus::success(ack_success_b64()).into(), + ) } fn on_acknowledgement_packet_validate( diff --git a/core/src/ledger/ibc/context/validation.rs b/core/src/ledger/ibc/context/validation.rs index 9ad3dd2654..ffc0585c8c 100644 --- a/core/src/ledger/ibc/context/validation.rs +++ b/core/src/ledger/ibc/context/validation.rs @@ -1,18 +1,18 @@ //! ValidationContext implementation for IBC -use prost::Message; - -use super::super::{IbcActions, IbcCommonContext}; -use crate::ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState; -use crate::ibc::core::ics02_client::client_state::ClientState; -use crate::ibc::core::ics02_client::consensus_state::ConsensusState; +use super::client::{AnyClientState, AnyConsensusState}; +use super::common::IbcCommonContext; +use super::IbcContext; +use crate::ibc::clients::ics07_tendermint::{ + CommonContext as TmCommonContext, ValidationContext as TmValidationContext, +}; use crate::ibc::core::ics02_client::error::ClientError; +use crate::ibc::core::ics02_client::ClientValidationContext; use crate::ibc::core::ics03_connection::connection::ConnectionEnd; use crate::ibc::core::ics04_channel::channel::ChannelEnd; use crate::ibc::core::ics04_channel::commitment::{ AcknowledgementCommitment, PacketCommitment, }; -use crate::ibc::core::ics04_channel::error::{ChannelError, PacketError}; use crate::ibc::core::ics04_channel::packet::{Receipt, Sequence}; use crate::ibc::core::ics23_commitment::commitment::CommitmentPrefix; use crate::ibc::core::ics23_commitment::specs::ProofSpecs; @@ -20,7 +20,7 @@ use crate::ibc::core::ics24_host::identifier::{ ChainId, ClientId, ConnectionId, }; use crate::ibc::core::ics24_host::path::{ - AckPath, ChannelEndPath, ClientConsensusStatePath, CommitmentPath, Path, + AckPath, ChannelEndPath, ClientConsensusStatePath, CommitmentPath, ReceiptPath, SeqAckPath, SeqRecvPath, SeqSendPath, }; use crate::ibc::core::timestamp::Timestamp; @@ -30,226 +30,175 @@ use crate::ibc::hosts::tendermint::ValidateSelfClientContext; use crate::ibc::mock::client_state::MockClientState; use crate::ibc::{Height, Signer}; use crate::ibc_proto::google::protobuf::Any; -use crate::ibc_proto::protobuf::Protobuf; use crate::ledger::ibc::storage; -use crate::ledger::parameters::storage::get_max_expected_time_per_block_key; -use crate::tendermint::Time as TmTime; -use crate::tendermint_proto::Protobuf as TmProtobuf; -use crate::types::storage::{BlockHeight, Key}; -use crate::types::time::DurationSecs; const COMMITMENT_PREFIX: &[u8] = b"ibc"; -impl ValidationContext for IbcActions<'_, C> +impl TmCommonContext for IbcContext where C: IbcCommonContext, { - fn client_state( - &self, - client_id: &ClientId, - ) -> Result, ContextError> { - self.ctx.borrow().client_state(client_id) + type AnyConsensusState = AnyConsensusState; + type ConversionError = ClientError; + + fn host_timestamp(&self) -> Result { + ValidationContext::host_timestamp(self) } - fn decode_client_state( - &self, - client_state: Any, - ) -> Result, ContextError> { - self.ctx.borrow().decode_client_state(client_state) + fn host_height(&self) -> Result { + ValidationContext::host_height(self) } fn consensus_state( &self, client_cons_state_path: &ClientConsensusStatePath, - ) -> Result, ContextError> { - self.ctx.borrow().consensus_state(client_cons_state_path) + ) -> Result { + ValidationContext::consensus_state(self, client_cons_state_path) + } + + fn consensus_state_heights( + &self, + client_id: &ClientId, + ) -> Result, ContextError> { + self.inner.borrow().consensus_state_heights(client_id) } +} +impl TmValidationContext for IbcContext +where + C: IbcCommonContext, +{ fn next_consensus_state( &self, client_id: &ClientId, height: &Height, - ) -> Result>, ContextError> { - let prefix = storage::consensus_state_prefix(client_id); - // for iterator - let ctx = self.ctx.borrow(); - let mut iter = ctx.iter_prefix(&prefix).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Reading the consensus state failed: ID {}, height {}", - client_id, height, - ), - }) - })?; - let mut lowest_height_value = None; - while let Some((key, value)) = - ctx.iter_next(&mut iter).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Iterating consensus states failed: ID {}, height {}", - client_id, height, - ), - }) - })? - { - let key = Key::parse(key).expect("the key should be parsable"); - let consensus_height = storage::consensus_height(&key) - .expect("the key should have a height"); - if consensus_height > *height { - lowest_height_value = match lowest_height_value { - Some((lowest, _)) if consensus_height < lowest => { - Some((consensus_height, value)) - } - Some(_) => continue, - None => Some((consensus_height, value)), - }; - } - } - match lowest_height_value { - Some((_, value)) => { - let any = Any::decode(&value[..]).map_err(|e| { - ContextError::ClientError(ClientError::Decode(e)) - })?; - let cs = self.ctx.borrow().decode_consensus_state(any)?; - Ok(Some(cs)) - } - None => Ok(None), - } + ) -> Result, ContextError> { + self.inner.borrow().next_consensus_state(client_id, height) } fn prev_consensus_state( &self, client_id: &ClientId, height: &Height, - ) -> Result>, ContextError> { - let prefix = storage::consensus_state_prefix(client_id); - // for iterator - let ctx = self.ctx.borrow(); - let mut iter = ctx.iter_prefix(&prefix).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Reading the consensus state failed: ID {}, height {}", - client_id, height, - ), - }) - })?; - let mut highest_height_value = None; - while let Some((key, value)) = - ctx.iter_next(&mut iter).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Iterating consensus states failed: ID {}, height {}", - client_id, height, - ), - }) - })? - { - let key = Key::parse(key).expect("the key should be parsable"); - let consensus_height = storage::consensus_height(&key) - .expect("the key should have the height"); - if consensus_height < *height { - highest_height_value = match highest_height_value { - Some((highest, _)) if consensus_height > highest => { - Some((consensus_height, value)) - } - Some(_) => continue, - None => Some((consensus_height, value)), - }; - } - } - match highest_height_value { - Some((_, value)) => { - let any = Any::decode(&value[..]).map_err(|e| { - ContextError::ClientError(ClientError::Decode(e)) - })?; - let cs = self.ctx.borrow().decode_consensus_state(any)?; - Ok(Some(cs)) - } - None => Ok(None), - } + ) -> Result, ContextError> { + self.inner.borrow().prev_consensus_state(client_id, height) + } +} + +#[cfg(feature = "ibc-mocks")] +use crate::ibc::mock::client_state::MockClientContext; +#[cfg(feature = "ibc-mocks")] +impl MockClientContext for IbcContext +where + C: IbcCommonContext, +{ + type AnyConsensusState = AnyConsensusState; + type ConversionError = ClientError; + + fn consensus_state( + &self, + client_cons_state_path: &ClientConsensusStatePath, + ) -> Result { + ValidationContext::consensus_state(self, client_cons_state_path) + } + + fn host_timestamp(&self) -> Result { + ValidationContext::host_timestamp(self) } fn host_height(&self) -> Result { - let height = self.ctx.borrow().get_height().map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: "Getting the host height failed".to_string(), - }) - })?; + ValidationContext::host_height(self) + } +} + +impl ClientValidationContext for IbcContext +where + C: IbcCommonContext, +{ + fn client_update_time( + &self, + client_id: &ClientId, + _height: &Height, + ) -> Result { + self.inner.borrow().client_update_time(client_id) + } + + fn client_update_height( + &self, + client_id: &ClientId, + _height: &Height, + ) -> Result { + self.inner.borrow().client_update_height(client_id) + } +} + +impl ValidationContext for IbcContext +where + C: IbcCommonContext, +{ + type AnyClientState = AnyClientState; + type AnyConsensusState = AnyConsensusState; + type E = Self; + type V = Self; + + fn get_client_validation_context(&self) -> &Self::V { + self + } + + fn client_state( + &self, + client_id: &ClientId, + ) -> Result { + self.inner.borrow().client_state(client_id) + } + + fn decode_client_state( + &self, + client_state: Any, + ) -> Result { + client_state.try_into().map_err(ContextError::from) + } + + fn consensus_state( + &self, + client_cons_state_path: &ClientConsensusStatePath, + ) -> Result { + let height = Height::new( + client_cons_state_path.epoch, + client_cons_state_path.height, + )?; + self.inner + .borrow() + .consensus_state(&client_cons_state_path.client_id, height) + } + + fn host_height(&self) -> Result { + let height = self.inner.borrow().get_block_height()?; // the revision number is always 0 Height::new(0, height.0).map_err(ContextError::ClientError) } fn host_timestamp(&self) -> Result { - let height = self.host_height()?; - let height = BlockHeight(height.revision_height()); - let header = self - .ctx - .borrow() - .get_header(height) - .map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: "Getting the host header failed".to_string(), - }) - })? - .ok_or_else(|| { - ContextError::ClientError(ClientError::Other { - description: "No host header".to_string(), - }) - })?; - let time = TmTime::try_from(header.time).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: "Converting to Tenderming time failed".to_string(), - }) - })?; - Ok(time.into()) + self.inner.borrow().host_timestamp() } fn host_consensus_state( &self, height: &Height, - ) -> Result, ContextError> { - let height = BlockHeight(height.revision_height()); - let header = self - .ctx - .borrow() - .get_header(height) - .map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Getting the header on this chain failed: Height {}", - height - ), - }) - })? - .ok_or_else(|| { - ContextError::ClientError(ClientError::Other { - description: "No host header".to_string(), - }) - })?; - let commitment_root = header.hash.to_vec().into(); - let time = header - .time - .try_into() - .expect("The time should be converted"); - let next_validators_hash = header - .next_validators_hash - .try_into() - .expect("The hash should be converted"); - let consensus_state = - TmConsensusState::new(commitment_root, time, next_validators_hash); - Ok(consensus_state.into_box()) + ) -> Result { + self.inner.borrow().host_consensus_state(height) } fn client_counter(&self) -> Result { let key = storage::client_counter_key(); - self.ctx.borrow().read_counter(&key) + self.inner.borrow().read_counter(&key) } fn connection_end( &self, connection_id: &ConnectionId, ) -> Result { - self.ctx.borrow().connection_end(connection_id) + self.inner.borrow().connection_end(connection_id) } fn validate_self_client( @@ -278,215 +227,80 @@ where fn connection_counter(&self) -> Result { let key = storage::connection_counter_key(); - self.ctx.borrow().read_counter(&key) + self.inner.borrow().read_counter(&key) } fn channel_end( &self, - channel_end_path: &ChannelEndPath, + path: &ChannelEndPath, ) -> Result { - self.ctx.borrow().channel_end(channel_end_path) + self.inner.borrow().channel_end(&path.0, &path.1) } fn get_next_sequence_send( &self, path: &SeqSendPath, ) -> Result { - self.ctx.borrow().get_next_sequence_send(path) + self.inner.borrow().get_next_sequence_send(&path.0, &path.1) } fn get_next_sequence_recv( &self, path: &SeqRecvPath, ) -> Result { - let path = Path::SeqRecv(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - self.ctx.borrow().read_sequence(&key) + self.inner.borrow().get_next_sequence_recv(&path.0, &path.1) } fn get_next_sequence_ack( &self, path: &SeqAckPath, ) -> Result { - let path = Path::SeqAck(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - self.ctx.borrow().read_sequence(&key) + self.inner.borrow().get_next_sequence_ack(&path.0, &path.1) } fn get_packet_commitment( &self, path: &CommitmentPath, ) -> Result { - let path = Path::Commitment(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - match self.ctx.borrow().read(&key) { - Ok(Some(value)) => Ok(value.into()), - Ok(None) => { - let port_channel_sequence_id = - storage::port_channel_sequence_id(&key) - .expect("invalid key"); - Err(ContextError::PacketError( - PacketError::PacketCommitmentNotFound { - sequence: port_channel_sequence_id.2, - }, - )) - } - Err(_) => Err(ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Reading commitment failed: Key {}", - key, - ), - }, - ))), - } + self.inner.borrow().packet_commitment( + &path.port_id, + &path.channel_id, + path.sequence, + ) } fn get_packet_receipt( &self, path: &ReceiptPath, ) -> Result { - let path = Path::Receipt(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - match self.ctx.borrow().read(&key) { - Ok(Some(_)) => Ok(Receipt::Ok), - Ok(None) => { - let port_channel_sequence_id = - storage::port_channel_sequence_id(&key) - .expect("invalid key"); - Err(ContextError::PacketError( - PacketError::PacketReceiptNotFound { - sequence: port_channel_sequence_id.2, - }, - )) - } - Err(_) => Err(ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Reading the receipt failed: Key {}", - key, - ), - }, - ))), - } + self.inner.borrow().packet_receipt( + &path.port_id, + &path.channel_id, + path.sequence, + ) } fn get_packet_acknowledgement( &self, path: &AckPath, ) -> Result { - let path = Path::Ack(path.clone()); - let key = storage::ibc_key(path.to_string()) - .expect("Creating a key for the client state shouldn't fail"); - match self.ctx.borrow().read(&key) { - Ok(Some(value)) => Ok(value.into()), - Ok(None) => { - let port_channel_sequence_id = - storage::port_channel_sequence_id(&key) - .expect("invalid key"); - Err(ContextError::PacketError( - PacketError::PacketAcknowledgementNotFound { - sequence: port_channel_sequence_id.2, - }, - )) - } - Err(_) => Err(ContextError::PacketError(PacketError::Channel( - ChannelError::Other { - description: format!( - "Reading the ack commitment failed: Key {}", - key - ), - }, - ))), - } - } - - fn client_update_time( - &self, - client_id: &ClientId, - _height: &Height, - ) -> Result { - let key = storage::client_update_timestamp_key(client_id); - match self.ctx.borrow().read(&key) { - Ok(Some(value)) => { - let time = TmTime::decode_vec(&value).map_err(|_| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Decoding the client update time failed: ID {}", - client_id - ), - }) - })?; - Ok(time.into()) - } - Ok(None) => { - Err(ContextError::ClientError(ClientError::ClientSpecific { - description: format!( - "The client update time doesn't exist: ID {}", - client_id - ), - })) - } - Err(_) => Err(ContextError::ClientError(ClientError::Other { - description: format!( - "Reading the client update time failed: ID {}", - client_id, - ), - })), - } - } - - fn client_update_height( - &self, - client_id: &ClientId, - _height: &Height, - ) -> Result { - let key = storage::client_update_height_key(client_id); - match self.ctx.borrow().read(&key) { - Ok(Some(value)) => Height::decode_vec(&value).map_err(|e| { - ContextError::ClientError(ClientError::Other { - description: format!( - "Decoding the height failed: Key {}, error {}", - key, e - ), - }) - }), - Ok(None) => { - Err(ContextError::ClientError(ClientError::ClientSpecific { - description: format!( - "The client update height doesn't exist: ID {}", - client_id - ), - })) - } - Err(_) => Err(ContextError::ClientError(ClientError::Other { - description: format!( - "Reading the client update height failed: ID {}", - client_id, - ), - })), - } + self.inner.borrow().packet_ack( + &path.port_id, + &path.channel_id, + path.sequence, + ) } fn channel_counter(&self) -> Result { let key = storage::channel_counter_key(); - self.ctx.borrow().read_counter(&key) + self.inner.borrow().read_counter(&key) } fn max_expected_time_per_block(&self) -> core::time::Duration { - let key = get_max_expected_time_per_block_key(); - match self.ctx.borrow().read(&key) { - Ok(Some(value)) => { - crate::ledger::storage::types::decode::(value) - .expect("Decoding max_expected_time_per_block failed") - .into() - } - _ => unreachable!("The parameter should be initialized"), - } + self.inner + .borrow() + .max_expected_time_per_block() + .expect("Error cannot be returned") } fn validate_message_signer( @@ -498,7 +312,7 @@ where } } -impl ValidateSelfClientContext for IbcActions<'_, C> +impl ValidateSelfClientContext for IbcContext where C: IbcCommonContext, { @@ -508,9 +322,9 @@ where fn host_current_height(&self) -> Height { let height = self - .ctx + .inner .borrow() - .get_height() + .get_block_height() .expect("The height should exist"); Height::new(0, height.0).expect("The conversion shouldn't fail") } diff --git a/core/src/ledger/ibc/mod.rs b/core/src/ledger/ibc/mod.rs index c78afeabd6..cf0962cdbd 100644 --- a/core/src/ledger/ibc/mod.rs +++ b/core/src/ledger/ibc/mod.rs @@ -4,15 +4,17 @@ pub mod context; pub mod storage; use std::cell::RefCell; -use std::collections::HashMap; use std::fmt::Debug; use std::rc::Rc; use std::str::FromStr; -use std::time::Duration; pub use context::common::IbcCommonContext; +use context::router::IbcRouter; pub use context::storage::{IbcStorageContext, ProofSpec}; +pub use context::token_transfer::TokenTransferContext; pub use context::transfer_mod::{ModuleWrapper, TransferModule}; +use context::IbcContext; +pub use context::ValidationParams; use prost::Message; use thiserror::Error; @@ -23,15 +25,13 @@ use crate::ibc::applications::transfer::{ PrefixedDenom, TracePrefix, }; use crate::ibc::core::ics04_channel::msgs::PacketMsg; -use crate::ibc::core::ics23_commitment::specs::ProofSpecs; use crate::ibc::core::ics24_host::identifier::{ - ChainId as IbcChainId, ChannelId, PortId, + ChannelId, IdentifierError, PortId, }; -use crate::ibc::core::router::{Module, ModuleId, Router}; +use crate::ibc::core::router::ModuleId; use crate::ibc::core::{execute, validate, MsgEnvelope, RouterError}; use crate::ibc_proto::google::protobuf::Any; use crate::types::address::{masp, Address}; -use crate::types::chain::ChainId; use crate::types::ibc::{ get_shielded_transfer, is_ibc_denom, EVENT_TYPE_DENOM_TRACE, EVENT_TYPE_PACKET, @@ -58,7 +58,7 @@ pub enum Error { #[error("Denom error: {0}")] Denom(String), #[error("Invalid chain ID: {0}")] - ChainId(ChainId), + ChainId(IdentifierError), #[error("Handling MASP transaction error: {0}")] MaspTx(String), } @@ -69,10 +69,8 @@ pub struct IbcActions<'a, C> where C: IbcCommonContext, { - ctx: Rc>, - modules: HashMap>, - ports: HashMap, - validation_params: ValidationParams, + ctx: IbcContext, + router: IbcRouter<'a>, } impl<'a, C> IbcActions<'a, C> @@ -82,39 +80,23 @@ where /// Make new IBC actions pub fn new(ctx: Rc>) -> Self { Self { - ctx, - modules: HashMap::new(), - ports: HashMap::new(), - validation_params: ValidationParams::default(), + ctx: IbcContext::new(ctx), + router: IbcRouter::new(), } } - /// Set the validation parameters - pub fn set_validation_params(&mut self, params: ValidationParams) { - self.validation_params = params; - } - /// Add TokenTransfer route - pub fn add_transfer_route( + pub fn add_transfer_module( &mut self, module_id: ModuleId, module: impl ModuleWrapper + 'a, ) { - self.modules.insert(module_id.clone(), Rc::new(module)); - self.ports.insert(PortId::transfer(), module_id); - } - - fn get_route_by_port(&self, port_id: &PortId) -> Option<&dyn Module> { - self.lookup_module_by_port(port_id) - .and_then(|id| self.get_route(&id)) + self.router.add_transfer_module(module_id, module) } - fn get_route_mut_by_port( - &mut self, - port_id: &PortId, - ) -> Option<&mut dyn Module> { - self.lookup_module_by_port(port_id) - .and_then(|id| self.get_route_mut(&id)) + /// Set the validation parameters + pub fn set_validation_params(&mut self, params: ValidationParams) { + self.ctx.validation_params = params; } /// Execute according to the message in an IBC transaction or VP @@ -122,20 +104,20 @@ where let any_msg = Any::decode(tx_data).map_err(Error::DecodingData)?; match MsgTransfer::try_from(any_msg.clone()) { Ok(msg) => { - let port_id = msg.port_id_on_a.clone(); - match self.get_route_mut_by_port(&port_id) { - Some(_module) => { - let mut module = TransferModule::new(self.ctx.clone()); - send_transfer_execute(&mut module, msg) - .map_err(Error::TokenTransfer) - } - None => Err(Error::NoModule), - } + let mut token_transfer_ctx = + TokenTransferContext::new(self.ctx.inner.clone()); + send_transfer_execute( + &mut self.ctx, + &mut token_transfer_ctx, + msg, + ) + .map_err(Error::TokenTransfer) } Err(_) => { let envelope = MsgEnvelope::try_from(any_msg).map_err(Error::Execution)?; - execute(self, envelope.clone()).map_err(Error::Execution)?; + execute(&mut self.ctx, &mut self.router, envelope.clone()) + .map_err(Error::Execution)?; // For receiving the token to a shielded address self.handle_masp_tx(&envelope)?; // the current ibc-rs execution doesn't store the denom for the @@ -147,52 +129,40 @@ where /// Store the denom when transfer with MsgRecvPacket fn store_denom(&mut self, envelope: &MsgEnvelope) -> Result<(), Error> { - match envelope { - MsgEnvelope::Packet(PacketMsg::Recv(_)) => { - if let Some((trace_hash, ibc_denom, receiver)) = - self.get_minted_token_info()? - { - // If the denomination trace event has the trace hash and - // the IBC denom, a token has been minted. The raw IBC denom - // including the port ID, the channel ID and the base token - // is stored to be restored from the trace hash. The amount - // denomination is also set for the minting. + if let MsgEnvelope::Packet(PacketMsg::Recv(_)) = envelope { + if let Some((trace_hash, ibc_denom, receiver)) = + self.get_minted_token_info()? + { + // If the denomination trace event has the trace hash and + // the IBC denom, a token has been minted. The raw IBC denom + // including the port ID, the channel ID and the base token + // is stored to be restored from the trace hash. The amount + // denomination is also set for the minting. + self.ctx + .inner + .borrow_mut() + .store_ibc_denom(&receiver, &trace_hash, &ibc_denom) + .map_err(|e| { + Error::Denom(format!( + "Writing the IBC denom failed: {}", + e + )) + })?; + if let Some((_, base_token)) = is_ibc_denom(&ibc_denom) { self.ctx + .inner .borrow_mut() - .store_ibc_denom(&receiver, &trace_hash, &ibc_denom) + .store_ibc_denom(base_token, trace_hash, &ibc_denom) .map_err(|e| { Error::Denom(format!( "Writing the IBC denom failed: {}", e )) })?; - if let Some((_, base_token)) = is_ibc_denom(&ibc_denom) { - self.ctx - .borrow_mut() - .store_ibc_denom(base_token, trace_hash, &ibc_denom) - .map_err(|e| { - Error::Denom(format!( - "Writing the IBC denom failed: {}", - e - )) - })?; - } - let token = storage::ibc_token(ibc_denom); - self.ctx.borrow_mut().store_token_denom(&token).map_err( - |e| { - Error::Denom(format!( - "Writing the token denom failed: {}", - e - )) - }, - ) - } else { - Ok(()) } } - // other messages - _ => Ok(()), } + Ok(()) } /// Get the minted IBC denom, the trace hash, and the receiver from IBC @@ -202,6 +172,7 @@ where ) -> Result, Error> { let receive_event = self .ctx + .inner .borrow() .get_ibc_events(EVENT_TYPE_PACKET) .map_err(|_| { @@ -233,6 +204,7 @@ where }; let denom_event = self .ctx + .inner .borrow() .get_ibc_events(EVENT_TYPE_DENOM_TRACE) .map_err(|_| { @@ -251,20 +223,16 @@ where let any_msg = Any::decode(tx_data).map_err(Error::DecodingData)?; match MsgTransfer::try_from(any_msg.clone()) { Ok(msg) => { - let port_id = msg.port_id_on_a.clone(); - match self.get_route_by_port(&port_id) { - Some(_module) => { - let module = TransferModule::new(self.ctx.clone()); - send_transfer_validate(&module, msg) - .map_err(Error::TokenTransfer) - } - None => Err(Error::NoModule), - } + let token_transfer_ctx = + TokenTransferContext::new(self.ctx.inner.clone()); + send_transfer_validate(&self.ctx, &token_transfer_ctx, msg) + .map_err(Error::TokenTransfer) } Err(_) => { let envelope = MsgEnvelope::try_from(any_msg) .map_err(Error::Validation)?; - validate(self, envelope).map_err(Error::Validation) + validate(&self.ctx, &self.router, envelope) + .map_err(Error::Validation) } } } @@ -275,6 +243,7 @@ where MsgEnvelope::Packet(PacketMsg::Recv(_)) => { let event = self .ctx + .inner .borrow() .get_ibc_events(EVENT_TYPE_PACKET) .map_err(|_| { @@ -294,6 +263,7 @@ where }; if let Some(shielded_transfer) = shielded_transfer { self.ctx + .inner .borrow_mut() .handle_masp_tx(&shielded_transfer) .map_err(|_| { @@ -304,19 +274,6 @@ where } } -#[derive(Debug, Default)] -/// Parameters for validation -pub struct ValidationParams { - /// Chain ID - pub chain_id: IbcChainId, - /// IBC proof specs - pub proof_specs: ProofSpecs, - /// Unbonding period - pub unbonding_period: Duration, - /// Upgrade path - pub upgrade_path: Vec, -} - /// Get the IbcToken from the source/destination ports and channels pub fn received_ibc_token( ibc_denom: &PrefixedDenom, diff --git a/core/src/ledger/storage/merkle_tree.rs b/core/src/ledger/storage/merkle_tree.rs index 961cbc3c35..fe804639ec 100644 --- a/core/src/ledger/storage/merkle_tree.rs +++ b/core/src/ledger/storage/merkle_tree.rs @@ -657,7 +657,7 @@ pub struct Proof { } #[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] -impl From for crate::tendermint::merkle::proof::Proof { +impl From for crate::tendermint::merkle::proof::ProofOps { fn from( Proof { key, @@ -667,7 +667,7 @@ impl From for crate::tendermint::merkle::proof::Proof { ) -> Self { use prost::Message; - use crate::tendermint::merkle::proof::{Proof, ProofOp}; + use crate::tendermint::merkle::proof::ProofOp; let mut data = vec![]; sub_proof @@ -690,7 +690,7 @@ impl From for crate::tendermint::merkle::proof::Proof { }; // Set ProofOps from leaf to root - Proof { + Self { ops: vec![sub_proof_op, base_proof_op], } } diff --git a/core/src/ledger/storage/mod.rs b/core/src/ledger/storage/mod.rs index b484246228..e6018d7f4b 100644 --- a/core/src/ledger/storage/mod.rs +++ b/core/src/ledger/storage/mod.rs @@ -39,7 +39,7 @@ use crate::ledger::storage::merkle_tree::{ Error as MerkleTreeError, MerkleRoot, }; #[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] -use crate::tendermint::merkle::proof::Proof; +use crate::tendermint::merkle::proof::ProofOps; use crate::types::address::{ masp, Address, EstablishedAddressGen, InternalAddress, }; @@ -889,7 +889,7 @@ where key: &Key, value: merkle_tree::StorageBytes, height: BlockHeight, - ) -> Result { + ) -> Result { use std::array; if height > self.get_last_block_height() { @@ -927,7 +927,7 @@ where &self, key: &Key, height: BlockHeight, - ) -> Result { + ) -> Result { if height > self.get_last_block_height() { Err(Error::Temporary { error: format!( diff --git a/core/src/ledger/storage_api/token.rs b/core/src/ledger/storage_api/token.rs index 5ea915d034..c372c0bfc1 100644 --- a/core/src/ledger/storage_api/token.rs +++ b/core/src/ledger/storage_api/token.rs @@ -55,7 +55,7 @@ where (token::denom_key(&token), true) } Address::Internal(InternalAddress::IbcToken(_)) => { - (token::denom_key(token), true) + return Ok(Some(0u8.into())); } token => (token::denom_key(token), false), }; diff --git a/core/src/proto/types.rs b/core/src/proto/types.rs index b1d2b40cb5..13173cb4df 100644 --- a/core/src/proto/types.rs +++ b/core/src/proto/types.rs @@ -29,7 +29,7 @@ use super::generated::types; use crate::ledger::gas::{GasMetering, VpGasMeter, VERIFY_TX_SIG_GAS_COST}; use crate::ledger::storage::{KeccakHasher, Sha256Hasher, StorageHasher}; #[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] -use crate::tendermint_proto::abci::ResponseDeliverTx; +use crate::tendermint_proto::v0_37::abci::ResponseDeliverTx; use crate::types::account::AccountPublicKeysMap; use crate::types::address::Address; use crate::types::chain::ChainId; @@ -1853,7 +1853,7 @@ impl From for ResponseDeliverTx { /// Annotate the Tx with meta-data based on its contents #[cfg(feature = "ferveo-tpke")] fn from(tx: Tx) -> ResponseDeliverTx { - use crate::tendermint_proto::abci::{Event, EventAttribute}; + use crate::tendermint_proto::v0_37::abci::{Event, EventAttribute}; // If data cannot be extracteed, then attach no events let tx_data = if let Some(data) = tx.data() { diff --git a/core/src/types/chain.rs b/core/src/types/chain.rs index 47f2af8146..26f82a5aa9 100644 --- a/core/src/types/chain.rs +++ b/core/src/types/chain.rs @@ -10,8 +10,9 @@ use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use thiserror::Error; -/// The length of chain ID string -pub const CHAIN_ID_LENGTH: usize = 30; +/// The length of the chain ID string. Tendermint's MAX_LENGTH is 50, and ibc-rs +/// would append a maximum of 21 characters. +pub const CHAIN_ID_LENGTH: usize = 29; /// The maximum length of chain ID prefix pub const CHAIN_ID_PREFIX_MAX_LEN: usize = 19; /// Separator between chain ID prefix and the generated hash @@ -177,7 +178,7 @@ impl ProposalBytes { } /// Release default chain ID. Must be [`CHAIN_ID_LENGTH`] long. -pub const DEFAULT_CHAIN_ID: &str = "namada-internal.00000000000000"; +pub const DEFAULT_CHAIN_ID: &str = "namada-internal.00000000000-0"; /// Chain ID #[derive( @@ -211,10 +212,10 @@ impl ChainId { let mut hasher = Sha256::new(); hasher.update(genesis_bytes); // less `1` for chain ID prefix separator char - let width = CHAIN_ID_LENGTH - 1 - prefix.len(); + let width = CHAIN_ID_LENGTH - 3 - prefix.len(); // lowercase hex of the first `width` chars of the hash let hash = format!("{:.width$x}", hasher.finalize(), width = width,); - let raw = format!("{}{}{}", prefix, CHAIN_ID_PREFIX_SEP, hash); + let raw = format!("{}{}{}-0", prefix, CHAIN_ID_PREFIX_SEP, hash); ChainId(raw) } @@ -230,10 +231,10 @@ impl ChainId { let mut hasher = Sha256::new(); hasher.update(genesis_bytes); // less `1` for chain ID prefix separator char - let width = CHAIN_ID_LENGTH - 1 - prefix.len(); + let width = CHAIN_ID_LENGTH - 3 - prefix.len(); // lowercase hex of the first `width` chars of the hash let expected_hash = - format!("{:.width$x}", hasher.finalize(), width = width,); + format!("{:.width$x}-0", hasher.finalize(), width = width,); if hash != expected_hash { errors.push(ChainIdValidationError::InvalidHash( expected_hash, diff --git a/core/src/types/hash.rs b/core/src/types/hash.rs index 9e25bfb832..9b69935add 100644 --- a/core/src/types/hash.rs +++ b/core/src/types/hash.rs @@ -140,13 +140,6 @@ impl Hash { } } -#[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] -impl From for crate::tendermint::abci::transaction::Hash { - fn from(hash: Hash) -> Self { - Self::new(hash.0) - } -} - #[cfg(any(feature = "tendermint", feature = "tendermint-abcipp"))] impl From for crate::tendermint::Hash { fn from(hash: Hash) -> Self { diff --git a/core/src/types/ibc.rs b/core/src/types/ibc.rs index a58d042eeb..e4b4fc4490 100644 --- a/core/src/types/ibc.rs +++ b/core/src/types/ibc.rs @@ -74,7 +74,7 @@ mod ibc_rs_conversion { use crate::ibc::core::events::{ Error as IbcEventError, IbcEvent as RawIbcEvent, }; - use crate::tendermint_proto::abci::Event as AbciEvent; + use crate::tendermint::abci::Event as AbciEvent; use crate::types::masp::PaymentAddress; #[allow(missing_docs)] diff --git a/ethereum_bridge/Cargo.toml b/ethereum_bridge/Cargo.toml index 08c5731e28..bd1b8908b6 100644 --- a/ethereum_bridge/Cargo.toml +++ b/ethereum_bridge/Cargo.toml @@ -40,9 +40,9 @@ itertools.workspace = true serde.workspace = true serde_json.workspace = true rand.workspace = true -tendermint = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", optional = true} -tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", default-features = false, features = ["trait-client"], optional = true} -tendermint-proto = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", optional = true} +tendermint = {workspace = true, optional = true} +tendermint-rpc = {workspace = true, optional = true} +tendermint-proto = {workspace = true, optional = true} tracing = "0.1.30" [dev-dependencies] diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 7162f92772..cfe7e6a8dc 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -101,7 +101,7 @@ serde.workspace = true serde_json.workspace = true sha2.workspace = true slip10_ed25519.workspace = true -tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", default-features = false, features = ["trait-client"], optional = true} +tendermint-rpc = {workspace = true, optional = true} thiserror.workspace = true tiny-bip39.workspace = true tiny-hderive.workspace = true diff --git a/sdk/src/events/mod.rs b/sdk/src/events/mod.rs index 141867c63d..0e83be3731 100644 --- a/sdk/src/events/mod.rs +++ b/sdk/src/events/mod.rs @@ -15,7 +15,7 @@ use serde_json::Value; // use crate::ledger::governance::utils::ProposalEvent; use crate::error::{EncodingError, Error, EventError}; -use crate::tendermint_proto::abci::EventAttribute; +use crate::tendermint_proto::v0_37::abci::EventAttribute; /// Indicates if an event is emitted do to /// an individual Tx or the nature of a finalized block @@ -172,7 +172,7 @@ impl From for Event { } /// Convert our custom event into the necessary tendermint proto type -impl From for crate::tendermint_proto::abci::Event { +impl From for crate::tendermint_proto::v0_37::abci::Event { fn from(event: Event) -> Self { Self { r#type: event.event_type.to_string(), diff --git a/sdk/src/queries/mod.rs b/sdk/src/queries/mod.rs index fdd5b042a8..af22898661 100644 --- a/sdk/src/queries/mod.rs +++ b/sdk/src/queries/mod.rs @@ -191,11 +191,11 @@ mod testing { }) } - async fn perform(&self, _request: R) -> Result + async fn perform(&self, _request: R) -> Result where R: tendermint_rpc::SimpleRequest, { - Response::from_string("TODO") + Ok(R::Response::from_string("TODO").unwrap().into()) } } } @@ -209,6 +209,7 @@ use tendermint_rpc::endpoint::{ use tendermint_rpc::query::Query; use tendermint_rpc::{Error as RpcError, Order}; +use crate::tendermint::abci::response::Info; use crate::tendermint::block::Height; /// A client with async request dispatcher method, which can be used to invoke @@ -243,7 +244,7 @@ pub trait Client { ) -> Result; /// `/abci_info`: get information about the ABCI application. - async fn abci_info(&self) -> Result { + async fn abci_info(&self) -> Result { Ok(self.perform(abci_info::Request).await?.response) } @@ -251,7 +252,7 @@ pub trait Client { /// from `CheckTx`. async fn broadcast_tx_sync( &self, - tx: crate::tendermint::abci::Transaction, + tx: impl Into>, ) -> Result { self.perform( @@ -320,7 +321,7 @@ pub trait Client { /// `/abci_query`: query the ABCI application async fn abci_query( &self, - path: Option, + path: Option, data: V, height: Option, prove: bool, @@ -423,14 +424,14 @@ pub trait Client { } /// Perform a request against the RPC endpoint - async fn perform(&self, request: R) -> Result + async fn perform(&self, request: R) -> Result where R: tendermint_rpc::SimpleRequest; } #[cfg_attr(feature = "async-send", async_trait::async_trait)] #[cfg_attr(not(feature = "async-send"), async_trait::async_trait(?Send))] -impl Client for C { +impl Client for C { type Error = Error; async fn request( @@ -463,14 +464,14 @@ impl Client for C { info: response.info, proof: response.proof, }), - Code::Err(code) => Err(Error::Query(response.info, code)), + Code::Err(code) => Err(Error::Query(response.info, code.into())), } } - async fn perform(&self, request: R) -> Result + async fn perform(&self, request: R) -> Result where R: tendermint_rpc::SimpleRequest, { - tendermint_rpc::Client::perform(self, request).await + tendermint_rpc::client::Client::perform(self, request).await } } diff --git a/sdk/src/queries/shell.rs b/sdk/src/queries/shell.rs index 1efba0083e..31d7a7c8e4 100644 --- a/sdk/src/queries/shell.rs +++ b/sdk/src/queries/shell.rs @@ -25,7 +25,7 @@ use crate::ibc::core::ics04_channel::packet::Sequence; use crate::ibc::core::ics24_host::identifier::{ChannelId, ClientId, PortId}; use crate::queries::types::{RequestCtx, RequestQuery}; use crate::queries::{require_latest_height, EncodedResponseQuery}; -use crate::tendermint::merkle::proof::Proof; +use crate::tendermint::merkle::proof::ProofOps; type Conversion = ( Address, @@ -313,7 +313,7 @@ where let proof = if request.prove { let mut ops = vec![]; for PrefixValue { key, value } in &data { - let mut proof: crate::tendermint::merkle::proof::Proof = ctx + let mut proof = ctx .wl_storage .storage .get_existence_proof(key, value, request.height) @@ -321,7 +321,7 @@ where ops.append(&mut proof.ops); } // ops is not empty in this case - let proof = Proof { ops }; + let proof = ProofOps { ops }; Some(proof) } else { None diff --git a/sdk/src/queries/types.rs b/sdk/src/queries/types.rs index 7283982099..e442c8d2e6 100644 --- a/sdk/src/queries/types.rs +++ b/sdk/src/queries/types.rs @@ -6,7 +6,7 @@ use namada_core::types::storage::BlockHeight; use thiserror::Error; use crate::events::log::EventLog; -use crate::tendermint::merkle::proof::Proof; +use crate::tendermint::merkle::proof::ProofOps; /// A request context provides read-only access to storage and WASM compilation /// caches to request handlers. #[derive(Debug, Clone)] @@ -113,7 +113,7 @@ pub struct ResponseQuery { /// Non-deterministic log of the request execution pub info: String, /// Optional proof - used for storage value reads which request `prove` - pub proof: Option, + pub proof: Option, } /// [`ResponseQuery`] with borsh-encoded `data` field @@ -127,12 +127,12 @@ impl RequestQuery { /// spec. A negative block height will cause an error. pub fn try_from_tm( storage: &WlStorage, - crate::tendermint_proto::abci::RequestQuery { + crate::tendermint_proto::v0_37::abci::RequestQuery { data, path, height, prove, - }: crate::tendermint_proto::abci::RequestQuery, + }: crate::tendermint_proto::v0_37::abci::RequestQuery, ) -> Result where D: DB + for<'iter> DBIter<'iter>, @@ -148,7 +148,7 @@ impl RequestQuery { })?), }; Ok(Self { - data, + data: data.to_vec(), path, height, prove, diff --git a/sdk/src/rpc.rs b/sdk/src/rpc.rs index a5c0793b36..69e08e7175 100644 --- a/sdk/src/rpc.rs +++ b/sdk/src/rpc.rs @@ -42,7 +42,7 @@ use crate::proto::Tx; use crate::queries::vp::pos::EnrichedBondsAndUnbondsDetails; use crate::queries::{Client, RPC}; use crate::tendermint::block::Height; -use crate::tendermint::merkle::proof::Proof; +use crate::tendermint::merkle::proof::ProofOps; use crate::tendermint_rpc::error::Error as TError; use crate::tendermint_rpc::query::Query; use crate::tendermint_rpc::Order; @@ -317,7 +317,7 @@ pub async fn query_storage_value_bytes( key: &storage::Key, height: Option, prove: bool, -) -> Result<(Option>, Option), error::Error> { +) -> Result<(Option>, Option), error::Error> { let data = None; let response = convert_response::( RPC.shell() @@ -590,10 +590,10 @@ pub async fn query_tx_response( events .iter() .find(|event| { - event.type_str == tx_query.event_type() + event.kind == tx_query.event_type() && event.attributes.iter().any(|tag| { - tag.key.as_ref() == "hash" - && tag.value.as_ref() == tx_query.tx_hash() + &tag.key == "hash" + && tag.value == tx_query.tx_hash() }) }) .cloned() diff --git a/sdk/src/tx.rs b/sdk/src/tx.rs index 2a7919895b..6ef6fc55f8 100644 --- a/sdk/src/tx.rs +++ b/sdk/src/tx.rs @@ -301,10 +301,7 @@ pub async fn broadcast_tx<'a>( // `tendermint-rs` for this, which is currently using a hard-coded 30s // timeout. let response = lift_rpc_error( - context - .client() - .broadcast_tx_sync(tx.to_bytes().into()) - .await, + context.client().broadcast_tx_sync(tx.to_bytes()).await, )?; if response.code == 0.into() { diff --git a/shared/Cargo.toml b/shared/Cargo.toml index ce39a22ef8..40872b3460 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -141,7 +141,7 @@ serde_json.workspace = true sha2.workspace = true slip10_ed25519.workspace = true tempfile = {version = "3.2.0", optional = true} -tendermint-rpc = {git = "https://github.com/heliaxdev/tendermint-rs.git", rev = "b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", default-features = false, features = ["trait-client"], optional = true} +tendermint-rpc = {workspace = true, optional = true} thiserror.workspace = true tiny-bip39.workspace = true tiny-hderive.workspace = true diff --git a/shared/src/ledger/mod.rs b/shared/src/ledger/mod.rs index 62e460f099..3c3122838b 100644 --- a/shared/src/ledger/mod.rs +++ b/shared/src/ledger/mod.rs @@ -264,11 +264,11 @@ mod test { }) } - async fn perform(&self, _request: R) -> Result + async fn perform(&self, _request: R) -> Result where R: tendermint_rpc::SimpleRequest, { - Response::from_string("TODO") + Ok(R::Response::from_string("TODO").unwrap().into()) } } diff --git a/shared/src/ledger/native_vp/ibc/context.rs b/shared/src/ledger/native_vp/ibc/context.rs index 7926f3d838..6104eaf1cb 100644 --- a/shared/src/ledger/native_vp/ibc/context.rs +++ b/shared/src/ledger/native_vp/ibc/context.rs @@ -4,25 +4,27 @@ use std::collections::{BTreeSet, HashMap, HashSet}; use borsh_ext::BorshSerializeExt; use masp_primitives::transaction::Transaction; -use namada_core::ledger::ibc::storage::is_ibc_key; use namada_core::ledger::ibc::{IbcCommonContext, IbcStorageContext}; -use namada_core::ledger::storage::write_log::StorageModification; -use namada_core::ledger::storage::{self as ledger_storage, StorageHasher}; -use namada_core::ledger::storage_api::StorageRead; -use namada_core::types::address::{self, Address, InternalAddress}; -use namada_core::types::ibc::{IbcEvent, IbcShieldedTransfer}; -use namada_core::types::storage::{ - BlockHeight, Epoch, Header, Key, KeySeg, TxIndex, + +use crate::ledger::ibc::storage::is_ibc_key; +use crate::ledger::native_vp::CtxPreStorageRead; +use crate::ledger::storage::write_log::StorageModification; +use crate::ledger::storage::{self as ledger_storage, StorageHasher}; +use crate::ledger::storage_api::{self, StorageRead, StorageWrite}; +use crate::types::address::{self, Address, InternalAddress}; +use crate::types::ibc::{IbcEvent, IbcShieldedTransfer}; +use crate::types::storage::{ + BlockHash, BlockHeight, Epoch, Header, Key, KeySeg, TxIndex, }; -use namada_core::types::token::{ +use crate::types::token::{ self, Amount, DenominatedAmount, Transfer, HEAD_TX_KEY, PIN_KEY_PREFIX, TX_KEY_PREFIX, }; - -use super::Error; -use crate::ledger::native_vp::CtxPreStorageRead; use crate::vm::WasmCacheAccess; +/// Result of a storage API call. +pub type Result = std::result::Result; + #[derive(Debug)] pub struct PseudoExecutionContext<'view, 'a, DB, H, CA> where @@ -61,17 +63,16 @@ where } } -impl<'view, 'a, DB, H, CA> IbcStorageContext +impl<'view, 'a, DB, H, CA> StorageRead for PseudoExecutionContext<'view, 'a, DB, H, CA> where DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, H: 'static + StorageHasher, CA: 'static + WasmCacheAccess, { - type Error = Error; type PrefixIter<'iter> = ledger_storage::PrefixIter<'iter, DB> where Self: 'iter; - fn read(&self, key: &Key) -> Result>, Self::Error> { + fn read_bytes(&self, key: &Key) -> Result>> { match self.store.get(key) { Some(StorageModification::Write { ref value }) => { Ok(Some(value.clone())) @@ -83,43 +84,94 @@ where Some(StorageModification::InitAccount { .. }) => { unreachable!("InitAccount shouldn't be inserted") } - None => self.ctx.read_bytes(key).map_err(Error::NativeVpError), + None => self.ctx.read_bytes(key), } } - fn has_key(&self, key: &Key) -> Result { - Ok(self.store.contains_key(key) - || self.ctx.has_key(key).map_err(Error::NativeVpError)?) + fn has_key(&self, key: &Key) -> Result { + Ok(self.store.contains_key(key) || self.ctx.has_key(key)?) } fn iter_prefix<'iter>( &'iter self, prefix: &Key, - ) -> Result, Self::Error> { + ) -> Result> { // NOTE: Read only the previous state since the updated state isn't // needed for the caller - self.ctx.iter_prefix(prefix).map_err(Error::NativeVpError) + self.ctx.iter_prefix(prefix) } fn iter_next<'iter>( &'iter self, iter: &mut Self::PrefixIter<'iter>, - ) -> Result)>, Self::Error> { - self.ctx.iter_next(iter).map_err(Error::NativeVpError) + ) -> Result)>> { + self.ctx.iter_next(iter) + } + + fn get_chain_id(&self) -> Result { + self.ctx.get_chain_id() + } + + fn get_block_height(&self) -> Result { + self.ctx.get_block_height() + } + + fn get_block_header(&self, height: BlockHeight) -> Result> { + self.ctx.get_block_header(height) + } + + fn get_block_hash(&self) -> Result { + self.ctx.get_block_hash() + } + + fn get_block_epoch(&self) -> Result { + self.ctx.get_block_epoch() + } + + fn get_tx_index(&self) -> Result { + self.ctx.get_tx_index() + } + + fn get_native_token(&self) -> Result
{ + self.ctx.get_native_token() } +} - fn write(&mut self, key: &Key, value: Vec) -> Result<(), Self::Error> { - self.store - .insert(key.clone(), StorageModification::Write { value }); +impl<'view, 'a, DB, H, CA> StorageWrite + for PseudoExecutionContext<'view, 'a, DB, H, CA> +where + DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, + H: 'static + StorageHasher, + CA: 'static + WasmCacheAccess, +{ + fn write_bytes( + &mut self, + key: &Key, + value: impl AsRef<[u8]>, + ) -> Result<()> { + self.store.insert( + key.clone(), + StorageModification::Write { + value: value.as_ref().to_vec(), + }, + ); Ok(()) } - fn delete(&mut self, key: &Key) -> Result<(), Self::Error> { + fn delete(&mut self, key: &Key) -> Result<()> { self.store.insert(key.clone(), StorageModification::Delete); Ok(()) } +} - fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<(), Self::Error> { +impl<'view, 'a, DB, H, CA> IbcStorageContext + for PseudoExecutionContext<'view, 'a, DB, H, CA> +where + DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, + H: 'static + StorageHasher, + CA: 'static + WasmCacheAccess, +{ + fn emit_ibc_event(&mut self, event: IbcEvent) -> Result<()> { self.event.insert(event); Ok(()) } @@ -127,7 +179,7 @@ where fn get_ibc_events( &self, event_type: impl AsRef, - ) -> Result, Self::Error> { + ) -> Result> { Ok(self .event .iter() @@ -142,28 +194,21 @@ where dest: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<()> { let src_key = token::balance_key(token, src); let dest_key = token::balance_key(token, dest); - let src_bal: Option = - self.ctx.read(&src_key).map_err(Error::NativeVpError)?; + let src_bal: Option = self.ctx.read(&src_key)?; let mut src_bal = src_bal.expect("The source has no balance"); src_bal.spend(&amount.amount); - let mut dest_bal: Amount = self - .ctx - .read(&dest_key) - .map_err(Error::NativeVpError)? - .unwrap_or_default(); + let mut dest_bal: Amount = + self.ctx.read(&dest_key)?.unwrap_or_default(); dest_bal.receive(&amount.amount); self.write(&src_key, src_bal.serialize_to_vec())?; self.write(&dest_key, dest_bal.serialize_to_vec()) } - fn handle_masp_tx( - &mut self, - shielded: &IbcShieldedTransfer, - ) -> Result<(), Self::Error> { + fn handle_masp_tx(&mut self, shielded: &IbcShieldedTransfer) -> Result<()> { let masp_addr = address::masp(); let head_tx_key = Key::from(masp_addr.to_db_key()) .push(&HEAD_TX_KEY.to_owned()) @@ -177,9 +222,9 @@ where // so that clients do not have to separately look these // up let record: (Epoch, BlockHeight, TxIndex, Transfer, Transaction) = ( - self.ctx.get_block_epoch().map_err(Error::NativeVpError)?, - self.ctx.get_block_height().map_err(Error::NativeVpError)?, - self.ctx.get_tx_index().map_err(Error::NativeVpError)?, + self.ctx.get_block_epoch()?, + self.ctx.get_block_height()?, + self.ctx.get_tx_index()?, shielded.transfer.clone(), shielded.masp_tx.clone(), ); @@ -200,21 +245,15 @@ where target: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<()> { let target_key = token::balance_key(token, target); - let mut target_bal: Amount = self - .ctx - .read(&target_key) - .map_err(Error::NativeVpError)? - .unwrap_or_default(); + let mut target_bal: Amount = + self.ctx.read(&target_key)?.unwrap_or_default(); target_bal.receive(&amount.amount); let minted_key = token::minted_balance_key(token); - let mut minted_bal: Amount = self - .ctx - .read(&minted_key) - .map_err(Error::NativeVpError)? - .unwrap_or_default(); + let mut minted_bal: Amount = + self.ctx.read(&minted_key)?.unwrap_or_default(); minted_bal.receive(&amount.amount); self.write(&target_key, target_bal.serialize_to_vec())?; @@ -232,44 +271,23 @@ where target: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<()> { let target_key = token::balance_key(token, target); - let mut target_bal: Amount = self - .ctx - .read(&target_key) - .map_err(Error::NativeVpError)? - .unwrap_or_default(); + let mut target_bal: Amount = + self.ctx.read(&target_key)?.unwrap_or_default(); target_bal.spend(&amount.amount); let minted_key = token::minted_balance_key(token); - let mut minted_bal: Amount = self - .ctx - .read(&minted_key) - .map_err(Error::NativeVpError)? - .unwrap_or_default(); + let mut minted_bal: Amount = + self.ctx.read(&minted_key)?.unwrap_or_default(); minted_bal.spend(&amount.amount); self.write(&target_key, target_bal.serialize_to_vec())?; self.write(&minted_key, minted_bal.serialize_to_vec()) } - /// Get the current height of this chain - fn get_height(&self) -> Result { - self.ctx.get_block_height().map_err(Error::NativeVpError) - } - - /// Get the block header of this chain - fn get_header( - &self, - height: BlockHeight, - ) -> Result, Self::Error> { - self.ctx - .get_block_header(height) - .map_err(Error::NativeVpError) - } - fn log_string(&self, message: String) { - tracing::debug!("{} in the pseudo execution for IBC VP", message); + tracing::debug!("{message} in the pseudo execution for IBC VP"); } } @@ -304,54 +322,101 @@ where } } -impl<'view, 'a, DB, H, CA> IbcStorageContext +impl<'view, 'a, DB, H, CA> StorageRead for VpValidationContext<'view, 'a, DB, H, CA> where DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, H: 'static + StorageHasher, CA: 'static + WasmCacheAccess, { - type Error = Error; type PrefixIter<'iter> = ledger_storage::PrefixIter<'iter, DB> where Self: 'iter; - fn read(&self, key: &Key) -> Result>, Self::Error> { - self.ctx.read_bytes(key).map_err(Error::NativeVpError) + fn read_bytes(&self, key: &Key) -> Result>> { + self.ctx.read_bytes(key) } - fn has_key(&self, key: &Key) -> Result { - self.ctx.has_key(key).map_err(Error::NativeVpError) + fn has_key(&self, key: &Key) -> Result { + self.ctx.has_key(key) } fn iter_prefix<'iter>( &'iter self, prefix: &Key, - ) -> Result, Self::Error> { - self.ctx.iter_prefix(prefix).map_err(Error::NativeVpError) + ) -> Result> { + self.ctx.iter_prefix(prefix) } fn iter_next<'iter>( &'iter self, iter: &mut Self::PrefixIter<'iter>, - ) -> Result)>, Self::Error> { - self.ctx.iter_next(iter).map_err(Error::NativeVpError) + ) -> Result)>> { + self.ctx.iter_next(iter) + } + + fn get_chain_id(&self) -> Result { + self.ctx.get_chain_id() + } + + fn get_block_height(&self) -> Result { + self.ctx.get_block_height() + } + + fn get_block_header(&self, height: BlockHeight) -> Result> { + self.ctx.get_block_header(height) + } + + fn get_block_hash(&self) -> Result { + self.ctx.get_block_hash() + } + + fn get_block_epoch(&self) -> Result { + self.ctx.get_block_epoch() } - fn write(&mut self, _key: &Key, _data: Vec) -> Result<(), Self::Error> { + fn get_tx_index(&self) -> Result { + self.ctx.get_tx_index() + } + + fn get_native_token(&self) -> Result
{ + self.ctx.get_native_token() + } +} + +impl<'view, 'a, DB, H, CA> StorageWrite + for VpValidationContext<'view, 'a, DB, H, CA> +where + DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, + H: 'static + StorageHasher, + CA: 'static + WasmCacheAccess, +{ + fn write_bytes( + &mut self, + _key: &Key, + _val: impl AsRef<[u8]>, + ) -> Result<()> { unimplemented!("Validation doesn't write any data") } - fn delete(&mut self, _key: &Key) -> Result<(), Self::Error> { + fn delete(&mut self, _key: &Key) -> Result<()> { unimplemented!("Validation doesn't delete any data") } +} - fn emit_ibc_event(&mut self, _event: IbcEvent) -> Result<(), Self::Error> { +impl<'view, 'a, DB, H, CA> IbcStorageContext + for VpValidationContext<'view, 'a, DB, H, CA> +where + DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, + H: 'static + StorageHasher, + CA: 'static + WasmCacheAccess, +{ + fn emit_ibc_event(&mut self, _event: IbcEvent) -> Result<()> { unimplemented!("Validation doesn't emit an event") } fn get_ibc_events( &self, _event_type: impl AsRef, - ) -> Result, Self::Error> { + ) -> Result> { unimplemented!("Validation doesn't get an event") } @@ -361,14 +426,14 @@ where _dest: &Address, _token: &Address, _amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<()> { unimplemented!("Validation doesn't transfer") } fn handle_masp_tx( &mut self, _shielded: &IbcShieldedTransfer, - ) -> Result<(), Self::Error> { + ) -> Result<()> { unimplemented!("Validation doesn't handle a masp tx") } @@ -377,7 +442,7 @@ where _target: &Address, _token: &Address, _amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<()> { unimplemented!("Validation doesn't mint") } @@ -386,26 +451,13 @@ where _target: &Address, _token: &Address, _amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<()> { unimplemented!("Validation doesn't burn") } - fn get_height(&self) -> Result { - self.ctx.get_block_height().map_err(Error::NativeVpError) - } - - fn get_header( - &self, - height: BlockHeight, - ) -> Result, Self::Error> { - self.ctx - .get_block_header(height) - .map_err(Error::NativeVpError) - } - /// Logging fn log_string(&self, message: String) { - tracing::debug!("{} for validation in IBC VP", message); + tracing::debug!("{message} for validation in IBC VP"); } } diff --git a/shared/src/ledger/native_vp/ibc/mod.rs b/shared/src/ledger/native_vp/ibc/mod.rs index 902bef0a5b..185c279adc 100644 --- a/shared/src/ledger/native_vp/ibc/mod.rs +++ b/shared/src/ledger/native_vp/ibc/mod.rs @@ -19,6 +19,7 @@ use namada_core::types::storage::Key; use namada_proof_of_stake::read_pos_params; use thiserror::Error; +use crate::ibc::core::ics24_host::identifier::ChainId as IbcChainId; use crate::ledger::ibc::storage::{calc_hash, is_ibc_denom_key, is_ibc_key}; use crate::ledger::native_vp::{self, Ctx, NativeVp, VpEnv}; use crate::ledger::parameters::read_epoch_duration_parameter; @@ -103,7 +104,7 @@ where let mut actions = IbcActions::new(ctx.clone()); let module = TransferModule::new(ctx.clone()); - actions.add_transfer_route(module.module_id(), module); + actions.add_transfer_module(module.module_id(), module); actions.execute(tx_data)?; let changed_ibc_keys: HashSet<&Key> = @@ -145,11 +146,12 @@ where actions.set_validation_params(self.validation_params()?); let module = TransferModule::new(ctx); - actions.add_transfer_route(module.module_id(), module); + actions.add_transfer_module(module.module_id(), module); actions.validate(tx_data).map_err(Error::IbcAction) } fn validation_params(&self) -> VpResult { + use std::str::FromStr; let chain_id = self.ctx.get_chain_id().map_err(Error::NativeVpError)?; let proof_specs = ledger_storage::ics23_specs::ibc_proof_specs::(); let pos_params = @@ -160,7 +162,8 @@ where let unbonding_period_secs = pipeline_len * epoch_duration.min_duration.0; Ok(ValidationParams { - chain_id: chain_id.into(), + chain_id: IbcChainId::from_str(&chain_id) + .map_err(|e| Error::IbcAction(ActionError::ChainId(e)))?, proof_specs: proof_specs.into(), unbonding_period: Duration::from_secs(unbonding_period_secs), upgrade_path: Vec::new(), @@ -295,6 +298,7 @@ mod tests { use std::convert::TryFrom; use std::str::FromStr; + use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; use namada_core::ledger::gas::TxGasMeter; use namada_core::ledger::governance::parameters::GovernanceParameters; @@ -316,7 +320,6 @@ mod tests { }; use crate::core::types::address::{nam, InternalAddress}; use crate::core::types::storage::Epoch; - use crate::ibc::applications::transfer::acknowledgement::TokenTransferAcknowledgement; use crate::ibc::applications::transfer::coin::PrefixedCoin; use crate::ibc::applications::transfer::denom::TracePrefix; use crate::ibc::applications::transfer::events::{ @@ -324,11 +327,10 @@ mod tests { }; use crate::ibc::applications::transfer::msgs::transfer::MsgTransfer; use crate::ibc::applications::transfer::packet::PacketData; - use crate::ibc::applications::transfer::VERSION; + use crate::ibc::applications::transfer::{ack_success_b64, VERSION}; use crate::ibc::core::events::{ IbcEvent as RawIbcEvent, MessageEvent, ModuleEvent, }; - use crate::ibc::core::ics02_client::client_state::ClientState; use crate::ibc::core::ics02_client::events::{CreateClient, UpdateClient}; use crate::ibc::core::ics02_client::msgs::create_client::MsgCreateClient; use crate::ibc::core::ics02_client::msgs::update_client::MsgUpdateClient; @@ -346,6 +348,9 @@ mod tests { use crate::ibc::core::ics03_connection::version::{ get_compatible_versions, Version as ConnVersion, }; + use crate::ibc::core::ics04_channel::acknowledgement::{ + Acknowledgement, AcknowledgementStatus, + }; use crate::ibc::core::ics04_channel::channel::{ ChannelEnd, Counterparty as ChanCounterparty, Order, State as ChanState, }; @@ -361,9 +366,7 @@ mod tests { MsgChannelOpenInit, MsgChannelOpenTry, MsgRecvPacket, MsgTimeout, MsgTimeoutOnClose, }; - use crate::ibc::core::ics04_channel::packet::{ - Acknowledgement, Packet, Sequence, - }; + use crate::ibc::core::ics04_channel::packet::{Packet, Sequence}; use crate::ibc::core::ics04_channel::timeout::TimeoutHeight; use crate::ibc::core::ics04_channel::Version as ChanVersion; use crate::ibc::core::ics23_commitment::commitment::{ @@ -388,6 +391,7 @@ mod tests { get_epoch_duration_storage_key, get_max_expected_time_per_block_key, }; use crate::ledger::parameters::EpochDuration; + use crate::ledger::storage_api::StorageRead; use crate::ledger::{ibc, pos}; use crate::proto::{Code, Data, Section, Signature, Tx}; use crate::tendermint::time::Time as TmTime; @@ -485,10 +489,7 @@ mod tests { .0 .unwrap() .time; - let bytes = TmTime::try_from(time) - .unwrap() - .encode_vec() - .expect("encoding failed"); + let bytes = TmTime::try_from(time).unwrap().encode_vec(); wl_storage .write_log .write(&client_update_time_key, bytes) @@ -571,8 +572,8 @@ mod tests { } } - fn increment_counter(wl_storage: &mut TestWlStorage, key: &Key) { - let count = match wl_storage.storage.read(key).expect("read failed").0 { + fn increment_sequence(wl_storage: &mut TestWlStorage, key: &Key) { + let count = match wl_storage.read_bytes(key).expect("read failed") { Some(value) => { let count: [u8; 8] = value.try_into().expect("decoding a count failed"); @@ -586,6 +587,19 @@ mod tests { .expect("write failed"); } + fn increment_counter(wl_storage: &mut TestWlStorage, key: &Key) { + let count = match wl_storage.read_bytes(key).expect("read failed") { + Some(value) => { + u64::try_from_slice(&value).expect("invalid counter value") + } + None => unreachable!("The counter should be initialized"), + }; + wl_storage + .write_log + .write(key, (count + 1).serialize_to_vec()) + .expect("write failed"); + } + fn dummy_proof() -> CommitmentProofBytes { CommitmentProofBytes::try_from(vec![0]).unwrap() } @@ -669,34 +683,6 @@ mod tests { .write(&consensus_key, bytes) .expect("write failed"); keys_changed.insert(consensus_key); - // client update time - let client_update_time_key = client_update_timestamp_key(&client_id); - let time = wl_storage - .storage - .get_block_header(None) - .unwrap() - .0 - .unwrap() - .time; - let bytes = TmTime::try_from(time) - .unwrap() - .encode_vec() - .expect("encoding failed"); - wl_storage - .write_log - .write(&client_update_time_key, bytes) - .expect("write failed"); - keys_changed.insert(client_update_time_key); - // client update height - let client_update_height_key = client_update_height_key(&client_id); - let host_height = wl_storage.storage.get_block_height().0; - let host_height = - Height::new(0, host_height.0).expect("invalid height"); - wl_storage - .write_log - .write(&client_update_height_key, host_height.encode_vec()) - .expect("write failed"); - keys_changed.insert(client_update_height_key); // client counter let client_counter_key = client_counter_key(); increment_counter(&mut wl_storage, &client_counter_key); @@ -862,7 +848,7 @@ mod tests { }; let msg = MsgUpdateClient { client_id: client_id.clone(), - header: header.into(), + client_message: header.into(), signer: "account0".to_string().into(), }; // client state @@ -891,10 +877,7 @@ mod tests { .0 .unwrap() .time; - let bytes = TmTime::try_from(time) - .unwrap() - .encode_vec() - .expect("encoding failed"); + let bytes = TmTime::try_from(time).unwrap().encode_vec(); wl_storage .write_log .write(&client_update_time_key, bytes) @@ -914,10 +897,10 @@ mod tests { let consensus_height = client_state.latest_height(); let event = RawIbcEvent::UpdateClient(UpdateClient::new( client_id, - client_state.client_type(), + client_type(), consensus_height, vec![consensus_height], - header.into(), + Protobuf::::encode_vec(&header), )); let message_event = RawIbcEvent::Message(MessageEvent::Client); wl_storage @@ -1213,6 +1196,7 @@ mod tests { proof_client: dummy_proof().into(), signer: "account0".to_string(), previous_connection_id: ConnectionId::default().to_string(), + host_consensus_state_proof: dummy_proof().into(), } .try_into() .expect("invalid message"); @@ -1353,6 +1337,7 @@ mod tests { consensus_height_of_a_on_b: client_state.latest_height(), version: ConnVersion::default(), signer: "account0".to_string().into(), + proof_consensus_state_of_a: None, }; // event let event = RawIbcEvent::OpenAckConnection(ConnOpenAck::new( @@ -1423,6 +1408,15 @@ mod tests { .expect("write failed"); wl_storage.write_log.commit_tx(); wl_storage.commit_block().expect("commit failed"); + // for next block + wl_storage + .storage + .set_header(get_dummy_header()) + .expect("Setting a dummy header shouldn't fail"); + wl_storage + .storage + .begin_block(BlockHash::default(), BlockHeight(2)) + .unwrap(); // update the connection to Open let conn = get_connection(ConnState::Open); @@ -1558,13 +1552,13 @@ mod tests { let channel_id = get_channel_id(); let port_id = msg.port_id_on_a.clone(); let send_key = next_sequence_send_key(&port_id, &channel_id); - increment_counter(&mut wl_storage, &send_key); + increment_sequence(&mut wl_storage, &send_key); keys_changed.insert(send_key); let recv_key = next_sequence_recv_key(&port_id, &channel_id); - increment_counter(&mut wl_storage, &recv_key); + increment_sequence(&mut wl_storage, &recv_key); keys_changed.insert(recv_key); let ack_key = next_sequence_ack_key(&port_id, &channel_id); - increment_counter(&mut wl_storage, &ack_key); + increment_sequence(&mut wl_storage, &ack_key); keys_changed.insert(ack_key); // event let event = RawIbcEvent::OpenInitChannel(ChanOpenInit::new( @@ -1681,13 +1675,13 @@ mod tests { let channel_id = get_channel_id(); let port_id = msg.port_id_on_a.clone(); let send_key = next_sequence_send_key(&port_id, &channel_id); - increment_counter(&mut wl_storage, &send_key); + increment_sequence(&mut wl_storage, &send_key); keys_changed.insert(send_key); let recv_key = next_sequence_recv_key(&port_id, &channel_id); - increment_counter(&mut wl_storage, &recv_key); + increment_sequence(&mut wl_storage, &recv_key); keys_changed.insert(recv_key); let ack_key = next_sequence_ack_key(&port_id, &channel_id); - increment_counter(&mut wl_storage, &ack_key); + increment_sequence(&mut wl_storage, &ack_key); keys_changed.insert(ack_key); // event let event = RawIbcEvent::OpenTryChannel(ChanOpenTry::new( @@ -2183,9 +2177,9 @@ mod tests { &packet.chan_id_on_b, msg.packet.seq_on_a, ); - let transfer_ack = TokenTransferAcknowledgement::success(); - let acknowledgement = Acknowledgement::from(transfer_ack); - let bytes = sha2::Sha256::digest(acknowledgement.as_ref()).to_vec(); + let transfer_ack = AcknowledgementStatus::success(ack_success_b64()); + let acknowledgement: Acknowledgement = transfer_ack.into(); + let bytes = sha2::Sha256::digest(acknowledgement.as_bytes()).to_vec(); wl_storage .write_log .write(&ack_key, bytes) @@ -2363,7 +2357,7 @@ mod tests { .unwrap(); // prepare data - let transfer_ack = TokenTransferAcknowledgement::success(); + let transfer_ack = AcknowledgementStatus::success(ack_success_b64()); let msg = MsgAcknowledgement { packet: packet.clone(), acknowledgement: transfer_ack.clone().into(), diff --git a/shared/src/ledger/native_vp/ibc/token.rs b/shared/src/ledger/native_vp/ibc/token.rs deleted file mode 100644 index 1c9cc5bc1d..0000000000 --- a/shared/src/ledger/native_vp/ibc/token.rs +++ /dev/null @@ -1,375 +0,0 @@ -//! IBC token transfer validation as a native validity predicate - -use std::collections::{BTreeSet, HashMap, HashSet}; - -use borsh::BorshDeserialize; -use prost::Message; -use thiserror::Error; - -use crate::ibc::applications::transfer::coin::PrefixedCoin; -use crate::ibc::applications::transfer::error::TokenTransferError; -use crate::ibc::applications::transfer::msgs::transfer::{ - MsgTransfer, TYPE_URL as MSG_TRANSFER_TYPE_URL, -}; -use crate::ibc::applications::transfer::packet::PacketData; -use crate::ibc::applications::transfer::{ - is_receiver_chain_source, is_sender_chain_source, -}; -use crate::ibc::core::ics04_channel::msgs::PacketMsg; -use crate::ibc::core::ics04_channel::packet::Packet; -use crate::ibc::core::ics26_routing::error::RouterError; -use crate::ibc::core::ics26_routing::msgs::MsgEnvelope; -use crate::ibc_proto::google::protobuf::Any; -use crate::ledger::ibc::storage as ibc_storage; -use crate::ledger::native_vp::{self, Ctx, NativeVp, VpEnv}; -use crate::ledger::storage::{self as ledger_storage, StorageHasher}; -use crate::proto::Tx; -use crate::types::address::{Address, InternalAddress}; -use crate::types::storage::Key; -use crate::types::token::{self, Amount, AmountParseError}; -use crate::vm::WasmCacheAccess; - -#[allow(missing_docs)] -#[derive(Error, Debug)] -pub enum Error { - #[error("Native VP error: {0}")] - NativeVpError(native_vp::Error), - #[error("IBC message error: {0}")] - IbcMessage(RouterError), - #[error("Invalid message")] - InvalidMessage, - #[error("Parsing amount error: {0}")] - Amount(AmountParseError), - #[error("Decoding error: {0}")] - Decoding(std::io::Error), - #[error("Decoding IBC data error: {0}")] - DecodingIbcData(prost::DecodeError), - #[error("Decoding PacketData error: {0}")] - DecodingPacketData(serde_json::Error), - #[error("IBC message is required as transaction data")] - NoTxData, - #[error("Invalid denom: {0}")] - Denom(String), - #[error("Invalid MsgTransfer: {0}")] - MsgTransfer(TokenTransferError), - #[error("Invalid token transfer: {0}")] - TokenTransfer(String), -} - -/// Result for IBC token VP -pub type Result = std::result::Result; - -/// IBC token VP to validate the transfer for an IBC-specific account. The -/// account is a sub-prefixed account with an IBC token hash, or a normal -/// account for `IbcEscrow`, `IbcBurn`, or `IbcMint`. -pub struct IbcToken<'a, DB, H, CA> -where - DB: ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, - H: StorageHasher, - CA: 'static + WasmCacheAccess, -{ - /// Context to interact with the host structures. - pub ctx: Ctx<'a, DB, H, CA>, -} - -impl<'a, DB, H, CA> NativeVp for IbcToken<'a, DB, H, CA> -where - DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, - H: 'static + StorageHasher, - CA: 'static + WasmCacheAccess, -{ - type Error = Error; - - fn validate_tx( - &self, - tx_data: &Tx, - keys_changed: &BTreeSet, - _verifiers: &BTreeSet
, - ) -> Result { - let signed = tx_data; - let tx_data = signed.data().ok_or(Error::NoTxData)?; - - // Check the non-onwer balance updates - let ibc_keys_changed: HashSet = keys_changed - .iter() - .filter(|k| { - matches!( - token::is_any_token_balance_key(k), - Some([ - _, - Address::Internal( - InternalAddress::IbcEscrow - | InternalAddress::IbcBurn - | InternalAddress::IbcMint - ) - ]) - ) - }) - .cloned() - .collect(); - if ibc_keys_changed.is_empty() { - // some multitoken balances are changed - let mut changes = HashMap::new(); - for key in keys_changed { - if let Some((sub_prefix, _)) = - token::is_any_multitoken_balance_key(key) - { - if !ibc_storage::is_ibc_sub_prefix(&sub_prefix) { - continue; - } - let pre: token::Amount = - self.ctx.read_pre(key)?.unwrap_or_default(); - let post: token::Amount = - self.ctx.read_post(key)?.unwrap_or_default(); - let this_change = post.change() - pre.change(); - let change: token::Change = - changes.get(&sub_prefix).cloned().unwrap_or_default(); - changes.insert(sub_prefix, change + this_change); - } - } - if changes.iter().all(|(_, c)| c.is_zero()) { - return Ok(true); - } else { - return Err(Error::TokenTransfer( - "Invalid transfer between different origin accounts" - .to_owned(), - )); - } - } else if ibc_keys_changed.len() > 1 { - // a transaction can update at most 1 special IBC account for now - return Err(Error::TokenTransfer( - "Invalid transfer for multiple non-owner balances".to_owned(), - )); - } - - // Check the message - let ibc_msg = - Any::decode(&tx_data[..]).map_err(Error::DecodingIbcData)?; - match ibc_msg.type_url.as_str() { - MSG_TRANSFER_TYPE_URL => { - let msg = MsgTransfer::try_from(ibc_msg) - .map_err(Error::MsgTransfer)?; - self.validate_sending_token(&msg) - } - _ => { - let envelope: MsgEnvelope = - ibc_msg.try_into().map_err(Error::IbcMessage)?; - match envelope { - MsgEnvelope::Packet(PacketMsg::Recv(msg)) => { - self.validate_receiving_token(&msg.packet) - } - MsgEnvelope::Packet(PacketMsg::Ack(msg)) => { - self.validate_refunding_token(&msg.packet) - } - MsgEnvelope::Packet(PacketMsg::Timeout(msg)) => { - self.validate_refunding_token(&msg.packet) - } - MsgEnvelope::Packet(PacketMsg::TimeoutOnClose(msg)) => { - self.validate_refunding_token(&msg.packet) - } - _ => Err(Error::InvalidMessage), - } - } - } - } -} - -impl<'a, DB, H, CA> IbcToken<'a, DB, H, CA> -where - DB: 'static + ledger_storage::DB + for<'iter> ledger_storage::DBIter<'iter>, - H: 'static + StorageHasher, - CA: 'static + WasmCacheAccess, -{ - fn validate_sending_token(&self, msg: &MsgTransfer) -> Result { - let mut coin = msg.token.clone(); - // lookup the original denom with the IBC token hash - if let Some(token_hash) = - ibc_storage::token_hash_from_denom(&coin.denom).map_err(|e| { - Error::Denom(format!("Invalid denom: error {}", e)) - })? - { - let denom_key = ibc_storage::ibc_denom_key(token_hash); - coin.denom = match self.ctx.read_bytes_pre(&denom_key) { - Ok(Some(v)) => String::from_utf8(v).map_err(|e| { - Error::Denom(format!( - "Decoding the denom string failed: {}", - e - )) - })?, - _ => { - return Err(Error::Denom(format!( - "No original denom: denom_key {}", - denom_key - ))); - } - }; - } - let coin = PrefixedCoin::try_from(coin).map_err(Error::MsgTransfer)?; - let token = ibc_storage::token(coin.denom.to_string()) - .map_err(|e| Error::Denom(e.to_string()))?; - let amount = Amount::try_from(coin.amount).map_err(Error::Amount)?; - - // check the denomination field - let change = if is_sender_chain_source( - msg.port_id_on_a.clone(), - msg.chan_id_on_a.clone(), - &coin.denom, - ) { - // source zone - // check the amount of the token has been escrowed - let target_key = token::balance_key( - &token, - &Address::Internal(InternalAddress::IbcEscrow), - ); - let pre = - try_decode_token_amount(self.ctx.read_bytes_pre(&target_key)?)? - .unwrap_or_default(); - let post = try_decode_token_amount( - self.ctx.read_bytes_post(&target_key)?, - )? - .unwrap_or_default(); - post.change() - pre.change() - } else { - // sink zone - // check the amount of the token has been burned - let target_key = token::balance_key( - &token, - &Address::Internal(InternalAddress::IbcBurn), - ); - let post = try_decode_token_amount( - self.ctx.read_bytes_temp(&target_key)?, - )? - .unwrap_or_default(); - // the previous balance of the burn address should be zero - post.change() - }; - - if change == amount.change() { - Ok(true) - } else { - Err(Error::TokenTransfer(format!( - "Sending the token is invalid: coin {}", - coin, - ))) - } - } - - fn validate_receiving_token(&self, packet: &Packet) -> Result { - let data = serde_json::from_slice::(&packet.data) - .map_err(Error::DecodingPacketData)?; - let token = ibc_storage::token(data.token.denom.to_string()) - .map_err(|e| Error::Denom(e.to_string()))?; - let amount = - Amount::try_from(data.token.amount).map_err(Error::Amount)?; - - let change = if is_receiver_chain_source( - packet.port_id_on_a.clone(), - packet.chan_id_on_a.clone(), - &data.token.denom, - ) { - // this chain is the source - // check the amount of the token has been unescrowed - let source_key = token::balance_key( - &token, - &Address::Internal(InternalAddress::IbcEscrow), - ); - let pre = - try_decode_token_amount(self.ctx.read_bytes_pre(&source_key)?)? - .unwrap_or_default(); - let post = try_decode_token_amount( - self.ctx.read_bytes_post(&source_key)?, - )? - .unwrap_or_default(); - pre.change() - post.change() - } else { - // the sender is the source - // check the amount of the token has been minted - let source_key = token::balance_key( - &token, - &Address::Internal(InternalAddress::IbcMint), - ); - let post = try_decode_token_amount( - self.ctx.read_bytes_temp(&source_key)?, - )? - .unwrap_or_default(); - // the previous balance of the mint address should be the maximum - Amount::max_signed().change() - post.change() - }; - - if change == amount.change() { - Ok(true) - } else { - Err(Error::TokenTransfer(format!( - "Receivinging the token is invalid: coin {}", - data.token - ))) - } - } - - fn validate_refunding_token(&self, packet: &Packet) -> Result { - let data = serde_json::from_slice::(&packet.data) - .map_err(Error::DecodingPacketData)?; - let token = ibc_storage::token(data.token.denom.to_string()) - .map_err(|e| Error::Denom(e.to_string()))?; - let amount = - Amount::try_from(data.token.amount).map_err(Error::Amount)?; - - // check the denom field - let change = if is_sender_chain_source( - packet.port_id_on_a.clone(), - packet.chan_id_on_a.clone(), - &data.token.denom, - ) { - // source zone: unescrow the token for the refund - let source_key = token::balance_key( - &token, - &Address::Internal(InternalAddress::IbcEscrow), - ); - let pre = - try_decode_token_amount(self.ctx.read_bytes_pre(&source_key)?)? - .unwrap_or_default(); - let post = try_decode_token_amount( - self.ctx.read_bytes_post(&source_key)?, - )? - .unwrap_or_default(); - pre.change() - post.change() - } else { - // sink zone: mint the token for the refund - let source_key = token::balance_key( - &token, - &Address::Internal(InternalAddress::IbcMint), - ); - let post = try_decode_token_amount( - self.ctx.read_bytes_temp(&source_key)?, - )? - .unwrap_or_default(); - // the previous balance of the mint address should be the maximum - Amount::max_signed().change() - post.change() - }; - - if change == amount.change() { - Ok(true) - } else { - Err(Error::TokenTransfer(format!( - "Refunding the token is invalid: coin {}", - data.token, - ))) - } - } -} - -impl From for Error { - fn from(err: native_vp::Error) -> Self { - Self::NativeVpError(err) - } -} - -fn try_decode_token_amount( - bytes: Option>, -) -> Result> { - if let Some(bytes) = bytes { - let tokens = Amount::try_from_slice(&bytes).map_err(Error::Decoding)?; - return Ok(Some(tokens)); - } - Ok(None) -} diff --git a/shared/src/vm/host_env.rs b/shared/src/vm/host_env.rs index 5f701b7e1f..de4b49a1f9 100644 --- a/shared/src/vm/host_env.rs +++ b/shared/src/vm/host_env.rs @@ -4,7 +4,7 @@ use std::collections::BTreeSet; use std::convert::TryInto; use std::num::TryFromIntError; -use borsh::{BorshDeserialize, BorshSerialize}; +use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; use masp_primitives::transaction::Transaction; use namada_core::ledger::gas::{GasMetering, TxGasMeter}; @@ -19,6 +19,7 @@ use super::WasmCacheAccess; use crate::ledger::gas::{self, VpGasMeter, STORAGE_ACCESS_GAS_PER_BYTE}; use crate::ledger::storage::write_log::{self, WriteLog}; use crate::ledger::storage::{self, Storage, StorageHasher}; +use crate::ledger::storage_api::{self, ResultExt}; use crate::ledger::vp_host_fns; use crate::proto::Tx; use crate::types::address::{self, Address}; @@ -1959,7 +1960,7 @@ where let ctx = Rc::new(RefCell::new(env.ctx.clone())); let mut actions = IbcActions::new(ctx.clone()); let module = TransferModule::new(ctx); - actions.add_transfer_route(module.module_id(), module); + actions.add_transfer_module(module.module_id(), module); actions.execute(&tx_data)?; Ok(()) @@ -2086,21 +2087,22 @@ where } // Temp. workaround for -impl<'a, DB, H, CA> namada_core::ledger::ibc::IbcStorageContext - for TxCtx<'a, DB, H, CA> +use namada_core::ledger::storage_api::StorageRead; + +use crate::types::storage::BlockHash; +impl<'a, DB, H, CA> StorageRead for TxCtx<'a, DB, H, CA> where DB: storage::DB + for<'iter> storage::DBIter<'iter>, H: StorageHasher, CA: WasmCacheAccess, { - type Error = TxRuntimeError; // type PrefixIter<'iter> = KeyValIterator<(String, Vec)>; type PrefixIter<'iter> = u64 where Self: 'iter; - fn read( + fn read_bytes( &self, key: &Key, - ) -> std::result::Result>, Self::Error> { + ) -> std::result::Result>, storage_api::Error> { let write_log = unsafe { self.write_log.get() }; let (log_val, gas) = write_log.read(key); ibc_tx_charge_gas(self, gas)?; @@ -2118,15 +2120,14 @@ where None => { // when not found in write log, try to read from the storage let storage = unsafe { self.storage.get() }; - let (value, gas) = - storage.read(key).map_err(TxRuntimeError::StorageError)?; + let (value, gas) = storage.read(key).into_storage_result()?; ibc_tx_charge_gas(self, gas)?; value } }) } - fn has_key(&self, key: &Key) -> Result { + fn has_key(&self, key: &Key) -> Result { // try to read from the write log first let write_log = unsafe { self.write_log.get() }; let (log_val, gas) = write_log.read(key); @@ -2139,31 +2140,18 @@ where None => { // when not found in write log, try to check the storage let storage = unsafe { self.storage.get() }; - let (present, gas) = storage - .has_key(key) - .map_err(TxRuntimeError::StorageError)?; + let (present, gas) = + storage.has_key(key).into_storage_result()?; ibc_tx_charge_gas(self, gas)?; present } }) } - fn write( - &mut self, - key: &Key, - data: Vec, - ) -> std::result::Result<(), Self::Error> { - let write_log = unsafe { self.write_log.get() }; - let (gas, _size_diff) = write_log - .write(key, data) - .map_err(TxRuntimeError::StorageModificationError)?; - ibc_tx_charge_gas(self, gas) - } - fn iter_prefix<'iter>( &'iter self, prefix: &Key, - ) -> Result, Self::Error> { + ) -> Result, storage_api::Error> { let write_log = unsafe { self.write_log.get() }; let storage = unsafe { self.storage.get() }; let (iter, gas) = storage::iter_prefix_post(write_log, storage, prefix); @@ -2176,15 +2164,13 @@ where fn iter_next<'iter>( &'iter self, iter_id: &mut Self::PrefixIter<'iter>, - ) -> Result)>, Self::Error> { + ) -> Result)>, storage_api::Error> { let write_log = unsafe { self.write_log.get() }; let iterators = unsafe { self.iterators.get() }; let iter_id = PrefixIteratorId::new(*iter_id); while let Some((key, val, iter_gas)) = iterators.next(iter_id) { - let (log_val, log_gas) = write_log.read( - &Key::parse(key.clone()) - .map_err(TxRuntimeError::StorageDataError)?, - ); + let (log_val, log_gas) = + write_log.read(&Key::parse(key.clone()).into_storage_result()?); ibc_tx_charge_gas(self, iter_gas + log_gas)?; match log_val { Some(write_log::StorageModification::Write { ref value }) => { @@ -2211,22 +2197,110 @@ where Ok(None) } - fn delete(&mut self, key: &Key) -> std::result::Result<(), Self::Error> { + fn get_chain_id(&self) -> Result { + let storage = unsafe { self.storage.get() }; + let (chain_id, gas) = storage.get_chain_id(); + ibc_tx_charge_gas(self, gas)?; + Ok(chain_id) + } + + fn get_block_height(&self) -> Result { + let storage = unsafe { self.storage.get() }; + let (height, gas) = storage.get_block_height(); + ibc_tx_charge_gas(self, gas)?; + Ok(height) + } + + fn get_block_header( + &self, + height: BlockHeight, + ) -> Result, storage_api::Error> + { + let storage = unsafe { self.storage.get() }; + let (header, gas) = storage + .get_block_header(Some(height)) + .into_storage_result()?; + ibc_tx_charge_gas(self, gas)?; + Ok(header) + } + + fn get_block_hash(&self) -> Result { + let storage = unsafe { self.storage.get() }; + let (hash, gas) = storage.get_block_hash(); + ibc_tx_charge_gas(self, gas)?; + Ok(hash) + } + + fn get_block_epoch(&self) -> Result { + let storage = unsafe { self.storage.get() }; + let (epoch, gas) = storage.get_current_epoch(); + ibc_tx_charge_gas(self, gas)?; + Ok(epoch) + } + + fn get_tx_index(&self) -> Result { + let tx_index = unsafe { self.tx_index.get() }; + ibc_tx_charge_gas( + self, + crate::vm::host_env::gas::STORAGE_ACCESS_GAS_PER_BYTE, + )?; + Ok(TxIndex(tx_index.0)) + } + + fn get_native_token(&self) -> Result { + let storage = unsafe { self.storage.get() }; + let native_token = storage.native_token.clone(); + ibc_tx_charge_gas( + self, + crate::vm::host_env::gas::STORAGE_ACCESS_GAS_PER_BYTE, + )?; + Ok(native_token) + } +} + +// Temp. workaround for +use namada_core::ledger::storage_api::StorageWrite; +impl<'a, DB, H, CA> StorageWrite for TxCtx<'a, DB, H, CA> +where + DB: storage::DB + for<'iter> storage::DBIter<'iter>, + H: StorageHasher, + CA: WasmCacheAccess, +{ + fn write_bytes( + &mut self, + key: &Key, + data: impl AsRef<[u8]>, + ) -> Result<(), storage_api::Error> { + let write_log = unsafe { self.write_log.get() }; + let (gas, _size_diff) = write_log + .write(key, data.as_ref().to_vec()) + .into_storage_result()?; + ibc_tx_charge_gas(self, gas) + } + + fn delete(&mut self, key: &Key) -> Result<(), storage_api::Error> { if key.is_validity_predicate().is_some() { - return Err(TxRuntimeError::CannotDeleteVp); + return Err(TxRuntimeError::CannotDeleteVp).into_storage_result(); } let write_log = unsafe { self.write_log.get() }; - let (gas, _size_diff) = write_log - .delete(key) - .map_err(TxRuntimeError::StorageModificationError)?; + let (gas, _size_diff) = write_log.delete(key).into_storage_result()?; ibc_tx_charge_gas(self, gas) } +} +// Temp. workaround for +impl<'a, DB, H, CA> namada_core::ledger::ibc::IbcStorageContext + for TxCtx<'a, DB, H, CA> +where + DB: storage::DB + for<'iter> storage::DBIter<'iter>, + H: StorageHasher, + CA: WasmCacheAccess, +{ fn emit_ibc_event( &mut self, event: IbcEvent, - ) -> std::result::Result<(), Self::Error> { + ) -> Result<(), storage_api::Error> { let write_log = unsafe { self.write_log.get() }; let gas = write_log.emit_ibc_event(event); ibc_tx_charge_gas(self, gas) @@ -2235,7 +2309,7 @@ where fn get_ibc_events( &self, event_type: impl AsRef, - ) -> Result, Self::Error> { + ) -> Result, storage_api::Error> { let write_log = unsafe { self.write_log.get() }; Ok(write_log .get_ibc_events() @@ -2251,24 +2325,23 @@ where dest: &Address, token: &Address, amount: namada_core::types::token::DenominatedAmount, - ) -> std::result::Result<(), Self::Error> { + ) -> Result<(), storage_api::Error> { use namada_core::types::token; if amount.amount != token::Amount::default() && src != dest { let src_key = token::balance_key(token, src); let dest_key = token::balance_key(token, dest); - let src_bal: Option = - ibc_read_borsh(self, &src_key)?; + let src_bal = self.read::(&src_key)?; let mut src_bal = src_bal.unwrap_or_else(|| { self.log_string(format!("src {} has no balance", src_key)); unreachable!() }); src_bal.spend(&amount.amount); - let mut dest_bal: token::Amount = - ibc_read_borsh(self, &dest_key)?.unwrap_or_default(); + let mut dest_bal = + self.read::(&dest_key)?.unwrap_or_default(); dest_bal.receive(&amount.amount); - ibc_write_borsh(self, &src_key, &src_bal)?; - ibc_write_borsh(self, &dest_key, &dest_bal)?; + self.write(&src_key, src_bal)?; + self.write(&dest_key, dest_bal)?; } Ok(()) } @@ -2276,14 +2349,13 @@ where fn handle_masp_tx( &mut self, shielded: &IbcShieldedTransfer, - ) -> Result<(), Self::Error> { + ) -> Result<(), storage_api::Error> { let masp_addr = address::masp(); let head_tx_key = Key::from(masp_addr.to_db_key()) .push(&HEAD_TX_KEY.to_owned()) .expect("Cannot obtain a storage key"); - let current_tx_idx: u64 = ibc_read_borsh(self, &head_tx_key) - .unwrap_or(None) - .unwrap_or(0); + let current_tx_idx = + self.read::(&head_tx_key).unwrap_or(None).unwrap_or(0); let current_tx_key = Key::from(masp_addr.to_db_key()) .push(&(TX_KEY_PREFIX.to_owned() + ¤t_tx_idx.to_string())) .expect("Cannot obtain a storage key"); @@ -2291,20 +2363,20 @@ where // so that clients do not have to separately look these // up let record: (Epoch, BlockHeight, TxIndex, Transfer, Transaction) = ( - ibc_get_block_epoch(self)?, - self.get_height()?, - ibc_get_tx_index(self)?, + self.get_block_epoch()?, + self.get_block_height()?, + self.get_tx_index()?, shielded.transfer.clone(), shielded.masp_tx.clone(), ); - ibc_write_borsh(self, ¤t_tx_key, &record)?; - ibc_write_borsh(self, &head_tx_key, &(current_tx_idx + 1))?; + self.write(¤t_tx_key, record)?; + self.write(&head_tx_key, current_tx_idx + 1)?; // If storage key has been supplied, then pin this transaction to it if let Some(key) = &shielded.transfer.key { let pin_key = Key::from(masp_addr.to_db_key()) .push(&(PIN_KEY_PREFIX.to_owned() + key)) .expect("Cannot obtain a storage key"); - ibc_write_borsh(self, &pin_key, ¤t_tx_idx)?; + self.write(&pin_key, current_tx_idx)?; } Ok(()) } @@ -2314,30 +2386,27 @@ where target: &Address, token: &Address, amount: namada_core::types::token::DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<(), storage_api::Error> { use namada_core::types::token; let target_key = token::balance_key(token, target); - let mut target_bal: token::Amount = - ibc_read_borsh(self, &target_key)?.unwrap_or_default(); + let mut target_bal = + self.read::(&target_key)?.unwrap_or_default(); target_bal.receive(&amount.amount); let minted_key = token::minted_balance_key(token); - let mut minted_bal: token::Amount = - ibc_read_borsh(self, &minted_key)?.unwrap_or_default(); + let mut minted_bal = + self.read::(&minted_key)?.unwrap_or_default(); minted_bal.receive(&amount.amount); - ibc_write_borsh(self, &target_key, &target_bal)?; - ibc_write_borsh(self, &minted_key, &minted_bal)?; + self.write(&target_key, target_bal)?; + self.write(&minted_key, minted_bal)?; let minter_key = token::minter_key(token); - ibc_write_borsh( - self, + self.write( &minter_key, - &Address::Internal(address::InternalAddress::Ibc), - )?; - - Ok(()) + Address::Internal(address::InternalAddress::Ibc), + ) } fn burn_token( @@ -2345,46 +2414,22 @@ where target: &Address, token: &Address, amount: namada_core::types::token::DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<(), storage_api::Error> { use namada_core::types::token; let target_key = token::balance_key(token, target); - let mut target_bal: token::Amount = - ibc_read_borsh(self, &target_key)?.unwrap_or_default(); + let mut target_bal = + self.read::(&target_key)?.unwrap_or_default(); target_bal.spend(&amount.amount); // burn the minted amount let minted_key = token::minted_balance_key(token); - let mut minted_bal: token::Amount = - ibc_read_borsh(self, &minted_key)?.unwrap_or_default(); + let mut minted_bal = + self.read::(&minted_key)?.unwrap_or_default(); minted_bal.spend(&amount.amount); - ibc_write_borsh(self, &target_key, &target_bal)?; - ibc_write_borsh(self, &minted_key, &minted_bal)?; - - Ok(()) - } - - fn get_height(&self) -> std::result::Result { - let storage = unsafe { self.storage.get() }; - let (height, gas) = storage.get_block_height(); - ibc_tx_charge_gas(self, gas)?; - Ok(height) - } - - fn get_header( - &self, - height: BlockHeight, - ) -> std::result::Result< - Option, - Self::Error, - > { - let storage = unsafe { self.storage.get() }; - let (header, gas) = storage - .get_block_header(Some(height)) - .map_err(TxRuntimeError::StorageError)?; - ibc_tx_charge_gas(self, gas)?; - Ok(header) + self.write(&target_key, target_bal)?; + self.write(&minted_key, minted_bal) } fn log_string(&self, message: String) { @@ -2397,7 +2442,7 @@ where fn ibc_tx_charge_gas<'a, DB, H, CA>( ctx: &TxCtx<'a, DB, H, CA>, used_gas: u64, -) -> TxResult<()> +) -> Result<(), storage_api::Error> where DB: storage::DB + for<'iter> storage::DBIter<'iter>, H: StorageHasher, @@ -2405,9 +2450,7 @@ where { let gas_meter = unsafe { ctx.gas_meter.get() }; // if we run out of gas, we need to stop the execution - let result = gas_meter - .consume(used_gas) - .map_err(TxRuntimeError::OutOfGas); + let result = gas_meter.consume(used_gas).into_storage_result(); if let Err(err) = &result { tracing::info!( "Stopping transaction execution because of gas error: {}", @@ -2417,81 +2460,6 @@ where result } -/// Read borsh encoded val by key. -// Temp helper for ibc tx workaround. -fn ibc_read_borsh<'a, T, DB, H, CA>( - ctx: &TxCtx<'a, DB, H, CA>, - key: &Key, -) -> TxResult> -where - T: BorshDeserialize, - DB: storage::DB + for<'iter> storage::DBIter<'iter>, - H: StorageHasher, - CA: WasmCacheAccess, -{ - let bytes = namada_core::ledger::ibc::IbcStorageContext::read(ctx, key)?; - match bytes { - Some(bytes) => { - let val = T::try_from_slice(&bytes) - .map_err(TxRuntimeError::EncodingError)?; - Ok(Some(val)) - } - None => Ok(None), - } -} - -/// Write borsh encoded val by key. -// Temp helper for ibc tx workaround. -fn ibc_write_borsh<'a, T, DB, H, CA>( - ctx: &mut TxCtx<'a, DB, H, CA>, - key: &Key, - val: &T, -) -> TxResult<()> -where - T: BorshSerialize, - DB: storage::DB + for<'iter> storage::DBIter<'iter>, - H: StorageHasher, - CA: WasmCacheAccess, -{ - let bytes = borsh::to_vec(val).map_err(TxRuntimeError::EncodingError)?; - namada_core::ledger::ibc::IbcStorageContext::write(ctx, key, bytes)?; - Ok(()) -} - -/// Get the current epoch. -// Temp helper for ibc tx workaround. -fn ibc_get_block_epoch<'a, DB, H, CA>( - ctx: &TxCtx<'a, DB, H, CA>, -) -> TxResult -where - DB: storage::DB + for<'iter> storage::DBIter<'iter>, - H: StorageHasher, - CA: WasmCacheAccess, -{ - let storage = unsafe { ctx.storage.get() }; - let (epoch, gas) = storage.get_current_epoch(); - ibc_tx_charge_gas(ctx, gas)?; - Ok(epoch) -} - -/// Get the tx index. -// Temp helper for ibc tx workaround. -fn ibc_get_tx_index<'a, DB, H, CA>( - ctx: &TxCtx<'a, DB, H, CA>, -) -> TxResult -where - DB: storage::DB + for<'iter> storage::DBIter<'iter>, - H: StorageHasher, - CA: WasmCacheAccess, -{ - let tx_index = unsafe { ctx.tx_index.get() }; - ibc_tx_charge_gas( - ctx, - crate::vm::host_env::gas::STORAGE_ACCESS_GAS_PER_BYTE, - )?; - Ok(TxIndex(tx_index.0)) -} - // Temp. workaround for impl<'a, DB, H, CA> namada_core::ledger::ibc::IbcCommonContext for TxCtx<'a, DB, H, CA> diff --git a/tests/src/e2e/ibc_tests.rs b/tests/src/e2e/ibc_tests.rs index 0b93d0df94..e8fc6ef75a 100644 --- a/tests/src/e2e/ibc_tests.rs +++ b/tests/src/e2e/ibc_tests.rs @@ -24,7 +24,6 @@ use namada::ibc::clients::ics07_tendermint::client_state::{ use namada::ibc::clients::ics07_tendermint::consensus_state::ConsensusState as TmConsensusState; use namada::ibc::clients::ics07_tendermint::header::Header as IbcTmHeader; use namada::ibc::clients::ics07_tendermint::trust_threshold::TrustThreshold; -use namada::ibc::core::ics02_client::client_state::ClientState; use namada::ibc::core::ics02_client::msgs::create_client::MsgCreateClient; use namada::ibc::core::ics02_client::msgs::update_client::MsgUpdateClient; use namada::ibc::core::ics03_connection::connection::Counterparty as ConnCounterparty; @@ -71,7 +70,7 @@ use namada_apps::config::genesis::{chain, templates}; use namada_apps::config::utils::set_port; use namada_apps::config::{ethereum_bridge, TendermintMode}; use namada_apps::facade::tendermint::block::Header as TmHeader; -use namada_apps::facade::tendermint::merkle::proof::Proof as TmProof; +use namada_apps::facade::tendermint::merkle::proof::ProofOps as TmProof; use namada_apps::facade::tendermint_config::net::Address as TendermintAddress; use namada_apps::facade::tendermint_rpc::{Client, HttpClient, Url}; use namada_sdk::masp::fs::FsShieldedUtils; @@ -300,7 +299,7 @@ fn setup_two_single_node_nets() -> Result<(Test, Test)> { fn create_client(test_a: &Test, test_b: &Test) -> Result<(ClientId, ClientId)> { let height = query_height(test_b)?; let client_state = make_client_state(test_b, height); - let height = client_state.latest_height(); + let height = client_state.latest_height; let message = MsgCreateClient { client_state: client_state.into(), consensus_state: make_consensus_state(test_b, height)?.into(), @@ -310,7 +309,7 @@ fn create_client(test_a: &Test, test_b: &Test) -> Result<(ClientId, ClientId)> { let height = query_height(test_a)?; let client_state = make_client_state(test_a, height); - let height = client_state.latest_height(); + let height = client_state.latest_height; let message = MsgCreateClient { client_state: client_state.into(), consensus_state: make_consensus_state(test_a, height)?.into(), @@ -397,7 +396,7 @@ fn update_client_with_height( }; let client_state = TmClientState::try_from(cs) .expect("the state should be a TmClientState"); - let trusted_height = client_state.latest_height(); + let trusted_height = client_state.latest_height; update_client( src_test, @@ -438,8 +437,8 @@ fn update_client( }; let message = MsgUpdateClient { - header: header.into(), client_id: client_id.clone(), + client_message: header.into(), signer: signer(), }; submit_ibc_tx(target_test, message, ALBERT, ALBERT_KEY, false)?; @@ -519,7 +518,7 @@ fn connection_handshake( let conn_proof = get_connection_proof(test_b, &conn_id_b, height_b)?; let (client_state, client_state_proof, consensus_proof) = get_client_states(test_b, client_id_b, height_b)?; - let consensus_height_of_a_on_b = client_state.latest_height(); + let consensus_height_of_a_on_b = client_state.latest_height; let msg = MsgConnectionOpenAck { conn_id_on_a: conn_id_a.clone(), conn_id_on_b: conn_id_b.clone(), @@ -531,6 +530,7 @@ fn connection_handshake( consensus_height_of_a_on_b, version: ConnVersion::default(), signer: signer(), + proof_consensus_state_of_a: None, }; // Update the client state of Chain B on Chain A update_client_with_height(test_b, test_a, client_id_a, height_b)?; @@ -695,7 +695,7 @@ fn get_client_states( .expect("the state should be a TmClientState"); let client_state_proof = convert_proof(tm_proof)?; - let height = client_state.latest_height(); + let height = client_state.latest_height; let ibc_height = Height::new(0, height.revision_height()).unwrap(); let key = consensus_state_key(client_id, ibc_height); let (_, tm_proof) = query_value_with_proof(test, &key, Some(query_height))?; @@ -1534,7 +1534,7 @@ fn make_msg_conn_open_try( ) -> MsgConnectionOpenTry { use namada::ibc_proto::ibc::core::connection::v1::MsgConnectionOpenTry as RawMsgConnectionOpenTry; - let consensus_height = client_state.latest_height(); + let consensus_height = client_state.latest_height; #[allow(deprecated)] RawMsgConnectionOpenTry { client_id: client_id.as_str().to_string(), @@ -1549,6 +1549,7 @@ fn make_msg_conn_open_try( consensus_height: Some(consensus_height.into()), signer: "signer".to_string(), previous_connection_id: ConnectionId::default().to_string(), + host_consensus_state_proof: vec![], } .try_into() .expect("invalid message") diff --git a/tests/src/integration/setup.rs b/tests/src/integration/setup.rs index 3a5739176d..16ea9a11c2 100644 --- a/tests/src/integration/setup.rs +++ b/tests/src/integration/setup.rs @@ -199,7 +199,7 @@ fn create_node( chain_id: chain_id.to_string(), consensus_params: None, validators: vec![], - app_state_bytes: vec![], + app_state_bytes: vec![].into(), initial_height: 0, }; { diff --git a/tests/src/vm_host_env/ibc.rs b/tests/src/vm_host_env/ibc.rs index 052b5b5e77..e0d4cce010 100644 --- a/tests/src/vm_host_env/ibc.rs +++ b/tests/src/vm_host_env/ibc.rs @@ -1,15 +1,11 @@ use core::time::Duration; use std::collections::HashMap; -use namada::ibc::applications::transfer::acknowledgement::TokenTransferAcknowledgement; use namada::ibc::applications::transfer::coin::PrefixedCoin; use namada::ibc::applications::transfer::error::TokenTransferError; use namada::ibc::applications::transfer::msgs::transfer::MsgTransfer; use namada::ibc::applications::transfer::packet::PacketData; -use namada::ibc::applications::transfer::VERSION; -use namada::ibc::core::ics02_client::client_state::ClientState; -use namada::ibc::core::ics02_client::client_type::ClientType; -use namada::ibc::core::ics02_client::consensus_state::ConsensusState; +use namada::ibc::applications::transfer::{ack_success_b64, VERSION}; use namada::ibc::core::ics02_client::msgs::create_client::MsgCreateClient; use namada::ibc::core::ics02_client::msgs::update_client::MsgUpdateClient; use namada::ibc::core::ics02_client::msgs::upgrade_client::MsgUpgradeClient; @@ -21,6 +17,9 @@ use namada::ibc::core::ics03_connection::msgs::conn_open_confirm::MsgConnectionO use namada::ibc::core::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit; use namada::ibc::core::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry; use namada::ibc::core::ics03_connection::version::Version as ConnVersion; +use namada::ibc::core::ics04_channel::acknowledgement::{ + AcknowledgementStatus, StatusValue, +}; use namada::ibc::core::ics04_channel::channel::{ ChannelEnd, Counterparty as ChanCounterparty, Order, State as ChanState, }; @@ -39,14 +38,12 @@ pub use namada::ibc::core::ics24_host::identifier::{ ChannelId, ClientId, ConnectionId, PortId, }; use namada::ibc::core::timestamp::Timestamp; -use namada::ibc::mock::client_state::{MockClientState, MOCK_CLIENT_TYPE}; +use namada::ibc::mock::client_state::{client_type, MockClientState}; use namada::ibc::mock::consensus_state::MockConsensusState; use namada::ibc::mock::header::MockHeader; use namada::ibc::Height; use namada::ibc_proto::google::protobuf::Any; -use namada::ibc_proto::ibc::core::commitment::v1::MerkleProof; use namada::ibc_proto::ibc::core::connection::v1::MsgConnectionOpenTry as RawMsgConnectionOpenTry; -use namada::ibc_proto::ics23::CommitmentProof; use namada::ibc_proto::protobuf::Protobuf; use namada::ledger::gas::VpGasMeter; pub use namada::ledger::ibc::storage::{ @@ -294,8 +291,7 @@ pub fn init_storage() -> (Address, Address) { } pub fn client_id() -> ClientId { - let (client_state, _) = dummy_client(); - ClientId::new(client_state.client_type(), 0).expect("invalid client ID") + ClientId::new(client_type(), 0).expect("invalid client ID") } pub fn prepare_client() -> (ClientId, Any, HashMap>) { @@ -305,12 +301,12 @@ pub fn prepare_client() -> (ClientId, Any, HashMap>) { // client state let client_id = client_id(); let key = client_state_key(&client_id); - let bytes = client_state.into_box().encode_vec(); + let bytes = Protobuf::::encode_vec(&client_state); writes.insert(key, bytes); // consensus state let height = client_state.latest_height(); let key = consensus_state_key(&client_id, height); - let bytes = consensus_state.into_box().encode_vec(); + let bytes = Protobuf::::encode_vec(&consensus_state); writes.insert(key, bytes); // client update time let key = client_update_timestamp_key(&client_id); @@ -324,10 +320,7 @@ pub fn prepare_client() -> (ClientId, Any, HashMap>) { .unwrap(); header.time }); - let bytes = TmTime::try_from(time) - .unwrap() - .encode_vec() - .expect("encoding failed"); + let bytes = TmTime::try_from(time).unwrap().encode_vec(); writes.insert(key, bytes); // client update height let key = client_update_height_key(&client_id); @@ -346,10 +339,11 @@ pub fn prepare_client() -> (ClientId, Any, HashMap>) { } fn dummy_client() -> (MockClientState, MockConsensusState) { - let height = Height::new(0, 1).expect("invalid height"); + let height = Height::new(0, 1).unwrap(); let header = MockHeader { height, - timestamp: Timestamp::now(), + // for a past block on the counterparty chain + timestamp: (Timestamp::now() - Duration::from_secs(10)).unwrap(), }; let client_state = MockClientState::new(header); let consensus_state = MockConsensusState::new(header); @@ -422,7 +416,7 @@ pub fn msg_create_client() -> MsgCreateClient { } pub fn msg_update_client(client_id: ClientId) -> MsgUpdateClient { - let height = Height::new(0, 2).expect("invalid height"); + let height = Height::new(0, 2).unwrap(); let header = MockHeader { height, timestamp: Timestamp::now(), @@ -430,37 +424,25 @@ pub fn msg_update_client(client_id: ClientId) -> MsgUpdateClient { .into(); MsgUpdateClient { client_id, - header, + client_message: header, signer: "test".to_string().into(), } } pub fn msg_upgrade_client(client_id: ClientId) -> MsgUpgradeClient { - let height = Height::new(0, 1).expect("invalid height"); - let header = MockHeader { - height, - timestamp: Timestamp::now(), - }; - let client_state = MockClientState::new(header).into(); - let consensus_state = MockConsensusState::new(header).into(); - let proof_upgrade_client = MerkleProof { - proofs: vec![CommitmentProof { proof: None }], - }; - let proof_upgrade_consensus_state = MerkleProof { - proofs: vec![CommitmentProof { proof: None }], - }; + let (client_state, consensus_state) = dummy_client(); MsgUpgradeClient { client_id, - client_state, - consensus_state, - proof_upgrade_client, - proof_upgrade_consensus_state, + upgraded_client_state: client_state.into(), + upgraded_consensus_state: consensus_state.into(), + proof_upgrade_client: dummy_proof(), + proof_upgrade_consensus_state: dummy_proof(), signer: "test".to_string().into(), } } pub fn msg_connection_open_init(client_id: ClientId) -> MsgConnectionOpenInit { - let client_type = ClientType::new(MOCK_CLIENT_TYPE.to_string()).unwrap(); + let client_type = client_type(); let counterparty_client_id = ClientId::new(client_type, 42).unwrap(); let commitment_prefix = CommitmentPrefix::try_from(COMMITMENT_PREFIX.to_vec()).unwrap(); @@ -486,17 +468,18 @@ pub fn msg_connection_open_try( #[allow(deprecated)] RawMsgConnectionOpenTry { client_id: client_id.as_str().to_string(), + previous_connection_id: ConnectionId::default().to_string(), client_state: Some(client_state), counterparty: Some(dummy_connection_counterparty().into()), delay_period: 0, counterparty_versions: vec![ConnVersion::default().into()], - proof_init: dummy_proof().into(), proof_height: Some(dummy_proof_height().into()), + proof_init: dummy_proof().into(), + proof_client: dummy_proof().into(), proof_consensus: dummy_proof().into(), consensus_height: Some(consensus_height.into()), - proof_client: dummy_proof().into(), signer: "test".to_string(), - previous_connection_id: ConnectionId::default().to_string(), + host_consensus_state_proof: dummy_proof().into(), } .try_into() .expect("invalid message") @@ -519,6 +502,7 @@ pub fn msg_connection_open_ack( consensus_height_of_a_on_b: consensus_height, version: ConnVersion::default(), signer: "test".to_string().into(), + proof_consensus_state_of_a: None, } } @@ -542,7 +526,7 @@ fn dummy_proof_height() -> Height { } fn dummy_connection_counterparty() -> ConnCounterparty { - let client_type = ClientType::new(MOCK_CLIENT_TYPE.to_string()).unwrap(); + let client_type = client_type(); let client_id = ClientId::new(client_type, 42).expect("invalid client ID"); let conn_id = ConnectionId::new(12); let commitment_prefix = @@ -677,7 +661,7 @@ pub fn msg_transfer( pub fn set_timeout_timestamp(msg: &mut MsgTransfer) { msg.timeout_timestamp_on_b = - (msg.timeout_timestamp_on_b - Duration::from_secs(101)).unwrap(); + (msg.timeout_timestamp_on_b - Duration::from_secs(201)).unwrap(); } pub fn msg_packet_recv(packet: Packet) -> MsgRecvPacket { @@ -690,10 +674,10 @@ pub fn msg_packet_recv(packet: Packet) -> MsgRecvPacket { } pub fn msg_packet_ack(packet: Packet) -> MsgAcknowledgement { - let packet_ack = TokenTransferAcknowledgement::success(); + let packet_ack = AcknowledgementStatus::success(ack_success_b64()).into(); MsgAcknowledgement { packet, - acknowledgement: packet_ack.into(), + acknowledgement: packet_ack, proof_acked_on_b: dummy_proof(), proof_height_on_b: dummy_proof_height(), signer: "test".to_string().into(), @@ -791,8 +775,11 @@ pub fn balance_key_with_ibc_prefix(denom: String, owner: &Address) -> Key { token::balance_key(&ibc_token, owner) } -pub fn transfer_ack_with_error() -> TokenTransferAcknowledgement { - TokenTransferAcknowledgement::Error( - TokenTransferError::PacketDataDeserialization.to_string(), +pub fn transfer_ack_with_error() -> AcknowledgementStatus { + AcknowledgementStatus::error( + StatusValue::new( + TokenTransferError::PacketDataDeserialization.to_string(), + ) + .expect("Empty message"), ) } diff --git a/tests/src/vm_host_env/mod.rs b/tests/src/vm_host_env/mod.rs index 948692fa70..820624b5a9 100644 --- a/tests/src/vm_host_env/mod.rs +++ b/tests/src/vm_host_env/mod.rs @@ -1033,7 +1033,7 @@ mod tests { let mut actions = tx_host_env::ibc::ibc_actions(tx::ctx()); // the dummy module closes the channel let dummy_module = DummyTransferModule {}; - actions.add_transfer_route(dummy_module.module_id(), dummy_module); + actions.add_transfer_module(dummy_module.module_id(), dummy_module); actions .execute(&tx_data) .expect("closing the channel failed"); diff --git a/tx_prelude/src/ibc.rs b/tx_prelude/src/ibc.rs index 2f19c24a82..dfd0430e5b 100644 --- a/tx_prelude/src/ibc.rs +++ b/tx_prelude/src/ibc.rs @@ -4,81 +4,37 @@ use std::cell::RefCell; use std::rc::Rc; pub use namada_core::ledger::ibc::{ - Error, IbcActions, IbcCommonContext, IbcStorageContext, ProofSpec, - TransferModule, + IbcActions, IbcCommonContext, IbcStorageContext, ProofSpec, TransferModule, }; -use namada_core::ledger::storage_api::{StorageRead, StorageWrite}; use namada_core::ledger::tx_env::TxEnv; use namada_core::types::address::{Address, InternalAddress}; pub use namada_core::types::ibc::{IbcEvent, IbcShieldedTransfer}; -use namada_core::types::storage::{BlockHeight, Header, Key}; use namada_core::types::token::DenominatedAmount; use crate::token::{burn, handle_masp_tx, mint, transfer}; -use crate::{Ctx, KeyValIterator}; +use crate::{Ctx, Error}; /// IBC actions to handle an IBC message pub fn ibc_actions(ctx: &mut Ctx) -> IbcActions { let ctx = Rc::new(RefCell::new(ctx.clone())); let mut actions = IbcActions::new(ctx.clone()); let module = TransferModule::new(ctx); - actions.add_transfer_route(module.module_id(), module); + actions.add_transfer_module(module.module_id(), module); actions } impl IbcStorageContext for Ctx { - type Error = crate::Error; - type PrefixIter<'iter> = KeyValIterator<(String, Vec)>; - - fn read( - &self, - key: &Key, - ) -> std::result::Result>, Self::Error> { - self.read_bytes(key) - } - - fn has_key(&self, key: &Key) -> Result { - ::has_key(self, key) - } - - fn write( - &mut self, - key: &Key, - data: Vec, - ) -> std::result::Result<(), Self::Error> { - self.write_bytes(key, data)?; - Ok(()) - } - - fn iter_prefix<'iter>( - &'iter self, - prefix: &Key, - ) -> Result, Self::Error> { - StorageRead::iter_prefix(self, prefix) - } - - fn iter_next<'iter>( - &'iter self, - iter: &mut Self::PrefixIter<'iter>, - ) -> Result)>, Self::Error> { - StorageRead::iter_next(self, iter) - } - - fn delete(&mut self, key: &Key) -> std::result::Result<(), Self::Error> { - StorageWrite::delete(self, key) - } - fn emit_ibc_event( &mut self, event: IbcEvent, - ) -> std::result::Result<(), Self::Error> { + ) -> std::result::Result<(), Error> { ::emit_ibc_event(self, &event) } fn get_ibc_events( &self, event_type: impl AsRef, - ) -> Result, Self::Error> { + ) -> Result, Error> { ::get_ibc_events(self, &event_type) } @@ -88,14 +44,14 @@ impl IbcStorageContext for Ctx { dest: &Address, token: &Address, amount: DenominatedAmount, - ) -> std::result::Result<(), Self::Error> { + ) -> std::result::Result<(), Error> { transfer(self, src, dest, token, amount) } fn handle_masp_tx( &mut self, shielded: &IbcShieldedTransfer, - ) -> Result<(), Self::Error> { + ) -> Result<(), Error> { handle_masp_tx(self, &shielded.transfer, &shielded.masp_tx) } @@ -104,7 +60,7 @@ impl IbcStorageContext for Ctx { target: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<(), Error> { mint( self, &Address::Internal(InternalAddress::Ibc), @@ -119,21 +75,10 @@ impl IbcStorageContext for Ctx { target: &Address, token: &Address, amount: DenominatedAmount, - ) -> Result<(), Self::Error> { + ) -> Result<(), Error> { burn(self, target, token, amount.amount) } - fn get_height(&self) -> std::result::Result { - self.get_block_height() - } - - fn get_header( - &self, - height: BlockHeight, - ) -> std::result::Result, Self::Error> { - self.get_block_header(height) - } - fn log_string(&self, message: String) { super::log_string(message); } diff --git a/wasm/Cargo.lock b/wasm/Cargo.lock index 9de3599e2a..fe0a5bbab3 100644 --- a/wasm/Cargo.lock +++ b/wasm/Cargo.lock @@ -54,7 +54,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -274,7 +274,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -561,16 +561,6 @@ dependencies = [ "hashbrown 0.11.2", ] -[[package]] -name = "borsh" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" -dependencies = [ - "borsh-derive 0.10.3", - "hashbrown 0.12.3", -] - [[package]] name = "borsh" version = "1.0.0-alpha.4" @@ -587,21 +577,8 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal 0.9.3", - "borsh-schema-derive-internal 0.9.3", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal 0.10.3", - "borsh-schema-derive-internal 0.10.3", + "borsh-derive-internal", + "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.109", @@ -617,7 +594,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", "syn_derive", ] @@ -632,17 +609,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "borsh-ext" version = "1.0.0-alpha.4" @@ -662,17 +628,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "bs58" version = "0.4.0" @@ -780,9 +735,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -920,7 +878,7 @@ dependencies = [ "bs58", "coins-core", "digest 0.10.6", - "getrandom 0.2.9", + "getrandom 0.2.10", "hmac 0.12.1", "k256", "lazy_static", @@ -937,7 +895,7 @@ checksum = "84f4d04ee18e58356accd644896aeb2094ddeafb6a713e056cef0c0a8e468c15" dependencies = [ "bitvec 0.17.4", "coins-bip32", - "getrandom 0.2.9", + "getrandom 0.2.10", "hmac 0.12.1", "once_cell", "pbkdf2 0.12.1", @@ -1238,15 +1196,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df" -[[package]] -name = "ct-logs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" -dependencies = [ - "sct 0.6.1", -] - [[package]] name = "ctr" version = "0.9.2" @@ -1302,7 +1251,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.16", + "strsim", + "syn 2.0.38", ] [[package]] @@ -1313,7 +1263,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1418,7 +1368,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1427,12 +1377,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" -[[package]] -name = "dyn-clone" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" - [[package]] name = "dynasm" version = "1.2.3" @@ -1484,6 +1428,16 @@ dependencies = [ "signature 1.6.4", ] +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature 2.1.0", +] + [[package]] name = "ed25519-consensus" version = "1.2.1" @@ -1499,6 +1453,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -1506,7 +1473,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", - "ed25519", + "ed25519 1.5.3", "merlin", "rand 0.7.3", "serde", @@ -1606,7 +1573,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1615,15 +1582,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" -[[package]] -name = "erased-serde" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2b0c2380453a92ea8b6c8e5f64ecaafccddde8ceab55ff7a8ac1029f894569" -dependencies = [ - "serde", -] - [[package]] name = "errno" version = "0.3.1" @@ -1812,7 +1770,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.16", + "syn 2.0.38", "tokio", "toml 0.7.5", "url", @@ -1832,7 +1790,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1858,7 +1816,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.16", + "syn 2.0.38", "tempfile", "thiserror", "tiny-keccak", @@ -1922,7 +1880,7 @@ dependencies = [ "futures-core", "futures-timer", "futures-util", - "getrandom 0.2.9", + "getrandom 0.2.10", "hashers", "hex", "http", @@ -2090,9 +2048,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -2183,7 +2141,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -2270,9 +2228,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -2424,31 +2382,6 @@ dependencies = [ "fxhash", ] -[[package]] -name = "headers" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" -dependencies = [ - "base64 0.13.1", - "bitflags", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", -] - -[[package]] -name = "headers-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" -dependencies = [ - "http", -] - [[package]] name = "heck" version = "0.4.1" @@ -2580,41 +2513,18 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-proxy" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca815a891b24fdfb243fa3239c86154392b0953ee584aa1a2a1f66d20cbe75cc" -dependencies = [ - "bytes", - "futures", - "headers", - "http", - "hyper", - "hyper-rustls", - "rustls-native-certs", - "tokio", - "tokio-rustls", - "tower-service", - "webpki 0.21.4", -] - [[package]] name = "hyper-rustls" -version = "0.22.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ - "ct-logs", "futures-util", + "http", "hyper", - "log", - "rustls 0.19.1", - "rustls-native-certs", + "rustls 0.21.8", "tokio", "tokio-rustls", - "webpki 0.21.4", - "webpki-roots 0.21.1", ] [[package]] @@ -2642,25 +2552,23 @@ dependencies = [ [[package]] name = "ibc" -version = "0.41.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs.git?rev=206cb5fa74a7ca38038b937d202ae39fbbd63c19#206cb5fa74a7ca38038b937d202ae39fbbd63c19" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "184eb22140cb4143bbcf7ddc8fdfeb9cc058ef73a6066f8ea78162e69d3565d1" dependencies = [ "bytes", - "cfg-if 1.0.0", "derive_more", "displaydoc", - "dyn-clone", - "erased-serde", + "ibc-derive", "ibc-proto", "ics23", "num-traits", "parking_lot", "primitive-types", - "prost", - "safe-regex", + "prost 0.12.1", "serde", + "serde-json-wasm", "serde_derive", - "serde_json", "sha2 0.10.6", "subtle-encoding", "tendermint", @@ -2669,21 +2577,33 @@ dependencies = [ "tendermint-testgen", "time", "tracing", + "typed-builder", "uint", ] +[[package]] +name = "ibc-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92f1528535e9ca495badb76c143bdd4763c1c9d987f59d1f8b47963ba0c11674" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "ibc-proto" -version = "0.30.0" -source = "git+https://github.com/heliaxdev/ibc-proto-rs.git?rev=31892ee743b2af017d5629b2af419ee20b6100c7#31892ee743b2af017d5629b2af419ee20b6100c7" +version = "0.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63042806bb2f662ca1c68026231900cfe13361136ddfd0dd09bcb315056a22b8" dependencies = [ "base64 0.21.0", - "borsh 0.10.3", "bytes", "flex-error", - "parity-scale-codec", - "prost", - "scale-info", + "ics23", + "prost 0.12.1", "serde", "subtle-encoding", "tendermint-proto", @@ -2691,15 +2611,17 @@ dependencies = [ [[package]] name = "ics23" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca44b684ce1859cff746ff46f5765ab72e12e3c06f76a8356db8f9a2ecf43f17" +checksum = "661e2d6f79952a65bc92b1c81f639ebd37228dae6ff412a5aba7d474bdc4b957" dependencies = [ "anyhow", "bytes", "hex", - "prost", + "informalsystems-pbjson", + "prost 0.12.1", "ripemd", + "serde", "sha2 0.10.6", "sha3", ] @@ -2712,9 +2634,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2814,6 +2736,16 @@ dependencies = [ "hashbrown 0.14.0", ] +[[package]] +name = "informalsystems-pbjson" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eecd90f87bea412eac91c6ef94f6b1e390128290898cbe14f2b926787ae1fb" +dependencies = [ + "base64 0.13.1", + "serde", +] + [[package]] name = "inout" version = "0.1.3" @@ -2958,9 +2890,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libloading" @@ -3099,7 +3031,7 @@ dependencies = [ "blake2b_simd", "bls12_381", "directories", - "getrandom 0.2.9", + "getrandom 0.2.10", "group", "itertools 0.11.0", "jubjub", @@ -3223,8 +3155,8 @@ dependencies = [ "log", "once_cell", "rustls 0.20.8", - "webpki 0.22.0", - "webpki-roots 0.22.6", + "webpki", + "webpki-roots", ] [[package]] @@ -3289,7 +3221,7 @@ dependencies = [ "parse_duration", "paste", "proptest", - "prost", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "rayon", @@ -3331,7 +3263,7 @@ dependencies = [ "chrono", "data-encoding", "derivative", - "ed25519-consensus", + "ed25519-consensus 1.2.1", "ethabi", "ethbridge-structs", "eyre", @@ -3339,6 +3271,7 @@ dependencies = [ "ferveo-common", "group-threshold-cryptography", "ibc", + "ibc-derive", "ibc-proto", "ics23", "impl-num-traits", @@ -3353,8 +3286,8 @@ dependencies = [ "num256", "primitive-types", "proptest", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "rayon", @@ -3441,7 +3374,7 @@ dependencies = [ "owo-colors", "parse_duration", "paste", - "prost", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "ripemd", @@ -3488,7 +3421,7 @@ dependencies = [ "namada_tx_prelude", "namada_vp_prelude", "num-traits", - "prost", + "prost 0.12.1", "regex", "serde", "serde_json", @@ -3544,7 +3477,7 @@ name = "namada_wasm" version = "0.25.0" dependencies = [ "borsh 1.0.0-alpha.4", - "getrandom 0.2.9", + "getrandom 0.2.10", "masp_primitives", "namada", "namada_test_utils", @@ -3742,7 +3675,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -3822,7 +3755,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6624905ddd92e460ff0685567539ed1ac985b2dee4c92c7edcd64fce905b00c" dependencies = [ "ct-codecs", - "getrandom 0.2.9", + "getrandom 0.2.10", "subtle 2.4.1", "zeroize", ] @@ -4005,9 +3938,9 @@ checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" @@ -4115,7 +4048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" dependencies = [ "proc-macro2", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -4177,9 +4110,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -4211,7 +4144,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +dependencies = [ + "bytes", + "prost-derive 0.12.1", ] [[package]] @@ -4228,8 +4171,8 @@ dependencies = [ "multimap", "petgraph", "prettyplease 0.1.25", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "regex", "syn 1.0.109", "tempfile", @@ -4249,13 +4192,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +dependencies = [ + "anyhow", + "itertools 0.11.0", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", +] + +[[package]] +name = "prost-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf" +dependencies = [ + "prost 0.12.1", ] [[package]] @@ -4286,9 +4251,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.27" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -4364,7 +4329,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -4464,7 +4429,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] @@ -4535,9 +4500,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "base64 0.21.0", "bytes", @@ -4548,6 +4513,7 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-rustls", "ipnet", "js-sys", "log", @@ -4555,10 +4521,15 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls 0.21.8", + "rustls-native-certs", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", @@ -4586,12 +4557,26 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom 0.2.10", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -4700,41 +4685,59 @@ dependencies = [ [[package]] name = "rustls" -version = "0.19.1" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ - "base64 0.13.1", "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", + "ring 0.16.20", + "sct", + "webpki", ] [[package]] name = "rustls" -version = "0.20.8" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring", - "sct 0.7.0", - "webpki 0.22.0", + "ring 0.17.5", + "rustls-webpki", + "sct", ] [[package]] name = "rustls-native-certs" -version = "0.5.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls 0.19.1", + "rustls-pemfile", "schannel", "security-framework", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.0", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.12" @@ -4759,53 +4762,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "safe-proc-macro2" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "814c536dcd27acf03296c618dab7ad62d28e70abd7ba41d3f34a2ce707a2c666" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "safe-quote" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e530f7831f3feafcd5f1aae406ac205dd998436b4007c8e80f03eca78a88f7" -dependencies = [ - "safe-proc-macro2", -] - -[[package]] -name = "safe-regex" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15289bf322e0673d52756a18194167f2378ec1a15fe884af6e2d2cb934822b0" -dependencies = [ - "safe-regex-macro", -] - -[[package]] -name = "safe-regex-compiler" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba76fae590a2aa665279deb1f57b5098cbace01a0c5e60e262fcf55f7c51542" -dependencies = [ - "safe-proc-macro2", - "safe-quote", -] - -[[package]] -name = "safe-regex-macro" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c2e96b5c03f158d1b16ba79af515137795f4ad4e8de3f790518aae91f1d127" -dependencies = [ - "safe-proc-macro2", - "safe-regex-compiler", -] - [[package]] name = "salsa20" version = "0.10.2" @@ -4875,24 +4831,14 @@ dependencies = [ "sha2 0.10.6", ] -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -4980,13 +4926,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" +dependencies = [ + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.9" @@ -5008,13 +4963,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5036,7 +4991,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5070,17 +5025,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.6", -] - [[package]] name = "sha2" version = "0.8.2" @@ -5210,7 +5154,7 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=df7ec062e7c40d5e76b136064e9aaf8bd2490750#df7ec062e7c40d5e76b136064e9aaf8bd2490750" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=aed81070ce2c83a41e1c6bada757347f33ef8eb6#aed81070ce2c83a41e1c6bada757347f33ef8eb6" dependencies = [ "borsh 1.0.0-alpha.4", "cfg-if 1.0.0", @@ -5224,6 +5168,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.2" @@ -5327,9 +5277,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.16" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -5345,7 +5295,28 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", ] [[package]] @@ -5375,25 +5346,26 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc2294fa667c8b548ee27a9ba59115472d0a09c2ba255771092a7f1dcf03a789" dependencies = [ - "async-trait", "bytes", - "ed25519", - "ed25519-dalek", + "digest 0.10.6", + "ed25519 2.2.3", + "ed25519-consensus 2.1.0", "flex-error", "futures", "num-traits", "once_cell", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "serde", "serde_bytes", "serde_json", "serde_repr", - "sha2 0.9.9", - "signature 1.6.4", + "sha2 0.10.6", + "signature 2.1.0", "subtle 2.4.1", "subtle-encoding", "tendermint-proto", @@ -5403,8 +5375,9 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a25dbe8b953e80f3d61789fbdb83bf9ad6c0ef16df5ca6546f49912542cc137" dependencies = [ "flex-error", "serde", @@ -5416,29 +5389,34 @@ dependencies = [ [[package]] name = "tendermint-light-client" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94aecbdccbc4b557649b2d1b1a4bfc27ec85205e00fb8020fce044245a4c9e3f" dependencies = [ "contracts", "crossbeam-channel 0.4.4", "derive_more", "flex-error", "futures", + "regex", "serde", "serde_cbor", "serde_derive", + "serde_json", "static_assertions", "tendermint", "tendermint-light-client-verifier", "tendermint-rpc", "time", "tokio", + "tracing", ] [[package]] name = "tendermint-light-client-verifier" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74994da9de4b1144837a367ca2c60c650f5526a7c1a54760a3020959b522e474" dependencies = [ "derive_more", "flex-error", @@ -5449,15 +5427,16 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc728a4f9e891d71adf66af6ecaece146f9c7a11312288a3107b3e1d6979aaf" dependencies = [ "bytes", "flex-error", "num-derive", "num-traits", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "serde", "serde_bytes", "subtle-encoding", @@ -5466,23 +5445,23 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbf0a4753b46a190f367337e0163d0b552a2674a6bac54e74f9f2cdcde2969b" dependencies = [ "async-trait", "bytes", "flex-error", "futures", - "getrandom 0.2.9", - "http", - "hyper", - "hyper-proxy", - "hyper-rustls", + "getrandom 0.2.10", "peg", "pin-project", + "reqwest", + "semver 1.0.17", "serde", "serde_bytes", "serde_json", + "subtle 2.4.1", "subtle-encoding", "tendermint", "tendermint-config", @@ -5498,10 +5477,11 @@ dependencies = [ [[package]] name = "tendermint-testgen" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19d4f02b7e38ce790da973fdc9edc71a0e35340ac57737bf278c8379037c1f5" dependencies = [ - "ed25519-dalek", + "ed25519-consensus 2.1.0", "gumdrop", "serde", "serde_json", @@ -5539,7 +5519,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5660,18 +5640,17 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] name = "tokio-rustls" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.19.1", + "rustls 0.21.8", "tokio", - "webpki 0.21.4", ] [[package]] @@ -5771,7 +5750,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5819,12 +5798,32 @@ name = "tx_template" version = "0.25.0" dependencies = [ "borsh 1.0.0-alpha.4", - "getrandom 0.2.9", + "getrandom 0.2.10", "namada_tests", "namada_tx_prelude", "wee_alloc", ] +[[package]] +name = "typed-builder" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c6a006a6d3d6a6f143fda41cf4d1ad35110080687628c9f2117bd3cc7924f3" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa054ee5e2346187d631d2f1d1fd3b33676772d6d03a2d84e1c5213b31674ee" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "typenum" version = "1.16.0" @@ -5904,11 +5903,17 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" -version = "2.3.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -5927,7 +5932,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "serde", ] @@ -5942,7 +5947,7 @@ name = "vp_template" version = "0.25.0" dependencies = [ "borsh 1.0.0-alpha.4", - "getrandom 0.2.9", + "getrandom 0.2.10", "namada_tests", "namada_vp_prelude", "wee_alloc", @@ -6010,7 +6015,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -6044,7 +6049,7 @@ checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6382,33 +6387,14 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" -dependencies = [ - "webpki 0.21.4", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -6417,7 +6403,7 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki", ] [[package]] @@ -6684,11 +6670,12 @@ dependencies = [ [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if 1.0.0", + "windows-sys 0.48.0", ] [[package]] @@ -6745,5 +6732,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] diff --git a/wasm_for_tests/wasm_source/Cargo.lock b/wasm_for_tests/wasm_source/Cargo.lock index 6f8992a3f2..40bdada960 100644 --- a/wasm_for_tests/wasm_source/Cargo.lock +++ b/wasm_for_tests/wasm_source/Cargo.lock @@ -54,7 +54,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "once_cell", "version_check", ] @@ -274,7 +274,7 @@ checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -561,16 +561,6 @@ dependencies = [ "hashbrown 0.11.2", ] -[[package]] -name = "borsh" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" -dependencies = [ - "borsh-derive 0.10.3", - "hashbrown 0.12.3", -] - [[package]] name = "borsh" version = "1.0.0-alpha.4" @@ -587,21 +577,8 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ - "borsh-derive-internal 0.9.3", - "borsh-schema-derive-internal 0.9.3", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "borsh-derive" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" -dependencies = [ - "borsh-derive-internal 0.10.3", - "borsh-schema-derive-internal 0.10.3", + "borsh-derive-internal", + "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.109", @@ -617,7 +594,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", "syn_derive", ] @@ -632,17 +609,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "borsh-ext" version = "1.0.0-alpha.4" @@ -662,17 +628,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "borsh-schema-derive-internal" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "bs58" version = "0.4.0" @@ -780,9 +735,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -920,7 +878,7 @@ dependencies = [ "bs58", "coins-core", "digest 0.10.6", - "getrandom 0.2.9", + "getrandom 0.2.10", "hmac 0.12.1", "k256", "lazy_static", @@ -937,7 +895,7 @@ checksum = "84f4d04ee18e58356accd644896aeb2094ddeafb6a713e056cef0c0a8e468c15" dependencies = [ "bitvec 0.17.4", "coins-bip32", - "getrandom 0.2.9", + "getrandom 0.2.10", "hmac 0.12.1", "once_cell", "pbkdf2 0.12.1", @@ -1238,15 +1196,6 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3b7eb4404b8195a9abb6356f4ac07d8ba267045c8d6d220ac4dc992e6cc75df" -[[package]] -name = "ct-logs" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1a816186fa68d9e426e3cb4ae4dff1fcd8e4a2c34b781bf7a822574a0d0aac8" -dependencies = [ - "sct 0.6.1", -] - [[package]] name = "ctr" version = "0.9.2" @@ -1302,7 +1251,8 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "syn 2.0.16", + "strsim", + "syn 2.0.38", ] [[package]] @@ -1313,7 +1263,7 @@ checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1418,7 +1368,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1427,12 +1377,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" -[[package]] -name = "dyn-clone" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" - [[package]] name = "dynasm" version = "1.2.3" @@ -1484,6 +1428,16 @@ dependencies = [ "signature 1.6.4", ] +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature 2.1.0", +] + [[package]] name = "ed25519-consensus" version = "1.2.1" @@ -1499,6 +1453,19 @@ dependencies = [ "zeroize", ] +[[package]] +name = "ed25519-consensus" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + [[package]] name = "ed25519-dalek" version = "1.0.1" @@ -1506,7 +1473,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", - "ed25519", + "ed25519 1.5.3", "merlin", "rand 0.7.3", "serde", @@ -1606,7 +1573,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1615,15 +1582,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" -[[package]] -name = "erased-serde" -version = "0.3.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2b0c2380453a92ea8b6c8e5f64ecaafccddde8ceab55ff7a8ac1029f894569" -dependencies = [ - "serde", -] - [[package]] name = "errno" version = "0.3.1" @@ -1812,7 +1770,7 @@ dependencies = [ "reqwest", "serde", "serde_json", - "syn 2.0.16", + "syn 2.0.38", "tokio", "toml 0.7.5", "url", @@ -1832,7 +1790,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -1858,7 +1816,7 @@ dependencies = [ "serde", "serde_json", "strum", - "syn 2.0.16", + "syn 2.0.38", "tempfile", "thiserror", "tiny-keccak", @@ -1922,7 +1880,7 @@ dependencies = [ "futures-core", "futures-timer", "futures-util", - "getrandom 0.2.9", + "getrandom 0.2.10", "hashers", "hex", "http", @@ -2090,9 +2048,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -2183,7 +2141,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -2270,9 +2228,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -2424,31 +2382,6 @@ dependencies = [ "fxhash", ] -[[package]] -name = "headers" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3e372db8e5c0d213e0cd0b9be18be2aca3d44cf2fe30a9d46a65581cd454584" -dependencies = [ - "base64 0.13.1", - "bitflags", - "bytes", - "headers-core", - "http", - "httpdate", - "mime", - "sha1", -] - -[[package]] -name = "headers-core" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7f66481bfee273957b1f20485a4ff3362987f85b2c236580d81b4eb7a326429" -dependencies = [ - "http", -] - [[package]] name = "heck" version = "0.4.1" @@ -2580,41 +2513,18 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-proxy" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca815a891b24fdfb243fa3239c86154392b0953ee584aa1a2a1f66d20cbe75cc" -dependencies = [ - "bytes", - "futures", - "headers", - "http", - "hyper", - "hyper-rustls", - "rustls-native-certs", - "tokio", - "tokio-rustls", - "tower-service", - "webpki 0.21.4", -] - [[package]] name = "hyper-rustls" -version = "0.22.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f7a97316d44c0af9b0301e65010573a853a9fc97046d7331d7f6bc0fd5a64" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ - "ct-logs", "futures-util", + "http", "hyper", - "log", - "rustls 0.19.1", - "rustls-native-certs", + "rustls 0.21.8", "tokio", "tokio-rustls", - "webpki 0.21.4", - "webpki-roots 0.21.1", ] [[package]] @@ -2642,25 +2552,23 @@ dependencies = [ [[package]] name = "ibc" -version = "0.41.0" -source = "git+https://github.com/heliaxdev/cosmos-ibc-rs.git?rev=206cb5fa74a7ca38038b937d202ae39fbbd63c19#206cb5fa74a7ca38038b937d202ae39fbbd63c19" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "184eb22140cb4143bbcf7ddc8fdfeb9cc058ef73a6066f8ea78162e69d3565d1" dependencies = [ "bytes", - "cfg-if 1.0.0", "derive_more", "displaydoc", - "dyn-clone", - "erased-serde", + "ibc-derive", "ibc-proto", "ics23", "num-traits", "parking_lot", "primitive-types", - "prost", - "safe-regex", + "prost 0.12.1", "serde", + "serde-json-wasm", "serde_derive", - "serde_json", "sha2 0.10.6", "subtle-encoding", "tendermint", @@ -2669,21 +2577,33 @@ dependencies = [ "tendermint-testgen", "time", "tracing", + "typed-builder", "uint", ] +[[package]] +name = "ibc-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92f1528535e9ca495badb76c143bdd4763c1c9d987f59d1f8b47963ba0c11674" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "ibc-proto" -version = "0.30.0" -source = "git+https://github.com/heliaxdev/ibc-proto-rs.git?rev=31892ee743b2af017d5629b2af419ee20b6100c7#31892ee743b2af017d5629b2af419ee20b6100c7" +version = "0.37.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63042806bb2f662ca1c68026231900cfe13361136ddfd0dd09bcb315056a22b8" dependencies = [ "base64 0.21.0", - "borsh 0.10.3", "bytes", "flex-error", - "parity-scale-codec", - "prost", - "scale-info", + "ics23", + "prost 0.12.1", "serde", "subtle-encoding", "tendermint-proto", @@ -2691,15 +2611,17 @@ dependencies = [ [[package]] name = "ics23" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca44b684ce1859cff746ff46f5765ab72e12e3c06f76a8356db8f9a2ecf43f17" +checksum = "661e2d6f79952a65bc92b1c81f639ebd37228dae6ff412a5aba7d474bdc4b957" dependencies = [ "anyhow", "bytes", "hex", - "prost", + "informalsystems-pbjson", + "prost 0.12.1", "ripemd", + "serde", "sha2 0.10.6", "sha3", ] @@ -2712,9 +2634,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2814,6 +2736,16 @@ dependencies = [ "hashbrown 0.14.0", ] +[[package]] +name = "informalsystems-pbjson" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4eecd90f87bea412eac91c6ef94f6b1e390128290898cbe14f2b926787ae1fb" +dependencies = [ + "base64 0.13.1", + "serde", +] + [[package]] name = "inout" version = "0.1.3" @@ -2958,9 +2890,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.144" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libloading" @@ -3099,7 +3031,7 @@ dependencies = [ "blake2b_simd", "bls12_381", "directories", - "getrandom 0.2.9", + "getrandom 0.2.10", "group", "itertools 0.11.0", "jubjub", @@ -3223,8 +3155,8 @@ dependencies = [ "log", "once_cell", "rustls 0.20.8", - "webpki 0.22.0", - "webpki-roots 0.22.6", + "webpki", + "webpki-roots", ] [[package]] @@ -3289,7 +3221,7 @@ dependencies = [ "parse_duration", "paste", "proptest", - "prost", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "rayon", @@ -3331,7 +3263,7 @@ dependencies = [ "chrono", "data-encoding", "derivative", - "ed25519-consensus", + "ed25519-consensus 1.2.1", "ethabi", "ethbridge-structs", "eyre", @@ -3339,6 +3271,7 @@ dependencies = [ "ferveo-common", "group-threshold-cryptography", "ibc", + "ibc-derive", "ibc-proto", "ics23", "impl-num-traits", @@ -3353,8 +3286,8 @@ dependencies = [ "num256", "primitive-types", "proptest", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "rayon", @@ -3441,7 +3374,7 @@ dependencies = [ "owo-colors", "parse_duration", "paste", - "prost", + "prost 0.12.1", "rand 0.8.5", "rand_core 0.6.4", "ripemd", @@ -3488,7 +3421,7 @@ dependencies = [ "namada_tx_prelude", "namada_vp_prelude", "num-traits", - "prost", + "prost 0.12.1", "regex", "serde", "serde_json", @@ -3544,7 +3477,7 @@ name = "namada_wasm_for_tests" version = "0.25.0" dependencies = [ "borsh 1.0.0-alpha.4", - "getrandom 0.2.9", + "getrandom 0.2.10", "namada_test_utils", "namada_tests", "namada_tx_prelude", @@ -3735,7 +3668,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -3815,7 +3748,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6624905ddd92e460ff0685567539ed1ac985b2dee4c92c7edcd64fce905b00c" dependencies = [ "ct-codecs", - "getrandom 0.2.9", + "getrandom 0.2.10", "subtle 2.4.1", "zeroize", ] @@ -3998,9 +3931,9 @@ checksum = "c719dcf55f09a3a7e764c6649ab594c18a177e3599c467983cdf644bfc0a4088" [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" @@ -4108,7 +4041,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9825a04601d60621feed79c4e6b56d65db77cdca55cef43b46b0de1096d1c282" dependencies = [ "proc-macro2", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -4170,9 +4103,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -4204,7 +4137,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.9", +] + +[[package]] +name = "prost" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +dependencies = [ + "bytes", + "prost-derive 0.12.1", ] [[package]] @@ -4221,8 +4164,8 @@ dependencies = [ "multimap", "petgraph", "prettyplease 0.1.25", - "prost", - "prost-types", + "prost 0.11.9", + "prost-types 0.11.9", "regex", "syn 1.0.109", "tempfile", @@ -4242,13 +4185,35 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "prost-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +dependencies = [ + "anyhow", + "itertools 0.11.0", + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "prost-types" version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ - "prost", + "prost 0.11.9", +] + +[[package]] +name = "prost-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf" +dependencies = [ + "prost 0.12.1", ] [[package]] @@ -4279,9 +4244,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.27" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -4357,7 +4322,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", ] [[package]] @@ -4457,7 +4422,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "redox_syscall 0.2.16", "thiserror", ] @@ -4528,9 +4493,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ "base64 0.21.0", "bytes", @@ -4541,6 +4506,7 @@ dependencies = [ "http", "http-body", "hyper", + "hyper-rustls", "ipnet", "js-sys", "log", @@ -4548,10 +4514,15 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "rustls 0.21.8", + "rustls-native-certs", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", + "tokio-rustls", "tower-service", "url", "wasm-bindgen", @@ -4579,12 +4550,26 @@ dependencies = [ "cc", "libc", "once_cell", - "spin", - "untrusted", + "spin 0.5.2", + "untrusted 0.7.1", "web-sys", "winapi", ] +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom 0.2.10", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + [[package]] name = "ripemd" version = "0.1.3" @@ -4693,41 +4678,59 @@ dependencies = [ [[package]] name = "rustls" -version = "0.19.1" +version = "0.20.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" dependencies = [ - "base64 0.13.1", "log", - "ring", - "sct 0.6.1", - "webpki 0.21.4", + "ring 0.16.20", + "sct", + "webpki", ] [[package]] name = "rustls" -version = "0.20.8" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring", - "sct 0.7.0", - "webpki 0.22.0", + "ring 0.17.5", + "rustls-webpki", + "sct", ] [[package]] name = "rustls-native-certs" -version = "0.5.0" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a07b7c1885bd8ed3831c289b7870b13ef46fe0e856d288c30d9cc17d75a2092" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls 0.19.1", + "rustls-pemfile", "schannel", "security-framework", ] +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.0", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.12" @@ -4752,53 +4755,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" -[[package]] -name = "safe-proc-macro2" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "814c536dcd27acf03296c618dab7ad62d28e70abd7ba41d3f34a2ce707a2c666" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "safe-quote" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77e530f7831f3feafcd5f1aae406ac205dd998436b4007c8e80f03eca78a88f7" -dependencies = [ - "safe-proc-macro2", -] - -[[package]] -name = "safe-regex" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15289bf322e0673d52756a18194167f2378ec1a15fe884af6e2d2cb934822b0" -dependencies = [ - "safe-regex-macro", -] - -[[package]] -name = "safe-regex-compiler" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba76fae590a2aa665279deb1f57b5098cbace01a0c5e60e262fcf55f7c51542" -dependencies = [ - "safe-proc-macro2", - "safe-quote", -] - -[[package]] -name = "safe-regex-macro" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96c2e96b5c03f158d1b16ba79af515137795f4ad4e8de3f790518aae91f1d127" -dependencies = [ - "safe-proc-macro2", - "safe-regex-compiler", -] - [[package]] name = "salsa20" version = "0.10.2" @@ -4868,24 +4824,14 @@ dependencies = [ "sha2 0.10.6", ] -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "sct" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" dependencies = [ - "ring", - "untrusted", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -4973,13 +4919,22 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.163" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] +[[package]] +name = "serde-json-wasm" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83c37d03f3b0f6b5f77c11af1e7c772de1c9af83e50bef7bb6069601900ba67b" +dependencies = [ + "serde", +] + [[package]] name = "serde_bytes" version = "0.11.9" @@ -5001,13 +4956,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.163" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5029,7 +4984,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5063,17 +5018,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sha1" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" -dependencies = [ - "cfg-if 1.0.0", - "cpufeatures", - "digest 0.10.6", -] - [[package]] name = "sha2" version = "0.8.2" @@ -5203,7 +5147,7 @@ dependencies = [ [[package]] name = "sparse-merkle-tree" version = "0.3.1-pre" -source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=df7ec062e7c40d5e76b136064e9aaf8bd2490750#df7ec062e7c40d5e76b136064e9aaf8bd2490750" +source = "git+https://github.com/heliaxdev/sparse-merkle-tree?rev=aed81070ce2c83a41e1c6bada757347f33ef8eb6#aed81070ce2c83a41e1c6bada757347f33ef8eb6" dependencies = [ "borsh 1.0.0-alpha.4", "cfg-if 1.0.0", @@ -5217,6 +5161,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.2" @@ -5320,9 +5270,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.16" +version = "2.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" +checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" dependencies = [ "proc-macro2", "quote", @@ -5338,7 +5288,28 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", ] [[package]] @@ -5368,25 +5339,26 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc2294fa667c8b548ee27a9ba59115472d0a09c2ba255771092a7f1dcf03a789" dependencies = [ - "async-trait", "bytes", - "ed25519", - "ed25519-dalek", + "digest 0.10.6", + "ed25519 2.2.3", + "ed25519-consensus 2.1.0", "flex-error", "futures", "num-traits", "once_cell", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "serde", "serde_bytes", "serde_json", "serde_repr", - "sha2 0.9.9", - "signature 1.6.4", + "sha2 0.10.6", + "signature 2.1.0", "subtle 2.4.1", "subtle-encoding", "tendermint-proto", @@ -5396,8 +5368,9 @@ dependencies = [ [[package]] name = "tendermint-config" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a25dbe8b953e80f3d61789fbdb83bf9ad6c0ef16df5ca6546f49912542cc137" dependencies = [ "flex-error", "serde", @@ -5409,29 +5382,34 @@ dependencies = [ [[package]] name = "tendermint-light-client" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94aecbdccbc4b557649b2d1b1a4bfc27ec85205e00fb8020fce044245a4c9e3f" dependencies = [ "contracts", "crossbeam-channel 0.4.4", "derive_more", "flex-error", "futures", + "regex", "serde", "serde_cbor", "serde_derive", + "serde_json", "static_assertions", "tendermint", "tendermint-light-client-verifier", "tendermint-rpc", "time", "tokio", + "tracing", ] [[package]] name = "tendermint-light-client-verifier" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74994da9de4b1144837a367ca2c60c650f5526a7c1a54760a3020959b522e474" dependencies = [ "derive_more", "flex-error", @@ -5442,15 +5420,16 @@ dependencies = [ [[package]] name = "tendermint-proto" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc728a4f9e891d71adf66af6ecaece146f9c7a11312288a3107b3e1d6979aaf" dependencies = [ "bytes", "flex-error", "num-derive", "num-traits", - "prost", - "prost-types", + "prost 0.12.1", + "prost-types 0.12.1", "serde", "serde_bytes", "subtle-encoding", @@ -5459,23 +5438,23 @@ dependencies = [ [[package]] name = "tendermint-rpc" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbf0a4753b46a190f367337e0163d0b552a2674a6bac54e74f9f2cdcde2969b" dependencies = [ "async-trait", "bytes", "flex-error", "futures", - "getrandom 0.2.9", - "http", - "hyper", - "hyper-proxy", - "hyper-rustls", + "getrandom 0.2.10", "peg", "pin-project", + "reqwest", + "semver 1.0.17", "serde", "serde_bytes", "serde_json", + "subtle 2.4.1", "subtle-encoding", "tendermint", "tendermint-config", @@ -5491,10 +5470,11 @@ dependencies = [ [[package]] name = "tendermint-testgen" -version = "0.23.6" -source = "git+https://github.com/heliaxdev/tendermint-rs.git?rev=b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7#b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7" +version = "0.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19d4f02b7e38ce790da973fdc9edc71a0e35340ac57737bf278c8379037c1f5" dependencies = [ - "ed25519-dalek", + "ed25519-consensus 2.1.0", "gumdrop", "serde", "serde_json", @@ -5532,7 +5512,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5653,18 +5633,17 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] name = "tokio-rustls" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.19.1", + "rustls 0.21.8", "tokio", - "webpki 0.21.4", ] [[package]] @@ -5764,7 +5743,7 @@ checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ] [[package]] @@ -5807,6 +5786,26 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "typed-builder" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c6a006a6d3d6a6f143fda41cf4d1ad35110080687628c9f2117bd3cc7924f3" +dependencies = [ + "typed-builder-macro", +] + +[[package]] +name = "typed-builder-macro" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa054ee5e2346187d631d2f1d1fd3b33676772d6d03a2d84e1c5213b31674ee" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "typenum" version = "1.16.0" @@ -5886,11 +5885,17 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + [[package]] name = "url" -version = "2.3.1" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -5909,7 +5914,7 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "getrandom 0.2.9", + "getrandom 0.2.10", "serde", ] @@ -5981,7 +5986,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", "wasm-bindgen-shared", ] @@ -6015,7 +6020,7 @@ checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6353,33 +6358,14 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring", - "untrusted", -] - [[package]] name = "webpki" version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" dependencies = [ - "ring", - "untrusted", -] - -[[package]] -name = "webpki-roots" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940" -dependencies = [ - "webpki 0.21.4", + "ring 0.16.20", + "untrusted 0.7.1", ] [[package]] @@ -6388,7 +6374,7 @@ version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" dependencies = [ - "webpki 0.22.0", + "webpki", ] [[package]] @@ -6655,11 +6641,12 @@ dependencies = [ [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if 1.0.0", + "windows-sys 0.48.0", ] [[package]] @@ -6716,5 +6703,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.16", + "syn 2.0.38", ]