From 2c763f2ae5be293312c4db1f3846357931ad8314 Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Tue, 29 Aug 2023 19:01:42 -0400 Subject: [PATCH 1/5] chore: upgrade error-stack version and remove deprecated dependencies --- Cargo.lock | 178 ++++++++------------- Cargo.toml | 2 +- ampd/src/broadcaster.rs | 22 +-- ampd/src/broadcaster/accounts.rs | 14 +- ampd/src/broadcaster/clients.rs | 10 +- ampd/src/broadcaster/dec_coin.rs | 11 +- ampd/src/event_processor.rs | 25 ++- ampd/src/event_sub.rs | 12 +- ampd/src/evm/json_rpc.rs | 10 +- ampd/src/handlers/chain.rs | 6 +- ampd/src/handlers/end_block.rs | 9 +- ampd/src/handlers/evm_verify_msg.rs | 4 +- ampd/src/lib.rs | 8 +- ampd/src/main.rs | 4 +- ampd/src/state.rs | 15 +- ampd/src/tm_client.rs | 8 +- ampd/src/tofnd/grpc.rs | 18 +-- packages/axelar-wasm-std/Cargo.toml | 2 + packages/axelar-wasm-std/src/lib.rs | 2 + packages/axelar-wasm-std/src/result_ext.rs | 22 +++ packages/events-derive/src/lib.rs | 5 +- packages/events/src/event.rs | 6 +- 22 files changed, 171 insertions(+), 222 deletions(-) create mode 100644 packages/axelar-wasm-std/src/result_ext.rs diff --git a/Cargo.lock b/Cargo.lock index 68047db5e..c5983428c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -82,7 +82,7 @@ version = "0.1.0" dependencies = [ "async-trait", "axelar-wasm-std", - "base64 0.21.2", + "base64 0.21.3", "clap", "config", "connection-router", @@ -263,17 +263,6 @@ dependencies = [ "rustc_version", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "auto_impl" version = "1.1.0" @@ -301,6 +290,8 @@ dependencies = [ "cosmwasm-storage", "cw-multi-test", "cw-storage-plus 1.1.0", + "error-stack", + "eyre", "flagset", "num-traits", "rand", @@ -391,9 +382,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -606,15 +597,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "winapi", + "windows-targets", ] [[package]] @@ -629,9 +620,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d5f1946157a96594eb2d2c10eb7ad9a2b27518cb3000209dec700c35df9197d" +checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" dependencies = [ "clap_builder", "clap_derive", @@ -640,9 +631,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.0" +version = "4.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78116e32a042dd73c2901f0dc30790d20ff3447f3e3472fad359e8c3d282bcd6" +checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" dependencies = [ "anstream", "anstyle", @@ -707,7 +698,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bech32", "bs58", "digest 0.10.7", @@ -769,9 +760,9 @@ dependencies = [ [[package]] name = "const-hex" -version = "1.6.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca268df6cd88e646b564e6aff1a016834e5f42077c736ef6b6789c31ef9ec5dc" +checksum = "08849ed393c907c90016652a01465a12d86361cd38ad2a7de026c56a520cc259" dependencies = [ "cfg-if", "cpufeatures", @@ -1582,7 +1573,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0be7b2ac146c1f99fe245c02d16af0696450d8e06c135db75e10eeb9e642c20d" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bytes", "hex", "k256 0.13.1", @@ -1614,9 +1605,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -1635,13 +1626,12 @@ dependencies = [ [[package]] name = "error-stack" -version = "0.2.4" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d224e04b2d93d974c08e375dac9b8d1a513846e44c6666450a57b1ed963f9" +checksum = "e6a37ef405b504fc3b87a24fa52906d98cdd1a7d4e5ef2b49f0d5fead138fced" dependencies = [ "anyhow", "eyre", - "owo-colors", "rustc_version", ] @@ -1882,7 +1872,7 @@ checksum = "00c84664b294e47fc2860d6db0db0246f79c4c724e552549631bb9505b834bee" dependencies = [ "async-trait", "auto_impl", - "base64 0.21.2", + "base64 0.21.3", "bytes", "const-hex", "enr", @@ -1967,7 +1957,7 @@ name = "events" version = "0.1.0" dependencies = [ "axelar-wasm-std", - "base64 0.21.2", + "base64 0.21.3", "error-stack", "serde_json", "tendermint 0.33.0", @@ -2411,15 +2401,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.2" @@ -2573,7 +2554,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.6", + "rustls 0.21.7", "tokio", "tokio-rustls 0.24.1", ] @@ -2725,17 +2706,11 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "rustix", "windows-sys", ] -[[package]] -name = "is_ci" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" - [[package]] name = "itertools" version = "0.10.5" @@ -2786,7 +2761,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "pem", "ring", "serde", @@ -2920,9 +2895,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f478948fd84d9f8e86967bf432640e46adfb5a4bd4f14ef7e864ab38220534ae" [[package]] name = "memoffset" @@ -3131,7 +3106,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.2", + "hermit-abi", "libc", ] @@ -3230,20 +3205,11 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" -dependencies = [ - "supports-color", -] - [[package]] name = "parity-scale-codec" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8e946cc0cc711189c0b0249fb8b599cbeeab9784d83c415719368bb8d4ac64" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" dependencies = [ "arrayvec", "bitvec", @@ -3255,9 +3221,9 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.4" +version = "3.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a296c3079b5fefbc499e1de58dc26c09b1b9a5952d26694ee89f04a43ebbb3e" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -3518,9 +3484,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -3863,9 +3829,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" dependencies = [ "aho-corasick", "memchr", @@ -3875,9 +3841,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" dependencies = [ "aho-corasick", "memchr", @@ -3886,9 +3852,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "reqwest" @@ -3896,7 +3862,7 @@ version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bytes", "encoding_rs", "futures-core", @@ -3913,7 +3879,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.6", + "rustls 0.21.7", "rustls-pemfile", "serde", "serde_json", @@ -4040,9 +4006,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.8" +version = "0.38.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +checksum = "ed6248e1caa625eb708e266e06159f135e8c26f2bb7ceb72dc4b2766d0340964" dependencies = [ "bitflags 2.4.0", "errno", @@ -4066,9 +4032,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.6" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", @@ -4094,7 +4060,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", ] [[package]] @@ -4182,9 +4148,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" dependencies = [ "dyn-clone", "schemars_derive", @@ -4194,9 +4160,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" dependencies = [ "proc-macro2", "quote", @@ -4316,9 +4282,9 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.186" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f5db24220c009de9bd45e69fb2938f4b6d2df856aa9304ce377b3180f83b7c1" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -4354,9 +4320,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.186" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ad697f7e0b65af4983a4ce8f56ed5b357e8d3c36651bf6a7e13639c17b8e670" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -4423,7 +4389,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "chrono", "hex", "indexmap 1.9.3", @@ -4715,16 +4681,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" -[[package]] -name = "supports-color" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" -dependencies = [ - "atty", - "is_ci", -] - [[package]] name = "svm-rs" version = "0.3.0" @@ -5000,9 +4956,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb39ee79a6d8de55f48f2293a830e040392f1c5f16e336bdd1788cd0aadce07" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ "deranged", "itoa", @@ -5019,9 +4975,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733d258752e9303d392b94b75230d07b0b9c489350c69b851fc6c065fde3e8f9" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -5106,7 +5062,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.6", + "rustls 0.21.7", "tokio", ] @@ -5130,7 +5086,7 @@ checksum = "2b2dbec703c26b00d74844519606ef15d09a7d6857860f84ad223dec002ddea2" dependencies = [ "futures-util", "log", - "rustls 0.21.6", + "rustls 0.21.7", "tokio", "tokio-rustls 0.24.1", "tungstenite", @@ -5376,7 +5332,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.21.6", + "rustls 0.21.7", "sha1", "thiserror", "url", @@ -5442,9 +5398,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", diff --git a/Cargo.toml b/Cargo.toml index 723fbaf7d..609befe6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ [workspace.dependencies] connection-router = { version = "^0.1.0", path = "contracts/connection-router" } -error-stack = { version = "0.2.4", features = ["eyre"] } +error-stack = { version = "0.4.0", features = ["eyre"] } events = { version = "^0.1.0", path = "packages/events" } events-derive = { version = "^0.1.0", path = "packages/events-derive" } axelar-wasm-std = { version = "^0.1.0", path = "packages/axelar-wasm-std" } diff --git a/ampd/src/broadcaster.rs b/ampd/src/broadcaster.rs index 21f4b8366..89f189525 100644 --- a/ampd/src/broadcaster.rs +++ b/ampd/src/broadcaster.rs @@ -2,6 +2,7 @@ use std::thread; use std::time::Duration; use async_trait::async_trait; +use axelar_wasm_std::ResultCompatExt; use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse; use cosmos_sdk_proto::cosmos::tx::v1beta1::{ BroadcastMode, BroadcastTxRequest, GetTxRequest, GetTxResponse, SimulateRequest, TxRaw, @@ -11,7 +12,7 @@ use cosmrs::tendermint::chain::Id; use cosmrs::tx::{BodyBuilder, Fee, SignDoc, SignerInfo}; use cosmrs::{Coin, Gas}; use derive_builder::Builder; -use error_stack::{FutureExt, IntoReport, IntoReportCompat, Report, Result, ResultExt}; +use error_stack::{FutureExt, Report, Result, ResultExt}; use futures::TryFutureExt; use mockall::automock; use serde::Deserialize; @@ -159,8 +160,7 @@ where response .gas_info .map(|info| info.gas_used) - .ok_or(Error::GasEstimation) - .into_report() + .ok_or(Error::GasEstimation.into()) }) .await } @@ -173,14 +173,12 @@ where .msgs(msgs) .finish() .into_bytes() - .into_report() .change_context(Error::TxMarshaling)?; let auth_info_bytes = SignerInfo::single_direct(Some(self.priv_key.public_key()), self.acc_sequence) .auth_info(zero_fee()) .into_bytes() - .into_report() .change_context(Error::TxMarshaling)?; let raw = TxRaw { @@ -190,9 +188,7 @@ where signatures: vec![vec![0; 64]], }; - raw.to_bytes() - .into_report() - .change_context(Error::TxMarshaling) + raw.to_bytes().change_context(Error::TxMarshaling) } pub fn create_tx(&self, msgs: M, fee: Fee) -> Result @@ -211,7 +207,6 @@ where tx_bytes: tx, mode: BroadcastMode::Sync as i32, }) - .into_report() .change_context(Error::TxMarshaling) } @@ -241,7 +236,7 @@ where return Ok(()); } - ConfirmationResult::Critical(err) => return Err(err).into_report(), + ConfirmationResult::Critical(err) => return Err(err.into()), ConfirmationResult::Retriable(err) => { if let Err(result) = result.as_mut() { result.extend_one(err); @@ -284,7 +279,6 @@ mod tests { use cosmos_sdk_proto::cosmos::tx::v1beta1::{GetTxResponse, SimulateResponse}; use cosmos_sdk_proto::Any; use cosmrs::{bank::MsgSend, tx::Msg, AccountId}; - use error_stack::IntoReport; use tokio::test; use tonic::Status; @@ -298,7 +292,7 @@ mod tests { let mut client = MockBroadcastClient::new(); client .expect_simulate() - .returning(|_| Err(Status::unavailable("unavailable service")).into_report()); + .returning(|_| Err(Status::unavailable("unavailable service").into())); let signer = MockEcdsaClient::new(); let priv_key = ECDSASigningKey::random(); @@ -375,7 +369,7 @@ mod tests { client .expect_broadcast_tx() - .returning(|_| Err(Status::aborted("failed")).into_report()); + .returning(|_| Err(Status::aborted("failed").into())); let signer = MockEcdsaClient::new(); let priv_key = ECDSASigningKey::random(); @@ -422,7 +416,7 @@ mod tests { client .expect_get_tx() .times((Config::default().tx_fetch_max_retries + 1) as usize) - .returning(|_| Err(Status::deadline_exceeded("time out")).into_report()); + .returning(|_| Err(Status::deadline_exceeded("time out").into())); let signer = MockEcdsaClient::new(); let priv_key = ECDSASigningKey::random(); diff --git a/ampd/src/broadcaster/accounts.rs b/ampd/src/broadcaster/accounts.rs index 0d3090faf..8c53da779 100644 --- a/ampd/src/broadcaster/accounts.rs +++ b/ampd/src/broadcaster/accounts.rs @@ -2,7 +2,7 @@ use crate::broadcaster::clients::AccountQueryClient; use crate::types::TMAddress; use cosmos_sdk_proto::cosmos::auth::v1beta1::{BaseAccount, QueryAccountRequest}; use cosmos_sdk_proto::traits::Message; -use error_stack::{FutureExt, IntoReport, Result, ResultExt}; +use error_stack::{FutureExt, Result, ResultExt}; use thiserror::Error; #[derive(Error, Debug)] @@ -30,13 +30,14 @@ where let account = response .account - .ok_or_else(|| Error::AccountNotFound { - address: address.clone(), + .ok_or_else(|| { + Error::AccountNotFound { + address: address.clone(), + } + .into() }) - .into_report() .and_then(|account| { BaseAccount::decode(&account.value[..]) - .into_report() .change_context(Error::MalformedResponse) .attach_printable_lazy(|| format!("{{ value = {:?} }}", account.value)) })?; @@ -55,7 +56,6 @@ mod tests { use cosmos_sdk_proto::cosmos::auth::v1beta1::QueryAccountResponse; use cosmos_sdk_proto::traits::MessageExt; use cosmrs::Any; - use error_stack::IntoReport; use tokio::test; use tonic::Status; @@ -64,7 +64,7 @@ mod tests { let mut client = MockAccountQueryClient::new(); client .expect_account() - .returning(|_| Err(Status::aborted("aborted")).into_report()); + .returning(|_| Err(Status::aborted("aborted").into())); let address = ECDSASigningKey::random().address(); diff --git a/ampd/src/broadcaster/clients.rs b/ampd/src/broadcaster/clients.rs index 3d4c43651..a453dd2c9 100644 --- a/ampd/src/broadcaster/clients.rs +++ b/ampd/src/broadcaster/clients.rs @@ -6,7 +6,7 @@ use cosmos_sdk_proto::cosmos::tx::v1beta1::service_client::ServiceClient; use cosmos_sdk_proto::cosmos::tx::v1beta1::{ BroadcastTxRequest, GetTxRequest, GetTxResponse, SimulateRequest, SimulateResponse, }; -use error_stack::{IntoReport, Result}; +use error_stack::{Report, Result}; use mockall::automock; use tonic::transport::Channel; @@ -31,21 +31,21 @@ impl BroadcastClient for ServiceClient { .tx_response .ok_or_else(|| Status::not_found("tx not found")) }) - .into_report() + .map_err(Report::from) } async fn simulate(&mut self, request: SimulateRequest) -> Result { self.simulate(request) .await .map(Response::into_inner) - .into_report() + .map_err(Report::from) } async fn get_tx(&mut self, request: GetTxRequest) -> Result { self.get_tx(request) .await .map(Response::into_inner) - .into_report() + .map_err(Report::from) } } @@ -67,6 +67,6 @@ impl AccountQueryClient for QueryClient { self.account(request) .await .map(Response::into_inner) - .into_report() + .map_err(Report::from) } } diff --git a/ampd/src/broadcaster/dec_coin.rs b/ampd/src/broadcaster/dec_coin.rs index ce67b89f3..c5576b5e1 100644 --- a/ampd/src/broadcaster/dec_coin.rs +++ b/ampd/src/broadcaster/dec_coin.rs @@ -3,8 +3,9 @@ use std::fmt::{Debug, Display, Formatter}; use std::str::FromStr; use std::{fmt, ops}; +use axelar_wasm_std::ResultCompatExt; use cosmrs::proto; -use error_stack::{ensure, IntoReport, IntoReportCompat, Report, Result, ResultExt}; +use error_stack::{ensure, Report, Result, ResultExt}; use serde::{Deserialize, Serialize}; use thiserror::Error; use tracing::error; @@ -93,10 +94,7 @@ impl FromStr for FiniteAmount { type Err = Report; fn from_str(s: &str) -> std::result::Result { - let f = s - .parse::() - .into_report() - .change_context(ParsingFailed)?; + let f = s.parse::().change_context(ParsingFailed)?; f.try_into() } } @@ -139,8 +137,7 @@ impl FromStr for Denom { type Err = Report; fn from_str(denom: &str) -> std::result::Result { - let denom: cosmrs::Denom = - IntoReportCompat::into_report(denom.parse()).change_context(ParsingFailed)?; + let denom: cosmrs::Denom = ResultCompatExt::change_context(denom.parse(), ParsingFailed)?; denom.try_into() } } diff --git a/ampd/src/event_processor.rs b/ampd/src/event_processor.rs index afb26572b..da51e8dcc 100644 --- a/ampd/src/event_processor.rs +++ b/ampd/src/event_processor.rs @@ -3,7 +3,7 @@ use core::pin::Pin; use std::vec; use async_trait::async_trait; -use error_stack::{Context, IntoReport, Result, ResultExt}; +use error_stack::{Context, Result, ResultExt}; use events::Event; use futures::{future::try_join_all, StreamExt}; use thiserror::Error; @@ -41,6 +41,7 @@ fn consume_events(event_stream: S, handler: H, token: CancellationToken where H: EventHandler + Send + Sync + 'static, S: Stream> + Send + 'static, + E: Context, { let task = async move { let mut event_stream = Box::pin(event_stream); @@ -80,6 +81,7 @@ impl EventProcessor { where H: EventHandler + Send + Sync + 'static, S: Stream> + Send + 'static, + E: Context, { self.tasks .push(consume_events(event_stream, handler, self.token.child_token()).into()); @@ -91,7 +93,6 @@ impl EventProcessor { try_join_all(handles) .await - .into_report() .change_context(EventProcessorError::EventHandlerError)? .into_iter() .find(Result::is_err) @@ -103,12 +104,12 @@ impl EventProcessor { mod tests { use crate::event_processor::{EventHandler, EventProcessor}; use async_trait::async_trait; - use error_stack::{IntoReport, Result}; + use error_stack::{Report, Result}; + use futures::TryStreamExt; use mockall::mock; use thiserror::Error; use tokio::{self, sync::broadcast}; use tokio_stream::wrappers::BroadcastStream; - use tokio_stream::StreamExt; use tokio_util::sync::CancellationToken; #[tokio::test] @@ -130,10 +131,7 @@ mod tests { } }); - processor.add_handler( - handler, - BroadcastStream::new(rx).map(IntoReport::into_report), - ); + processor.add_handler(handler, BroadcastStream::new(rx).map_err(Report::from)); assert!(processor.run().await.is_ok()); } @@ -146,17 +144,14 @@ mod tests { let mut handler = MockEventHandler::new(); handler .expect_handle() - .returning(|_| Err(EventHandlerError::Unknown).into_report()) + .returning(|_| Err(EventHandlerError::Unknown.into())) .once(); tokio::spawn(async move { assert!(tx.send(events::Event::BlockEnd((10_u32).into())).is_ok()); }); - processor.add_handler( - handler, - BroadcastStream::new(rx).map(IntoReport::into_report), - ); + processor.add_handler(handler, BroadcastStream::new(rx).map_err(Report::from)); assert!(processor.run().await.is_err()); } @@ -166,8 +161,8 @@ mod tests { let (tx, rx) = broadcast::channel::(event_count); let token = CancellationToken::new(); let mut processor = EventProcessor::new(token.child_token()); - let stream = BroadcastStream::new(rx).map(IntoReport::into_report); - let another_stream = BroadcastStream::new(tx.subscribe()).map(IntoReport::into_report); + let stream = BroadcastStream::new(rx).map_err(Report::from); + let another_stream = BroadcastStream::new(tx.subscribe()).map_err(Report::from); let mut handler = MockEventHandler::new(); handler diff --git a/ampd/src/event_sub.rs b/ampd/src/event_sub.rs index 595aac8b9..06481f450 100644 --- a/ampd/src/event_sub.rs +++ b/ampd/src/event_sub.rs @@ -2,8 +2,9 @@ use std::convert::TryInto; use std::iter; use std::time::Duration; -use error_stack::{FutureExt, Result}; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; +use error_stack::{FutureExt, Report, Result}; +use futures::TryStreamExt; use tendermint::abci; use tendermint::block; use thiserror::Error; @@ -53,7 +54,7 @@ impl EventSub { } pub fn sub(&mut self) -> impl Stream> { - BroadcastStream::new(self.tx.subscribe()).map(IntoReport::into_report) + BroadcastStream::new(self.tx.subscribe()).map_err(Report::from) } pub async fn run(mut self) -> Result<(), EventSubError> { @@ -123,10 +124,7 @@ impl EventSub { .chain(iter::once(Event::BlockEnd(height))); for event in events { - self.tx - .send(event) - .into_report() - .change_context(EventSubError::Publish)?; + self.tx.send(event).change_context(EventSubError::Publish)?; } Ok(()) diff --git a/ampd/src/evm/json_rpc.rs b/ampd/src/evm/json_rpc.rs index 679bc1b25..424929083 100644 --- a/ampd/src/evm/json_rpc.rs +++ b/ampd/src/evm/json_rpc.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use error_stack::{self, IntoReport}; +use error_stack::Report; use ethers::providers::{Http, JsonRpcClient, ProviderError}; use ethers::types::{Block, BlockNumber, TransactionReceipt, H256, U64}; use ethers::utils::serialize; @@ -58,7 +58,7 @@ where ) .await .map_err(Into::into) - .into_report() + .map_err(Report::from) } async fn block_number(&self) -> Result { @@ -66,7 +66,7 @@ where .request("eth_blockNumber", ()) .await .map_err(Into::into) - .into_report() + .map_err(Report::from) } async fn transaction_receipt(&self, hash: H256) -> Result> { @@ -74,7 +74,7 @@ where .request("eth_getTransactionReceipt", [hash]) .await .map_err(Into::into) - .into_report() + .map_err(Report::from) } } @@ -88,6 +88,6 @@ where .request("chain_getFinalizedHead", ()) .await .map_err(Into::into) - .into_report() + .map_err(Report::from) } } diff --git a/ampd/src/handlers/chain.rs b/ampd/src/handlers/chain.rs index 9d1589916..e1f077471 100644 --- a/ampd/src/handlers/chain.rs +++ b/ampd/src/handlers/chain.rs @@ -58,7 +58,7 @@ where mod tests { use crate::event_processor::{self, EventHandler}; use async_trait::async_trait; - use error_stack::{IntoReport, Result}; + use error_stack::Result; use events::Event; use mockall::{mock, predicate}; use tendermint::block; @@ -97,7 +97,7 @@ mod tests { .expect_handle() .once() .with(predicate::eq(Event::BlockEnd(height))) - .returning(|_| Err(EventHandlerError::Unknown).into_report()); + .returning(|_| Err(EventHandlerError::Unknown.into())); assert!(handler_1 .chain(MockEventHandler::new()) @@ -121,7 +121,7 @@ mod tests { .expect_handle() .once() .with(predicate::eq(Event::BlockEnd(height))) - .returning(|_| Err(EventHandlerError::Unknown).into_report()); + .returning(|_| Err(EventHandlerError::Unknown.into())); assert!(handler_1 .chain(handler_2) diff --git a/ampd/src/handlers/end_block.rs b/ampd/src/handlers/end_block.rs index b41ad66aa..75281aa65 100644 --- a/ampd/src/handlers/end_block.rs +++ b/ampd/src/handlers/end_block.rs @@ -1,6 +1,6 @@ use crate::event_processor::EventHandler; use async_trait::async_trait; -use error_stack::{IntoReport, Result, ResultExt}; +use error_stack::{Result, ResultExt}; use events::Event; use tendermint::block; use thiserror::Error; @@ -36,12 +36,7 @@ impl EventHandler for Handler { async fn handle(&self, event: &Event) -> Result<(), Error> { match event { - Event::BlockEnd(height) => self - .tx - .send(*height) - .await - .into_report() - .change_context(Error::SendError), + Event::BlockEnd(height) => self.tx.send(*height).await.change_context(Error::SendError), _ => Ok(()), } } diff --git a/ampd/src/handlers/evm_verify_msg.rs b/ampd/src/handlers/evm_verify_msg.rs index ef32a9c9d..8da364bba 100644 --- a/ampd/src/handlers/evm_verify_msg.rs +++ b/ampd/src/handlers/evm_verify_msg.rs @@ -3,7 +3,7 @@ use std::convert::TryInto; use async_trait::async_trait; use cosmrs::cosmwasm::MsgExecuteContract; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use ethers::types::{TransactionReceipt, U64}; use futures::future::join_all; use serde::Deserialize; @@ -105,7 +105,7 @@ where ) .await .into_iter() - .filter_map(std::result::Result::unwrap_or_default) + .filter_map(Result::unwrap_or_default) .filter_map(|tx_receipt| { if tx_receipt .block_number diff --git a/ampd/src/lib.rs b/ampd/src/lib.rs index e7eb8e4b0..b0ecb67bd 100644 --- a/ampd/src/lib.rs +++ b/ampd/src/lib.rs @@ -4,7 +4,7 @@ use std::pin::Pin; use cosmos_sdk_proto::cosmos::{ auth::v1beta1::query_client::QueryClient, tx::v1beta1::service_client::ServiceClient, }; -use error_stack::{FutureExt, IntoReport, Result, ResultExt}; +use error_stack::{FutureExt, Report, Result, ResultExt}; use tokio::signal::unix::{signal, SignalKind}; use tokio::task::JoinSet; use tokio_stream::Stream; @@ -88,7 +88,6 @@ pub async fn run(cfg: Config, state_path: PathBuf) -> Result<(), Error> { .pub_key((tofnd_config.key_uid, pub_key)) .config(broadcast.clone()) .build() - .into_report() .change_context(Error::Broadcaster)?; App::new( @@ -225,10 +224,7 @@ where let res = match (set.join_next().await, token.is_cancelled()) { (Some(result), false) => { token.cancel(); - result - .map_err(Error::new) - .into_report() - .and_then(|result| result) + result.map_err(Error::new).map_err(Report::from)? } (Some(_), true) => Ok(()), (None, _) => panic!("all tasks exited unexpectedly"), diff --git a/ampd/src/main.rs b/ampd/src/main.rs index 5fac98466..930db79b0 100644 --- a/ampd/src/main.rs +++ b/ampd/src/main.rs @@ -6,7 +6,7 @@ use std::process::ExitCode; use ::config::{Config as cfg, Environment, File, FileFormat, FileSourceFile}; use clap::{Parser, ValueEnum}; use config::ConfigError; -use error_stack::IntoReport; +use error_stack::Report; use tracing::{error, info}; use ampd::config::Config; @@ -63,7 +63,7 @@ fn init_config(args: &Args) -> Config { let files = find_config_files(&args.config); info!("found {} config files to load", files.len()); - match parse_config(files).into_report() { + match parse_config(files).map_err(Report::from) { Ok(cfg) => cfg, Err(report) => { let err = LoggableError::from(&report); diff --git a/ampd/src/state.rs b/ampd/src/state.rs index 6418159e4..bb777a16f 100644 --- a/ampd/src/state.rs +++ b/ampd/src/state.rs @@ -1,6 +1,6 @@ use std::{collections::HashMap, fs, path::PathBuf}; -use error_stack::{IntoReport, Result, ResultExt}; +use error_stack::{Result, ResultExt}; use serde::{Deserialize, Serialize}; use tendermint::block; use thiserror::Error; @@ -50,9 +50,7 @@ pub struct StateUpdater { impl StateUpdater { pub fn new(state_path: PathBuf) -> Result { let state = match fs::read_to_string(state_path.as_path()) { - Ok(state) => serde_json::from_str(&state) - .into_report() - .change_context(Error::InvalidState)?, + Ok(state) => serde_json::from_str(&state).change_context(Error::InvalidState)?, Err(_) => { info!("state does not exist, falling back to default"); @@ -92,13 +90,10 @@ impl StateUpdater { fn flush(self) -> Result<(), Error> { info!("persisting state to disk"); - let state = serde_json::to_string(&self.state) - .into_report() - .change_context(Error::SerializationFailure)?; + let state = + serde_json::to_string(&self.state).change_context(Error::SerializationFailure)?; - fs::write(self.state_path, state) - .into_report() - .change_context(Error::WriteFailure)?; + fs::write(self.state_path, state).change_context(Error::WriteFailure)?; Ok(()) } diff --git a/ampd/src/tm_client.rs b/ampd/src/tm_client.rs index 9d90e7a6e..44f91b475 100644 --- a/ampd/src/tm_client.rs +++ b/ampd/src/tm_client.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use error_stack::{IntoReport, Result}; +use error_stack::{Report, Result}; use mockall::automock; use tendermint::block::Height; use tendermint_rpc::{Client, HttpClient}; @@ -18,10 +18,12 @@ pub trait TmClient { #[async_trait] impl TmClient for HttpClient { async fn latest_block(&self) -> Result { - Client::latest_block(self).await.into_report() + Client::latest_block(self).await.map_err(Report::from) } async fn block_results(&self, height: Height) -> Result { - Client::block_results(self, height).await.into_report() + Client::block_results(self, height) + .await + .map_err(Report::from) } } diff --git a/ampd/src/tofnd/grpc.rs b/ampd/src/tofnd/grpc.rs index 00e81f5b7..417be99a2 100644 --- a/ampd/src/tofnd/grpc.rs +++ b/ampd/src/tofnd/grpc.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use async_trait::async_trait; use ecdsa::VerifyingKey; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use mockall::automock; use tokio::sync::Mutex; use tonic::{transport::Channel, Status}; @@ -39,7 +39,6 @@ impl MultisigClient { party_uid, client: multisig_client::MultisigClient::connect(url.to_string()) .await - .into_report() .change_context(Error::Grpc)?, }) } @@ -62,19 +61,17 @@ impl EcdsaClient for MultisigClient { .keygen_response .ok_or_else(|| Status::internal("keygen response is empty")) }) - .into_report() .change_context(Error::Grpc) .and_then(|response| match response { KeygenResponse::PubKey(pub_key) => { VerifyingKey::from_sec1_bytes(pub_key.as_slice()) - .into_report() .change_context(Error::ParsingFailed) .attach_printable(format!("{{ invalid_value = {:?} }}", pub_key)) .map(Into::into) } - KeygenResponse::Error(error_msg) => Err(TofndError::ExecutionFailed(error_msg)) - .into_report() - .change_context(Error::KeygenFailed), + KeygenResponse::Error(error_msg) => { + Err(TofndError::ExecutionFailed(error_msg)).change_context(Error::KeygenFailed) + } }) } @@ -100,13 +97,12 @@ impl EcdsaClient for MultisigClient { .sign_response .ok_or_else(|| Status::internal("sign response is empty")) }) - .into_report() .change_context(Error::Grpc) .and_then(|response| match response { SignResponse::Signature(signature) => Ok(signature), - SignResponse::Error(error_msg) => Err(TofndError::ExecutionFailed(error_msg)) - .into_report() - .change_context(Error::SignFailed), + SignResponse::Error(error_msg) => { + Err(TofndError::ExecutionFailed(error_msg)).change_context(Error::SignFailed) + } }) } } diff --git a/packages/axelar-wasm-std/Cargo.toml b/packages/axelar-wasm-std/Cargo.toml index 7a377da54..9fdfa433c 100644 --- a/packages/axelar-wasm-std/Cargo.toml +++ b/packages/axelar-wasm-std/Cargo.toml @@ -28,6 +28,7 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] +error-stack = {workspace = true} cosmwasm-schema = "1.1.3" cosmwasm-std = "1.2.1" cosmwasm-storage = "1.1.3" @@ -39,6 +40,7 @@ serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" sha3 = { version = "0.10", default-features = false, features = [] } thiserror = { version = "1.0.31" } +eyre = "0.6.8" [dev-dependencies] cw-multi-test = "0.15.1" diff --git a/packages/axelar-wasm-std/src/lib.rs b/packages/axelar-wasm-std/src/lib.rs index bc6c84c1e..eb91a73a3 100644 --- a/packages/axelar-wasm-std/src/lib.rs +++ b/packages/axelar-wasm-std/src/lib.rs @@ -3,12 +3,14 @@ pub mod flagset; mod fn_ext; pub mod nonempty; pub mod operators; +mod result_ext; pub mod snapshot; pub mod threshold; pub mod voting; pub use crate::{ fn_ext::FnExt, + result_ext::ResultCompatExt, snapshot::{Participant, Snapshot}, threshold::Threshold, }; diff --git a/packages/axelar-wasm-std/src/result_ext.rs b/packages/axelar-wasm-std/src/result_ext.rs new file mode 100644 index 000000000..eb0bfb02e --- /dev/null +++ b/packages/axelar-wasm-std/src/result_ext.rs @@ -0,0 +1,22 @@ +use error_stack::{Context, IntoReportCompat, Report}; +use eyre::Report as EyreReport; + +pub trait ResultCompatExt { + type Ok; + + fn change_context(self, context: C) -> Result> + where + C: Context; +} + +impl ResultCompatExt for Result { + type Ok = T; + + fn change_context(self, context: C) -> Result> + where + C: Context, + { + self.into_report() + .map_err(|report| report.change_context(context)) + } +} diff --git a/packages/events-derive/src/lib.rs b/packages/events-derive/src/lib.rs index f315b10d9..695394f46 100644 --- a/packages/events-derive/src/lib.rs +++ b/packages/events-derive/src/lib.rs @@ -39,7 +39,7 @@ pub fn try_from(arg: TokenStream, input: TokenStream) -> TokenStream { TokenStream::from(quote! { #input - use error_stack::{IntoReport as _, ResultExt as _}; + use error_stack::{ResultExt as _}; use events as _internal_events; use core::convert::TryFrom as _internal_TryFrom; @@ -51,14 +51,13 @@ pub fn try_from(arg: TokenStream, input: TokenStream) -> TokenStream { _internal_events::Event::Abci { event_type, attributes } if event_type == #event_type => { let event = #event_struct::deserialize(serde::de::value::MapDeserializer::new(attributes.clone().into_iter())) - .into_report() .change_context(_internal_events::Error::DeserializationFailed( #event_type.to_string(), #event_struct_name.to_string()), )?; Ok(event) } - event => Err(_internal_events::Error::EventTypeMismatch(#event_type.to_string())).into_report() + event => Err(_internal_events::Error::EventTypeMismatch(#event_type.to_string())) .attach_printable(format!("{{ event = {event:?} }}")), } } diff --git a/packages/events/src/event.rs b/packages/events/src/event.rs index 9617947ae..4e8f94dca 100644 --- a/packages/events/src/event.rs +++ b/packages/events/src/event.rs @@ -1,7 +1,7 @@ use axelar_wasm_std::FnExt; use base64::engine::general_purpose::STANDARD; use base64::Engine; -use error_stack::{IntoReport, Report, Result, ResultExt}; +use error_stack::{Report, Result, ResultExt}; use serde_json::Value; use tendermint::abci::EventAttribute; use tendermint::{abci, block}; @@ -63,8 +63,8 @@ fn try_into_kv_pair(attr: &EventAttribute) -> Result<(String, Value), Error> { fn decode_event_attribute(attribute: &EventAttribute) -> Result<(String, String), DecodingError> { Ok(( - base64_to_utf8(&attribute.key).into_report()?, - base64_to_utf8(&attribute.value).into_report()?, + base64_to_utf8(&attribute.key)?, + base64_to_utf8(&attribute.value)?, )) } From 0d9b61ed85e8b2fdf6b82f28008d80d594e7da77 Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Tue, 29 Aug 2023 19:17:58 -0400 Subject: [PATCH 2/5] fix issues --- Cargo.lock | 11 +++++++++-- Cargo.toml | 1 + ampd/Cargo.toml | 1 + ampd/src/broadcaster.rs | 2 +- ampd/src/broadcaster/dec_coin.rs | 2 +- ampd/src/handlers/evm_verify_msg.rs | 2 +- ampd/src/lib.rs | 2 +- packages/axelar-wasm-std/Cargo.toml | 2 -- packages/axelar-wasm-std/src/lib.rs | 3 +-- packages/report/Cargo.toml | 9 +++++++++ packages/report/src/lib.rs | 3 +++ .../{axelar-wasm-std => report}/src/result_ext.rs | 0 12 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 packages/report/Cargo.toml create mode 100644 packages/report/src/lib.rs rename packages/{axelar-wasm-std => report}/src/result_ext.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index c5983428c..de385ceec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -106,6 +106,7 @@ dependencies = [ "prost 0.11.9", "rand", "random-string", + "report", "serde", "serde_json", "serde_with", @@ -290,8 +291,6 @@ dependencies = [ "cosmwasm-storage", "cw-multi-test", "cw-storage-plus 1.1.0", - "error-stack", - "eyre", "flagset", "num-traits", "rand", @@ -3856,6 +3855,14 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "report" +version = "0.1.0" +dependencies = [ + "error-stack", + "eyre", +] + [[package]] name = "reqwest" version = "0.11.20" diff --git a/Cargo.toml b/Cargo.toml index 609befe6c..744ddff8b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ multisig = { version = "^0.1.0", path = "contracts/multisig" } service-registry = { version = "^0.1.0", path = "contracts/service-registry" } aggregate-verifier = { version = "^0.1.0", path = "contracts/aggregate-verifier" } gateway = { version = "^0.1.0", path = "contracts/gateway" } +report = { version = "^0.1.0", path = "packages/report" } [profile.release] opt-level = 3 diff --git a/ampd/Cargo.toml b/ampd/Cargo.toml index d18d23240..7f9a2501a 100644 --- a/ampd/Cargo.toml +++ b/ampd/Cargo.toml @@ -29,6 +29,7 @@ k256 = { version = "0.13.1", features = ["ecdsa"] } mockall = "0.11.3" multisig = { workspace = true } prost = "0.11.9" +report = { workspace = true } serde = { version = "1.0.147", features = ["derive"] } serde_json = "1.0.89" serde_with = "3.2.0" diff --git a/ampd/src/broadcaster.rs b/ampd/src/broadcaster.rs index 89f189525..4c93db2c6 100644 --- a/ampd/src/broadcaster.rs +++ b/ampd/src/broadcaster.rs @@ -2,7 +2,6 @@ use std::thread; use std::time::Duration; use async_trait::async_trait; -use axelar_wasm_std::ResultCompatExt; use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse; use cosmos_sdk_proto::cosmos::tx::v1beta1::{ BroadcastMode, BroadcastTxRequest, GetTxRequest, GetTxResponse, SimulateRequest, TxRaw, @@ -15,6 +14,7 @@ use derive_builder::Builder; use error_stack::{FutureExt, Report, Result, ResultExt}; use futures::TryFutureExt; use mockall::automock; +use report::ResultCompatExt; use serde::Deserialize; use thiserror::Error; use tonic::Status; diff --git a/ampd/src/broadcaster/dec_coin.rs b/ampd/src/broadcaster/dec_coin.rs index c5576b5e1..ebe6c79c4 100644 --- a/ampd/src/broadcaster/dec_coin.rs +++ b/ampd/src/broadcaster/dec_coin.rs @@ -3,9 +3,9 @@ use std::fmt::{Debug, Display, Formatter}; use std::str::FromStr; use std::{fmt, ops}; -use axelar_wasm_std::ResultCompatExt; use cosmrs::proto; use error_stack::{ensure, Report, Result, ResultExt}; +use report::ResultCompatExt; use serde::{Deserialize, Serialize}; use thiserror::Error; use tracing::error; diff --git a/ampd/src/handlers/evm_verify_msg.rs b/ampd/src/handlers/evm_verify_msg.rs index 8da364bba..46facbc49 100644 --- a/ampd/src/handlers/evm_verify_msg.rs +++ b/ampd/src/handlers/evm_verify_msg.rs @@ -105,7 +105,7 @@ where ) .await .into_iter() - .filter_map(Result::unwrap_or_default) + .filter_map(std::result::Result::unwrap_or_default) .filter_map(|tx_receipt| { if tx_receipt .block_number diff --git a/ampd/src/lib.rs b/ampd/src/lib.rs index b0ecb67bd..1d446bb20 100644 --- a/ampd/src/lib.rs +++ b/ampd/src/lib.rs @@ -12,12 +12,12 @@ use tokio_util::sync::CancellationToken; use tracing::info; use crate::config::Config; +use crate::report::Error; use broadcaster::{accounts::account, key::ECDSASigningKey, Broadcaster}; use event_processor::EventProcessor; use events::Event; use evm::EvmChainConfig; use queue::queued_broadcaster::{QueuedBroadcaster, QueuedBroadcasterDriver}; -use report::Error; use state::StateUpdater; use tofnd::grpc::{MultisigClient, SharableEcdsaClient}; use types::TMAddress; diff --git a/packages/axelar-wasm-std/Cargo.toml b/packages/axelar-wasm-std/Cargo.toml index 9fdfa433c..7a377da54 100644 --- a/packages/axelar-wasm-std/Cargo.toml +++ b/packages/axelar-wasm-std/Cargo.toml @@ -28,7 +28,6 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -error-stack = {workspace = true} cosmwasm-schema = "1.1.3" cosmwasm-std = "1.2.1" cosmwasm-storage = "1.1.3" @@ -40,7 +39,6 @@ serde = { version = "1.0.145", default-features = false, features = ["derive"] } serde_json = "1.0.89" sha3 = { version = "0.10", default-features = false, features = [] } thiserror = { version = "1.0.31" } -eyre = "0.6.8" [dev-dependencies] cw-multi-test = "0.15.1" diff --git a/packages/axelar-wasm-std/src/lib.rs b/packages/axelar-wasm-std/src/lib.rs index eb91a73a3..71059aa8e 100644 --- a/packages/axelar-wasm-std/src/lib.rs +++ b/packages/axelar-wasm-std/src/lib.rs @@ -3,14 +3,13 @@ pub mod flagset; mod fn_ext; pub mod nonempty; pub mod operators; -mod result_ext; + pub mod snapshot; pub mod threshold; pub mod voting; pub use crate::{ fn_ext::FnExt, - result_ext::ResultCompatExt, snapshot::{Participant, Snapshot}, threshold::Threshold, }; diff --git a/packages/report/Cargo.toml b/packages/report/Cargo.toml new file mode 100644 index 000000000..b22fac571 --- /dev/null +++ b/packages/report/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "report" +version = "0.1.0" +edition = "2021" +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +error-stack = { workspace = true } +eyre = "0.6.8" diff --git a/packages/report/src/lib.rs b/packages/report/src/lib.rs new file mode 100644 index 000000000..680c11ad0 --- /dev/null +++ b/packages/report/src/lib.rs @@ -0,0 +1,3 @@ +mod result_ext; + +pub use crate::result_ext::ResultCompatExt; diff --git a/packages/axelar-wasm-std/src/result_ext.rs b/packages/report/src/result_ext.rs similarity index 100% rename from packages/axelar-wasm-std/src/result_ext.rs rename to packages/report/src/result_ext.rs From 6b7317a68b62174cbec12b15976c0eaef6926f8f Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Thu, 31 Aug 2023 17:35:38 -0400 Subject: [PATCH 3/5] remove debug code --- ampd/src/broadcaster/tx.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ampd/src/broadcaster/tx.rs b/ampd/src/broadcaster/tx.rs index 85b7591d4..b4773adfb 100644 --- a/ampd/src/broadcaster/tx.rs +++ b/ampd/src/broadcaster/tx.rs @@ -89,16 +89,14 @@ where } pub async fn with_dummy_sig(self) -> Result { - let x = self - .sign_with( - &DUMMY_CHAIN_ID - .parse() - .expect("the dummy chain id must be valid"), - DUMMY_ACC_NUMBER, - |_| async { Result::<_, Error>::Ok(vec![0; 64]) }, - ) - .await; - x + self.sign_with( + &DUMMY_CHAIN_ID + .parse() + .expect("the dummy chain id must be valid"), + DUMMY_ACC_NUMBER, + |_| async { Result::<_, Error>::Ok(vec![0; 64]) }, + ) + .await } } From 2dd42090b675a3cbe06de3aecdc7f7d9b4afe0de Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Thu, 31 Aug 2023 17:45:12 -0400 Subject: [PATCH 4/5] clippy fix --- ampd/src/handlers/multisig.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ampd/src/handlers/multisig.rs b/ampd/src/handlers/multisig.rs index c1c52a1ec..3ba513554 100644 --- a/ampd/src/handlers/multisig.rs +++ b/ampd/src/handlers/multisig.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use cosmrs::cosmwasm::MsgExecuteContract; use cosmwasm_std::{HexBinary, Uint64}; use ecdsa::VerifyingKey; -use error_stack::{IntoReport, ResultExt}; +use error_stack::ResultExt; use hex::{encode, FromHex}; use serde::de::Error as DeserializeError; use serde::{Deserialize, Deserializer}; From 6fedc48f5fafc820b2cca9d0106f1cf873812182 Mon Sep 17 00:00:00 2001 From: Christian Gorenflo Date: Thu, 31 Aug 2023 17:46:12 -0400 Subject: [PATCH 5/5] fmt --- packages/axelar-wasm-std/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/axelar-wasm-std/src/lib.rs b/packages/axelar-wasm-std/src/lib.rs index 71059aa8e..ff7dd4a27 100644 --- a/packages/axelar-wasm-std/src/lib.rs +++ b/packages/axelar-wasm-std/src/lib.rs @@ -1,15 +1,14 @@ +pub use crate::{ + fn_ext::FnExt, + snapshot::{Participant, Snapshot}, + threshold::Threshold, +}; + pub mod counter; pub mod flagset; mod fn_ext; pub mod nonempty; pub mod operators; - pub mod snapshot; pub mod threshold; pub mod voting; - -pub use crate::{ - fn_ext::FnExt, - snapshot::{Participant, Snapshot}, - threshold::Threshold, -};