Skip to content

Commit

Permalink
[feature] #2073: Prefer ConstString over String for types in blockcha…
Browse files Browse the repository at this point in the history
…in (#2505)

* [feature] #2073: Prefer ConstString over String for data_model

Signed-off-by: Ales Tsurko <ales.tsurko@gmail.com>

* [feature] #2073: Encapsulate iroha_data_primitives into shared crate

Signed-off-by: Ales Tsurko <ales.tsurko@gmail.com>

* [feature] #2073: Use ConstString in crypto

Signed-off-by: Ales Tsurko <ales.tsurko@gmail.com>

* [feature] #2073: Rename data_primitives crate into primitives

Signed-off-by: Ales Tsurko <ales.tsurko@gmail.com>
  • Loading branch information
ales-tsurko authored Jul 22, 2022
1 parent 425e7fc commit 9c5c531
Show file tree
Hide file tree
Showing 45 changed files with 125 additions and 122 deletions.
44 changes: 24 additions & 20 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ members = [
"core",
"core/test_network",
"crypto",
"tools/kura_inspector",
"tools/parity_scale_decoder",
"tools/kagami",
"data_model",
"data_model/primitives",
"primitives",
"ffi",
"ffi/derive",
"futures",
Expand All @@ -27,10 +24,13 @@ members = [
"p2p",
"permissions_validators",
"schema",
"schema/gen",
"schema/derive",
"schema/gen",
"substrate",
"telemetry",
"tools/kagami",
"tools/kura_inspector",
"tools/parity_scale_decoder",
"version",
"version/derive",
]
Expand Down
2 changes: 1 addition & 1 deletion actor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deadlock_detection = ["petgraph"]
[dependencies]
iroha_actor_derive = { version = "=2.0.0-pre-rc.5", path = "derive" }
iroha_logger = { version = "=2.0.0-pre-rc.5", path = "../logger" }
iroha_data_primitives = { version = "=2.0.0-pre-rc.5", path = "../data_model/primitives" }
iroha_primitives = { version = "=2.0.0-pre-rc.5", path = "../primitives" }

async-trait = "0.1"
once_cell = "1.8.0"
Expand Down
2 changes: 1 addition & 1 deletion actor/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use std::{collections::HashMap, sync::Arc};

use dashmap::{mapref::entry::Entry, DashMap};
use futures::{prelude::*, stream::FuturesUnordered};
use iroha_data_primitives::small::{self, SmallVec};
use iroha_primitives::small::{self, SmallVec};

use super::*;

Expand Down
3 changes: 2 additions & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ maintenance = { status = "actively-developed" }

[dependencies]
iroha_config = { version = "=2.0.0-pre-rc.5", path = "../config" }
iroha_core = { version = "=2.0.0-pre-rc.5", path = "../core", features = ["dev-telemetry", "telemetry"]}
iroha_crypto = { version = "=2.0.0-pre-rc.5", path = "../crypto"}
iroha_data_model = { version = "=2.0.0-pre-rc.5", path = "../data_model", features = ["warp"] }
iroha_primitives = { version = "=2.0.0-pre-rc.5", path = "../primitives" }
iroha_logger = { version = "=2.0.0-pre-rc.5", path = "../logger"}
iroha_telemetry = { version ="=2.0.0-pre-rc.5", path = "../telemetry" }
iroha_version = { version = "=2.0.0-pre-rc.5", path = "../version" }
iroha_core = { version = "=2.0.0-pre-rc.5", path = "../core", features = ["dev-telemetry", "telemetry"]}

attohttpc = "0.18"
eyre = "0.6.5"
Expand Down
13 changes: 7 additions & 6 deletions client/benches/torii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use iroha_core::{
prelude::*,
};
use iroha_data_model::prelude::*;
use iroha_primitives::small::SmallStr;
use iroha_version::Encode;
use test_network::{get_key_pair, Peer as TestPeer, PeerBuilder, TestRuntime};
use tokio::runtime::Runtime;
Expand Down Expand Up @@ -65,14 +66,14 @@ fn query_requests(criterion: &mut Criterion) {
let mut client_config = iroha_client::samples::get_client_config(&get_key_pair());

// TODO: We should definitely turn this into type-checked state. `String` is a terrible bodge
client_config.torii_api_url = small::SmallStr::from_string(peer.api_address.clone());
client_config.torii_api_url = SmallStr::from_string(peer.api_address.clone());
if !client_config.torii_api_url.starts_with("http://") {
client_config.torii_api_url =
small::SmallStr::from_string(format!("http://{}", client_config.torii_api_url));
SmallStr::from_string(format!("http://{}", client_config.torii_api_url));
}
if !client_config.torii_telemetry_url.starts_with("http://") {
client_config.torii_telemetry_url =
small::SmallStr::from_string(format!("http://{}", client_config.torii_telemetry_url));
SmallStr::from_string(format!("http://{}", client_config.torii_telemetry_url));
}
let iroha_client = Client::new(&client_config).expect("Invalid client configuration");
thread::sleep(std::time::Duration::from_millis(5000));
Expand Down Expand Up @@ -149,14 +150,14 @@ fn instruction_submits(criterion: &mut Criterion) {
let create_account = RegisterBox::new(Account::new(account_id.clone(), [public_key]));
let asset_definition_id = AssetDefinitionId::new("xor".parse().expect("Valid"), domain_id);
let mut client_config = iroha_client::samples::get_client_config(&get_key_pair());
client_config.torii_api_url = small::SmallStr::from_string(peer.api_address.clone());
client_config.torii_api_url = SmallStr::from_string(peer.api_address.clone());
if !client_config.torii_api_url.starts_with("http://") {
client_config.torii_api_url =
small::SmallStr::from_string(format!("http://{}", client_config.torii_api_url));
SmallStr::from_string(format!("http://{}", client_config.torii_api_url));
}
if !client_config.torii_telemetry_url.starts_with("http://") {
client_config.torii_telemetry_url =
small::SmallStr::from_string(format!("http://{}", client_config.torii_telemetry_url));
SmallStr::from_string(format!("http://{}", client_config.torii_telemetry_url));
}
let iroha_client = Client::new(&client_config).expect("Invalid client configuration");
thread::sleep(std::time::Duration::from_millis(5000));
Expand Down
2 changes: 1 addition & 1 deletion client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use iroha_core::smartcontracts::isi::query::Error as QueryError;
use iroha_crypto::{HashOf, KeyPair};
use iroha_data_model::{predicate::PredicateBox, prelude::*, query::SignedQueryRequest};
use iroha_logger::prelude::*;
use iroha_primitives::small::SmallStr;
use iroha_telemetry::metrics::Status;
use iroha_version::prelude::*;
use parity_scale_codec::DecodeAll;
use rand::Rng;
use serde::de::DeserializeOwned;
use small::SmallStr;

use crate::{
config::Configuration,
Expand Down
6 changes: 3 additions & 3 deletions client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use iroha_config::derive::Configurable;
use iroha_crypto::prelude::*;
use iroha_data_model::{prelude::*, transaction};
use iroha_logger::Configuration as LoggerConfiguration;
use iroha_primitives::small::SmallStr;
use serde::{Deserialize, Serialize};
use small::SmallStr;

const DEFAULT_TORII_TELEMETRY_URL: &str = "127.0.0.1:8180";
const DEFAULT_TRANSACTION_TIME_TO_LIVE_MS: u64 = 100_000;
Expand Down Expand Up @@ -100,8 +100,8 @@ impl Default for Configuration {
private_key,
account_id: Self::placeholder_account(),
basic_auth: None,
torii_api_url: small::SmallStr::from_str(uri::DEFAULT_API_URL),
torii_telemetry_url: small::SmallStr::from_str(DEFAULT_TORII_TELEMETRY_URL),
torii_api_url: SmallStr::from_str(uri::DEFAULT_API_URL),
torii_telemetry_url: SmallStr::from_str(DEFAULT_TORII_TELEMETRY_URL),
transaction_time_to_live_ms: DEFAULT_TRANSACTION_TIME_TO_LIVE_MS,
transaction_status_timeout_ms: DEFAULT_TRANSACTION_STATUS_TIMEOUT_MS,
transaction_limits: TransactionLimits {
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub mod samples {
public_key,
private_key,
account_id: "alice@wonderland".parse().expect("Should not fail."),
torii_api_url: iroha_data_model::small::SmallStr::from_str(uri::DEFAULT_API_URL),
torii_api_url: iroha_primitives::small::SmallStr::from_str(uri::DEFAULT_API_URL),
..Configuration::default()
}
}
Expand Down
3 changes: 2 additions & 1 deletion client/tests/integration/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use std::{str::FromStr as _, thread};

use eyre::Result;
use iroha_client::client;
use iroha_data_model::{fixed::Fixed, prelude::*};
use iroha_data_model::prelude::*;
use iroha_primitives::fixed::Fixed;
use test_network::*;

use super::Configuration;
Expand Down
3 changes: 2 additions & 1 deletion client/tests/integration/multisignature_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use iroha_client::{
};
use iroha_core::prelude::*;
use iroha_data_model::{account::TRANSACTION_SIGNATORIES_VALUE, prelude::*};
use iroha_primitives::small::SmallStr;
use test_network::*;

use super::Configuration;
Expand Down Expand Up @@ -71,7 +72,7 @@ fn multisignature_transactions_should_wait_for_all_signatures() {
thread::sleep(pipeline_time);

//Then
client_configuration.torii_api_url = small::SmallStr::from_string(
client_configuration.torii_api_url = SmallStr::from_string(
"http://".to_owned() + &network.peers.values().last().unwrap().api_address,
);
let iroha_client_1 = Client::new(&client_configuration).expect("Invalid client configuration");
Expand Down
1 change: 1 addition & 0 deletions client/tests/integration/transfer_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use iroha_client::client;
use iroha_core::prelude::*;
use iroha_data_model::{prelude::*, Registered};
use iroha_primitives::fixed::Fixed;
use test_network::*;

#[test]
Expand Down
15 changes: 8 additions & 7 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ is-it-maintained-open-issues = { repository = "https://github.com/hyperledger/ir
maintenance = { status = "actively-developed" }

[dependencies]
iroha_data_model = { version = "=2.0.0-pre-rc.5", path = "../data_model", features = ["mutable_api", "warp"] }
iroha_macro = { version = "=2.0.0-pre-rc.5", path = "../macro" }
iroha_p2p = { version = "=2.0.0-pre-rc.5", path = "../p2p" }
iroha_logger = { version = "=2.0.0-pre-rc.5", path = "../logger"}
iroha_crypto = { version = "=2.0.0-pre-rc.5", path = "../crypto" }
iroha_version = { version = "=2.0.0-pre-rc.5", path = "../version", features = ["warp"] }
iroha_actor = { version = "=2.0.0-pre-rc.5", path = "../actor" }
iroha_config = { version = "=2.0.0-pre-rc.5", path = "../config" }
iroha_crypto = { version = "=2.0.0-pre-rc.5", path = "../crypto" }
iroha_data_model = { version = "=2.0.0-pre-rc.5", path = "../data_model", features = ["mutable_api", "warp"] }
iroha_primitives = { version = "=2.0.0-pre-rc.5", path = "../primitives" }
iroha_futures = { version = "=2.0.0-pre-rc.5", path = "../futures" }
iroha_telemetry = { version = "=2.0.0-pre-rc.5", path = "../telemetry" }
iroha_logger = { version = "=2.0.0-pre-rc.5", path = "../logger"}
iroha_macro = { version = "=2.0.0-pre-rc.5", path = "../macro" }
iroha_p2p = { version = "=2.0.0-pre-rc.5", path = "../p2p" }
iroha_schema = { version = "=2.0.0-pre-rc.5", path = "../schema" }
iroha_telemetry = { version = "=2.0.0-pre-rc.5", path = "../telemetry" }
iroha_version = { version = "=2.0.0-pre-rc.5", path = "../version", features = ["warp"] }

async-trait = "0.1"
async-stream = "0.3.2"
Expand Down
4 changes: 2 additions & 2 deletions core/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use eyre::{eyre, Result, WrapErr};
use iroha_actor::Addr;
use iroha_crypto::{KeyPair, PublicKey};
use iroha_data_model::{asset::AssetDefinition, prelude::*};
use iroha_primitives::small::{smallvec, SmallVec};
use iroha_schema::prelude::*;
use serde::{Deserialize, Serialize};
use small::{smallvec, SmallVec};
use tokio::{time, time::Duration};

pub use self::config::GenesisConfiguration;
Expand Down Expand Up @@ -421,7 +421,7 @@ impl RawGenesisBlockBuilder {
pub fn new() -> Self {
RawGenesisBlockBuilder {
transaction: GenesisTransaction {
isi: iroha_data_model::small::SmallVec::new(),
isi: SmallVec::new(),
},
}
}
Expand Down
6 changes: 2 additions & 4 deletions core/src/smartcontracts/isi/asset.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
//! This module contains [`Asset`] structure, it's implementation and related traits and
//! instructions implementations.

use iroha_data_model::{
prelude::*,
primitives::{CheckedOp, IntoMetric},
};
use iroha_data_model::prelude::*;
use iroha_primitives::{fixed::Fixed, CheckedOp, IntoMetric};
use iroha_telemetry::metrics;

use super::prelude::*;
Expand Down
4 changes: 3 additions & 1 deletion core/src/smartcontracts/isi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub use error::*;
use eyre::Result;
use iroha_data_model::{expression::prelude::*, isi::*, prelude::*};
use iroha_logger::prelude::*;
use iroha_primitives::fixed::Fixed;

use super::{Evaluate, Execute};
use crate::{prelude::*, wsv::WorldStateView};
Expand All @@ -30,7 +31,8 @@ pub mod error {

use derive_more::Display;
use iroha_crypto::HashOf;
use iroha_data_model::{fixed::FixedPointOperationError, metadata, prelude::*, trigger};
use iroha_data_model::{metadata, prelude::*, trigger};
use iroha_primitives::fixed::FixedPointOperationError;
use iroha_schema::IntoSchema;
use parity_scale_codec::{Decode, Encode};
use thiserror::Error;
Expand Down
3 changes: 2 additions & 1 deletion core/src/wsv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use dashmap::{
use eyre::Result;
use getset::Getters;
use iroha_crypto::HashOf;
use iroha_data_model::{prelude::*, small::SmallVec};
use iroha_data_model::prelude::*;
use iroha_logger::prelude::*;
use iroha_primitives::small::SmallVec;
use iroha_telemetry::metrics::Metrics;
use tokio::{sync::broadcast, task};

Expand Down
1 change: 1 addition & 0 deletions core/test_network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ iroha_actor = { version = "=2.0.0-pre-rc.5", path = "../../actor" }
iroha_client = { version = "=2.0.0-pre-rc.5", path = "../../client" }
iroha_core = { version = "=2.0.0-pre-rc.5", path = "../../core" }
iroha_data_model = { version = "=2.0.0-pre-rc.5", path = "../../data_model" }
iroha_primitives = { version = "=2.0.0-pre-rc.5", path = "../../primitives" }
iroha_logger = { version = "=2.0.0-pre-rc.5", path = "../../logger" }
iroha_permissions_validators = { version = "=2.0.0-pre-rc.5", path = "../../permissions_validators" }

Expand Down
Loading

0 comments on commit 9c5c531

Please sign in to comment.