diff --git a/sway-core/src/asm_generation/fuel/functions.rs b/sway-core/src/asm_generation/fuel/functions.rs index ddeb499a9fd..c5328162b89 100644 --- a/sway-core/src/asm_generation/fuel/functions.rs +++ b/sway-core/src/asm_generation/fuel/functions.rs @@ -812,7 +812,11 @@ impl<'ir, 'eng> FuelAsmBuilder<'ir, 'eng> { self.cur_bytecode.push(Op::register_move( locals_base_reg.clone(), VirtualRegister::Constant(ConstantRegister::StackPointer), - "save locals base register", + format!( + "save locals base register for {}", + function.get_name(self.context) + ) + .to_string(), None, )); diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index 8f7b616c7a8..c1b3de35b71 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -295,8 +295,7 @@ impl<'eng> FnCompiler<'eng> { md_mgr: &mut MetadataManager, ast_expr: &ty::TyExpression, ) -> Result { - // Compile expression which *may* be a pointer. We can't return a value so create a - // temporary here, store the value and return its pointer. + // Compile expression which *may* be a pointer. let val = return_on_termination_or_extract!(self.compile_expression(context, md_mgr, ast_expr)?); let ty = match val.get_type(context) { @@ -304,16 +303,36 @@ impl<'eng> FnCompiler<'eng> { _ => return Ok(TerminatorValue::new(val, context)), }; - // Create a temporary. - let temp_name = self.lexical_map.insert_anon(); - let tmp_var = self - .function - .new_local_var(context, temp_name, ty, None, false) - .map_err(|ir_error| CompileError::InternalOwned(ir_error.to_string(), Span::dummy()))?; - let tmp_val = self.current_block.append(context).get_local(tmp_var); - self.current_block.append(context).store(tmp_val, val); + let is_argument = val.get_argument(context).is_some_and(|arg| { + arg.block.get_function(context).get_entry_block(context) == arg.block + }); + + let ptr_val = if is_argument { + // The `ptr_to_int` instructions gets the address of a variable into an integer. + // We then cast it back to a pointer. + let ptr_ty = Type::new_ptr(context, ty); + let int_ty = Type::get_uint64(context); + let ptr_to_int = self.current_block.append(context).ptr_to_int(val, int_ty); + let int_to_ptr = self + .current_block + .append(context) + .int_to_ptr(ptr_to_int, ptr_ty); + int_to_ptr + } else { + // We can't return a value so create a temporary here, store the value and return its pointer. + let temp_name = self.lexical_map.insert_anon(); + let tmp_var = self + .function + .new_local_var(context, temp_name, ty, None, false) + .map_err(|ir_error| { + CompileError::InternalOwned(ir_error.to_string(), Span::dummy()) + })?; + let tmp_val = self.current_block.append(context).get_local(tmp_var); + self.current_block.append(context).store(tmp_val, val); + tmp_val + }; - Ok(TerminatorValue::new(tmp_val, context)) + Ok(TerminatorValue::new(ptr_val, context)) } fn compile_string_slice( diff --git a/sway-ir/src/optimize/inline.rs b/sway-ir/src/optimize/inline.rs index a98893aa1bd..8c209ea162c 100644 --- a/sway-ir/src/optimize/inline.rs +++ b/sway-ir/src/optimize/inline.rs @@ -132,15 +132,6 @@ pub fn inline_in_module( return true; } - // See https://github.com/FuelLabs/sway/pull/4899 - if func.args_iter(ctx).any(|(_name, arg_val)| { - arg_val.get_type(ctx).map_or(false, |ty| { - ty.is_ptr(ctx) || !(ty.is_unit(ctx) | ty.is_bool(ctx) | ty.is_uint(ctx)) - }) - }) { - return true; - } - false }; diff --git a/sway-ir/src/optimize/memcpyopt.rs b/sway-ir/src/optimize/memcpyopt.rs index 13a8e181a7f..a6a6c082972 100644 --- a/sway-ir/src/optimize/memcpyopt.rs +++ b/sway-ir/src/optimize/memcpyopt.rs @@ -76,6 +76,14 @@ fn local_copy_prop_prememcpy(context: &mut Context, function: Function) -> Resul instr_info_map.insert(inst, info()); } } + Instruction { + op: InstOp::PtrToInt(value, _), + .. + } => { + if let Some(local) = get_symbol(context, *value) { + escaping_uses.insert(local); + } + } Instruction { op: InstOp::AsmBlock(_, args), .. diff --git a/sway-ir/src/optimize/misc_demotion.rs b/sway-ir/src/optimize/misc_demotion.rs index 768043cdec3..e77c177c2ab 100644 --- a/sway-ir/src/optimize/misc_demotion.rs +++ b/sway-ir/src/optimize/misc_demotion.rs @@ -287,9 +287,21 @@ fn ptr_to_int_demotion(context: &mut Context, function: Function) -> Result Some(loaded_val), + _ => None, + } { + ptr_to_int_instr_val.replace_instruction_value(context, ptr_val, loaded_val); + continue; + } + } + + // Take the ptr_to_int value, store it in a temporary local, and replace it with its pointer in + // the ptr_to_int instruction. + // Create a variable for the arg, a get_local for it and a store. let loc_var = function.new_unique_local_var( context, diff --git a/sway-ir/tests/demote_misc/demote_ptr_to_int.ir b/sway-ir/tests/demote_misc/demote_ptr_to_int.ir index c2532c40812..db013941ded 100644 --- a/sway-ir/tests/demote_misc/demote_ptr_to_int.ir +++ b/sway-ir/tests/demote_misc/demote_ptr_to_int.ir @@ -1,25 +1,32 @@ script { + fn test(v1: b256) -> u64 { + entry(v1: b256): + v2 = ptr_to_int v1 to u64 + ret u64 v2 + } entry fn main() -> u64 { local b256 foo = const b256 0x2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b entry(): - v0 = get_local ptr b256, foo - v1 = load v0 - v2 = ptr_to_int v1 to u64 - ret u64 v2 + foo_ptr = get_local ptr b256, foo + foo = load foo_ptr + v1 = call test(foo) + ret u64 v1 } } // regex: VAL=v\d+ // regex: ID=[[:alpha:]0-9_]+ +// check: fn test($(foo_val=$ID): b256) -> u64 // check: local b256 $(tmp_loc=$ID) -// check: local b256 foo = const b256 0x2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b -// check: $(foo_ptr=$VAL) = get_local ptr b256, foo -// check: $(foo_val=$VAL) = load $foo_ptr // check: $(tmp_ptr=$VAL) = get_local ptr b256, $tmp_loc // check: store $foo_val to $tmp_ptr // check: $(tmp_ptr_int=$VAL) = ptr_to_int $tmp_ptr to u64 // check: ret u64 $tmp_ptr_int +// check: entry fn main() -> u64 +// check: local b256 foo = const b256 0x2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b +// check: $(foo_ptr=$VAL) = get_local ptr b256, foo +// check: $(foo_val=$VAL) = load $foo_ptr diff --git a/sway-lib-std/src/bytes.sw b/sway-lib-std/src/bytes.sw index 8d115538c20..5aad58cf2b5 100644 --- a/sway-lib-std/src/bytes.sw +++ b/sway-lib-std/src/bytes.sw @@ -6,6 +6,7 @@ use ::assert::{assert, assert_eq}; use ::intrinsics::size_of_val; use ::option::Option::{self, *}; use ::convert::{From, Into, *}; +use ::clone::Clone; struct RawBytes { ptr: raw_ptr, @@ -907,6 +908,16 @@ impl From for Vec { } } +impl Clone for Bytes { + fn clone(self) -> Self { + let len = self.len(); + let mut c = Self::with_capacity(len); + c.len = len; + self.ptr().copy_bytes_to(c.ptr(), len); + c + } +} + impl AbiEncode for Bytes { fn abi_encode(self, ref mut buffer: Buffer) { buffer.push_u64(self.len); diff --git a/sway-lib-std/src/clone.sw b/sway-lib-std/src/clone.sw new file mode 100644 index 00000000000..b36c900e7fb --- /dev/null +++ b/sway-lib-std/src/clone.sw @@ -0,0 +1,8 @@ +//! The clone trait, for explicit duplication. +library; + +/// A common trait for the ability to explicitly duplicate an object. +pub trait Clone { + /// Clone self into a new value of the same type. + fn clone(self) -> Self; +} diff --git a/sway-lib-std/src/lib.sw b/sway-lib-std/src/lib.sw index 7f52116b17c..b82e16bde11 100644 --- a/sway-lib-std/src/lib.sw +++ b/sway-lib-std/src/lib.sw @@ -44,5 +44,6 @@ pub mod prelude; pub mod low_level_call; pub mod array_conversions; pub mod bytes_conversions; +pub mod clone; use core::*; diff --git a/sway-lib-std/src/low_level_call.sw b/sway-lib-std/src/low_level_call.sw index a8b0549cf71..c0dc49675e1 100644 --- a/sway-lib-std/src/low_level_call.sw +++ b/sway-lib-std/src/low_level_call.sw @@ -203,10 +203,10 @@ fn create_payload( // let mut payload = Bytes::new().append(contract_id_to_bytes(target)).append(function_selector); let mut payload = Bytes::new(); payload.append(contract_id_to_bytes(target)); - payload.append(function_selector); + payload.append(function_selector.clone()); if (single_value_type_arg) { - payload.append(calldata); // When calldata is copy type, just pass calldata + payload.append(calldata.clone()); // When calldata is copy type, just pass calldata } else { payload.append(ptr_as_bytes(calldata.ptr())); // When calldata is reference type, need to get pointer as bytes }; diff --git a/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/reduced_lib.config b/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/reduced_lib.config index 624471573d5..87e01ae7cd0 100644 --- a/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/reduced_lib.config +++ b/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/reduced_lib.config @@ -11,6 +11,7 @@ convert.sw intrinsics.sw constants.sw bytes.sw +clone.sw bytes_conversions.sw bytes_conversions/b256.sw bytes_conversions/u16.sw diff --git a/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/src/lib.sw b/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/src/lib.sw index c331363c862..4f8c777cad2 100644 --- a/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/src/lib.sw +++ b/test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-conversions/src/lib.sw @@ -15,6 +15,7 @@ pub mod bytes; pub mod primitive_conversions; pub mod array_conversions; pub mod bytes_conversions; +pub mod clone; pub mod prelude; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle.json b/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle.json index 877e58079fd..273f9b12649 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle.json +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/configurable_consts/json_abi_oracle.json @@ -7,7 +7,7 @@ "typeArguments": null }, "name": "C0", - "offset": 4476 + "offset": 4724 }, { "configurableType": { @@ -16,7 +16,7 @@ "typeArguments": null }, "name": "C1", - "offset": 4492 + "offset": 4740 }, { "configurableType": { @@ -25,7 +25,7 @@ "typeArguments": null }, "name": "C2", - "offset": 4508 + "offset": 4756 }, { "configurableType": { @@ -34,7 +34,7 @@ "typeArguments": [] }, "name": "C3", - "offset": 4540 + "offset": 4788 }, { "configurableType": { @@ -43,7 +43,7 @@ "typeArguments": [] }, "name": "C4", - "offset": 4556 + "offset": 4804 }, { "configurableType": { @@ -52,7 +52,7 @@ "typeArguments": [] }, "name": "C5", - "offset": 4572 + "offset": 4820 }, { "configurableType": { @@ -61,7 +61,7 @@ "typeArguments": null }, "name": "C6", - "offset": 4588 + "offset": 4836 }, { "configurableType": { @@ -70,7 +70,7 @@ "typeArguments": null }, "name": "C7", - "offset": 4604 + "offset": 4852 }, { "configurableType": { @@ -79,7 +79,7 @@ "typeArguments": null }, "name": "C7_2", - "offset": 4708 + "offset": 4956 }, { "configurableType": { @@ -88,7 +88,7 @@ "typeArguments": null }, "name": "C9", - "offset": 4652 + "offset": 4900 } ], "functions": [ diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/references/referencing_function_parameters/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/language/references/referencing_function_parameters/src/main.sw index 541cd47e510..e1a59b5f62b 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/references/referencing_function_parameters/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/references/referencing_function_parameters/src/main.sw @@ -108,6 +108,10 @@ fn empty_struct_parameter_not_inlined(p: EmptyStruct) { #[inline(always)] fn struct_parameter(p: S) { + + let r_p_1_addr_of = __addr_of(p); + assert(r_p_1_addr_of == __addr_of(p)); + let r_p_1 = &p; let r_p_2 = &p; @@ -123,6 +127,9 @@ fn struct_parameter(p: S) { assert(*r_p_1 == *r_p_2); assert(r_p_1.x == r_p_2.x); + + let q = S::new(); + assert(r_p_1_addr_of != __addr_of(q)); } #[inline(never)] diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw index 6ee9ff1d949..c4f6c0a1ea1 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/array_of_structs_caller/src/main.sw @@ -6,7 +6,7 @@ use std::hash::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x7fae96947a8cad59cc2a25239f9f80897955d4c1b10d31510681f15842b93265; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x54996ea6be619740d315438a413cf060d858fd548ffb75a54408fd8af1519ff8; +const CONTRACT_ID = 0x0e38f647c805a9ea913ffc8ae37cf3b5a76aa86bb4f42d2057c06c5f45a7edd6; fn main() -> u64 { let addr = abi(TestContract, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw index 1ff3524a570..d0b9b8f1e0c 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/asset_ops_test/src/main.sw @@ -9,12 +9,12 @@ use test_fuel_coin_abi::*; #[cfg(experimental_new_encoding = false)] const FUEL_COIN_CONTRACT_ID = 0x27447d931b1c2c0eaf94aa9ffd1c1ea09298ee23a632937accdac91947a502a0; #[cfg(experimental_new_encoding = true)] -const FUEL_COIN_CONTRACT_ID = 0x32dcf3d874415397505a12b60c85c63f4f70eb36a33f984ee81fd8214d4faeeb; +const FUEL_COIN_CONTRACT_ID = 0xce28916d1aafcab28b0495481b514632c7f908e4915e6152c77290b78bc99353; #[cfg(experimental_new_encoding = false)] const BALANCE_CONTRACT_ID = 0x3b8cb681056f61a41e138b8884d7e3bb9332fbd7a8e38e3e0b0ada766cabfa4e; #[cfg(experimental_new_encoding = true)] -const BALANCE_CONTRACT_ID = 0x2d15bdaa30e59eb25bab934e9533d10ace0a971ae942e47119e49ef411978d34; +const BALANCE_CONTRACT_ID = 0xdf3aecbed3bde3772553ed1ea84411a114aff5c31b90b0d7f13c6e4e74cb804a; fn main() -> bool { let default_gas = 1_000_000_000_000; diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw index 4d10821ed2d..ee0c72f4ee3 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/bal_opcode/src/main.sw @@ -6,7 +6,7 @@ use balance_test_abi::BalanceTest; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x3b8cb681056f61a41e138b8884d7e3bb9332fbd7a8e38e3e0b0ada766cabfa4e; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x2d15bdaa30e59eb25bab934e9533d10ace0a971ae942e47119e49ef411978d34; +const CONTRACT_ID = 0xdf3aecbed3bde3772553ed1ea84411a114aff5c31b90b0d7f13c6e4e74cb804a; fn main() -> bool { let balance_test_contract = abi(BalanceTest, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw index ebb54990cca..d66ce48e91d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_abi_with_tuples/src/main.sw @@ -5,7 +5,7 @@ use abi_with_tuples::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xb351aff8258ce46d16a71be666dd2b0b09d72243105c51f4423765824e59cac9; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xde6ab165b5b0f9058daf26002d22f472e6d1af1c35e0210821e743d297d55b17; +const CONTRACT_ID = 0xf96a023e849fb8e84db3e4fc22fea0041080223e7b8c37a97f3fa1682a151f4b; fn main() -> bool { let the_abi = abi(MyContract, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw index 717f09f4e6c..80c68d7e4bb 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_basic_storage/src/main.sw @@ -2,9 +2,9 @@ script; use basic_storage_abi::{BasicStorage, Quad}; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xa75e1629f14cf3fa28c6fc442d2a2470cbeb966ee53574935ee4fe28bd24dcb1; +const CONTRACT_ID = 0xbb236cbc9f99b66bb8b8daea5702fd58b740163b0629a042b73f3a8063329ffa; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xbc349573913779db616406eaf74d0ac24da58ce2f26cdedd8a7c3134f34d2739; +const CONTRACT_ID = 0x2a999e8bc26b68091f593906e2136508658065264ccd9e6d49a72d1898ea7080; fn main() -> u64 { let addr = abi(BasicStorage, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw index 30f2c556ac8..50775e10ef4 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_contract_with_type_aliases/src/main.sw @@ -5,7 +5,7 @@ use contract_with_type_aliases_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0x9d76ecbf446c30ef659efd1157d67d156de02b1e6c2ac2f9c744125571efa229; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x02ab63e5c022d26c890c2adff800623b10a09612d6da902c12afa11705b9c5cd; +const CONTRACT_ID = 0x504fe1c163e5cb921ecb8acae1dff181b4d0b92ddd2871c719828f24a70bc727; fn main() { let caller = abi(MyContract, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw index 0742f187903..3986cbc1997 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_increment_contract/src/main.sw @@ -4,9 +4,9 @@ use increment_abi::Incrementor; use dynamic_contract_call::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xb7a555aa47aaa778e0b1c351e897e83b08b34a1599114166bb5635721da0ab14; +const CONTRACT_ID = 0x4440ac68a7f88e414ae29425ab22c6aed0434cf6632d0ee1d41ab82607923493; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x3c1b3e3ad4debae2393ff81b5d77260c62f1356daa51c67ff220a09e7838a52a; +const CONTRACT_ID = 0x1fc4e213dd620f6f452736398448e6352a5dac3c7815cc6f808e7a7104146a31; fn main() -> bool { let the_abi = abi(Incrementor, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw index dda4aa458fe..6b5f7c63666 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/call_storage_enum/src/main.sw @@ -3,9 +3,9 @@ script; use storage_enum_abi::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0x10ac00a805f5d051274a250b79047439e9df9c6c5626e0b4cecddc93e45e6ca3; +const CONTRACT_ID = 0x1ce765336fbb4c4558c7f5753fad01a8549521b03e82bc94048fa512750b9554; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xc1d94591f6ea13e0a666939f12afab7a5db992559328032a8029c2c048d56632; +const CONTRACT_ID = 0x35edb2feb79541369f9d4353b39ffbb044a95a1944e219f431e5135275e6d434; fn main() -> u64 { let caller = abi(StorageEnum, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw index 0b936fa004b..508908dee82 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_auth_test/src/main.sw @@ -5,7 +5,7 @@ use auth_testing_abi::AuthTesting; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xd7ef57c654a7e52ee8b85f34c64fa2f8e1a250eceb446cfe9805b175a0a7680f; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xe11b1032f7669c45109c1bcfade9aa7fb3e480634c8a05f6a45d36434d2edbbf; +const CONTRACT_ID = 0x4b72fe570b69663d9047ab2bb1befae7981c3192dff3019fe385cc246f0d6b22; // should be false in the case of a script fn main() -> bool { diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw index 05b40a34b78..3dfc1028931 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/caller_context_test/src/main.sw @@ -7,7 +7,7 @@ use context_testing_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xe83ed45906627117f00f60e47140c6100b4b69133389a2dafd35bc3282329385; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x3a0ad97b880a8e5f127e19eb5a05ed1b252a29b0367e5051df8ecf57d6fd234f; +const CONTRACT_ID = 0x1901a76a101ec5de439100f2f21896be0893fe8a783be41206dd8c61cb81b52f; fn main() -> bool { let gas: u64 = u64::max(); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw index 1bdf81d6b51..19520b52b32 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/nested_struct_args_caller/src/main.sw @@ -5,7 +5,7 @@ use nested_struct_args_abi::*; #[cfg(experimental_new_encoding = false)] const CONTRACT_ID = 0xc615be7b48402210cbec3bc1667ab5a8093d449d5d8d1fdcc26e6f18e7942ea9; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0xcfc9c8eb2bacbf90c13ced943f843264be07ed82029779345a83e1c9e686d334; +const CONTRACT_ID = 0x7bd6ebe7187a3051d68cba2737f150821e2774bb209c56432ef4494b8dd358db; fn main() -> bool { let caller = abi(NestedStructArgs, CONTRACT_ID); diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw index 4551857777b..438aac74fe0 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/require_contract_deployment/storage_access_caller/src/main.sw @@ -4,9 +4,9 @@ use storage_access_abi::*; use std::hash::*; #[cfg(experimental_new_encoding = false)] -const CONTRACT_ID = 0xb0eee35cb9c3e2da8b5be0435192ea915d0e0dba2876528424af7bbb31574648; +const CONTRACT_ID = 0x060a673b757bf47ce307548322586ec68b94a11ef330da149a7000435e3a294b; #[cfg(experimental_new_encoding = true)] -const CONTRACT_ID = 0x69100d93fdb5870d073083e86f8b8705f584d14956c3c88a5c1697a962437d1d; +const CONTRACT_ID = 0xb01e2b0b2baecaf6751cf6a5ad731eee3ff5f6dd5f8ad3bcb85ea956d2b17f50; fn main() -> bool { let caller = abi(StorageAccess, CONTRACT_ID); diff --git a/test/src/ir_generation/tests/simple_contract_call.sw b/test/src/ir_generation/tests/simple_contract_call.sw index cf5e61acb73..be06b930217 100644 --- a/test/src/ir_generation/tests/simple_contract_call.sw +++ b/test/src/ir_generation/tests/simple_contract_call.sw @@ -46,8 +46,10 @@ fn main() -> u64 { // check: local b256 $(big_fives_const=$ID) = const b256 0x5555555555555555555555555555555555555555555555555555555555555555 // check: local b256 $(contract_id_2_const=$ID) = const b256 0x0c1c50c2bf5ba4bb351b4249a2f5e7d86556fcb4a6ae90465ff6c86126eeb3c0 // check: local b256 $(asset_id_2_const=$ID) = const b256 0x0000000000000000000000000000000000000000000000000000000000000000 +// check: local b256 $(arg_for_get_b256=$ID) // check: $(contract_id_0_ptr=$VAL) = get_local ptr b256, $contract_id_0_const +// check: $(threes_const_ptr=$VAL) = get_local ptr b256, $threes_const // check: $(contract_id_1_ptr=$VAL) = get_local ptr b256, $contract_id_1_const // check: $(big_fives_ptr=$VAL) = get_local ptr b256, $big_fives_const // check: $(contract_id_2_ptr=$VAL) = get_local ptr b256, $contract_id_2_const @@ -77,7 +79,8 @@ fn main() -> u64 { // check: $(call_res=$VAL) = contract_call u64 get_u64 $args_ptr, $coins, $asset_id_ptr, $gas // --- call get_b256() --- -// check: $(user_arg_ptr=$VAL) = get_local ptr b256, $threes_const +// check: $(user_arg_ptr=$VAL) = get_local ptr b256, $arg_for_get_b256 +// check: mem_copy_val $user_arg_ptr, $threes_const_ptr // check: $(user_arg=$VAL) = ptr_to_int $user_arg_ptr to u64 // check: $(args_ptr=$VAL) = get_local ptr { b256, u64, u64 }, $ID diff --git a/test/src/sdk-harness/test_projects/low_level_call_bytes/src/main.sw b/test/src/sdk-harness/test_projects/low_level_call_bytes/src/main.sw index aa4351020a6..51a7598497d 100644 --- a/test/src/sdk-harness/test_projects/low_level_call_bytes/src/main.sw +++ b/test/src/sdk-harness/test_projects/low_level_call_bytes/src/main.sw @@ -2,7 +2,7 @@ script; use std::bytes::Bytes; use std::constants::BASE_ASSET_ID; -use std::low_level_call::{call_with_function_selector, call_with_function_selector_vec, CallParams}; +use std::low_level_call::{call_with_function_selector, CallParams}; fn main( target: ContractId,