From fababeb4f50bf6adf17bd365c721a3aef3b53338 Mon Sep 17 00:00:00 2001 From: Dmitry Novikov Date: Fri, 20 Oct 2023 13:52:33 +0400 Subject: [PATCH] feat!(runtime): Add field `keep_alive` to gear extrinsics defining existence requirement (#3425) --- gclient/src/api/calls.rs | 4 + gsdk/src/metadata/generated.rs | 6 + gsdk/src/metadata/impls.rs | 8 + gsdk/src/signer/calls.rs | 4 + node/authorship/src/tests.rs | 1 + pallets/gear-bank/src/lib.rs | 32 +- pallets/gear-bank/src/tests.rs | 168 ++++--- pallets/gear-debug/src/tests/mod.rs | 13 + pallets/gear-scheduler/src/tests.rs | 2 +- pallets/gear-voucher/src/lib.rs | 2 + pallets/gear/src/benchmarking/mod.rs | 28 +- pallets/gear/src/benchmarking/tasks.rs | 10 + .../benchmarking/tests/syscalls_integrity.rs | 10 + pallets/gear/src/internal.rs | 4 +- pallets/gear/src/lib.rs | 74 ++- pallets/gear/src/manager/journal.rs | 1 + pallets/gear/src/runtime_api.rs | 37 +- pallets/gear/src/tests.rs | 441 ++++++++++++++++-- pallets/payment/src/tests.rs | 4 + runtime/vara/src/integration_tests.rs | 3 + utils/runtime-fuzzer/src/lib.rs | 3 + 21 files changed, 688 insertions(+), 167 deletions(-) diff --git a/gclient/src/api/calls.rs b/gclient/src/api/calls.rs index a8733d8d375..c31533e4901 100644 --- a/gclient/src/api/calls.rs +++ b/gclient/src/api/calls.rs @@ -204,6 +204,7 @@ impl GearApi { init_payload: payload.as_ref().to_vec(), gas_limit, value, + keep_alive: false, }) }) .collect(); @@ -765,6 +766,7 @@ impl GearApi { payload: payload.as_ref().to_vec(), gas_limit, value, + keep_alive: false, }) }) .collect(); @@ -898,6 +900,7 @@ impl GearApi { payload: payload.as_ref().to_vec(), gas_limit, value, + keep_alive: false, }) }) .collect(); @@ -1127,6 +1130,7 @@ impl GearApi { init_payload: payload.as_ref().to_vec(), gas_limit, value, + keep_alive: false, }) }) .collect(); diff --git a/gsdk/src/metadata/generated.rs b/gsdk/src/metadata/generated.rs index c18c5739afa..681bb7f4122 100644 --- a/gsdk/src/metadata/generated.rs +++ b/gsdk/src/metadata/generated.rs @@ -2450,6 +2450,7 @@ pub mod runtime_types { init_payload: ::std::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, + keep_alive: ::core::primitive::bool, }, #[codec(index = 2)] #[doc = "Creates program via `code_id` from storage."] @@ -2474,6 +2475,7 @@ pub mod runtime_types { init_payload: ::std::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, + keep_alive: ::core::primitive::bool, }, #[codec(index = 3)] #[doc = "Sends a message to a program or to another account."] @@ -2498,6 +2500,7 @@ pub mod runtime_types { payload: ::std::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, + keep_alive: ::core::primitive::bool, }, #[codec(index = 4)] #[doc = "Send reply on message in `Mailbox`."] @@ -2518,6 +2521,7 @@ pub mod runtime_types { payload: ::std::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: ::core::primitive::u128, + keep_alive: ::core::primitive::bool, }, #[codec(index = 5)] #[doc = "Claim value from message in `Mailbox`."] @@ -3343,6 +3347,7 @@ pub mod runtime_types { payload: ::std::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: _0, + keep_alive: ::core::primitive::bool, }, #[codec(index = 1)] SendReply { @@ -3350,6 +3355,7 @@ pub mod runtime_types { payload: ::std::vec::Vec<::core::primitive::u8>, gas_limit: ::core::primitive::u64, value: _0, + keep_alive: ::core::primitive::bool, }, } } diff --git a/gsdk/src/metadata/impls.rs b/gsdk/src/metadata/impls.rs index f695436da7d..34a3a4d637f 100644 --- a/gsdk/src/metadata/impls.rs +++ b/gsdk/src/metadata/impls.rs @@ -188,6 +188,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { init_payload, gas_limit, value, + keep_alive, } => Value::named_variant( "upload_program", [ @@ -196,6 +197,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { ("init_payload", Value::from_bytes(init_payload)), ("gas_limit", Value::u128(gas_limit as u128)), ("value", Value::u128(value as u128)), + ("keep_alive", Value::bool(keep_alive)), ], ), GearCall::create_program { @@ -204,6 +206,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { init_payload, gas_limit, value, + keep_alive, } => Value::named_variant( "create_program", [ @@ -212,6 +215,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { ("init_payload", Value::from_bytes(init_payload)), ("gas_limit", Value::u128(gas_limit as u128)), ("value", Value::u128(value as u128)), + ("keep_alive", Value::bool(keep_alive)), ], ), GearCall::send_message { @@ -219,6 +223,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { payload, gas_limit, value, + keep_alive, } => Value::named_variant( "send_message", [ @@ -226,6 +231,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { ("payload", Value::from_bytes(payload)), ("gas_limit", Value::u128(gas_limit as u128)), ("value", Value::u128(value as u128)), + ("keep_alive", Value::bool(keep_alive)), ], ), GearCall::send_reply { @@ -233,6 +239,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { payload, gas_limit, value, + keep_alive, } => Value::named_variant( "send_reply", [ @@ -240,6 +247,7 @@ fn gear_call_to_scale_value(call: GearCall) -> Value { ("payload", Value::from_bytes(payload)), ("gas_limit", Value::u128(gas_limit as u128)), ("value", Value::u128(value as u128)), + ("keep_alive", Value::bool(keep_alive)), ], ), GearCall::claim_value { message_id } => Value::named_variant( diff --git a/gsdk/src/signer/calls.rs b/gsdk/src/signer/calls.rs index 061cdf0caad..de69b87e4f7 100644 --- a/gsdk/src/signer/calls.rs +++ b/gsdk/src/signer/calls.rs @@ -74,6 +74,7 @@ impl SignerCalls { Value::from_bytes(payload), Value::u128(gas_limit as u128), Value::u128(value), + Value::bool(false), ], ) .await @@ -102,6 +103,7 @@ impl SignerCalls { Value::from_bytes(payload), Value::u128(gas_limit as u128), Value::u128(value), + Value::bool(false), ], ) .await @@ -123,6 +125,7 @@ impl SignerCalls { Value::from_bytes(payload), Value::u128(gas_limit as u128), Value::u128(value), + Value::bool(false), ], ) .await @@ -153,6 +156,7 @@ impl SignerCalls { Value::from_bytes(payload), Value::u128(gas_limit as u128), Value::u128(value), + Value::bool(false), ], ) .await diff --git a/node/authorship/src/tests.rs b/node/authorship/src/tests.rs index 8a403f9ec22..d058f329bfa 100644 --- a/node/authorship/src/tests.rs +++ b/node/authorship/src/tests.rs @@ -96,6 +96,7 @@ fn checked_extrinsics(n: u32, signer: AccountId, nonce: &mut u32) -> Vec Pallet { /// Transfers value from `account_id` to bank address. - fn deposit(account_id: &AccountIdOf, value: BalanceOf) -> Result<(), Error> { + fn deposit( + account_id: &AccountIdOf, + value: BalanceOf, + keep_alive: bool, + ) -> Result<(), Error> { let bank_address = T::BankAddress::get(); ensure!( @@ -166,14 +170,15 @@ pub mod pallet { Error::InsufficientDeposit ); + let existence_requirement = if keep_alive { + ExistenceRequirement::KeepAlive + } else { + ExistenceRequirement::AllowDeath + }; + // Check on zero value is inside `pallet_balances` implementation. - CurrencyOf::::transfer( - account_id, - &bank_address, - value, - ExistenceRequirement::AllowDeath, - ) - .map_err(|_| Error::::InsufficientBalance) + CurrencyOf::::transfer(account_id, &bank_address, value, existence_requirement) + .map_err(|_| Error::::InsufficientBalance) } /// Ensures that bank account is able to transfer requested value. @@ -233,14 +238,18 @@ pub mod pallet { Self::withdraw(&block_author, value) } - pub fn deposit_gas(account_id: &AccountIdOf, amount: u64) -> Result<(), Error> { + pub fn deposit_gas( + account_id: &AccountIdOf, + amount: u64, + keep_alive: bool, + ) -> Result<(), Error> { if amount.is_zero() { return Ok(()); } let value = GasMultiplierOf::::get().gas_to_value(amount); - Self::deposit(account_id, value)?; + Self::deposit(account_id, value, keep_alive)?; Bank::::mutate(account_id, |details| { let details = details.get_or_insert_with(Default::default); @@ -327,12 +336,13 @@ pub mod pallet { pub fn deposit_value( account_id: &AccountIdOf, value: BalanceOf, + keep_alive: bool, ) -> Result<(), Error> { if value.is_zero() { return Ok(()); } - Self::deposit(account_id, value)?; + Self::deposit(account_id, value, keep_alive)?; Bank::::mutate(account_id, |details| { let details = details.get_or_insert_with(Default::default); diff --git a/pallets/gear-bank/src/tests.rs b/pallets/gear-bank/src/tests.rs index bc98568ea63..1379d8746d7 100644 --- a/pallets/gear-bank/src/tests.rs +++ b/pallets/gear-bank/src/tests.rs @@ -21,6 +21,26 @@ use frame_support::{assert_noop, assert_ok}; use sp_runtime::traits::Zero; use utils::*; +#[test] +fn keep_alive_fails_deposits_on_low_balance() { + new_test_ext().execute_with(|| { + const ALICE_TO_DUST_BALANCE: Balance = EXISTENTIAL_DEPOSIT - VALUE_PER_GAS; + + const VALUE: Balance = ALICE_BALANCE - ALICE_TO_DUST_BALANCE; + const GAS_AMOUNT: u64 = (VALUE / VALUE_PER_GAS) as u64; + + assert_noop!( + GearBank::deposit_gas(&ALICE, GAS_AMOUNT, true), + Error::::InsufficientBalance, + ); + + assert_noop!( + GearBank::deposit_value(&ALICE, VALUE, true), + Error::::InsufficientBalance, + ); + }) +} + #[test] fn deposit_gas_different_users() { new_test_ext().execute_with(|| { @@ -30,7 +50,7 @@ fn deposit_gas_different_users() { assert_balance(&BOB, BOB_BALANCE); const ALICE_GAS: u64 = 1_234_567; - assert_ok!(GearBank::deposit_gas(&ALICE, ALICE_GAS)); + assert_ok!(GearBank::deposit_gas(&ALICE, ALICE_GAS, false)); assert_bank_balance(ALICE_GAS, 0); @@ -38,7 +58,7 @@ fn deposit_gas_different_users() { assert_gas_value(&ALICE, ALICE_GAS, 0); const BOB_GAS: u64 = 56_789; - assert_ok!(GearBank::deposit_gas(&BOB, BOB_GAS)); + assert_ok!(GearBank::deposit_gas(&BOB, BOB_GAS, false)); assert_bank_balance(ALICE_GAS + BOB_GAS, 0); @@ -54,7 +74,7 @@ fn deposit_gas_different_users() { fn deposit_gas_single_user() { new_test_ext().execute_with(|| { const GAS_1: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_1)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_1, false)); assert_bank_balance(GAS_1, 0); @@ -62,7 +82,7 @@ fn deposit_gas_single_user() { assert_gas_value(&ALICE, GAS_1, 0); const GAS_2: u64 = 67_890; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_2)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_2, false)); assert_bank_balance(GAS_1 + GAS_2, 0); @@ -81,7 +101,7 @@ fn deposit_gas_user_account_deleted() { assert_eq!(gas_price(GAS_AMOUNT), BALANCE_DIFF); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_bank_balance(GAS_AMOUNT, 0); @@ -95,9 +115,9 @@ fn deposit_gas_zero() { new_test_ext().execute_with(|| { let h = frame_support::storage_root(frame_support::StateVersion::V1); - assert_ok!(GearBank::deposit_gas(&ALICE, 0)); + assert_ok!(GearBank::deposit_gas(&ALICE, 0, false)); - assert_ok!(GearBank::deposit_gas(&Zero::zero(), 0)); + assert_ok!(GearBank::deposit_gas(&Zero::zero(), 0, false)); // No-op operation assertion. assert_eq!( @@ -116,7 +136,7 @@ fn deposit_gas_insufficient_balance() { assert!(gas_price(GAS_AMOUNT) > Balances::free_balance(ALICE)); assert_noop!( - GearBank::deposit_gas(&ALICE, GAS_AMOUNT), + GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false), Error::::InsufficientBalance ); }) @@ -137,7 +157,7 @@ fn deposit_gas_insufficient_deposit() { )); assert_noop!( - GearBank::deposit_gas(&ALICE, GAS_AMOUNT), + GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false), Error::::InsufficientDeposit ); }) @@ -147,10 +167,10 @@ fn deposit_gas_insufficient_deposit() { fn withdraw_gas_different_users() { new_test_ext().execute_with(|| { const ALICE_GAS: u64 = 1_234_567; - assert_ok!(GearBank::deposit_gas(&ALICE, ALICE_GAS)); + assert_ok!(GearBank::deposit_gas(&ALICE, ALICE_GAS, false)); const BOB_GAS: u64 = 56_789; - assert_ok!(GearBank::deposit_gas(&BOB, BOB_GAS)); + assert_ok!(GearBank::deposit_gas(&BOB, BOB_GAS, false)); const ALICE_WITHDRAW: u64 = ALICE_GAS - 123_456; assert_ok!(GearBank::withdraw_gas(&ALICE, ALICE_WITHDRAW, mult())); @@ -180,7 +200,7 @@ fn withdraw_gas_different_users() { fn withdraw_gas_single_user() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); const WITHDRAW_1: u64 = GAS_AMOUNT - 23_456; assert_ok!(GearBank::withdraw_gas(&ALICE, WITHDRAW_1, mult())); @@ -204,7 +224,7 @@ fn withdraw_gas_single_user() { fn withdraw_gas_all_balance() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(GearBank::withdraw_gas(&ALICE, GAS_AMOUNT, mult())); @@ -226,7 +246,7 @@ fn withdraw_gas_all_balance_user_account_deleted() { assert_eq!(gas_price(GAS_AMOUNT), BALANCE_DIFF); assert!(BALANCE_DIFF > CurrencyOf::::minimum_balance()); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(GearBank::withdraw_gas(&ALICE, GAS_AMOUNT, mult())); assert_bank_balance(0, 0); @@ -243,7 +263,7 @@ fn withdraw_gas_small_amount() { assert!(gas_price(GAS_AMOUNT) < CurrencyOf::::minimum_balance()); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(GearBank::withdraw_gas(&ALICE, GAS_AMOUNT, mult())); @@ -263,7 +283,7 @@ fn withdraw_gas_small_amount_user_account_deleted() { const GAS_AMOUNT: u64 = (GAS_VALUE_AMOUNT / VALUE_PER_GAS) as u64; assert_eq!(gas_price(GAS_AMOUNT), GAS_VALUE_AMOUNT); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(ALICE), @@ -307,7 +327,7 @@ fn withdraw_gas_insufficient_bank_balance() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(BANK_ADDRESS), @@ -327,14 +347,14 @@ fn withdraw_gas_insufficient_gas_balance() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_noop!( GearBank::withdraw_gas(&ALICE, GAS_AMOUNT + 1, mult()), Error::::InsufficientGasBalance ); - assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT, false)); assert_noop!( GearBank::withdraw_gas(&ALICE, GAS_AMOUNT + 1, mult()), @@ -358,7 +378,7 @@ fn withdraw_gas_insufficient_inexistent_gas_balance() { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT, false)); assert_noop!( GearBank::withdraw_gas(&ALICE, 1, mult()), @@ -376,10 +396,10 @@ fn withdraw_gas_insufficient_inexistent_gas_balance() { fn spend_gas_different_users() { new_test_ext().execute_with(|| { const ALICE_GAS: u64 = 1_234_567; - assert_ok!(GearBank::deposit_gas(&ALICE, ALICE_GAS)); + assert_ok!(GearBank::deposit_gas(&ALICE, ALICE_GAS, false)); const BOB_GAS: u64 = 56_789; - assert_ok!(GearBank::deposit_gas(&BOB, BOB_GAS)); + assert_ok!(GearBank::deposit_gas(&BOB, BOB_GAS, false)); const ALICE_BURN: u64 = ALICE_GAS - 123_456; assert_ok!(GearBank::spend_gas(&ALICE, ALICE_BURN, mult())); @@ -413,7 +433,7 @@ fn spend_gas_different_users() { fn spend_gas_single_user() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); const BURN_1: u64 = GAS_AMOUNT - 23_456; assert_ok!(GearBank::spend_gas(&ALICE, BURN_1, mult())); @@ -441,7 +461,7 @@ fn spend_gas_single_user() { fn spend_gas_all_balance() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(GearBank::spend_gas(&ALICE, GAS_AMOUNT, mult())); @@ -461,7 +481,7 @@ fn spend_gas_all_balance_validator_account_deleted() { assert!(gas_price(GAS_AMOUNT) >= CurrencyOf::::minimum_balance()); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(BLOCK_AUTHOR), @@ -487,7 +507,7 @@ fn spend_gas_small_amount() { assert!(gas_price(GAS_AMOUNT) < CurrencyOf::::minimum_balance()); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(GearBank::spend_gas(&ALICE, GAS_AMOUNT, mult())); @@ -509,7 +529,7 @@ fn spend_gas_small_amount_validator_account_deleted() { const GAS_AMOUNT: u64 = (GAS_VALUE_AMOUNT / VALUE_PER_GAS) as u64; assert_eq!(gas_price(GAS_AMOUNT), GAS_VALUE_AMOUNT); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(BLOCK_AUTHOR), @@ -555,7 +575,7 @@ fn spend_gas_insufficient_bank_balance() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(BANK_ADDRESS), @@ -577,14 +597,14 @@ fn spend_gas_insufficient_gas_balance() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_noop!( GearBank::spend_gas(&ALICE, GAS_AMOUNT + 1, mult()), Error::::InsufficientGasBalance ); - assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT, false)); assert_noop!( GearBank::spend_gas(&ALICE, GAS_AMOUNT + 1, mult()), @@ -607,7 +627,7 @@ fn spend_gas_insufficient_inexistent_gas_balance() { ); const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&BOB, GAS_AMOUNT, false)); assert_noop!( GearBank::spend_gas(&ALICE, 1, mult()), @@ -625,7 +645,7 @@ fn spend_gas_insufficient_inexistent_gas_balance() { fn deposit_value_different_users() { new_test_ext().execute_with(|| { const ALICE_VALUE: Balance = 1_234_567_000; - assert_ok!(GearBank::deposit_value(&ALICE, ALICE_VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, ALICE_VALUE, false)); assert_bank_balance(0, ALICE_VALUE); @@ -633,7 +653,7 @@ fn deposit_value_different_users() { assert_gas_value(&ALICE, 0, ALICE_VALUE); const BOB_VALUE: Balance = 56_789_000; - assert_ok!(GearBank::deposit_value(&BOB, BOB_VALUE)); + assert_ok!(GearBank::deposit_value(&BOB, BOB_VALUE, false)); assert_bank_balance(0, ALICE_VALUE + BOB_VALUE); @@ -649,7 +669,7 @@ fn deposit_value_different_users() { fn deposit_value_single_user() { new_test_ext().execute_with(|| { const VALUE_1: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE_1)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE_1, false)); assert_bank_balance(0, VALUE_1); @@ -657,7 +677,7 @@ fn deposit_value_single_user() { assert_gas_value(&ALICE, 0, VALUE_1); const VALUE_2: Balance = 67_890_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE_2)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE_2, false)); assert_bank_balance(0, VALUE_1 + VALUE_2); @@ -673,7 +693,7 @@ fn deposit_value_user_account_deleted() { const VALUE: Balance = ALICE_BALANCE - ALICE_TO_DUST_BALANCE; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_bank_balance(0, VALUE); @@ -687,9 +707,9 @@ fn deposit_value_zero() { new_test_ext().execute_with(|| { let h = frame_support::storage_root(frame_support::StateVersion::V1); - assert_ok!(GearBank::deposit_value(&ALICE, 0)); + assert_ok!(GearBank::deposit_value(&ALICE, 0, false)); - assert_ok!(GearBank::deposit_value(&Zero::zero(), 0)); + assert_ok!(GearBank::deposit_value(&Zero::zero(), 0, false)); // No-op operation assertion. assert_eq!( @@ -708,7 +728,7 @@ fn deposit_value_insufficient_balance() { assert!(VALUE > Balances::free_balance(ALICE)); assert_noop!( - GearBank::deposit_value(&ALICE, VALUE), + GearBank::deposit_value(&ALICE, VALUE, false), Error::::InsufficientBalance ); }) @@ -727,7 +747,7 @@ fn deposit_value_insufficient_deposit() { )); assert_noop!( - GearBank::deposit_value(&ALICE, VALUE), + GearBank::deposit_value(&ALICE, VALUE, false), Error::::InsufficientDeposit ); }) @@ -737,10 +757,10 @@ fn deposit_value_insufficient_deposit() { fn withdraw_value_different_users() { new_test_ext().execute_with(|| { const ALICE_VALUE: Balance = 1_234_567_000; - assert_ok!(GearBank::deposit_value(&ALICE, ALICE_VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, ALICE_VALUE, false)); const BOB_VALUE: Balance = 56_789_000; - assert_ok!(GearBank::deposit_value(&BOB, BOB_VALUE)); + assert_ok!(GearBank::deposit_value(&BOB, BOB_VALUE, false)); const ALICE_WITHDRAW: Balance = ALICE_VALUE - 123_456_000; assert_ok!(GearBank::withdraw_value(&ALICE, ALICE_WITHDRAW)); @@ -770,7 +790,7 @@ fn withdraw_value_different_users() { fn withdraw_value_single_user() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); const WITHDRAW_1: Balance = VALUE - 23_456_000; assert_ok!(GearBank::withdraw_value(&ALICE, WITHDRAW_1)); @@ -794,7 +814,7 @@ fn withdraw_value_single_user() { fn withdraw_value_all_balance() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(GearBank::withdraw_value(&ALICE, VALUE)); @@ -812,7 +832,7 @@ fn withdraw_value_all_balance_user_account_deleted() { const VALUE: Balance = ALICE_BALANCE - ALICE_TO_DUST_BALANCE; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(GearBank::withdraw_value(&ALICE, VALUE)); assert_bank_balance(0, 0); @@ -827,7 +847,7 @@ fn withdraw_value_small_amount() { new_test_ext().execute_with(|| { const VALUE: u128 = EXISTENTIAL_DEPOSIT - 1; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(GearBank::withdraw_value(&ALICE, VALUE)); @@ -843,7 +863,7 @@ fn withdraw_value_small_amount_user_account_deleted() { new_test_ext().execute_with(|| { const VALUE: Balance = EXISTENTIAL_DEPOSIT - 1; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(ALICE), @@ -887,7 +907,7 @@ fn withdraw_value_insufficient_bank_balance() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(BANK_ADDRESS), @@ -907,14 +927,14 @@ fn withdraw_value_insufficient_value_balance() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_noop!( GearBank::withdraw_value(&ALICE, VALUE + 1), Error::::InsufficientValueBalance ); - assert_ok!(GearBank::deposit_value(&BOB, VALUE)); + assert_ok!(GearBank::deposit_value(&BOB, VALUE, false)); assert_noop!( GearBank::withdraw_value(&ALICE, VALUE + 1), @@ -938,7 +958,7 @@ fn withdraw_value_insufficient_inexistent_value_balance() { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&BOB, VALUE)); + assert_ok!(GearBank::deposit_value(&BOB, VALUE, false)); assert_noop!( GearBank::withdraw_value(&ALICE, 1), @@ -956,10 +976,10 @@ fn withdraw_value_insufficient_inexistent_value_balance() { fn transfer_value_different_users() { new_test_ext().execute_with(|| { const ALICE_VALUE: Balance = 1_234_567_000; - assert_ok!(GearBank::deposit_value(&ALICE, ALICE_VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, ALICE_VALUE, false)); const BOB_VALUE: Balance = 56_789_000; - assert_ok!(GearBank::deposit_value(&BOB, BOB_VALUE)); + assert_ok!(GearBank::deposit_value(&BOB, BOB_VALUE, false)); const ALICE_TRANSFER: Balance = ALICE_VALUE - 123_456_000; assert_ok!(GearBank::transfer_value(&ALICE, &CHARLIE, ALICE_TRANSFER)); @@ -993,7 +1013,7 @@ fn transfer_value_different_users() { fn transfer_value_single_user() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); const TRANSFER_1: Balance = VALUE - 23_456_000; assert_ok!(GearBank::transfer_value(&ALICE, &CHARLIE, TRANSFER_1)); @@ -1022,7 +1042,7 @@ fn transfer_value_single_user() { fn transfer_value_self() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); const TRANSFER_1: Balance = VALUE - 23_456_000; assert_ok!(GearBank::transfer_value(&ALICE, &ALICE, TRANSFER_1)); @@ -1046,7 +1066,7 @@ fn transfer_value_self() { fn transfer_balance_all_balance() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(GearBank::transfer_value(&ALICE, &CHARLIE, VALUE)); @@ -1064,7 +1084,7 @@ fn transfer_value_all_balance_destination_account_deleted() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(CHARLIE), @@ -1088,7 +1108,7 @@ fn transfer_value_all_balance_self_account_deleted() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(ALICE), @@ -1110,7 +1130,7 @@ fn transfer_value_small_amount() { new_test_ext().execute_with(|| { const VALUE: Balance = EXISTENTIAL_DEPOSIT - 1; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(GearBank::transfer_value(&ALICE, &CHARLIE, VALUE)); @@ -1127,7 +1147,7 @@ fn transfer_value_small_amount() { fn transfer_value_small_amount_destination_account_deleted() { new_test_ext().execute_with(|| { const VALUE: Balance = EXISTENTIAL_DEPOSIT - 1; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(CHARLIE), @@ -1153,7 +1173,7 @@ fn transfer_value_small_amount_destination_account_deleted() { fn transfer_value_small_amount_self_account_deleted() { new_test_ext().execute_with(|| { const VALUE: Balance = EXISTENTIAL_DEPOSIT - 1; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(ALICE), @@ -1200,7 +1220,7 @@ fn transfer_value_insufficient_bank_balance() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_ok!(Balances::transfer_all( RuntimeOrigin::signed(BANK_ADDRESS), @@ -1227,7 +1247,7 @@ fn transfer_value_insufficient_value_balance() { new_test_ext().execute_with(|| { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_noop!( GearBank::transfer_value(&ALICE, &CHARLIE, VALUE + 1), @@ -1239,7 +1259,7 @@ fn transfer_value_insufficient_value_balance() { Error::::InsufficientValueBalance ); - assert_ok!(GearBank::deposit_value(&BOB, VALUE)); + assert_ok!(GearBank::deposit_value(&BOB, VALUE, false)); assert_noop!( GearBank::transfer_value(&ALICE, &CHARLIE, VALUE + 1), @@ -1278,7 +1298,7 @@ fn transfer_value_insufficient_inexistent_value_balance() { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&BOB, VALUE)); + assert_ok!(GearBank::deposit_value(&BOB, VALUE, false)); assert_noop!( GearBank::transfer_value(&ALICE, &ALICE, 1), @@ -1309,13 +1329,13 @@ fn empty_accounts_deleted() { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert!(GearBank::account(ALICE).is_some()); assert_ok!(GearBank::withdraw_gas(&ALICE, GAS_AMOUNT, mult())); assert!(GearBank::account(ALICE).is_none()); - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert!(GearBank::account(ALICE).is_some()); assert_ok!(GearBank::spend_gas(&ALICE, GAS_AMOUNT, mult())); @@ -1323,19 +1343,19 @@ fn empty_accounts_deleted() { const VALUE: Balance = 123_456_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert!(GearBank::account(ALICE).is_some()); assert_ok!(GearBank::withdraw_value(&ALICE, VALUE)); assert!(GearBank::account(ALICE).is_none()); - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert!(GearBank::account(ALICE).is_some()); assert_ok!(GearBank::transfer_value(&ALICE, &CHARLIE, VALUE)); assert!(GearBank::account(ALICE).is_none()); - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert!(GearBank::account(ALICE).is_some()); assert_ok!(GearBank::transfer_value(&ALICE, &ALICE, VALUE)); @@ -1348,7 +1368,7 @@ fn empty_zero_accounts_deleted() { new_test_ext().execute_with(|| { assert!(GearBank::account(::zero()).is_none()); - assert_ok!(GearBank::deposit_gas(&Zero::zero(), 0)); + assert_ok!(GearBank::deposit_gas(&Zero::zero(), 0, false)); assert!(GearBank::account(::zero()).is_none()); assert_ok!(GearBank::withdraw_gas(&Zero::zero(), 0, mult())); @@ -1357,7 +1377,7 @@ fn empty_zero_accounts_deleted() { assert_ok!(GearBank::spend_gas(&Zero::zero(), 0, mult())); assert!(GearBank::account(::zero()).is_none()); - assert_ok!(GearBank::deposit_value(&Zero::zero(), 0)); + assert_ok!(GearBank::deposit_value(&Zero::zero(), 0, false)); assert!(GearBank::account(::zero()).is_none()); assert_ok!(GearBank::withdraw_value(&Zero::zero(), 0)); @@ -1375,7 +1395,7 @@ fn empty_zero_accounts_deleted() { fn empty_composite_accounts_deleted() { new_test_ext().execute_with(|| { const GAS_AMOUNT: u64 = 123_456; - assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT)); + assert_ok!(GearBank::deposit_gas(&ALICE, GAS_AMOUNT, false)); assert_bank_balance(GAS_AMOUNT, 0); @@ -1384,7 +1404,7 @@ fn empty_composite_accounts_deleted() { assert_gas_value(&ALICE, GAS_AMOUNT, 0); const VALUE: Balance = 234_567_000; - assert_ok!(GearBank::deposit_value(&ALICE, VALUE)); + assert_ok!(GearBank::deposit_value(&ALICE, VALUE, false)); assert_bank_balance(GAS_AMOUNT, VALUE); diff --git a/pallets/gear-debug/src/tests/mod.rs b/pallets/gear-debug/src/tests/mod.rs index 8777f6584d8..9017791a2e0 100644 --- a/pallets/gear-debug/src/tests/mod.rs +++ b/pallets/gear-debug/src/tests/mod.rs @@ -57,6 +57,7 @@ fn vec() { vec![], 10_000_000_000, 0, + false, )); let vec_id = get_last_program_id(); @@ -76,6 +77,7 @@ fn vec() { 131072i32.encode(), 10_000_000_000, 0, + false, )); run_to_next_block(None); @@ -153,6 +155,7 @@ fn debug_mode_works() { Vec::new(), 10_000_000_000_u64, 0_u128, + false, ) .expect("Failed to submit program"); @@ -187,6 +190,7 @@ fn debug_mode_works() { Vec::new(), 10_000_000_000_u64, 0_u128, + false, ) .expect("Failed to submit program"); @@ -225,6 +229,7 @@ fn debug_mode_works() { vec![], 1_000_000_000_u64, 0_u128, + false, ) .expect("Failed to send message"); @@ -236,6 +241,7 @@ fn debug_mode_works() { vec![], 1_000_000_000_u64, 0_u128, + false, ) .expect("Failed to send message"); @@ -520,6 +526,7 @@ fn check_not_allocated_pages() { Vec::new(), 5_000_000_000_u64, 0_u128, + false, )); // Enable debug mode. @@ -562,6 +569,7 @@ fn check_not_allocated_pages() { vec![], 5_000_000_000_u64, 0_u128, + false, )); run_to_block(3, None); @@ -746,6 +754,7 @@ fn check_changed_pages_in_storage() { Vec::new(), 5_000_000_000_u64, 0_u128, + false, )); // Enable debug mode. @@ -794,6 +803,7 @@ fn check_changed_pages_in_storage() { vec![], 5_000_000_000_u64, 0_u128, + false, )); run_to_block(3, None); @@ -875,6 +885,7 @@ fn check_gear_stack_end() { Vec::new(), 5_000_000_000_u64, 0_u128, + false, )); // Enable debug mode. @@ -932,6 +943,7 @@ fn disabled_program_rent() { pay_rent_id.into_bytes().to_vec(), 20_000_000_000, program_value, + false, )); run_to_next_block(None); @@ -953,6 +965,7 @@ fn disabled_program_rent() { .encode(), 20_000_000_000, 0, + false, )); run_to_next_block(None); diff --git a/pallets/gear-scheduler/src/tests.rs b/pallets/gear-scheduler/src/tests.rs index 58a0285d026..14f9143f61f 100644 --- a/pallets/gear-scheduler/src/tests.rs +++ b/pallets/gear-scheduler/src/tests.rs @@ -73,7 +73,7 @@ fn populate_wl_from( TaskPoolOf::::add(bn, ScheduledTask::RemoveFromWaitlist(pid, mid)) .expect("Failed to insert task"); WaitlistOf::::insert(dispatch, bn).expect("Failed to insert to waitlist"); - GearBank::deposit_gas(&src, DEFAULT_GAS).expect("Cannot reserve gas"); + GearBank::deposit_gas(&src, DEFAULT_GAS, false).expect("Cannot reserve gas"); let multiplier = ::GasMultiplier::get(); GasHandlerOf::::create(src, multiplier, mid, DEFAULT_GAS) diff --git a/pallets/gear-voucher/src/lib.rs b/pallets/gear-voucher/src/lib.rs index 81c71ea41ac..c3257765888 100644 --- a/pallets/gear-voucher/src/lib.rs +++ b/pallets/gear-voucher/src/lib.rs @@ -216,12 +216,14 @@ pub enum PrepaidCall { payload: Vec, gas_limit: u64, value: Balance, + keep_alive: bool, }, SendReply { reply_to_id: MessageId, payload: Vec, gas_limit: u64, value: Balance, + keep_alive: bool, }, } diff --git a/pallets/gear/src/benchmarking/mod.rs b/pallets/gear/src/benchmarking/mod.rs index 5c1283fd9dd..1fedb330dbb 100644 --- a/pallets/gear/src/benchmarking/mod.rs +++ b/pallets/gear/src/benchmarking/mod.rs @@ -475,8 +475,8 @@ benchmarks! { let value = 10000u32.into(); let multiplier = ::GasMultiplier::get(); GasHandlerOf::::create(program_id.clone(), multiplier, original_message_id, gas_limit).expect("Failed to create gas handler"); - GearBank::::deposit_gas(&program_id, gas_limit).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); - GearBank::::deposit_value(&program_id, value).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); + GearBank::::deposit_gas(&program_id, gas_limit, true).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); + GearBank::::deposit_value(&program_id, value, true).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); MailboxOf::::insert(gear_core::message::StoredMessage::new( original_message_id, ProgramId::from_origin(program_id.into_origin()), @@ -502,7 +502,7 @@ benchmarks! { let code = benchmarking::generate_wasm2(16.into()).unwrap(); let salt = vec![]; let program_id = ProgramId::generate_from_user(CodeId::generate(&code), &salt); - Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into()).expect("submit program failed"); + Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into(), false).expect("submit program failed"); let block_count = 1_000u32.into(); @@ -522,7 +522,7 @@ benchmarks! { let code = benchmarking::generate_wasm2(16.into()).unwrap(); let salt = vec![]; let program_id = ProgramId::generate_from_user(CodeId::generate(&code), &salt); - Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into()).expect("submit program failed"); + Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into(), false).expect("submit program failed"); init_block::(None); @@ -547,7 +547,7 @@ benchmarks! { let code = benchmarking::generate_wasm2(16.into()).unwrap(); let salt = vec![]; let program_id = ProgramId::generate_from_user(CodeId::generate(&code), &salt); - Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into()).expect("submit program failed"); + Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into(), false,).expect("submit program failed"); init_block::(None); @@ -583,7 +583,7 @@ benchmarks! { let code = benchmarking::generate_wasm2(0.into()).unwrap(); let salt = vec![]; let program_id = ProgramId::generate_from_user(CodeId::generate(&code), &salt); - Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into()).expect("submit program failed"); + Gear::::upload_program(RawOrigin::Signed(caller.clone()).into(), code, salt, b"init_payload".to_vec(), 10_000_000_000, 0u32.into(), false,).expect("submit program failed"); init_block::(None); @@ -657,7 +657,7 @@ benchmarks! { let origin = RawOrigin::Signed(caller); init_block::(None); - }: _(origin, code_id, salt, vec![], 100_000_000_u64, value) + }: _(origin, code_id, salt, vec![], 100_000_000_u64, value, false) verify { assert!(::CodeStorage::exists(code_id)); } @@ -685,7 +685,7 @@ benchmarks! { let origin = RawOrigin::Signed(caller); init_block::(None); - }: _(origin, code, salt, vec![], 100_000_000_u64, value) + }: _(origin, code, salt, vec![], 100_000_000_u64, value, false) verify { assert!(matches!(QueueOf::::dequeue(), Ok(Some(_)))); } @@ -701,7 +701,7 @@ benchmarks! { let payload = vec![0_u8; p as usize]; init_block::(None); - }: _(RawOrigin::Signed(caller), program_id, payload, 100_000_000_u64, minimum_balance) + }: _(RawOrigin::Signed(caller), program_id, payload, 100_000_000_u64, minimum_balance, false) verify { assert!(matches!(QueueOf::::dequeue(), Ok(Some(_)))); } @@ -720,8 +720,8 @@ benchmarks! { let value = (p % 2).into(); let multiplier = ::GasMultiplier::get(); GasHandlerOf::::create(program_id.clone(), multiplier, original_message_id, gas_limit).expect("Failed to create gas handler"); - GearBank::::deposit_gas(&program_id, gas_limit).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); - GearBank::::deposit_value(&program_id, value).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); + GearBank::::deposit_gas(&program_id, gas_limit, true).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); + GearBank::::deposit_value(&program_id, value, true).unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); MailboxOf::::insert(gear_core::message::StoredMessage::new( original_message_id, ProgramId::from_origin(program_id.into_origin()), @@ -733,7 +733,7 @@ benchmarks! { let payload = vec![0_u8; p as usize]; init_block::(None); - }: _(RawOrigin::Signed(caller.clone()), original_message_id, payload, 100_000_000_u64, minimum_balance) + }: _(RawOrigin::Signed(caller.clone()), original_message_id, payload, 100_000_000_u64, minimum_balance, false) verify { assert!(matches!(QueueOf::::dequeue(), Ok(Some(_)))); assert!(MailboxOf::::is_empty(&caller)) @@ -747,7 +747,7 @@ benchmarks! { let code = benchmarking::generate_wasm(q.into()).unwrap(); let salt = vec![255u8; 32]; }: { - let _ = Gear::::upload_program(RawOrigin::Signed(caller).into(), code, salt, vec![], 100_000_000u64, 0u32.into()); + let _ = Gear::::upload_program(RawOrigin::Signed(caller).into(), code, salt, vec![], 100_000_000u64, 0u32.into(), false,); process_queue::(); } verify { @@ -762,7 +762,7 @@ benchmarks! { let code = benchmarking::generate_wasm2(q.into()).unwrap(); let salt = vec![255u8; 32]; }: { - let _ = Gear::::upload_program(RawOrigin::Signed(caller).into(), code, salt, vec![], 100_000_000u64, 0u32.into()); + let _ = Gear::::upload_program(RawOrigin::Signed(caller).into(), code, salt, vec![], 100_000_000u64, 0u32.into(), false,); process_queue::(); } verify { diff --git a/pallets/gear/src/benchmarking/tasks.rs b/pallets/gear/src/benchmarking/tasks.rs index 1ec61aac52d..88d6b2fb1cb 100644 --- a/pallets/gear/src/benchmarking/tasks.rs +++ b/pallets/gear/src/benchmarking/tasks.rs @@ -37,6 +37,7 @@ where delay.encode(), 100_000_000_000, 0u32.into(), + false, ) .expect("submit program failed"); @@ -63,6 +64,7 @@ where b"init_payload".to_vec(), 10_000_000_000, 0u32.into(), + false, ) .expect("submit program failed"); @@ -113,6 +115,7 @@ where b"init_payload".to_vec(), 10_000_000_000, 0u32.into(), + false, ) .expect("submit program failed"); @@ -153,6 +156,7 @@ where InitAction::Normal(vec![(50_000, 100)]).encode(), 10_000_000_000, 0u32.into(), + false, ) .expect("submit program failed"); @@ -219,6 +223,7 @@ where Scheme::empty().encode(), 10_000_000_000, 0u32.into(), + false, ) .expect("submit program failed"); @@ -236,6 +241,7 @@ where calls.encode(), 10_000_000_000, 0u32.into(), + false, ) .expect("failed to send message"); @@ -273,6 +279,7 @@ where vec![], 10_000_000_000, 0u32.into(), + false, ) .expect("submit program failed"); @@ -283,6 +290,7 @@ where Command::Wait(WaitSubcommand::WaitFor(delay)).encode(), 10_000_000_000, 0u32.into(), + false, ) .expect("failed to send message"); @@ -321,6 +329,7 @@ where vec![], 10_000_000_000, 0u32.into(), + false, ) .expect("submit program failed"); @@ -330,6 +339,7 @@ where Command::Wait(WaitSubcommand::Wait).encode(), 10_000_000_000, 0u32.into(), + false, ) .expect("failed to send message"); diff --git a/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs b/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs index 8df659cde24..41e058da3ea 100644 --- a/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs +++ b/pallets/gear/src/benchmarking/tests/syscalls_integrity.rs @@ -65,6 +65,7 @@ where Default::default(), BlockGasLimitOf::::get(), Zero::zero(), + false, ) .expect("Failed to upload read_big_state binary"); @@ -96,6 +97,7 @@ where strings.encode(), BlockGasLimitOf::::get(), Zero::zero(), + false, ) .expect("Failed to send read_big_state append command"); @@ -401,6 +403,7 @@ where b"".to_vec(), 50_000_000_000, 0u128.unique_saturated_into(), + false, ) .expect("failed to upload test program"); @@ -417,6 +420,7 @@ where b"".to_vec(), 50_000_000_000, 0u128.unique_saturated_into(), + false, ) .expect("failed to send message to test program"); utils::run_to_next_block::(None); @@ -775,6 +779,7 @@ where vec![Kind::ReplyDetails([255u8; 32], reply_code)].encode(), 50_000_000_000, 0u128.unique_saturated_into(), + false, ) .expect("triggering message send to mailbox failed"); @@ -813,6 +818,7 @@ where vec![Kind::SignalDetails].encode(), 50_000_000_000, 0u128.unique_saturated_into(), + false, ) .expect("triggering message send to mailbox failed"); @@ -985,6 +991,7 @@ where vec![], 50_000_000_000, 0u128.unique_saturated_into(), + false, ) .expect("child program deploy failed"); @@ -1001,6 +1008,7 @@ where child_code_hash.encode(), 50_000_000_000, 0u128.unique_saturated_into(), + false, ) .expect("sys-call check program deploy failed"); @@ -1017,6 +1025,7 @@ where mp.payload, 50_000_000_000, mp.value.unique_saturated_into(), + false, ) .expect("failed send message"); } @@ -1028,6 +1037,7 @@ where rp.payload, 50_000_000_000, rp.value.unique_saturated_into(), + false, ) .expect("failed send reply"); } diff --git a/pallets/gear/src/internal.rs b/pallets/gear/src/internal.rs index 5103771e38e..5fbb0831d39 100644 --- a/pallets/gear/src/internal.rs +++ b/pallets/gear/src/internal.rs @@ -652,7 +652,7 @@ where if !dispatch.value().is_zero() { // Reserving value from source for future transfer or unreserve. - GearBank::::deposit_value(&from, value) + GearBank::::deposit_value(&from, value, false) .unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); } @@ -759,7 +759,7 @@ where .unwrap_or_else(|e| unreachable!("GasTree corrupted! {:?}", e)); // Reserving value from source for future transfer or unreserve. - GearBank::::deposit_value(&from, value) + GearBank::::deposit_value(&from, value, false) .unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); // Lock the entire `gas_limit` since the only purpose of it is payment for storage. diff --git a/pallets/gear/src/lib.rs b/pallets/gear/src/lib.rs index 293cf4bcf1c..69263cfe5ec 100644 --- a/pallets/gear/src/lib.rs +++ b/pallets/gear/src/lib.rs @@ -594,8 +594,8 @@ pub mod pallet { // First we reserve enough funds on the account to pay for `gas_limit` // and to transfer declared value. - GearBank::::deposit_gas(&who, gas_limit)?; - GearBank::::deposit_value(&who, value)?; + GearBank::::deposit_gas(&who, gas_limit, false)?; + GearBank::::deposit_value(&who, value, false)?; let origin = who.clone().into_origin(); @@ -1174,6 +1174,7 @@ pub mod pallet { init_payload: Vec, gas_limit: u64, value: BalanceOf, + keep_alive: bool, ) -> Result { let packet = InitPacket::new_with_gas( code_id, @@ -1196,8 +1197,8 @@ pub mod pallet { // First we reserve enough funds on the account to pay for `gas_limit` // and to transfer declared value. - GearBank::::deposit_gas(&who, gas_limit)?; - GearBank::::deposit_value(&who, value)?; + GearBank::::deposit_gas(&who, gas_limit, keep_alive)?; + GearBank::::deposit_value(&who, value, keep_alive)?; Ok(packet) } @@ -1362,6 +1363,7 @@ pub mod pallet { init_payload: Vec, gas_limit: u64, value: BalanceOf, + keep_alive: bool, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; @@ -1376,6 +1378,7 @@ pub mod pallet { init_payload, gas_limit, value, + keep_alive, )?; if !T::CodeStorage::exists(code_and_id.code_id()) { @@ -1423,6 +1426,7 @@ pub mod pallet { init_payload: Vec, gas_limit: u64, value: BalanceOf, + keep_alive: bool, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; @@ -1433,8 +1437,15 @@ pub mod pallet { Self::check_gas_limit_and_value(gas_limit, value)?; // Construct packet. - let packet = - Self::init_packet(who.clone(), code_id, salt, init_payload, gas_limit, value)?; + let packet = Self::init_packet( + who.clone(), + code_id, + salt, + init_payload, + gas_limit, + value, + keep_alive, + )?; Self::do_create_program(who, packet, CodeInfo::from_code(&code_id, &code))?; Ok(().into()) @@ -1465,11 +1476,20 @@ pub mod pallet { payload: Vec, gas_limit: u64, value: BalanceOf, + keep_alive: bool, ) -> DispatchResultWithPostInfo { // Validating origin. let who = ensure_signed(origin)?; - Self::send_message_impl(who, destination, payload, gas_limit, value, false) + Self::send_message_impl( + who, + destination, + payload, + gas_limit, + value, + false, + keep_alive, + ) } /// Send reply on message in `Mailbox`. @@ -1493,11 +1513,20 @@ pub mod pallet { payload: Vec, gas_limit: u64, value: BalanceOf, + keep_alive: bool, ) -> DispatchResultWithPostInfo { // Validating origin. let who = ensure_signed(origin)?; - Self::send_reply_impl(who, reply_to_id, payload, gas_limit, value, false) + Self::send_reply_impl( + who, + reply_to_id, + payload, + gas_limit, + value, + false, + keep_alive, + ) } /// Claim value from message in `Mailbox`. @@ -1796,6 +1825,7 @@ pub mod pallet { gas_limit: u64, value: BalanceOf, prepaid: bool, + keep_alive: bool, ) -> DispatchResultWithPostInfo { let payload = payload .try_into() @@ -1824,14 +1854,14 @@ pub mod pallet { // in the queue. // Note: reservation is always made against the user's account regardless whether // a voucher exists. The latter can only be used to pay for gas or transaction fee. - GearBank::::deposit_value(&who, value)?; + GearBank::::deposit_value(&who, value, keep_alive)?; let external_node = if prepaid { // If voucher is used, we attempt to reserve funds on the respective account. // If no such voucher exists, the call is invalidated. let voucher_id = VoucherOf::::voucher_id(who.clone(), destination); - GearBank::::deposit_gas(&voucher_id, gas_limit).map_err(|e| { + GearBank::::deposit_gas(&voucher_id, gas_limit, keep_alive).map_err(|e| { log::debug!( "Failed to redeem voucher for user {who:?} and program {destination:?}: {e:?}" ); @@ -1841,7 +1871,7 @@ pub mod pallet { voucher_id } else { // If voucher is not used, we reserve gas limit on the user's account. - GearBank::::deposit_gas(&who, gas_limit)?; + GearBank::::deposit_gas(&who, gas_limit, keep_alive)?; who.clone() }; @@ -1891,6 +1921,7 @@ pub mod pallet { gas_limit: u64, value: BalanceOf, prepaid: bool, + keep_alive: bool, ) -> DispatchResultWithPostInfo { let payload = payload .try_into() @@ -1919,14 +1950,14 @@ pub mod pallet { gas_limit }; - GearBank::::deposit_value(&origin, value)?; + GearBank::::deposit_value(&origin, value, keep_alive)?; let external_node = if prepaid { // If voucher is used, we attempt to reserve funds on the respective account. // If no such voucher exists, the call is invalidated. let voucher_id = VoucherOf::::voucher_id(origin.clone(), destination); - GearBank::::deposit_gas(&voucher_id, gas_limit).map_err(|e| { + GearBank::::deposit_gas(&voucher_id, gas_limit, keep_alive).map_err(|e| { log::debug!( "Failed to redeem voucher for user {origin:?} and program {destination:?}: {e:?}" ); @@ -1936,7 +1967,7 @@ pub mod pallet { voucher_id } else { // If voucher is not used, we reserve gas limit on the user's account. - GearBank::::deposit_gas(&origin, gas_limit)?; + GearBank::::deposit_gas(&origin, gas_limit, keep_alive)?; origin.clone() }; @@ -2004,6 +2035,7 @@ pub mod pallet { payload, gas_limit, value, + keep_alive, } => Self::send_message_impl( account_id, destination, @@ -2011,15 +2043,23 @@ pub mod pallet { gas_limit, value, true, + keep_alive, ), PrepaidCall::SendReply { reply_to_id, payload, gas_limit, value, - } => { - Self::send_reply_impl(account_id, reply_to_id, payload, gas_limit, value, true) - } + keep_alive, + } => Self::send_reply_impl( + account_id, + reply_to_id, + payload, + gas_limit, + value, + true, + keep_alive, + ), } } } diff --git a/pallets/gear/src/manager/journal.rs b/pallets/gear/src/manager/journal.rs index f5c4deed77d..dbd89248c1d 100644 --- a/pallets/gear/src/manager/journal.rs +++ b/pallets/gear/src/manager/journal.rs @@ -226,6 +226,7 @@ where GearBank::::deposit_value( &::from_origin(dispatch.source().into_origin()), dispatch.value().unique_saturated_into(), + false, ) .unwrap_or_else(|e| unreachable!("Gear bank error: {e:?}")); } diff --git a/pallets/gear/src/runtime_api.rs b/pallets/gear/src/runtime_api.rs index 41cbd44383a..689cfe1b3f7 100644 --- a/pallets/gear/src/runtime_api.rs +++ b/pallets/gear/src/runtime_api.rs @@ -71,26 +71,37 @@ where match kind { HandleKind::Init(code) => { let salt = b"calculate_gas_salt".to_vec(); - Self::upload_program(who.into(), code, salt, payload, initial_gas, value).map_err( - |e| format!("Internal error: upload_program failed with '{e:?}'").into_bytes(), - )?; + Self::upload_program(who.into(), code, salt, payload, initial_gas, value, false) + .map_err(|e| { + format!("Internal error: upload_program failed with '{e:?}'").into_bytes() + })?; } HandleKind::InitByHash(code_id) => { let salt = b"calculate_gas_salt".to_vec(); - Self::create_program(who.into(), code_id, salt, payload, initial_gas, value) - .map_err(|e| { - format!("Internal error: create_program failed with '{e:?}'").into_bytes() - })?; + Self::create_program( + who.into(), + code_id, + salt, + payload, + initial_gas, + value, + false, + ) + .map_err(|e| { + format!("Internal error: create_program failed with '{e:?}'").into_bytes() + })?; } HandleKind::Handle(destination) => { - Self::send_message(who.into(), destination, payload, initial_gas, value).map_err( - |e| format!("Internal error: send_message failed with '{e:?}'").into_bytes(), - )?; + Self::send_message(who.into(), destination, payload, initial_gas, value, false) + .map_err(|e| { + format!("Internal error: send_message failed with '{e:?}'").into_bytes() + })?; } HandleKind::Reply(reply_to_id, _status_code) => { - Self::send_reply(who.into(), reply_to_id, payload, initial_gas, value).map_err( - |e| format!("Internal error: send_reply failed with '{e:?}'").into_bytes(), - )?; + Self::send_reply(who.into(), reply_to_id, payload, initial_gas, value, false) + .map_err(|e| { + format!("Internal error: send_reply failed with '{e:?}'").into_bytes() + })?; } HandleKind::Signal(_signal_from, _status_code) => { return Err(b"Gas calculation for `handle_signal` is not supported".to_vec()); diff --git a/pallets/gear/src/tests.rs b/pallets/gear/src/tests.rs index a9a9b4fec66..274dcaf2069 100644 --- a/pallets/gear/src/tests.rs +++ b/pallets/gear/src/tests.rs @@ -96,6 +96,7 @@ fn default_wait_lock_timeout() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000u64, 0, + false, )); let pid = get_last_program_id(); @@ -110,6 +111,7 @@ fn default_wait_lock_timeout() { Kind::Send.encode(), BlockGasLimitOf::::get(), 0, + false, )); let mid = utils::get_last_message_id(); @@ -180,6 +182,7 @@ fn value_counter_set_correctly_for_interruptions() { Default::default(), BlockGasLimitOf::::get(), VALUE, + false, )); run_to_next_block(None); @@ -211,6 +214,7 @@ fn calculate_gas_returns_not_block_limit() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); let generator_id = get_last_program_id(); @@ -246,6 +250,7 @@ fn read_big_state() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); let pid = get_last_program_id(); @@ -277,6 +282,7 @@ fn read_big_state() { strings.encode(), BlockGasLimitOf::::get(), 0, + false, )); let mid = get_last_message_id(); @@ -315,6 +321,7 @@ fn auto_reply_sent() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 10_000, + false, )); run_to_next_block(None); @@ -344,6 +351,7 @@ fn auto_reply_sent() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); System::reset_events(); @@ -372,6 +380,7 @@ fn auto_reply_from_user_no_mailbox() { calls.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -396,6 +405,7 @@ fn auto_reply_from_user_no_mailbox() { calls.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -423,6 +433,7 @@ fn auto_reply_out_of_rent_waitlist() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); let waiter_id = get_last_program_id(); @@ -436,6 +447,7 @@ fn auto_reply_out_of_rent_waitlist() { .encode(), BlockGasLimitOf::::get(), 0, + false, )); let proxy_id = get_last_program_id(); @@ -471,6 +483,7 @@ fn auto_reply_out_of_rent_waitlist() { Command::Wait(WaitSubcommand::Wait).encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -504,6 +517,7 @@ fn auto_reply_out_of_rent_mailbox() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), value, + false, )); let program_id = utils::get_last_program_id(); @@ -519,6 +533,7 @@ fn auto_reply_out_of_rent_mailbox() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); let message_id = utils::get_last_message_id(); @@ -582,6 +597,7 @@ fn reply_deposit_to_program() { 10_000_000_000u64.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -613,6 +629,7 @@ fn reply_deposit_to_user_auto_reply() { 10_000_000_000u64.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -644,6 +661,7 @@ fn reply_deposit_panic_in_handle_reply() { 1u64.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -677,6 +695,7 @@ fn reply_deposit_to_user_reply() { reply_deposit.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -708,6 +727,7 @@ fn reply_deposit_to_user_reply() { vec![], BlockGasLimitOf::::get(), value, + false, )); assert_eq!(get_last_message_id(), reply_id); @@ -752,6 +772,7 @@ fn reply_deposit_to_user_claim() { reply_deposit.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -818,6 +839,7 @@ fn reply_deposit_to_user_out_of_rent() { reply_deposit.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -880,6 +902,7 @@ fn reply_deposit_gstd_async() { (USER_2.into_origin().as_fixed_bytes(), 10_000_000_000u64).encode(), 30_000_000_000, 0, + false, )); let program_id = get_last_program_id(); @@ -891,6 +914,7 @@ fn reply_deposit_gstd_async() { hello.to_vec(), 30_000_000_000, 0, + false, )); let handle_id = get_last_message_id(); @@ -908,6 +932,7 @@ fn reply_deposit_gstd_async() { hello_reply.to_vec(), 0, 0, + false, )); run_to_next_block(None); @@ -939,6 +964,7 @@ fn pseudo_duplicate_wake() { calls.encode(), BlockGasLimitOf::::get(), 0, + false, )); let msg_id = get_last_message_id(); run_to_next_block(None); @@ -1004,6 +1030,7 @@ fn gasfull_after_gasless() { EMPTY_PAYLOAD.to_vec(), min_limit - 1, 0, + false, )); // Make sure nothing panics. @@ -1024,6 +1051,7 @@ fn backend_errors_handled_in_program() { InitMessage::BackendError.encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let mid = utils::get_last_message_id(); @@ -1074,6 +1102,7 @@ fn non_existent_code_id_zero_gas() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); run_to_next_block(None); @@ -1141,6 +1170,7 @@ fn waited_with_zero_gas() { EMPTY_PAYLOAD.to_vec(), min_limit, 0, + false, )); let program_id = utils::get_last_program_id(); @@ -1154,6 +1184,7 @@ fn waited_with_zero_gas() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); run_to_next_block(None); @@ -1190,6 +1221,7 @@ fn terminated_program_zero_gas() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let program_id = utils::get_last_program_id(); @@ -1200,6 +1232,7 @@ fn terminated_program_zero_gas() { EMPTY_PAYLOAD.to_vec(), 0, 0, + false, )); run_to_next_block(None); @@ -1235,6 +1268,7 @@ fn exited_program_zero_gas() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let program_id = utils::get_last_program_id(); @@ -1245,6 +1279,7 @@ fn exited_program_zero_gas() { EMPTY_PAYLOAD.to_vec(), 0, 0, + false, )); run_to_next_block(None); @@ -1275,6 +1310,7 @@ fn delayed_user_replacement() { gas_limit_to_forward.encode(), // to be forwarded as gas limit gas_limit_to_forward + DEFAULT_GAS_LIMIT * 100, 100_000_000, // before fix to be forwarded as value + false, )); let message_id = utils::get_last_message_id(); @@ -1289,6 +1325,7 @@ fn delayed_user_replacement() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); assert_eq!(future_program_address, utils::get_last_program_id()); @@ -1365,6 +1402,7 @@ fn delayed_send_user_message_payment() { 0u64.encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy_msg_id = get_last_message_id(); @@ -1452,6 +1490,7 @@ fn delayed_send_user_message_with_reservation() { .encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy = utils::get_last_program_id(); @@ -1465,6 +1504,7 @@ fn delayed_send_user_message_with_reservation() { 0u64.encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy_msg_id = get_last_message_id(); @@ -1558,6 +1598,7 @@ fn delayed_send_program_message_payment() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let program_address = utils::get_last_program_id(); @@ -1573,6 +1614,7 @@ fn delayed_send_program_message_payment() { 0u64.encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy_msg_id = utils::get_last_message_id(); @@ -1643,6 +1685,7 @@ fn delayed_send_program_message_with_reservation() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let program_address = utils::get_last_program_id(); @@ -1661,6 +1704,7 @@ fn delayed_send_program_message_with_reservation() { .encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy = utils::get_last_program_id(); @@ -1675,6 +1719,7 @@ fn delayed_send_program_message_with_reservation() { 0u64.encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy_msg_id = utils::get_last_message_id(); @@ -1753,6 +1798,7 @@ fn delayed_send_program_message_with_low_reservation() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let program_address = utils::get_last_program_id(); @@ -1771,6 +1817,7 @@ fn delayed_send_program_message_with_low_reservation() { .encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy = utils::get_last_program_id(); @@ -1785,6 +1832,7 @@ fn delayed_send_program_message_with_low_reservation() { 0u64.encode(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let proxy_msg_id = utils::get_last_message_id(); @@ -1889,6 +1937,7 @@ fn delayed_program_creation_no_code() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT * 100, 0, + false, )); let creator = utils::get_last_program_id(); @@ -1981,6 +2030,7 @@ fn unstoppable_block_execution_works() { EMPTY_PAYLOAD.to_vec(), gas_for_each_execution, 0, + false, )); } @@ -2015,6 +2065,7 @@ fn read_state_works() { ::default().encode(), DEFAULT_GAS_LIMIT * 100, 10_000, + false, )); let program_id = utils::get_last_program_id(); @@ -2048,6 +2099,7 @@ fn read_state_using_wasm_works() { ::default().encode(), DEFAULT_GAS_LIMIT * 100, 10_000, + false, )); let program_id = utils::get_last_program_id(); @@ -2146,6 +2198,7 @@ fn read_state_bn_and_timestamp_works() { ::default().encode(), DEFAULT_GAS_LIMIT * 100, 10_000, + false, )); let program_id = utils::get_last_program_id(); @@ -2177,6 +2230,7 @@ fn wasm_metadata_generation_works() { ::default().encode(), DEFAULT_GAS_LIMIT * 100, 10_000, + false, )); let program_id = utils::get_last_program_id(); @@ -2250,6 +2304,7 @@ fn read_state_using_wasm_errors() { ::default().encode(), DEFAULT_GAS_LIMIT * 100, 10_000, + false, )); let program_id = utils::get_last_program_id(); @@ -2532,6 +2587,7 @@ fn mailbox_sending_instant_transfer() { payload.request(USER_2.into_origin()).encode(), gas_info.burned + gas_limit.unwrap_or_default(), 0, + false, )); utils::assert_balance( @@ -2565,7 +2621,8 @@ fn upload_program_expected_failure() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, - balance + 1 + balance + 1, + false, ), pallet_gear_bank::Error::::InsufficientBalance ); @@ -2584,7 +2641,8 @@ fn upload_program_expected_failure() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), block_gas_limit + 1, - 0 + 0, + false, ), Error::::GasLimitTooHigh ); @@ -2651,6 +2709,7 @@ fn send_message_works() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, mail_value, + false, )); let message_id = get_last_message_id(); @@ -2730,6 +2789,7 @@ fn mailbox_threshold_works() { (rent - 1).encode(), BlockGasLimitOf::::get(), 0, + false, )); check_result(false); @@ -2740,6 +2800,7 @@ fn mailbox_threshold_works() { (rent).encode(), BlockGasLimitOf::::get(), 0, + false, )); let message_id = check_result(true); @@ -2750,6 +2811,7 @@ fn mailbox_threshold_works() { rent.encode(), BlockGasLimitOf::::get(), 0, + false, )); let message_id = check_result(true); @@ -2760,6 +2822,7 @@ fn mailbox_threshold_works() { (rent - 1).encode(), BlockGasLimitOf::::get(), 0, + false, )); check_result(false); }); @@ -2781,6 +2844,7 @@ fn send_message_uninitialized_program() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -2842,6 +2906,7 @@ fn send_message_expected_failure() { EMPTY_PAYLOAD.to_vec(), 10, value, + false, )); // And no message will be in mailbox @@ -2863,6 +2928,7 @@ fn send_message_expected_failure() { EMPTY_PAYLOAD.to_vec(), block_gas_limit + 1, 0, + false, ), Error::::GasLimitTooHigh ); @@ -2949,6 +3015,7 @@ fn unused_gas_released_back_works() { EMPTY_PAYLOAD.to_vec(), huge_send_message_gas_limit, 0, + false, )); // Spends for submit program with default gas limit and sending default message with a huge gas limit @@ -3011,6 +3078,7 @@ fn restrict_start_section() { EMPTY_PAYLOAD.to_vec(), 5_000_000, 0, + false, ) .expect_err("Must throw err, because code contains start section"); }); @@ -3217,6 +3285,7 @@ fn memory_access_cases() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .map(|_| prog_id); let pid = res.expect("submit result is not ok"); @@ -3232,6 +3301,7 @@ fn memory_access_cases() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, ); assert_ok!(res); @@ -3246,6 +3316,7 @@ fn memory_access_cases() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, ); assert_ok!(res); @@ -3316,6 +3387,7 @@ fn lazy_pages() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, ) .map(|_| prog_id); assert_ok!(res); @@ -3331,6 +3403,7 @@ fn lazy_pages() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 1000, + false, ); assert_ok!(res); @@ -3440,6 +3513,7 @@ fn initial_pages_cheaper_than_allocated_pages() { EMPTY_PAYLOAD.to_vec(), 100_000_000_000, 0, + false, ); assert_ok!(res); @@ -3585,6 +3659,7 @@ fn block_gas_limit_works() { EMPTY_PAYLOAD.to_vec(), gas1.min_limit - 1, 1000, + false, )); let failed1 = get_last_message_id(); @@ -3594,6 +3669,7 @@ fn block_gas_limit_works() { EMPTY_PAYLOAD.to_vec(), gas1.min_limit, 1000, + false, )); let succeed1 = get_last_message_id(); @@ -3603,6 +3679,7 @@ fn block_gas_limit_works() { EMPTY_PAYLOAD.to_vec(), gas2.min_limit - 1, 1000, + false, )); let failed2 = get_last_message_id(); @@ -3612,6 +3689,7 @@ fn block_gas_limit_works() { EMPTY_PAYLOAD.to_vec(), gas2.min_limit, 1000, + false, )); let succeed2 = get_last_message_id(); @@ -3642,6 +3720,7 @@ fn block_gas_limit_works() { EMPTY_PAYLOAD.to_vec(), gas.min_limit, 1000, + false, )); }; @@ -3980,6 +4059,7 @@ fn send_reply_works() { EMPTY_PAYLOAD.to_vec(), 10_000_000, 1000, // `prog_id` sent message with value of 1000 (see program code) + false, )); let expected_reply_message_id = get_last_message_id(); @@ -4015,6 +4095,7 @@ fn send_reply_failure_to_claim_from_mailbox() { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, 0, + false, ), Error::::MessageNotFound ); @@ -4103,6 +4184,7 @@ fn send_reply_value_claiming_works() { EMPTY_PAYLOAD.to_vec(), gas_limit_to_reply, value_to_reply, + false, )); let currently_sent = value_to_reply + gas_price(gas_limit_to_reply); @@ -4229,7 +4311,8 @@ fn uninitialized_program_zero_gas() { vec![], Vec::new(), 50_000_000_000u64, - 0u128 + 0u128, + false, )); let init_message_id = utils::get_last_message_id(); @@ -4250,6 +4333,7 @@ fn uninitialized_program_zero_gas() { vec![], 0, // that triggers unreachable code atm 0, + false, )); run_to_block(3, None); @@ -4271,6 +4355,7 @@ fn distributor_initialize() { EMPTY_PAYLOAD.to_vec(), 10_000_000, 0, + false, )); run_to_block(2, None); @@ -4304,6 +4389,7 @@ fn distributor_distribute() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); run_to_block(2, None); @@ -4314,6 +4400,7 @@ fn distributor_distribute() { Request::Receive(10).encode(), 30_000_000_000, 0, + false, )); run_to_block(3, None); @@ -4411,7 +4498,8 @@ fn test_code_is_not_submitted_twice_after_program_submission() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, - 0 + 0, + false, )); // TODO: replace this temporary (`None`) value @@ -4458,7 +4546,8 @@ fn test_code_is_not_reset_within_program_submission() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, - 0 + 0, + false, )); let actual_meta = ::CodeStorage::get_metadata(code_id); let actual_code_saved_events = System::events() @@ -4493,7 +4582,8 @@ fn messages_to_uninitialized_program_wait() { vec![], Vec::new(), 50_000_000_000u64, - 0u128 + 0u128, + false, )); let program_id = utils::get_last_program_id(); @@ -4512,6 +4602,7 @@ fn messages_to_uninitialized_program_wait() { vec![], 10_000u64, 0u128, + false, )); run_to_block(3, None); @@ -4537,7 +4628,8 @@ fn uninitialized_program_should_accept_replies() { vec![], Vec::new(), 10_000_000_000u64, - 0u128 + 0u128, + false, )); let program_id = utils::get_last_program_id(); @@ -4560,6 +4652,7 @@ fn uninitialized_program_should_accept_replies() { b"PONG".to_vec(), 10_000_000_000u64, 0, + false, )); run_to_block(3, None); @@ -4582,7 +4675,8 @@ fn defer_program_initialization() { vec![], Vec::new(), 10_000_000_000u64, - 0u128 + 0u128, + false, )); let program_id = utils::get_last_program_id(); @@ -4600,6 +4694,7 @@ fn defer_program_initialization() { b"PONG".to_vec(), 10_000_000_000u64, 0, + false, )); run_to_block(3, None); @@ -4610,6 +4705,7 @@ fn defer_program_initialization() { vec![], 10_000_000_000u64, 0u128, + false, )); run_to_block(4, None); @@ -4638,7 +4734,8 @@ fn wake_messages_after_program_inited() { vec![], Vec::new(), 10_000_000_000u64, - 0u128 + 0u128, + false, )); let program_id = utils::get_last_program_id(); @@ -4655,6 +4752,7 @@ fn wake_messages_after_program_inited() { vec![], 5_000_000_000u64, 0u128, + false, )); } @@ -4671,6 +4769,7 @@ fn wake_messages_after_program_inited() { b"PONG".to_vec(), 20_000_000_000u64, 0, + false, )); run_to_block(20, None); @@ -4704,7 +4803,8 @@ fn test_different_waits_success() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 100_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -4753,6 +4853,7 @@ fn test_different_waits_success() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_success = get_last_message_id(); @@ -4785,6 +4886,7 @@ fn test_different_waits_success() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_for_success = get_last_message_id(); @@ -4820,6 +4922,7 @@ fn test_different_waits_success() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_up_to_success = get_last_message_id(); @@ -4845,7 +4948,8 @@ fn test_different_waits_fail() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 100_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -4879,6 +4983,7 @@ fn test_different_waits_fail() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_gas = get_last_message_id(); @@ -4915,6 +5020,7 @@ fn test_different_waits_fail() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_for_gas = get_last_message_id(); @@ -4951,6 +5057,7 @@ fn test_different_waits_fail() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_up_to_gas = get_last_message_id(); @@ -4988,6 +5095,7 @@ fn test_different_waits_fail() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_for_arg = get_last_message_id(); @@ -5025,6 +5133,7 @@ fn test_different_waits_fail() { payload, gas_info.burned + wl_gas + system_reservation, value, + false, )); let wait_up_to_arg = get_last_message_id(); @@ -5054,7 +5163,8 @@ fn wait_after_reply() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 100_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -5068,6 +5178,7 @@ fn wait_after_reply() { Command::ReplyAndWait(subcommand).encode(), BlockGasLimitOf::::get(), 0, + false, )); let message_id = utils::get_last_message_id(); @@ -5103,7 +5214,8 @@ fn test_requeue_after_wait_for_timeout() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 100_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -5118,6 +5230,7 @@ fn test_requeue_after_wait_for_timeout() { payload, 30_000_000_000, 0, + false, )); // Fast forward blocks. @@ -5170,7 +5283,8 @@ fn test_sending_waits() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 20_000_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -5189,6 +5303,7 @@ fn test_sending_waits() { payload, 25_000_000_000, 0, + false, )); let wait_for = get_last_message_id(); @@ -5207,6 +5322,7 @@ fn test_sending_waits() { payload, 25_000_000_000, 0, + false, )); let wait_no_more = get_last_message_id(); @@ -5225,6 +5341,7 @@ fn test_sending_waits() { payload, 30_000_000_000, 0, + false, )); let wait_wait = get_last_message_id(); @@ -5243,6 +5360,7 @@ fn test_sending_waits() { vec![], 10_000_000_000, 0, + false, )); run_to_next_block(None); @@ -5267,7 +5385,8 @@ fn test_wait_timeout() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 10_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -5284,6 +5403,7 @@ fn test_wait_timeout() { payload, 30_000_000_000, 0, + false, )); run_to_next_block(None); @@ -5297,6 +5417,7 @@ fn test_wait_timeout() { Command::Wake.encode(), 10_000_000, 0, + false, )); run_to_next_block(None); @@ -5323,7 +5444,8 @@ fn test_join_wait_timeout() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 10_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -5340,6 +5462,7 @@ fn test_join_wait_timeout() { payload, 30_000_000_000, 0, + false, )); run_to_next_block(None); @@ -5381,7 +5504,8 @@ fn test_select_wait_timeout() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 10_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -5398,6 +5522,7 @@ fn test_select_wait_timeout() { payload, 30_000_000_000, 0, + false, )); run_to_next_block(None); @@ -5428,7 +5553,8 @@ fn test_wait_lost() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), 10_000_000u64, - 0u128 + 0u128, + false, )); let program_id = get_last_program_id(); @@ -5443,6 +5569,7 @@ fn test_wait_lost() { payload, 30_000_000_000, 0, + false, )); run_to_next_block(None); @@ -5455,6 +5582,7 @@ fn test_wait_lost() { b"ping".to_vec(), 100_000_000, 0, + false, )); true @@ -5511,6 +5639,7 @@ fn test_message_processing_for_non_existing_destination() { EMPTY_PAYLOAD.to_vec(), 10_000, 1_000, + false, )); let skipped_message_id = get_last_message_id(); @@ -5551,6 +5680,7 @@ fn exit_locking_funds() { calls.encode(), 10_000_000_000, value, + false, )); let message_1 = utils::get_last_message_id(); @@ -5561,6 +5691,7 @@ fn exit_locking_funds() { calls.encode(), 10_000_000_000, 0, + false, )); let message_2 = utils::get_last_message_id(); @@ -5660,7 +5791,8 @@ fn terminated_locking_funds() { DEFAULT_SALT.to_vec(), USER_3.into_origin().encode(), gas_spent_init + gas_for_second_init_execution, - 5_000u128 + 5_000u128, + false )); let program_id = get_last_program_id(); @@ -5703,6 +5835,7 @@ fn terminated_locking_funds() { EMPTY_PAYLOAD.to_vec(), gas_spent_reply, 0, + false, )); let reply_id = get_last_message_id(); @@ -5783,7 +5916,8 @@ fn pause_terminated_exited_program() { DEFAULT_SALT.to_vec(), Vec::new(), 2_000_000_000, - 0u128 + 0u128, + false, ), Error::::ProgramAlreadyExists, ); @@ -5846,7 +5980,8 @@ fn test_create_program_works() { // // Calculate the gas spent after #1242. 10_000_000_000u64, - 0u128 + 0u128, + false, )); let program_id = utils::get_last_program_id(); @@ -5872,6 +6007,7 @@ fn test_create_program_works() { // Calculate the gas spent after #1242. 10_000_000_000u64, 0, + false, )); run_to_next_block(None); @@ -5906,6 +6042,7 @@ fn test_create_program_no_code_hash() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, )); // Try to create a program with non existing code hash @@ -5915,6 +6052,7 @@ fn test_create_program_no_code_hash() { CreateProgram::Default.encode(), 50_000_000_000, 0, + false, )); run_to_block(2, None); @@ -5939,6 +6077,7 @@ fn test_create_program_no_code_hash() { .encode(), 100_000_000_000, 0, + false, )); run_to_block(3, None); @@ -5969,6 +6108,7 @@ fn test_create_program_no_code_hash() { .encode(), 100_000_000_000, 0, + false, )); run_to_block(4, None); @@ -6001,6 +6141,7 @@ fn test_create_program_simple() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, )); run_to_block(2, None); @@ -6011,6 +6152,7 @@ fn test_create_program_simple() { CreateProgram::Default.encode(), 50_000_000_000, 0, + false, )); run_to_block(3, None); @@ -6024,6 +6166,7 @@ fn test_create_program_simple() { .encode(), 10_000_000_000, 0, + false, )); run_to_block(4, None); @@ -6045,6 +6188,7 @@ fn test_create_program_simple() { .encode(), 50_000_000_000, 0, + false, )); run_to_block(5, None); @@ -6059,6 +6203,7 @@ fn test_create_program_simple() { .encode(), 50_000_000_000, 0, + false, )); run_to_block(6, None); @@ -6086,6 +6231,7 @@ fn test_pausing_programs_works() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, )); let factory_bn = System::block_number(); @@ -6102,6 +6248,7 @@ fn test_pausing_programs_works() { .encode(), 50_000_000_000, 0, + false, )); let child_program_id = ProgramId::generate_from_program( @@ -6279,6 +6426,7 @@ fn state_request() { InitMessage::BTree.encode(), 50_000_000_000, 0, + false, )); let data = [(0u32, 1u32), (2, 4), (7, 8)]; @@ -6289,6 +6437,7 @@ fn state_request() { Request::Insert(key, value).encode(), 1_000_000_000, 0, + false, )); } @@ -6326,6 +6475,7 @@ fn resume_session_push_works() { InitMessage::BTree.encode(), 50_000_000_000, 0, + false, )); let request = Request::Insert(0, 1).encode(); @@ -6335,6 +6485,7 @@ fn resume_session_push_works() { request, 1_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6440,6 +6591,7 @@ fn resume_program_works() { InitMessage::BTree.encode(), 50_000_000_000, 0, + false, )); let request = Request::Insert(0, 1).encode(); @@ -6449,6 +6601,7 @@ fn resume_program_works() { request, 10_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6611,6 +6764,7 @@ fn resume_program_works() { request, 10_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6635,6 +6789,7 @@ fn test_no_messages_to_paused_program() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6644,6 +6799,7 @@ fn test_no_messages_to_paused_program() { demo_wait_wake::Request::EchoWait(10).encode(), 50_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6676,6 +6832,7 @@ fn reservations_cleaned_in_paused_program() { .encode(), 50_000_000_000, 0, + false, )); let program_id = get_last_program_id(); @@ -6732,6 +6889,7 @@ fn uninitialized_program_terminates_on_pause() { InitAction::Wait.encode(), 50_000_000_000, 0, + false, )); let program_id = get_last_program_id(); @@ -6744,6 +6902,7 @@ fn uninitialized_program_terminates_on_pause() { b"0123456789".to_vec(), 50_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6813,6 +6972,7 @@ fn pay_program_rent_syscall_works() { pay_rent_id.into_bytes().to_vec(), 20_000_000_000, program_value, + false, )); run_to_next_block(None); @@ -6835,6 +6995,7 @@ fn pay_program_rent_syscall_works() { .encode(), 20_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6858,6 +7019,7 @@ fn pay_program_rent_syscall_works() { vec![Kind::PayProgramRent([0u8; 32], rent, None)].encode(), 20_000_000_000, 0, + false, )); run_to_next_block(None); @@ -6876,6 +7038,7 @@ fn pay_program_rent_syscall_works() { .encode(), 20_000_000_000, 0, + false, )); let message_id = get_last_message_id(); @@ -6921,6 +7084,7 @@ fn pay_program_rent_syscall_works() { .encode(), 20_000_000_000, Gear::rent_fee_for(u32::MAX), + false, )); let message_id = get_last_message_id(); @@ -6957,6 +7121,7 @@ fn pay_program_rent_syscall_works() { .encode(), 20_000_000_000, required_value, + false, )); let message_id = get_last_message_id(); @@ -7089,6 +7254,7 @@ fn test_create_program_duplicate() { EMPTY_PAYLOAD.to_vec(), 20_000_000_000, 0, + false, )); run_to_block(2, None); @@ -7108,6 +7274,7 @@ fn test_create_program_duplicate() { .encode(), 20_000_000_000, 0, + false, )); run_to_block(4, None); @@ -7125,6 +7292,7 @@ fn test_create_program_duplicate() { .encode(), 20_000_000_000, 0, + false, )); run_to_block(5, None); @@ -7136,6 +7304,7 @@ fn test_create_program_duplicate() { .encode(), 20_000_000_000, 0, + false, )); run_to_block(6, None); @@ -7149,6 +7318,7 @@ fn test_create_program_duplicate() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); }); } @@ -7175,6 +7345,7 @@ fn test_create_program_duplicate_in_one_execution() { EMPTY_PAYLOAD.to_vec(), 2_000_000_000, 0, + false, )); run_to_block(2, None); @@ -7189,6 +7360,7 @@ fn test_create_program_duplicate_in_one_execution() { .encode(), 20_000_000_000, 0, + false, )); run_to_block(3, None); @@ -7208,6 +7380,7 @@ fn test_create_program_duplicate_in_one_execution() { .encode(), 20_000_000_000, 0, + false, )); run_to_block(4, None); @@ -7260,6 +7433,7 @@ fn test_create_program_miscellaneous() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, )); run_to_block(2, None); @@ -7277,6 +7451,7 @@ fn test_create_program_miscellaneous() { .encode(), 50_000_000_000, 0, + false, )); run_to_block(3, None); @@ -7294,6 +7469,7 @@ fn test_create_program_miscellaneous() { .encode(), 50_000_000_000, 0, + false, )); run_to_block(4, None); @@ -7310,6 +7486,7 @@ fn test_create_program_miscellaneous() { .encode(), 50_000_000_000, 0, + false, )); run_to_block(5, None); @@ -7336,6 +7513,7 @@ fn exit_handle() { vec![], 50_000_000_000u64, 0u128, + false, )); run_to_block(3, None); @@ -7355,7 +7533,8 @@ fn exit_handle() { DEFAULT_SALT.to_vec(), Vec::new(), 2_000_000_000, - 0u128 + 0u128, + false, ), Error::::ProgramAlreadyExists, ); @@ -7388,6 +7567,7 @@ fn no_redundant_gas_value_after_exiting() { EMPTY_PAYLOAD.to_vec(), gas_spent, 0, + false, )); let msg_id = get_last_message_id(); @@ -7433,7 +7613,8 @@ fn init_wait_reply_exit_cleaned_storage() { EMPTY_PAYLOAD.to_vec(), Vec::new(), 50_000_000_000u64, - 0u128 + 0u128, + false, )); let pid = get_last_program_id(); @@ -7449,6 +7630,7 @@ fn init_wait_reply_exit_cleaned_storage() { vec![], 10_000u64, 0u128, + false, )); } @@ -7472,6 +7654,7 @@ fn init_wait_reply_exit_cleaned_storage() { EMPTY_PAYLOAD.to_vec(), 100_000_000_000u64, 0, + false, )); assert!(!Gear::is_initialized(pid)); @@ -7516,7 +7699,8 @@ fn locking_gas_for_waitlist() { Default::default(), Default::default(), 100_000_000_000, - 0 + 0, + false, )); let calculator = get_last_program_id(); @@ -7610,7 +7794,8 @@ fn calculate_init_gas() { DEFAULT_SALT.to_vec(), EMPTY_PAYLOAD.to_vec(), gas_info.min_limit, - 0 + 0, + false, )); let init_message_id = get_last_message_id(); @@ -7640,6 +7825,7 @@ fn gas_spent_vs_balance() { InitMessage::BTree.encode(), 50_000_000_000, 0, + false, )); let prog_id = utils::get_last_program_id(); @@ -7655,6 +7841,7 @@ fn gas_spent_vs_balance() { request.clone(), 10_000_000_000, 0, + false, )); run_to_block(3, None); @@ -7968,6 +8155,7 @@ fn test_two_contracts_composition_works() { 50_u64.encode(), 10_000_000_000, 0, + false, )); assert_ok!(Gear::create_program( @@ -7977,6 +8165,7 @@ fn test_two_contracts_composition_works() { 75_u64.encode(), 10_000_000_000, 0, + false, )); assert_ok!(Gear::upload_program( @@ -7990,6 +8179,7 @@ fn test_two_contracts_composition_works() { .encode(), 10_000_000_000, 0, + false, )); run_to_block(2, None); @@ -8000,6 +8190,7 @@ fn test_two_contracts_composition_works() { 100_u64.to_le_bytes().to_vec(), 60_000_000_000, 0, + false, )); run_to_block(4, None); @@ -8053,6 +8244,7 @@ fn test_create_program_with_value_lt_ed() { EMPTY_PAYLOAD.to_vec(), 100_000_000, ed - 1, + false, ), Error::::ValueLessThanMinimal, ); @@ -8098,6 +8290,7 @@ fn test_create_program_with_value_lt_ed() { Scheme::direct(calls).encode(), 10_000_000_000, 10_000, + false, )); let msg_id = get_last_message_id(); @@ -8151,6 +8344,7 @@ fn test_create_program_with_exceeding_value() { Scheme::direct(calls).encode(), 10_000_000_000, msg_value - 1, + false, )); let msg_id = get_last_message_id(); @@ -8217,6 +8411,7 @@ fn demo_constructor_works() { calls.encode(), BlockGasLimitOf::::get(), 100_000, + false, )); let message_id = get_last_message_id(); @@ -8245,6 +8440,7 @@ fn demo_constructor_works() { calls.encode(), BlockGasLimitOf::::get(), 0, + false, )); let message_id = get_last_message_id(); @@ -8296,6 +8492,7 @@ fn demo_constructor_value_eq() { calls.encode(), BlockGasLimitOf::::get(), 100_000, + false, )); run_to_next_block(None); @@ -8309,6 +8506,7 @@ fn demo_constructor_value_eq() { calls.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -8358,6 +8556,7 @@ fn demo_constructor_is_demo_ping() { b"PING".to_vec(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -8375,6 +8574,7 @@ fn demo_constructor_is_demo_ping() { vec![], BlockGasLimitOf::::get(), 0, + false, )); let reply_id = get_last_message_id(); @@ -8410,6 +8610,7 @@ fn test_reply_to_terminated_program() { payload: EMPTY_PAYLOAD.to_vec(), gas_limit: 10_000_000, value: 0, + keep_alive: false, }); assert_noop!( reply_call.dispatch(RuntimeOrigin::signed(USER_1)), @@ -8464,7 +8665,8 @@ fn delayed_sending() { DEFAULT_SALT.to_vec(), delay.to_le_bytes().to_vec(), BlockGasLimitOf::::get(), - 0 + 0, + false, )); let prog = utils::get_last_program_id(); @@ -8509,7 +8711,8 @@ fn delayed_wake() { DEFAULT_SALT.to_vec(), 0u32.to_le_bytes().to_vec(), BlockGasLimitOf::::get(), - 0 + 0, + false, )); let prog = utils::get_last_program_id(); @@ -8527,6 +8730,7 @@ fn delayed_wake() { vec![], BlockGasLimitOf::::get(), 0, + false, )); let mid = get_last_message_id(); @@ -8546,6 +8750,7 @@ fn delayed_wake() { delay.to_le_bytes().to_vec(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -8576,6 +8781,7 @@ fn cascading_messages_with_value_do_not_overcharge() { 50_u64.encode(), 10_000_000_000, 0, + false, )); assert_ok!(Gear::upload_program( @@ -8585,6 +8791,7 @@ fn cascading_messages_with_value_do_not_overcharge() { (<[u8; 32]>::from(contract_id), 0u64).encode(), 10_000_000_000, 0, + false, )); run_to_block(2, None); @@ -8638,6 +8845,7 @@ fn cascading_messages_with_value_do_not_overcharge() { payload, gas_reserved, value, + false, )); let gas_to_spend = gas_price(gas_to_spend); @@ -8778,6 +8986,7 @@ fn execution_over_blocks() { EMPTY_PAYLOAD.to_vec(), init_gas.burned, 0, + false, )); let in_one_block = get_last_program_id(); @@ -8812,6 +9021,7 @@ fn execution_over_blocks() { EMPTY_PAYLOAD.to_vec(), 5_000_000_000, 0, + false, )); let in_one_block = get_last_program_id(); @@ -8826,6 +9036,7 @@ fn execution_over_blocks() { Package::new(expected, src).encode(), block_gas_limit, 0, + false, )); run_to_next_block(Some(MAX_BLOCK)); @@ -8838,6 +9049,7 @@ fn execution_over_blocks() { Package::new(1_024, src).encode(), block_gas_limit, 0, + false, )); let message_id = get_last_message_id(); @@ -8864,6 +9076,7 @@ fn execution_over_blocks() { calc_threshold.encode(), 9_000_000_000, 0, + false, )); let over_blocks = get_last_program_id(); @@ -8878,6 +9091,7 @@ fn execution_over_blocks() { Method::Start { src, id, expected }.encode(), 9_000_000_000, 0, + false, )); run_to_next_block(Some(MAX_BLOCK)); @@ -8896,6 +9110,7 @@ fn execution_over_blocks() { Method::Refuel(id).encode(), block_gas_limit, 0, + false, )); count += 1; @@ -8962,6 +9177,7 @@ fn waking_message_waiting_for_mx_lock_does_not_lead_to_deadlock() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, ) .expect("Failed to upload Waiter"); let waiter_prog_id = get_last_program_id(); @@ -8975,6 +9191,7 @@ fn waking_message_waiting_for_mx_lock_does_not_lead_to_deadlock() { command.encode(), BlockGasLimitOf::::get(), 0, + false, ) .unwrap_or_else(|_| panic!("Failed to send command {:?} to Waiter", command)); let msg_id = get_last_message_id(); @@ -9045,6 +9262,7 @@ fn waking_message_waiting_for_rw_lock_does_not_lead_to_deadlock() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, ) .expect("Failed to upload Waiter"); let waiter_prog_id = get_last_program_id(); @@ -9058,6 +9276,7 @@ fn waking_message_waiting_for_rw_lock_does_not_lead_to_deadlock() { command.encode(), BlockGasLimitOf::::get(), 0, + false, ) .unwrap_or_else(|_| panic!("Failed to send command {:?} to Waiter", command)); let msg_id = get_last_message_id(); @@ -9175,6 +9394,7 @@ fn mx_lock_ownership_exceedance() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, ) .expect("Failed to upload Waiter"); let waiter_prog_id = get_last_program_id(); @@ -9190,6 +9410,7 @@ fn mx_lock_ownership_exceedance() { command.encode(), BlockGasLimitOf::::get(), 0, + false, ) .unwrap_or_else(|_| panic!("Failed to send command {:?} to Waiter", command)); let msg_id = get_last_message_id(); @@ -9482,6 +9703,7 @@ fn async_sleep_for() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, ) .expect("Failed to upload Waiter"); let waiter_prog_id = get_last_program_id(); @@ -9497,6 +9719,7 @@ fn async_sleep_for() { command.encode(), BlockGasLimitOf::::get(), 0, + false, ) .unwrap_or_else(|_| panic!("Failed to send command {:?} to Waiter", command)); let msg_id = get_last_message_id(); @@ -9739,6 +9962,7 @@ fn test_async_messages() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000u64, 0, + false, )); let pid = get_last_program_id(); @@ -9757,6 +9981,7 @@ fn test_async_messages() { kind.encode(), 30_000_000_000u64, 0, + false, )); // check the message sent from the program @@ -9772,6 +9997,7 @@ fn test_async_messages() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000u64, 0, + false, )); // check the reply from the program @@ -9806,6 +10032,7 @@ fn program_generator_works() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); let generator_id = get_last_program_id(); @@ -9820,6 +10047,7 @@ fn program_generator_works() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); let message_id = get_last_message_id(); @@ -9848,6 +10076,7 @@ fn wait_state_machine() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let wait_id = get_last_program_id(); @@ -9961,6 +10190,7 @@ fn missing_functions_are_not_executed() { EMPTY_PAYLOAD.to_vec(), 1_000_000_000, 0, + false, )); run_to_next_block(None); @@ -9987,6 +10217,7 @@ fn missing_functions_are_not_executed() { EMPTY_PAYLOAD.to_vec(), 100_000_000, reply_value, + false, )); run_to_next_block(None); @@ -10025,6 +10256,7 @@ fn missing_handle_is_not_executed() { EMPTY_PAYLOAD.to_vec(), 1_000_000_000, 0, + false, ) .map(|_| get_last_program_id()) .expect("submit_program failed"); @@ -10036,6 +10268,7 @@ fn missing_handle_is_not_executed() { EMPTY_PAYLOAD.to_vec(), 1_000_000_000, 0, + false, ) .map(|_| get_last_program_id()) .expect("submit_program failed"); @@ -10051,6 +10284,7 @@ fn missing_handle_is_not_executed() { EMPTY_PAYLOAD.to_vec(), 1_000_000_000, 0, + false, )); assert_ok!(Gear::send_message( @@ -10059,6 +10293,7 @@ fn missing_handle_is_not_executed() { EMPTY_PAYLOAD.to_vec(), 1_000_000_000, 0, + false, )); run_to_next_block(None); @@ -10100,6 +10335,7 @@ fn invalid_memory_page_count_rejected() { EMPTY_PAYLOAD.to_vec(), 1_000_000_000, 0, + false, ), Error::::ProgramConstructionFailed ); @@ -10132,6 +10368,7 @@ fn test_reinstrumentation_works() { vec![], 10_000_000_000, 0, + false, )); run_to_block(3, None); @@ -10146,6 +10383,7 @@ fn test_reinstrumentation_works() { vec![], 10_000_000_000, 0, + false, )); run_to_block(4, None); @@ -10216,6 +10454,7 @@ fn send_from_reservation() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -10227,6 +10466,7 @@ fn send_from_reservation() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -10240,6 +10480,7 @@ fn send_from_reservation() { HandleAction::SendToUser.encode(), 10_000_000_000, 1_000, + false, )); run_to_block(3, None); @@ -10264,6 +10505,7 @@ fn send_from_reservation() { .encode(), 10_000_000_000, 1_000, + false, )); let mid = get_last_message_id(); @@ -10288,6 +10530,7 @@ fn send_from_reservation() { HandleAction::SendToUserDelayed.encode(), 10_000_000_000, 1_000, + false, )); run_to_block(5, None); @@ -10316,6 +10559,7 @@ fn send_from_reservation() { .encode(), 10_000_000_000, 1_000, + false, )); let mid = get_last_message_id(); @@ -10349,6 +10593,7 @@ fn reply_from_reservation() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -10360,6 +10605,7 @@ fn reply_from_reservation() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -10373,6 +10619,7 @@ fn reply_from_reservation() { HandleAction::ReplyToUser.encode(), 30_000_000_000, 1_000, + false, )); run_to_block(3, None); @@ -10397,6 +10644,7 @@ fn reply_from_reservation() { .encode(), 30_000_000_000, 1_000, + false, )); let mid = get_last_message_id(); @@ -10427,6 +10675,7 @@ fn signal_recursion_not_occurs() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -10442,6 +10691,7 @@ fn signal_recursion_not_occurs() { HandleAction::PanicInSignal.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -10499,6 +10749,7 @@ fn signal_during_precharge() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -10511,6 +10762,7 @@ fn signal_during_precharge() { HandleAction::WaitWithReserveAmountAndPanic(1).encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -10527,6 +10779,7 @@ fn signal_during_precharge() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); run_to_block(4, None); @@ -10561,6 +10814,7 @@ fn signal_during_prepare() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -10580,6 +10834,7 @@ fn signal_during_prepare() { HandleAction::WaitWithReserveAmountAndPanic(program_gas).encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -10596,6 +10851,7 @@ fn signal_during_prepare() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); run_to_block(4, None); @@ -10630,6 +10886,7 @@ fn signal_async_wait_works() { InitAction::None.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -10658,6 +10915,7 @@ fn signal_async_wait_works() { EMPTY_PAYLOAD.to_vec(), gas_spent, 0, + false, )); let mid = get_last_message_id(); @@ -10716,6 +10974,7 @@ fn signal_run_out_of_gas_memory_access_works() { USER_1.encode(), GAS_LIMIT, 0, + false, )); let pid = get_last_program_id(); @@ -10733,6 +10992,7 @@ fn signal_run_out_of_gas_memory_access_works() { HandleAction::SaveSignal(SimpleExecutionError::RanOutOfGas.into()).encode(), GAS_LIMIT, 0, + false, )); run_to_next_block(None); @@ -10755,6 +11015,7 @@ fn signal_run_out_of_gas_memory_access_works() { demo_signal_entry::HandleAction::MemoryAccess.encode(), min_limit - 1, 0, + false, )); let mid = get_last_message_id(); @@ -10843,6 +11104,7 @@ fn signal_removed_from_waitlist_works() { USER_1.encode(), GAS_LIMIT, 0, + false, )); let pid = get_last_program_id(); @@ -10860,6 +11122,7 @@ fn signal_removed_from_waitlist_works() { HandleAction::SaveSignal(SignalCode::RemovedFromWaitlist).encode(), GAS_LIMIT, 0, + false, )); run_to_next_block(None); @@ -10871,6 +11134,7 @@ fn signal_removed_from_waitlist_works() { HandleAction::WaitWithoutSendingMessage.encode(), GAS_LIMIT, 0, + false, )); let mid = get_last_message_id(); @@ -10909,6 +11173,7 @@ fn system_reservation_unreserve_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -10933,6 +11198,7 @@ fn system_reservation_unreserve_works() { HandleAction::Simple.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -10962,6 +11228,7 @@ fn few_system_reservations_across_waits_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -10974,6 +11241,7 @@ fn few_system_reservations_across_waits_works() { HandleAction::AcrossWaits.encode(), 30_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -10992,6 +11260,7 @@ fn few_system_reservations_across_waits_works() { EMPTY_PAYLOAD.to_vec(), 30_000_000_000, 0, + false, )); run_to_next_block(None); @@ -11012,6 +11281,7 @@ fn system_reservation_panic_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11024,6 +11294,7 @@ fn system_reservation_panic_works() { HandleAction::Panic.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11051,6 +11322,7 @@ fn system_reservation_exit_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11063,6 +11335,7 @@ fn system_reservation_exit_works() { HandleAction::Exit.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11092,6 +11365,7 @@ fn system_reservation_wait_and_panic_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11104,6 +11378,7 @@ fn system_reservation_wait_and_panic_works() { HandleAction::WaitAndPanic.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11120,6 +11395,7 @@ fn system_reservation_wait_and_panic_works() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); run_to_block(4, None); @@ -11141,6 +11417,7 @@ fn system_reservation_wait_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11153,6 +11430,7 @@ fn system_reservation_wait_works() { HandleAction::Wait.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11200,6 +11478,7 @@ fn system_reservation_wait_and_exit_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11212,6 +11491,7 @@ fn system_reservation_wait_and_exit_works() { HandleAction::WaitAndExit.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11228,6 +11508,7 @@ fn system_reservation_wait_and_exit_works() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); run_to_block(4, None); @@ -11253,6 +11534,7 @@ fn system_reservation_wait_and_reserve_with_panic_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11265,6 +11547,7 @@ fn system_reservation_wait_and_reserve_with_panic_works() { HandleAction::WaitAndReserveWithPanic.encode(), 30_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11283,6 +11566,7 @@ fn system_reservation_wait_and_reserve_with_panic_works() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); run_to_block(4, None); @@ -11308,6 +11592,7 @@ fn system_reservation_accumulate_works() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11320,6 +11605,7 @@ fn system_reservation_accumulate_works() { HandleAction::Accumulate.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11345,6 +11631,7 @@ fn system_reservation_zero_amount_panics() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11357,6 +11644,7 @@ fn system_reservation_zero_amount_panics() { HandleAction::ZeroReserve.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11386,6 +11674,7 @@ fn gas_reservation_works() { .encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11417,6 +11706,7 @@ fn gas_reservation_works() { HandleAction::Unreserve.encode(), spent_gas, 0, + false, )); run_to_block(3, None); @@ -11458,6 +11748,7 @@ fn gas_reservation_works() { HandleAction::Exit.encode(), 50_000_000_000, 0, + false, )); run_to_block(2 + 4, None); @@ -11482,6 +11773,7 @@ fn gas_reservations_cleaned_in_terminated_program() { InitAction::Wait.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11506,6 +11798,7 @@ fn gas_reservations_cleaned_in_terminated_program() { ReplyAction::Panic.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_block(3, None); @@ -11531,6 +11824,7 @@ fn gas_reservation_wait_wake_exit() { InitAction::Wait.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11555,6 +11849,7 @@ fn gas_reservation_wait_wake_exit() { ReplyAction::Exit.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_block(3, None); @@ -11583,6 +11878,7 @@ fn gas_reservations_check_params() { .encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11606,6 +11902,7 @@ fn gas_reservations_fresh_reserve_unreserve() { InitAction::FreshReserveUnreserve.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11630,6 +11927,7 @@ fn gas_reservations_existing_reserve_unreserve() { InitAction::Normal(vec![]).encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); let pid = get_last_program_id(); @@ -11644,6 +11942,7 @@ fn gas_reservations_existing_reserve_unreserve() { HandleAction::SendFromReservationAndUnreserve.encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11669,6 +11968,7 @@ fn custom_async_entrypoint_works() { USER_1.encode(), 30_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11681,6 +11981,7 @@ fn custom_async_entrypoint_works() { EMPTY_PAYLOAD.to_vec(), 30_000_000_000, 0, + false, )); run_to_block(3, None); @@ -11694,6 +11995,7 @@ fn custom_async_entrypoint_works() { EMPTY_PAYLOAD.to_vec(), 30_000_000_000, 0, + false, )); run_to_block(4, None); @@ -11716,6 +12018,7 @@ fn dispatch_kind_forbidden_function() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11731,6 +12034,7 @@ fn dispatch_kind_forbidden_function() { HandleAction::ForbiddenCallInSignal(USER_1.into_origin().into()).encode(), 10_000_000_000, 0, + false, )); let mid = get_last_message_id(); @@ -11788,6 +12092,7 @@ fn system_reservation_gas_allowance_rollbacks() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11810,6 +12115,7 @@ fn system_reservation_gas_allowance_rollbacks() { HandleAction::Simple.encode(), min_limit, 0, + false, )); let mid = get_last_message_id(); @@ -11833,6 +12139,7 @@ fn system_reservation_wait_and_exit_across_executions() { USER_1.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11845,6 +12152,7 @@ fn system_reservation_wait_and_exit_across_executions() { HandleAction::Wait.encode(), 10_000_000_000, 0, + false, )); let mid_wait = get_last_message_id(); @@ -11859,6 +12167,7 @@ fn system_reservation_wait_and_exit_across_executions() { HandleAction::Exit.encode(), 10_000_000_000, 0, + false, )); let mid_exit = get_last_message_id(); @@ -11908,6 +12217,7 @@ fn signal_on_uninitialized_program() { InitAction::Panic.encode(), 10_000_000_000, 0, + false, )); let pid = get_last_program_id(); @@ -11927,6 +12237,7 @@ fn signal_on_uninitialized_program() { EMPTY_PAYLOAD.to_vec(), 10_000_000_000, 0, + false, )); let reply_mid = get_last_message_id(); @@ -11958,6 +12269,7 @@ fn missing_block_tasks_handled() { vec![], 100_000_000, 1000, + false, )); run_to_block(N - 1, None); @@ -12008,6 +12320,7 @@ fn async_does_not_duplicate_sync() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let ping = get_last_program_id(); @@ -12019,6 +12332,7 @@ fn async_does_not_duplicate_sync() { ping.encode(), BlockGasLimitOf::::get(), 0, + false, )); let sync = get_last_program_id(); @@ -12031,6 +12345,7 @@ fn async_does_not_duplicate_sync() { b"async".to_vec(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -12055,6 +12370,7 @@ fn state_rollback() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let rollback = get_last_program_id(); @@ -12124,6 +12440,7 @@ fn incomplete_async_payloads_kept() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let ping = get_last_program_id(); @@ -12135,6 +12452,7 @@ fn incomplete_async_payloads_kept() { ping.encode(), BlockGasLimitOf::::get(), 0, + false, )); let incomplete = get_last_program_id(); @@ -12189,6 +12507,7 @@ fn rw_lock_works() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let ping = get_last_program_id(); @@ -12200,6 +12519,7 @@ fn rw_lock_works() { ping.encode(), BlockGasLimitOf::::get(), 0, + false, )); let prog_id = get_last_program_id(); @@ -12319,6 +12639,7 @@ fn async_works() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let ping = get_last_program_id(); @@ -12330,6 +12651,7 @@ fn async_works() { ping.encode(), BlockGasLimitOf::::get(), 0, + false, )); let prog_id = get_last_program_id(); @@ -12383,6 +12705,7 @@ fn futures_unordered() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let ping = get_last_program_id(); @@ -12394,6 +12717,7 @@ fn futures_unordered() { ping.encode(), BlockGasLimitOf::::get(), 0, + false, )); let demo_async = get_last_program_id(); @@ -12405,6 +12729,7 @@ fn futures_unordered() { (demo_async, ping).encode(), BlockGasLimitOf::::get(), 0, + false, )); let prog_id = get_last_program_id(); @@ -12477,6 +12802,7 @@ fn async_recursion() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let ping = get_last_program_id(); @@ -12488,6 +12814,7 @@ fn async_recursion() { ping.encode(), BlockGasLimitOf::::get(), 0, + false, )); let prog_id = get_last_program_id(); @@ -12534,6 +12861,7 @@ fn async_init() { Default::default(), BlockGasLimitOf::::get(), 0, + false, )); let ping = get_last_program_id(); @@ -12545,6 +12873,7 @@ fn async_init() { InputArgs::from_two(ping, ping).encode(), BlockGasLimitOf::::get(), 0, + false, )); get_last_program_id() @@ -12593,6 +12922,7 @@ fn check_gear_stack_end_fail() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .expect("Failed to upload program"); @@ -12619,6 +12949,7 @@ fn check_gear_stack_end_fail() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .expect("Failed to upload program"); @@ -12642,6 +12973,7 @@ fn check_gear_stack_end_fail() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .expect("Failed to upload program"); @@ -12684,6 +13016,7 @@ fn check_gr_read_error_works() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .expect("Failed to upload program"); @@ -12734,6 +13067,7 @@ fn check_reply_push_payload_exceed() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .expect("Failed to upload program"); @@ -12783,6 +13117,7 @@ fn check_random_works() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .expect("Failed to upload program"); @@ -12797,6 +13132,7 @@ fn check_random_works() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, )); let output: ([u8; 32], BlockNumber) = @@ -12843,7 +13179,8 @@ fn reply_with_small_non_zero_gas() { DEFAULT_SALT.to_vec(), RelayCall::RereplyWithGas(gas_limit).encode(), 50_000_000_000, - 0u128 + 0u128, + false, )); let proxy = utils::get_last_program_id(); @@ -12859,6 +13196,7 @@ fn reply_with_small_non_zero_gas() { payload.to_vec(), DEFAULT_GAS_LIMIT * 10, 0, + false, )); let message_id = utils::get_last_message_id(); @@ -12889,7 +13227,8 @@ fn replies_denied_in_handle_reply() { } .encode(), 50_000_000_000, - 0u128 + 0u128, + false, )); let proxy = utils::get_last_program_id(); @@ -12900,6 +13239,7 @@ fn replies_denied_in_handle_reply() { vec![], 50_000_000_000, 0, + false, )); let message_id = get_last_message_id(); @@ -12914,6 +13254,7 @@ fn replies_denied_in_handle_reply() { vec![], 50_000_000_000, 0, + false, )); let reply_id = get_last_message_id(); @@ -12951,7 +13292,8 @@ fn relay_messages() { vec![], relay_call.encode(), 50_000_000_000u64, - 0u128 + 0u128, + false, ) .is_ok(), "{}", @@ -12971,6 +13313,7 @@ fn relay_messages() { payload.to_vec(), DEFAULT_GAS_LIMIT * 10, 0, + false, ) .is_ok(), "{}", @@ -13147,6 +13490,7 @@ fn module_instantiation_error() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .map(|_| prog_id); let mid = get_last_message_id(); @@ -13181,6 +13525,7 @@ fn wrong_entry_type() { EMPTY_PAYLOAD.to_vec(), 50_000_000_000, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -13207,6 +13552,7 @@ fn oom_handler_works() { EMPTY_PAYLOAD.to_vec(), 100_000_000_000_u64, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -13249,6 +13595,7 @@ fn alloc_charge_error() { EMPTY_PAYLOAD.to_vec(), 500_000_000_u64, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -13293,6 +13640,7 @@ fn free_usage_error() { EMPTY_PAYLOAD.to_vec(), 500_000_000_u64, 0, + false, ) .map(|_| get_last_program_id()) .unwrap(); @@ -13353,6 +13701,7 @@ fn calculate_gas_fails_when_calculation_limit_exceeded() { Init::Normal(vec![]).encode(), BlockGasLimitOf::::get(), 0, + false, ) .map(|_| get_last_program_id()) .expect("Program uploading failed"); @@ -13369,6 +13718,7 @@ fn calculate_gas_fails_when_calculation_limit_exceeded() { .encode(), BlockGasLimitOf::::get(), 0, + false, ) .expect("Making reservation failed"); } @@ -13420,6 +13770,7 @@ fn reservation_manager() { vec![], BlockGasLimitOf::::get(), 0, + false, ) .map(|_| get_last_program_id()) .expect("Program uploading failed"); @@ -13435,6 +13786,7 @@ fn reservation_manager() { payload.encode(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -13553,7 +13905,8 @@ fn send_gasless_message_works() { destination: program_id, payload: EMPTY_PAYLOAD.to_vec(), gas_limit: DEFAULT_GAS_LIMIT, - value: 0 + value: 0, + keep_alive: false, } ), Error::::FailureRedeemingVoucher @@ -13594,7 +13947,8 @@ fn send_gasless_message_works() { destination: program_id, payload: EMPTY_PAYLOAD.to_vec(), gas_limit: DEFAULT_GAS_LIMIT, - value: 1_000_000 + value: 1_000_000, + keep_alive: false, } )); @@ -13679,7 +14033,8 @@ fn send_gasless_reply_works() { reply_to_id, payload: EMPTY_PAYLOAD.to_vec(), gas_limit, - value: 1_000 + value: 1_000, + keep_alive: false, } )); let expected_reply_message_id = get_last_message_id(); @@ -13746,6 +14101,7 @@ fn double_read_works() { b"PAYLOAD".to_vec(), BlockGasLimitOf::::get(), 100_000, + false, )); run_to_next_block(None); @@ -13840,6 +14196,7 @@ fn test_gas_allowance_exceed_with_context() { calls.encode(), BlockGasLimitOf::::get(), 0, + false, )); let msg_id = get_last_message_id(); run_to_next_block(allowance); @@ -13991,6 +14348,7 @@ fn test_send_to_terminated_from_program() { EMPTY_PAYLOAD.to_vec(), BlockGasLimitOf::::get(), 0, + false, )); run_to_next_block(None); @@ -14030,7 +14388,8 @@ fn pause_waited_uninited_program() { current_gas.to_le_bytes().to_vec(), Vec::new(), current_gas, - 0u128 + 0u128, + false, )); let program_id = utils::get_last_program_id(); @@ -14088,7 +14447,8 @@ fn pause_waited_uninited_program() { vec![], Vec::new(), gas, - 0u128 + 0u128, + false, )); let program_id = utils::get_last_program_id(); @@ -14170,6 +14530,7 @@ fn remove_from_waitlist_after_exit_reply() { vec![], 1_000_000_000, 0, + false, )); run_to_next_block(None); @@ -14381,6 +14742,7 @@ mod utils { scheme.encode(), min_limit, value, + false, )); (get_last_message_id(), get_last_program_id()) @@ -14444,6 +14806,7 @@ mod utils { payload, limit, value, + false, )); let message_id = get_last_message_id(); @@ -14539,6 +14902,7 @@ mod utils { Vec::new(), gas_limit, // `prog_id` program sends message in handle which sets gas limit to 10_000_000. value, + false, )); let message_id = get_last_message_id(); @@ -14614,6 +14978,7 @@ mod utils { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, 0, + false, ) .map(|_| get_last_program_id()) } @@ -14636,6 +15001,7 @@ mod utils { EMPTY_PAYLOAD.to_vec(), DEFAULT_GAS_LIMIT, 0, + false, ) } @@ -14645,6 +15011,7 @@ mod utils { payload: EMPTY_PAYLOAD.to_vec(), gas_limit: DEFAULT_GAS_LIMIT, value: 0, + keep_alive: false, }) } @@ -15115,6 +15482,7 @@ mod utils { payload, BlockGasLimitOf::::get(), 0, + false, )); get_last_message_id() @@ -15173,6 +15541,7 @@ mod utils { USER_1.encode(), GAS_LIMIT, 0, + false, )); let pid = get_last_program_id(); @@ -15190,6 +15559,7 @@ mod utils { HandleAction::SaveSignal(signal_code).encode(), GAS_LIMIT, 0, + false, )); run_to_next_block(None); @@ -15201,6 +15571,7 @@ mod utils { action.encode(), GAS_LIMIT, 0, + false, )); let mid = get_last_message_id(); diff --git a/pallets/payment/src/tests.rs b/pallets/payment/src/tests.rs index de712b3e193..067c4db71a4 100644 --- a/pallets/payment/src/tests.rs +++ b/pallets/payment/src/tests.rs @@ -218,6 +218,7 @@ fn mq_size_affecting_fee_works() { payload: Default::default(), gas_limit: 100_000, value: 0, + keep_alive: false, }); let len = 100usize; @@ -398,6 +399,7 @@ fn query_info_and_fee_details_work() { payload: Default::default(), gas_limit: 100_000, value: 0, + keep_alive: false, }); let call_not_affecting_mq = RuntimeCall::Gear(pallet_gear::Call::claim_value { message_id: 1.into(), @@ -575,6 +577,7 @@ fn fee_payer_replacement_works() { payload: Default::default(), gas_limit: 100_000, value: 0, + keep_alive: false, }, }); @@ -665,6 +668,7 @@ fn reply_with_voucher_pays_fee_from_voucher_ok() { payload: vec![], gas_limit, value: 0, + keep_alive: false, }, }); diff --git a/runtime/vara/src/integration_tests.rs b/runtime/vara/src/integration_tests.rs index ab5e6b3e4b9..d99c8755c49 100644 --- a/runtime/vara/src/integration_tests.rs +++ b/runtime/vara/src/integration_tests.rs @@ -334,6 +334,7 @@ fn tokens_locking_works() { vec![], 10_000_000_000, 10_000 * UNITS, + false, ), pallet_gear_bank::Error::::InsufficientBalance ); @@ -352,6 +353,7 @@ fn tokens_locking_works() { vec![], 10_000_000_000, 0, + false, )); let program_id = get_last_program_id(); @@ -366,6 +368,7 @@ fn tokens_locking_works() { vec![], 10_000_000_000, 11_000 * UNITS, + false, ), pallet_gear_bank::Error::::InsufficientBalance ); diff --git a/utils/runtime-fuzzer/src/lib.rs b/utils/runtime-fuzzer/src/lib.rs index a877e90f29b..1c2b4be4f37 100644 --- a/utils/runtime-fuzzer/src/lib.rs +++ b/utils/runtime-fuzzer/src/lib.rs @@ -117,6 +117,7 @@ fn execute_gear_call(sender: AccountId, call: GearCall) -> DispatchResultWithPos payload, gas_limit, value, + false, ) } GearCall::SendMessage(args) => { @@ -127,6 +128,7 @@ fn execute_gear_call(sender: AccountId, call: GearCall) -> DispatchResultWithPos payload, gas_limit, value, + false, ) } GearCall::SendReply(args) => { @@ -137,6 +139,7 @@ fn execute_gear_call(sender: AccountId, call: GearCall) -> DispatchResultWithPos payload, gas_limit, value, + false, ) } GearCall::ClaimValue(args) => {