Skip to content

Commit

Permalink
fix: Fix iroha_genesis compilation without transparent_api feature (
Browse files Browse the repository at this point in the history
#5056)

Signed-off-by: Dmitry Murzin <[email protected]>
  • Loading branch information
dima74 authored Sep 12, 2024
1 parent 98b4edb commit 7b84762
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 37 deletions.
2 changes: 1 addition & 1 deletion crates/iroha/tests/integration/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn limits_should_work() -> Result<()> {

#[test]
fn reported_length_should_be_accurate() -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_170).start_with_runtime();
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_200).start_with_runtime();
wait_for_genesis_committed(&vec![client.clone()], 0);

register_assets(&client)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/iroha/tests/integration/status_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn status_eq_excluding_uptime_and_queue(lhs: &Status, rhs: &Status) -> bool {

#[test]
fn json_and_scale_statuses_equality() -> Result<()> {
let (_rt, network, client) = Network::start_test_with_runtime(2, Some(11_200));
let (_rt, network, client) = Network::start_test_with_runtime(2, Some(11_280));
wait_for_genesis_committed(&network.clients(), 0);

let json_status_zero = get_status_json(&client).unwrap();
Expand Down
35 changes: 35 additions & 0 deletions crates/iroha_data_model/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,41 @@ impl Parameters {
)
.chain(self.custom.values().cloned().map(Parameter::Custom))
}

/// Set `parameter` value to corresponding parameter in `self`
pub fn set_parameter(&mut self, parameter: Parameter) {
macro_rules! apply_parameter {
($($container:ident($param:ident.$field:ident) => $single:ident::$variant:ident),* $(,)?) => {
match parameter {
$(
Parameter::$container($single::$variant(next)) => {
self.$param.$field = next;
}
)*
Parameter::Custom(next) => {
self.custom.insert(next.id.clone(), next);
}
}
};
}

apply_parameter!(
Sumeragi(sumeragi.max_clock_drift_ms) => SumeragiParameter::MaxClockDriftMs,
Sumeragi(sumeragi.block_time_ms) => SumeragiParameter::BlockTimeMs,
Sumeragi(sumeragi.commit_time_ms) => SumeragiParameter::CommitTimeMs,

Block(block.max_transactions) => BlockParameter::MaxTransactions,

Transaction(transaction.max_instructions) => TransactionParameter::MaxInstructions,
Transaction(transaction.smart_contract_size) => TransactionParameter::SmartContractSize,

SmartContract(smart_contract.fuel) => SmartContractParameter::Fuel,
SmartContract(smart_contract.memory) => SmartContractParameter::Memory,

Executor(executor.fuel) => SmartContractParameter::Fuel,
Executor(executor.memory) => SmartContractParameter::Memory,
);
}
}

impl SumeragiParameters {
Expand Down
36 changes: 1 addition & 35 deletions crates/iroha_genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,45 +334,11 @@ fn convert_parameters(parameters: Vec<Parameter>) -> Option<Parameters> {
}
let mut result = Parameters::default();
for parameter in parameters {
apply_parameter(&mut result, parameter);
result.set_parameter(parameter);
}
Some(result)
}

fn apply_parameter(parameters: &mut Parameters, parameter: Parameter) {
macro_rules! apply_parameter {
($($container:ident($param:ident.$field:ident) => $single:ident::$variant:ident),* $(,)?) => {
match parameter {
$(
Parameter::$container(iroha_data_model::parameter::$single::$variant(next)) => {
parameters.$param.$field = next;
}
)*
Parameter::Custom(next) => {
parameters.custom.insert(next.id.clone(), next);
}
}
};
}

apply_parameter!(
Sumeragi(sumeragi.max_clock_drift_ms) => SumeragiParameter::MaxClockDriftMs,
Sumeragi(sumeragi.block_time_ms) => SumeragiParameter::BlockTimeMs,
Sumeragi(sumeragi.commit_time_ms) => SumeragiParameter::CommitTimeMs,

Block(block.max_transactions) => BlockParameter::MaxTransactions,

Transaction(transaction.max_instructions) => TransactionParameter::MaxInstructions,
Transaction(transaction.smart_contract_size) => TransactionParameter::SmartContractSize,

SmartContract(smart_contract.fuel) => SmartContractParameter::Fuel,
SmartContract(smart_contract.memory) => SmartContractParameter::Memory,

Executor(executor.fuel) => SmartContractParameter::Fuel,
Executor(executor.memory) => SmartContractParameter::Memory,
);
}

impl Encode for ExecutorPath {
fn encode(&self) -> Vec<u8> {
self.0
Expand Down

0 comments on commit 7b84762

Please sign in to comment.