Skip to content

Commit bb249f6

Browse files
Prepare for release of v0.8.3 (#72)
* Add funding JSON file for RetroPGF * Improve foundry setup (#67) * chore: Remove dependencies * chore: Add foundry.toml * forge install: forge-std v1.7.6 * chore: Remove remappings * chore: Add .nvmrc * chore: Add test workflow * chore: Setup foundry in github workflow * fix: Include recursive submodules in github workflow * Deleting GitHub workflow from the PR because of safety concerns. Accepting all other changes. --------- Co-authored-by: Gonçalo Sá <[email protected]> * Remove non-aligned equality function to address concerns in #69 --------- Co-authored-by: Ján Jakub Naništa <[email protected]>
1 parent c433288 commit bb249f6

File tree

8 files changed

+16
-99
lines changed

8 files changed

+16
-99
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18.16.0

contracts/BytesLib.sol

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -436,72 +436,6 @@ library BytesLib {
436436
return success;
437437
}
438438

439-
function equal_nonAligned(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
440-
bool success = true;
441-
442-
assembly {
443-
let length := mload(_preBytes)
444-
445-
// if lengths don't match the arrays are not equal
446-
switch eq(length, mload(_postBytes))
447-
case 1 {
448-
// cb is a circuit breaker in the for loop since there's
449-
// no said feature for inline assembly loops
450-
// cb = 1 - don't breaker
451-
// cb = 0 - break
452-
let cb := 1
453-
454-
let endMinusWord := add(_preBytes, length)
455-
let mc := add(_preBytes, 0x20)
456-
let cc := add(_postBytes, 0x20)
457-
458-
for {
459-
// the next line is the loop condition:
460-
// while(uint256(mc < endWord) + cb == 2)
461-
} eq(add(lt(mc, endMinusWord), cb), 2) {
462-
mc := add(mc, 0x20)
463-
cc := add(cc, 0x20)
464-
} {
465-
// if any of these checks fails then arrays are not equal
466-
if iszero(eq(mload(mc), mload(cc))) {
467-
// unsuccess:
468-
success := 0
469-
cb := 0
470-
}
471-
}
472-
473-
// Only if still successful
474-
// For <1 word tail bytes
475-
if gt(success, 0) {
476-
// Get the remainder of length/32
477-
// length % 32 = AND(length, 32 - 1)
478-
let numTailBytes := and(length, 0x1f)
479-
let mcRem := mload(mc)
480-
let ccRem := mload(cc)
481-
for {
482-
let i := 0
483-
// the next line is the loop condition:
484-
// while(uint256(i < numTailBytes) + cb == 2)
485-
} eq(add(lt(i, numTailBytes), cb), 2) {
486-
i := add(i, 1)
487-
} {
488-
if iszero(eq(byte(i, mcRem), byte(i, ccRem))) {
489-
// unsuccess:
490-
success := 0
491-
cb := 0
492-
}
493-
}
494-
}
495-
}
496-
default {
497-
// unsuccess:
498-
success := 0
499-
}
500-
}
501-
502-
return success;
503-
}
504-
505439
function equalStorage(
506440
bytes storage _preBytes,
507441
bytes memory _postBytes

foundry.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[profile.default]
2+
solc-version = '0.8.22'
3+
src = 'contracts'
4+
test = 'test'
5+
cache_path = 'cache'
6+
libs = ['lib']

lib/forge-std

Submodule forge-std added at ae570fe

package-lock.json

Lines changed: 1 addition & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
"authors": [
2121
"Gonçalo Sá <[email protected]>"
2222
],
23+
"scripts": {
24+
"test": "forge test"
25+
},
2326
"license": "MIT",
2427
"bugs": {
2528
"url": "https://github.com/GNSPS/solidity-bytes-utils/issues"
2629
},
27-
"homepage": "https://github.com/GNSPS/solidity-bytes-utils#readme",
28-
"dependencies": {
29-
"ds-test": "github:dapphub/ds-test",
30-
"forge-std": "^1.1.2"
31-
}
30+
"homepage": "https://github.com/GNSPS/solidity-bytes-utils#readme"
3231
}

remappings.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)