From f725d961b3738c04ec09d370522e2d50a08b5cec Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 7 Nov 2022 17:22:03 +0000 Subject: [PATCH 1/4] First attempt at fixing shared abcipp --- apps/src/lib/client/rpc.rs | 2 +- shared/Cargo.toml | 8 +++++++- shared/src/ledger/queries/mod.rs | 12 ++++++------ shared/src/ledger/queries/shell.rs | 2 +- shared/src/ledger/queries/types.rs | 7 +++---- shared/src/lib.rs | 3 ++- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index ce6a542897..34da6deb08 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -54,7 +54,7 @@ pub async fn query_epoch(args: args::Query) -> Epoch { /// Query the last committed block pub async fn query_block( args: args::Query, -) -> tendermint_rpc::endpoint::block::Response { +) -> crate::facade::tendermint_rpc::endpoint::block::Response { let client = HttpClient::new(args.ledger_address).unwrap(); let response = client.latest_block().await.unwrap(); println!( diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 87bae5ef94..9e9025b22b 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -60,12 +60,17 @@ tendermint-rpc = [ "async-client", "dep:tendermint-rpc", ] +tendermint-rpc-abcipp = [ + "async-client", + "dep:tendermint-rpc-abcipp", +] abcipp = [ "ibc-proto-abcipp", "ibc-abcipp", "tendermint-abcipp", - "tendermint-proto-abcipp" + "tendermint-proto-abcipp", + "tendermint-rpc-abcipp", ] abciplus = [ @@ -73,6 +78,7 @@ abciplus = [ "ibc-proto", "tendermint", "tendermint-proto", + "tendermint-rpc", ] [dependencies] diff --git a/shared/src/ledger/queries/mod.rs b/shared/src/ledger/queries/mod.rs index 8b31376be4..ea448b6df4 100644 --- a/shared/src/ledger/queries/mod.rs +++ b/shared/src/ledger/queries/mod.rs @@ -91,7 +91,7 @@ pub mod tm { #[derive(Error, Debug)] pub enum Error { #[error("{0}")] - Tendermint(#[from] tendermint_rpc::Error), + Tendermint(#[from] crate::tendermint_rpc::Error), #[error("Decoding error: {0}")] Decoding(#[from] std::io::Error), #[error("Info log: {0}, error code: {1}")] @@ -101,7 +101,7 @@ pub mod tm { } #[async_trait::async_trait] - impl Client for tendermint_rpc::HttpClient { + impl Client for crate::tendermint_rpc::HttpClient { type Error = Error; async fn request( @@ -114,11 +114,11 @@ pub mod tm { let data = data.unwrap_or_default(); let height = height .map(|height| { - tendermint::block::Height::try_from(height.0) + crate::tendermint::block::Height::try_from(height.0) .map_err(|_err| Error::InvalidHeight(height)) }) .transpose()?; - let response = tendermint_rpc::Client::abci_query( + let response = crate::tendermint_rpc::Client::abci_query( self, // TODO open the private Path constructor in tendermint-rpc Some(std::str::FromStr::from_str(&path).unwrap()), @@ -128,12 +128,12 @@ pub mod tm { ) .await?; match response.code { - tendermint::abci::Code::Ok => Ok(EncodedResponseQuery { + crate::tendermint::abci::Code::Ok => Ok(EncodedResponseQuery { data: response.value, info: response.info, proof_ops: response.proof.map(Into::into), }), - tendermint::abci::Code::Err(code) => { + crate::tendermint::abci::Code::Err(code) => { Err(Error::Query(response.info, code)) } } diff --git a/shared/src/ledger/queries/shell.rs b/shared/src/ledger/queries/shell.rs index 7491af4945..d6d9d7b5f6 100644 --- a/shared/src/ledger/queries/shell.rs +++ b/shared/src/ledger/queries/shell.rs @@ -1,10 +1,10 @@ use borsh::BorshSerialize; -use tendermint_proto::crypto::{ProofOp, ProofOps}; use crate::ledger::queries::types::{RequestCtx, RequestQuery}; use crate::ledger::queries::{require_latest_height, EncodedResponseQuery}; use crate::ledger::storage::{DBIter, StorageHasher, DB}; use crate::ledger::storage_api::{self, ResultExt, StorageRead}; +use crate::tendermint_proto::crypto::{ProofOp, ProofOps}; use crate::types::storage::{self, Epoch, PrefixValue}; #[cfg(all(feature = "wasm-runtime", feature = "ferveo-tpke"))] use crate::types::transaction::TxResult; diff --git a/shared/src/ledger/queries/types.rs b/shared/src/ledger/queries/types.rs index c7b349ddc0..a33c465e08 100644 --- a/shared/src/ledger/queries/types.rs +++ b/shared/src/ledger/queries/types.rs @@ -1,7 +1,6 @@ -use tendermint_proto::crypto::ProofOps; - use crate::ledger::storage::{DBIter, Storage, StorageHasher, DB}; use crate::ledger::storage_api; +use crate::tendermint_proto::crypto::ProofOps; use crate::types::storage::BlockHeight; #[cfg(feature = "wasm-runtime")] use crate::vm::wasm::{TxCache, VpCache}; @@ -141,12 +140,12 @@ impl RequestQuery { /// spec. A negative block height will cause an error. pub fn try_from_tm( storage: &Storage, - tendermint_proto::abci::RequestQuery { + crate::tendermint_proto::abci::RequestQuery { data, path, height, prove, - }: tendermint_proto::abci::RequestQuery, + }: crate::tendermint_proto::abci::RequestQuery, ) -> Result where D: DB + for<'iter> DBIter<'iter>, diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 6faaf2ff36..946367bfa1 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -7,12 +7,13 @@ #![deny(rustdoc::private_intra_doc_links)] #[cfg(not(feature = "abcipp"))] -pub use {ibc, ibc_proto, tendermint, tendermint_proto}; +pub use {ibc, ibc_proto, tendermint, tendermint_proto, tendermint_rpc}; #[cfg(feature = "abcipp")] pub use { ibc_abcipp as ibc, ibc_proto_abcipp as ibc_proto, tendermint_abcipp as tendermint, tendermint_proto_abcipp as tendermint_proto, + tendermint_rpc_abcipp as tendermint_rpc, }; pub mod bytes; From 74f4c99eb25b64920e7e51145997c2f7bde8f5a4 Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 7 Nov 2022 17:57:57 +0000 Subject: [PATCH 2/4] Use ferveo-tpke flag to stop tendermint-rpc being pulled into wasm --- shared/Cargo.toml | 2 +- shared/src/lib.rs | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 9e9025b22b..2cbcb8baec 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -70,6 +70,7 @@ abcipp = [ "ibc-abcipp", "tendermint-abcipp", "tendermint-proto-abcipp", + # it's OK to include the tendermint-rpc feature here, as we aren't currently building wasms with `abcipp` "tendermint-rpc-abcipp", ] @@ -78,7 +79,6 @@ abciplus = [ "ibc-proto", "tendermint", "tendermint-proto", - "tendermint-rpc", ] [dependencies] diff --git a/shared/src/lib.rs b/shared/src/lib.rs index 946367bfa1..1d34093f68 100644 --- a/shared/src/lib.rs +++ b/shared/src/lib.rs @@ -6,14 +6,17 @@ #![deny(rustdoc::broken_intra_doc_links)] #![deny(rustdoc::private_intra_doc_links)] +#[cfg(all(not(feature = "abcipp"), feature = "ferveo-tpke"))] +pub use tendermint_rpc; +#[cfg(all(feature = "abcipp", feature = "ferveo-tpke"))] +pub use tendermint_rpc_abcipp as tendermint_rpc; #[cfg(not(feature = "abcipp"))] -pub use {ibc, ibc_proto, tendermint, tendermint_proto, tendermint_rpc}; +pub use {ibc, ibc_proto, tendermint, tendermint_proto}; #[cfg(feature = "abcipp")] pub use { ibc_abcipp as ibc, ibc_proto_abcipp as ibc_proto, tendermint_abcipp as tendermint, tendermint_proto_abcipp as tendermint_proto, - tendermint_rpc_abcipp as tendermint_rpc, }; pub mod bytes; From 6ab51020c7aeb3dd9212cba76ee75462a826c84a Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 7 Nov 2022 18:03:39 +0000 Subject: [PATCH 3/4] Add check-abcipp command --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index b2d0393df9..6b065bbdb0 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ check: make -C $(wasms_for_tests) check && \ $(foreach wasm,$(wasm_templates),$(check-wasm) && ) true +check-abcipp: + $(cargo) check --all-targets --no-default-features --features "abcipp namada/ibc-mocks-abcipp" + clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings clippy: From 2604a91cd23c6d542abab9502ec446502adfbee2 Mon Sep 17 00:00:00 2001 From: James Hiew Date: Wed, 9 Nov 2022 12:41:00 +0000 Subject: [PATCH 4/4] Add changelog --- .changelog/unreleased/bug-fixes/754-fix-abcipp.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/bug-fixes/754-fix-abcipp.md diff --git a/.changelog/unreleased/bug-fixes/754-fix-abcipp.md b/.changelog/unreleased/bug-fixes/754-fix-abcipp.md new file mode 100644 index 0000000000..0355963cab --- /dev/null +++ b/.changelog/unreleased/bug-fixes/754-fix-abcipp.md @@ -0,0 +1,2 @@ +- Fix building with the feature again + ([#754](https://github.com/anoma/namada/pull/754)) \ No newline at end of file