Skip to content

Commit

Permalink
fix: unnest wasm samples from client, exclude it from workspace (#4863
Browse files Browse the repository at this point in the history
)

Signed-off-by: Nurzhan Sakén <[email protected]>
  • Loading branch information
nxsaken authored Jul 30, 2024
1 parent 0af879b commit f92bbad
Show file tree
Hide file tree
Showing 63 changed files with 108 additions and 346 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ updates:

- package-ecosystem: "cargo"
target-branch: "main"
directory: "/default_executor/"
directory: "/wasm_samples/"
schedule:
interval: "daily"
commit-message:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/iroha2-dev-pr-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
- uses: Swatinem/rust-cache@v2
- name: Default executor format
run: |
cd ./default_executor
cd ./wasm_samples/default_executor
mold --run cargo fmt --all -- --check
- name: Integration tests smart contracts format
run: |
cd ./client/tests/integration/smartcontracts
cd ./wasm_samples
mold --run cargo fmt --all -- --check
python_static_analysis:
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ members = [
"wasm_codec/derive",
"wasm_builder",
]
exclude = [
"wasm_samples",
]

[profile.deploy]
inherits = "release"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ To generate WASM files for smart contracts, use the provided script `generate_wa
bash ./scripts/generate_wasm.sh [path/to/smartcontracts]
```

The generated WASM files will be saved in a generated directory `test-smartcontracts`, relative to your current working directory. The default path for smart contracts in this project is `client/tests/integration/smartcontracts`.
The generated WASM files will be saved in a generated directory `test-smartcontracts`, relative to your current working directory. The default path for smart contracts in this project is `wasm_samples`.

</details>

Expand Down Expand Up @@ -143,7 +143,7 @@ Iroha project mainly consists of the following crates:
* [`iroha_logger`](logger) uses `tracing` to provide logging facilities.
* [`iroha_macro`](macro) provides the convenience macros.
* [`iroha_p2p`](p2p) defines peer creation and handshake logic.
* [`iroha_default_executor`](default_executor) defines runtime validation logic.
* [`iroha_default_executor`](wasm_samples/default_executor) defines runtime validation logic.
* [`iroha_telemetry`](telemetry) is used for monitoring and analysis of telemetry data.
* [`iroha_version`](version) provides message versioning for non-simultaneous system updates.

Expand Down
2 changes: 1 addition & 1 deletion client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ irohad = { workspace = true }
iroha_wasm_builder = { workspace = true }
iroha_genesis = { workspace = true }
test_network = { workspace = true }
executor_custom_data_model = { path = "tests/integration/smartcontracts/executor_custom_data_model" }
executor_custom_data_model = { version = "=2.0.0-pre-rc.22.0", path = "../wasm_samples/executor_custom_data_model" }

tokio = { workspace = true, features = ["rt-multi-thread"] }
criterion = { workspace = true, features = ["html_reports"] }
Expand Down
6 changes: 4 additions & 2 deletions client/benches/torii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ fn query_requests(criterion: &mut Criterion) {
);

let rt = Runtime::test();
let executor = construct_executor("../default_executor").expect("Failed to construct executor");
let executor = construct_executor("../wasm_samples/default_executor")
.expect("Failed to construct executor");
let topology = vec![peer.id.clone()];
let genesis = GenesisBuilder::default()
.domain("wonderland".parse().expect("Valid"))
Expand Down Expand Up @@ -127,7 +128,8 @@ fn instruction_submits(criterion: &mut Criterion) {
get_key_pair(test_network::Signatory::Peer),
genesis_key_pair.public_key(),
);
let executor = construct_executor("../default_executor").expect("Failed to construct executor");
let executor = construct_executor("../wasm_samples/default_executor")
.expect("Failed to construct executor");
let genesis = GenesisBuilder::default()
.domain("wonderland".parse().expect("Valid"))
.account(configuration.common.key_pair.public_key().clone())
Expand Down
3 changes: 2 additions & 1 deletion client/examples/million_accounts_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ fn generate_genesis(
.finish_domain();
}

let executor = construct_executor("../default_executor").expect("Failed to construct executor");
let executor = construct_executor("../wasm_samples/default_executor")
.expect("Failed to construct executor");
builder.build_and_sign(executor, chain_id, genesis_key_pair, topology)
}

Expand Down
15 changes: 7 additions & 8 deletions client/examples/register_1000_triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ fn generate_genesis(
SmartContractParameter::Memory(NonZeroU64::MAX),
)));

let wasm = iroha_wasm_builder::Builder::new(
"client/tests/integration/smartcontracts/mint_rose_trigger",
)
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = iroha_wasm_builder::Builder::new("wasm_samples/mint_rose_trigger")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = WasmSmartContract::from_compiled(wasm);
let (account_id, _account_keypair) = gen_account_in("wonderland");

Expand All @@ -65,7 +63,8 @@ fn generate_genesis(
})
.fold(builder, GenesisBuilder::append_instruction);

let executor = construct_executor("default_executor").expect("Failed to construct executor");
let executor = construct_executor("../wasm_samples/default_executor")
.expect("Failed to construct executor");
Ok(builder.build_and_sign(executor, chain_id, genesis_key_pair, topology))
}

Expand Down
11 changes: 5 additions & 6 deletions client/tests/integration/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ fn mutlisig() -> Result<()> {
let account_id = ALICE_ID.clone();
let multisig_register_trigger_id = TriggerId::from_str("multisig_register")?;

let wasm =
iroha_wasm_builder::Builder::new("tests/integration/smartcontracts/multisig_register")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = iroha_wasm_builder::Builder::new("../wasm_samples/multisig_register")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = WasmSmartContract::from_compiled(wasm);

let trigger = Trigger::new(
Expand Down
25 changes: 11 additions & 14 deletions client/tests/integration/queries/smart_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ fn live_query_is_dropped_after_smart_contract_end() -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_140).start_with_runtime();
wait_for_genesis_committed(&[client.clone()], 0);

let wasm = iroha_wasm_builder::Builder::new(
"tests/integration/smartcontracts/query_assets_and_save_cursor",
)
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = iroha_wasm_builder::Builder::new("../wasm_samples/query_assets_and_save_cursor")
.show_output()
.build()?
.optimize()?
.into_bytes()?;

let transaction =
client.build_transaction(WasmSmartContract::from_compiled(wasm), Metadata::default());
Expand Down Expand Up @@ -49,13 +47,12 @@ fn smart_contract_can_filter_queries() -> Result<()> {
let (_rt, _peer, client) = <PeerBuilder>::new().with_port(11_260).start_with_runtime();
wait_for_genesis_committed(&[client.clone()], 0);

let wasm = iroha_wasm_builder::Builder::new(
"tests/integration/smartcontracts/smart_contract_can_filter_queries",
)
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm =
iroha_wasm_builder::Builder::new("../wasm_samples/smart_contract_can_filter_queries")
.show_output()
.build()?
.optimize()?
.into_bytes()?;

let transaction =
client.build_transaction(WasmSmartContract::from_compiled(wasm), Metadata::default());
Expand Down
33 changes: 15 additions & 18 deletions client/tests/integration/triggers/by_call_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,11 @@ fn trigger_in_genesis_using_base64() -> Result<()> {
// Building wasm trigger

info!("Building trigger");
let wasm =
iroha_wasm_builder::Builder::new("tests/integration/smartcontracts/mint_rose_trigger")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = iroha_wasm_builder::Builder::new("../wasm_samples/mint_rose_trigger")
.show_output()
.build()?
.optimize()?
.into_bytes()?;

info!("WASM size is {} bytes", wasm.len());

Expand Down Expand Up @@ -579,12 +578,11 @@ fn unregistering_one_of_two_triggers_with_identical_wasm_should_not_cause_origin
let first_trigger_id = TriggerId::from_str("mint_rose_1")?;
let second_trigger_id = TriggerId::from_str("mint_rose_2")?;

let wasm =
iroha_wasm_builder::Builder::new("tests/integration/smartcontracts/mint_rose_trigger")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = iroha_wasm_builder::Builder::new("../wasm_samples/mint_rose_trigger")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = WasmSmartContract::from_compiled(wasm);

let build_trigger = |trigger_id: TriggerId| {
Expand Down Expand Up @@ -661,12 +659,11 @@ fn call_execute_trigger_with_args() -> Result<()> {
let prev_value = get_asset_value(&mut test_client, asset_id.clone());

let trigger_id = TriggerId::from_str(TRIGGER_NAME)?;
let wasm =
iroha_wasm_builder::Builder::new("tests/integration/smartcontracts/mint_rose_trigger_args")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = iroha_wasm_builder::Builder::new("../wasm_samples/mint_rose_trigger_args")
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm = WasmSmartContract::from_compiled(wasm);
let trigger = Trigger::new(
trigger_id.clone(),
Expand Down
13 changes: 6 additions & 7 deletions client/tests/integration/triggers/time_trigger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,12 @@ fn mint_nft_for_every_user_every_1_sec() -> Result<()> {
const EXPECTED_COUNT: u64 = 4;

info!("Building trigger");
let wasm = iroha_wasm_builder::Builder::new(
"tests/integration/smartcontracts/create_nft_for_every_user_trigger",
)
.show_output()
.build()?
.optimize()?
.into_bytes()?;
let wasm =
iroha_wasm_builder::Builder::new("../wasm_samples/create_nft_for_every_user_trigger")
.show_output()
.build()?
.optimize()?
.into_bytes()?;

info!("WASM size is {} bytes", wasm.len());

Expand Down
38 changes: 9 additions & 29 deletions client/tests/integration/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ fn executor_upgrade_should_work() -> Result<()> {
.submit_transaction_blocking(&transfer_rose_tx)
.expect_err("Should fail");

upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_with_admin",
)?;
upgrade_executor(&client, "../wasm_samples/executor_with_admin")?;

// Check that admin can transfer alice's rose now
// Creating new transaction instead of cloning, because we need to update it's creation time
Expand Down Expand Up @@ -99,10 +96,7 @@ fn executor_upgrade_should_run_migration() -> Result<()> {
.is_ok_and(|permission| permission == can_unregister_domain)
}));

upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_with_custom_permission",
)?;
upgrade_executor(&client, "../wasm_samples/executor_with_custom_permission")?;

// Check that `CanUnregisterDomain` doesn't exist
let data_model = client.request(FindExecutorDataModel)?;
Expand Down Expand Up @@ -176,10 +170,7 @@ fn executor_upgrade_should_revoke_removed_permissions() -> Result<()> {
.is_ok_and(|permission| permission == can_unregister_domain)
}));

upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_remove_permission",
)?;
upgrade_executor(&client, "../wasm_samples/executor_remove_permission")?;

// Check that permission doesn't exist
assert!(!client
Expand Down Expand Up @@ -223,7 +214,7 @@ fn executor_custom_instructions_simple() -> Result<()> {

upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_custom_instructions_simple",
"../wasm_samples/executor_custom_instructions_simple",
)?;

let asset_definition_id: AssetDefinitionId = "rose#wonderland".parse().unwrap();
Expand Down Expand Up @@ -269,7 +260,7 @@ fn executor_custom_instructions_complex() -> Result<()> {
client.submit_blocking(executor_fuel_limit)?;
upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_custom_instructions_complex",
"../wasm_samples/executor_custom_instructions_complex",
)?;

// Give 6 roses to bob
Expand Down Expand Up @@ -334,11 +325,8 @@ fn migration_fail_should_not_cause_any_effects() {
"failed_migration_test_domain".parse().expect("Valid");
assert_domain_does_not_exist(&client, &domain_registered_in_migration);

let _err = upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_with_migration_fail",
)
.expect_err("Upgrade should fail due to migration failure");
let _err = upgrade_executor(&client, "../wasm_samples/executor_with_migration_fail")
.expect_err("Upgrade should fail due to migration failure");

// Checking that things registered in migration does not exist after failed migration
assert_domain_does_not_exist(&client, &domain_registered_in_migration);
Expand Down Expand Up @@ -369,11 +357,7 @@ fn migration_should_cause_upgrade_event() {
}
});

upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_with_custom_permission",
)
.unwrap();
upgrade_executor(&client, "../wasm_samples/executor_with_custom_permission").unwrap();

rt.block_on(async {
tokio::time::timeout(core::time::Duration::from_secs(60), task)
Expand All @@ -394,11 +378,7 @@ fn define_custom_parameter() -> Result<()> {
let create_domain = Register::domain(Domain::new(long_domain_name));
client.submit_blocking(create_domain)?;

upgrade_executor(
&client,
"tests/integration/smartcontracts/executor_with_custom_parameter",
)
.unwrap();
upgrade_executor(&client, "../wasm_samples/executor_with_custom_parameter").unwrap();

let too_long_domain_name = "1".repeat(2_usize.pow(5)).parse::<DomainId>()?;
let create_domain = Register::domain(Domain::new(too_long_domain_name));
Expand Down
31 changes: 0 additions & 31 deletions default_executor/Cargo.toml

This file was deleted.

Loading

0 comments on commit f92bbad

Please sign in to comment.