diff --git a/CHANGELOG.md b/CHANGELOG.md index 64b76882..2530d4a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -379,7 +379,7 @@ The validator state files use an incompatible syntax from Tendermint KMS v0.5. It has been changed to match the conventions used by the rest of Tendermint, where integer values are stored in strings rather than JSON integers. -When upgrading, you will need to either *delete existing state files* +When upgrading, you will need to either *delete existing state files* (they will be recreated automatically), or ensure the integer `height` and `round` fields contained within these files are quoted in strings, e.g. `{"height":"123456","round":"0",...}`. @@ -476,7 +476,7 @@ section in the Tendermint KMS YubiHSM docs: ## 0.3.0 (2019-01-23) - Add ability to terminate on SIGTERM or SIGINT -- Remove `PoisonPillMsg` +- Remove `PoisonPillMsg` ## 0.2.4 (2019-01-18) diff --git a/Cargo.lock b/Cargo.lock index 8bc9684d..e0e068e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "cipher", "cpufeatures", ] @@ -103,9 +103,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.19" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192" dependencies = [ "anstyle", "anstyle-parse", @@ -133,22 +133,22 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2" dependencies = [ - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "anstyle-wincon" -version = "3.0.9" +version = "3.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a" dependencies = [ "anstyle", "once_cell_polyfill", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -182,12 +182,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", - "cfg-if 1.0.0", + "cfg-if 1.0.1", "libc", "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -239,9 +239,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "block-buffer" @@ -317,9 +317,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.30" +version = "1.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" +checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" dependencies = [ "shlex", ] @@ -344,9 +344,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "chacha20" @@ -354,7 +354,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "cipher", "cpufeatures", ] @@ -405,9 +405,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.42" +version = "4.5.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" +checksum = "50fd97c9dc2399518aa331917ac6f274280ec5eb34e555dd291899745c48ec6f" dependencies = [ "clap_builder", "clap_derive", @@ -415,9 +415,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.42" +version = "4.5.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +checksum = "c35b5830294e1fa0462034af85cc95225a4cb07092c088c55bda3147cfcd8f65" dependencies = [ "anstream", "anstyle", @@ -434,7 +434,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -473,6 +473,62 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" +[[package]] +name = "cometbft" +version = "0.1.0-alpha.2" +source = "git+https://github.com/cometbft/cometbft-rs.git?rev=71af716216216cfdc150cacef5ceae3610a5824b#71af716216216cfdc150cacef5ceae3610a5824b" +dependencies = [ + "bytes", + "cometbft-proto", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", + "flex-error", + "futures", + "k256", + "num-traits", + "once_cell", + "prost 0.13.5", + "ripemd", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2 0.10.9", + "signature", + "subtle", + "subtle-encoding", + "time", + "zeroize", +] + +[[package]] +name = "cometbft-config" +version = "0.1.0-alpha.2" +source = "git+https://github.com/cometbft/cometbft-rs.git?rev=71af716216216cfdc150cacef5ceae3610a5824b#71af716216216cfdc150cacef5ceae3610a5824b" +dependencies = [ + "cometbft", + "flex-error", + "serde", + "serde_json", + "toml", + "url 2.5.4", +] + +[[package]] +name = "cometbft-proto" +version = "0.1.0-alpha.2" +source = "git+https://github.com/cometbft/cometbft-rs.git?rev=71af716216216cfdc150cacef5ceae3610a5824b#71af716216216cfdc150cacef5ceae3610a5824b" +dependencies = [ + "bytes", + "flex-error", + "prost 0.13.5", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + [[package]] name = "const-oid" version = "0.9.6" @@ -501,8 +557,8 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95ac39be7373404accccaede7cc1ec942ccef14f0ca18d209967a756bf1dbb1f" dependencies = [ - "prost", - "tendermint-proto", + "prost 0.13.5", + "tendermint-proto 0.40.4", ] [[package]] @@ -521,7 +577,7 @@ dependencies = [ "serde_json", "signature", "subtle-encoding", - "tendermint", + "tendermint 0.40.4", "thiserror", ] @@ -572,7 +628,7 @@ version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "cpufeatures", "curve25519-dalek-derive", "digest 0.10.7", @@ -590,7 +646,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -664,7 +720,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -759,7 +815,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -964,18 +1020,18 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "libc", "wasi 0.11.1+wasi-snapshot-preview1", ] [[package]] name = "getrandom" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "libc", "r-efi", "wasi 0.14.2+wasi-0.2.4", @@ -1019,9 +1075,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.4" +version = "0.15.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" [[package]] name = "headers" @@ -1316,9 +1372,9 @@ dependencies = [ [[package]] name = "indenter" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" +checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" [[package]] name = "indexmap" @@ -1346,8 +1402,8 @@ version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4" dependencies = [ - "bitflags 2.9.0", - "cfg-if 1.0.0", + "bitflags 2.9.1", + "cfg-if 1.0.1", "libc", ] @@ -1357,6 +1413,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -1388,7 +1453,7 @@ version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "ecdsa", "elliptic-curve", "once_cell", @@ -1578,6 +1643,17 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1620,8 +1696,8 @@ version = "0.10.73" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" dependencies = [ - "bitflags 2.9.0", - "cfg-if 1.0.0", + "bitflags 2.9.1", + "cfg-if 1.0.1", "foreign-types", "libc", "once_cell", @@ -1637,7 +1713,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -1796,13 +1872,23 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "beef09f85ae72cea1ef96ba6870c51e6382ebfa4f0e85b643459331f3daa5be0" dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive 0.12.6", +] + [[package]] name = "prost" version = "0.13.5" @@ -1810,7 +1896,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2796faa41db3ec313a31f7624d9286acf277b52de526150b7e69f3debf891ee5" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.13.5", +] + +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.104", ] [[package]] @@ -1820,10 +1919,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools", + "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", +] + +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost 0.12.6", ] [[package]] @@ -1992,18 +2100,18 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "rustversion" -version = "1.0.21" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "ryu" @@ -2093,7 +2201,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "core-foundation", "core-foundation-sys", "libc", @@ -2145,14 +2253,14 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] name = "serde_json" -version = "1.0.140" +version = "1.0.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" dependencies = [ "itoa", "memchr", @@ -2168,7 +2276,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2186,7 +2294,7 @@ version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "cpufeatures", "digest 0.10.7", ] @@ -2198,7 +2306,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", - "cfg-if 1.0.0", + "cfg-if 1.0.1", "cpufeatures", "digest 0.9.0", "opaque-debug", @@ -2210,7 +2318,7 @@ version = "0.10.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "cpufeatures", "digest 0.10.7", ] @@ -2249,7 +2357,7 @@ checksum = "ab0381d1913eeaf4c7bc4094016c9a8de6c1120663afe32a90ff268ad7f80486" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2269,9 +2377,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" +checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" [[package]] name = "smallvec" @@ -2354,9 +2462,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.101" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -2383,7 +2491,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2393,7 +2501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" dependencies = [ "fastrand", - "getrandom 0.3.2", + "getrandom 0.3.3", "once_cell", "rustix", "windows-sys 0.59.0", @@ -2401,53 +2509,66 @@ dependencies = [ [[package]] name = "tendermint" -version = "0.40.4" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc997743ecfd4864bbca8170d68d9b2bee24653b034210752c2d883ef4b838b1" +checksum = "43f8a10105d0a7c4af0a242e23ed5a12519afe5cc0e68419da441bb5981a6802" dependencies = [ "bytes", "digest 0.10.7", "ed25519", - "ed25519-consensus", "flex-error", "futures", - "k256", "num-traits", "once_cell", - "prost", - "ripemd", + "prost 0.12.6", + "prost-types", "serde", "serde_bytes", "serde_json", "serde_repr", - "sha2 0.10.9", "signature", "subtle", "subtle-encoding", - "tendermint-proto", + "tendermint-proto 0.35.0", "time", "zeroize", ] [[package]] -name = "tendermint-config" +name = "tendermint" version = "0.40.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "069d1791f9b02a596abcd26eb72003b2e9906c6169a60fa82ffc080dd3a43fda" +checksum = "fc997743ecfd4864bbca8170d68d9b2bee24653b034210752c2d883ef4b838b1" dependencies = [ + "bytes", + "digest 0.10.7", + "ed25519", + "ed25519-consensus", "flex-error", + "futures", + "k256", + "num-traits", + "once_cell", + "prost 0.13.5", + "ripemd", "serde", + "serde_bytes", "serde_json", - "tendermint", - "toml", - "url 2.5.4", + "serde_repr", + "sha2 0.10.9", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto 0.40.4", + "time", + "zeroize", ] [[package]] name = "tendermint-p2p" -version = "0.40.4" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "047c1002b9af811bfc62afef70be329e779a3e7f4a2fd23eebce102d1b63e5f4" +checksum = "7dbaed086e2104a3996200d9cb36a02a50b2c40fc84feed34018e38c1cd76f30" dependencies = [ "aead", "chacha20poly1305", @@ -2458,17 +2579,35 @@ dependencies = [ "flume", "hkdf", "merlin", - "prost", + "prost 0.12.6", "rand_core", "sha2 0.10.9", "signature", "subtle", - "tendermint", - "tendermint-proto", + "tendermint 0.35.0", + "tendermint-proto 0.35.0", "tendermint-std-ext", "zeroize", ] +[[package]] +name = "tendermint-proto" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff525d5540a9fc535c38dc0d92a98da3ee36fcdfbda99cecb9f3cce5cd4d41d7" +dependencies = [ + "bytes", + "flex-error", + "num-derive", + "num-traits", + "prost 0.12.6", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "time", +] + [[package]] name = "tendermint-proto" version = "0.40.4" @@ -2477,7 +2616,7 @@ checksum = "d2c40e13d39ca19082d8a7ed22de7595979350319833698f8b1080f29620a094" dependencies = [ "bytes", "flex-error", - "prost", + "prost 0.13.5", "serde", "serde_bytes", "subtle-encoding", @@ -2486,9 +2625,9 @@ dependencies = [ [[package]] name = "tendermint-std-ext" -version = "0.40.4" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "298e90b07eab583fdf4829f4b1b85f0405ea3bfdd3154287064ac8507d3969f1" +checksum = "21d83875eb543e63a6f4903620af14796c41db1e457478bb7feabf3eac88b09f" [[package]] name = "termcolor" @@ -2516,7 +2655,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2525,7 +2664,7 @@ version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", ] [[package]] @@ -2605,6 +2744,9 @@ dependencies = [ "bytes", "chrono", "clap", + "cometbft", + "cometbft-config", + "cometbft-proto", "cosmrs", "ed25519", "ed25519-consensus", @@ -2616,8 +2758,7 @@ dependencies = [ "k256", "ledger", "once_cell", - "prost", - "prost-derive", + "prost 0.13.5", "rand", "rand_core", "rpassword", @@ -2629,10 +2770,7 @@ dependencies = [ "subtle", "subtle-encoding", "tempfile", - "tendermint", - "tendermint-config", "tendermint-p2p", - "tendermint-proto", "thiserror", "url 2.5.4", "uuid", @@ -2643,9 +2781,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.47.0" +version = "1.47.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" dependencies = [ "backtrace", "bytes", @@ -2667,7 +2805,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2693,9 +2831,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.15" +version = "0.7.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" dependencies = [ "bytes", "futures-core", @@ -2770,7 +2908,7 @@ checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -2902,7 +3040,7 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" dependencies = [ - "getrandom 0.3.2", + "getrandom 0.3.3", "js-sys", "serde", "wasm-bindgen", @@ -2971,7 +3109,7 @@ version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ - "cfg-if 1.0.0", + "cfg-if 1.0.1", "once_cell", "rustversion", "wasm-bindgen-macro", @@ -2987,7 +3125,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "wasm-bindgen-shared", ] @@ -3009,7 +3147,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3075,7 +3213,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3086,7 +3224,7 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3119,7 +3257,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3128,7 +3266,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", ] [[package]] @@ -3137,14 +3284,31 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -3153,48 +3317,96 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "winnow" version = "0.7.12" @@ -3210,7 +3422,7 @@ version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -3239,7 +3451,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "synstructure 0.13.2", ] @@ -3250,7 +3462,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "467a4c054be41ff657a6823246b0194cd727fadc3c539b265d7bc125ac6d4884" dependencies = [ "aes", - "bitflags 2.9.0", + "bitflags 2.9.1", "cbc", "ccm", "cmac", @@ -3295,7 +3507,7 @@ checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3315,7 +3527,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", "synstructure 0.13.2", ] @@ -3336,7 +3548,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] [[package]] @@ -3352,9 +3564,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.2" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +checksum = "e7aa2bd55086f1ab526693ecbe444205da57e25f4489879da80635a46d90e73b" dependencies = [ "yoke", "zerofrom", @@ -3369,5 +3581,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.101", + "syn 2.0.104", ] diff --git a/Cargo.toml b/Cargo.toml index 0d0201b7..1a83dcd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,6 @@ k256 = { version = "0.13", features = ["ecdsa", "sha256"] } ledger = { version = "0.2", optional = true } once_cell = "1.5" prost = "0.13" -prost-derive = "0.13" rand_core = { version = "0.6", features = ["std"] } rpassword = { version = "7", optional = true } sdkms = { version = "0.5", optional = true } @@ -43,10 +42,10 @@ signature = { version = "2", features = ["std"] } subtle = "2" subtle-encoding = { version = "0.5", features = ["bech32-preview"] } tempfile = "3" -tendermint = { version = "0.40", features = ["secp256k1"] } -tendermint-config = "0.40" -tendermint-p2p = "0.40" -tendermint-proto = "0.40" +cometbft = { git = "https://github.com/cometbft/cometbft-rs.git", rev = "71af716216216cfdc150cacef5ceae3610a5824b", features = ["secp256k1"] } +cometbft-config = { git = "https://github.com/cometbft/cometbft-rs.git", rev = "71af716216216cfdc150cacef5ceae3610a5824b" } +cometbft-proto = { git = "https://github.com/cometbft/cometbft-rs.git", rev = "71af716216216cfdc150cacef5ceae3610a5824b" } +tendermint-p2p = "0.35" # cometbft-rs does not provide p2p crate thiserror = "1" url = { version = "2.2.2", features = ["serde"], optional = true } uuid = { version = "1", features = ["serde"], optional = true } diff --git a/Dockerfile b/Dockerfile index a42e7b54..47dc6f38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -88,4 +88,3 @@ USER root # Ensure the /harness folder has the right owner RUN chown -R developer /harness USER developer - diff --git a/README.fortanixdsm.md b/README.fortanixdsm.md index 4ecaccee..a0a2fcc1 100644 --- a/README.fortanixdsm.md +++ b/README.fortanixdsm.md @@ -1,6 +1,6 @@ # Fortanix DSM + Tendermint KMS -Fortanix Data Security Manager (DSM) provides integrated data security with encryption, multicloud key management, tokenization, and other capabilities from one platform. +Fortanix Data Security Manager (DSM) provides integrated data security with encryption, multicloud key management, tokenization, and other capabilities from one platform. This document describes how to configure Fortanix DSM for production use with Tendermint KMS. @@ -62,7 +62,7 @@ contains the authentication details needed to authenticate to the DSM with an AP This configuration should be placed in a file called: `tmkms.toml`. You can specifty the path to the config with either `-c /path/to/tmkms.toml` or else tmkms will look in the current working directory for the same file. -example: +example: ```toml [[providers.fortanixdsm]] diff --git a/README.md b/README.md index fa2ea6f6..7b6a2e94 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -# Tendermint KMS 🔐 + # Tendermint KMS 🔐 -[![Crate][crate-image]][crate-link] -[![Build Status][build-image]][build-link] -[![Apache 2.0 Licensed][license-image]][license-link] +![Crate][crate-image] +![Build Status][build-image] +![Apache 2.0 Licensed][license-image] ![MSRV][rustc-image] -Key Management System for [Tendermint] applications such as -[Cosmos Validators]. +Key Management System for [Tendermint] applications such as [Cosmos Validators]. Provides isolated, optionally HSM-backed signing key management for Tendermint applications including validators, oracles, IBC relayers, and other transaction @@ -47,7 +46,8 @@ instructions on how to build Tendermint KMS). The following signing backend providers are presently supported: #### Hardware Security Modules (recommended) -- [FortanixDSM](./README.fortanixdsm.md) (gated under the `fortanixdsm` cargo feature. See [README.fortanixdsm.md](./README.fortanixdsm.md) + +- [FortanixDSM](./README.fortanixdsm.md) (gated under the `fortanixdsm` cargo feature. See [README.fortanixdsm.md](./README.fortanixdsm.md) - [YubiHSM2] (gated under the `yubihsm` cargo feature. See [README.yubihsm.md][yubihsm2] for more info) - [Ledger] (gated under the `ledger` cargo feature) @@ -238,7 +238,7 @@ limitations under the License. [//]: # (general links) -[Tendermint]: https://tendermint.com/ +[Tendermint]: https://tendermint.com [Cosmos Validators]: https://hub.cosmos.network/main/validators/validator-faq [YubiHSM2]: https://github.com/iqlusioninc/tmkms/blob/main/README.yubihsm.md [Ledger]: https://www.ledger.com/ diff --git a/README.yubihsm.md b/README.yubihsm.md index 6760fd01..3b0126e9 100644 --- a/README.yubihsm.md +++ b/README.yubihsm.md @@ -625,4 +625,4 @@ auth = { key = 4, password = "kms-validator-password-zzzzzzzzzzzz" } 14. You're done! -15. You may want to delete the old `priv_validator_key.json` from the server, so no attacker can steal it, but please make sure you have backups. \ No newline at end of file +15. You may want to delete the old `priv_validator_key.json` from the server, so no attacker can steal it, but please make sure you have backups. diff --git a/src/chain.rs b/src/chain.rs index 166e9f87..81a008f7 100644 --- a/src/chain.rs +++ b/src/chain.rs @@ -15,8 +15,8 @@ use crate::{ keyring::{self, KeyRing}, prelude::*, }; +pub use cometbft::chain::Id; use std::{path::PathBuf, sync::Mutex}; -pub use tendermint::chain::Id; /// Information about a particular Tendermint blockchain network pub struct Chain { diff --git a/src/chain/state.rs b/src/chain/state.rs index 34cf7b63..9b895f7a 100644 --- a/src/chain/state.rs +++ b/src/chain/state.rs @@ -12,13 +12,13 @@ use crate::{ error::{Error, ErrorKind::*}, prelude::*, }; +use cometbft::consensus; use std::{ fs, io::{self, prelude::*}, path::{Path, PathBuf}, }; use tempfile::NamedTempFile; -use tendermint::consensus; /// State tracking for double signing prevention pub struct State { @@ -209,7 +209,7 @@ impl State { #[cfg(test)] mod tests { use super::*; - use tendermint::block; + use cometbft::block; const EXAMPLE_BLOCK_ID: &str = "26C0A41F3243C6BCD7AD2DFF8A8D83A71D29D307B5326C227F734A1A512FE47D"; diff --git a/src/chain/state/hook.rs b/src/chain/state/hook.rs index aa04a37d..e7f0e250 100644 --- a/src/chain/state/hook.rs +++ b/src/chain/state/hook.rs @@ -5,9 +5,9 @@ use crate::{ error::{Error, ErrorKind::HookError}, prelude::*, }; +use cometbft::block; use serde::Deserialize; use std::{process::Command, time::Duration}; -use tendermint::block; use wait_timeout::ChildExt; /// Default timeout to use when a user one is unspecified diff --git a/src/commands/ledger.rs b/src/commands/ledger.rs index ad6cb610..f954a8b0 100644 --- a/src/commands/ledger.rs +++ b/src/commands/ledger.rs @@ -7,9 +7,9 @@ use crate::{ }; use abscissa_core::{Command, Runnable}; use clap::{Parser, Subcommand}; +use cometbft::Vote; +use cometbft_proto as proto; use std::{path::PathBuf, process}; -use tendermint::Vote; -use tendermint_proto as proto; /// `ledger` subcommand #[derive(Command, Debug, Runnable, Subcommand)] @@ -55,7 +55,7 @@ impl Runnable for InitCommand { let registry = chain::REGISTRY.get(); let chain = registry.get_chain(&chain_id).unwrap(); - let vote = proto::types::Vote { + let vote = proto::types::v1::Vote { height: self.height.unwrap(), round: self.round.unwrap() as i32, r#type: SignedMsgType::Proposal.into(), diff --git a/src/commands/softsign/import.rs b/src/commands/softsign/import.rs index bad79f8d..c79eef9f 100644 --- a/src/commands/softsign/import.rs +++ b/src/commands/softsign/import.rs @@ -3,9 +3,9 @@ use crate::{config::provider::softsign::KeyFormat, key_utils, prelude::*}; use abscissa_core::Command; use clap::Parser; +use cometbft::PrivateKey; +use cometbft_config::PrivValidatorKey; use std::{path::PathBuf, process}; -use tendermint::PrivateKey; -use tendermint_config::PrivValidatorKey; /// `import` command: import a `priv_validator.json` formatted key and convert /// it into the raw format used by the softsign backend (by default) diff --git a/src/commands/yubihsm/keys/generate.rs b/src/commands/yubihsm/keys/generate.rs index 1e072c05..2593ca69 100644 --- a/src/commands/yubihsm/keys/generate.rs +++ b/src/commands/yubihsm/keys/generate.rs @@ -5,11 +5,11 @@ use crate::{config::provider::KeyType, key_utils, prelude::*}; use abscissa_core::Command; use chrono::{SecondsFormat, Utc}; use clap::Parser; +use cometbft::PublicKey; use std::{ path::{Path, PathBuf}, process, }; -use tendermint::PublicKey; /// The `yubihsm keys generate` subcommand #[derive(Command, Debug, Default, Parser)] diff --git a/src/commands/yubihsm/keys/import.rs b/src/commands/yubihsm/keys/import.rs index f74082b7..6aac1151 100644 --- a/src/commands/yubihsm/keys/import.rs +++ b/src/commands/yubihsm/keys/import.rs @@ -4,10 +4,10 @@ use super::{DEFAULT_DOMAINS, DEFAULT_WRAP_KEY}; use crate::{keyring::ed25519, prelude::*}; use abscissa_core::Command; use clap::Parser; +use cometbft::{PrivateKey, PublicKey}; +use cometbft_config::PrivValidatorKey; use std::{fs, path::PathBuf, process}; use subtle_encoding::base64; -use tendermint::{PrivateKey, PublicKey}; -use tendermint_config::PrivValidatorKey; use yubihsm::object; use zeroize::Zeroizing; diff --git a/src/commands/yubihsm/keys/list.rs b/src/commands/yubihsm/keys/list.rs index ed24ee7c..d428dd71 100644 --- a/src/commands/yubihsm/keys/list.rs +++ b/src/commands/yubihsm/keys/list.rs @@ -3,9 +3,9 @@ use crate::{chain, keyring, prelude::*, Map}; use abscissa_core::Command; use clap::Parser; +use cometbft::{CometbftKey, PublicKey}; use k256::elliptic_curve::generic_array::GenericArray; use std::{path::PathBuf, process}; -use tendermint::{PublicKey, TendermintKey}; /// The `yubihsm keys list` subcommand #[derive(Command, Debug, Default, Parser)] @@ -121,7 +121,7 @@ fn display_key_info( let key_id = format!("- 0x{:04x}", key.object_id); - let tendermint_key = match public_key.algorithm { + let cometbft_key = match public_key.algorithm { yubihsm::asymmetric::Algorithm::EcK256 => { // The YubiHSM2 returns the uncompressed public key, so for // compatibility with Tendermint, we have to compress it first @@ -130,13 +130,13 @@ fn display_key_info( ) .compress(); - TendermintKey::AccountKey( + CometbftKey::AccountKey( PublicKey::from_raw_secp256k1(compressed_pubkey.as_ref()).unwrap(), ) } yubihsm::asymmetric::Algorithm::Ed25519 => { let pk = PublicKey::from_raw_ed25519(public_key.as_ref()).unwrap(); - TendermintKey::ConsensusKey(pk) + CometbftKey::ConsensusKey(pk) } other => { status_attr_err!(key_id, "unsupported algorithm: {:?}", other); @@ -144,16 +144,16 @@ fn display_key_info( } }; - let key_type = match tendermint_key { - TendermintKey::AccountKey(_) => "acct", - TendermintKey::ConsensusKey(_) => "cons", + let key_type = match cometbft_key { + CometbftKey::AccountKey(_) => "acct", + CometbftKey::ConsensusKey(_) => "cons", }; let key_serialized = match key_formatters.get(&key.object_id) { - Some(key_formatter) => key_formatter.serialize(tendermint_key), - None => match tendermint_key { - TendermintKey::AccountKey(k) => k.to_hex(), - TendermintKey::ConsensusKey(k) => k.to_hex(), + Some(key_formatter) => key_formatter.serialize(cometbft_key), + None => match cometbft_key { + CometbftKey::AccountKey(k) => k.to_hex(), + CometbftKey::ConsensusKey(k) => k.to_hex(), }, }; diff --git a/src/config/provider/yubihsm.rs b/src/config/provider/yubihsm.rs index 56fc40cb..e13ad1bf 100644 --- a/src/config/provider/yubihsm.rs +++ b/src/config/provider/yubihsm.rs @@ -4,10 +4,11 @@ use super::KeyType; use crate::{chain, prelude::*}; use serde::Deserialize; use std::{fmt, fs, path::PathBuf, process}; -use tendermint_config::net; use yubihsm::Credentials; use zeroize::{Zeroize, Zeroizing}; +use cometbft_config::net; + /// The (optional) `[providers.yubihsm]` config section #[derive(Clone, Deserialize, Debug)] #[serde(deny_unknown_fields)] diff --git a/src/config/validator.rs b/src/config/validator.rs index f59fbea9..3cd8d199 100644 --- a/src/config/validator.rs +++ b/src/config/validator.rs @@ -1,9 +1,9 @@ //! Validator configuration +use cometbft::chain; +use cometbft_config::net; use serde::{Deserialize, Serialize}; use std::path::PathBuf; -use tendermint::chain; -use tendermint_config::net; use tendermint_p2p::secret_connection; /// Validator configuration @@ -27,7 +27,7 @@ pub struct ValidatorConfig { pub secret_key: Option, /// Height at which to stop signing - pub max_height: Option, + pub max_height: Option, /// Version of Secret Connection protocol to use when connecting pub protocol_version: ProtocolVersion, diff --git a/src/connection/tcp.rs b/src/connection/tcp.rs index d538c312..fd6fee82 100644 --- a/src/connection/tcp.rs +++ b/src/connection/tcp.rs @@ -2,8 +2,8 @@ use std::{net::TcpStream, path::PathBuf, time::Duration}; +use cometbft::node; use subtle::ConstantTimeEq; -use tendermint::node; use tendermint_p2p::error::ErrorDetail as TmError; use tendermint_p2p::secret_connection::{self, PublicKey, SecretConnection}; @@ -55,7 +55,12 @@ pub fn open_secret_connection( // TODO(tarcieri): move this into `SecretConnection::new` if let Some(expected_peer_id) = peer_id { - if expected_peer_id.ct_eq(&actual_peer_id).unwrap_u8() == 0 { + if expected_peer_id + .as_bytes() + .ct_eq(actual_peer_id.as_bytes()) + .unwrap_u8() + == 0 + { fail!( VerificationError, "{}:{}: validator peer ID mismatch! (expected {}, got {})", diff --git a/src/error.rs b/src/error.rs index e09ea3fc..13126331 100644 --- a/src/error.rs +++ b/src/error.rs @@ -94,6 +94,10 @@ pub enum ErrorKind { #[cfg(feature = "yubihsm")] #[error("YubiHSM error")] YubihsmError, + + /// Protobuf encoding error + #[error("protobuf error")] + ProtobufError, } impl ErrorKind { @@ -190,12 +194,18 @@ impl From for Error { } } -impl From for Error { - fn from(other: tendermint::error::Error) -> Self { +impl From for Error { + fn from(other: cometbft::error::Error) -> Self { ErrorKind::TendermintError.context(other).into() } } +impl From for Error { + fn from(other: cometbft_proto::Error) -> Self { + ErrorKind::ProtobufError.context(other).into() + } +} + impl From for Error { fn from(other: chain::state::StateError) -> Self { ErrorKind::DoubleSign.context(other).into() diff --git a/src/keyring.rs b/src/keyring.rs index 364c658b..67345c93 100644 --- a/src/keyring.rs +++ b/src/keyring.rs @@ -14,7 +14,7 @@ use crate::{ prelude::*, Map, }; -use tendermint::{account, TendermintKey}; +use cometbft::{account, CometbftKey}; /// File encoding for software-backed secret keys pub type SecretKeyEncoding = subtle_encoding::Base64; @@ -22,10 +22,10 @@ pub type SecretKeyEncoding = subtle_encoding::Base64; /// Signing keyring pub struct KeyRing { /// ECDSA keys in the keyring - ecdsa_keys: Map, + ecdsa_keys: Map, /// Ed25519 keys in the keyring - ed25519_keys: Map, + ed25519_keys: Map, /// Formatting configuration when displaying keys (e.g. bech32) format: Format, @@ -48,8 +48,8 @@ impl KeyRing { let public_key = signer.public_key(); let public_key_serialized = self.format.serialize(public_key); let key_type = match public_key { - TendermintKey::AccountKey(_) => "account", - TendermintKey::ConsensusKey(_) => unimplemented!( + CometbftKey::AccountKey(_) => "account", + CometbftKey::ConsensusKey(_) => unimplemented!( "ECDSA consensus keys unsupported: {:?}", public_key_serialized ), @@ -80,11 +80,11 @@ impl KeyRing { let public_key = signer.public_key(); let public_key_serialized = self.format.serialize(public_key); let key_type = match public_key { - TendermintKey::AccountKey(_) => unimplemented!( + CometbftKey::AccountKey(_) => unimplemented!( "Ed25519 account keys unsupported: {:?}", public_key_serialized ), - TendermintKey::ConsensusKey(_) => "consensus", + CometbftKey::ConsensusKey(_) => "consensus", }; info!( @@ -106,7 +106,7 @@ impl KeyRing { } /// Get the default Ed25519 (i.e. consensus) public key for this keyring - pub fn default_pubkey(&self) -> Result { + pub fn default_pubkey(&self) -> Result { if !self.ed25519_keys.is_empty() { let mut keys = self.ed25519_keys.keys(); @@ -129,9 +129,9 @@ impl KeyRing { } /// Get ECDSA public key bytes for a given account ID - pub fn get_account_pubkey(&self, account_id: account::Id) -> Option { + pub fn get_account_pubkey(&self, account_id: account::Id) -> Option { for key in self.ecdsa_keys.keys() { - if let TendermintKey::AccountKey(pk) = key { + if let CometbftKey::AccountKey(pk) = key { if account_id == account::Id::from(*pk) { return Some(*pk); } @@ -148,7 +148,7 @@ impl KeyRing { msg: &[u8], ) -> Result { for (key, signer) in &self.ecdsa_keys { - if let TendermintKey::AccountKey(pk) = key { + if let CometbftKey::AccountKey(pk) = key { if account_id == account::Id::from(*pk) { return signer.sign(msg); } @@ -164,7 +164,7 @@ impl KeyRing { /// Sign a message using the secret key associated with the given public key /// (if it is in our keyring) - pub fn sign(&self, public_key: Option<&TendermintKey>, msg: &[u8]) -> Result { + pub fn sign(&self, public_key: Option<&CometbftKey>, msg: &[u8]) -> Result { if self.ed25519_keys.len() > 1 || self.ecdsa_keys.len() > 1 { fail!(SigningError, "expected only one key in keyring"); } @@ -176,8 +176,8 @@ impl KeyRing { InvalidKey, "not in keyring: {}", match public_key { - TendermintKey::AccountKey(pk) => pk.to_bech32(""), - TendermintKey::ConsensusKey(pk) => pk.to_bech32(""), + CometbftKey::AccountKey(pk) => pk.to_bech32(""), + CometbftKey::ConsensusKey(pk) => pk.to_bech32(""), } ) }), @@ -196,8 +196,8 @@ impl KeyRing { InvalidKey, "not in keyring: {}", match public_key { - TendermintKey::AccountKey(pk) => pk.to_bech32(""), - TendermintKey::ConsensusKey(pk) => pk.to_bech32(""), + CometbftKey::AccountKey(pk) => pk.to_bech32(""), + CometbftKey::ConsensusKey(pk) => pk.to_bech32(""), } ) }), diff --git a/src/keyring/ecdsa.rs b/src/keyring/ecdsa.rs index f2041ea6..0ea0a177 100644 --- a/src/keyring/ecdsa.rs +++ b/src/keyring/ecdsa.rs @@ -7,8 +7,8 @@ use crate::{ keyring::SigningProvider, prelude::*, }; +use cometbft::CometbftKey; use std::sync::Arc; -use tendermint::TendermintKey; /// ECDSA signer #[derive(Clone)] @@ -18,7 +18,7 @@ pub struct Signer { provider: SigningProvider, /// Tendermint public key - public_key: TendermintKey, + public_key: CometbftKey, /// Signer trait object signer: Arc + Send + Sync>>, @@ -28,7 +28,7 @@ impl Signer { /// Create a new signer pub fn new( provider: SigningProvider, - public_key: TendermintKey, + public_key: CometbftKey, signer: Box + Send + Sync>, ) -> Self { Self { @@ -39,7 +39,7 @@ impl Signer { } /// Get the Tendermint public key for this signer - pub fn public_key(&self) -> TendermintKey { + pub fn public_key(&self) -> CometbftKey { self.public_key } diff --git a/src/keyring/ed25519.rs b/src/keyring/ed25519.rs index 6dd94ce9..43c12d26 100644 --- a/src/keyring/ed25519.rs +++ b/src/keyring/ed25519.rs @@ -11,8 +11,8 @@ use crate::{ keyring::SigningProvider, prelude::*, }; +use cometbft::CometbftKey; use std::sync::Arc; -use tendermint::TendermintKey; /// Ed25519 signer #[derive(Clone)] @@ -22,7 +22,7 @@ pub struct Signer { provider: SigningProvider, /// Tendermint public key - public_key: TendermintKey, + public_key: CometbftKey, /// Signer trait object signer: Arc + Send + Sync>>, @@ -32,7 +32,7 @@ impl Signer { /// Create a new signer pub fn new( provider: SigningProvider, - public_key: TendermintKey, + public_key: CometbftKey, signer: Box + Send + Sync>, ) -> Self { Self { @@ -43,7 +43,7 @@ impl Signer { } /// Get the Tendermint public key for this signer - pub fn public_key(&self) -> TendermintKey { + pub fn public_key(&self) -> CometbftKey { self.public_key } diff --git a/src/keyring/ed25519/signing_key.rs b/src/keyring/ed25519/signing_key.rs index ef76000a..8caea73a 100644 --- a/src/keyring/ed25519/signing_key.rs +++ b/src/keyring/ed25519/signing_key.rs @@ -48,8 +48,8 @@ impl From for SigningKey { } } -impl From for SigningKey { - fn from(signing_key: tendermint::private_key::Ed25519) -> SigningKey { +impl From for SigningKey { + fn from(signing_key: cometbft::private_key::Ed25519) -> SigningKey { signing_key .as_bytes() .try_into() diff --git a/src/keyring/ed25519/verifying_key.rs b/src/keyring/ed25519/verifying_key.rs index 3681f257..10fa91a0 100644 --- a/src/keyring/ed25519/verifying_key.rs +++ b/src/keyring/ed25519/verifying_key.rs @@ -23,9 +23,9 @@ impl From<&SigningKey> for VerifyingKey { } } -impl From for tendermint::PublicKey { - fn from(verifying_key: VerifyingKey) -> tendermint::PublicKey { - tendermint::PublicKey::from_raw_ed25519(verifying_key.as_bytes()) +impl From for cometbft::PublicKey { + fn from(verifying_key: VerifyingKey) -> cometbft::PublicKey { + cometbft::PublicKey::from_raw_ed25519(verifying_key.as_bytes()) .expect("invalid Ed25519 key") } } diff --git a/src/keyring/format.rs b/src/keyring/format.rs index 001aefe9..a172b484 100644 --- a/src/keyring/format.rs +++ b/src/keyring/format.rs @@ -1,9 +1,9 @@ //! Chain-specific key configuration -use cosmrs::crypto::PublicKey; +use cometbft::CometbftKey; +// use cosmrs::crypto::PublicKey; use serde::Deserialize; use subtle_encoding::bech32; -use tendermint::TendermintKey; /// Options for how keys for this chain are represented #[derive(Clone, Debug, Deserialize)] @@ -29,22 +29,22 @@ pub enum Format { } impl Format { - /// Serialize a `TendermintKey` according to chain-specific rules - pub fn serialize(&self, public_key: TendermintKey) -> String { + /// Serialize a `CometbftKey` according to chain-specific rules + pub fn serialize(&self, public_key: CometbftKey) -> String { match self { Format::Bech32 { account_key_prefix, consensus_key_prefix, } => match public_key { - TendermintKey::AccountKey(pk) => { - bech32::encode(account_key_prefix, tendermint::account::Id::from(pk)) + CometbftKey::AccountKey(pk) => { + bech32::encode(account_key_prefix, cometbft::account::Id::from(pk)) } - TendermintKey::ConsensusKey(pk) => pk.to_bech32(consensus_key_prefix), + CometbftKey::ConsensusKey(pk) => pk.to_bech32(consensus_key_prefix), }, - Format::CosmosJson => PublicKey::from(*public_key.public_key()).to_json(), + Format::CosmosJson => unimplemented!("cosmrs needs to be updated!"), Format::Hex => match public_key { - TendermintKey::AccountKey(pk) => pk.to_hex(), - TendermintKey::ConsensusKey(pk) => pk.to_hex(), + CometbftKey::AccountKey(pk) => pk.to_hex(), + CometbftKey::ConsensusKey(pk) => pk.to_hex(), }, } } diff --git a/src/keyring/providers/fortanixdsm.rs b/src/keyring/providers/fortanixdsm.rs index 0dffece6..87040930 100644 --- a/src/keyring/providers/fortanixdsm.rs +++ b/src/keyring/providers/fortanixdsm.rs @@ -8,6 +8,8 @@ use crate::{ keyring::{self, ed25519, SigningProvider}, prelude::*, }; +use cometbft::public_key::{Ed25519, Secp256k1}; +use cometbft::{CometbftKey, PublicKey}; use elliptic_curve::pkcs8::{ spki::Error as SpkiError, DecodePublicKey, ObjectIdentifier, SubjectPublicKeyInfoRef, }; @@ -19,8 +21,6 @@ use sdkms::api_model::{ use sdkms::{Error as SdkmsError, SdkmsClient}; use signature::Signer; use std::sync::Arc; -use tendermint::public_key::{Ed25519, Secp256k1}; -use tendermint::{PublicKey, TendermintKey}; use url::Url; /// Create Fortanix DSM backed signer objects from the given configuration @@ -80,7 +80,7 @@ impl SigningKey { client: Arc, descriptor: KeyDescriptor, key_type: KeyType, - ) -> Result<(Self, TendermintKey), Error> { + ) -> Result<(Self, CometbftKey), Error> { let descriptor: SobjectDescriptor = descriptor.into(); let key = client .get_sobject(None, &descriptor) @@ -121,7 +121,7 @@ impl SigningKey { ) })? .into(); - TendermintKey::AccountKey(PublicKey::from(pub_key)) + CometbftKey::AccountKey(PublicKey::from(pub_key)) } KeyType::Consensus => { let pub_key = Ed25519PublicKey::from_public_key_der(&public_key).map_err(|e| { @@ -131,7 +131,7 @@ impl SigningKey { e ) })?; - TendermintKey::ConsensusKey(PublicKey::from(pub_key.0)) + CometbftKey::ConsensusKey(PublicKey::from(pub_key.0)) } }; diff --git a/src/keyring/providers/ledgertm.rs b/src/keyring/providers/ledgertm.rs index d200b065..eda26e35 100644 --- a/src/keyring/providers/ledgertm.rs +++ b/src/keyring/providers/ledgertm.rs @@ -15,7 +15,7 @@ use crate::{ }, prelude::*, }; -use tendermint::{PublicKey, TendermintKey}; +use cometbft::{CometbftKey, PublicKey}; /// Create Ledger Tendermint signer object from the given configuration pub fn init( @@ -41,7 +41,7 @@ pub fn init( let signer = Signer::new( SigningProvider::LedgerTm, - TendermintKey::ConsensusKey(public_key), + CometbftKey::ConsensusKey(public_key), Box::new(provider), ); diff --git a/src/keyring/providers/softsign.rs b/src/keyring/providers/softsign.rs index 03901b39..90798034 100644 --- a/src/keyring/providers/softsign.rs +++ b/src/keyring/providers/softsign.rs @@ -13,9 +13,9 @@ use crate::{ keyring::{self, ed25519, SigningProvider}, prelude::*, }; +use cometbft::{CometbftKey, PrivateKey}; +use cometbft_config::PrivValidatorKey; use k256::ecdsa; -use tendermint::{PrivateKey, TendermintKey}; -use tendermint_config::PrivValidatorKey; /// Create software-backed Ed25519 signer objects from the given configuration pub fn init(chain_registry: &mut chain::Registry, configs: &[SoftsignConfig]) -> Result<(), Error> { @@ -29,12 +29,12 @@ pub fn init(chain_registry: &mut chain::Registry, configs: &[SoftsignConfig]) -> match config.key_type { KeyType::Account => { let signer = load_secp256k1_key(config)?; - let public_key = tendermint::PublicKey::from_raw_secp256k1( + let public_key = cometbft::PublicKey::from_raw_secp256k1( &signer.verifying_key().to_sec1_bytes(), ) .unwrap(); - let account_pubkey = TendermintKey::AccountKey(public_key); + let account_pubkey = CometbftKey::AccountKey(public_key); let signer = keyring::ecdsa::Signer::new( SigningProvider::SoftSign, @@ -58,7 +58,7 @@ pub fn init(chain_registry: &mut chain::Registry, configs: &[SoftsignConfig]) -> let signing_key = load_ed25519_key(config)?; let consensus_pubkey = - TendermintKey::ConsensusKey(signing_key.verifying_key().into()); + CometbftKey::ConsensusKey(signing_key.verifying_key().into()); let signer = ed25519::Signer::new( SigningProvider::SoftSign, diff --git a/src/keyring/providers/yubihsm.rs b/src/keyring/providers/yubihsm.rs index 42a02514..87faaea1 100644 --- a/src/keyring/providers/yubihsm.rs +++ b/src/keyring/providers/yubihsm.rs @@ -10,7 +10,7 @@ use crate::{ keyring::{self, SigningProvider}, prelude::*, }; -use tendermint::TendermintKey; +use cometbft::CometbftKey; /// Create hardware-backed YubiHSM signer objects from the given configuration pub fn init( @@ -55,12 +55,12 @@ fn add_account_key( })?; let public_key = - tendermint::PublicKey::from_raw_secp256k1(signer.public_key().compress().as_bytes()) + cometbft::PublicKey::from_raw_secp256k1(signer.public_key().compress().as_bytes()) .expect("invalid secp256k1 key"); let signer = keyring::ecdsa::Signer::new( SigningProvider::Yubihsm, - TendermintKey::AccountKey(public_key), + CometbftKey::AccountKey(public_key), Box::new(signer), ); @@ -85,12 +85,12 @@ fn add_consensus_key( ) })?; - let public_key = tendermint::PublicKey::from_raw_ed25519(signer.public_key().as_bytes()) + let public_key = cometbft::PublicKey::from_raw_ed25519(signer.public_key().as_bytes()) .expect("invalid Ed25519 key"); let signer = keyring::ed25519::Signer::new( SigningProvider::Yubihsm, - TendermintKey::ConsensusKey(public_key), + CometbftKey::ConsensusKey(public_key), Box::new(signer), ); diff --git a/src/keyring/signature.rs b/src/keyring/signature.rs index 37cd5673..37cb07b8 100644 --- a/src/keyring/signature.rs +++ b/src/keyring/signature.rs @@ -34,8 +34,8 @@ impl From for Signature { } } -impl From for tendermint::Signature { - fn from(sig: Signature) -> tendermint::Signature { +impl From for cometbft::Signature { + fn from(sig: Signature) -> cometbft::Signature { sig.to_vec().try_into().expect("signature should be valid") } } diff --git a/src/privval.rs b/src/privval.rs index cdab361f..84ceae99 100644 --- a/src/privval.rs +++ b/src/privval.rs @@ -1,9 +1,8 @@ //! Validator private key operations: signing consensus votes and proposals. use bytes::{Bytes, BytesMut}; -use prost::{EncodeError, Message as _}; -use tendermint::{block, chain, consensus, vote, Error, Proposal, Vote}; -use tendermint_proto as proto; +use cometbft::{block, chain, consensus, vote, Error, Proposal, Vote}; +use cometbft_proto::{self as proto, Error as ProtobufError}; /// Message codes. pub type SignedMsgCode = i32; @@ -49,36 +48,15 @@ impl SignableMsg { /// Get the bytes representing a canonically encoded message over which a /// signature is computed over. - pub fn canonical_bytes(&self, chain_id: chain::Id) -> Result { + pub fn canonical_bytes(&self, chain_id: chain::Id) -> Result { let mut bytes = BytesMut::new(); match self { Self::Proposal(proposal) => { - let canonical = proto::types::CanonicalProposal { - chain_id: chain_id.to_string(), - r#type: SignedMsgType::Proposal.into(), - height: proposal.height.into(), - block_id: proposal.block_id.map(Into::into), - pol_round: proposal - .pol_round - .map(|round| round.value().into()) - .unwrap_or(-1), - round: proposal.round.value().into(), - timestamp: proposal.timestamp.map(Into::into), - }; - - canonical.encode_length_delimited(&mut bytes)?; + proposal.to_signable_bytes(chain_id, &mut bytes)?; } Self::Vote(vote) => { - let canonical = proto::types::CanonicalVote { - r#type: vote.vote_type.into(), - height: vote.height.into(), - round: vote.round.value().into(), - block_id: vote.block_id.map(Into::into), - timestamp: vote.timestamp.map(Into::into), - chain_id: chain_id.to_string(), - }; - canonical.encode_length_delimited(&mut bytes)?; + vote.to_signable_bytes(chain_id, &mut bytes)?; } } @@ -86,7 +64,7 @@ impl SignableMsg { } /// Get the bytes representing a vote extension if applicable. - pub fn extension_bytes(&self, chain_id: chain::Id) -> Result, EncodeError> { + pub fn extension_bytes(&self, chain_id: chain::Id) -> Result, ProtobufError> { match self { Self::Proposal(_) => Ok(None), Self::Vote(v) => { @@ -94,16 +72,16 @@ impl SignableMsg { // Only sign extension if it's a precommit for a non-nil block. // Note that extension can be empty. (vote::Type::Precommit, Some(_)) => { - let canonical = proto::types::CanonicalVoteExtension { + use prost::Message; + + let canonical = proto::types::v1::CanonicalVoteExtension { extension: v.extension.clone(), height: v.height.into(), round: v.round.value().into(), chain_id: chain_id.to_string(), }; - let mut bytes = BytesMut::new(); - canonical.encode_length_delimited(&mut bytes)?; - Ok(Some(bytes.into())) + Ok(Some(canonical.encode_length_delimited_to_vec().into())) } _ => Ok(None), } @@ -133,7 +111,7 @@ impl SignableMsg { } /// Add a consensus signature to this message. - pub fn add_consensus_signature(&mut self, signature: impl Into) { + pub fn add_consensus_signature(&mut self, signature: impl Into) { match self { SignableMsg::Proposal(proposal) => { proposal.signature = Some(signature.into()); @@ -147,7 +125,7 @@ impl SignableMsg { /// Add an extension signature to this message. pub fn add_extension_signature( &mut self, - signature: impl Into, + signature: impl Into, ) -> Result<(), Error> { match self { SignableMsg::Vote(vote) => { @@ -171,18 +149,18 @@ impl From for SignableMsg { } } -impl TryFrom for SignableMsg { +impl TryFrom for SignableMsg { type Error = Error; - fn try_from(proposal: proto::types::Proposal) -> Result { + fn try_from(proposal: proto::types::v1::Proposal) -> Result { Proposal::try_from(proposal).map(Self::Proposal) } } -impl TryFrom for SignableMsg { +impl TryFrom for SignableMsg { type Error = Error; - fn try_from(vote: proto::types::Vote) -> Result { + fn try_from(vote: proto::types::v1::Vote) -> Result { Vote::try_from(vote).map(Self::Vote) } } @@ -225,24 +203,24 @@ impl From for SignedMsgCode { } } -impl From for proto::types::SignedMsgType { - fn from(msg_type: SignedMsgType) -> proto::types::SignedMsgType { +impl From for proto::types::v1::SignedMsgType { + fn from(msg_type: SignedMsgType) -> proto::types::v1::SignedMsgType { match msg_type { - SignedMsgType::Unknown => proto::types::SignedMsgType::Unknown, - SignedMsgType::Prevote => proto::types::SignedMsgType::Prevote, - SignedMsgType::Precommit => proto::types::SignedMsgType::Precommit, - SignedMsgType::Proposal => proto::types::SignedMsgType::Proposal, + SignedMsgType::Unknown => proto::types::v1::SignedMsgType::Unknown, + SignedMsgType::Prevote => proto::types::v1::SignedMsgType::Prevote, + SignedMsgType::Precommit => proto::types::v1::SignedMsgType::Precommit, + SignedMsgType::Proposal => proto::types::v1::SignedMsgType::Proposal, } } } -impl From for SignedMsgType { - fn from(proto: proto::types::SignedMsgType) -> SignedMsgType { +impl From for SignedMsgType { + fn from(proto: proto::types::v1::SignedMsgType) -> SignedMsgType { match proto { - proto::types::SignedMsgType::Unknown => Self::Unknown, - proto::types::SignedMsgType::Prevote => Self::Prevote, - proto::types::SignedMsgType::Precommit => Self::Precommit, - proto::types::SignedMsgType::Proposal => Self::Proposal, + proto::types::v1::SignedMsgType::Unknown => Self::Unknown, + proto::types::v1::SignedMsgType::Prevote => Self::Prevote, + proto::types::v1::SignedMsgType::Precommit => Self::Precommit, + proto::types::v1::SignedMsgType::Proposal => Self::Proposal, } } } @@ -260,7 +238,7 @@ impl TryFrom for SignedMsgType { type Error = Error; fn try_from(code: SignedMsgCode) -> Result { - proto::types::SignedMsgType::try_from(code) + proto::types::v1::SignedMsgType::try_from(code) .map(Into::into) .map_err(|e| Error::parse(e.to_string())) } @@ -269,7 +247,7 @@ impl TryFrom for SignedMsgType { #[cfg(test)] mod tests { use super::{chain, proto, SignableMsg, SignedMsgType}; - use tendermint::{Proposal, Time, Vote}; + use cometbft::{Proposal, Time, Vote}; fn example_chain_id() -> chain::Id { chain::Id::try_from("test_chain_id").unwrap() @@ -285,7 +263,7 @@ mod tests { } fn example_proposal() -> Proposal { - proto::types::Proposal { + proto::types::v1::Proposal { r#type: SignedMsgType::Proposal.into(), height: 12345, round: 1, @@ -299,14 +277,14 @@ mod tests { } fn example_vote() -> Vote { - proto::types::Vote { + proto::types::v1::Vote { r#type: 0x01, height: 500001, round: 2, timestamp: Some(example_timestamp()), - block_id: Some(proto::types::BlockId { + block_id: Some(proto::types::v1::BlockId { hash: b"some hash00000000000000000000000".to_vec(), - part_set_header: Some(proto::types::PartSetHeader { + part_set_header: Some(proto::types::v1::PartSetHeader { total: 1000000, hash: b"parts_hash0000000000000000000000".to_vec(), }), diff --git a/src/rpc.rs b/src/rpc.rs index 7e2a9819..7d8b851b 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -4,11 +4,14 @@ #![allow(missing_docs)] use crate::privval::SignableMsg; +use cometbft::{chain, Proposal, Vote}; +use cometbft_proto as proto; use prost::Message as _; use std::io::Read; -use tendermint::{chain, Proposal, Vote}; -use tendermint_p2p::secret_connection::DATA_MAX_SIZE; -use tendermint_proto as proto; + +// TODO(tarcieri): use `tendermint_p2p::secret_connection::DATA_MAX_SIZE` +// See informalsystems/tendermint-rs#1356 +const DATA_MAX_SIZE: usize = 262144; use crate::{ error::{Error, ErrorKind}, @@ -18,9 +21,10 @@ use crate::{ /// RPC requests to the KMS #[derive(Debug)] pub enum Request { - /// Sign the given message + /// Sign the given proposal SignProposal(Proposal), - SignVote(Vote), + /// Sign the given vote + SignVote((Vote, bool)), // skip_extension_signing ShowPublicKey, PingRequest, } @@ -38,7 +42,7 @@ impl Request { msg_bytes.append(&mut msg_chunk); // if we can decode it, great, break the loop - match proto::privval::Message::decode_length_delimited(msg_bytes.as_ref()) { + match proto::privval::v1::Message::decode_length_delimited(msg_bytes.as_ref()) { Ok(m) => { msg = m.sum; break; @@ -60,22 +64,26 @@ impl Request { } let (req, chain_id) = match msg { - Some(proto::privval::message::Sum::SignVoteRequest( - proto::privval::SignVoteRequest { + Some(proto::privval::v1::message::Sum::SignVoteRequest( + proto::privval::v1::SignVoteRequest { vote: Some(vote), chain_id, + skip_extension_signing, }, - )) => (Request::SignVote(vote.try_into()?), chain_id), - Some(proto::privval::message::Sum::SignProposalRequest( - proto::privval::SignProposalRequest { + )) => ( + Request::SignVote((vote.try_into()?, skip_extension_signing)), + chain_id, + ), + Some(proto::privval::v1::message::Sum::SignProposalRequest( + proto::privval::v1::SignProposalRequest { proposal: Some(proposal), chain_id, }, )) => (Request::SignProposal(proposal.try_into()?), chain_id), - Some(proto::privval::message::Sum::PubKeyRequest(req)) => { + Some(proto::privval::v1::message::Sum::PubKeyRequest(req)) => { (Request::ShowPublicKey, req.chain_id) } - Some(proto::privval::message::Sum::PingRequest(_)) => { + Some(proto::privval::v1::message::Sum::PingRequest(_)) => { return Ok(Request::PingRequest); } _ => fail!(ErrorKind::ProtocolError, "invalid RPC message: {:?}", msg), @@ -98,7 +106,7 @@ impl Request { pub fn into_signable_msg(self) -> Result { match self { Self::SignProposal(proposal) => Ok(proposal.into()), - Self::SignVote(vote) => Ok(vote.into()), + Self::SignVote((vote, _)) => Ok(vote.into()), _ => fail!( ErrorKind::InvalidMessageError, "expected a signable message type: {:?}", @@ -112,10 +120,10 @@ impl Request { #[derive(Debug)] pub enum Response { /// Signature response - SignedVote(proto::privval::SignedVoteResponse), - SignedProposal(proto::privval::SignedProposalResponse), - Ping(proto::privval::PingResponse), - PublicKey(proto::privval::PubKeyResponse), + SignedVote(proto::privval::v1::SignedVoteResponse), + SignedProposal(proto::privval::v1::SignedProposalResponse), + Ping(proto::privval::v1::PingResponse), + PublicKey(proto::privval::v1::PubKeyResponse), } impl Response { @@ -123,27 +131,29 @@ impl Response { pub fn encode(self) -> Result, Error> { let mut buf = Vec::new(); let msg = match self { - Response::SignedVote(resp) => proto::privval::message::Sum::SignedVoteResponse(resp), + Response::SignedVote(resp) => { + proto::privval::v1::message::Sum::SignedVoteResponse(resp) + } Response::SignedProposal(resp) => { - proto::privval::message::Sum::SignedProposalResponse(resp) + proto::privval::v1::message::Sum::SignedProposalResponse(resp) } - Response::Ping(resp) => proto::privval::message::Sum::PingResponse(resp), - Response::PublicKey(resp) => proto::privval::message::Sum::PubKeyResponse(resp), + Response::Ping(resp) => proto::privval::v1::message::Sum::PingResponse(resp), + Response::PublicKey(resp) => proto::privval::v1::message::Sum::PubKeyResponse(resp), }; - proto::privval::Message { sum: Some(msg) }.encode_length_delimited(&mut buf)?; + proto::privval::v1::Message { sum: Some(msg) }.encode_length_delimited(&mut buf)?; Ok(buf) } /// Construct an error response for a given [`SignableMsg`]. - pub fn error(msg: SignableMsg, error: proto::privval::RemoteSignerError) -> Response { + pub fn error(msg: SignableMsg, error: proto::privval::v1::RemoteSignerError) -> Response { match msg { SignableMsg::Proposal(_) => { - Response::SignedProposal(proto::privval::SignedProposalResponse { + Response::SignedProposal(proto::privval::v1::SignedProposalResponse { proposal: None, error: Some(error), }) } - SignableMsg::Vote(_) => Response::SignedVote(proto::privval::SignedVoteResponse { + SignableMsg::Vote(_) => Response::SignedVote(proto::privval::v1::SignedVoteResponse { vote: None, error: Some(error), }), @@ -155,15 +165,17 @@ impl From for Response { fn from(msg: SignableMsg) -> Response { match msg { SignableMsg::Proposal(proposal) => { - Response::SignedProposal(proto::privval::SignedProposalResponse { + Response::SignedProposal(proto::privval::v1::SignedProposalResponse { proposal: Some(proposal.into()), error: None, }) } - SignableMsg::Vote(vote) => Response::SignedVote(proto::privval::SignedVoteResponse { - vote: Some(vote.into()), - error: None, - }), + SignableMsg::Vote(vote) => { + Response::SignedVote(proto::privval::v1::SignedVoteResponse { + vote: Some(vote.into()), + error: None, + }) + } } } } diff --git a/src/session.rs b/src/session.rs index d61f7831..80061472 100644 --- a/src/session.rs +++ b/src/session.rs @@ -9,10 +9,10 @@ use crate::{ privval::SignableMsg, rpc::{Request, Response}, }; +use cometbft::{consensus, CometbftKey}; +use cometbft_config::net; +use cometbft_proto as proto; use std::{os::unix::net::UnixStream, time::Instant}; -use tendermint::{consensus, TendermintKey}; -use tendermint_config::net; -use tendermint_proto as proto; /// Encrypted session with a validator node pub struct Session { @@ -107,7 +107,7 @@ impl Session { self.sign(request.into_signable_msg()?)? } // non-signable requests: - Request::PingRequest => Response::Ping(proto::privval::PingResponse {}), + Request::PingRequest => Response::Ping(proto::privval::v1::PingResponse {}), Request::ShowPublicKey => self.get_public_key()?, }; @@ -193,7 +193,7 @@ impl Session { &mut self, chain: &Chain, signable_msg: &SignableMsg, - ) -> Result, Error> { + ) -> Result, Error> { let msg_type = signable_msg.msg_type(); let request_state = signable_msg.consensus_state(); let mut chain_state = chain.state.lock().unwrap(); @@ -232,12 +232,13 @@ impl Session { }); let pub_key = match chain.keyring.default_pubkey()? { - TendermintKey::AccountKey(pk) => pk, - TendermintKey::ConsensusKey(pk) => pk, + CometbftKey::AccountKey(pk) => pk, + CometbftKey::ConsensusKey(pk) => pk, }; - Ok(Response::PublicKey(proto::privval::PubKeyResponse { - pub_key: Some(pub_key.into()), + Ok(Response::PublicKey(proto::privval::v1::PubKeyResponse { + pub_key_bytes: pub_key.to_bytes(), + pub_key_type: pub_key.type_str().to_owned(), error: None, })) } @@ -266,11 +267,11 @@ impl Session { } /// Double signing handler. -fn double_sign(consensus_state: consensus::State) -> proto::privval::RemoteSignerError { +fn double_sign(consensus_state: consensus::State) -> proto::privval::v1::RemoteSignerError { /// Double signing error code. const DOUBLE_SIGN_ERROR: i32 = 2; - proto::privval::RemoteSignerError { + proto::privval::v1::RemoteSignerError { code: DOUBLE_SIGN_ERROR, description: format!( "double signing requested at height: {}", diff --git a/src/yubihsm.rs b/src/yubihsm.rs index 5e456fb5..0858d234 100644 --- a/src/yubihsm.rs +++ b/src/yubihsm.rs @@ -23,7 +23,7 @@ use zeroize::Zeroizing; #[cfg(not(feature = "yubihsm-mock"))] use { crate::config::provider::yubihsm::AdapterConfig, - tendermint_config::net, + cometbft_config::net, yubihsm::{device::SerialNumber, HttpConfig, UsbConfig}, }; diff --git a/tests/integration.rs b/tests/integration.rs index eda8b7f7..56e8ecc1 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -2,6 +2,7 @@ use abscissa_core::prelude::warn; use chrono::{DateTime, Utc}; +use cometbft_proto as proto; use prost::Message; use rand::Rng; use signature::Verifier; @@ -15,7 +16,6 @@ use std::{ }; use tempfile::NamedTempFile; use tendermint_p2p::secret_connection::{self, SecretConnection}; -use tendermint_proto as proto; use tmkms::{ config::provider::KeyType, connection::unix::UnixConnection, @@ -339,7 +339,7 @@ fn handle_and_sign_proposal(key_type: KeyType) { }; ProtocolTester::apply(&key_type, |mut pt| { - let proposal = proto::types::Proposal { + let proposal = proto::types::v1::Proposal { r#type: SignedMsgType::Proposal.into(), height: 12345, round: 1, @@ -351,18 +351,18 @@ fn handle_and_sign_proposal(key_type: KeyType) { let signable_msg = SignableMsg::try_from(proposal.clone()).unwrap(); - let request = proto::privval::SignProposalRequest { + let request = proto::privval::v1::SignProposalRequest { proposal: Some(proposal), chain_id: chain_id.into(), }; send_request( - proto::privval::message::Sum::SignProposalRequest(request), + proto::privval::v1::message::Sum::SignProposalRequest(request), &mut pt, ); let response = match read_response(&mut pt) { - proto::privval::message::Sum::SignedProposalResponse(resp) => resp, + proto::privval::v1::message::Sum::SignedProposalResponse(resp) => resp, other => panic!("unexpected message type in response: {other:?}"), }; @@ -413,14 +413,14 @@ fn handle_and_sign_vote(key_type: KeyType) { }; ProtocolTester::apply(&key_type, |mut pt| { - let vote_msg = proto::types::Vote { + let vote_msg = proto::types::v1::Vote { r#type: 0x01, height: 12345, round: 2, timestamp: Some(t), - block_id: Some(proto::types::BlockId { + block_id: Some(proto::types::v1::BlockId { hash: b"some hash00000000000000000000000".to_vec(), - part_set_header: Some(proto::types::PartSetHeader { + part_set_header: Some(proto::types::v1::PartSetHeader { total: 1000000, hash: b"parts_hash0000000000000000000000".to_vec(), }), @@ -437,15 +437,19 @@ fn handle_and_sign_vote(key_type: KeyType) { let signable_msg = SignableMsg::try_from(vote_msg.clone()).unwrap(); - let vote = proto::privval::SignVoteRequest { + let vote = proto::privval::v1::SignVoteRequest { vote: Some(vote_msg), chain_id: chain_id.into(), + skip_extension_signing: false, }; - send_request(proto::privval::message::Sum::SignVoteRequest(vote), &mut pt); + send_request( + proto::privval::v1::message::Sum::SignVoteRequest(vote), + &mut pt, + ); let request = match read_response(&mut pt) { - proto::privval::message::Sum::SignedVoteResponse(resp) => resp, + proto::privval::v1::message::Sum::SignedVoteResponse(resp) => resp, other => panic!("unexpected message type in response: {other:?}"), }; @@ -453,7 +457,7 @@ fn handle_and_sign_vote(key_type: KeyType) { .canonical_bytes(chain_id.parse().unwrap()) .unwrap(); - let vote_msg: proto::types::Vote = request + let vote_msg: proto::types::v1::Vote = request .vote .expect("vote should be embedded int the response but none was found"); @@ -500,14 +504,14 @@ fn exceed_max_height(key_type: KeyType) { }; ProtocolTester::apply(&key_type, |mut pt| { - let vote_msg = proto::types::Vote { + let vote_msg = proto::types::v1::Vote { r#type: 0x01, height: 500001, round: 2, timestamp: Some(t), - block_id: Some(proto::types::BlockId { + block_id: Some(proto::types::v1::BlockId { hash: b"some hash00000000000000000000000".to_vec(), - part_set_header: Some(proto::types::PartSetHeader { + part_set_header: Some(proto::types::v1::PartSetHeader { total: 1000000, hash: b"parts_hash0000000000000000000000".to_vec(), }), @@ -524,15 +528,19 @@ fn exceed_max_height(key_type: KeyType) { let signable_msg = SignableMsg::try_from(vote_msg.clone()).unwrap(); - let vote = proto::privval::SignVoteRequest { + let vote = proto::privval::v1::SignVoteRequest { vote: Some(vote_msg), chain_id: chain_id.into(), + skip_extension_signing: false, }; - send_request(proto::privval::message::Sum::SignVoteRequest(vote), &mut pt); + send_request( + proto::privval::v1::message::Sum::SignVoteRequest(vote), + &mut pt, + ); let response = match read_response(&mut pt) { - proto::privval::message::Sum::SignedVoteResponse(resp) => resp, + proto::privval::v1::message::Sum::SignedVoteResponse(resp) => resp, other => panic!("unexpected message type in response: {other:?}"), }; @@ -579,31 +587,23 @@ fn handle_and_sign_get_publickey(key_type: KeyType) { let chain_id = "test_chain_id"; ProtocolTester::apply(&key_type, |mut pt| { - let request = proto::privval::PubKeyRequest { + let request = proto::privval::v1::PubKeyRequest { chain_id: chain_id.into(), }; send_request( - proto::privval::message::Sum::PubKeyRequest(request), + proto::privval::v1::message::Sum::PubKeyRequest(request), &mut pt, ); let response = match read_response(&mut pt) { - proto::privval::message::Sum::PubKeyResponse(resp) => resp, + proto::privval::v1::message::Sum::PubKeyResponse(resp) => resp, other => panic!("unexpected message type in response: {other:?}"), }; - let pub_key = response - .pub_key - .and_then(|pk| pk.sum) - .expect("missing public key"); - - let pk_bytes = match pub_key { - proto::crypto::public_key::Sum::Ed25519(bytes) => bytes, - proto::crypto::public_key::Sum::Secp256k1(bytes) => bytes, - }; - - assert_ne!(pk_bytes.len(), 0); + assert_ne!(response.pub_key_type.len(), 0); + // TODO: assert specific pub_key_type + assert_ne!(response.pub_key_bytes.len(), 0); }); } @@ -612,8 +612,11 @@ fn test_handle_and_sign_ping_pong() { let key_type = KeyType::Consensus; ProtocolTester::apply(&key_type, |mut pt| { - let request = proto::privval::PingRequest {}; - send_request(proto::privval::message::Sum::PingRequest(request), &mut pt); + let request = proto::privval::v1::PingRequest {}; + send_request( + proto::privval::v1::message::Sum::PingRequest(request), + &mut pt, + ); read_response(&mut pt); }); } @@ -624,7 +627,7 @@ fn test_buffer_underflow_sign_proposal() { ProtocolTester::apply(&key_type, |mut pt| { send_buffer_underflow_request(&mut pt); let response: Result<(), ()> = match read_response(&mut pt) { - proto::privval::message::Sum::SignedProposalResponse(_) => Ok(()), + proto::privval::v1::message::Sum::SignedProposalResponse(_) => Ok(()), other => panic!("unexpected message type in response: {other:?}"), }; @@ -633,9 +636,9 @@ fn test_buffer_underflow_sign_proposal() { } /// Encode request as a Protobuf message -fn send_request(request: proto::privval::message::Sum, pt: &mut ProtocolTester) { +fn send_request(request: proto::privval::v1::message::Sum, pt: &mut ProtocolTester) { let mut buf = vec![]; - proto::privval::Message { sum: Some(request) } + proto::privval::v1::Message { sum: Some(request) } .encode_length_delimited(&mut buf) .unwrap(); @@ -652,7 +655,7 @@ fn send_buffer_underflow_request(pt: &mut ProtocolTester) { } /// Read the response as a Protobuf message -fn read_response(pt: &mut ProtocolTester) -> proto::privval::message::Sum { +fn read_response(pt: &mut ProtocolTester) -> proto::privval::v1::message::Sum { let mut resp_buf = vec![0u8; 4096]; pt.read(&mut resp_buf).unwrap(); @@ -660,6 +663,7 @@ fn read_response(pt: &mut ProtocolTester) -> proto::privval::message::Sum { let mut resp_bytes = vec![0u8; actual_len as usize]; resp_bytes.copy_from_slice(&resp_buf[..actual_len as usize]); - let message = proto::privval::Message::decode_length_delimited(resp_bytes.as_ref()).unwrap(); + let message = + proto::privval::v1::Message::decode_length_delimited(resp_bytes.as_ref()).unwrap(); message.sum.expect("no sum field in message") }