From d15cc4b51193c59d9f3122b025b6a791eb63f489 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 20 Oct 2025 22:12:30 +0400 Subject: [PATCH 01/11] update flake --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 133533e..894a168 100644 --- a/flake.lock +++ b/flake.lock @@ -158,11 +158,11 @@ "solc": "solc" }, "locked": { - "lastModified": 1758730752, - "narHash": "sha256-ZQ1INSsEWYgb1NdC5zo6nu1ObLzOCDI+wjiZ4222fQ8=", + "lastModified": 1760460761, + "narHash": "sha256-IHvwnmphDaOyZnzvObwOoDQlA9nzym2ZUxe9K/5vs0U=", "owner": "rainprotocol", "repo": "rainix", - "rev": "cc7c9bbbd9b817aa3a6a5c994262e14fb0bc920c", + "rev": "add0d8a1fd76ce0e65b962c952e9252257876465", "type": "github" }, "original": { From 749cef6cae27fc74a2d2cae2b4905dc551d59348 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 20 Oct 2025 22:20:42 +0400 Subject: [PATCH 02/11] foundry bump --- foundry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundry.lock b/foundry.lock index 169fc42..d2b1baf 100644 --- a/foundry.lock +++ b/foundry.lock @@ -1,6 +1,6 @@ { "lib/forge-std": { - "rev": "17a9b2398a7d629931dc66a168a098d051d53dc6" + "rev": "b8f065fda83b8cd94a6b2fec8fcd911dc3b444fd" }, "lib/openzeppelin-contracts": { "rev": "dc44c9f1a4c3b10af99492eed84f83ed244203f6" From 075c861714e1e24324a936ea479b8cf604f95f8c Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 20 Oct 2025 22:27:04 +0400 Subject: [PATCH 03/11] intorastring update --- foundry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundry.lock b/foundry.lock index d2b1baf..6c61141 100644 --- a/foundry.lock +++ b/foundry.lock @@ -6,7 +6,7 @@ "rev": "dc44c9f1a4c3b10af99492eed84f83ed244203f6" }, "lib/rain.intorastring": { - "rev": "e93a36d3f3814850a91eff75d7129dfcbaaf0cd5" + "rev": "82bc048226050a0e33c01c9f4282f3349a27e491" }, "lib/rain.lib.hash": { "rev": "d130af03ed5215b314499578486708095d08a918" From fd7712f0f596db441fda429860a4c86ce9d63619 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 20 Oct 2025 22:27:32 +0400 Subject: [PATCH 04/11] forge std update --- lib/forge-std | 2 +- lib/rain.intorastring | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/forge-std b/lib/forge-std index 17a9b23..b8f065f 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 17a9b2398a7d629931dc66a168a098d051d53dc6 +Subproject commit b8f065fda83b8cd94a6b2fec8fcd911dc3b444fd diff --git a/lib/rain.intorastring b/lib/rain.intorastring index e93a36d..82bc048 160000 --- a/lib/rain.intorastring +++ b/lib/rain.intorastring @@ -1 +1 @@ -Subproject commit e93a36d3f3814850a91eff75d7129dfcbaaf0cd5 +Subproject commit 82bc048226050a0e33c01c9f4282f3349a27e491 From 4f34a8cd60848129c4469c39e0c8f70740cd2ac8 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 21 Oct 2025 13:38:54 +0400 Subject: [PATCH 05/11] update lib hash --- foundry.lock | 2 +- lib/rain.lib.hash | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foundry.lock b/foundry.lock index 6c61141..92f3096 100644 --- a/foundry.lock +++ b/foundry.lock @@ -9,7 +9,7 @@ "rev": "82bc048226050a0e33c01c9f4282f3349a27e491" }, "lib/rain.lib.hash": { - "rev": "d130af03ed5215b314499578486708095d08a918" + "rev": "97609eecc66fe2e30f37e48834eed4a71304af32" }, "lib/rain.lib.typecast": { "rev": "9c533a0a0080d2edca6033c4a9b924afc635e41b" diff --git a/lib/rain.lib.hash b/lib/rain.lib.hash index d130af0..97609ee 160000 --- a/lib/rain.lib.hash +++ b/lib/rain.lib.hash @@ -1 +1 @@ -Subproject commit d130af03ed5215b314499578486708095d08a918 +Subproject commit 97609eecc66fe2e30f37e48834eed4a71304af32 From c5b850f9b89aeae9400408d93e10569420c9b80d Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 21 Oct 2025 13:49:31 +0400 Subject: [PATCH 06/11] update typecast --- foundry.lock | 2 +- lib/rain.lib.typecast | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foundry.lock b/foundry.lock index 92f3096..418c685 100644 --- a/foundry.lock +++ b/foundry.lock @@ -12,7 +12,7 @@ "rev": "97609eecc66fe2e30f37e48834eed4a71304af32" }, "lib/rain.lib.typecast": { - "rev": "9c533a0a0080d2edca6033c4a9b924afc635e41b" + "rev": "6bf6e0e63bfbff37d9057332ff042a8158397681" }, "lib/rain.math.binary": { "rev": "d4fea34509c8b2ed5411aff28233e4c52549b62d" diff --git a/lib/rain.lib.typecast b/lib/rain.lib.typecast index 9c533a0..6bf6e0e 160000 --- a/lib/rain.lib.typecast +++ b/lib/rain.lib.typecast @@ -1 +1 @@ -Subproject commit 9c533a0a0080d2edca6033c4a9b924afc635e41b +Subproject commit 6bf6e0e63bfbff37d9057332ff042a8158397681 From f7fb04684edb8ec30149df9405aee849c339a714 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 21 Oct 2025 14:03:22 +0400 Subject: [PATCH 07/11] math binary --- foundry.lock | 2 +- lib/rain.math.binary | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foundry.lock b/foundry.lock index 418c685..a061dff 100644 --- a/foundry.lock +++ b/foundry.lock @@ -15,7 +15,7 @@ "rev": "6bf6e0e63bfbff37d9057332ff042a8158397681" }, "lib/rain.math.binary": { - "rev": "d4fea34509c8b2ed5411aff28233e4c52549b62d" + "rev": "54450d62a89be456d07db1b9508f3b8a24dbb5f8" }, "lib/rain.math.float": { "rev": "78e15cb91b5c12ccacda8c8772a28eeb21f5b7d3" diff --git a/lib/rain.math.binary b/lib/rain.math.binary index d4fea34..54450d6 160000 --- a/lib/rain.math.binary +++ b/lib/rain.math.binary @@ -1 +1 @@ -Subproject commit d4fea34509c8b2ed5411aff28233e4c52549b62d +Subproject commit 54450d62a89be456d07db1b9508f3b8a24dbb5f8 From 2bce9516d71acdea208f0158926ed982272b2e1d Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 21 Oct 2025 17:22:36 +0400 Subject: [PATCH 08/11] update float --- foundry.lock | 2 +- lib/rain.math.float | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foundry.lock b/foundry.lock index a061dff..c3deb93 100644 --- a/foundry.lock +++ b/foundry.lock @@ -18,7 +18,7 @@ "rev": "54450d62a89be456d07db1b9508f3b8a24dbb5f8" }, "lib/rain.math.float": { - "rev": "78e15cb91b5c12ccacda8c8772a28eeb21f5b7d3" + "rev": "35b7b3980cdeab2f245dad17ee84658c1065648d" }, "lib/rain.sol.codegen": { "rev": "769792d577a7ecae954a7cdd64a222b8d6fe450d" diff --git a/lib/rain.math.float b/lib/rain.math.float index 78e15cb..35b7b39 160000 --- a/lib/rain.math.float +++ b/lib/rain.math.float @@ -1 +1 @@ -Subproject commit 78e15cb91b5c12ccacda8c8772a28eeb21f5b7d3 +Subproject commit 35b7b3980cdeab2f245dad17ee84658c1065648d From 1a9dae4272f13ebdf5ee61a619466b4938fe6fb5 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 21 Oct 2025 17:24:19 +0400 Subject: [PATCH 09/11] codegen --- foundry.lock | 2 +- lib/rain.sol.codegen | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foundry.lock b/foundry.lock index c3deb93..3de2dba 100644 --- a/foundry.lock +++ b/foundry.lock @@ -21,7 +21,7 @@ "rev": "35b7b3980cdeab2f245dad17ee84658c1065648d" }, "lib/rain.sol.codegen": { - "rev": "769792d577a7ecae954a7cdd64a222b8d6fe450d" + "rev": "00734d24d91db3fc4aac87c0a3c885de28449f96" }, "lib/rain.solmem": { "rev": "0b2e688e2f3ea84891fd43012fbdc696ac220218" diff --git a/lib/rain.sol.codegen b/lib/rain.sol.codegen index 769792d..00734d2 160000 --- a/lib/rain.sol.codegen +++ b/lib/rain.sol.codegen @@ -1 +1 @@ -Subproject commit 769792d577a7ecae954a7cdd64a222b8d6fe450d +Subproject commit 00734d24d91db3fc4aac87c0a3c885de28449f96 From 8778ebfa6d2fac6ae850bed4c679aaf702a5d944 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 21 Oct 2025 18:00:54 +0400 Subject: [PATCH 10/11] fix lints --- .gas-snapshot | 110 +++++++++--------- src/interface/IInterpreterCallerV3.sol | 8 +- src/interface/IInterpreterExternV3.sol | 2 + src/interface/IInterpreterStoreV2.sol | 2 + src/interface/IInterpreterV3.sol | 16 +++ src/interface/IParserV2.sol | 1 + src/interface/ISubParserV3.sol | 5 + .../deprecated/IDebugExpressionDeployerV1.sol | 2 + .../deprecated/IDebugInterpreterV1.sol | 2 + .../deprecated/IDebugInterpreterV2.sol | 2 + .../deprecated/IInterpreterExternV2.sol | 2 + src/interface/deprecated/IInterpreterV2.sol | 2 + src/interface/deprecated/IParserV1View.sol | 2 + src/interface/deprecated/ISubParserV2.sol | 4 + .../unstable/IInterpreterCallerV4.sol | 8 +- .../unstable/IInterpreterStoreV3.sol | 2 + src/interface/unstable/IInterpreterV4.sol | 14 +++ src/interface/unstable/ISubParserV4.sol | 2 + src/lib/bytecode/LibBytecode.sol | 1 + src/lib/caller/LibEvaluable.sol | 4 + src/lib/codegen/LibGenParseMeta.sol | 3 + .../deprecated/caller/LibEncodedDispatch.sol | 3 +- test/abstract/BytecodeTest.sol | 12 ++ .../LibBytecode.checkNoOOBPointers.t.sol | 24 ++++ .../LibBytecode.sourceInputsOutputs.t.sol | 1 - test/src/lib/caller/LibContext.hash.t.sol | 6 +- test/src/lib/caller/LibContext.t.sol | 6 +- .../codegen/LibGenParseMeta.buildMeta.t.sol | 3 + .../parse/LibParseMeta.wordBitmapped.t.sol | 4 + 29 files changed, 188 insertions(+), 65 deletions(-) diff --git a/.gas-snapshot b/.gas-snapshot index be86882..86d1c5c 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,70 +1,70 @@ -LibBloomTest:testLibBloomNoFalseNegatives(bytes32[],uint256,uint256) (runs: 2048, μ: 41386, ~: 36424) -LibBloomTest:testLibBloomVaguelyAvoidsFalsePositives(uint256,uint8) (runs: 2048, μ: 1770527, ~: 23096) +LibBloomTest:testLibBloomNoFalseNegatives(bytes32[],uint256,uint256) (runs: 1976, μ: 40655, ~: 35438) +LibBloomTest:testLibBloomVaguelyAvoidsFalsePositives(uint256,uint8) (runs: 2048, μ: 1581001, ~: 22262) LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointers0() (gas: 427) LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointers1() (gas: 455) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointers1Fail(bytes) (runs: 2048, μ: 6779, ~: 6596) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersConforming(bytes,uint256,bytes32) (runs: 2048, μ: 19217, ~: 16837) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersCorruptOffsetPointer(bytes,uint8,bytes32,uint8) (runs: 2048, μ: 25657, ~: 23005) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersCorruptOpsCount(bytes,uint8,bytes32,uint8) (runs: 2048, μ: 26086, ~: 23613) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersCorruptSourcesCount(bytes,uint8,bytes32,uint8) (runs: 2048, μ: 21143, ~: 19945) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersEndGarbage(bytes,bytes) (runs: 2048, μ: 18246, ~: 16949) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersHeaderTruncated(bytes,uint8,bytes32,uint256) (runs: 2048, μ: 28173, ~: 25692) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersInputsNotMonotonic(bytes,uint8,bytes32,uint256,uint256) (runs: 2048, μ: 30684, ~: 27816) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersOffsetsTruncated(bytes,uint8,uint256) (runs: 2048, μ: 11312, ~: 11319) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersOutputsNotMonotonic(bytes,uint8,bytes32,uint256,uint256) (runs: 2048, μ: 30676, ~: 27849) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersSourceTruncated(bytes,uint8,bytes32,uint8) (runs: 2048, μ: 26741, ~: 24363) -LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersTrailingOffsetBytes(bytes,bytes,uint8,bytes32) (runs: 2048, μ: 31095, ~: 27697) -LibBytecodeSourceCountTest:testSourceCount0() (gas: 3189) -LibBytecodeSourceCountTest:testSourceCount1(bytes) (runs: 2048, μ: 3953, ~: 3950) -LibBytecodeSourceCountTest:testSourceCountReference(bytes) (runs: 2048, μ: 3673, ~: 3670) -LibBytecodeSourceInputsOutputsTest:testSourceInputsOutputsAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 27912, ~: 24664) -LibBytecodeSourceInputsOutputsTest:testSourceInputsOutputsIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 25218, ~: 23134) -LibBytecodeSourceOpsCountTest:testSourceOpsCount() (gas: 6042) -LibBytecodeSourceOpsCountTest:testSourceOpsCountAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 27256, ~: 24159) -LibBytecodeSourceOpsCountTest:testSourceOpsCountIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 24959, ~: 22648) -LibBytecodeSourcePointerTest:testSourcePointerAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 27199, ~: 24013) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointers1Fail(bytes) (runs: 2022, μ: 6776, ~: 6596) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersConforming(bytes,uint256,bytes32) (runs: 2048, μ: 18887, ~: 16837) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersCorruptOffsetPointer(bytes,uint8,bytes32,uint8) (runs: 1339, μ: 25442, ~: 22955) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersCorruptOpsCount(bytes,uint8,bytes32,uint8) (runs: 1399, μ: 25991, ~: 23574) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersCorruptSourcesCount(bytes,uint8,bytes32,uint8) (runs: 1871, μ: 21201, ~: 19864) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersEndGarbage(bytes,bytes) (runs: 2023, μ: 18234, ~: 16943) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersHeaderTruncated(bytes,uint8,bytes32,uint256) (runs: 1464, μ: 27962, ~: 25534) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersInputsNotMonotonic(bytes,uint8,bytes32,uint256,uint256) (runs: 1481, μ: 30614, ~: 27673) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersOffsetsTruncated(bytes,uint8,uint256) (runs: 1756, μ: 11314, ~: 11319) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersOutputsNotMonotonic(bytes,uint8,bytes32,uint256,uint256) (runs: 1481, μ: 30611, ~: 27640) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersSourceTruncated(bytes,uint8,bytes32,uint8) (runs: 1399, μ: 26658, ~: 24197) +LibBytecodeCheckNoOOBPointersTest:testCheckNoOOBPointersTrailingOffsetBytes(bytes,bytes,uint8,bytes32) (runs: 1473, μ: 31407, ~: 27697) +LibBytecodeSourceCountTest:testSourceCount0() (gas: 349) +LibBytecodeSourceCountTest:testSourceCount1(bytes) (runs: 2037, μ: 3619, ~: 3616) +LibBytecodeSourceCountTest:testSourceCountReference(bytes) (runs: 2048, μ: 836, ~: 833) +LibBytecodeSourceInputsOutputsTest:testSourceInputsOutputsAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 1657, μ: 27607, ~: 23995) +LibBytecodeSourceInputsOutputsTest:testSourceInputsOutputsIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 25469, ~: 22729) +LibBytecodeSourceOpsCountTest:testSourceOpsCount() (gas: 2212) +LibBytecodeSourceOpsCountTest:testSourceOpsCountAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 1641, μ: 27558, ~: 23821) +LibBytecodeSourceOpsCountTest:testSourceOpsCountIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 25366, ~: 22648) +LibBytecodeSourcePointerTest:testSourcePointerAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 1634, μ: 27269, ~: 23675) LibBytecodeSourcePointerTest:testSourcePointerEmpty0(uint256) (runs: 2048, μ: 5775, ~: 5775) LibBytecodeSourcePointerTest:testSourcePointerEmpty1(uint256) (runs: 2048, μ: 6158, ~: 6158) -LibBytecodeSourcePointerTest:testSourcePointerIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 25128, ~: 23076) -LibBytecodeSourceRelativeOffsetTest:testSourceRelativeOffsetHappy() (gas: 5070) +LibBytecodeSourcePointerTest:testSourcePointerIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 25195, ~: 22360) +LibBytecodeSourceRelativeOffsetTest:testSourceRelativeOffsetHappy() (gas: 1237) LibBytecodeSourceRelativeOffsetTest:testSourceRelativeOffsetIndexError() (gas: 95395) -LibBytecodeSourceRelativeOffsetTest:testSourceRelativeOffsetReference(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 26668, ~: 23453) -LibBytecodeSourceStackAllocationTest:testSourceStackAllocationAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 27399, ~: 24210) -LibBytecodeSourceStackAllocationTest:testSourceStackAllocationIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 24928, ~: 22645) -LibContextHashTest:testFuzzHash0() (gas: 3530) +LibBytecodeSourceRelativeOffsetTest:testSourceRelativeOffsetReference(bytes,uint256,uint256,bytes32) (runs: 1639, μ: 26790, ~: 23115) +LibBytecodeSourceStackAllocationTest:testSourceStackAllocationAgainstSlow(bytes,uint256,uint256,bytes32) (runs: 1625, μ: 27554, ~: 23875) +LibBytecodeSourceStackAllocationTest:testSourceStackAllocationIndexOutOfBounds(bytes,uint256,uint256,bytes32) (runs: 2048, μ: 25197, ~: 22550) +LibContextHashTest:testFuzzHash0() (gas: 3552) LibContextHashTest:testHash(uint256) (runs: 2048, μ: 282, ~: 282) -LibContextHashTest:testHashGas0() (gas: 209) -LibContextHashTest:testSignedContextArrayHashReferenceImplementation((address,uint256[],bytes)[]) (runs: 100, μ: 2545172, ~: 2291732) -LibContextHashTest:testSignedContextArrayHashReferenceImplementation0() (gas: 5088) +LibContextHashTest:testHashGas0() (gas: 208) +LibContextHashTest:testSignedContextArrayHashReferenceImplementation((address,bytes32[],bytes)[]) (runs: 100, μ: 2616738, ~: 2348780) +LibContextHashTest:testSignedContextArrayHashReferenceImplementation0() (gas: 2190) LibContextHashTest:testSignedContextHashEncodeGas0() (gas: 1683) LibContextHashTest:testSignedContextHashGas0() (gas: 827) -LibContextHashTest:testSignedContextHashReferenceImplementation((address,uint256[],bytes)) (runs: 100, μ: 15354, ~: 14891) -LibContextTest:testBase() (gas: 4431) -LibContextTest:testBuild0() (gas: 5359) -LibContextTest:testBuildGas0() (gas: 896) -LibContextTest:testBuildStructureReferenceImplementation(uint256[][]) (runs: 100, μ: 4402850, ~: 4186832) +LibContextHashTest:testSignedContextHashReferenceImplementation((address,bytes32[],bytes)) (runs: 100, μ: 13613, ~: 13205) +LibContextTest:testBase() (gas: 616) +LibContextTest:testBuild0() (gas: 5028) +LibContextTest:testBuildGas0() (gas: 962) +LibContextTest:testBuildStructureReferenceImplementation(bytes32[][]) (runs: 100, μ: 4643768, ~: 4795790) LibDeployerDiscoverableTest:testTouchDeployerV4Mock() (gas: 184831) -LibEncodedDispatchTest:testRoundTrip(address,uint256,uint16) (runs: 2048, μ: 8034, ~: 8311) -LibEvaluableTest:testEvaluableV2HashDifferent((address,address,address),(address,address,address)) (runs: 2048, μ: 4560, ~: 4560) +LibEncodedDispatchTest:testRoundTrip(address,uint256,uint16) (runs: 2048, μ: 4498, ~: 4781) +LibEvaluableTest:testEvaluableV2HashDifferent((address,address,address),(address,address,address)) (runs: 2048, μ: 4238, ~: 4238) LibEvaluableTest:testEvaluableV2HashGas0() (gas: 297) LibEvaluableTest:testEvaluableV2HashGasSlow0() (gas: 583) -LibEvaluableTest:testEvaluableV2HashSame((address,address,address)) (runs: 2048, μ: 3846, ~: 3846) -LibEvaluableTest:testEvaluableV2HashSensitivity((address,address,address),(address,address,address)) (runs: 2048, μ: 7958, ~: 7958) -LibEvaluableTest:testEvaluableV2KnownHash() (gas: 3194) -LibEvaluableTest:testEvaluableV2ReferenceImplementation((address,address,address)) (runs: 2048, μ: 3910, ~: 3910) -LibEvaluableTest:testEvaluableV3BytecodeLengthSensitivity() (gas: 3729) -LibEvaluableTest:testEvaluableV3HashDifferent((address,address,bytes),(address,address,bytes)) (runs: 2048, μ: 5517, ~: 5514) +LibEvaluableTest:testEvaluableV2HashSame((address,address,address)) (runs: 2048, μ: 1006, ~: 1006) +LibEvaluableTest:testEvaluableV2HashSensitivity((address,address,address),(address,address,address)) (runs: 2045, μ: 6002, ~: 6002) +LibEvaluableTest:testEvaluableV2KnownHash() (gas: 354) +LibEvaluableTest:testEvaluableV2ReferenceImplementation((address,address,address)) (runs: 2048, μ: 1070, ~: 1070) +LibEvaluableTest:testEvaluableV3BytecodeLengthSensitivity() (gas: 901) +LibEvaluableTest:testEvaluableV3HashDifferent((address,address,bytes),(address,address,bytes)) (runs: 2048, μ: 5194, ~: 5192) LibEvaluableTest:testEvaluableV3HashGas0() (gas: 431) LibEvaluableTest:testEvaluableV3HashGasSlow0() (gas: 764) -LibEvaluableTest:testEvaluableV3HashSame((address,address,bytes)) (runs: 2048, μ: 4445, ~: 4434) -LibEvaluableTest:testEvaluableV3HashSensitivity((address,address,bytes),(address,address,bytes)) (runs: 2048, μ: 10298, ~: 10268) -LibEvaluableTest:testEvaluableV3KnownHash() (gas: 3444) -LibEvaluableTest:testEvaluableV3ReferenceImplementation((address,address,bytes)) (runs: 2048, μ: 4551, ~: 4540) -LibGenParseMetaBuildMetaTest:testBuildMeta((bytes32,string)[]) (runs: 2048, μ: 3511253, ~: 1823519) -LibGenParseMetaBuildMetaTest:testRoundMetaExpanderDeeper((bytes32,string)[],uint8,bytes32) (runs: 2048, μ: 6731595, ~: 6433817) -LibGenParseMetaBuildMetaTest:testRoundMetaExpanderShallow((bytes32,string)[],uint8,bytes32) (runs: 2048, μ: 3608563, ~: 3039373) -LibGenParseMetaFindExpanderTest:testFindExpanderSmall((bytes32,string)[]) (runs: 2048, μ: 43196, ~: 34218) +LibEvaluableTest:testEvaluableV3HashSame((address,address,bytes)) (runs: 2048, μ: 1605, ~: 1594) +LibEvaluableTest:testEvaluableV3HashSensitivity((address,address,bytes),(address,address,bytes)) (runs: 2047, μ: 8339, ~: 8312) +LibEvaluableTest:testEvaluableV3KnownHash() (gas: 604) +LibEvaluableTest:testEvaluableV3ReferenceImplementation((address,address,bytes)) (runs: 2048, μ: 1711, ~: 1700) +LibGenParseMetaBuildMetaTest:testBuildMeta((bytes32,string)[]) (runs: 746, μ: 3740032, ~: 2814714) +LibGenParseMetaBuildMetaTest:testRoundMetaExpanderDeeper((bytes32,string)[],uint8,bytes32) (runs: 364, μ: 6840949, ~: 6501238) +LibGenParseMetaBuildMetaTest:testRoundMetaExpanderShallow((bytes32,string)[],uint8,bytes32) (runs: 717, μ: 3598305, ~: 2882702) +LibGenParseMetaFindExpanderTest:testFindExpanderSmall((bytes32,string)[]) (runs: 254, μ: 43912, ~: 33558) LibNamespaceTest:testQualifyNamespaceGas0(uint256,address) (runs: 2048, μ: 362, ~: 362) LibNamespaceTest:testQualifyNamespaceGasSlow0(uint256,address) (runs: 2048, μ: 569, ~: 569) -LibNamespaceTest:testQualifyNamespaceReferenceImplementation(uint256,address) (runs: 2048, μ: 3566, ~: 3566) -LitParseMetaTest:testWordBitmapped(uint256,bytes32) (runs: 2048, μ: 4740, ~: 4740) \ No newline at end of file +LibNamespaceTest:testQualifyNamespaceReferenceImplementation(uint256,address) (runs: 2048, μ: 726, ~: 726) +LitParseMetaTest:testWordBitmapped(uint256,bytes32) (runs: 2048, μ: 969, ~: 969) \ No newline at end of file diff --git a/src/interface/IInterpreterCallerV3.sol b/src/interface/IInterpreterCallerV3.sol index f439818..95d8f02 100644 --- a/src/interface/IInterpreterCallerV3.sol +++ b/src/interface/IInterpreterCallerV3.sol @@ -2,15 +2,21 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {IParserV2} from "./IParserV2.sol"; import {IInterpreterStoreV2} from "./IInterpreterStoreV2.sol"; import {IInterpreterV3} from "./IInterpreterV3.sol"; -import { +import +// Exported for convenience. +//forge-lint: disable-start(unused-import) +{ SignedContextV1, SIGNED_CONTEXT_SIGNER_OFFSET, SIGNED_CONTEXT_CONTEXT_OFFSET, SIGNED_CONTEXT_SIGNATURE_OFFSET } from "./deprecated/IInterpreterCallerV2.sol"; +//forge-lint: disable-end /// Struct over the return of `IParserV2.parse2` which MAY be more convenient to /// work with than raw addresses. diff --git a/src/interface/IInterpreterExternV3.sol b/src/interface/IInterpreterExternV3.sol index 8977b3a..3680441 100644 --- a/src/interface/IInterpreterExternV3.sol +++ b/src/interface/IInterpreterExternV3.sol @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {EncodedExternDispatch, ExternDispatch} from "./deprecated/IInterpreterExternV2.sol"; /// @title IInterpreterExternV3 diff --git a/src/interface/IInterpreterStoreV2.sol b/src/interface/IInterpreterStoreV2.sol index ad204e7..7f0db31 100644 --- a/src/interface/IInterpreterStoreV2.sol +++ b/src/interface/IInterpreterStoreV2.sol @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {StateNamespace, FullyQualifiedNamespace, NO_STORE} from "./deprecated/IInterpreterStoreV1.sol"; /// @title IInterpreterStoreV2 diff --git a/src/interface/IInterpreterV3.sol b/src/interface/IInterpreterV3.sol index 7f7284d..7eaaeef 100644 --- a/src/interface/IInterpreterV3.sol +++ b/src/interface/IInterpreterV3.sol @@ -5,14 +5,30 @@ pragma solidity ^0.8.18; import { IInterpreterStoreV2, FullyQualifiedNamespace, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) StateNamespace, SourceIndexV2, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) DEFAULT_STATE_NAMESPACE, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) Operand, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_CONSTANT, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_CONTEXT, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_EXTERN, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_UNKNOWN, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_STACK } from "./deprecated/IInterpreterV2.sol"; diff --git a/src/interface/IParserV2.sol b/src/interface/IParserV2.sol index 6a85fb0..155c383 100644 --- a/src/interface/IParserV2.sol +++ b/src/interface/IParserV2.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.18; // Reexport AuthoringMetaV2 for downstream use. +//forge-lint: disable-next-line(unused-import) import {AuthoringMetaV2} from "./deprecated/IParserV1.sol"; interface IParserV2 { diff --git a/src/interface/ISubParserV3.sol b/src/interface/ISubParserV3.sol index 807a353..5d769bc 100644 --- a/src/interface/ISubParserV3.sol +++ b/src/interface/ISubParserV3.sol @@ -3,8 +3,13 @@ pragma solidity ^0.8.18; // Reexports for implementations to use. +//forge-lint: disable-next-line(unused-import) import {AuthoringMetaV2} from "./deprecated/IParserV1.sol"; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {Operand} from "./deprecated/IInterpreterV2.sol"; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {COMPATIBILITY_V2, COMPATIBILITY_V3, COMPATIBILITY_V4} from "./deprecated/ISubParserV2.sol"; /// @dev A compatibility version for the subparser interface. diff --git a/src/interface/deprecated/IDebugExpressionDeployerV1.sol b/src/interface/deprecated/IDebugExpressionDeployerV1.sol index d5e3fff..f05681a 100644 --- a/src/interface/deprecated/IDebugExpressionDeployerV1.sol +++ b/src/interface/deprecated/IDebugExpressionDeployerV1.sol @@ -3,6 +3,8 @@ pragma solidity ^0.8.18; import {FullyQualifiedNamespace} from "./IInterpreterStoreV1.sol"; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {IInterpreterV1, SourceIndex} from "./IInterpreterV1.sol"; interface IDebugExpressionDeployerV1 { diff --git a/src/interface/deprecated/IDebugInterpreterV1.sol b/src/interface/deprecated/IDebugInterpreterV1.sol index d81c7d5..aec4366 100644 --- a/src/interface/deprecated/IDebugInterpreterV1.sol +++ b/src/interface/deprecated/IDebugInterpreterV1.sol @@ -3,6 +3,8 @@ pragma solidity ^0.8.18; import {IInterpreterStoreV1, FullyQualifiedNamespace} from "./IInterpreterStoreV1.sol"; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {IInterpreterV1, SourceIndex} from "./IInterpreterV1.sol"; interface IDebugInterpreterV1 { diff --git a/src/interface/deprecated/IDebugInterpreterV2.sol b/src/interface/deprecated/IDebugInterpreterV2.sol index e13e238..f2a6c6b 100644 --- a/src/interface/deprecated/IDebugInterpreterV2.sol +++ b/src/interface/deprecated/IDebugInterpreterV2.sol @@ -3,6 +3,8 @@ pragma solidity ^0.8.18; import {IInterpreterStoreV1, FullyQualifiedNamespace} from "./IInterpreterStoreV1.sol"; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {IInterpreterV1, SourceIndex} from "./IInterpreterV1.sol"; interface IDebugInterpreterV2 { diff --git a/src/interface/deprecated/IInterpreterExternV2.sol b/src/interface/deprecated/IInterpreterExternV2.sol index 21860ce..032ea62 100644 --- a/src/interface/deprecated/IInterpreterExternV2.sol +++ b/src/interface/deprecated/IInterpreterExternV2.sol @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {EncodedExternDispatch, ExternDispatch} from "./IInterpreterExternV1.sol"; /// @title IInterpreterExternV2 diff --git a/src/interface/deprecated/IInterpreterV2.sol b/src/interface/deprecated/IInterpreterV2.sol index cf88957..d874e7c 100644 --- a/src/interface/deprecated/IInterpreterV2.sol +++ b/src/interface/deprecated/IInterpreterV2.sol @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {EncodedDispatch, StateNamespace, Operand, DEFAULT_STATE_NAMESPACE} from "./IInterpreterV1.sol"; import {FullyQualifiedNamespace, IInterpreterStoreV2} from "../IInterpreterStoreV2.sol"; diff --git a/src/interface/deprecated/IParserV1View.sol b/src/interface/deprecated/IParserV1View.sol index 40568e1..ea05b52 100644 --- a/src/interface/deprecated/IParserV1View.sol +++ b/src/interface/deprecated/IParserV1View.sol @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {AuthoringMeta, AuthoringMetaV2} from "./IParserV1.sol"; /// @title IParserV1View diff --git a/src/interface/deprecated/ISubParserV2.sol b/src/interface/deprecated/ISubParserV2.sol index 5e8f0c8..7d0f5f0 100644 --- a/src/interface/deprecated/ISubParserV2.sol +++ b/src/interface/deprecated/ISubParserV2.sol @@ -3,7 +3,11 @@ pragma solidity ^0.8.18; // Reexports for implementations to use. +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {AuthoringMetaV2} from "./IParserV1.sol"; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {Operand} from "./IInterpreterV2.sol"; /// @dev A compatibility version for the subparser interface. diff --git a/src/interface/unstable/IInterpreterCallerV4.sol b/src/interface/unstable/IInterpreterCallerV4.sol index 75930b7..71c9fc7 100644 --- a/src/interface/unstable/IInterpreterCallerV4.sol +++ b/src/interface/unstable/IInterpreterCallerV4.sol @@ -2,15 +2,21 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {IParserV2} from "../IParserV2.sol"; import {IInterpreterStoreV3} from "./IInterpreterStoreV3.sol"; import {IInterpreterV4} from "./IInterpreterV4.sol"; -import { +import +// Exported for convenience. +//forge-lint: disable-start(unused-import) +{ SignedContextV1, SIGNED_CONTEXT_SIGNER_OFFSET, SIGNED_CONTEXT_CONTEXT_OFFSET, SIGNED_CONTEXT_SIGNATURE_OFFSET } from "../IInterpreterCallerV3.sol"; +//forge-lint: disable-end /// @param interpreter Will evaluate the expression. /// @param store Will store state changes due to evaluation of the expression. diff --git a/src/interface/unstable/IInterpreterStoreV3.sol b/src/interface/unstable/IInterpreterStoreV3.sol index 7c32692..1ef7e28 100644 --- a/src/interface/unstable/IInterpreterStoreV3.sol +++ b/src/interface/unstable/IInterpreterStoreV3.sol @@ -2,6 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.18; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {StateNamespace, FullyQualifiedNamespace, NO_STORE} from "../IInterpreterStoreV2.sol"; /// @title IInterpreterStoreV3 diff --git a/src/interface/unstable/IInterpreterV4.sol b/src/interface/unstable/IInterpreterV4.sol index b7a89b4..6ee60ab 100644 --- a/src/interface/unstable/IInterpreterV4.sol +++ b/src/interface/unstable/IInterpreterV4.sol @@ -4,13 +4,27 @@ pragma solidity ^0.8.25; import { FullyQualifiedNamespace, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) StateNamespace, SourceIndexV2, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) DEFAULT_STATE_NAMESPACE, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_CONSTANT, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_CONTEXT, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_EXTERN, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_UNKNOWN, + // Exported for convenience. + //forge-lint: disable-next-line(unused-import) OPCODE_STACK } from "../IInterpreterV3.sol"; import {IInterpreterStoreV3} from "./IInterpreterStoreV3.sol"; diff --git a/src/interface/unstable/ISubParserV4.sol b/src/interface/unstable/ISubParserV4.sol index 81206ea..3c7b78f 100644 --- a/src/interface/unstable/ISubParserV4.sol +++ b/src/interface/unstable/ISubParserV4.sol @@ -3,7 +3,9 @@ pragma solidity ^0.8.18; // Reexports for implementations to use. +//forge-lint: disable-next-line(unused-import) import {AuthoringMetaV2} from "../ISubParserV3.sol"; +//forge-lint: disable-next-line(unused-import) import {OperandV2} from "./IInterpreterV4.sol"; /// @title ISubParserV4 diff --git a/src/lib/bytecode/LibBytecode.sol b/src/lib/bytecode/LibBytecode.sol index 9d33e08..39609bd 100644 --- a/src/lib/bytecode/LibBytecode.sol +++ b/src/lib/bytecode/LibBytecode.sol @@ -66,6 +66,7 @@ library LibBytecode { /// - The number of opcodes specified in the header of each source locates /// the end of the source exactly at either the offset of the next source /// or the end of the bytecode `bytes`. + //forge-lint: disable-next-line(mixed-case-function) function checkNoOOBPointers(bytes memory bytecode) internal pure { unchecked { uint256 count = sourceCount(bytecode); diff --git a/src/lib/caller/LibEvaluable.sol b/src/lib/caller/LibEvaluable.sol index 8349451..3624aca 100644 --- a/src/lib/caller/LibEvaluable.sol +++ b/src/lib/caller/LibEvaluable.sol @@ -3,7 +3,11 @@ pragma solidity ^0.8.25; /// Export dispair interfaces for convenience downstream. +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {IInterpreterStoreV2} from "../../interface/IInterpreterStoreV2.sol"; +// Exported for convenience. +//forge-lint: disable-next-line(unused-import) import {IInterpreterV2} from "../../interface/deprecated/IInterpreterV2.sol"; import {EvaluableV2} from "../../interface/deprecated/IInterpreterCallerV2.sol"; diff --git a/src/lib/codegen/LibGenParseMeta.sol b/src/lib/codegen/LibGenParseMeta.sol index 67387b5..0daa2f4 100644 --- a/src/lib/codegen/LibGenParseMeta.sol +++ b/src/lib/codegen/LibGenParseMeta.sol @@ -14,6 +14,7 @@ import {LibCtPop} from "rain.math.binary/lib/LibCtPop.sol"; import {Vm} from "forge-std/Vm.sol"; import {LibCodeGen} from "rain.sol.codegen/lib/LibCodeGen.sol"; +//forge-lint: disable-next-line(incorrect-shift) uint256 constant META_ITEM_MASK = (1 << META_ITEM_SIZE) - 1; /// @dev For metadata builder. @@ -38,6 +39,8 @@ library LibGenParseMeta { uint256 ct = LibCtPop.ctpop(expansion); if (ct > bestCt) { bestCt = ct; + // Seed is within 1 byte. + //forge-lint: disable-next-line(unsafe-typecast) bestSeed = uint8(seed); bestExpansion = expansion; } diff --git a/src/lib/deprecated/caller/LibEncodedDispatch.sol b/src/lib/deprecated/caller/LibEncodedDispatch.sol index 31dba62..dca32b2 100644 --- a/src/lib/deprecated/caller/LibEncodedDispatch.sol +++ b/src/lib/deprecated/caller/LibEncodedDispatch.sol @@ -29,7 +29,8 @@ library LibEncodedDispatch { // values to uint16. return EncodedDispatch.wrap( (uint256(uint160(expression)) << 0x20) | (uint256(uint16(SourceIndexV2.unwrap(sourceIndex))) << 0x10) - | uint256(uint16(maxOutputs)) + // forge-lint: disable-next-line(unsafe-typecast) + | uint256(uint16(maxOutputs)) ); } diff --git a/test/abstract/BytecodeTest.sol b/test/abstract/BytecodeTest.sol index cd5126f..a6289d2 100644 --- a/test/abstract/BytecodeTest.sol +++ b/test/abstract/BytecodeTest.sol @@ -27,6 +27,9 @@ abstract contract BytecodeTest is Test { return; } + // Sourcecount is bound to max source count which is bound so + // this typecast is safe. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[0] = bytes1(uint8(sourceCount)); uint256 sourcesRelativeStart = 1 + sourceCount * 2; @@ -59,7 +62,11 @@ abstract contract BytecodeTest is Test { uint256 offset = 0; uint256 cursor = 1; for (uint256 i = 0; i < sourceCount; i++) { + // Offset being set one byte at a time so tyecast truncation + // is intentional. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[cursor] = bytes1(uint8(offset >> 8)); + //forge-lint: disable-next-line(unsafe-typecast) bytecode[cursor + 1] = bytes1(uint8(offset)); cursor += 2; @@ -75,9 +82,14 @@ abstract contract BytecodeTest is Test { // inputs can't exceed outputs. inputs = bound(inputs, 0, outputs); + // inputs is bound to outputs, which is a single byte, so + // this is a safe cast. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[headerPosition + 2] = bytes1(uint8(inputs)); // allocation can't be less than outputs. allocation = bound(allocation, outputs, type(uint8).max); + // Allocation is bound so safe to typecast. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[headerPosition + 1] = bytes1(uint8(allocation)); offset += opsPerSource[i] * 4 + 4; diff --git a/test/src/lib/bytecode/LibBytecode.checkNoOOBPointers.t.sol b/test/src/lib/bytecode/LibBytecode.checkNoOOBPointers.t.sol index d986e82..8618aff 100644 --- a/test/src/lib/bytecode/LibBytecode.checkNoOOBPointers.t.sol +++ b/test/src/lib/bytecode/LibBytecode.checkNoOOBPointers.t.sol @@ -22,6 +22,7 @@ contract LibBytecodeCheckNoOOBPointersTest is BytecodeTest { /// Expose the library function externally so we can expect reverts against /// it. + //forge-lint: disable-next-line(mixed-case-function) function checkNoOOBPointersExternal(bytes memory bytecode) external pure { LibBytecode.checkNoOOBPointers(bytecode); } @@ -96,7 +97,11 @@ contract LibBytecodeCheckNoOOBPointersTest is BytecodeTest { } corruptOffset = bound(corruptOffset, nextOffset - 3, type(uint16).max); uint256 offsetPosition = offsetIndex * 2 + 1; + // Taking the corrupt offset one byte at a time, so a shift and truncate + // is expected. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[offsetPosition] = bytes1(uint8(corruptOffset >> 8)); + //forge-lint: disable-next-line(unsafe-typecast) bytecode[offsetPosition + 1] = bytes1(uint8(corruptOffset)); vm.expectRevert(abi.encodeWithSelector(TruncatedHeader.selector, bytecode)); @@ -166,7 +171,11 @@ contract LibBytecodeCheckNoOOBPointersTest is BytecodeTest { uint256 offset = (uint256(uint8(bytecodeCorrupted[offsetPosition])) << 8) | uint256(uint8(bytecodeCorrupted[offsetPosition + 1])); offset += garbage.length; + // Deliberately writing offset as two bytes so the truncation per + // byte is intentional. + //forge-lint: disable-next-line(unsafe-typecast) bytecodeCorrupted[offsetPosition] = bytes1(uint8(offset >> 8)); + //forge-lint: disable-next-line(unsafe-typecast) bytecodeCorrupted[offsetPosition + 1] = bytes1(uint8(offset)); } @@ -302,12 +311,18 @@ contract LibBytecodeCheckNoOOBPointersTest is BytecodeTest { inputs = bound(corruptInputs, 1, type(uint8).max); outputs = bound(corruptOutputs, 0, inputs - 1); } + // Inputs is either a single byte or bound so safe to cast like this. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[inputsPosition] = bytes1(uint8(inputs)); + // Outputs is a single byte or bound so safe to cast like this. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[outputsPosition] = bytes1(uint8(outputs)); // Ensure the allocation is valid so we don't get false positives. uint256 allocation = uint256(uint8(bytecode[headerPosition + 1])); allocation = bound(allocation, outputs, type(uint8).max); + // Allocation is bound so safe to cast. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[headerPosition + 1] = bytes1(uint8(allocation)); } @@ -351,12 +366,21 @@ contract LibBytecodeCheckNoOOBPointersTest is BytecodeTest { outputs = bound(corruptOutputs, 1, type(uint8).max); allocation = bound(corruptAllocation, 0, outputs - 1); } + // Outputs is either a single byte or bound above so it is safe to + // cast like this. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[outputsPosition] = bytes1(uint8(outputs)); + // Allocation is either a single byte or bound above so it is safe + // to cast like this. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[allocationPosition] = bytes1(uint8(allocation)); // Ensure the inputs is valid so we don't get false positives. uint256 inputs = uint256(uint8(bytecode[headerPosition + 2])); inputs = bound(inputs, 0, outputs); + // Outputs bound to type(uint8).max so this can't overflow due to + // the inputs bound. + //forge-lint: disable-next-line(unsafe-typecast) bytecode[headerPosition + 2] = bytes1(uint8(inputs)); } diff --git a/test/src/lib/bytecode/LibBytecode.sourceInputsOutputs.t.sol b/test/src/lib/bytecode/LibBytecode.sourceInputsOutputs.t.sol index 9dc7f4e..493de8e 100644 --- a/test/src/lib/bytecode/LibBytecode.sourceInputsOutputs.t.sol +++ b/test/src/lib/bytecode/LibBytecode.sourceInputsOutputs.t.sol @@ -5,7 +5,6 @@ pragma solidity =0.8.25; import {BytecodeTest} from "test/abstract/BytecodeTest.sol"; import {LibBytecode, SourceIndexOutOfBounds} from "src/lib/bytecode/LibBytecode.sol"; import {LibBytecodeSlow} from "test/src/lib/bytecode/LibBytecodeSlow.sol"; -import {Pointer} from "rain.solmem/lib/LibPointer.sol"; contract LibBytecodeSourceInputsOutputsTest is BytecodeTest { function sourceInputsOutputsExternal(bytes memory bytecode, uint256 sourceIndex) diff --git a/test/src/lib/caller/LibContext.hash.t.sol b/test/src/lib/caller/LibContext.hash.t.sol index f8ceb0e..f332d88 100644 --- a/test/src/lib/caller/LibContext.hash.t.sol +++ b/test/src/lib/caller/LibContext.hash.t.sol @@ -2,9 +2,9 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import "forge-std/Test.sol"; -import "src/lib/caller/LibContext.sol"; -import "./LibContextSlow.sol"; +import {Test} from "forge-std/Test.sol"; +import {SignedContextV1, LibContext} from "src/lib/caller/LibContext.sol"; +import {LibContextSlow} from "./LibContextSlow.sol"; contract LibContextHashTest is Test { function testFuzzHash0() public pure { diff --git a/test/src/lib/caller/LibContext.t.sol b/test/src/lib/caller/LibContext.t.sol index 7cf7086..94301ef 100644 --- a/test/src/lib/caller/LibContext.t.sol +++ b/test/src/lib/caller/LibContext.t.sol @@ -2,9 +2,9 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import "forge-std/Test.sol"; -import "src/lib/caller/LibContext.sol"; -import "./LibContextSlow.sol"; +import {Test} from "forge-std/Test.sol"; +import {LibContext, ECDSA, LibHashNoAlloc, SignedContextV1} from "src/lib/caller/LibContext.sol"; +import {LibContextSlow} from "./LibContextSlow.sol"; contract LibContextTest is Test { function testBase() public view { diff --git a/test/src/lib/codegen/LibGenParseMeta.buildMeta.t.sol b/test/src/lib/codegen/LibGenParseMeta.buildMeta.t.sol index 7a6cf18..d0ba092 100644 --- a/test/src/lib/codegen/LibGenParseMeta.buildMeta.t.sol +++ b/test/src/lib/codegen/LibGenParseMeta.buildMeta.t.sol @@ -16,6 +16,9 @@ contract LibGenParseMetaBuildMetaTest is Test { // + 1 for solidity flooring everything // + 1 for a non-fully saturated but still quite full expander // + 1 for a potentially nearly empty expander + // This is NOT a safe typecast, but in normal useage we are unlikely to + // get anywhere near the limit as that would imply ~256^2 words. + //forge-lint: disable-next-line(unsafe-typecast) return uint8(n / type(uint8).max + 3); } diff --git a/test/src/lib/parse/LibParseMeta.wordBitmapped.t.sol b/test/src/lib/parse/LibParseMeta.wordBitmapped.t.sol index 15b2873..6195deb 100644 --- a/test/src/lib/parse/LibParseMeta.wordBitmapped.t.sol +++ b/test/src/lib/parse/LibParseMeta.wordBitmapped.t.sol @@ -8,7 +8,11 @@ import {LibParseMeta} from "src/lib/parse/LibParseMeta.sol"; contract LitParseMetaTest is Test { function referenceWordBitmapped(uint256 seed, bytes32 word) public pure returns (uint256 bitmap, uint256 hashed) { + // taking the low byte of the seed is intentional. + //forge-lint: disable-next-line(unsafe-typecast) hashed = uint256(keccak256(abi.encodePacked(word, uint8(seed)))); + // Taking the type byte of hashed only. + //forge-lint: disable-next-line(unsafe-typecast, incorrect-shift) bitmap = 1 << uint256(uint8(uint256(hashed) >> 0xF8)); } From de9c71bc317a1bab9e6608accb6932a0e16c2c23 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 21 Oct 2025 18:02:42 +0400 Subject: [PATCH 11/11] solmem bump --- foundry.lock | 2 +- lib/rain.solmem | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foundry.lock b/foundry.lock index 3de2dba..5d1617b 100644 --- a/foundry.lock +++ b/foundry.lock @@ -24,6 +24,6 @@ "rev": "00734d24d91db3fc4aac87c0a3c885de28449f96" }, "lib/rain.solmem": { - "rev": "0b2e688e2f3ea84891fd43012fbdc696ac220218" + "rev": "c1c22cf27963a9de0889ebf7f52869050f1fdfb9" } } \ No newline at end of file diff --git a/lib/rain.solmem b/lib/rain.solmem index 0b2e688..c1c22cf 160000 --- a/lib/rain.solmem +++ b/lib/rain.solmem @@ -1 +1 @@ -Subproject commit 0b2e688e2f3ea84891fd43012fbdc696ac220218 +Subproject commit c1c22cf27963a9de0889ebf7f52869050f1fdfb9