diff --git a/sway-lib-std/src/execution.sw b/sway-lib-std/src/execution.sw index d80207fb096..759053a8b1d 100644 --- a/sway-lib-std/src/execution.sw +++ b/sway-lib-std/src/execution.sw @@ -30,43 +30,3 @@ pub fn run_external(load_target: ContractId) -> ! { } __jmp_mem() } - -pub fn run_external2(load_target1: ContractId, load_target2: ContractId) -> ! { - // Get lengths of both chunks - // Store load_target2 on the heap as it'll be overwritten with the first LDC we do. - // Save the old $ssp value as that's were the contract will be loaded. - // Shrink the stack since LDC wants $ssp == $sp - // Do the loads - // __jmp_mem jumps to $MEM[$hp], so set that up. - asm( - load_target1: load_target1, - load_target2: load_target2, - load_target2_heap, - heap_alloc_size, - length1, - length2, - ssp_saved, - cur_stack_size, - ) { - csiz length1 load_target1; - csiz length2 load_target2; - - addi heap_alloc_size zero i32; - aloc heap_alloc_size; - mcp hp load_target2 heap_alloc_size; - move load_target2_heap hp; - - move ssp_saved ssp; - - sub cur_stack_size sp ssp; - cfs cur_stack_size; - - ldc load_target1 zero length1 i0; - ldc load_target2_heap zero length2 i0; - - addi heap_alloc_size zero i64; - aloc heap_alloc_size; - sw hp ssp_saved i0; - } - __jmp_mem() -} diff --git a/test/src/sdk-harness/test_projects/run_external_proxy/mod.rs b/test/src/sdk-harness/test_projects/run_external_proxy/mod.rs index 6cb5a33ddc9..d5a25c3e5bb 100644 --- a/test/src/sdk-harness/test_projects/run_external_proxy/mod.rs +++ b/test/src/sdk-harness/test_projects/run_external_proxy/mod.rs @@ -9,8 +9,8 @@ abigen!(Contract( async fn run_external_can_proxy_call() { let wallet = launch_provider_and_get_wallet().await.unwrap(); - let target_id1 = Contract::load_from( - "test_projects/run_external_target/out/release/part-1.bin", + let target_id = Contract::load_from( + "test_projects/run_external_target/out/release/run_external_target.bin", LoadConfiguration::default() .with_storage_configuration(StorageConfiguration::default().with_autoload(false)), ) @@ -19,22 +19,8 @@ async fn run_external_can_proxy_call() { .await .unwrap(); - let target_id2 = Contract::load_from( - "test_projects/run_external_target/out/release/part-2.bin", - LoadConfiguration::default() - .with_storage_configuration(StorageConfiguration::default().with_autoload(false)), - ) - .unwrap() - .deploy(&wallet, TxPolicies::default()) - .await - .unwrap(); - - dbg!(&target_id1, &target_id2); - let configurables = RunExternalProxyContractConfigurables::default() - .with_TARGET_1(target_id1.clone().into()) - .unwrap() - .with_TARGET_2(target_id2.clone().into()) + .with_TARGET(target_id.clone().into()) .unwrap(); let id = Contract::load_from( "test_projects/run_external_proxy/out/release/run_external_proxy.bin", @@ -44,9 +30,7 @@ async fn run_external_can_proxy_call() { .deploy(&wallet, TxPolicies::default()) .await .unwrap(); - let instance = RunExternalProxyContract::new(id.clone(), wallet); - // Call "large_value" // Will call run_external_proxy::large_value // that will call run_external_target::large_value @@ -54,7 +38,7 @@ async fn run_external_can_proxy_call() { let result = instance .methods() .large_value() - .with_contract_ids(&[target_id1.clone().into(), target_id2.clone().into()]) + .with_contract_ids(&[target_id.clone().into()]) .call() .await .unwrap(); @@ -67,7 +51,6 @@ async fn run_external_can_proxy_call() { print!("{:?} ", s); } } - println!("{:?}", data); } } @@ -78,7 +61,6 @@ async fn run_external_can_proxy_call() { Bits256::from_hex_str("0x00000000000000000000000059F2f1fCfE2474fD5F0b9BA1E73ca90b143Eb8d0") .unwrap(); assert_eq!(result.value, expected_large); - // Call "double_value" // Will call run_external_proxy::double_value // that will call run_external_target::double_value @@ -86,7 +68,7 @@ async fn run_external_can_proxy_call() { let result = instance .methods() .double_value(42) - .with_contract_ids(&[target_id1.clone().into(), target_id2.clone().into()]) + .with_contract_ids(&[target_id.clone().into()]) .call() .await .unwrap(); @@ -99,7 +81,6 @@ async fn run_external_can_proxy_call() { print!("{:?} ", s); } } - println!("{:?}", data); } } @@ -107,7 +88,6 @@ async fn run_external_can_proxy_call() { } } assert_eq!(result.value, 84); - // Call "does_not_exist_in_the_target" // Will call run_external_proxy::does_not_exist_in_the_target // it will proxy the call to run_external_target, @@ -115,7 +95,7 @@ async fn run_external_can_proxy_call() { let result = instance .methods() .does_not_exist_in_the_target(42) - .with_contract_ids(&[target_id1.into(), target_id2.into()]) + .with_contract_ids(&[target_id.into()]) .call() .await .unwrap(); diff --git a/test/src/sdk-harness/test_projects/run_external_proxy/src/main.sw b/test/src/sdk-harness/test_projects/run_external_proxy/src/main.sw index 89cf10fcf57..05dc44f0473 100644 --- a/test/src/sdk-harness/test_projects/run_external_proxy/src/main.sw +++ b/test/src/sdk-harness/test_projects/run_external_proxy/src/main.sw @@ -1,10 +1,9 @@ contract; -use std::execution::run_external2; +use std::execution::run_external; configurable { - TARGET_1: ContractId = ContractId::zero(), - TARGET_2: ContractId = ContractId::zero(), + TARGET: ContractId = ContractId::zero(), } abi RunExternalTest { @@ -12,20 +11,19 @@ abi RunExternalTest { fn large_value() -> b256; fn does_not_exist_in_the_target(foo: u64) -> u64; } - impl RunExternalTest for Contract { fn double_value(_foo: u64) -> u64 { __log(1); - run_external2(TARGET_1, TARGET_2) + run_external(TARGET) } fn large_value() -> b256 { - run_external2(TARGET_1, TARGET_2) + run_external(TARGET) } // ANCHOR: does_not_exist_in_the_target fn does_not_exist_in_the_target(_foo: u64) -> u64 { - run_external2(TARGET_1, TARGET_2) + run_external(TARGET) } // ANCHOR_END: does_not_exist_in_the_target -} +} \ No newline at end of file