From c820c87b131d874ef450d302d3f7c22d9116d03c Mon Sep 17 00:00:00 2001 From: xunilrj Date: Sat, 4 Oct 2025 21:02:05 -0300 Subject: [PATCH 01/17] better tests to measure cost of contract calls --- sway-lib-std/src/codec.sw | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index fef49ad4d12..155a860060e 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3380,14 +3380,18 @@ impl AbiDecode for [T; N] where T: AbiDecode, { + #[inline(never)] fn abi_decode(ref mut buffer: BufferReader) -> [T; N] { const LENGTH: u64 = __size_of::() * N; - let mut array = [0u8; LENGTH]; + __log(LENGTH); + let mut array = [0u8; LENGTH]; let array: &mut [T; N] = __transmute::<&mut [u8; LENGTH], &mut [T; N]>(&mut array); let mut i = 0; + __log(N); while i < N { + __log(2); let item: &mut T = __elem_at(array, i); *item = buffer.decode::(); i += 1; @@ -5377,8 +5381,12 @@ where retl: u64 }; + __log(101); let mut buffer = BufferReader::from_parts(ptr, len); - T::abi_decode(buffer) + __log(102); + let r = T::abi_decode(buffer); + __log(103); + r } pub fn decode_script_data() -> T From c61b8d63a8d45e0389a3fe143248ab22fcd4e471 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Sun, 5 Oct 2025 11:51:47 -0300 Subject: [PATCH 02/17] fix SubtsType for TyConstantDecl --- scripts/bisect-forc/bisect-forc.sh | 19 ++++++++++--------- sway-lib-std/src/codec.sw | 27 ++++++++++++--------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/scripts/bisect-forc/bisect-forc.sh b/scripts/bisect-forc/bisect-forc.sh index 3f883ade03c..ae93dae7b5f 100755 --- a/scripts/bisect-forc/bisect-forc.sh +++ b/scripts/bisect-forc/bisect-forc.sh @@ -20,15 +20,7 @@ compile_and_cp_to_cache() { fi } -run_cargo() { - if [ "$2" = "" ]; then - bash -c "$CACHE/$CACHENAME build --path $PROJ" &>> /dev/null - echo "$?" - else - bash -c "$CACHE/$CACHENAME $2 --path $PROJ" &>> /dev/null - echo "$?" - fi -} + INITIAL_COMMIT="$(git show -s --format='%H' HEAD)" END_COMMIT="" @@ -47,6 +39,15 @@ git log -1 --oneline echo -n "Running: " CACHENAME="$(git show -s --format='%as-%ct-%H' HEAD)" +run_cargo() { + if [ "$2" = "" ]; then + bash -c "$CACHE/$CACHENAME build --path $PROJ" &>> /dev/null + echo "$?" + else + bash -c "$CACHE/$CACHENAME $2 --path $PROJ" &>> /dev/null + echo "$?" + fi +} compile_and_cp_to_cache "$CACHENAME" INITIAL_COMPILATION_STATUS=$(run_cargo "$1" "$2") diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index 155a860060e..b10caa4aedf 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3376,27 +3376,28 @@ impl AbiDecode for str[64] { // END STRARRAY_DECODE #[cfg(experimental_const_generics = true)] -impl AbiDecode for [T; N] +impl AbiDecode for [TTT; N] where - T: AbiDecode, + TTT: AbiEncode + AbiDecode, { #[inline(never)] - fn abi_decode(ref mut buffer: BufferReader) -> [T; N] { - const LENGTH: u64 = __size_of::() * N; - __log(LENGTH); + fn abi_decode(ref mut buffer: BufferReader) -> [TTT; N] { + const SIZE_OF_TTT = __size_of::(); + const LENGTH: u64 = SIZE_OF_TTT * N; let mut array = [0u8; LENGTH]; - let array: &mut [T; N] = __transmute::<&mut [u8; LENGTH], &mut [T; N]>(&mut array); + let array: &mut [TTT; N] = __transmute::<&mut [u8; LENGTH], &mut [TTT; N]>(&mut array); let mut i = 0; - __log(N); while i < N { - __log(2); - let item: &mut T = __elem_at(array, i); - *item = buffer.decode::(); + let item: &mut TTT = __elem_at(array, i); + let decoded = buffer.decode::(); + __log((i, decoded)); + *item = decoded; i += 1; } + __log(*array); *array } } @@ -5381,12 +5382,8 @@ where retl: u64 }; - __log(101); let mut buffer = BufferReader::from_parts(ptr, len); - __log(102); - let r = T::abi_decode(buffer); - __log(103); - r + T::abi_decode(buffer) } pub fn decode_script_data() -> T From 9c849d6d903af7f417f4891e9fe47f0e7a7410b0 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Sun, 5 Oct 2025 12:25:05 -0300 Subject: [PATCH 03/17] fmt and clippy issues --- sway-lib-std/src/codec.sw | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index b10caa4aedf..8bd4a1f297f 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3376,28 +3376,23 @@ impl AbiDecode for str[64] { // END STRARRAY_DECODE #[cfg(experimental_const_generics = true)] -impl AbiDecode for [TTT; N] +impl AbiDecode for [T; N] where - TTT: AbiEncode + AbiDecode, + T: AbiDecode, { - #[inline(never)] - fn abi_decode(ref mut buffer: BufferReader) -> [TTT; N] { - const SIZE_OF_TTT = __size_of::(); - const LENGTH: u64 = SIZE_OF_TTT * N; + fn abi_decode(ref mut buffer: BufferReader) -> [T; N] { + const LENGTH: u64 = __size_of::() * N; let mut array = [0u8; LENGTH]; - let array: &mut [TTT; N] = __transmute::<&mut [u8; LENGTH], &mut [TTT; N]>(&mut array); + let array: &mut [T; N] = __transmute::<&mut [u8; LENGTH], &mut [T; N]>(&mut array); let mut i = 0; while i < N { - let item: &mut TTT = __elem_at(array, i); - let decoded = buffer.decode::(); - __log((i, decoded)); - *item = decoded; + let item: &mut T = __elem_at(array, i); + *item = buffer.decode::(); i += 1; } - __log(*array); *array } } From 99c7b83d24b3ae03c2d1a20f5725a89aea84726c Mon Sep 17 00:00:00 2001 From: xunilrj Date: Sun, 5 Oct 2025 12:29:35 -0300 Subject: [PATCH 04/17] fmt and clippy issues --- sway-lib-std/src/codec.sw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index 8bd4a1f297f..fef49ad4d12 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -3382,7 +3382,7 @@ where { fn abi_decode(ref mut buffer: BufferReader) -> [T; N] { const LENGTH: u64 = __size_of::() * N; - let mut array = [0u8; LENGTH]; + let mut array = [0u8; LENGTH]; let array: &mut [T; N] = __transmute::<&mut [u8; LENGTH], &mut [T; N]>(&mut array); let mut i = 0; From de2367558daf6a75ee55f2c1139e6f7a337f495c Mon Sep 17 00:00:00 2001 From: xunilrj Date: Mon, 6 Oct 2025 17:15:01 -0300 Subject: [PATCH 05/17] rename tests for better historic comparison --- scripts/csv2html/htmltable2report.sh | 51 +++++++++++++++++++ .../const_of_contract_call/snapshot.toml | 2 + .../const_of_contract_call/stdout.snap | 2 +- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 scripts/csv2html/htmltable2report.sh diff --git a/scripts/csv2html/htmltable2report.sh b/scripts/csv2html/htmltable2report.sh new file mode 100755 index 00000000000..50c66b72a7c --- /dev/null +++ b/scripts/csv2html/htmltable2report.sh @@ -0,0 +1,51 @@ +echo ' + + + Pivot Demo + + + + + + + + + + + + + + + + + + + + +
+
' +cat $1 +echo '' \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml index e29e5ff922e..e6bea08993f 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml @@ -1,4 +1,6 @@ cmds = [ + #"echo This test will first run all test together. In this way we can measure the cost of contract method selection.", + #"echo After that, each test will be run isolated, giving a more precise cost of encoding/decoding boilerplate for each type.", "forc test --path {root} --release --experimental const_generics", { repeat = "for-each-block", cmds = [ "replace-file src/main.sw \"fn cost_of_in\" \"fn isolated_cost_of_in\"", diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap index fbc5f34e8a8..f802c136f0d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap @@ -229,7 +229,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.256 KB] in ??? + Finished release [optimized + fuel] target(s) [1.88 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call From 88f8b97d5f4b630a4d44617bb0bddf41f3a2c848 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Mon, 6 Oct 2025 21:19:18 -0300 Subject: [PATCH 06/17] fix CI --- .../tests/fixtures/sample_workspace/Forc.lock | 3 +- .../const_of_contract_call/stdout.snap | 78 +++++++++---------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock b/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock index 3a0e99b3fda..d417554ccd2 100644 --- a/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock +++ b/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock @@ -12,5 +12,4 @@ dependencies = [ [[package]] name = "std" -version = "0.69.0" -source = "registry+std?0.69.0#QmSeLFUtVXk8i13owCv87Kga1MfsYgfn7sdj6WimxLwq2g!" +source = "path+from-root-0CDB23161116D3A1" diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap index f802c136f0d..ec582f364e0 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap @@ -7,40 +7,40 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [36.248 KB] in ??? + Finished release [optimized + fuel] target(s) [38.76 KB] in ??? Running 29 tests, filtered 0 tests tested -- const_of_contract_call - test cost_of_in_bool ... ok (???, 2279 gas) - test cost_of_in_u8 ... ok (???, 4526 gas) - test cost_of_in_u16 ... ok (???, 4141 gas) - test cost_of_in_u32 ... ok (???, 4582 gas) - test cost_of_in_u64 ... ok (???, 4589 gas) - test cost_of_in_u256 ... ok (???, 4433 gas) - test cost_of_in_b256 ... ok (???, 2147 gas) - test cost_of_in_str_0 ... ok (???, 2697 gas) - test cost_of_in_str_1 ... ok (???, 2998 gas) - test cost_of_in_str_8 ... ok (???, 3421 gas) - test cost_of_in_str_16 ... ok (???, 3030 gas) - test cost_of_in_str_32 ... ok (???, 3227 gas) - test cost_of_in_array_0 ... FAILED (???, 1285 gas) - test cost_of_in_array_1 ... ok (???, 1779 gas) - test cost_of_in_array_8 ... ok (???, 4382 gas) - test cost_of_in_array_16 ... ok (???, 4753 gas) - test cost_of_in_array_32 ... ok (???, 8079 gas) - test cost_of_in_array_64 ... ok (???, 14545 gas) - test cost_of_in_tuple_0 ... ok (???, 3479 gas) - test cost_of_in_tuple_1 ... ok (???, 4050 gas) - test cost_of_in_tuple_2 ... ok (???, 4418 gas) - test cost_of_in_tuple_3 ... ok (???, 4761 gas) - test cost_of_in_tuple_4 ... ok (???, 5126 gas) - test in_struct_u64 ... ok (???, 3293 gas) - test in_struct_u64_u64 ... ok (???, 3554 gas) - test in_struct_u64_u64_u64 ... ok (???, 3813 gas) - test in_enum_u64 ... ok (???, 2843 gas) - test in_enum_u64_u64 ... ok (???, 2718 gas) - test in_enum_u64_u64_u64 ... ok (???, 2830 gas) + test cost_of_in_bool ... ok (???, 2627 gas) + test cost_of_in_u8 ... ok (???, 4874 gas) + test cost_of_in_u16 ... ok (???, 4493 gas) + test cost_of_in_u32 ... ok (???, 4926 gas) + test cost_of_in_u64 ... ok (???, 4934 gas) + test cost_of_in_u256 ... ok (???, 4777 gas) + test cost_of_in_b256 ... ok (???, 2491 gas) + test cost_of_in_str_0 ... ok (???, 3043 gas) + test cost_of_in_str_1 ... ok (???, 3345 gas) + test cost_of_in_str_8 ... ok (???, 3768 gas) + test cost_of_in_str_16 ... ok (???, 3374 gas) + test cost_of_in_str_32 ... ok (???, 3572 gas) + test cost_of_in_array_0 ... FAILED (???, 1632 gas) + test cost_of_in_array_1 ... ok (???, 2125 gas) + test cost_of_in_array_8 ... ok (???, 4724 gas) + test cost_of_in_array_16 ... ok (???, 5096 gas) + test cost_of_in_array_32 ... ok (???, 8421 gas) + test cost_of_in_array_64 ... ok (???, 14895 gas) + test cost_of_in_tuple_0 ... ok (???, 3822 gas) + test cost_of_in_tuple_1 ... ok (???, 4392 gas) + test cost_of_in_tuple_2 ... ok (???, 4761 gas) + test cost_of_in_tuple_3 ... ok (???, 5104 gas) + test cost_of_in_tuple_4 ... ok (???, 5468 gas) + test in_struct_u64 ... ok (???, 3635 gas) + test in_struct_u64_u64 ... ok (???, 3897 gas) + test in_struct_u64_u64_u64 ... ok (???, 4156 gas) + test in_enum_u64 ... ok (???, 3186 gas) + test in_enum_u64_u64 ... ok (???, 3061 gas) + test in_enum_u64_u64_u64 ... ok (???, 3173 gas) failures: test cost_of_in_array_0, "test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/src/main.sw":347 @@ -62,7 +62,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.016 KB] in ??? + Finished release [optimized + fuel] target(s) [2.448 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -89,7 +89,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.192 KB] in ??? + Finished release [optimized + fuel] target(s) [2.624 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -109,7 +109,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.216 KB] in ??? + Finished release [optimized + fuel] target(s) [2.648 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -129,7 +129,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.216 KB] in ??? + Finished release [optimized + fuel] target(s) [2.648 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -149,7 +149,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.288 KB] in ??? + Finished release [optimized + fuel] target(s) [2.848 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -169,7 +169,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.352 KB] in ??? + Finished release [optimized + fuel] target(s) [2.784 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -189,7 +189,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.064 KB] in ??? + Finished release [optimized + fuel] target(s) [2.504 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -209,7 +209,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.952 KB] in ??? + Finished release [optimized + fuel] target(s) [2.504 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -629,7 +629,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.92 KB] in ??? + Finished release [optimized + fuel] target(s) [2.472 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call From e337917e8fb31102aad82db86a6df39c57fcb3b9 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Mon, 6 Oct 2025 22:05:51 -0300 Subject: [PATCH 07/17] fixing CI --- .../tests/fixtures/sample_workspace/Forc.lock | 3 +- scripts/bisect-forc/bisect-forc.sh | 19 ++++--- scripts/csv2html/csv2html.sh | 4 ++ scripts/csv2html/htmltable2report.sh | 51 ------------------- .../const_of_contract_call/snapshot.toml | 2 - 5 files changed, 15 insertions(+), 64 deletions(-) delete mode 100755 scripts/csv2html/htmltable2report.sh diff --git a/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock b/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock index d417554ccd2..3a0e99b3fda 100644 --- a/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock +++ b/forc-plugins/forc-doc/tests/fixtures/sample_workspace/Forc.lock @@ -12,4 +12,5 @@ dependencies = [ [[package]] name = "std" -source = "path+from-root-0CDB23161116D3A1" +version = "0.69.0" +source = "registry+std?0.69.0#QmSeLFUtVXk8i13owCv87Kga1MfsYgfn7sdj6WimxLwq2g!" diff --git a/scripts/bisect-forc/bisect-forc.sh b/scripts/bisect-forc/bisect-forc.sh index ae93dae7b5f..3f883ade03c 100755 --- a/scripts/bisect-forc/bisect-forc.sh +++ b/scripts/bisect-forc/bisect-forc.sh @@ -20,7 +20,15 @@ compile_and_cp_to_cache() { fi } - +run_cargo() { + if [ "$2" = "" ]; then + bash -c "$CACHE/$CACHENAME build --path $PROJ" &>> /dev/null + echo "$?" + else + bash -c "$CACHE/$CACHENAME $2 --path $PROJ" &>> /dev/null + echo "$?" + fi +} INITIAL_COMMIT="$(git show -s --format='%H' HEAD)" END_COMMIT="" @@ -39,15 +47,6 @@ git log -1 --oneline echo -n "Running: " CACHENAME="$(git show -s --format='%as-%ct-%H' HEAD)" -run_cargo() { - if [ "$2" = "" ]; then - bash -c "$CACHE/$CACHENAME build --path $PROJ" &>> /dev/null - echo "$?" - else - bash -c "$CACHE/$CACHENAME $2 --path $PROJ" &>> /dev/null - echo "$?" - fi -} compile_and_cp_to_cache "$CACHENAME" INITIAL_COMPILATION_STATUS=$(run_cargo "$1" "$2") diff --git a/scripts/csv2html/csv2html.sh b/scripts/csv2html/csv2html.sh index c77bdd239b7..a1b079cdfef 100755 --- a/scripts/csv2html/csv2html.sh +++ b/scripts/csv2html/csv2html.sh @@ -57,4 +57,8 @@ tail -n +2 "$1" | sed -e 's/^//' -e 's/,/<\/td>/g' -e 's/$/<\/td><\/ echo " +<<<<<<< HEAD " +======= +" +>>>>>>> bdd5b43f5 (fixing CI) diff --git a/scripts/csv2html/htmltable2report.sh b/scripts/csv2html/htmltable2report.sh deleted file mode 100755 index 50c66b72a7c..00000000000 --- a/scripts/csv2html/htmltable2report.sh +++ /dev/null @@ -1,51 +0,0 @@ -echo ' - - - Pivot Demo - - - - - - - - - - - - - - - - - - - - -
-
' -cat $1 -echo '' \ No newline at end of file diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml index e6bea08993f..e29e5ff922e 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/snapshot.toml @@ -1,6 +1,4 @@ cmds = [ - #"echo This test will first run all test together. In this way we can measure the cost of contract method selection.", - #"echo After that, each test will be run isolated, giving a more precise cost of encoding/decoding boilerplate for each type.", "forc test --path {root} --release --experimental const_generics", { repeat = "for-each-block", cmds = [ "replace-file src/main.sw \"fn cost_of_in\" \"fn isolated_cost_of_in\"", From 397c2834f84981e42bdddb01fd92a36e72dcee0c Mon Sep 17 00:00:00 2001 From: xunilrj Date: Fri, 10 Oct 2025 19:42:40 -0300 Subject: [PATCH 08/17] avoid method name encoding by generating the expected format directly --- sway-core/src/ir_generation/convert.rs | 12 +-- sway-core/src/ir_generation/function.rs | 30 +++++-- sway-core/src/language/literal.rs | 7 ++ .../match_expression/analysis/pattern.rs | 1 + .../ast_node/expression/typed_expression.rs | 1 + .../typed_expression/method_application.rs | 13 +++- sway-ir/src/constant.rs | 13 ++++ sway-ir/src/irtype.rs | 4 + sway-lib-std/src/codec.sw | 6 +- sway-lsp/src/traverse/parsed_tree.rs | 1 + sway-lsp/src/utils/debug.rs | 1 + .../const_of_contract_call/stdout.snap | 78 +++++++++---------- 12 files changed, 106 insertions(+), 61 deletions(-) diff --git a/sway-core/src/ir_generation/convert.rs b/sway-core/src/ir_generation/convert.rs index af987956c51..466d452bb41 100644 --- a/sway-core/src/ir_generation/convert.rs +++ b/sway-core/src/ir_generation/convert.rs @@ -14,15 +14,6 @@ use sway_types::{integer_bits::IntegerBits, span::Span}; pub(super) fn convert_literal_to_value(context: &mut Context, ast_literal: &Literal) -> Value { match ast_literal { - // In Sway for now we don't have `as` casting and for integers which may be implicitly cast - // between widths we just emit a warning, and essentially ignore it. We also assume a - // 'Numeric' integer of undetermined width is 'u64`. The IR would like to be type - // consistent and doesn't tolerate missing integers of different width, so for now, until we - // do introduce explicit `as` casting, all integers are `u64` as far as the IR is - // concerned. - // - // XXX The above isn't true for other targets. We need to improved this. - // FIXME Literal::U8(n) => ConstantContent::get_uint(context, 8, *n as u64), Literal::U16(n) => ConstantContent::get_uint(context, 64, *n as u64), Literal::U32(n) => ConstantContent::get_uint(context, 64, *n as u64), @@ -32,6 +23,7 @@ pub(super) fn convert_literal_to_value(context: &mut Context, ast_literal: &Lite Literal::String(s) => ConstantContent::get_string(context, s.as_str().as_bytes().to_vec()), Literal::Boolean(b) => ConstantContent::get_bool(context, *b), Literal::B256(bs) => ConstantContent::get_b256(context, *bs), + Literal::Binary(bytes) => ConstantContent::get_untyped_slice(context, bytes.clone()), } } @@ -40,7 +32,6 @@ pub(super) fn convert_literal_to_constant( ast_literal: &Literal, ) -> Constant { let c = match ast_literal { - // All integers are `u64`. See comment above. Literal::U8(n) => ConstantContent::new_uint(context, 8, *n as u64), Literal::U16(n) => ConstantContent::new_uint(context, 64, *n as u64), Literal::U32(n) => ConstantContent::new_uint(context, 64, *n as u64), @@ -50,6 +41,7 @@ pub(super) fn convert_literal_to_constant( Literal::String(s) => ConstantContent::new_string(context, s.as_str().as_bytes().to_vec()), Literal::Boolean(b) => ConstantContent::new_bool(context, *b), Literal::B256(bs) => ConstantContent::new_b256(context, *bs), + Literal::Binary(_) => todo!(), }; Constant::unique(context, c) } diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index 75044834d56..b42516aa15f 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -457,12 +457,13 @@ impl<'a> FnCompiler<'a> { )) } - fn compile_string_slice( + // Can be used to raw untyped slice and string slice + fn compile_slice( &mut self, context: &mut Context, span_md_idx: Option, - string_data: Value, - string_len: u64, + slice_ptr: Value, + slice_len: u64, ) -> Result { let int_ty = Type::get_uint64(context); let ptr_ty = Type::get_ptr(context); @@ -471,9 +472,9 @@ impl<'a> FnCompiler<'a> { let ptr_val = self .current_block .append(context) - .cast_ptr(string_data, ptr_ty) + .cast_ptr(slice_ptr, ptr_ty) .add_metadatum(context, span_md_idx); - let len_val = ConstantContent::get_uint(context, 64, string_len); + let len_val = ConstantContent::get_uint(context, 64, slice_len); // a slice is a pointer and a length let field_types = vec![ptr_ty, int_ty]; @@ -569,7 +570,24 @@ impl<'a> FnCompiler<'a> { .append(context) .get_global(string_data_ptr); let string_len = s.as_str().len() as u64; - self.compile_string_slice(context, span_md_idx, string_ptr, string_len) + self.compile_slice(context, span_md_idx, string_ptr, string_len) + } + ty::TyExpressionVariant::Literal(Literal::Binary(bytes)) => { + let data = ConstantContent::get_untyped_slice(context, bytes.clone()) + .get_constant(context) + .unwrap(); + let data_ptr = self.module.new_unique_global_var( + context, + "__const_global".into(), + data.get_content(context).ty, + Some(*data), + false, + ); + + let slice_ptr = self.current_block.append(context).get_global(data_ptr); + let slice_len = bytes.len() as u64; + + self.compile_slice(context, span_md_idx, slice_ptr, slice_len) } ty::TyExpressionVariant::Literal(Literal::Numeric(n)) => { let implied_lit = match &*self.engines.te().get(ast_expr.return_type) { diff --git a/sway-core/src/language/literal.rs b/sway-core/src/language/literal.rs index df0bc8735fb..db67e712176 100644 --- a/sway-core/src/language/literal.rs +++ b/sway-core/src/language/literal.rs @@ -19,6 +19,7 @@ pub enum Literal { Numeric(u64), Boolean(bool), B256([u8; 32]), + Binary(Vec), } impl Literal { @@ -74,6 +75,10 @@ impl Hash for Literal { state.write_u8(8); x.hash(state); } + Binary(x) => { + state.write_u8(9); + x.hash(state); + } } } } @@ -111,6 +116,7 @@ impl fmt::Display for Literal { .map(|x| x.to_string()) .collect::>() .join(", "), + Literal::Binary(_) => todo!(), }; write!(f, "{s}") } @@ -154,6 +160,7 @@ impl Literal { Literal::U256(_) => TypeInfo::UnsignedInteger(IntegerBits::V256), Literal::Boolean(_) => TypeInfo::Boolean, Literal::B256(_) => TypeInfo::B256, + Literal::Binary(_) => todo!(), } } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs index 7de4cc88dc4..d3898662f40 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs @@ -180,6 +180,7 @@ impl Pattern { Literal::Boolean(b) => Pattern::Boolean(b), Literal::Numeric(x) => Pattern::Numeric(Range::from_single(x)), Literal::String(s) => Pattern::String(s.as_str().to_string()), + Literal::Binary(_) => todo!(), } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs index 7f6487899ae..c8b69d999be 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression.rs @@ -635,6 +635,7 @@ impl ty::TyExpression { Literal::U256(_) => type_engine.id_of_u256(), Literal::Boolean(_) => type_engine.id_of_bool(), Literal::B256(_) => type_engine.id_of_b256(), + Literal::Binary(_) => type_engine.id_of_raw_slice(), }; ty::TyExpression { expression: ty::TyExpressionVariant::Literal(lit), diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs index 9bfc54cc9e5..b9c6d8ccd86 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs @@ -533,10 +533,17 @@ pub(crate) fn type_check_method_application( } } - fn string_slice_literal(ident: &BaseIdent) -> Expression { + fn method_name_literal(method_name: &BaseIdent) -> Expression { + let method_name_str = method_name.as_str().to_string(); + let len_bytes = (method_name_str.len() as u64).to_be_bytes(); + + let mut blob = vec![]; + blob.extend(len_bytes); + blob.extend(method_name_str.as_bytes()); + Expression { - kind: ExpressionKind::Literal(Literal::String(ident.span())), - span: ident.span(), + kind: ExpressionKind::Literal(Literal::Binary(blob)), + span: method_name.span(), } } diff --git a/sway-ir/src/constant.rs b/sway-ir/src/constant.rs index 94a8f017f00..83e485975b9 100644 --- a/sway-ir/src/constant.rs +++ b/sway-ir/src/constant.rs @@ -120,6 +120,13 @@ impl ConstantContent { } } + pub fn new_untyped_slice(context: &mut Context, bytes: Vec) -> Self { + ConstantContent { + ty: Type::new_untyped_slice(context), + value: ConstantValue::RawUntypedSlice(bytes), + } + } + pub fn new_array(context: &mut Context, elm_ty: Type, elems: Vec) -> Self { ConstantContent { ty: Type::new_array(context, elm_ty, elems.len() as u64), @@ -181,6 +188,12 @@ impl ConstantContent { Value::new_constant(context, new_const) } + pub fn get_untyped_slice(context: &mut Context, value: Vec) -> Value { + let new_const_contents = ConstantContent::new_untyped_slice(context, value); + let new_const = Constant::unique(context, new_const_contents); + Value::new_constant(context, new_const) + } + /// `value` must be created as an array constant first, using [`Constant::new_array()`]. pub fn get_array(context: &mut Context, value: ConstantContent) -> Value { assert!(value.ty.is_array(context)); diff --git a/sway-ir/src/irtype.rs b/sway-ir/src/irtype.rs index 99126928500..b57d2f9fd39 100644 --- a/sway-ir/src/irtype.rs +++ b/sway-ir/src/irtype.rs @@ -140,6 +140,10 @@ impl Type { Self::get_type(context, &TypeContent::Pointer).expect("create_basic_types not called") } + pub fn new_untyped_slice(context: &mut Context) -> Type { + Self::get_or_create_unique_type(context, TypeContent::Slice) + } + /// Get string type pub fn new_string_array(context: &mut Context, len: u64) -> Type { Self::get_or_create_unique_type(context, TypeContent::StringArray(len)) diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index fef49ad4d12..e02e1272d52 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -5345,9 +5345,10 @@ where // END TUPLES_DECODE use ::ops::*; +#[inline(never)] pub fn contract_call( contract_id: b256, - method_name: str, + method_name: raw_slice, args: TArgs, coins: u64, asset_id: b256, @@ -5357,11 +5358,10 @@ where T: AbiDecode, TArgs: AbiEncode, { - let first_parameter = encode(method_name); let second_parameter = encode(args); let params = ( contract_id, - asm(a: first_parameter.ptr()) { + asm(a: method_name.ptr()) { a: u64 }, asm(a: second_parameter.ptr()) { diff --git a/sway-lsp/src/traverse/parsed_tree.rs b/sway-lsp/src/traverse/parsed_tree.rs index 22ff185b198..8580e4c7717 100644 --- a/sway-lsp/src/traverse/parsed_tree.rs +++ b/sway-lsp/src/traverse/parsed_tree.rs @@ -1252,5 +1252,6 @@ fn literal_to_symbol_kind(value: &Literal) -> SymbolKind { Literal::String(..) => SymbolKind::StringLiteral, Literal::B256(..) => SymbolKind::ByteLiteral, Literal::Boolean(..) => SymbolKind::BoolLiteral, + Literal::Binary(_) => todo!(), } } diff --git a/sway-lsp/src/utils/debug.rs b/sway-lsp/src/utils/debug.rs index e98390d6694..e4678457ec1 100644 --- a/sway-lsp/src/utils/debug.rs +++ b/sway-lsp/src/utils/debug.rs @@ -67,6 +67,7 @@ fn literal_to_string(literal: &Literal) -> String { Literal::String(len) => format!("str[{}]", len.as_str().len()), Literal::Boolean(_) => "bool".into(), Literal::B256(_) => "b256".into(), + Literal::Binary(_) => todo!(), } } diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap index ec582f364e0..698fdd6ea6d 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap @@ -7,40 +7,40 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [38.76 KB] in ??? + Finished release [optimized + fuel] target(s) [39.864 KB] in ??? Running 29 tests, filtered 0 tests tested -- const_of_contract_call - test cost_of_in_bool ... ok (???, 2627 gas) - test cost_of_in_u8 ... ok (???, 4874 gas) - test cost_of_in_u16 ... ok (???, 4493 gas) - test cost_of_in_u32 ... ok (???, 4926 gas) - test cost_of_in_u64 ... ok (???, 4934 gas) - test cost_of_in_u256 ... ok (???, 4777 gas) - test cost_of_in_b256 ... ok (???, 2491 gas) - test cost_of_in_str_0 ... ok (???, 3043 gas) - test cost_of_in_str_1 ... ok (???, 3345 gas) - test cost_of_in_str_8 ... ok (???, 3768 gas) - test cost_of_in_str_16 ... ok (???, 3374 gas) - test cost_of_in_str_32 ... ok (???, 3572 gas) - test cost_of_in_array_0 ... FAILED (???, 1632 gas) - test cost_of_in_array_1 ... ok (???, 2125 gas) - test cost_of_in_array_8 ... ok (???, 4724 gas) - test cost_of_in_array_16 ... ok (???, 5096 gas) - test cost_of_in_array_32 ... ok (???, 8421 gas) - test cost_of_in_array_64 ... ok (???, 14895 gas) - test cost_of_in_tuple_0 ... ok (???, 3822 gas) - test cost_of_in_tuple_1 ... ok (???, 4392 gas) - test cost_of_in_tuple_2 ... ok (???, 4761 gas) - test cost_of_in_tuple_3 ... ok (???, 5104 gas) - test cost_of_in_tuple_4 ... ok (???, 5468 gas) - test in_struct_u64 ... ok (???, 3635 gas) - test in_struct_u64_u64 ... ok (???, 3897 gas) - test in_struct_u64_u64_u64 ... ok (???, 4156 gas) - test in_enum_u64 ... ok (???, 3186 gas) - test in_enum_u64_u64 ... ok (???, 3061 gas) - test in_enum_u64_u64_u64 ... ok (???, 3173 gas) + test cost_of_in_bool ... ok (???, 2467 gas) + test cost_of_in_u8 ... ok (???, 4712 gas) + test cost_of_in_u16 ... ok (???, 4337 gas) + test cost_of_in_u32 ... ok (???, 4766 gas) + test cost_of_in_u64 ... ok (???, 4778 gas) + test cost_of_in_u256 ... ok (???, 4621 gas) + test cost_of_in_b256 ... ok (???, 2340 gas) + test cost_of_in_str_0 ... ok (???, 2890 gas) + test cost_of_in_str_1 ... ok (???, 3189 gas) + test cost_of_in_str_8 ... ok (???, 3612 gas) + test cost_of_in_str_16 ... ok (???, 3220 gas) + test cost_of_in_str_32 ... ok (???, 3420 gas) + test cost_of_in_array_0 ... FAILED (???, 1477 gas) + test cost_of_in_array_1 ... ok (???, 1974 gas) + test cost_of_in_array_8 ... ok (???, 4581 gas) + test cost_of_in_array_16 ... ok (???, 4953 gas) + test cost_of_in_array_32 ... ok (???, 8278 gas) + test cost_of_in_array_64 ... ok (???, 14731 gas) + test cost_of_in_tuple_0 ... ok (???, 3672 gas) + test cost_of_in_tuple_1 ... ok (???, 4237 gas) + test cost_of_in_tuple_2 ... ok (???, 4607 gas) + test cost_of_in_tuple_3 ... ok (???, 4950 gas) + test cost_of_in_tuple_4 ... ok (???, 5319 gas) + test in_struct_u64 ... ok (???, 3483 gas) + test in_struct_u64_u64 ... ok (???, 3743 gas) + test in_struct_u64_u64_u64 ... ok (???, 4002 gas) + test in_enum_u64 ... ok (???, 3042 gas) + test in_enum_u64_u64 ... ok (???, 2917 gas) + test in_enum_u64_u64_u64 ... ok (???, 3029 gas) failures: test cost_of_in_array_0, "test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/src/main.sw":347 @@ -62,7 +62,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.448 KB] in ??? + Finished release [optimized + fuel] target(s) [2.336 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -89,7 +89,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.624 KB] in ??? + Finished release [optimized + fuel] target(s) [2.512 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -109,7 +109,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.648 KB] in ??? + Finished release [optimized + fuel] target(s) [2.544 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -129,7 +129,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.648 KB] in ??? + Finished release [optimized + fuel] target(s) [2.544 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -149,7 +149,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.848 KB] in ??? + Finished release [optimized + fuel] target(s) [2.544 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -169,7 +169,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.784 KB] in ??? + Finished release [optimized + fuel] target(s) [2.68 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -189,7 +189,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.504 KB] in ??? + Finished release [optimized + fuel] target(s) [2.392 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -209,7 +209,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.504 KB] in ??? + Finished release [optimized + fuel] target(s) [2.368 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call @@ -629,7 +629,7 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.472 KB] in ??? + Finished release [optimized + fuel] target(s) [2.344 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call From a9324075af23a95b487d4251fcb229b6e0c15515 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Mon, 20 Oct 2025 15:54:59 -0300 Subject: [PATCH 09/17] update tests --- sway-core/src/ir_generation/convert.rs | 2 +- .../typed_expression/method_application.rs | 2 +- .../panicking_contract/stdout.snap | 52 +++--- .../const_of_contract_call/stdout.snap | 176 +++++++++--------- 4 files changed, 116 insertions(+), 116 deletions(-) diff --git a/sway-core/src/ir_generation/convert.rs b/sway-core/src/ir_generation/convert.rs index 466d452bb41..6cc8e8321dc 100644 --- a/sway-core/src/ir_generation/convert.rs +++ b/sway-core/src/ir_generation/convert.rs @@ -41,7 +41,7 @@ pub(super) fn convert_literal_to_constant( Literal::String(s) => ConstantContent::new_string(context, s.as_str().as_bytes().to_vec()), Literal::Boolean(b) => ConstantContent::new_bool(context, *b), Literal::B256(bs) => ConstantContent::new_b256(context, *bs), - Literal::Binary(_) => todo!(), + Literal::Binary(bytes) => ConstantContent::new_untyped_slice(context, bytes.clone()), }; Constant::unique(context, c) } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs index b9c6d8ccd86..2ce69f820a2 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs @@ -588,7 +588,7 @@ pub(crate) fn type_check_method_application( &mut ctx, span, method.return_type.type_id, - string_slice_literal(&method.name), + method_name_literal(&method.name), old_arguments.first().cloned().unwrap(), args, arguments.iter().map(|x| x.1.return_type).collect(), diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap index 3dd256e3096..4a1e25319ca 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract/stdout.snap @@ -8,17 +8,17 @@ output: Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib) Compiling contract panicking_contract (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract) - Finished debug [unoptimized + fuel] target(s) [8.512 KB] in ??? + Finished debug [unoptimized + fuel] target(s) [8.88 KB] in ??? Running 12 tests, filtered 0 tests tested -- panicking_contract - test test_panicking_in_contract_self_impl ... ok (???, 1245 gas) + test test_panicking_in_contract_self_impl ... ok (???, 1032 gas) revert code: 8000000000000001 ├─ panic message: panicking in contract self impl ├─ panicked: in ::panicking_in_contract_self_impl │ └─ at panicking_contract@1.2.3, src/main.sw:22:9 - test test_directly_panicking_method ... ok (???, 1774 gas) + test test_directly_panicking_method ... ok (???, 1561 gas) revert code: 8080000000000002 ├─ panic message: Error C. ├─ panic value: C(true) @@ -26,7 +26,7 @@ tested -- panicking_contract │ └─ at panicking_contract@1.2.3, src/main.sw:28:9 decoded log values: C(true), log rb: 5503570629422409978 - test test_nested_panic_inlined ... ok (???, 3470 gas) + test test_nested_panic_inlined ... ok (???, 3257 gas) revert code: 830000000540a013 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) @@ -38,7 +38,7 @@ C(true), log rb: 5503570629422409978 └─ at panicking_contract@1.2.3, src/main.sw:32:9 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_nested_panic_inlined_same_revert_code ... ok (???, 3470 gas) + test test_nested_panic_inlined_same_revert_code ... ok (???, 3257 gas) revert code: 830000000540a013 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) @@ -50,7 +50,7 @@ E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString └─ at panicking_contract@1.2.3, src/main.sw:32:9 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_nested_panic_non_inlined ... ok (???, 3798 gas) + test test_nested_panic_non_inlined ... ok (???, 3585 gas) revert code: 838000000680c818 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) @@ -62,7 +62,7 @@ E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString └─ at panicking_contract@1.2.3, src/main.sw:40:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_nested_panic_non_inlined_same_revert_code ... ok (???, 3798 gas) + test test_nested_panic_non_inlined_same_revert_code ... ok (???, 3585 gas) revert code: 838000000680c818 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) @@ -74,7 +74,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d └─ at panicking_contract@1.2.3, src/main.sw:40:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_generic_panic_with_unit ... ok (???, 2469 gas) + test test_generic_panic_with_unit ... ok (???, 2256 gas) revert code: 828000000000800f ├─ panic value: () ├─ panicked: in panicking_lib::generic_panic @@ -83,7 +83,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d └─ at panicking_contract@1.2.3, src/main.sw:48:9 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_unit_same_revert_code ... ok (???, 2469 gas) + test test_generic_panic_with_unit_same_revert_code ... ok (???, 2256 gas) revert code: 828000000000800f ├─ panic value: () ├─ panicked: in panicking_lib::generic_panic @@ -92,7 +92,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d └─ at panicking_contract@1.2.3, src/main.sw:48:9 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_str ... ok (???, 2421 gas) + test test_generic_panic_with_str ... ok (???, 2208 gas) revert code: 818000000000700d ├─ panic message: generic panic with string ├─ panicked: in panicking_lib::generic_panic @@ -101,7 +101,7 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d └─ at panicking_contract@1.2.3, src/main.sw:56:9 decoded log values: AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218 - test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1962 gas) + test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1749 gas) revert code: 8180000000004007 ├─ panic message: generic panic with different string ├─ panicked: in panicking_lib::generic_panic @@ -110,7 +110,7 @@ AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218 └─ at panicking_contract@1.2.3, src/main.sw:60:9 decoded log values: AsciiString { data: "generic panic with different string" }, log rb: 10098701174489624218 - test test_generic_panic_with_error_type_enum ... ok (???, 2146 gas) + test test_generic_panic_with_error_type_enum ... ok (???, 1933 gas) revert code: 8200000000005009 ├─ panic message: Error A. ├─ panic value: A @@ -120,7 +120,7 @@ AsciiString { data: "generic panic with different string" }, log rb: 10098701174 └─ at panicking_contract@1.2.3, src/main.sw:64:9 decoded log values: A, log rb: 5503570629422409978 - test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2378 gas) + test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 2165 gas) revert code: 820000000000600b ├─ panic message: Error B. ├─ panic value: B(42) @@ -142,17 +142,17 @@ output: Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling library panicking_lib (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_lib) Compiling contract panicking_contract (test/src/e2e_vm_tests/test_programs/should_pass/language/panic_expression/panicking_contract) - Finished release [optimized + fuel] target(s) [7.024 KB] in ??? + Finished release [optimized + fuel] target(s) [7.4 KB] in ??? Running 12 tests, filtered 0 tests tested -- panicking_contract - test test_panicking_in_contract_self_impl ... ok (???, 869 gas) + test test_panicking_in_contract_self_impl ... ok (???, 673 gas) revert code: 8000000000000000 ├─ panic message: panicking in contract self impl └─ panicked: in ::panicking_in_contract_self_impl └─ at panicking_contract@1.2.3, src/main.sw:22:9 - test test_directly_panicking_method ... ok (???, 1291 gas) + test test_directly_panicking_method ... ok (???, 1095 gas) revert code: 8080000000000000 ├─ panic message: Error C. ├─ panic value: C(true) @@ -160,7 +160,7 @@ tested -- panicking_contract └─ at panicking_contract@1.2.3, src/main.sw:28:9 decoded log values: C(true), log rb: 5503570629422409978 - test test_nested_panic_inlined ... ok (???, 2537 gas) + test test_nested_panic_inlined ... ok (???, 2341 gas) revert code: 8300000000000000 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) @@ -168,7 +168,7 @@ C(true), log rb: 5503570629422409978 └─ at panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_nested_panic_inlined_same_revert_code ... ok (???, 2537 gas) + test test_nested_panic_inlined_same_revert_code ... ok (???, 2341 gas) revert code: 8300000000000000 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]) @@ -176,7 +176,7 @@ E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString └─ at panicking_lib, src/lib.sw:35:5 decoded log values: E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString { data: "in error enum variants" }]), log rb: 5503570629422409978 - test test_nested_panic_non_inlined ... ok (???, 2767 gas) + test test_nested_panic_non_inlined ... ok (???, 2571 gas) revert code: 8380000000000000 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) @@ -184,7 +184,7 @@ E([AsciiString { data: "to have" }, AsciiString { data: "strings" }, AsciiString └─ at panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_nested_panic_non_inlined_same_revert_code ... ok (???, 2767 gas) + test test_nested_panic_non_inlined_same_revert_code ... ok (???, 2571 gas) revert code: 8380000000000000 ├─ panic message: Error E. ├─ panic value: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]) @@ -192,35 +192,35 @@ E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { d └─ at panicking_lib, src/lib.sw:41:9 decoded log values: E([AsciiString { data: "this" }, AsciiString { data: "is not" }, AsciiString { data: "the best practice" }]), log rb: 5503570629422409978 - test test_generic_panic_with_unit ... ok (???, 1739 gas) + test test_generic_panic_with_unit ... ok (???, 1543 gas) revert code: 8280000000000000 ├─ panic value: () └─ panicked: in panicking_lib::generic_panic └─ at panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_unit_same_revert_code ... ok (???, 1739 gas) + test test_generic_panic_with_unit_same_revert_code ... ok (???, 1543 gas) revert code: 8280000000000000 ├─ panic value: () └─ panicked: in panicking_lib::generic_panic └─ at panicking_lib, src/lib.sw:74:5 decoded log values: (), log rb: 3330666440490685604 - test test_generic_panic_with_str ... ok (???, 1743 gas) + test test_generic_panic_with_str ... ok (???, 1547 gas) revert code: 8180000000000000 ├─ panic message: generic panic with string └─ panicked: in panicking_lib::generic_panic └─ at panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic with string" }, log rb: 10098701174489624218 - test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1425 gas) + test test_generic_panic_with_different_str_same_revert_code ... ok (???, 1229 gas) revert code: 8180000000000000 ├─ panic message: generic panic with different string └─ panicked: in panicking_lib::generic_panic └─ at panicking_lib, src/lib.sw:74:5 decoded log values: AsciiString { data: "generic panic with different string" }, log rb: 10098701174489624218 - test test_generic_panic_with_error_type_enum ... ok (???, 1546 gas) + test test_generic_panic_with_error_type_enum ... ok (???, 1350 gas) revert code: 8200000000000000 ├─ panic message: Error A. ├─ panic value: A @@ -228,7 +228,7 @@ AsciiString { data: "generic panic with different string" }, log rb: 10098701174 └─ at panicking_lib, src/lib.sw:74:5 decoded log values: A, log rb: 5503570629422409978 - test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 1709 gas) + test test_generic_panic_with_error_type_enum_different_variant_same_revert_code ... ok (???, 1513 gas) revert code: 8200000000000000 ├─ panic message: Error B. ├─ panic value: B(42) diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap index 698fdd6ea6d..39fbd1d36b2 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap @@ -7,40 +7,40 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [39.864 KB] in ??? + Finished release [optimized + fuel] target(s) [37.584 KB] in ??? Running 29 tests, filtered 0 tests tested -- const_of_contract_call - test cost_of_in_bool ... ok (???, 2467 gas) - test cost_of_in_u8 ... ok (???, 4712 gas) - test cost_of_in_u16 ... ok (???, 4337 gas) - test cost_of_in_u32 ... ok (???, 4766 gas) - test cost_of_in_u64 ... ok (???, 4778 gas) - test cost_of_in_u256 ... ok (???, 4621 gas) - test cost_of_in_b256 ... ok (???, 2340 gas) - test cost_of_in_str_0 ... ok (???, 2890 gas) - test cost_of_in_str_1 ... ok (???, 3189 gas) - test cost_of_in_str_8 ... ok (???, 3612 gas) - test cost_of_in_str_16 ... ok (???, 3220 gas) - test cost_of_in_str_32 ... ok (???, 3420 gas) - test cost_of_in_array_0 ... FAILED (???, 1477 gas) - test cost_of_in_array_1 ... ok (???, 1974 gas) - test cost_of_in_array_8 ... ok (???, 4581 gas) - test cost_of_in_array_16 ... ok (???, 4953 gas) - test cost_of_in_array_32 ... ok (???, 8278 gas) - test cost_of_in_array_64 ... ok (???, 14731 gas) - test cost_of_in_tuple_0 ... ok (???, 3672 gas) - test cost_of_in_tuple_1 ... ok (???, 4237 gas) - test cost_of_in_tuple_2 ... ok (???, 4607 gas) - test cost_of_in_tuple_3 ... ok (???, 4950 gas) - test cost_of_in_tuple_4 ... ok (???, 5319 gas) - test in_struct_u64 ... ok (???, 3483 gas) - test in_struct_u64_u64 ... ok (???, 3743 gas) - test in_struct_u64_u64_u64 ... ok (???, 4002 gas) - test in_enum_u64 ... ok (???, 3042 gas) - test in_enum_u64_u64 ... ok (???, 2917 gas) - test in_enum_u64_u64_u64 ... ok (???, 3029 gas) + test cost_of_in_bool ... ok (???, 2124 gas) + test cost_of_in_u8 ... ok (???, 4368 gas) + test cost_of_in_u16 ... ok (???, 3993 gas) + test cost_of_in_u32 ... ok (???, 4422 gas) + test cost_of_in_u64 ... ok (???, 4434 gas) + test cost_of_in_u256 ... ok (???, 4277 gas) + test cost_of_in_b256 ... ok (???, 1997 gas) + test cost_of_in_str_0 ... ok (???, 2547 gas) + test cost_of_in_str_1 ... ok (???, 2845 gas) + test cost_of_in_str_8 ... ok (???, 3268 gas) + test cost_of_in_str_16 ... ok (???, 2876 gas) + test cost_of_in_str_32 ... ok (???, 3073 gas) + test cost_of_in_array_0 ... FAILED (???, 1130 gas) + test cost_of_in_array_1 ... ok (???, 1627 gas) + test cost_of_in_array_8 ... ok (???, 4237 gas) + test cost_of_in_array_16 ... ok (???, 4608 gas) + test cost_of_in_array_32 ... ok (???, 7933 gas) + test cost_of_in_array_64 ... ok (???, 14387 gas) + test cost_of_in_tuple_0 ... ok (???, 3327 gas) + test cost_of_in_tuple_1 ... ok (???, 3892 gas) + test cost_of_in_tuple_2 ... ok (???, 4263 gas) + test cost_of_in_tuple_3 ... ok (???, 4606 gas) + test cost_of_in_tuple_4 ... ok (???, 4975 gas) + test in_struct_u64 ... ok (???, 3137 gas) + test in_struct_u64_u64 ... ok (???, 3399 gas) + test in_struct_u64_u64_u64 ... ok (???, 3658 gas) + test in_enum_u64 ... ok (???, 2697 gas) + test in_enum_u64_u64 ... ok (???, 2572 gas) + test in_enum_u64_u64_u64 ... ok (???, 2684 gas) failures: test cost_of_in_array_0, "test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/src/main.sw":347 @@ -62,12 +62,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.336 KB] in ??? + Finished release [optimized + fuel] target(s) [1.888 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_0 ... FAILED (???, 956 gas) + test isolated_cost_of_in_array_0 ... FAILED (???, 826 gas) failures: test isolated_cost_of_in_array_0, "test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/src/main.sw":175 @@ -89,12 +89,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.512 KB] in ??? + Finished release [optimized + fuel] target(s) [2.064 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_1 ... ok (???, 1185 gas) + test isolated_cost_of_in_array_1 ... ok (???, 1059 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -109,12 +109,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.544 KB] in ??? + Finished release [optimized + fuel] target(s) [2.096 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_16 ... ok (???, 3266 gas) + test isolated_cost_of_in_array_16 ... ok (???, 3144 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -129,12 +129,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.544 KB] in ??? + Finished release [optimized + fuel] target(s) [2.096 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_32 ... ok (???, 5471 gas) + test isolated_cost_of_in_array_32 ... ok (???, 5349 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -149,12 +149,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.544 KB] in ??? + Finished release [optimized + fuel] target(s) [2.096 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_64 ... ok (???, 9914 gas) + test isolated_cost_of_in_array_64 ... ok (???, 9774 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -169,12 +169,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.68 KB] in ??? + Finished release [optimized + fuel] target(s) [2.232 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_8 ... ok (???, 2728 gas) + test isolated_cost_of_in_array_8 ... ok (???, 2607 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -189,12 +189,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.392 KB] in ??? + Finished release [optimized + fuel] target(s) [1.936 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_b256 ... ok (???, 1120 gas) + test isolated_cost_of_in_b256 ... ok (???, 998 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -209,12 +209,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.368 KB] in ??? + Finished release [optimized + fuel] target(s) [1.808 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_bool ... ok (???, 1047 gas) + test isolated_cost_of_in_bool ... ok (???, 922 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -229,12 +229,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.88 KB] in ??? + Finished release [optimized + fuel] target(s) [2.136 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_enum_u64 ... ok (???, 1333 gas) + test in_enum_u64 ... ok (???, 1211 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -249,12 +249,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.408 KB] in ??? + Finished release [optimized + fuel] target(s) [2.288 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_enum_u64_u64 ... ok (???, 1347 gas) + test in_enum_u64_u64 ... ok (???, 1225 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -269,12 +269,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.584 KB] in ??? + Finished release [optimized + fuel] target(s) [2.472 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_enum_u64_u64_u64 ... ok (???, 1350 gas) + test in_enum_u64_u64_u64 ... ok (???, 1228 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -289,12 +289,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.984 KB] in ??? + Finished release [optimized + fuel] target(s) [1.848 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_0 ... ok (???, 1140 gas) + test isolated_cost_of_in_str_0 ... ok (???, 1018 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -309,12 +309,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.184 KB] in ??? + Finished release [optimized + fuel] target(s) [2.056 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_1 ... ok (???, 1237 gas) + test isolated_cost_of_in_str_1 ... ok (???, 1111 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -329,12 +329,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.224 KB] in ??? + Finished release [optimized + fuel] target(s) [2.096 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_16 ... ok (???, 1241 gas) + test isolated_cost_of_in_str_16 ... ok (???, 1115 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -349,12 +349,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.24 KB] in ??? + Finished release [optimized + fuel] target(s) [2.104 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_32 ... ok (???, 1242 gas) + test isolated_cost_of_in_str_32 ... ok (???, 1116 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -369,12 +369,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.2 KB] in ??? + Finished release [optimized + fuel] target(s) [2.072 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_8 ... ok (???, 1241 gas) + test isolated_cost_of_in_str_8 ... ok (???, 1115 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -389,12 +389,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.072 KB] in ??? + Finished release [optimized + fuel] target(s) [1.936 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_struct_u64 ... ok (???, 1113 gas) + test in_struct_u64 ... ok (???, 986 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -409,12 +409,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.2 KB] in ??? + Finished release [optimized + fuel] target(s) [2.08 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_struct_u64_u64 ... ok (???, 1304 gas) + test in_struct_u64_u64 ... ok (???, 1177 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -429,12 +429,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.272 KB] in ??? + Finished release [optimized + fuel] target(s) [2.144 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_struct_u64_u64_u64 ... ok (???, 1455 gas) + test in_struct_u64_u64_u64 ... ok (???, 1328 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -449,12 +449,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.472 KB] in ??? + Finished release [optimized + fuel] target(s) [1.216 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_0 ... ok (???, 820 gas) + test isolated_cost_of_in_tuple_0 ... ok (???, 658 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -469,12 +469,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.016 KB] in ??? + Finished release [optimized + fuel] target(s) [1.88 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_1 ... ok (???, 1090 gas) + test isolated_cost_of_in_tuple_1 ... ok (???, 962 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -489,12 +489,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.192 KB] in ??? + Finished release [optimized + fuel] target(s) [2.064 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_2 ... ok (???, 1304 gas) + test isolated_cost_of_in_tuple_2 ... ok (???, 1177 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -509,12 +509,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.264 KB] in ??? + Finished release [optimized + fuel] target(s) [2.128 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_3 ... ok (???, 1455 gas) + test isolated_cost_of_in_tuple_3 ... ok (???, 1328 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -529,12 +529,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.328 KB] in ??? + Finished release [optimized + fuel] target(s) [2.2 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_4 ... ok (???, 1605 gas) + test isolated_cost_of_in_tuple_4 ... ok (???, 1478 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -549,12 +549,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.976 KB] in ??? + Finished release [optimized + fuel] target(s) [1.864 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u16 ... ok (???, 1117 gas) + test isolated_cost_of_in_u16 ... ok (???, 999 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -569,12 +569,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.064 KB] in ??? + Finished release [optimized + fuel] target(s) [1.936 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u256 ... ok (???, 1120 gas) + test isolated_cost_of_in_u256 ... ok (???, 998 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -589,12 +589,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.088 KB] in ??? + Finished release [optimized + fuel] target(s) [1.944 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u32 ... ok (???, 1243 gas) + test isolated_cost_of_in_u32 ... ok (???, 1117 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -609,12 +609,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.88 KB] in ??? + Finished release [optimized + fuel] target(s) [1.744 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u64 ... ok (???, 1025 gas) + test isolated_cost_of_in_u64 ... ok (???, 901 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -629,12 +629,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.344 KB] in ??? + Finished release [optimized + fuel] target(s) [1.784 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u8 ... ok (???, 1041 gas) + test isolated_cost_of_in_u8 ... ok (???, 916 gas) test result: OK. 1 passed; 0 failed; finished in ??? From 1db5915171fd92a7ceeaf6f246474ba88f21c28a Mon Sep 17 00:00:00 2001 From: xunilrj Date: Mon, 20 Oct 2025 15:59:08 -0300 Subject: [PATCH 10/17] fix rebase issues --- scripts/csv2html/csv2html.sh | 4 ---- sway-core/src/ir_generation/convert.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/csv2html/csv2html.sh b/scripts/csv2html/csv2html.sh index a1b079cdfef..c77bdd239b7 100755 --- a/scripts/csv2html/csv2html.sh +++ b/scripts/csv2html/csv2html.sh @@ -57,8 +57,4 @@ tail -n +2 "$1" | sed -e 's/^//' -e 's/,/<\/td>/g' -e 's/$/<\/td><\/ echo " -<<<<<<< HEAD " -======= -" ->>>>>>> bdd5b43f5 (fixing CI) diff --git a/sway-core/src/ir_generation/convert.rs b/sway-core/src/ir_generation/convert.rs index 6cc8e8321dc..a1f535f426b 100644 --- a/sway-core/src/ir_generation/convert.rs +++ b/sway-core/src/ir_generation/convert.rs @@ -14,6 +14,15 @@ use sway_types::{integer_bits::IntegerBits, span::Span}; pub(super) fn convert_literal_to_value(context: &mut Context, ast_literal: &Literal) -> Value { match ast_literal { + // In Sway for now we don't have `as` casting and for integers which may be implicitly cast + // between widths we just emit a warning, and essentially ignore it. We also assume a + // 'Numeric' integer of undetermined width is 'u64`. The IR would like to be type + // consistent and doesn't tolerate missing integers of different width, so for now, until we + // do introduce explicit `as` casting, all integers are `u64` as far as the IR is + // concerned. + // + // XXX The above isn't true for other targets. We need to improved this. + // FIXME Literal::U8(n) => ConstantContent::get_uint(context, 8, *n as u64), Literal::U16(n) => ConstantContent::get_uint(context, 64, *n as u64), Literal::U32(n) => ConstantContent::get_uint(context, 64, *n as u64), @@ -32,6 +41,7 @@ pub(super) fn convert_literal_to_constant( ast_literal: &Literal, ) -> Constant { let c = match ast_literal { + // All integers are `u64`. See comment above. Literal::U8(n) => ConstantContent::new_uint(context, 8, *n as u64), Literal::U16(n) => ConstantContent::new_uint(context, 64, *n as u64), Literal::U32(n) => ConstantContent::new_uint(context, 64, *n as u64), From 6a33e0ea06e52bbb7917f1e47e32fe61fd818d5d Mon Sep 17 00:00:00 2001 From: xunilrj Date: Tue, 21 Oct 2025 12:27:58 -0300 Subject: [PATCH 11/17] fix dynamic contract call --- .../should_pass/test_contracts/dynamic_contract_call/src/lib.sw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/dynamic_contract_call/src/lib.sw b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/dynamic_contract_call/src/lib.sw index 1a261f8dce1..4e039515afa 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/dynamic_contract_call/src/lib.sw +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/dynamic_contract_call/src/lib.sw @@ -19,7 +19,7 @@ pub fn dynamic_contract_call(contract_id: b256) -> u64 { #[cfg(experimental_new_encoding = true)] pub fn dynamic_contract_call(contract_id: b256) -> u64 { contract_call::(contract_id, - "some_method_name", + encode("some_method_name"), (1, 2, 3), 0, 0x0000000000000000000000000000000000000000000000000000000000000000, From 3b4f6727688133b3eaab1ff71aaf0323917eb207 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Tue, 21 Oct 2025 13:38:25 -0300 Subject: [PATCH 12/17] running require_contract_deployment sequentially --- test/src/e2e_vm_tests/mod.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/src/e2e_vm_tests/mod.rs b/test/src/e2e_vm_tests/mod.rs index b119e0f3285..62732112bce 100644 --- a/test/src/e2e_vm_tests/mod.rs +++ b/test/src/e2e_vm_tests/mod.rs @@ -1209,15 +1209,6 @@ pub async fn run_in_parallel(filter_config: &FilterConfig, run_config: &RunConfi &failed_tests, ); - // 2. Run "run_on_node" tests that don't share contracts in parallel over different wallets. - let mut run_on_node_tests_per_wallet = HashMap::new(); - for test in run_on_node_tests.iter() { - let signing_key = *test.expect_signing_key(); - run_on_node_tests_per_wallet - .entry(signing_key) - .or_insert_with(Vec::new) - .push(test); - } let longest_wallet_test_chain_size = run_on_node_tests_per_wallet .values() .max_by_key(|tests| tests.len()) From 580b232096d64c3e3fc7bb1ac30aeff78dbadf57 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Wed, 22 Oct 2025 11:59:07 -0300 Subject: [PATCH 13/17] fix rebase issues --- test/src/e2e_vm_tests/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/src/e2e_vm_tests/mod.rs b/test/src/e2e_vm_tests/mod.rs index 62732112bce..b119e0f3285 100644 --- a/test/src/e2e_vm_tests/mod.rs +++ b/test/src/e2e_vm_tests/mod.rs @@ -1209,6 +1209,15 @@ pub async fn run_in_parallel(filter_config: &FilterConfig, run_config: &RunConfi &failed_tests, ); + // 2. Run "run_on_node" tests that don't share contracts in parallel over different wallets. + let mut run_on_node_tests_per_wallet = HashMap::new(); + for test in run_on_node_tests.iter() { + let signing_key = *test.expect_signing_key(); + run_on_node_tests_per_wallet + .entry(signing_key) + .or_insert_with(Vec::new) + .push(test); + } let longest_wallet_test_chain_size = run_on_node_tests_per_wallet .values() .max_by_key(|tests| tests.len()) From f2bebaeec8d6b21739af1f9ef409708c9417c35d Mon Sep 17 00:00:00 2001 From: xunilrj Date: Wed, 22 Oct 2025 16:27:55 -0300 Subject: [PATCH 14/17] removing todos --- sway-core/src/language/literal.rs | 8 ++++++-- .../expression/match_expression/analysis/pattern.rs | 4 +++- sway-lib-std/src/codec.sw | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sway-core/src/language/literal.rs b/sway-core/src/language/literal.rs index db67e712176..953bea49015 100644 --- a/sway-core/src/language/literal.rs +++ b/sway-core/src/language/literal.rs @@ -116,7 +116,11 @@ impl fmt::Display for Literal { .map(|x| x.to_string()) .collect::>() .join(", "), - Literal::Binary(_) => todo!(), + Literal::Binary(content) => content + .iter() + .map(|x| x.to_string()) + .collect::>() + .join(", "), }; write!(f, "{s}") } @@ -160,7 +164,7 @@ impl Literal { Literal::U256(_) => TypeInfo::UnsignedInteger(IntegerBits::V256), Literal::Boolean(_) => TypeInfo::Boolean, Literal::B256(_) => TypeInfo::B256, - Literal::Binary(_) => todo!(), + Literal::Binary(_) => TypeInfo::RawUntypedSlice, } } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs index d3898662f40..1e835568c81 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs @@ -180,7 +180,9 @@ impl Pattern { Literal::Boolean(b) => Pattern::Boolean(b), Literal::Numeric(x) => Pattern::Numeric(Range::from_single(x)), Literal::String(s) => Pattern::String(s.as_str().to_string()), - Literal::Binary(_) => todo!(), + Literal::Binary(_) => { + unreachable!("literals cannot be expressed in the language yet") + }, } } diff --git a/sway-lib-std/src/codec.sw b/sway-lib-std/src/codec.sw index e02e1272d52..1b45e57a97f 100644 --- a/sway-lib-std/src/codec.sw +++ b/sway-lib-std/src/codec.sw @@ -5345,7 +5345,6 @@ where // END TUPLES_DECODE use ::ops::*; -#[inline(never)] pub fn contract_call( contract_id: b256, method_name: raw_slice, From 8bc7709b295cb21f64c105c1c5530a28bdb3cba9 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Wed, 22 Oct 2025 16:31:44 -0300 Subject: [PATCH 15/17] fmt and clippy issues --- .../ast_node/expression/match_expression/analysis/pattern.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs index 1e835568c81..9b898852ed2 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/match_expression/analysis/pattern.rs @@ -182,7 +182,7 @@ impl Pattern { Literal::String(s) => Pattern::String(s.as_str().to_string()), Literal::Binary(_) => { unreachable!("literals cannot be expressed in the language yet") - }, + } } } From 9104192a2a5366b2c0b535cab1a9bbc668ef04b6 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Thu, 23 Oct 2025 06:46:28 -0300 Subject: [PATCH 16/17] update tests --- .../const_of_contract_call/stdout.snap | 176 +++++++++--------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap index 39fbd1d36b2..abb135b5b79 100644 --- a/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap +++ b/test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/stdout.snap @@ -7,40 +7,40 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [37.584 KB] in ??? + Finished release [optimized + fuel] target(s) [35.272 KB] in ??? Running 29 tests, filtered 0 tests tested -- const_of_contract_call - test cost_of_in_bool ... ok (???, 2124 gas) - test cost_of_in_u8 ... ok (???, 4368 gas) - test cost_of_in_u16 ... ok (???, 3993 gas) - test cost_of_in_u32 ... ok (???, 4422 gas) - test cost_of_in_u64 ... ok (???, 4434 gas) - test cost_of_in_u256 ... ok (???, 4277 gas) - test cost_of_in_b256 ... ok (???, 1997 gas) - test cost_of_in_str_0 ... ok (???, 2547 gas) - test cost_of_in_str_1 ... ok (???, 2845 gas) - test cost_of_in_str_8 ... ok (???, 3268 gas) - test cost_of_in_str_16 ... ok (???, 2876 gas) - test cost_of_in_str_32 ... ok (???, 3073 gas) - test cost_of_in_array_0 ... FAILED (???, 1130 gas) - test cost_of_in_array_1 ... ok (???, 1627 gas) - test cost_of_in_array_8 ... ok (???, 4237 gas) - test cost_of_in_array_16 ... ok (???, 4608 gas) - test cost_of_in_array_32 ... ok (???, 7933 gas) - test cost_of_in_array_64 ... ok (???, 14387 gas) - test cost_of_in_tuple_0 ... ok (???, 3327 gas) - test cost_of_in_tuple_1 ... ok (???, 3892 gas) - test cost_of_in_tuple_2 ... ok (???, 4263 gas) - test cost_of_in_tuple_3 ... ok (???, 4606 gas) - test cost_of_in_tuple_4 ... ok (???, 4975 gas) - test in_struct_u64 ... ok (???, 3137 gas) - test in_struct_u64_u64 ... ok (???, 3399 gas) - test in_struct_u64_u64_u64 ... ok (???, 3658 gas) - test in_enum_u64 ... ok (???, 2697 gas) - test in_enum_u64_u64 ... ok (???, 2572 gas) - test in_enum_u64_u64_u64 ... ok (???, 2684 gas) + test cost_of_in_bool ... ok (???, 2082 gas) + test cost_of_in_u8 ... ok (???, 4331 gas) + test cost_of_in_u16 ... ok (???, 3948 gas) + test cost_of_in_u32 ... ok (???, 4389 gas) + test cost_of_in_u64 ... ok (???, 4397 gas) + test cost_of_in_u256 ... ok (???, 4240 gas) + test cost_of_in_b256 ... ok (???, 1954 gas) + test cost_of_in_str_0 ... ok (???, 2505 gas) + test cost_of_in_str_1 ... ok (???, 2806 gas) + test cost_of_in_str_8 ... ok (???, 3229 gas) + test cost_of_in_str_16 ... ok (???, 2837 gas) + test cost_of_in_str_32 ... ok (???, 3035 gas) + test cost_of_in_array_0 ... FAILED (???, 1095 gas) + test cost_of_in_array_1 ... ok (???, 1589 gas) + test cost_of_in_array_8 ... ok (???, 4192 gas) + test cost_of_in_array_16 ... ok (???, 4563 gas) + test cost_of_in_array_32 ... ok (???, 7889 gas) + test cost_of_in_array_64 ... ok (???, 14352 gas) + test cost_of_in_tuple_0 ... ok (???, 3289 gas) + test cost_of_in_tuple_1 ... ok (???, 3860 gas) + test cost_of_in_tuple_2 ... ok (???, 4228 gas) + test cost_of_in_tuple_3 ... ok (???, 4571 gas) + test cost_of_in_tuple_4 ... ok (???, 4935 gas) + test in_struct_u64 ... ok (???, 3103 gas) + test in_struct_u64_u64 ... ok (???, 3364 gas) + test in_struct_u64_u64_u64 ... ok (???, 3623 gas) + test in_enum_u64 ... ok (???, 2653 gas) + test in_enum_u64_u64 ... ok (???, 2528 gas) + test in_enum_u64_u64_u64 ... ok (???, 2640 gas) failures: test cost_of_in_array_0, "test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/src/main.sw":347 @@ -62,12 +62,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.888 KB] in ??? + Finished release [optimized + fuel] target(s) [1.768 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_0 ... FAILED (???, 826 gas) + test isolated_cost_of_in_array_0 ... FAILED (???, 795 gas) failures: test isolated_cost_of_in_array_0, "test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call/src/main.sw":175 @@ -89,12 +89,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.064 KB] in ??? + Finished release [optimized + fuel] target(s) [1.944 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_1 ... ok (???, 1059 gas) + test isolated_cost_of_in_array_1 ... ok (???, 1025 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -109,12 +109,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.096 KB] in ??? + Finished release [optimized + fuel] target(s) [1.968 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_16 ... ok (???, 3144 gas) + test isolated_cost_of_in_array_16 ... ok (???, 3105 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -129,12 +129,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.096 KB] in ??? + Finished release [optimized + fuel] target(s) [1.968 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_32 ... ok (???, 5349 gas) + test isolated_cost_of_in_array_32 ... ok (???, 5311 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -149,12 +149,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.096 KB] in ??? + Finished release [optimized + fuel] target(s) [2.008 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_64 ... ok (???, 9774 gas) + test isolated_cost_of_in_array_64 ... ok (???, 9745 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -169,12 +169,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.232 KB] in ??? + Finished release [optimized + fuel] target(s) [2.104 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_array_8 ... ok (???, 2607 gas) + test isolated_cost_of_in_array_8 ... ok (???, 2568 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -189,12 +189,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.936 KB] in ??? + Finished release [optimized + fuel] target(s) [1.808 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_b256 ... ok (???, 998 gas) + test isolated_cost_of_in_b256 ... ok (???, 959 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -209,12 +209,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.808 KB] in ??? + Finished release [optimized + fuel] target(s) [1.696 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_bool ... ok (???, 922 gas) + test isolated_cost_of_in_bool ... ok (???, 886 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -229,12 +229,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.136 KB] in ??? + Finished release [optimized + fuel] target(s) [2.008 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_enum_u64 ... ok (???, 1211 gas) + test in_enum_u64 ... ok (???, 1173 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -249,12 +249,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.288 KB] in ??? + Finished release [optimized + fuel] target(s) [2.16 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_enum_u64_u64 ... ok (???, 1225 gas) + test in_enum_u64_u64 ... ok (???, 1187 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -269,12 +269,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.472 KB] in ??? + Finished release [optimized + fuel] target(s) [2.344 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_enum_u64_u64_u64 ... ok (???, 1228 gas) + test in_enum_u64_u64_u64 ... ok (???, 1190 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -289,12 +289,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.848 KB] in ??? + Finished release [optimized + fuel] target(s) [1.728 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_0 ... ok (???, 1018 gas) + test isolated_cost_of_in_str_0 ... ok (???, 980 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -309,12 +309,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.056 KB] in ??? + Finished release [optimized + fuel] target(s) [1.928 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_1 ... ok (???, 1111 gas) + test isolated_cost_of_in_str_1 ... ok (???, 1076 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -329,12 +329,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.096 KB] in ??? + Finished release [optimized + fuel] target(s) [1.976 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_16 ... ok (???, 1115 gas) + test isolated_cost_of_in_str_16 ... ok (???, 1080 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -349,12 +349,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.104 KB] in ??? + Finished release [optimized + fuel] target(s) [1.992 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_32 ... ok (???, 1116 gas) + test isolated_cost_of_in_str_32 ... ok (???, 1082 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -369,12 +369,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.072 KB] in ??? + Finished release [optimized + fuel] target(s) [1.944 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_str_8 ... ok (???, 1115 gas) + test isolated_cost_of_in_str_8 ... ok (???, 1080 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -389,12 +389,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.936 KB] in ??? + Finished release [optimized + fuel] target(s) [1.824 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_struct_u64 ... ok (???, 986 gas) + test in_struct_u64 ... ok (???, 953 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -409,12 +409,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.08 KB] in ??? + Finished release [optimized + fuel] target(s) [1.96 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_struct_u64_u64 ... ok (???, 1177 gas) + test in_struct_u64_u64 ... ok (???, 1144 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -429,12 +429,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.144 KB] in ??? + Finished release [optimized + fuel] target(s) [2.032 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test in_struct_u64_u64_u64 ... ok (???, 1328 gas) + test in_struct_u64_u64_u64 ... ok (???, 1294 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -449,12 +449,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.216 KB] in ??? + Finished release [optimized + fuel] target(s) [1.12 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_0 ... ok (???, 658 gas) + test isolated_cost_of_in_tuple_0 ... ok (???, 626 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -469,12 +469,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.88 KB] in ??? + Finished release [optimized + fuel] target(s) [1.768 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_1 ... ok (???, 962 gas) + test isolated_cost_of_in_tuple_1 ... ok (???, 930 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -489,12 +489,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.064 KB] in ??? + Finished release [optimized + fuel] target(s) [1.944 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_2 ... ok (???, 1177 gas) + test isolated_cost_of_in_tuple_2 ... ok (???, 1144 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -509,12 +509,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.128 KB] in ??? + Finished release [optimized + fuel] target(s) [2.016 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_3 ... ok (???, 1328 gas) + test isolated_cost_of_in_tuple_3 ... ok (???, 1294 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -529,12 +529,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [2.2 KB] in ??? + Finished release [optimized + fuel] target(s) [2.08 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_tuple_4 ... ok (???, 1478 gas) + test isolated_cost_of_in_tuple_4 ... ok (???, 1444 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -549,12 +549,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.864 KB] in ??? + Finished release [optimized + fuel] target(s) [1.72 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u16 ... ok (???, 999 gas) + test isolated_cost_of_in_u16 ... ok (???, 956 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -569,12 +569,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.936 KB] in ??? + Finished release [optimized + fuel] target(s) [1.808 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u256 ... ok (???, 998 gas) + test isolated_cost_of_in_u256 ... ok (???, 959 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -589,12 +589,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.944 KB] in ??? + Finished release [optimized + fuel] target(s) [1.832 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u32 ... ok (???, 1117 gas) + test isolated_cost_of_in_u32 ... ok (???, 1082 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -609,12 +609,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.744 KB] in ??? + Finished release [optimized + fuel] target(s) [1.624 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u64 ... ok (???, 901 gas) + test isolated_cost_of_in_u64 ... ok (???, 864 gas) test result: OK. 1 passed; 0 failed; finished in ??? @@ -629,12 +629,12 @@ output: Building test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call Compiling library std (test/src/e2e_vm_tests/reduced_std_libs/sway-lib-std-core) Compiling contract const_of_contract_call (test/src/e2e_vm_tests/test_programs/should_pass/test_contracts/const_of_contract_call) - Finished release [optimized + fuel] target(s) [1.784 KB] in ??? + Finished release [optimized + fuel] target(s) [1.664 KB] in ??? Running 1 test, filtered 0 tests tested -- const_of_contract_call - test isolated_cost_of_in_u8 ... ok (???, 916 gas) + test isolated_cost_of_in_u8 ... ok (???, 880 gas) test result: OK. 1 passed; 0 failed; finished in ??? From 6832509f04b72bd03f2fb5b768ddf11e91b47b23 Mon Sep 17 00:00:00 2001 From: xunilrj Date: Thu, 23 Oct 2025 12:12:29 -0300 Subject: [PATCH 17/17] PR adjustments --- sway-core/src/ir_generation/function.rs | 2 +- sway-core/src/language/literal.rs | 1 + .../expression/typed_expression/method_application.rs | 4 ++-- sway-lsp/src/traverse/parsed_tree.rs | 2 +- sway-lsp/src/utils/debug.rs | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sway-core/src/ir_generation/function.rs b/sway-core/src/ir_generation/function.rs index b42516aa15f..9b5196d4658 100644 --- a/sway-core/src/ir_generation/function.rs +++ b/sway-core/src/ir_generation/function.rs @@ -457,7 +457,7 @@ impl<'a> FnCompiler<'a> { )) } - // Can be used to raw untyped slice and string slice + // Can be used for raw untyped slice and string slice fn compile_slice( &mut self, context: &mut Context, diff --git a/sway-core/src/language/literal.rs b/sway-core/src/language/literal.rs index 953bea49015..171aa9a76de 100644 --- a/sway-core/src/language/literal.rs +++ b/sway-core/src/language/literal.rs @@ -95,6 +95,7 @@ impl PartialEq for Literal { (Self::Numeric(l0), Self::Numeric(r0)) => l0 == r0, (Self::Boolean(l0), Self::Boolean(r0)) => l0 == r0, (Self::B256(l0), Self::B256(r0)) => l0 == r0, + (Self::Binary(l0), Self::Binary(r0)) => l0 == r0, _ => false, } } diff --git a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs index 2ce69f820a2..ee461a139db 100644 --- a/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs +++ b/sway-core/src/semantic_analysis/ast_node/expression/typed_expression/method_application.rs @@ -534,10 +534,10 @@ pub(crate) fn type_check_method_application( } fn method_name_literal(method_name: &BaseIdent) -> Expression { - let method_name_str = method_name.as_str().to_string(); + let method_name_str = method_name.as_str(); let len_bytes = (method_name_str.len() as u64).to_be_bytes(); - let mut blob = vec![]; + let mut blob = Vec::with_capacity(len_bytes.len() + method_name_str.len()); blob.extend(len_bytes); blob.extend(method_name_str.as_bytes()); diff --git a/sway-lsp/src/traverse/parsed_tree.rs b/sway-lsp/src/traverse/parsed_tree.rs index 8580e4c7717..dc93bb2ca58 100644 --- a/sway-lsp/src/traverse/parsed_tree.rs +++ b/sway-lsp/src/traverse/parsed_tree.rs @@ -1252,6 +1252,6 @@ fn literal_to_symbol_kind(value: &Literal) -> SymbolKind { Literal::String(..) => SymbolKind::StringLiteral, Literal::B256(..) => SymbolKind::ByteLiteral, Literal::Boolean(..) => SymbolKind::BoolLiteral, - Literal::Binary(_) => todo!(), + Literal::Binary(_) => unreachable!("literals cannot be expressed in the language yet"), } } diff --git a/sway-lsp/src/utils/debug.rs b/sway-lsp/src/utils/debug.rs index e4678457ec1..dcb2ab0cebd 100644 --- a/sway-lsp/src/utils/debug.rs +++ b/sway-lsp/src/utils/debug.rs @@ -67,7 +67,7 @@ fn literal_to_string(literal: &Literal) -> String { Literal::String(len) => format!("str[{}]", len.as_str().len()), Literal::Boolean(_) => "bool".into(), Literal::B256(_) => "b256".into(), - Literal::Binary(_) => todo!(), + Literal::Binary(_) => unreachable!("literals cannot be expressed in the language yet"), } }