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ć <marin.versic101@gmail.com>
  • Loading branch information
mversic committed Oct 18, 2024
1 parent 4976419 commit 00bb622
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 80 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
1 change: 1 addition & 0 deletions crates/iroha_config_base/src/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ impl<'a> From<&'a mut Table> for Writer<'a> {
/// Extension trait to implement writing with [`Writer`] directly into [`Table`] in a chained manner.
pub trait WriteExt: Sized {
/// See [`Writer::write`].
#[must_use]
fn write<P: WritePath, T: Serialize>(self, path: P, value: T) -> Self;
}

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
6 changes: 3 additions & 3 deletions crates/iroha_schema_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ pub fn schema_derive(input: TokenStream) -> TokenStream {
);

// add trait bounds on field types using the same algorithm that parity scale codec uses
emitter.handle(trait_bounds::add(
trait_bounds::add(
&input.ident,
&mut input.generics,
&input.data,
syn::parse_quote!(iroha_schema::IntoSchema),
&syn::parse_quote!(iroha_schema::IntoSchema),
None,
false,
&syn::parse_quote!(iroha_schema),
));
);

let impl_type_id = impl_type_id(&mut syn::parse2(original_input).unwrap());

Expand Down
Loading

0 comments on commit 00bb622

Please sign in to comment.