From 8f93b3bd31aaa55c3069041c7355521bfb6e97cd Mon Sep 17 00:00:00 2001 From: sczembor Date: Thu, 7 Mar 2024 14:11:16 +0100 Subject: [PATCH 1/6] update dependencies; update rust toolchain --- contract-v1/Cargo.toml | 6 +++--- contract-v1/src/main.rs | 12 ++++++------ contract-v2/Cargo.toml | 4 ++-- contract-v2/src/main.rs | 18 +++++++++--------- counter-call/Cargo.toml | 4 ++-- rust-toolchain | 2 +- tests/Cargo.toml | 6 +++--- tests/src/integration_tests.rs | 20 +++++++++++++------- 8 files changed, 39 insertions(+), 33 deletions(-) diff --git a/contract-v1/Cargo.toml b/contract-v1/Cargo.toml index 2c95ce1..bc9f67e 100644 --- a/contract-v1/Cargo.toml +++ b/contract-v1/Cargo.toml @@ -5,8 +5,8 @@ authors = ["CasperLabs "] edition = "2021" [dependencies] -casper-contract = "1.4.4" -casper-types = "1.5.0" +casper-contract = "4.0.0" +casper-types = "4.0.1" [[bin]] name = "counter-v1" @@ -15,4 +15,4 @@ bench = false doctest = false test = false -[profile.release] #reduces Wasm size \ No newline at end of file +[profile.release] #reduces Wasm size diff --git a/contract-v1/src/main.rs b/contract-v1/src/main.rs index 0d92d79..6765a9b 100644 --- a/contract-v1/src/main.rs +++ b/contract-v1/src/main.rs @@ -23,20 +23,20 @@ use casper_types::{ CLType, CLValue, URef, }; -// Constants for the keys pointing to values stored in the account's named keys. +/// Constants for the keys pointing to values stored in the account's named keys. const CONTRACT_PACKAGE_NAME: &str = "counter_package_name"; const CONTRACT_ACCESS_UREF: &str = "counter_access_uref"; -// Creating constants for the various contract entry points. +/// Creating constants for the various contract entry points. const ENTRY_POINT_COUNTER_INC: &str = "counter_inc"; const ENTRY_POINT_COUNTER_GET: &str = "counter_get"; -// Constants for the keys pointing to values stored in the contract's named keys. +/// Constants for the keys pointing to values stored in the contract's named keys. const CONTRACT_VERSION_KEY: &str = "version"; const CONTRACT_KEY: &str = "counter"; const COUNT_KEY: &str = "count"; -// Entry point that increments the count value by 1. +/// Entry point that increments the count value by 1. #[no_mangle] pub extern "C" fn counter_inc() { let uref: URef = runtime::get_key(COUNT_KEY) @@ -46,7 +46,7 @@ pub extern "C" fn counter_inc() { storage::add(uref, 1); // Increment the count by 1. } -// Entry point that returns the count value. +/// Entry point that returns the count value. #[no_mangle] pub extern "C" fn counter_get() { let uref: URef = runtime::get_key(COUNT_KEY) @@ -60,7 +60,7 @@ pub extern "C" fn counter_get() { runtime::ret(typed_result); // Return the count value. } -// Entry point that executes automatically when a caller installs the contract. +/// Entry point that executes automatically when a caller installs the contract. #[no_mangle] pub extern "C" fn call() { // Initialize the count to 0, locally. diff --git a/contract-v2/Cargo.toml b/contract-v2/Cargo.toml index e84a115..5fba803 100644 --- a/contract-v2/Cargo.toml +++ b/contract-v2/Cargo.toml @@ -4,8 +4,8 @@ version = "1.0.0" edition = "2021" [dependencies] -casper-contract = "1.4.4" -casper-types = "1.5.0" +casper-contract = "4.0.0" +casper-types = "4.0.1" [[bin]] name = "counter-v2" diff --git a/contract-v2/src/main.rs b/contract-v2/src/main.rs index c2c38a6..4e76182 100644 --- a/contract-v2/src/main.rs +++ b/contract-v2/src/main.rs @@ -24,21 +24,21 @@ use casper_types::{ CLType, CLValue, URef, }; -// Creating constants for the various contract entry points. +/// Creating constants for the various contract entry points. const ENTRY_POINT_COUNTER_INC: &str = "counter_inc"; const ENTRY_POINT_COUNTER_GET: &str = "counter_get"; const ENTRY_POINT_COUNTER_DECREMENT: &str = "counter_decrement"; -// Constants for the keys pointing to values stored in the contract's named keys. +/// Constants for the keys pointing to values stored in the contract's named keys. const CONTRACT_VERSION_KEY: &str = "version"; const CONTRACT_KEY: &str = "counter"; const COUNT_KEY: &str = "count"; -// Constants for the keys pointing to values stored in the account's named keys. +/// Constants for the keys pointing to values stored in the account's named keys. const CONTRACT_PACKAGE_NAME: &str = "counter_package_name"; const CONTRACT_ACCESS_UREF: &str = "counter_access_uref"; -// Entry point that increments the count value by 1. +/// Entry point that increments the count value by 1. #[no_mangle] pub extern "C" fn counter_inc() { let uref: URef = runtime::get_key(COUNT_KEY) @@ -48,7 +48,7 @@ pub extern "C" fn counter_inc() { storage::add(uref, 1); // Increment the count by 1. } -// Entry point that returns the count value. +/// Entry point that returns the count value. #[no_mangle] pub extern "C" fn counter_get() { let uref: URef = runtime::get_key(COUNT_KEY) @@ -62,7 +62,7 @@ pub extern "C" fn counter_get() { runtime::ret(typed_result); // Return the count value. } -// Entry point that decrements the count value by 1. +/// Entry point that decrements the count value by 1. #[no_mangle] pub extern "C" fn counter_decrement() { let uref: URef = runtime::get_key(COUNT_KEY) @@ -72,7 +72,7 @@ pub extern "C" fn counter_decrement() { storage::add(uref, -1); // Decrement the count. } -// Helper function that installs the counter contract on chain. +/// Helper function that installs the counter contract on chain. fn install_counter() { // Initialize the count to 0, locally. let count_start = storage::new_uref(0_i32); @@ -121,7 +121,7 @@ fn install_counter() { runtime::put_key(CONTRACT_KEY, stored_contract_hash.into()); } -// Helper function that upgrades the contract package to a new version. +/// Helper function that upgrades the contract package to a new version. fn upgrade_counter() { // In this version, we will not add any named keys. // The named keys from the previous version should still be available. @@ -178,7 +178,7 @@ fn upgrade_counter() { runtime::put_key(CONTRACT_KEY, stored_contract_hash.into()); } -// Entry point that executes automatically when a caller installs the contract. +/// Entry point that executes automatically when a caller installs the contract. #[no_mangle] pub extern "C" fn call() { match runtime::get_key(CONTRACT_ACCESS_UREF) { diff --git a/counter-call/Cargo.toml b/counter-call/Cargo.toml index 39ad909..281295a 100644 --- a/counter-call/Cargo.toml +++ b/counter-call/Cargo.toml @@ -5,8 +5,8 @@ authors = ["CasperLabs "] edition = "2021" [dependencies] -casper-contract = "1.4.4" -casper-types = "1.5.0" +casper-contract = "4.0.0" +casper-types = "4.0.1" [[bin]] name = "counter-call" diff --git a/rust-toolchain b/rust-toolchain index f828db8..f9e5e5e 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2022-03-17 +nightly-2023-03-25 diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 73a2a48..217d05a 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -5,9 +5,9 @@ authors = ["CasperLabs "] edition = "2021" [dependencies] -casper-engine-test-support = { version = "2.2.0", features = ["test-support"] } -casper-execution-engine = "2.0.0" -casper-types = "1.5.0" +casper-engine-test-support = { version = "7.0.1", features = ["test-support"] } +casper-execution-engine = "7.0.1" +casper-types = "4.0.1" [[bin]] name = "integration-tests" diff --git a/tests/src/integration_tests.rs b/tests/src/integration_tests.rs index 9d58698..3580e7c 100644 --- a/tests/src/integration_tests.rs +++ b/tests/src/integration_tests.rs @@ -3,7 +3,7 @@ mod tests { // Outlining aspects of the Casper test support crate to include. use casper_engine_test_support::{ ExecuteRequestBuilder, InMemoryWasmTestBuilder, DEFAULT_ACCOUNT_ADDR, - DEFAULT_RUN_GENESIS_REQUEST, + PRODUCTION_RUN_GENESIS_REQUEST, }; // Custom Casper types that will be used within this test. use casper_types::{runtime_args, ContractHash, RuntimeArgs}; @@ -19,7 +19,6 @@ mod tests { const ENTRY_POINT_COUNTER_DECREMENT: &str = "counter_decrement"; // Entry point to decrement the count value const ENTRY_POINT_COUNTER_INC: &str = "counter_inc"; // Entry point to increment the count value - #[test] /// Install version 1 of the counter contract and check its available entry points. /// Only the increment entry point should be available. /// The decrement call should fail, because that entry point should not be in this version. @@ -32,9 +31,12 @@ mod tests { /// - Verify that the count value is now 1. /// - Call the decrement entry point, which should fail. /// - Ensure the count value was not decremented and is still 1. + #[test] fn install_version1_and_check_entry_points() { let mut builder = InMemoryWasmTestBuilder::default(); - builder.run_genesis(&*DEFAULT_RUN_GENESIS_REQUEST).commit(); + builder + .run_genesis(&PRODUCTION_RUN_GENESIS_REQUEST) + .commit(); // Install the contract. let contract_v1_installation_request = ExecuteRequestBuilder::standard( @@ -153,7 +155,6 @@ mod tests { assert_eq!(current_count, 1); } - #[test] /// Install version 1 of the counter contract and check its functionality. /// Then, upgrade the contract by installing a second Wasm for version 2. /// Check the functionality of the second version. @@ -171,9 +172,12 @@ mod tests { /// - Verify the new contract version is 2. /// - Increment the counter to check that counter_inc is still working after the upgrade. Count is now 2. /// - Call the decrement entry point and verify that the count is now 1. + #[test] fn install_version1_and_upgrade_to_version2() { let mut builder = InMemoryWasmTestBuilder::default(); - builder.run_genesis(&*DEFAULT_RUN_GENESIS_REQUEST).commit(); + builder + .run_genesis(&PRODUCTION_RUN_GENESIS_REQUEST) + .commit(); // Install the first version of the contract. let contract_v1_installation_request = ExecuteRequestBuilder::standard( @@ -381,7 +385,6 @@ mod tests { assert_eq!(decremented_count, 1); } - #[test] /// Install version 2 of the counter contract without having version 1 already on chain. /// Test summary: /// - Install the counter-v2.wasm contract. @@ -392,9 +395,12 @@ mod tests { /// - Verify that the count value is now 1. /// - Call the decrement entry point, which should succeed. /// - Verify that the count is 0. + #[test] fn install_version2_directly_without_version1() { let mut builder = InMemoryWasmTestBuilder::default(); - builder.run_genesis(&*DEFAULT_RUN_GENESIS_REQUEST).commit(); + builder + .run_genesis(&PRODUCTION_RUN_GENESIS_REQUEST) + .commit(); // Install the contract. let contract_v2_installation_request = ExecuteRequestBuilder::standard( From b4a5f78359add235021e2e5db1b758b5ff55ac0e Mon Sep 17 00:00:00 2001 From: sczembor Date: Thu, 7 Mar 2024 14:41:16 +0100 Subject: [PATCH 2/6] update workflow --- .github/workflows/ci-casper-rust-contract.yml | 28 +++++++++---------- .github/workflows/nightly-scheduled-test.yml | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-casper-rust-contract.yml b/.github/workflows/ci-casper-rust-contract.yml index f8322d9..a7b2e7f 100644 --- a/.github/workflows/ci-casper-rust-contract.yml +++ b/.github/workflows/ci-casper-rust-contract.yml @@ -2,14 +2,14 @@ name: ci-casper-rust-contract on: push: - branches: [ master ] + branches: [master] paths-ignore: - - '**.md' + - "**.md" pull_request: - branches: [ master ] + branches: [master] paths-ignore: - - '**.md' + - "**.md" jobs: build: @@ -18,13 +18,13 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: rustfmt, clippy - # Needed for gcc install - - run: sudo apt update && sudo apt install -y build-essential - - run: make prepare - - run: make check-lint - - run: make test + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v2 + with: + profile: minimal + components: rustfmt, clippy + # Needed for gcc install + - run: sudo apt update && sudo apt install -y build-essential + - run: make prepare + - run: make check-lint + - run: make test diff --git a/.github/workflows/nightly-scheduled-test.yml b/.github/workflows/nightly-scheduled-test.yml index bdadfe1..8d85862 100644 --- a/.github/workflows/nightly-scheduled-test.yml +++ b/.github/workflows/nightly-scheduled-test.yml @@ -14,8 +14,8 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v2 with: profile: minimal components: rustfmt, clippy From d4312bb846fc543e01f00bcfe18cc5a7b5857d91 Mon Sep 17 00:00:00 2001 From: sczembor Date: Thu, 7 Mar 2024 14:46:11 +0100 Subject: [PATCH 3/6] update workflow --- .github/workflows/ci-casper-rust-contract.yml | 3 ++- .github/workflows/nightly-scheduled-test.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-casper-rust-contract.yml b/.github/workflows/ci-casper-rust-contract.yml index a7b2e7f..dda4791 100644 --- a/.github/workflows/ci-casper-rust-contract.yml +++ b/.github/workflows/ci-casper-rust-contract.yml @@ -19,10 +19,11 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v2 + - uses: actions-rs/toolchain@v1 with: profile: minimal components: rustfmt, clippy + toolchain: nightly # Needed for gcc install - run: sudo apt update && sudo apt install -y build-essential - run: make prepare diff --git a/.github/workflows/nightly-scheduled-test.yml b/.github/workflows/nightly-scheduled-test.yml index 8d85862..c6a0b0a 100644 --- a/.github/workflows/nightly-scheduled-test.yml +++ b/.github/workflows/nightly-scheduled-test.yml @@ -15,10 +15,11 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v2 + - uses: actions-rs/toolchain@v1 with: profile: minimal components: rustfmt, clippy + toolchain: nightly # Needed for gcc install - run: sudo apt update && sudo apt install -y build-essential - run: make prepare From ad8a25732f98fb0c404baf1016595eadc6b34dbf Mon Sep 17 00:00:00 2001 From: sczembor Date: Thu, 7 Mar 2024 14:48:28 +0100 Subject: [PATCH 4/6] update workflow --- .github/workflows/ci-casper-rust-contract.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-casper-rust-contract.yml b/.github/workflows/ci-casper-rust-contract.yml index dda4791..dda55ab 100644 --- a/.github/workflows/ci-casper-rust-contract.yml +++ b/.github/workflows/ci-casper-rust-contract.yml @@ -23,7 +23,7 @@ jobs: with: profile: minimal components: rustfmt, clippy - toolchain: nightly + toolchain: nightly-2023-03-25 # Needed for gcc install - run: sudo apt update && sudo apt install -y build-essential - run: make prepare From 2f62a334237b8e5258f528ceb7eb2600cbfe0d0b Mon Sep 17 00:00:00 2001 From: sczembor Date: Thu, 7 Mar 2024 15:01:07 +0100 Subject: [PATCH 5/6] update workflow --- .github/workflows/ci-casper-rust-contract.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-casper-rust-contract.yml b/.github/workflows/ci-casper-rust-contract.yml index dda55ab..cdb4867 100644 --- a/.github/workflows/ci-casper-rust-contract.yml +++ b/.github/workflows/ci-casper-rust-contract.yml @@ -25,7 +25,6 @@ jobs: components: rustfmt, clippy toolchain: nightly-2023-03-25 # Needed for gcc install - - run: sudo apt update && sudo apt install -y build-essential - run: make prepare - run: make check-lint - run: make test From f8c34b2bcbe52f67b7f3a73a5f425bb9c9bf4b37 Mon Sep 17 00:00:00 2001 From: sczembor Date: Thu, 7 Mar 2024 15:32:43 +0100 Subject: [PATCH 6/6] downgrade the dependecnies --- .github/workflows/ci-casper-rust-contract.yml | 4 ++-- .github/workflows/nightly-scheduled-test.yml | 3 +-- contract-v1/Cargo.toml | 4 ++-- contract-v2/Cargo.toml | 4 ++-- counter-call/Cargo.toml | 4 ++-- tests/Cargo.toml | 6 +++--- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci-casper-rust-contract.yml b/.github/workflows/ci-casper-rust-contract.yml index cdb4867..d1e821e 100644 --- a/.github/workflows/ci-casper-rust-contract.yml +++ b/.github/workflows/ci-casper-rust-contract.yml @@ -18,13 +18,13 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: profile: minimal components: rustfmt, clippy - toolchain: nightly-2023-03-25 # Needed for gcc install + - run: sudo apt update && sudo apt install -y build-essential - run: make prepare - run: make check-lint - run: make test diff --git a/.github/workflows/nightly-scheduled-test.yml b/.github/workflows/nightly-scheduled-test.yml index c6a0b0a..bdadfe1 100644 --- a/.github/workflows/nightly-scheduled-test.yml +++ b/.github/workflows/nightly-scheduled-test.yml @@ -14,12 +14,11 @@ jobs: os: [ubuntu-20.04, ubuntu-22.04] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 with: profile: minimal components: rustfmt, clippy - toolchain: nightly # Needed for gcc install - run: sudo apt update && sudo apt install -y build-essential - run: make prepare diff --git a/contract-v1/Cargo.toml b/contract-v1/Cargo.toml index bc9f67e..e190734 100644 --- a/contract-v1/Cargo.toml +++ b/contract-v1/Cargo.toml @@ -5,8 +5,8 @@ authors = ["CasperLabs "] edition = "2021" [dependencies] -casper-contract = "4.0.0" -casper-types = "4.0.1" +casper-contract = "3.0.0" +casper-types = "3.0.0" [[bin]] name = "counter-v1" diff --git a/contract-v2/Cargo.toml b/contract-v2/Cargo.toml index 5fba803..047e0c1 100644 --- a/contract-v2/Cargo.toml +++ b/contract-v2/Cargo.toml @@ -4,8 +4,8 @@ version = "1.0.0" edition = "2021" [dependencies] -casper-contract = "4.0.0" -casper-types = "4.0.1" +casper-contract = "3.0.0" +casper-types = "3.0.0" [[bin]] name = "counter-v2" diff --git a/counter-call/Cargo.toml b/counter-call/Cargo.toml index 281295a..917a996 100644 --- a/counter-call/Cargo.toml +++ b/counter-call/Cargo.toml @@ -5,8 +5,8 @@ authors = ["CasperLabs "] edition = "2021" [dependencies] -casper-contract = "4.0.0" -casper-types = "4.0.1" +casper-contract = "3.0.0" +casper-types = "3.0.0" [[bin]] name = "counter-call" diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 217d05a..c023817 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -5,9 +5,9 @@ authors = ["CasperLabs "] edition = "2021" [dependencies] -casper-engine-test-support = { version = "7.0.1", features = ["test-support"] } -casper-execution-engine = "7.0.1" -casper-types = "4.0.1" +casper-engine-test-support = { version = "5.0.0", features = ["test-support"] } +casper-execution-engine = "5.0.0" +casper-types = "3.0.0" [[bin]] name = "integration-tests"