mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 05:11:02 +00:00
contracts: Upgrade to wasmi 0.28 (#13312)
* Upgrade to wasmi 0.28 * ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_contracts * Update stale comment * Renamed variants of `Determinism` * Compile fix --------- Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
d5650ba07b
commit
82cb69922f
@@ -529,7 +529,7 @@ fn instantiate_and_call_and_deposit_event() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
));
|
||||
|
||||
// Drop previous events
|
||||
@@ -726,13 +726,8 @@ fn instantiate_unique_trie_id() {
|
||||
|
||||
ExtBuilder::default().existential_deposit(500).build().execute_with(|| {
|
||||
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
|
||||
Contracts::upload_code(
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
None,
|
||||
Determinism::Deterministic,
|
||||
)
|
||||
.unwrap();
|
||||
Contracts::upload_code(RuntimeOrigin::signed(ALICE), wasm, None, Determinism::Enforced)
|
||||
.unwrap();
|
||||
|
||||
// Instantiate the contract and store its trie id for later comparison.
|
||||
let addr = Contracts::bare_instantiate(
|
||||
@@ -860,7 +855,7 @@ fn deploy_and_call_other_contract() {
|
||||
.result
|
||||
.unwrap()
|
||||
.account_id;
|
||||
Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Deterministic).unwrap();
|
||||
Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Enforced).unwrap();
|
||||
|
||||
let callee_addr = Contracts::contract_address(
|
||||
&caller_addr,
|
||||
@@ -1011,7 +1006,7 @@ fn delegate_call() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
callee_wasm,
|
||||
Some(codec::Compact(100_000)),
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
));
|
||||
|
||||
assert_ok!(Contracts::call(
|
||||
@@ -1321,7 +1316,7 @@ fn destroy_contract_and_transfer_funds() {
|
||||
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
|
||||
// Create code hash for bob to instantiate
|
||||
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
|
||||
Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Deterministic).unwrap();
|
||||
Contracts::bare_upload_code(ALICE, callee_wasm, None, Determinism::Enforced).unwrap();
|
||||
|
||||
// This deploys the BOB contract, which in turn deploys the CHARLIE contract during
|
||||
// construction.
|
||||
@@ -1431,7 +1426,7 @@ fn crypto_hashes() {
|
||||
None,
|
||||
params,
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1473,7 +1468,7 @@ fn transfer_return_code() {
|
||||
None,
|
||||
vec![],
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1514,7 +1509,7 @@ fn call_return_code() {
|
||||
None,
|
||||
AsRef::<[u8]>::as_ref(&DJANGO).to_vec(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1548,7 +1543,7 @@ fn call_return_code() {
|
||||
.cloned()
|
||||
.collect(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1568,7 +1563,7 @@ fn call_return_code() {
|
||||
.cloned()
|
||||
.collect(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1587,7 +1582,7 @@ fn call_return_code() {
|
||||
.cloned()
|
||||
.collect(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1639,7 +1634,7 @@ fn instantiate_return_code() {
|
||||
None,
|
||||
callee_hash.clone(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1655,7 +1650,7 @@ fn instantiate_return_code() {
|
||||
None,
|
||||
vec![0; 33],
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1670,7 +1665,7 @@ fn instantiate_return_code() {
|
||||
None,
|
||||
callee_hash.iter().chain(&1u32.to_le_bytes()).cloned().collect(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1685,7 +1680,7 @@ fn instantiate_return_code() {
|
||||
None,
|
||||
callee_hash.iter().chain(&2u32.to_le_bytes()).cloned().collect(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1772,7 +1767,7 @@ fn chain_extension_works() {
|
||||
None,
|
||||
input.clone(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert_eq!(TestExtension::last_seen_buffer(), input);
|
||||
assert_eq!(result.result.unwrap().data, input);
|
||||
@@ -1786,7 +1781,7 @@ fn chain_extension_works() {
|
||||
None,
|
||||
ExtensionInput { extension_id: 0, func_id: 1, extra: &[] }.into(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1802,7 +1797,7 @@ fn chain_extension_works() {
|
||||
None,
|
||||
ExtensionInput { extension_id: 0, func_id: 2, extra: &[0] }.into(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert_ok!(result.result);
|
||||
let gas_consumed = result.gas_consumed;
|
||||
@@ -1814,7 +1809,7 @@ fn chain_extension_works() {
|
||||
None,
|
||||
ExtensionInput { extension_id: 0, func_id: 2, extra: &[42] }.into(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert_ok!(result.result);
|
||||
assert_eq!(result.gas_consumed.ref_time(), gas_consumed.ref_time() + 42);
|
||||
@@ -1826,7 +1821,7 @@ fn chain_extension_works() {
|
||||
None,
|
||||
ExtensionInput { extension_id: 0, func_id: 2, extra: &[95] }.into(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert_ok!(result.result);
|
||||
assert_eq!(result.gas_consumed.ref_time(), gas_consumed.ref_time() + 95);
|
||||
@@ -1840,7 +1835,7 @@ fn chain_extension_works() {
|
||||
None,
|
||||
ExtensionInput { extension_id: 0, func_id: 3, extra: &[] }.into(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1858,7 +1853,7 @@ fn chain_extension_works() {
|
||||
None,
|
||||
ExtensionInput { extension_id: 1, func_id: 0, extra: &[] }.into(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -1919,7 +1914,7 @@ fn chain_extension_temp_storage_works() {
|
||||
None,
|
||||
input.clone(),
|
||||
false,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
)
|
||||
.result
|
||||
);
|
||||
@@ -2480,7 +2475,7 @@ fn reinstrument_does_charge() {
|
||||
None,
|
||||
zero.clone(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert!(!result0.result.unwrap().did_revert());
|
||||
|
||||
@@ -2492,7 +2487,7 @@ fn reinstrument_does_charge() {
|
||||
None,
|
||||
zero.clone(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert!(!result1.result.unwrap().did_revert());
|
||||
|
||||
@@ -2514,7 +2509,7 @@ fn reinstrument_does_charge() {
|
||||
None,
|
||||
zero.clone(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert!(!result2.result.unwrap().did_revert());
|
||||
assert!(result2.gas_consumed.ref_time() > result1.gas_consumed.ref_time());
|
||||
@@ -2553,7 +2548,7 @@ fn debug_message_works() {
|
||||
None,
|
||||
vec![],
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
|
||||
assert_matches!(result.result, Ok(_));
|
||||
@@ -2589,7 +2584,7 @@ fn debug_message_logging_disabled() {
|
||||
None,
|
||||
vec![],
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert_matches!(result.result, Ok(_));
|
||||
// the dispatchables always run without debugging
|
||||
@@ -2625,7 +2620,7 @@ fn debug_message_invalid_utf8() {
|
||||
None,
|
||||
vec![],
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert_ok!(result.result);
|
||||
assert!(result.debug_message.is_empty());
|
||||
@@ -2684,7 +2679,7 @@ fn gas_estimation_nested_call_fixed_limit() {
|
||||
None,
|
||||
input.clone(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
assert_ok!(&result.result);
|
||||
|
||||
@@ -2701,7 +2696,7 @@ fn gas_estimation_nested_call_fixed_limit() {
|
||||
Some(result.storage_deposit.charge_or_zero()),
|
||||
input,
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
);
|
||||
@@ -2760,7 +2755,7 @@ fn gas_estimation_call_runtime() {
|
||||
None,
|
||||
call.encode(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
);
|
||||
// contract encodes the result of the dispatch runtime
|
||||
let outcome = u32::decode(&mut result.result.unwrap().data.as_ref()).unwrap();
|
||||
@@ -2777,7 +2772,7 @@ fn gas_estimation_call_runtime() {
|
||||
None,
|
||||
call.encode(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
);
|
||||
@@ -2840,7 +2835,7 @@ fn gas_call_runtime_reentrancy_guarded() {
|
||||
None,
|
||||
call.encode(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -2902,7 +2897,7 @@ fn ecdsa_recover() {
|
||||
None,
|
||||
params,
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -2926,7 +2921,7 @@ fn upload_code_works() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
Some(codec::Compact(1_000)),
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
));
|
||||
assert!(<CodeStorage<Test>>::contains_key(code_hash));
|
||||
|
||||
@@ -2966,7 +2961,7 @@ fn upload_code_limit_too_low() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
Some(codec::Compact(100)),
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
),
|
||||
<Error<Test>>::StorageDepositLimitExhausted,
|
||||
);
|
||||
@@ -2990,7 +2985,7 @@ fn upload_code_not_enough_balance() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
Some(codec::Compact(1_000)),
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
),
|
||||
<Error<Test>>::StorageDepositNotEnoughFunds,
|
||||
);
|
||||
@@ -3013,7 +3008,7 @@ fn remove_code_works() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
Some(codec::Compact(1_000)),
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
));
|
||||
|
||||
assert!(<CodeStorage<Test>>::contains_key(code_hash));
|
||||
@@ -3068,7 +3063,7 @@ fn remove_code_wrong_origin() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
Some(codec::Compact(1_000)),
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
));
|
||||
|
||||
assert_noop!(
|
||||
@@ -3538,7 +3533,7 @@ fn set_code_extrinsic() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
new_wasm,
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
));
|
||||
|
||||
// Drop previous events
|
||||
@@ -3658,7 +3653,7 @@ fn contract_reverted() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm.clone(),
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
));
|
||||
|
||||
// Calling extrinsic: revert leads to an error
|
||||
@@ -3746,7 +3741,7 @@ fn contract_reverted() {
|
||||
None,
|
||||
input,
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -3766,7 +3761,7 @@ fn code_rejected_error_works() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm.clone(),
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
@@ -3792,7 +3787,7 @@ fn code_rejected_error_works() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm.clone(),
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
@@ -3842,7 +3837,7 @@ fn set_code_hash() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
new_wasm.clone(),
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
));
|
||||
|
||||
System::reset_events();
|
||||
@@ -3856,7 +3851,7 @@ fn set_code_hash() {
|
||||
None,
|
||||
new_code_hash.as_ref().to_vec(),
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -3871,7 +3866,7 @@ fn set_code_hash() {
|
||||
None,
|
||||
vec![],
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -4268,7 +4263,7 @@ fn cannot_instantiate_indeterministic_code() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm.clone(),
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
Determinism::Enforced
|
||||
),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
@@ -4278,7 +4273,7 @@ fn cannot_instantiate_indeterministic_code() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
None,
|
||||
Determinism::AllowIndeterminism,
|
||||
Determinism::Relaxed,
|
||||
));
|
||||
assert_err_ignore_postinfo!(
|
||||
Contracts::instantiate(
|
||||
@@ -4332,7 +4327,7 @@ fn cannot_instantiate_indeterministic_code() {
|
||||
None,
|
||||
code_hash.encode(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result,
|
||||
<Error<Test>>::Indeterministic,
|
||||
@@ -4348,7 +4343,7 @@ fn cannot_instantiate_indeterministic_code() {
|
||||
None,
|
||||
code_hash.encode(),
|
||||
false,
|
||||
Determinism::AllowIndeterminism,
|
||||
Determinism::Relaxed,
|
||||
)
|
||||
.result,
|
||||
<Error<Test>>::Indeterministic,
|
||||
@@ -4368,7 +4363,7 @@ fn cannot_set_code_indeterministic_code() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
None,
|
||||
Determinism::AllowIndeterminism,
|
||||
Determinism::Relaxed,
|
||||
));
|
||||
|
||||
// Create the contract that will call `seal_set_code_hash`
|
||||
@@ -4396,7 +4391,7 @@ fn cannot_set_code_indeterministic_code() {
|
||||
None,
|
||||
code_hash.encode(),
|
||||
false,
|
||||
Determinism::AllowIndeterminism,
|
||||
Determinism::Relaxed,
|
||||
)
|
||||
.result,
|
||||
<Error<Test>>::Indeterministic,
|
||||
@@ -4416,7 +4411,7 @@ fn delegate_call_indeterministic_code() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm,
|
||||
None,
|
||||
Determinism::AllowIndeterminism,
|
||||
Determinism::Relaxed,
|
||||
));
|
||||
|
||||
// Create the contract that will call `seal_delegate_call`
|
||||
@@ -4444,7 +4439,7 @@ fn delegate_call_indeterministic_code() {
|
||||
None,
|
||||
code_hash.encode(),
|
||||
false,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result,
|
||||
<Error<Test>>::Indeterministic,
|
||||
@@ -4460,7 +4455,7 @@ fn delegate_call_indeterministic_code() {
|
||||
None,
|
||||
code_hash.encode(),
|
||||
false,
|
||||
Determinism::AllowIndeterminism,
|
||||
Determinism::Relaxed,
|
||||
)
|
||||
.result
|
||||
);
|
||||
@@ -4499,7 +4494,7 @@ fn reentrance_count_works_with_call() {
|
||||
None,
|
||||
input,
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -4538,7 +4533,7 @@ fn reentrance_count_works_with_delegated_call() {
|
||||
None,
|
||||
input,
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -4590,7 +4585,7 @@ fn account_reentrance_count_works() {
|
||||
None,
|
||||
contract_addr.encode(),
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
@@ -4603,7 +4598,7 @@ fn account_reentrance_count_works() {
|
||||
None,
|
||||
another_contract_addr.encode(),
|
||||
true,
|
||||
Determinism::Deterministic,
|
||||
Determinism::Enforced,
|
||||
)
|
||||
.result
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user