From af579a63279ff3bd310764598865c25afc0ef999 Mon Sep 17 00:00:00 2001 From: atarpara Date: Tue, 30 Dec 2025 19:27:16 +0530 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=90=9E=20Fix=20packTwo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- foundry.toml | 5 +++++ src/utils/LibString.sol | 2 +- test/LibString.t.sol | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/foundry.toml b/foundry.toml index bcfe0c08a..91177180f 100644 --- a/foundry.toml +++ b/foundry.toml @@ -15,6 +15,8 @@ fs_permissions = [{ access = "read", path = "./test/data"}] remappings = [ "forge-std=test/utils/forge-std/" ] +# remove memory-safe-assembly warning from complier +ignored_error_codes = [2424,8429,4591] [profile.pre_global_structs] skip = ["*/g/*", "*/*7702*", "*/*BlockHashLib*", "*/*Transient*", "*/ext/ithaca/*", "*/ext/zksync/*"] @@ -46,6 +48,9 @@ remappings = [ "forge-std=test/utils/forge-std/" ] +[lint] +lint_on_build = false + [fmt] line_length = 100 # While we allow up to 120, we lint at 100 for readability. ignore = ["src/accounts/EIP7702Proxy.sol"] diff --git a/src/utils/LibString.sol b/src/utils/LibString.sol index 708004f41..d84bacc68 100644 --- a/src/utils/LibString.sol +++ b/src/utils/LibString.sol @@ -926,7 +926,7 @@ library LibString { result := mul( or( // Load the length and the bytes of `a` and `b`. shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), - mload(sub(add(b, 0x1e), aLen)) + shr(shl(3, add(aLen, 1)), mload(add(b, 0x1f))) ), // `totalLen != 0 && totalLen < 31`. Abuses underflow. // Assumes that the lengths are valid and within the block gas limit. diff --git a/test/LibString.t.sol b/test/LibString.t.sol index 9b90f9973..c64555de4 100644 --- a/test/LibString.t.sol +++ b/test/LibString.t.sol @@ -1447,7 +1447,7 @@ contract LibStringTest is SoladyTest { } } - function testStringPackAndUnpackTwo() public { + function testStringPackAndUnpackTwo_O() public { unchecked { testStringPackAndUnpackTwo("", ""); testStringPackAndUnpackTwo("", ""); @@ -1456,6 +1456,8 @@ contract LibStringTest is SoladyTest { testStringPackAndUnpackTwo("abcdefghijklmnopqrstuvwxyzABCD", ""); testStringPackAndUnpackTwo("The strongest community I've ever seen", "NGL"); testStringPackAndUnpackTwo("", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + testStringPackAndUnpackTwo("01234567890123456789012345678901_search_search_search_search_search_search_23456789012345678901234567890123456789_search_search_search_search_search_search",""); + testStringPackAndUnpackTwoDifferential("01234567890123456789012345678901_search_search_search_search_search_search_23456789012345678901234567890123456789_search_search_search_search_search_search",""); } } From c57c7d7358bb8eebcc62be92c33a945b51531bb8 Mon Sep 17 00:00:00 2001 From: atarpara Date: Tue, 30 Dec 2025 19:31:41 +0530 Subject: [PATCH 2/5] f fmt --- test/LibString.t.sol | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/LibString.t.sol b/test/LibString.t.sol index c64555de4..45079460a 100644 --- a/test/LibString.t.sol +++ b/test/LibString.t.sol @@ -1456,8 +1456,14 @@ contract LibStringTest is SoladyTest { testStringPackAndUnpackTwo("abcdefghijklmnopqrstuvwxyzABCD", ""); testStringPackAndUnpackTwo("The strongest community I've ever seen", "NGL"); testStringPackAndUnpackTwo("", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); - testStringPackAndUnpackTwo("01234567890123456789012345678901_search_search_search_search_search_search_23456789012345678901234567890123456789_search_search_search_search_search_search",""); - testStringPackAndUnpackTwoDifferential("01234567890123456789012345678901_search_search_search_search_search_search_23456789012345678901234567890123456789_search_search_search_search_search_search",""); + testStringPackAndUnpackTwo( + "01234567890123456789012345678901_search_search_search_search_search_search_23456789012345678901234567890123456789_search_search_search_search_search_search", + "" + ); + testStringPackAndUnpackTwoDifferential( + "01234567890123456789012345678901_search_search_search_search_search_search_23456789012345678901234567890123456789_search_search_search_search_search_search", + "" + ); } } From b4ab3dcd6b3dc8ef90b78d993563ec1612783570 Mon Sep 17 00:00:00 2001 From: atarpara Date: Tue, 30 Dec 2025 19:32:22 +0530 Subject: [PATCH 3/5] T --- src/utils/g/LibString.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/g/LibString.sol b/src/utils/g/LibString.sol index b20eabf13..f7d03047e 100644 --- a/src/utils/g/LibString.sol +++ b/src/utils/g/LibString.sol @@ -930,7 +930,7 @@ library LibString { result := mul( or( // Load the length and the bytes of `a` and `b`. shl(shl(3, sub(0x1f, aLen)), mload(add(a, aLen))), - mload(sub(add(b, 0x1e), aLen)) + shr(shl(3, add(aLen, 1)), mload(add(b, 0x1f))) ), // `totalLen != 0 && totalLen < 31`. Abuses underflow. // Assumes that the lengths are valid and within the block gas limit. From a9ebd627a904a4dcea2718f7834d6333e8956288 Mon Sep 17 00:00:00 2001 From: atarpara Date: Tue, 30 Dec 2025 19:32:51 +0530 Subject: [PATCH 4/5] T --- test/LibString.t.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/LibString.t.sol b/test/LibString.t.sol index 45079460a..fac778ea2 100644 --- a/test/LibString.t.sol +++ b/test/LibString.t.sol @@ -1447,7 +1447,7 @@ contract LibStringTest is SoladyTest { } } - function testStringPackAndUnpackTwo_O() public { + function testStringPackAndUnpackTwo() public { unchecked { testStringPackAndUnpackTwo("", ""); testStringPackAndUnpackTwo("", ""); From 37f287965b6f1111d9738657b5621470add06b98 Mon Sep 17 00:00:00 2001 From: atarpara Date: Tue, 30 Dec 2025 19:35:37 +0530 Subject: [PATCH 5/5] fix typo --- foundry.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundry.toml b/foundry.toml index 91177180f..e502cbe48 100644 --- a/foundry.toml +++ b/foundry.toml @@ -15,7 +15,7 @@ fs_permissions = [{ access = "read", path = "./test/data"}] remappings = [ "forge-std=test/utils/forge-std/" ] -# remove memory-safe-assembly warning from complier +# remove memory-safe-assembly warning from compiler ignored_error_codes = [2424,8429,4591] [profile.pre_global_structs]