mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 01:57:56 +00:00
contracts: Replace sp-sandbox and wasmi-validation by newest wasmi (#12501)
* Replace sp-sandbox and wasmi-validation by just wasmi * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Re-check original code on re-instrumentation * Fix clippy * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Apply suggestions from code review Co-authored-by: Robin Freyler <robin.freyler@gmail.com> * Replace wasmi by ::wasmi * Bump wasmi to 0.20 * Add explanation for `unreachable` * Change proof * Fixup master merge * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Fixup naming inconsistencies introduced by reentrancy PR * Fix `scan_imports` docs * Apply suggestions from code review Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * Fixup suggestions * Remove unnecessary &mut * Fix test * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Fix benchmark merge fail * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts * Fix docs as suggested by code review * Improve docs for `CodeRejected` * Apply suggestions from code review Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * Fix logic bug when setting `deterministic_only` * Don't panic when module fails to compile * Apply suggestions from code review Co-authored-by: Robin Freyler <robin.freyler@gmail.com> Co-authored-by: command-bot <> Co-authored-by: Robin Freyler <robin.freyler@gmail.com> Co-authored-by: Sasha Gryaznov <hi@agryaznov.com>
This commit is contained in:
committed by
GitHub
parent
e69c3649b5
commit
08657f14b7
@@ -514,7 +514,7 @@ fn calling_plain_account_fails() {
|
||||
|
||||
#[test]
|
||||
fn instantiate_and_call_and_deposit_event() {
|
||||
let (wasm, code_hash) = compile_module::<Test>("return_from_start_fn").unwrap();
|
||||
let (wasm, code_hash) = compile_module::<Test>("event_and_return_on_deploy").unwrap();
|
||||
|
||||
ExtBuilder::default().existential_deposit(500).build().execute_with(|| {
|
||||
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
|
||||
@@ -3720,10 +3720,36 @@ fn contract_reverted() {
|
||||
|
||||
#[test]
|
||||
fn code_rejected_error_works() {
|
||||
let (wasm, _) = compile_module::<Test>("invalid_import").unwrap();
|
||||
ExtBuilder::default().existential_deposit(200).build().execute_with(|| {
|
||||
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
|
||||
|
||||
let (wasm, _) = compile_module::<Test>("invalid_module").unwrap();
|
||||
assert_noop!(
|
||||
Contracts::upload_code(
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
wasm.clone(),
|
||||
None,
|
||||
Determinism::Deterministic
|
||||
),
|
||||
<Error<Test>>::CodeRejected,
|
||||
);
|
||||
let result = Contracts::bare_instantiate(
|
||||
ALICE,
|
||||
0,
|
||||
GAS_LIMIT,
|
||||
None,
|
||||
Code::Upload(wasm),
|
||||
vec![],
|
||||
vec![],
|
||||
true,
|
||||
);
|
||||
assert_err!(result.result, <Error<Test>>::CodeRejected);
|
||||
assert_eq!(
|
||||
std::str::from_utf8(&result.debug_message).unwrap(),
|
||||
"validation of new code failed"
|
||||
);
|
||||
|
||||
let (wasm, _) = compile_module::<Test>("invalid_contract").unwrap();
|
||||
assert_noop!(
|
||||
Contracts::upload_code(
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
@@ -3747,7 +3773,7 @@ fn code_rejected_error_works() {
|
||||
assert_err!(result.result, <Error<Test>>::CodeRejected);
|
||||
assert_eq!(
|
||||
std::str::from_utf8(&result.debug_message).unwrap(),
|
||||
"module imports a non-existent function"
|
||||
"call function isn't exported"
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -4386,8 +4412,8 @@ fn delegate_call_indeterministic_code() {
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "unstable-interface")]
|
||||
fn reentrant_count_works_with_call() {
|
||||
let (wasm, code_hash) = compile_module::<Test>("reentrant_count_call").unwrap();
|
||||
fn reentrance_count_works_with_call() {
|
||||
let (wasm, code_hash) = compile_module::<Test>("reentrance_count_call").unwrap();
|
||||
let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]);
|
||||
|
||||
ExtBuilder::default().existential_deposit(100).build().execute_with(|| {
|
||||
@@ -4423,8 +4449,8 @@ fn reentrant_count_works_with_call() {
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "unstable-interface")]
|
||||
fn reentrant_count_works_with_delegated_call() {
|
||||
let (wasm, code_hash) = compile_module::<Test>("reentrant_count_delegated_call").unwrap();
|
||||
fn reentrance_count_works_with_delegated_call() {
|
||||
let (wasm, code_hash) = compile_module::<Test>("reentrance_count_delegated_call").unwrap();
|
||||
let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]);
|
||||
|
||||
ExtBuilder::default().existential_deposit(100).build().execute_with(|| {
|
||||
@@ -4462,8 +4488,8 @@ fn reentrant_count_works_with_delegated_call() {
|
||||
#[cfg(feature = "unstable-interface")]
|
||||
fn account_reentrance_count_works() {
|
||||
let (wasm, code_hash) = compile_module::<Test>("account_reentrance_count_call").unwrap();
|
||||
let (wasm_reentrant_count, code_hash_reentrant_count) =
|
||||
compile_module::<Test>("reentrant_count_call").unwrap();
|
||||
let (wasm_reentrance_count, code_hash_reentrance_count) =
|
||||
compile_module::<Test>("reentrance_count_call").unwrap();
|
||||
|
||||
ExtBuilder::default().existential_deposit(100).build().execute_with(|| {
|
||||
let _ = Balances::deposit_creating(&ALICE, 1_000_000);
|
||||
@@ -4483,14 +4509,14 @@ fn account_reentrance_count_works() {
|
||||
300_000,
|
||||
GAS_LIMIT,
|
||||
None,
|
||||
wasm_reentrant_count,
|
||||
wasm_reentrance_count,
|
||||
vec![],
|
||||
vec![]
|
||||
));
|
||||
|
||||
let contract_addr = Contracts::contract_address(&ALICE, &code_hash, &[]);
|
||||
let another_contract_addr =
|
||||
Contracts::contract_address(&ALICE, &code_hash_reentrant_count, &[]);
|
||||
Contracts::contract_address(&ALICE, &code_hash_reentrance_count, &[]);
|
||||
|
||||
let result1 = Contracts::bare_call(
|
||||
ALICE,
|
||||
|
||||
Reference in New Issue
Block a user