Skip to content

Commit

Permalink
fix: remove transparent_api feature from iroha dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Veršić <[email protected]>
  • Loading branch information
mversic committed Oct 18, 2024
1 parent bc79734 commit 98782af
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 49 deletions.
3 changes: 0 additions & 3 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions crates/iroha/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ tls-rustls-webpki-roots = [
iroha_config = { workspace = true }
iroha_config_base = { workspace = true }
iroha_crypto = { workspace = true }
# FIXME: should remove `transparent_api` feature. Check the other FIXME comment in dev-dependencies
iroha_data_model = { workspace = true, features = ["http", "transparent_api"] }
iroha_data_model = { workspace = true, features = ["http"] }
iroha_executor_data_model = { workspace = true }
iroha_primitives = { workspace = true }
iroha_logger = { workspace = true }
Expand Down
60 changes: 48 additions & 12 deletions crates/iroha_ffi/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,26 @@ pub trait IrTypeFamily {
}

impl<R: Cloned> IrTypeFamily for R {
type Ref<'itm> = &'itm Self where Self: 'itm;
type Ref<'itm>
= &'itm Self
where
Self: 'itm;
// NOTE: Unused
type RefMut<'itm> = () where Self: 'itm;
type RefMut<'itm>
= ()
where
Self: 'itm;
type Box = Box<Self>;
type BoxedSlice = Box<[Self]>;
type RefSlice<'itm> = &'itm [Self] where Self: 'itm;
type RefSlice<'itm>
= &'itm [Self]
where
Self: 'itm;
// NOTE: Unused
type RefMutSlice<'itm> = () where Self: 'itm;
type RefMutSlice<'itm>
= ()
where
Self: 'itm;
type Vec = Vec<Self>;
type Arr<const N: usize> = [Self; N];
}
Expand Down Expand Up @@ -166,22 +178,46 @@ impl IrTypeFamily for Transparent {
type Arr<const N: usize> = Self;
}
impl IrTypeFamily for &Extern {
type Ref<'itm> = &'itm Self where Self: 'itm;
type RefMut<'itm> = &'itm mut Self where Self: 'itm;
type Ref<'itm>
= &'itm Self
where
Self: 'itm;
type RefMut<'itm>
= &'itm mut Self
where
Self: 'itm;
type Box = Box<Self>;
type BoxedSlice = Box<[Self]>;
type RefSlice<'itm> = &'itm [Self] where Self: 'itm;
type RefMutSlice<'itm> = &'itm mut [Self] where Self: 'itm;
type RefSlice<'itm>
= &'itm [Self]
where
Self: 'itm;
type RefMutSlice<'itm>
= &'itm mut [Self]
where
Self: 'itm;
type Vec = Vec<Self>;
type Arr<const N: usize> = [Self; N];
}
impl IrTypeFamily for &mut Extern {
type Ref<'itm> = &'itm Self where Self: 'itm;
type RefMut<'itm> = &'itm mut Self where Self: 'itm;
type Ref<'itm>
= &'itm Self
where
Self: 'itm;
type RefMut<'itm>
= &'itm mut Self
where
Self: 'itm;
type Box = Box<Self>;
type BoxedSlice = Box<[Self]>;
type RefSlice<'itm> = &'itm [Self] where Self: 'itm;
type RefMutSlice<'itm> = &'itm mut [Self] where Self: 'itm;
type RefSlice<'itm>
= &'itm [Self]
where
Self: 'itm;
type RefMutSlice<'itm>
= &'itm mut [Self]
where
Self: 'itm;
type Vec = Vec<Self>;
type Arr<const N: usize> = [Self; N];
}
Expand Down
5 changes: 1 addition & 4 deletions crates/iroha_p2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ workspace = true
[dependencies]
iroha_logger = { workspace = true }
iroha_crypto = { workspace = true, default-features = true }
iroha_data_model = { workspace = true, default-features = true, features = [
"transparent_api",
] }
iroha_data_model = { workspace = true, default-features = true }
iroha_primitives = { workspace = true }
iroha_config = { workspace = true }
iroha_futures = { workspace = true }
Expand All @@ -39,4 +37,3 @@ bytes = { workspace = true }

[dev-dependencies]
iroha_config_base = { workspace = true }
iroha_test_network = { workspace = true }
18 changes: 9 additions & 9 deletions crates/iroha_p2p/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {
.iter()
// Peer is not connected but should
.filter_map(|(peer, is_active)| {
(!self.peers.contains_key(&peer.public_key)
(!self.peers.contains_key(peer.public_key())
&& !self
.connecting_peers
.values()
Expand Down Expand Up @@ -362,7 +362,7 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {

fn connect_peer(&mut self, peer: &PeerId) {
iroha_logger::trace!(
listen_addr = %self.listen_addr, peer.id.address = %peer.address,
listen_addr = %self.listen_addr, peer.id.address = %peer.address(),
"Creating new peer actor",
);

Expand All @@ -372,7 +372,7 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {
let service_message_sender = self.service_message_sender.clone();
connecting::<T, K, E>(
// NOTE: we intentionally use peer's address and our public key, it's used during handshake
peer.address.clone(),
peer.address().clone(),
self.key_pair.clone(),
conn_id,
service_message_sender,
Expand Down Expand Up @@ -410,7 +410,7 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {
}

// Insert peer if peer not in peers yet or replace peer if it's disambiguator value is smaller than new one (simultaneous connections resolution rule)
match self.peers.get(&peer_id.public_key) {
match self.peers.get(peer_id.public_key()) {
Some(peer) if peer.disambiguator > disambiguator => {
iroha_logger::debug!(
"Peer is disconnected due to simultaneous connection resolution policy"
Expand All @@ -428,7 +428,7 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {
let ref_peer = RefPeer {
handle: ready_peer_handle,
conn_id: connection_id,
p2p_addr: peer_id.address.clone(),
p2p_addr: peer_id.address().clone(),
disambiguator,
};
let _ = peer_message_sender.send(self.peer_message_sender.clone());
Expand All @@ -439,10 +439,10 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {
fn peer_terminated(&mut self, Terminated { peer_id, conn_id }: Terminated) {
self.connecting_peers.remove(&conn_id);
if let Some(peer_id) = peer_id {
if let Some(peer) = self.peers.get(&peer_id.public_key) {
if let Some(peer) = self.peers.get(peer_id.public_key()) {
if peer.conn_id == conn_id {
iroha_logger::debug!(conn_id, peer=%peer_id, "Peer terminated");
self.peers.remove(&peer_id.public_key);
self.peers.remove(peer_id.public_key());
Self::remove_online_peer(&self.online_peers_sender, &peer_id);
}
}
Expand All @@ -451,11 +451,11 @@ impl<T: Pload, K: Kex, E: Enc> NetworkBase<T, K, E> {

fn post(&mut self, Post { data, peer_id }: Post<T>) {
iroha_logger::trace!(peer=%peer_id, "Post message");
match self.peers.get(&peer_id.public_key) {
match self.peers.get(peer_id.public_key()) {
Some(peer) => {
if peer.handle.post(data).is_err() {
iroha_logger::error!(peer=%peer_id, "Failed to send message to peer");
self.peers.remove(&peer_id.public_key);
self.peers.remove(peer_id.public_key());
Self::remove_online_peer(&self.online_peers_sender, &peer_id);
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/iroha_p2p/tests/integration/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,12 @@ async fn start_network(
barrier: Arc<Barrier>,
shutdown_signal: ShutdownSignal,
) -> (PeerId, NetworkHandle<TestMessage>) {
info!(peer_addr = %peer.address, "Starting network");
info!(peer_addr = %peer.address(), "Starting network");

// This actor will get the messages from other peers and increment the counter
let actor = TestActor::start(messages);

let PeerId { address, .. } = peer.clone();
let address = peer.address().clone();
let idle_timeout = Duration::from_secs(60);
let config = Config {
address: WithOrigin::inline(address),
Expand All @@ -329,14 +329,14 @@ async fn start_network(
tokio::time::timeout(Duration::from_millis(10_000), async {
let mut connections = network.wait_online_peers_update(HashSet::len).await;
while conn_count != connections {
info!(peer_addr = %peer.address, %connections);
info!(peer_addr = %peer.address(), %connections);
connections = network.wait_online_peers_update(HashSet::len).await;
}
})
.await
.expect("Failed to get all connections");

info!(peer_addr = %peer.address, %conn_count, "Got all connections!");
info!(peer_addr = %peer.address(), %conn_count, "Got all connections!");

(peer, network)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/iroha_schema_derive/src/trait_bounds.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Algorithm for generating trait bounds in IntoSchema derive
//! Algorithm for generating trait bounds in `IntoSchema` derive
//!
//! Based on https://github.com/paritytech/parity-scale-codec/blob/2c61d4ab70dfa157556430546441cd2deb5031f2/derive/src/trait_bounds.rs
//! Based on <https://github.com/paritytech/parity-scale-codec/blob/2c61d4ab70dfa157556430546441cd2deb5031f2/derive/src/trait_bounds.rs>
use std::iter;

Expand Down
1 change: 1 addition & 0 deletions crates/iroha_schema_gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ license.workspace = true
workspace = true

[dependencies]
# TODO: `transparent_api` feature shouldn't be activated/required here
iroha_data_model = { workspace = true, features = ["http", "transparent_api"] }
iroha_executor_data_model = { workspace = true }

Expand Down
2 changes: 0 additions & 2 deletions crates/iroha_telemetry_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@ manyhow = { workspace = true }
iroha_macro_utils = { workspace = true }

[dev-dependencies]
iroha_core = { workspace = true }

trybuild = { workspace = true }
3 changes: 2 additions & 1 deletion crates/iroha_telemetry_derive/tests/ui_fail/not_execute.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use iroha_core::state::StateTransaction;
use iroha_telemetry_derive::metrics;

struct StateTransaction;

#[metrics(+"test_query", "another_test_query_without_timing")]
fn exequte(_state_transaction: &StateTransaction) -> Result<(), ()> {
Ok(())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: Function should be an `impl execute`
--> tests/ui_fail/not_execute.rs:5:4
--> tests/ui_fail/not_execute.rs:6:4
|
5 | fn exequte(_state_transaction: &StateTransaction) -> Result<(), ()> {
6 | fn exequte(_state_transaction: &StateTransaction) -> Result<(), ()> {
| ^^^^^^^
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use iroha_telemetry_derive::metrics;
use iroha_core::state::StateTransaction;

type MyNotResult = Option<i32>;

struct StateTransaction;

#[metrics(+"test_query", "another_test_query_without_timing")]
fn execute(_state_transaction: &StateTransaction) -> MyNotResult {
None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: Should return `Result`. Found MyNotResult
--> tests/ui_fail/not_return_result.rs:7:54
--> tests/ui_fail/not_return_result.rs:8:54
|
7 | fn execute(_state_transaction: &StateTransaction) -> MyNotResult {
8 | fn execute(_state_transaction: &StateTransaction) -> MyNotResult {
| ^^^^^^^^^^^
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use iroha_core::state::StateTransaction;
use iroha_telemetry_derive::metrics;

struct StateTransaction;

#[metrics(+"test_query", "another_test_query_without_timing")]
fn execute(_state_transaction: &StateTransaction) {
Ok::<(), ()>(());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: `Fn` must return `Result`. Returns nothing instead.
--> tests/ui_fail/return_nothing.rs:4:1
--> tests/ui_fail/return_nothing.rs:5:1
|
4 | #[metrics(+"test_query", "another_test_query_without_timing")]
5 | #[metrics(+"test_query", "another_test_query_without_timing")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the attribute macro `metrics` (in Nightly builds, run with -Z macro-backtrace for more info)
1 change: 0 additions & 1 deletion crates/iroha_test_network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ authors.workspace = true
license.workspace = true

[dependencies]
iroha_core.workspace = true
iroha.workspace = true

iroha_executor_data_model.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/iroha_test_network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use iroha_config::base::{
read::ConfigReader,
toml::{TomlSource, WriteExt as _, Writer as TomlWriter},
};
pub use iroha_core::state::StateReadOnly;
use iroha_crypto::{ExposedPrivateKey, KeyPair, PrivateKey};
use iroha_data_model::{
events::pipeline::BlockEventFilter,
Expand Down

0 comments on commit 98782af

Please sign in to comment.