Skip to content

Commit

Permalink
fix!: remove on-chain parameters from config and remove NewParameter ISI
Browse files Browse the repository at this point in the history
Signed-off-by: Marin Veršić <[email protected]>
  • Loading branch information
mversic committed Jun 24, 2024
1 parent d5086e7 commit 94027e9
Show file tree
Hide file tree
Showing 80 changed files with 1,253 additions and 2,499 deletions.
3 changes: 1 addition & 2 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ impl Iroha {
None
}
}.unwrap_or_else(|| {
State::from_config(
config.chain_wide,
State::new(
world,
Arc::clone(&kura),
live_query_store_handle.clone(),
Expand Down
3 changes: 1 addition & 2 deletions cli/src/samples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ pub fn get_config_toml(
.write(["sumeragi", "trusted_peers"], peers)
.write(["network", "address"], DEFAULT_P2P_ADDR)
.write(["network", "block_gossip_period_ms"], 500)
.write(["network", "block_gossip_max_size"], 1)
.write(["network", "block_gossip_size"], 1)
.write(["torii", "address"], DEFAULT_TORII_ADDR)
.write(["chain_wide", "max_transactions_in_block"], 2)
.write(["genesis", "public_key"], genesis_public_key)
.write(
["genesis", "signed_file"],
Expand Down
16 changes: 4 additions & 12 deletions client/benches/tps/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use iroha::{
crypto::KeyPair,
data_model::{
events::pipeline::{BlockEventFilter, BlockStatus},
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
};
use iroha_data_model::param::BlockLimits;
use nonzero_ext::nonzero;
use serde::Deserialize;
use test_network::*;
Expand All @@ -22,7 +22,7 @@ pub struct Config {
pub peers: u32,
/// Interval in microseconds between transactions to reduce load
pub interval_us_per_tx: u64,
pub max_txs_per_block: u32,
pub block_limits: BlockLimits,
pub blocks: u32,
pub sample_size: u32,
pub genesis_max_retries: u32,
Expand All @@ -33,11 +33,7 @@ impl fmt::Display for Config {
write!(
f,
"{}peers-{}interval_µs-{}max_txs-{}blocks-{}samples",
self.peers,
self.interval_us_per_tx,
self.max_txs_per_block,
self.blocks,
self.sample_size,
self.peers, self.interval_us_per_tx, self.block_limits, self.blocks, self.sample_size,
)
}
}
Expand All @@ -55,11 +51,7 @@ impl Config {
let clients = network.clients();
wait_for_genesis_committed_with_max_retries(&clients, 0, self.genesis_max_retries);

client.submit_all_blocking(
ParametersBuilder::new()
.add_parameter(MAX_TRANSACTIONS_IN_BLOCK, self.max_txs_per_block)?
.into_set_parameters(),
)?;
client.submit_blocking(SetParameter::new(Parameter::BlockLimits(self.block_limits)))?;

let unit_names = (UnitName::MIN..).take(self.peers as usize);
let units = clients
Expand Down
6 changes: 1 addition & 5 deletions client/examples/register_1000_triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let chain_id = get_chain_id();
let genesis_key_pair = get_key_pair(test_network::Signatory::Genesis);
let topology = vec![peer.id.clone()];
let mut configuration = get_config(
let configuration = get_config(
unique_vec![peer.id.clone()],
chain_id.clone(),
get_key_pair(test_network::Signatory::Peer),
genesis_key_pair.public_key(),
);

// Increase executor limits for large genesis
configuration.chain_wide.executor_runtime.fuel_limit = u64::MAX;
configuration.chain_wide.executor_runtime.max_memory = u32::MAX.into();

let genesis = generate_genesis(1_000_u32, chain_id, &genesis_key_pair, topology)?;

let builder = PeerBuilder::new()
Expand Down
8 changes: 4 additions & 4 deletions client/examples/tutorial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn domain_registration_test(config: Config) -> Result<(), Error> {
use iroha::{
client::Client,
data_model::{
metadata::UnlimitedMetadata,
metadata::Metadata,
prelude::{Domain, DomainId, InstructionBox, Register},
},
};
Expand All @@ -57,7 +57,7 @@ fn domain_registration_test(config: Config) -> Result<(), Error> {

// #region domain_register_example_prepare_tx
// Prepare a transaction
let metadata = UnlimitedMetadata::default();
let metadata = Metadata::default();
let instructions: Vec<InstructionBox> = vec![create_looking_glass.into()];
let tx = iroha.build_transaction(instructions, metadata);
// #endregion domain_register_example_prepare_tx
Expand Down Expand Up @@ -101,7 +101,7 @@ fn account_registration_test(config: Config) -> Result<(), Error> {
client::Client,
crypto::KeyPair,
data_model::{
metadata::UnlimitedMetadata,
metadata::Metadata,
prelude::{Account, AccountId, InstructionBox, Register},
},
};
Expand All @@ -127,7 +127,7 @@ fn account_registration_test(config: Config) -> Result<(), Error> {
// #region register_account_prepare_tx
// Prepare a transaction using the
// Account's RegisterBox
let metadata = UnlimitedMetadata::new();
let metadata = Metadata::default();
let instructions: Vec<InstructionBox> = vec![create_account.into()];
let tx = iroha.build_transaction(instructions, metadata);
// #endregion register_account_prepare_tx
Expand Down
17 changes: 9 additions & 8 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ impl_query_output! {
crate::data_model::executor::ExecutorDataModel,
crate::data_model::trigger::Trigger,
crate::data_model::prelude::Numeric,
crate::data_model::param::Parameters,
}

/// Iroha client
Expand Down Expand Up @@ -452,7 +453,7 @@ impl Client {
pub fn build_transaction(
&self,
instructions: impl Into<Executable>,
metadata: UnlimitedMetadata,
metadata: Metadata,
) -> SignedTransaction {
let tx_builder = TransactionBuilder::new(self.chain.clone(), self.account.clone());

Expand Down Expand Up @@ -509,7 +510,7 @@ impl Client {
&self,
instructions: impl IntoIterator<Item = impl Instruction>,
) -> Result<HashOf<SignedTransaction>> {
self.submit_all_with_metadata(instructions, UnlimitedMetadata::new())
self.submit_all_with_metadata(instructions, Metadata::default())
}

/// Instructions API entry point. Submits one Iroha Special Instruction to `Iroha` peers.
Expand All @@ -521,7 +522,7 @@ impl Client {
pub fn submit_with_metadata(
&self,
instruction: impl Instruction,
metadata: UnlimitedMetadata,
metadata: Metadata,
) -> Result<HashOf<SignedTransaction>> {
self.submit_all_with_metadata([instruction], metadata)
}
Expand All @@ -535,7 +536,7 @@ impl Client {
pub fn submit_all_with_metadata(
&self,
instructions: impl IntoIterator<Item = impl Instruction>,
metadata: UnlimitedMetadata,
metadata: Metadata,
) -> Result<HashOf<SignedTransaction>> {
self.submit_transaction(&self.build_transaction(instructions, metadata))
}
Expand Down Expand Up @@ -718,7 +719,7 @@ impl Client {
&self,
instructions: impl IntoIterator<Item = impl Instruction>,
) -> Result<HashOf<SignedTransaction>> {
self.submit_all_blocking_with_metadata(instructions, UnlimitedMetadata::new())
self.submit_all_blocking_with_metadata(instructions, Metadata::default())
}

/// Submits and waits until the transaction is either rejected or committed.
Expand All @@ -730,7 +731,7 @@ impl Client {
pub fn submit_blocking_with_metadata(
&self,
instruction: impl Instruction,
metadata: UnlimitedMetadata,
metadata: Metadata,
) -> Result<HashOf<SignedTransaction>> {
self.submit_all_blocking_with_metadata(vec![instruction.into()], metadata)
}
Expand All @@ -744,7 +745,7 @@ impl Client {
pub fn submit_all_blocking_with_metadata(
&self,
instructions: impl IntoIterator<Item = impl Instruction>,
metadata: UnlimitedMetadata,
metadata: Metadata,
) -> Result<HashOf<SignedTransaction>> {
let transaction = self.build_transaction(instructions, metadata);
self.submit_transaction_blocking(&transaction)
Expand Down Expand Up @@ -1620,7 +1621,7 @@ mod tests {
});

let build_transaction =
|| client.build_transaction(Vec::<InstructionBox>::new(), UnlimitedMetadata::new());
|| client.build_transaction(Vec::<InstructionBox>::new(), Metadata::default());
let tx1 = build_transaction();
let tx2 = build_transaction();
assert_ne!(tx1.hash(), tx2.hash());
Expand Down
3 changes: 1 addition & 2 deletions client/tests/integration/add_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use iroha_config::parameters::actual::Root as Config;
use test_network::*;

#[test]
// This test suite is also covered at the UI level in the iroha_cli tests
// in test_register_domains.py
#[ignore = "should be implemented with custom parameters"]
fn client_add_domain_with_name_length_more_than_limit_should_not_commit_transaction() -> Result<()>
{
let (_rt, _peer, test_client) = <PeerBuilder>::new().with_port(10_500).start_with_runtime();
Expand Down
6 changes: 3 additions & 3 deletions client/tests/integration/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount() ->
let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid");
let create_asset =
Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone()));
let metadata = iroha::data_model::metadata::UnlimitedMetadata::default();
let metadata = iroha::data_model::metadata::Metadata::default();
//When
let quantity = numeric!(200);
let mint = Mint::asset_numeric(
Expand Down Expand Up @@ -137,7 +137,7 @@ fn client_add_big_asset_quantity_to_existing_asset_should_increase_asset_amount(
let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid");
let create_asset =
Register::asset_definition(AssetDefinition::numeric(asset_definition_id.clone()));
let metadata = iroha::data_model::metadata::UnlimitedMetadata::default();
let metadata = iroha::data_model::metadata::Metadata::default();
//When
let quantity = Numeric::new(2_u128.pow(65), 0);
let mint = Mint::asset_numeric(
Expand Down Expand Up @@ -168,7 +168,7 @@ fn client_add_asset_with_decimal_should_increase_asset_amount() -> Result<()> {
let asset_definition_id = AssetDefinitionId::from_str("xor#wonderland").expect("Valid");
let asset_definition = AssetDefinition::numeric(asset_definition_id.clone());
let create_asset = Register::asset_definition(asset_definition);
let metadata = iroha::data_model::metadata::UnlimitedMetadata::default();
let metadata = iroha::data_model::metadata::Metadata::default();

//When
let quantity = numeric!(123.456);
Expand Down
16 changes: 6 additions & 10 deletions client/tests/integration/asset_propagation.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use std::{str::FromStr as _, thread};
use std::{num::NonZeroU64, str::FromStr as _, thread};

use eyre::Result;
use iroha::{
client::{self, QueryResult},
data_model::{
parameter::{default::MAX_TRANSACTIONS_IN_BLOCK, ParametersBuilder},
prelude::*,
},
data_model::prelude::*,
};
use iroha_config::parameters::actual::Root as Config;
use iroha_data_model::param::BlockLimits;
use test_network::*;
use test_samples::gen_account_in;

Expand All @@ -22,11 +20,9 @@ fn client_add_asset_quantity_to_existing_asset_should_increase_asset_amount_on_a
wait_for_genesis_committed(&network.clients(), 0);
let pipeline_time = Config::pipeline_time();

client.submit_all_blocking(
ParametersBuilder::new()
.add_parameter(MAX_TRANSACTIONS_IN_BLOCK, 1u32)?
.into_set_parameters(),
)?;
client.submit_blocking(SetParameter::new(Parameter::BlockLimits(BlockLimits {
max_transactions: NonZeroU64::new(1).unwrap(),
})))?;

let create_domain: InstructionBox =
Register::domain(Domain::new(DomainId::from_str("domain")?)).into();
Expand Down
24 changes: 12 additions & 12 deletions client/tests/integration/events/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fn transaction_execution_should_produce_events(

// submit transaction to produce events
init_receiver.recv()?;
let transaction = client.build_transaction(executable, UnlimitedMetadata::new());
let transaction = client.build_transaction(executable, Metadata::default());
client.submit_transaction_blocking(&transaction)?;

// assertion
Expand All @@ -161,9 +161,9 @@ fn transaction_execution_should_produce_events(
iroha_logger::info!("Event: {:?}", event);
assert!(matches!(event, DataEvent::Domain(_)));
if let DataEvent::Domain(domain_event) = event {
assert!(matches!(domain_event, DomainEvent::Created(_)));
assert!(matches!(domain_event, DomainEvent::Create(_)));

if let DomainEvent::Created(created_domain) = domain_event {
if let DomainEvent::Create(created_domain) = domain_event {
let domain_id = DomainId::new(i.to_string().parse().expect("Valid"));
assert_eq!(domain_id, *created_domain.id());
}
Expand Down Expand Up @@ -226,9 +226,9 @@ fn produce_multiple_events() -> Result<()> {
let event: DataEvent = event_receiver.recv()??.try_into()?;
assert!(matches!(event, DataEvent::Role(_)));
if let DataEvent::Role(role_event) = event {
assert!(matches!(role_event, RoleEvent::Created(_)));
assert!(matches!(role_event, RoleEvent::Create(_)));

if let RoleEvent::Created(created_role) = role_event {
if let RoleEvent::Create(created_role) = role_event {
assert_eq!(created_role.id(), role.id());
assert!(created_role
.permissions()
Expand All @@ -237,43 +237,43 @@ fn produce_multiple_events() -> Result<()> {
}

let expected_domain_events: Vec<DataEvent> = [
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdded(
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdd(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_1.id.clone(),
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdded(
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionAdd(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_2.id.clone(),
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleGranted(
DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleGrant(
AccountRoleChanged {
account: bob_id.clone(),
role: role_id.clone(),
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemoved(
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemove(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_1.id,
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemoved(
DataEvent::Domain(DomainEvent::Account(AccountEvent::PermissionRemove(
AccountPermissionChanged {
account: bob_id.clone(),
permission: token_2.id,
},
))),
DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleRevoked(
DataEvent::Domain(DomainEvent::Account(AccountEvent::RoleRevoke(
AccountRoleChanged {
account: bob_id,
role: role_id.clone(),
},
))),
DataEvent::Role(RoleEvent::Deleted(role_id)),
DataEvent::Role(RoleEvent::Delete(role_id)),
]
.into_iter()
.map(Into::into)
Expand Down
Loading

0 comments on commit 94027e9

Please sign in to comment.