From d0004982f67cec5c2f0ac42a70fcf7bcba6eb6a1 Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 7 Nov 2022 17:22:03 +0000 Subject: [PATCH 1/6] 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 | 1 + shared/src/ledger/queries/types.rs | 5 +++-- shared/src/lib.rs | 3 ++- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/apps/src/lib/client/rpc.rs b/apps/src/lib/client/rpc.rs index 474b8a1cee..3082a49b01 100644 --- a/apps/src/lib/client/rpc.rs +++ b/apps/src/lib/client/rpc.rs @@ -75,7 +75,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 1af1162f92..e930a7a493 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 8d7b5e0274..e2e03452fb 100644 --- a/shared/src/ledger/queries/mod.rs +++ b/shared/src/ledger/queries/mod.rs @@ -94,7 +94,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}")] @@ -104,7 +104,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( @@ -117,11 +117,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()), @@ -131,12 +131,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: response.proof, }), - 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 46ac0753a9..948262291f 100644 --- a/shared/src/ledger/queries/shell.rs +++ b/shared/src/ledger/queries/shell.rs @@ -3,6 +3,7 @@ use masp_primitives::asset_type::AssetType; use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::Node; use tendermint::merkle::proof::Proof; +use tendermint_proto::crypto::{ProofOp, ProofOps}; use crate::ledger::queries::types::{RequestCtx, RequestQuery}; use crate::ledger::queries::{require_latest_height, EncodedResponseQuery}; diff --git a/shared/src/ledger/queries/types.rs b/shared/src/ledger/queries/types.rs index 806a403322..ab6f9b5900 100644 --- a/shared/src/ledger/queries/types.rs +++ b/shared/src/ledger/queries/types.rs @@ -2,6 +2,7 @@ use tendermint::merkle::proof::Proof; 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}; @@ -145,12 +146,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 6201b80246166e652e91c3b251e2df418d70b042 Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 7 Nov 2022 17:57:57 +0000 Subject: [PATCH 2/6] 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 e930a7a493..91921c2441 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 e94fe47b9fa5928e3ea73655d6dd809a1c36fbfe Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 7 Nov 2022 18:03:39 +0000 Subject: [PATCH 3/6] Add check-abcipp command --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 829488eca6..5231795ac3 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 09d316e8240f4ffe1178841d0f2fdc9f840a35c1 Mon Sep 17 00:00:00 2001 From: James Hiew Date: Wed, 9 Nov 2022 12:41:00 +0000 Subject: [PATCH 4/6] 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 From 04b313ac0bc86f5de0e94489d5746a0178c4b503 Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 28 Nov 2022 12:23:50 +0000 Subject: [PATCH 5/6] Fix up for namada v0.10.1 --- Makefile | 9 +++++++-- apps/src/lib/client/types.rs | 2 +- shared/src/ledger/queries/shell.rs | 3 +-- shared/src/ledger/queries/types.rs | 4 +--- shared/src/proto/types.rs | 21 +++++---------------- 5 files changed, 15 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 5231795ac3..fabcdb61d3 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,12 @@ check: $(foreach wasm,$(wasm_templates),$(check-wasm) && ) true check-abcipp: - $(cargo) check --all-targets --no-default-features --features "abcipp namada/ibc-mocks-abcipp" + $(cargo) check \ + --workspace \ + --exclude namada_tests \ + --all-targets \ + --no-default-features \ + --features "abcipp ibc-mocks-abcipp testing" clippy-wasm = $(cargo) +$(nightly) clippy --manifest-path $(wasm)/Cargo.toml --all-targets -- -D warnings @@ -63,7 +68,7 @@ clippy-abcipp: $(cargo) +$(nightly) clippy --all-targets \ --manifest-path ./shared/Cargo.toml \ --no-default-features \ - --features "testing wasm-runtime abcipp ibc-mocks-abcipp" && \ + --features "testing wasm-runtime abcipp ibc-mocks-abcipp ferveo-tpke" && \ $(cargo) +$(nightly) clippy \ --all-targets \ --manifest-path ./vm_env/Cargo.toml \ diff --git a/apps/src/lib/client/types.rs b/apps/src/lib/client/types.rs index 1f94838d25..5a26244474 100644 --- a/apps/src/lib/client/types.rs +++ b/apps/src/lib/client/types.rs @@ -8,11 +8,11 @@ use namada::types::masp::{TransferSource, TransferTarget}; use namada::types::storage::Epoch; use namada::types::transaction::GasLimit; use namada::types::{key, token}; -use tendermint_config::net::Address as TendermintAddress; use super::rpc; use crate::cli::{args, Context}; use crate::client::tx::Conversions; +use crate::facade::tendermint_config::net::Address as TendermintAddress; #[derive(Clone, Debug)] pub struct ParsedTxArgs { diff --git a/shared/src/ledger/queries/shell.rs b/shared/src/ledger/queries/shell.rs index 948262291f..0fe28053f7 100644 --- a/shared/src/ledger/queries/shell.rs +++ b/shared/src/ledger/queries/shell.rs @@ -2,13 +2,12 @@ use borsh::{BorshDeserialize, BorshSerialize}; use masp_primitives::asset_type::AssetType; use masp_primitives::merkle_tree::MerklePath; use masp_primitives::sapling::Node; -use tendermint::merkle::proof::Proof; -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::merkle::proof::Proof; use crate::types::address::Address; #[cfg(all(feature = "wasm-runtime", feature = "ferveo-tpke"))] use crate::types::storage::TxIndex; diff --git a/shared/src/ledger/queries/types.rs b/shared/src/ledger/queries/types.rs index ab6f9b5900..31b028e136 100644 --- a/shared/src/ledger/queries/types.rs +++ b/shared/src/ledger/queries/types.rs @@ -1,8 +1,6 @@ -use tendermint::merkle::proof::Proof; - use crate::ledger::storage::{DBIter, Storage, StorageHasher, DB}; use crate::ledger::storage_api; -use crate::tendermint_proto::crypto::ProofOps; +use crate::tendermint::merkle::proof::Proof; use crate::types::storage::BlockHeight; #[cfg(feature = "wasm-runtime")] use crate::vm::wasm::{TxCache, VpCache}; diff --git a/shared/src/proto/types.rs b/shared/src/proto/types.rs index 3a0bb1d8ea..ed3f66f75e 100644 --- a/shared/src/proto/types.rs +++ b/shared/src/proto/types.rs @@ -4,25 +4,14 @@ use std::hash::{Hash, Hasher}; use borsh::{BorshDeserialize, BorshSchema, BorshSerialize}; use prost::Message; use serde::{Deserialize, Serialize}; -#[cfg(not(feature = "ABCI"))] -#[cfg(feature = "ferveo-tpke")] -use tendermint_proto::abci::Event; -#[cfg(not(feature = "ABCI"))] -#[cfg(feature = "ferveo-tpke")] -use tendermint_proto::abci::EventAttribute; -#[cfg(not(feature = "ABCI"))] -use tendermint_proto::abci::ResponseDeliverTx; -#[cfg(feature = "ABCI")] -#[cfg(feature = "ferveo-tpke")] -use tendermint_proto_abci::abci::Event; -#[cfg(feature = "ABCI")] -#[cfg(feature = "ferveo-tpke")] -use tendermint_proto_abci::abci::EventAttribute; -#[cfg(feature = "ABCI")] -use tendermint_proto_abci::abci::ResponseDeliverTx; use thiserror::Error; use super::generated::types; +#[cfg(feature = "ferveo-tpke")] +use crate::tendermint_proto::abci::Event; +#[cfg(feature = "ferveo-tpke")] +use crate::tendermint_proto::abci::EventAttribute; +use crate::tendermint_proto::abci::ResponseDeliverTx; use crate::types::key::*; use crate::types::time::DateTimeUtc; #[cfg(feature = "ferveo-tpke")] From d912dd31f267c33ef47ff0ea8087b4ee77ab6a4e Mon Sep 17 00:00:00 2001 From: James Hiew Date: Mon, 28 Nov 2022 13:12:17 +0000 Subject: [PATCH 6/6] Fix changelog --- .changelog/unreleased/bug-fixes/754-fix-abcipp.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/unreleased/bug-fixes/754-fix-abcipp.md b/.changelog/unreleased/bug-fixes/754-fix-abcipp.md index 0355963cab..ca80419640 100644 --- a/.changelog/unreleased/bug-fixes/754-fix-abcipp.md +++ b/.changelog/unreleased/bug-fixes/754-fix-abcipp.md @@ -1,2 +1,2 @@ -- Fix building with the feature again +- Fix building with the `abcipp` feature again ([#754](https://github.com/anoma/namada/pull/754)) \ No newline at end of file