Skip to content

Commit f25f4f3

Browse files
committed
[refactor]: #3268 Rename item identifiers so that they are globally unique
Signed-off-by: Marin Veršić <marin.versic101@gmail.com>
1 parent 726f5ea commit f25f4f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+5664
-6716
lines changed

actor/src/lib.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
clippy::expect_used,
55
clippy::same_name_method
66
)]
7-
#[cfg(feature = "deadlock_detection")]
8-
use core::any::type_name;
97
use core::{
108
fmt::Debug,
119
ops::{Deref, DerefMut},
@@ -85,7 +83,7 @@ impl<A: Actor> Addr<A> {
8583
Self {
8684
sender,
8785
#[cfg(feature = "deadlock_detection")]
88-
actor_id: ActorId::new(Some(type_name::<A>())),
86+
actor_id: ActorId::new(Some(core::any::type_name::<A>())),
8987
}
9088
}
9189

@@ -432,7 +430,7 @@ impl<A: Actor> InitializedActor<A> {
432430
}
433431
}
434432
}
435-
iroha_logger::error!(actor = %std::any::type_name::<A>(), "Actor stopped");
433+
iroha_logger::error!(actor = %core::any::type_name::<A>(), "Actor stopped");
436434
actor.on_stop(&mut ctx).await;
437435
}
438436
.in_current_span();

cli/src/samples.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use iroha_config::{
88
torii::{uri::DEFAULT_API_URL, DEFAULT_TORII_P2P_ADDR, DEFAULT_TORII_TELEMETRY_URL},
99
};
1010
use iroha_crypto::{KeyPair, PublicKey};
11-
use iroha_data_model::peer::Id as PeerId;
11+
use iroha_data_model::peer::PeerId;
1212

1313
/// Get sample trusted peers. The public key must be the same as `configuration.public_key`
1414
///

cli/src/torii/routing.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Routing functions for Torii. If you want to add an endpoint to
22
//! Iroha you should add it here by creating a `handle_*` function,
3-
//! and add it to impl Torii. This module also defines the `VerifiedQueryRequest`,
3+
//! and add it to impl Torii. This module also defines the `VerifiedQuery`,
44
//! which is the only kind of query that is permitted to execute.
55
66
// FIXME: This can't be fixed, because one trait in `warp` is private.
@@ -47,15 +47,15 @@ pub fn sorting() -> impl warp::Filter<Extract = (Sorting,), Error = warp::Reject
4747

4848
/// Query Request verified on the Iroha node side.
4949
#[derive(Debug, Decode, Encode)]
50-
pub struct VerifiedQueryRequest {
50+
pub struct VerifiedQuery {
5151
/// Payload, containing the time, the query, the authenticating
5252
/// user account and a filter
53-
payload: query::http::Payload,
53+
payload: query::http::QueryPayload,
5454
/// Signature of the authenticating user
55-
signature: SignatureOf<query::http::Payload>,
55+
signature: SignatureOf<query::http::QueryPayload>,
5656
}
5757

58-
impl VerifiedQueryRequest {
58+
impl VerifiedQuery {
5959
/// Validate query.
6060
///
6161
/// # Errors
@@ -84,10 +84,10 @@ impl VerifiedQueryRequest {
8484
}
8585
}
8686

87-
impl TryFrom<SignedQueryRequest> for VerifiedQueryRequest {
87+
impl TryFrom<SignedQuery> for VerifiedQuery {
8888
type Error = QueryExecutionFailure;
8989

90-
fn try_from(query: SignedQueryRequest) -> Result<Self, Self::Error> {
90+
fn try_from(query: SignedQuery) -> Result<Self, Self::Error> {
9191
query
9292
.signature
9393
.verify(&query.payload)
@@ -131,10 +131,10 @@ pub(crate) async fn handle_queries(
131131
sumeragi: Arc<Sumeragi>,
132132
pagination: Pagination,
133133
sorting: Sorting,
134-
request: VersionedSignedQueryRequest,
134+
request: VersionedSignedQuery,
135135
) -> Result<Scale<VersionedPaginatedQueryResult>> {
136-
let VersionedSignedQueryRequest::V1(request) = request;
137-
let request: VerifiedQueryRequest = request.try_into()?;
136+
let VersionedSignedQuery::V1(request) = request;
137+
let request: VerifiedQuery = request.try_into()?;
138138

139139
let (result, filter) = {
140140
let wsv = sumeragi.wsv_mutex_access().clone();

client/benches/tps/utils.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl MeasurerUnit {
173173
.with_params([("asset_id".parse()?, asset_id.clone().into())]);
174174
let allow_alice_to_transfer_my_asset =
175175
GrantBox::new(can_transfer_my_asset, alice_id).into();
176-
let grant_tx = Transaction::new(
176+
let grant_tx = TransactionBuilder::new(
177177
account_id,
178178
vec![
179179
allow_alice_to_burn_my_asset,
@@ -222,15 +222,15 @@ impl MeasurerUnit {
222222
let submitter = self.client.clone();
223223
let interval_us_per_tx = self.config.interval_us_per_tx;
224224
let instructions = self.instructions();
225-
let alice_id = <Account as Identifiable>::Id::from_str("alice@wonderland")
226-
.expect("Failed to parse account id");
225+
let account_id = account_id(self.name);
226+
227227
let mut nonce = 0;
228228
thread::spawn(move || {
229229
for instruction in instructions {
230230
match shutdown_signal.try_recv() {
231231
Err(mpsc::TryRecvError::Empty) => {
232232
let transaction =
233-
Transaction::new(alice_id.clone(), [instruction], u64::MAX)
233+
TransactionBuilder::new(account_id.clone(), [instruction], u64::MAX)
234234
.with_nonce(nonce); // Use nonce to avoid transaction duplication within the same thread
235235
let transaction = submitter
236236
.sign_transaction(transaction)
@@ -270,7 +270,7 @@ impl MeasurerUnit {
270270
let supply_roses = MintBox::new(100_u32.to_value(), asset_id(self.name));
271271
let burn_a_rose = BurnBox::new(1_u32.to_value(), asset_id(self.name));
272272

273-
IfInstruction::with_otherwise(is_running_out, supply_roses, burn_a_rose).into()
273+
Conditional::with_otherwise(is_running_out, supply_roses, burn_a_rose).into()
274274
}
275275

276276
fn relay_a_rose(&self) -> Instruction {
@@ -289,7 +289,7 @@ impl MeasurerUnit {
289289
asset_id(self.next_name),
290290
);
291291

292-
IfInstruction::new(enough_to_transfer, transfer_rose).into()
292+
Conditional::new(enough_to_transfer, transfer_rose).into()
293293
}
294294
}
295295

client/examples/tutorial.rs

+9-17
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,13 @@ fn domain_registration_test(config: &Configuration) -> Result<(), Error> {
9393

9494
fn account_definition_test() -> Result<(), Error> {
9595
// #region account_definition_comparison
96-
use iroha_data_model::{account::Id as AccountIdStruct, prelude::AccountId};
96+
use iroha_data_model::prelude::AccountId;
9797

98-
// Create an `iroha_data_model::account::Id` instance
98+
// Create an `iroha_data_model::AccountId` instance
9999
// with a DomainId instance and a Domain ID for an account
100-
let longhand_account_id = AccountIdStruct {
101-
name: "white_rabbit".parse()?,
102-
domain_id: "looking_glass".parse()?,
103-
};
100+
let longhand_account_id = AccountId::new("white_rabbit".parse()?, "looking_glass".parse()?);
104101
let account_id: AccountId = "white_rabbit@looking_glass"
105-
.parse::<AccountIdStruct>()
102+
.parse()
106103
.expect("Valid, because the string contains no whitespace, has a single '@' character and is not empty after");
107104

108105
// Check that two ways to define an account match
@@ -119,7 +116,6 @@ fn account_registration_test(config: &Configuration) -> Result<(), Error> {
119116
use iroha_client::client::Client;
120117
use iroha_crypto::KeyPair;
121118
use iroha_data_model::{
122-
account::Id as AccountIdStruct,
123119
metadata::UnlimitedMetadata,
124120
prelude::{Account, AccountId, Instruction, RegisterBox},
125121
};
@@ -129,10 +125,9 @@ fn account_registration_test(config: &Configuration) -> Result<(), Error> {
129125
let iroha_client: Client = Client::new(&config)?;
130126

131127
// #region register_account_create
132-
// Create an AccountId instance by providing
133-
// the account and domain name
128+
// Create an AccountId instance by providing the account and domain name
134129
let account_id: AccountId = "white_rabbit@looking_glass"
135-
.parse::<AccountIdStruct>()
130+
.parse()
136131
.expect("Valid, because the string contains no whitespace, has a single '@' character and is not empty after");
137132
// #endregion register_account_create
138133

@@ -169,11 +164,8 @@ fn asset_registration_test(config: &Configuration) -> Result<(), Error> {
169164
use std::str::FromStr as _;
170165

171166
use iroha_client::client::Client;
172-
use iroha_data_model::{
173-
account::Id as AccountIdStruct,
174-
prelude::{
175-
AccountId, AssetDefinition, AssetDefinitionId, AssetId, IdBox, MintBox, RegisterBox,
176-
},
167+
use iroha_data_model::prelude::{
168+
AccountId, AssetDefinition, AssetDefinitionId, AssetId, IdBox, MintBox, RegisterBox,
177169
};
178170
// #endregion register_asset_crates
179171

@@ -197,7 +189,7 @@ fn asset_registration_test(config: &Configuration) -> Result<(), Error> {
197189

198190
// Create an account using the previously defined asset
199191
let account_id: AccountId = "white_rabbit@looking_glass"
200-
.parse::<AccountIdStruct>()
192+
.parse()
201193
.expect("Valid, because the string contains no whitespace, has a single '@' character and is not empty after");
202194

203195
// #region register_asset_mint_submit

client/src/client.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use iroha_config::{client::Configuration, torii::uri, GetConfiguration, PostConf
1515
use iroha_crypto::{HashOf, KeyPair};
1616
use iroha_data_model::{
1717
block::VersionedCommittedBlock, predicate::PredicateBox, prelude::*,
18-
query::error::QueryExecutionFailure, transaction::Payload,
18+
query::error::QueryExecutionFailure, transaction::TransactionPayload,
1919
};
2020
use iroha_logger::prelude::*;
2121
use iroha_primitives::small::SmallStr;
@@ -329,7 +329,7 @@ impl Client {
329329
instructions: impl Into<Executable>,
330330
metadata: UnlimitedMetadata,
331331
) -> Result<SignedTransaction> {
332-
let transaction = Transaction::new(
332+
let transaction = TransactionBuilder::new(
333333
self.account_id.clone(),
334334
instructions,
335335
self.proposed_transaction_ttl_ms,
@@ -343,7 +343,9 @@ impl Client {
343343
}
344344
.with_metadata(metadata);
345345

346-
self.sign_transaction(transaction_with_metadata)
346+
transaction_with_metadata
347+
.sign(self.key_pair.clone())
348+
.wrap_err("Failed to sign transaction")
347349
}
348350

349351
/// Signs transaction
@@ -360,7 +362,7 @@ impl Client {
360362
///
361363
/// # Errors
362364
/// Fails if signature generation fails
363-
pub fn sign_query(&self, query: QueryRequest) -> Result<SignedQueryRequest> {
365+
pub fn sign_query(&self, query: QueryBuilder) -> Result<SignedQuery> {
364366
query
365367
.sign(self.key_pair.clone())
366368
.wrap_err("Failed to sign query")
@@ -392,7 +394,7 @@ impl Client {
392394
}
393395

394396
/// Instructions API entry point. Submits one Iroha Special Instruction to `Iroha` peers.
395-
/// Allows to specify [`Metadata`] of [`Transaction`].
397+
/// Allows to specify [`Metadata`] of [`TransactionBuilder`].
396398
/// Returns submitted transaction's hash or error string.
397399
///
398400
/// # Errors
@@ -406,7 +408,7 @@ impl Client {
406408
}
407409

408410
/// Instructions API entry point. Submits several Iroha Special Instructions to `Iroha` peers.
409-
/// Allows to specify [`Metadata`] of [`Transaction`].
411+
/// Allows to specify [`Metadata`] of [`TransactionBuilder`].
410412
/// Returns submitted transaction's hash or error string.
411413
///
412414
/// # Errors
@@ -591,7 +593,7 @@ impl Client {
591593
}
592594

593595
/// Submits and waits until the transaction is either rejected or committed.
594-
/// Allows to specify [`Metadata`] of [`Transaction`].
596+
/// Allows to specify [`Metadata`] of [`TransactionBuilder`].
595597
/// Returns rejection reason if transaction was rejected.
596598
///
597599
/// # Errors
@@ -605,7 +607,7 @@ impl Client {
605607
}
606608

607609
/// Submits and waits until the transaction is either rejected or committed.
608-
/// Allows to specify [`Metadata`] of [`Transaction`].
610+
/// Allows to specify [`Metadata`] of [`TransactionBuilder`].
609611
/// Returns rejection reason if transaction was rejected.
610612
///
611613
/// # Errors
@@ -693,8 +695,8 @@ impl Client {
693695
{
694696
let pagination: Vec<_> = pagination.into();
695697
let sorting: Vec<_> = sorting.into();
696-
let request = QueryRequest::new(request.into(), self.account_id.clone(), filter);
697-
let request: VersionedSignedQueryRequest = self.sign_query(request)?.into();
698+
let request = QueryBuilder::new(request.into(), self.account_id.clone(), filter);
699+
let request: VersionedSignedQuery = self.sign_query(request)?.into();
698700

699701
Ok((
700702
B::new(
@@ -939,7 +941,10 @@ impl Client {
939941
}
940942

941943
/// Check if two transactions are the same. Compare their contents excluding the creation time.
942-
fn equals_excluding_creation_time(first: &Payload, second: &Payload) -> bool {
944+
fn equals_excluding_creation_time(
945+
first: &TransactionPayload,
946+
second: &TransactionPayload,
947+
) -> bool {
943948
first.account_id() == second.account_id()
944949
&& first.instructions() == second.instructions()
945950
&& first.time_to_live_ms() == second.time_to_live_ms()

client/tests/integration/events/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn produce_instructions() -> Vec<Instruction> {
3131
registers[0].clone(),
3232
Pair::new::<Instruction, _>(
3333
registers[1].clone(),
34-
IfInstruction::with_otherwise(
34+
Conditional::with_otherwise(
3535
false,
3636
FailBox::new("unreachable"),
3737
SequenceBox::new(vec![registers[2].clone(), registers[3].clone()]),

client/tests/integration/permissions/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn permissions_differ_not_only_by_names() {
229229
)
230230
.into();
231231

232-
let grant_hats_access_tx = Transaction::new(
232+
let grant_hats_access_tx = TransactionBuilder::new(
233233
mouse_id.clone(),
234234
vec![allow_alice_to_set_key_value_in_hats],
235235
100_000,
@@ -268,7 +268,7 @@ fn permissions_differ_not_only_by_names() {
268268
)
269269
.into();
270270

271-
let grant_shoes_access_tx = Transaction::new(
271+
let grant_shoes_access_tx = TransactionBuilder::new(
272272
mouse_id,
273273
vec![allow_alice_to_set_key_value_in_shoes],
274274
100_000,

client/tests/integration/permissions/runtime_validators.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn deny_new_validators() -> Result<()> {
3535

3636
let validator = Validator::new(
3737
"deny_new_validators%alice@wonderland".parse().unwrap(),
38-
validator::Type::Instruction,
38+
validator::ValidatorType::Instruction,
3939
WasmSmartContract::new(wasm.clone()),
4040
);
4141
info!("Submitting registration of the validator (should pass)");
@@ -44,7 +44,7 @@ fn deny_new_validators() -> Result<()> {
4444
// Trying to register the validator again
4545
let validator_2 = Validator::new(
4646
"deny_new_validators_2%alice@wonderland".parse().unwrap(),
47-
validator::Type::Instruction,
47+
validator::ValidatorType::Instruction,
4848
WasmSmartContract::new(wasm),
4949
);
5050
info!("Submitting registration of a new validator (should fail)");

client/tests/integration/roles.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn register_and_grant_role_for_metadata_access() -> Result<()> {
7474

7575
// Mouse grants role to Alice
7676
let grant_role = GrantBox::new(role_id.clone(), alice_id.clone());
77-
let grant_role_tx = Transaction::new(mouse_id.clone(), vec![grant_role.into()], 100_000)
77+
let grant_role_tx = TransactionBuilder::new(mouse_id.clone(), vec![grant_role.into()], 100_000)
7878
.sign(mouse_key_pair)?;
7979
test_client.submit_transaction_blocking(grant_role_tx)?;
8080

0 commit comments

Comments
 (0)