diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 315952660f5..6fffbb34d9b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -39,7 +39,7 @@ updates: - package-ecosystem: "cargo" target-branch: "main" - directory: "/default_executor/" + directory: "/wasm_samples/" schedule: interval: "daily" commit-message: diff --git a/.github/workflows/iroha2-dev-pr-static.yml b/.github/workflows/iroha2-dev-pr-static.yml index c987af863e1..7c87fb86cfb 100644 --- a/.github/workflows/iroha2-dev-pr-static.yml +++ b/.github/workflows/iroha2-dev-pr-static.yml @@ -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: diff --git a/Cargo.toml b/Cargo.toml index 1122017a6d9..a005cbbf058 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -253,6 +253,9 @@ members = [ "wasm_codec/derive", "wasm_builder", ] +exclude = [ + "wasm_samples", +] [profile.deploy] inherits = "release" diff --git a/README.md b/README.md index aa2da8a08f9..3ae649008ac 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -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. diff --git a/client/Cargo.toml b/client/Cargo.toml index fcfaff67283..e924eb65da4 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -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"] } diff --git a/client/benches/torii.rs b/client/benches/torii.rs index b5274d83b38..fc7ddaa109d 100644 --- a/client/benches/torii.rs +++ b/client/benches/torii.rs @@ -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")) @@ -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()) diff --git a/client/examples/million_accounts_genesis.rs b/client/examples/million_accounts_genesis.rs index 1ba83bb68b6..4c6f8622fac 100644 --- a/client/examples/million_accounts_genesis.rs +++ b/client/examples/million_accounts_genesis.rs @@ -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) } diff --git a/client/examples/register_1000_triggers.rs b/client/examples/register_1000_triggers.rs index cab69ee94e0..e1fbc844c67 100644 --- a/client/examples/register_1000_triggers.rs +++ b/client/examples/register_1000_triggers.rs @@ -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"); @@ -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)) } diff --git a/client/tests/integration/multisig.rs b/client/tests/integration/multisig.rs index c7fd8b0bb0c..e08cd7d97c1 100644 --- a/client/tests/integration/multisig.rs +++ b/client/tests/integration/multisig.rs @@ -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( diff --git a/client/tests/integration/queries/smart_contract.rs b/client/tests/integration/queries/smart_contract.rs index e41c4bd985a..0f063397ce8 100644 --- a/client/tests/integration/queries/smart_contract.rs +++ b/client/tests/integration/queries/smart_contract.rs @@ -12,13 +12,11 @@ fn live_query_is_dropped_after_smart_contract_end() -> Result<()> { let (_rt, _peer, client) = ::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()); @@ -49,13 +47,12 @@ fn smart_contract_can_filter_queries() -> Result<()> { let (_rt, _peer, client) = ::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()); diff --git a/client/tests/integration/triggers/by_call_trigger.rs b/client/tests/integration/triggers/by_call_trigger.rs index 293982cee0e..09e7a6c01aa 100644 --- a/client/tests/integration/triggers/by_call_trigger.rs +++ b/client/tests/integration/triggers/by_call_trigger.rs @@ -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()); @@ -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| { @@ -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(), diff --git a/client/tests/integration/triggers/time_trigger.rs b/client/tests/integration/triggers/time_trigger.rs index c77ca97eea9..8a9a48f1b33 100644 --- a/client/tests/integration/triggers/time_trigger.rs +++ b/client/tests/integration/triggers/time_trigger.rs @@ -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()); diff --git a/client/tests/integration/upgrade.rs b/client/tests/integration/upgrade.rs index 2ce4f3e85fa..7bc02f9ec58 100644 --- a/client/tests/integration/upgrade.rs +++ b/client/tests/integration/upgrade.rs @@ -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 @@ -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)?; @@ -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 @@ -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(); @@ -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 @@ -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); @@ -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) @@ -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::()?; let create_domain = Register::domain(Domain::new(too_long_domain_name)); diff --git a/default_executor/Cargo.toml b/default_executor/Cargo.toml deleted file mode 100644 index 7f915d58e76..00000000000 --- a/default_executor/Cargo.toml +++ /dev/null @@ -1,31 +0,0 @@ -[package] -name = "iroha_default_executor" - -edition = "2021" -version = "2.0.0-pre-rc.22.0" -# TODO: teams are being deprecated update the authors URL -authors = ["Iroha 2 team "] - -license = "Apache-2.0" - -[workspace] - -[lib] -crate-type = ['cdylib'] - -[profile.dev] -panic = "abort" - -[profile.release] -strip = "debuginfo" # Remove debugging info from the binary -panic = "abort" # Panics are transcribed to Traps when compiling for wasm anyways -lto = true # Link-time-optimization produces notable decrease in binary size -opt-level = "z" # Optimize for size vs speed with "s"/"z"(removes vectorization) -codegen-units = 1 # Further reduces binary size but increases compilation time - -[dependencies] -iroha_executor = { version = "2.0.0-pre-rc.22.0", path = "../smart_contract/executor", features = ["debug"] } -getrandom = { version = "0.2", features = ["custom"] } - -dlmalloc = { version = "0.2.6", features = ["global"] } -panic-halt = "0.2.0" diff --git a/default_executor/LICENSE b/default_executor/LICENSE deleted file mode 100644 index 857e425343c..00000000000 --- a/default_executor/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2017 Soramitsu LLC - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/default_executor/README.md b/default_executor/README.md deleted file mode 100644 index c8ca6099267..00000000000 --- a/default_executor/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# `iroha_default_executor` - -Use the [Wasm Builder CLI](../tools/wasm_builder_cli) in order to build it: - -```bash -cargo run --bin iroha_wasm_builder -- \ - build ./default_executor --optimize --out-file ./defaults/executor.wasm -``` diff --git a/hooks/pre-commit.sample b/hooks/pre-commit.sample index 4de7a10321d..59586491626 100755 --- a/hooks/pre-commit.sample +++ b/hooks/pre-commit.sample @@ -3,14 +3,14 @@ set -e # format checks cargo fmt --all -- --check -cd ./default_executor +cd ./wasm_samples/default_executor cargo fmt --all -- --check cd - -cd ./client/tests/integration/smartcontracts +cd ./wasm_samples cargo fmt --all -- --check cd - # update the default executor -cargo run --release --bin iroha_wasm_builder -- build ./default_executor --optimize --out-file ./defaults/executor.wasm +cargo run --release --bin iroha_wasm_builder -- build ./wasm_samples/default_executor --optimize --out-file ./defaults/executor.wasm # update the default genesis, assuming the transaction authority is `test_samples::SAMPLE_GENESIS_ACCOUNT_ID` cargo run --release --bin kagami -- genesis generate --executor-path-in-genesis ./executor.wasm --genesis-public-key ed01204164BF554923ECE1FD412D241036D863A6AE430476C898248B8237D77534CFC4 > ./defaults/genesis.json # update schema diff --git a/scripts/generate_wasm.sh b/scripts/generate_wasm.sh index d91f9a3ca8a..b7fcd2a0a22 100755 --- a/scripts/generate_wasm.sh +++ b/scripts/generate_wasm.sh @@ -1,7 +1,7 @@ #!/bin/sh # Default source directory -DEFAULT_SOURCE_DIR="client/tests/integration/smartcontracts" +DEFAULT_SOURCE_DIR="wasm_samples" # If no arguments are provided, use the default source directory if [ "$#" -eq 0 ]; then diff --git a/client/tests/integration/smartcontracts/.cargo/config.toml b/wasm_samples/.cargo/config.toml similarity index 100% rename from client/tests/integration/smartcontracts/.cargo/config.toml rename to wasm_samples/.cargo/config.toml diff --git a/client/tests/integration/smartcontracts/Cargo.toml b/wasm_samples/Cargo.toml similarity index 80% rename from client/tests/integration/smartcontracts/Cargo.toml rename to wasm_samples/Cargo.toml index 1cae1bf818f..804d5588c0e 100644 --- a/client/tests/integration/smartcontracts/Cargo.toml +++ b/wasm_samples/Cargo.toml @@ -9,6 +9,7 @@ license = "Apache-2.0" [workspace] resolver = "2" members = [ + "default_executor", "create_nft_for_every_user_trigger", "mint_rose_trigger", "mint_rose_trigger_args", @@ -39,12 +40,12 @@ codegen-units = 1 # Further reduces binary size but increases compilation time [workspace.dependencies] executor_custom_data_model = { path = "executor_custom_data_model" } -iroha_smart_contract = { version = "=2.0.0-pre-rc.22.0", path = "../../../../smart_contract", features = ["debug"] } -iroha_trigger = { version = "=2.0.0-pre-rc.22.0", path = "../../../../smart_contract/trigger", features = ["debug"] } -iroha_executor = { version = "=2.0.0-pre-rc.22.0", path = "../../../../smart_contract/executor", features = ["debug"] } -iroha_schema = { version = "=2.0.0-pre-rc.22.0", path = "../../../../schema" } -iroha_data_model = { version = "=2.0.0-pre-rc.22.0", path = "../../../../data_model", default-features = false } -iroha_executor_data_model = { version = "=2.0.0-pre-rc.22.0", path = "../../../../smart_contract/executor/data_model" } +iroha_smart_contract = { version = "=2.0.0-pre-rc.22.0", path = "../smart_contract", features = ["debug"] } +iroha_trigger = { version = "=2.0.0-pre-rc.22.0", path = "../smart_contract/trigger", features = ["debug"] } +iroha_executor = { version = "=2.0.0-pre-rc.22.0", path = "../smart_contract/executor", features = ["debug"] } +iroha_schema = { version = "=2.0.0-pre-rc.22.0", path = "../schema" } +iroha_data_model = { version = "=2.0.0-pre-rc.22.0", path = "../data_model", default-features = false } +iroha_executor_data_model = { version = "=2.0.0-pre-rc.22.0", path = "../smart_contract/executor/data_model" } parity-scale-codec = { version = "3.2.1", default-features = false } anyhow = { version = "1.0.71", default-features = false } diff --git a/client/tests/integration/smartcontracts/LICENSE b/wasm_samples/LICENSE similarity index 100% rename from client/tests/integration/smartcontracts/LICENSE rename to wasm_samples/LICENSE diff --git a/client/tests/integration/smartcontracts/README.md b/wasm_samples/README.md similarity index 100% rename from client/tests/integration/smartcontracts/README.md rename to wasm_samples/README.md diff --git a/client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/Cargo.toml b/wasm_samples/create_nft_for_every_user_trigger/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/Cargo.toml rename to wasm_samples/create_nft_for_every_user_trigger/Cargo.toml diff --git a/client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/src/lib.rs b/wasm_samples/create_nft_for_every_user_trigger/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/create_nft_for_every_user_trigger/src/lib.rs rename to wasm_samples/create_nft_for_every_user_trigger/src/lib.rs diff --git a/default_executor/.cargo/config.toml b/wasm_samples/default_executor/.cargo/config.toml similarity index 100% rename from default_executor/.cargo/config.toml rename to wasm_samples/default_executor/.cargo/config.toml diff --git a/wasm_samples/default_executor/Cargo.toml b/wasm_samples/default_executor/Cargo.toml new file mode 100644 index 00000000000..3efbe8de352 --- /dev/null +++ b/wasm_samples/default_executor/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "iroha_default_executor" + +edition.workspace = true +version.workspace = true +authors.workspace = true +license.workspace = true + +[lib] +crate-type = ['cdylib'] + +[dependencies] +iroha_executor.workspace = true + +panic-halt.workspace = true +dlmalloc.workspace = true +getrandom.workspace = true diff --git a/wasm_samples/default_executor/README.md b/wasm_samples/default_executor/README.md new file mode 100644 index 00000000000..d5571035d9e --- /dev/null +++ b/wasm_samples/default_executor/README.md @@ -0,0 +1,8 @@ +# `iroha_default_executor` + +Use the [Wasm Builder CLI](../../tools/wasm_builder_cli) in order to build it: + +```bash +cargo run --bin iroha_wasm_builder -- \ + build ./wasm_samples/default_executor --optimize --out-file ./defaults/executor.wasm +``` diff --git a/default_executor/src/lib.rs b/wasm_samples/default_executor/src/lib.rs similarity index 100% rename from default_executor/src/lib.rs rename to wasm_samples/default_executor/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/Cargo.toml b/wasm_samples/executor_custom_data_model/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_data_model/Cargo.toml rename to wasm_samples/executor_custom_data_model/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/complex_isi.rs b/wasm_samples/executor_custom_data_model/src/complex_isi.rs similarity index 99% rename from client/tests/integration/smartcontracts/executor_custom_data_model/src/complex_isi.rs rename to wasm_samples/executor_custom_data_model/src/complex_isi.rs index c025c27b022..2b353f7a150 100644 --- a/client/tests/integration/smartcontracts/executor_custom_data_model/src/complex_isi.rs +++ b/wasm_samples/executor_custom_data_model/src/complex_isi.rs @@ -1,6 +1,6 @@ //! Example of custom expression system. //! Only few expressions are implemented to show proof-of-concept. -//! See `smartcontracts/executor_custom_instructions_complex`. +//! See `wasm_samples/executor_custom_instructions_complex`. //! This is simplified version of expression system from Iroha v2.0.0-pre-rc.20 pub use evaluate::*; diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/lib.rs b/wasm_samples/executor_custom_data_model/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_data_model/src/lib.rs rename to wasm_samples/executor_custom_data_model/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/mint_rose_args.rs b/wasm_samples/executor_custom_data_model/src/mint_rose_args.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_data_model/src/mint_rose_args.rs rename to wasm_samples/executor_custom_data_model/src/mint_rose_args.rs diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/multisig.rs b/wasm_samples/executor_custom_data_model/src/multisig.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_data_model/src/multisig.rs rename to wasm_samples/executor_custom_data_model/src/multisig.rs diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/parameters.rs b/wasm_samples/executor_custom_data_model/src/parameters.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_data_model/src/parameters.rs rename to wasm_samples/executor_custom_data_model/src/parameters.rs diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/permissions.rs b/wasm_samples/executor_custom_data_model/src/permissions.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_data_model/src/permissions.rs rename to wasm_samples/executor_custom_data_model/src/permissions.rs diff --git a/client/tests/integration/smartcontracts/executor_custom_data_model/src/simple_isi.rs b/wasm_samples/executor_custom_data_model/src/simple_isi.rs similarity index 96% rename from client/tests/integration/smartcontracts/executor_custom_data_model/src/simple_isi.rs rename to wasm_samples/executor_custom_data_model/src/simple_isi.rs index e82e5b0a97f..e89200fee18 100644 --- a/client/tests/integration/smartcontracts/executor_custom_data_model/src/simple_isi.rs +++ b/wasm_samples/executor_custom_data_model/src/simple_isi.rs @@ -1,5 +1,5 @@ //! Example of one custom instruction. -//! See `smartcontracts/executor_custom_instructions_simple`. +//! See `wasm_samples/executor_custom_instructions_simple`. use alloc::{format, string::String, vec::Vec}; diff --git a/client/tests/integration/smartcontracts/executor_custom_instructions_complex/Cargo.toml b/wasm_samples/executor_custom_instructions_complex/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_instructions_complex/Cargo.toml rename to wasm_samples/executor_custom_instructions_complex/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_custom_instructions_complex/src/lib.rs b/wasm_samples/executor_custom_instructions_complex/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_instructions_complex/src/lib.rs rename to wasm_samples/executor_custom_instructions_complex/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_custom_instructions_simple/Cargo.toml b/wasm_samples/executor_custom_instructions_simple/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_instructions_simple/Cargo.toml rename to wasm_samples/executor_custom_instructions_simple/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_custom_instructions_simple/src/lib.rs b/wasm_samples/executor_custom_instructions_simple/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_custom_instructions_simple/src/lib.rs rename to wasm_samples/executor_custom_instructions_simple/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_remove_permission/Cargo.toml b/wasm_samples/executor_remove_permission/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_remove_permission/Cargo.toml rename to wasm_samples/executor_remove_permission/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_remove_permission/src/lib.rs b/wasm_samples/executor_remove_permission/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_remove_permission/src/lib.rs rename to wasm_samples/executor_remove_permission/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_with_admin/Cargo.toml b/wasm_samples/executor_with_admin/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_admin/Cargo.toml rename to wasm_samples/executor_with_admin/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_with_admin/src/lib.rs b/wasm_samples/executor_with_admin/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_admin/src/lib.rs rename to wasm_samples/executor_with_admin/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_with_custom_parameter/Cargo.toml b/wasm_samples/executor_with_custom_parameter/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_custom_parameter/Cargo.toml rename to wasm_samples/executor_with_custom_parameter/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_with_custom_parameter/src/lib.rs b/wasm_samples/executor_with_custom_parameter/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_custom_parameter/src/lib.rs rename to wasm_samples/executor_with_custom_parameter/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_with_custom_permission/Cargo.toml b/wasm_samples/executor_with_custom_permission/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_custom_permission/Cargo.toml rename to wasm_samples/executor_with_custom_permission/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_with_custom_permission/src/lib.rs b/wasm_samples/executor_with_custom_permission/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_custom_permission/src/lib.rs rename to wasm_samples/executor_with_custom_permission/src/lib.rs diff --git a/client/tests/integration/smartcontracts/executor_with_migration_fail/Cargo.toml b/wasm_samples/executor_with_migration_fail/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_migration_fail/Cargo.toml rename to wasm_samples/executor_with_migration_fail/Cargo.toml diff --git a/client/tests/integration/smartcontracts/executor_with_migration_fail/src/lib.rs b/wasm_samples/executor_with_migration_fail/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/executor_with_migration_fail/src/lib.rs rename to wasm_samples/executor_with_migration_fail/src/lib.rs diff --git a/client/tests/integration/smartcontracts/mint_rose_trigger/Cargo.toml b/wasm_samples/mint_rose_trigger/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/mint_rose_trigger/Cargo.toml rename to wasm_samples/mint_rose_trigger/Cargo.toml diff --git a/client/tests/integration/smartcontracts/mint_rose_trigger/src/lib.rs b/wasm_samples/mint_rose_trigger/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/mint_rose_trigger/src/lib.rs rename to wasm_samples/mint_rose_trigger/src/lib.rs diff --git a/client/tests/integration/smartcontracts/mint_rose_trigger_args/Cargo.toml b/wasm_samples/mint_rose_trigger_args/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/mint_rose_trigger_args/Cargo.toml rename to wasm_samples/mint_rose_trigger_args/Cargo.toml diff --git a/client/tests/integration/smartcontracts/mint_rose_trigger_args/src/lib.rs b/wasm_samples/mint_rose_trigger_args/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/mint_rose_trigger_args/src/lib.rs rename to wasm_samples/mint_rose_trigger_args/src/lib.rs diff --git a/client/tests/integration/smartcontracts/multisig/Cargo.toml b/wasm_samples/multisig/Cargo.toml similarity index 94% rename from client/tests/integration/smartcontracts/multisig/Cargo.toml rename to wasm_samples/multisig/Cargo.toml index 1e4d03811a7..e55300353cf 100644 --- a/client/tests/integration/smartcontracts/multisig/Cargo.toml +++ b/wasm_samples/multisig/Cargo.toml @@ -22,4 +22,4 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, default-features = false } [build-dependencies] -iroha_wasm_builder = { version = "=2.0.0-pre-rc.22.0", path = "../../../../../wasm_builder" } +iroha_wasm_builder = { version = "=2.0.0-pre-rc.22.0", path = "../../wasm_builder" } diff --git a/client/tests/integration/smartcontracts/multisig/src/lib.rs b/wasm_samples/multisig/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/multisig/src/lib.rs rename to wasm_samples/multisig/src/lib.rs diff --git a/client/tests/integration/smartcontracts/multisig_register/Cargo.toml b/wasm_samples/multisig_register/Cargo.toml similarity index 95% rename from client/tests/integration/smartcontracts/multisig_register/Cargo.toml rename to wasm_samples/multisig_register/Cargo.toml index fba9b75bc4b..b4e774073c9 100644 --- a/client/tests/integration/smartcontracts/multisig_register/Cargo.toml +++ b/wasm_samples/multisig_register/Cargo.toml @@ -23,4 +23,4 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, default-features = false } [build-dependencies] -iroha_wasm_builder = { version = "=2.0.0-pre-rc.22.0", path = "../../../../../wasm_builder" } +iroha_wasm_builder = { version = "=2.0.0-pre-rc.22.0", path = "../../wasm_builder" } diff --git a/client/tests/integration/smartcontracts/multisig_register/build.rs b/wasm_samples/multisig_register/build.rs similarity index 100% rename from client/tests/integration/smartcontracts/multisig_register/build.rs rename to wasm_samples/multisig_register/build.rs diff --git a/client/tests/integration/smartcontracts/multisig_register/src/lib.rs b/wasm_samples/multisig_register/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/multisig_register/src/lib.rs rename to wasm_samples/multisig_register/src/lib.rs diff --git a/client/tests/integration/smartcontracts/query_assets_and_save_cursor/Cargo.toml b/wasm_samples/query_assets_and_save_cursor/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/query_assets_and_save_cursor/Cargo.toml rename to wasm_samples/query_assets_and_save_cursor/Cargo.toml diff --git a/client/tests/integration/smartcontracts/query_assets_and_save_cursor/src/lib.rs b/wasm_samples/query_assets_and_save_cursor/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/query_assets_and_save_cursor/src/lib.rs rename to wasm_samples/query_assets_and_save_cursor/src/lib.rs diff --git a/client/tests/integration/smartcontracts/smart_contract_can_filter_queries/Cargo.toml b/wasm_samples/smart_contract_can_filter_queries/Cargo.toml similarity index 100% rename from client/tests/integration/smartcontracts/smart_contract_can_filter_queries/Cargo.toml rename to wasm_samples/smart_contract_can_filter_queries/Cargo.toml diff --git a/client/tests/integration/smartcontracts/smart_contract_can_filter_queries/src/lib.rs b/wasm_samples/smart_contract_can_filter_queries/src/lib.rs similarity index 100% rename from client/tests/integration/smartcontracts/smart_contract_can_filter_queries/src/lib.rs rename to wasm_samples/smart_contract_can_filter_queries/src/lib.rs