Skip to content

Commit

Permalink
chore: simplify cosmos proto dependencies (axelarnetwork#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgorenflo authored Jun 5, 2024
1 parent fe08c00 commit bf6750b
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 82 deletions.
46 changes: 6 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions ampd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ base64 = "0.21.2"
bcs = "0.1.5"
clap = { version = "4.2.7", features = ["derive", "cargo"] }
config = "0.13.2"
cosmos-sdk-proto = "0.16.0"
cosmrs = { version = "0.14.0", features = ["cosmwasm"] }
cosmrs = { version = "0.14.0", features = ["cosmwasm", "grpc"] }
cosmwasm-std = { workspace = true, features = ["stargate"] }
deref-derive = "0.1.0"
dirs = "5.0.1"
Expand Down Expand Up @@ -58,7 +57,7 @@ tokio = { version = "1.22.0", features = ["signal"] }
tokio-stream = { version = "0.1.11", features = ["sync"] }
tokio-util = "0.7.8"
toml = "0.5.9"
tonic = "0.8.3"
tonic = "0.9.2"
tracing = { version = "0.1.37", features = ["valuable", "log"] }
tracing-core = { version = "0.1.30", features = ["valuable"] }
tracing-subscriber = { version = "0.3.16", features = ["json", "valuable"] }
Expand Down
37 changes: 17 additions & 20 deletions ampd/src/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::time::Duration;
use std::{cmp, thread};

use async_trait::async_trait;
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmos_sdk_proto::cosmos::tx::v1beta1::{
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::tx::v1beta1::{
BroadcastMode, BroadcastTxRequest, GetTxRequest, GetTxResponse, SimulateRequest,
};
use cosmos_sdk_proto::traits::MessageExt;
use cosmrs::proto::traits::MessageExt;
use cosmrs::tendermint::chain::Id;
use cosmrs::tx::Fee;
use cosmrs::{Coin, Gas};
Expand Down Expand Up @@ -51,7 +51,7 @@ pub enum Error {
#[error("failed to confirm tx inclusion in block")]
TxConfirmation,
#[error("failed to execute tx")]
Execution { response: TxResponse },
Execution { response: Box<TxResponse> },
#[error("failed to query account information for address {address}")]
QueryAccount { address: TMAddress },
}
Expand Down Expand Up @@ -290,7 +290,9 @@ fn evaluate_response(response: Result<GetTxResponse, Status>) -> ConfirmationRes
..
}) => match response {
TxResponse { code: 0, .. } => ConfirmationResult::Success,
_ => ConfirmationResult::Critical(Error::Execution { response }),
_ => ConfirmationResult::Critical(Error::Execution {
response: Box::new(response),
}),
},
}
}
Expand All @@ -303,11 +305,11 @@ enum ConfirmationResult {

#[cfg(test)]
mod tests {
use cosmos_sdk_proto::cosmos::auth::v1beta1::{BaseAccount, QueryAccountResponse};
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::{GasInfo, TxResponse};
use cosmos_sdk_proto::cosmos::tx::v1beta1::{GetTxResponse, SimulateResponse};
use cosmos_sdk_proto::traits::MessageExt;
use cosmos_sdk_proto::Any;
use cosmrs::proto::cosmos::auth::v1beta1::{BaseAccount, QueryAccountResponse};
use cosmrs::proto::cosmos::base::abci::v1beta1::{GasInfo, TxResponse};
use cosmrs::proto::cosmos::tx::v1beta1::{GetTxResponse, SimulateResponse};
use cosmrs::proto::traits::MessageExt;
use cosmrs::proto::Any;
use cosmrs::{bank::MsgSend, tx::Msg, AccountId};
use ecdsa::SigningKey;
use rand::rngs::OsRng;
Expand Down Expand Up @@ -642,16 +644,11 @@ mod tests {
.build();
let msgs = vec![dummy_msg()];

assert!(matches!(
broadcaster
.broadcast(msgs)
.await
.unwrap_err()
.current_context(),
Error::Execution {
response: TxResponse { code: 32, .. }
}
));
let report = broadcaster.broadcast(msgs).await.unwrap_err();
assert!(matches!(report.current_context(), Error::Execution { .. }));
if let Error::Execution { response } = report.current_context() {
assert_eq!(response.code, 32);
}
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions ampd/src/broadcaster/accounts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmos_sdk_proto::cosmos::auth::v1beta1::{BaseAccount, QueryAccountRequest};
use cosmos_sdk_proto::traits::Message;
use cosmrs::proto::cosmos::auth::v1beta1::{BaseAccount, QueryAccountRequest};
use cosmrs::proto::traits::Message;
use error_stack::{Result, ResultExt};
use thiserror::Error;

Expand Down Expand Up @@ -54,9 +54,9 @@ where

#[cfg(test)]
mod tests {
use cosmos_sdk_proto::cosmos::auth::v1beta1::BaseAccount;
use cosmos_sdk_proto::cosmos::auth::v1beta1::QueryAccountResponse;
use cosmos_sdk_proto::traits::MessageExt;
use cosmrs::proto::cosmos::auth::v1beta1::BaseAccount;
use cosmrs::proto::cosmos::auth::v1beta1::QueryAccountResponse;
use cosmrs::proto::traits::MessageExt;
use cosmrs::Any;
use ecdsa::SigningKey;
use rand::rngs::OsRng;
Expand Down
10 changes: 5 additions & 5 deletions ampd/src/broadcaster/clients.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use async_trait::async_trait;
use cosmos_sdk_proto::cosmos::auth::v1beta1::query_client::QueryClient;
use cosmos_sdk_proto::cosmos::auth::v1beta1::{QueryAccountRequest, QueryAccountResponse};
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmos_sdk_proto::cosmos::tx::v1beta1::service_client::ServiceClient;
use cosmos_sdk_proto::cosmos::tx::v1beta1::{
use cosmrs::proto::cosmos::auth::v1beta1::query_client::QueryClient;
use cosmrs::proto::cosmos::auth::v1beta1::{QueryAccountRequest, QueryAccountResponse};
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::tx::v1beta1::service_client::ServiceClient;
use cosmrs::proto::cosmos::tx::v1beta1::{
BroadcastTxRequest, GetTxRequest, GetTxResponse, SimulateRequest, SimulateResponse,
};
use error_stack::{Report, Result};
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/broadcaster/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ where

#[cfg(test)]
mod tests {
use cosmos_sdk_proto::Any;
use cosmrs::proto::Any;
use cosmrs::{
bank::MsgSend,
bip32::secp256k1::elliptic_curve::rand_core::OsRng,
Expand Down
6 changes: 3 additions & 3 deletions ampd/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::path::Path;

use clap::Subcommand;
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmos_sdk_proto::cosmos::{
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::{
auth::v1beta1::query_client::QueryClient, tx::v1beta1::service_client::ServiceClient,
};
use cosmos_sdk_proto::Any;
use cosmrs::proto::Any;
use cosmrs::AccountId;
use error_stack::Result;
use error_stack::ResultExt;
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/grpc/ampd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ mod tests {
use std::collections::HashMap;
use std::time::Duration;

use cosmos_sdk_proto::Any;
use cosmrs::proto::Any;
use cosmrs::{bank::MsgSend, tx::Msg, AccountId};
use error_stack::Report;
use events::Event;
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/handlers/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ mod test {

use base64::engine::general_purpose::STANDARD;
use base64::Engine;
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::AccountId;
use cosmwasm_std::{HexBinary, Uint64};
use ecdsa::SigningKey;
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::pin::Pin;
use std::time::Duration;

use block_height_monitor::BlockHeightMonitor;
use cosmos_sdk_proto::cosmos::{
use cosmrs::proto::cosmos::{
auth::v1beta1::query_client::QueryClient, tx::v1beta1::service_client::ServiceClient,
};
use error_stack::{report, FutureExt, Result, ResultExt};
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/queue/msg_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl MsgQueue {

#[cfg(test)]
mod test {
use cosmos_sdk_proto::Any;
use cosmrs::proto::Any;
use cosmrs::{bank::MsgSend, tx::Msg, AccountId};

use super::MsgQueue;
Expand Down
2 changes: 1 addition & 1 deletion ampd/src/queue/queued_broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where

#[cfg(test)]
mod test {
use cosmos_sdk_proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::proto::cosmos::base::abci::v1beta1::TxResponse;
use cosmrs::tx::Fee;
use cosmrs::Any;
use cosmrs::{bank::MsgSend, tx::Msg, AccountId};
Expand Down

0 comments on commit bf6750b

Please sign in to comment.