Skip to content

Commit

Permalink
T
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Aug 3, 2024
1 parent 8ac37b6 commit 44ffa1b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 59 deletions.
86 changes: 43 additions & 43 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ DelegateCheckerLibTest:testCheckDelegateForERC20(address,address,address,bytes32
DelegateCheckerLibTest:testCheckDelegateForERC721() (gas: 69938)
DelegateCheckerLibTest:testCheckDelegateForERC721(address,address,address,uint256,bytes32) (runs: 302, μ: 424706, ~: 381545)
DelegateCheckerLibTest:test__codesize() (gas: 33189)
DeploylessPredeployQueryerTest:testPredeployQueryer(bytes32) (runs: 302, μ: 270917, ~: 224587)
DeploylessPredeployQueryerTest:testPredeployQueryer(bytes32) (runs: 302, μ: 269079, ~: 222226)
DeploylessPredeployQueryerTest:testTargetGenerate() (gas: 286339)
DeploylessPredeployQueryerTest:test__codesize() (gas: 8280)
DynamicBufferLibTest:testClear(uint256) (runs: 302, μ: 34600, ~: 34657)
Expand Down Expand Up @@ -242,8 +242,8 @@ ERC2981Test:testRoyaltyOverflowCheckDifferential(uint256,uint256) (runs: 302, μ
ERC2981Test:testSetAndGetRoyaltyInfo(uint256) (runs: 302, μ: 106932, ~: 104398)
ERC2981Test:test__codesize() (gas: 7247)
ERC4337FactoryTest:testCreateAccountRepeatedDeployment() (gas: 149753)
ERC4337FactoryTest:testCreateAccountRepeatedDeployment(uint256) (runs: 302, μ: 171342, ~: 171396)
ERC4337FactoryTest:testDeployDeterministic(uint256) (runs: 302, μ: 131988, ~: 139605)
ERC4337FactoryTest:testCreateAccountRepeatedDeployment(uint256) (runs: 302, μ: 171338, ~: 171295)
ERC4337FactoryTest:testDeployDeterministic(uint256) (runs: 302, μ: 130669, ~: 139611)
ERC4337FactoryTest:test__codesize() (gas: 13049)
ERC4337Test:testCdFallback() (gas: 438041)
ERC4337Test:testCdFallback2() (gas: 1135303)
Expand Down Expand Up @@ -655,47 +655,47 @@ LibBitmapTest:testBitmapUnsetBatchAcrossMultipleBuckets() (gas: 438470)
LibBitmapTest:testBitmapUnsetBatchWithinSingleBucket() (gas: 445869)
LibBitmapTest:test__codesize() (gas: 8720)
LibCWIATest:testCloneDeteministicWithImmutableArgs() (gas: 191687)
LibCWIATest:testCloneDeteministicWithImmutableArgs(address,uint256,uint256[],bytes,uint64,uint8,uint256) (runs: 302, μ: 1097675, ~: 1045340)
LibCWIATest:testCloneDeteministicWithImmutableArgs(address,uint256,uint256[],bytes,uint64,uint8,uint256) (runs: 302, μ: 1097764, ~: 1045340)
LibCWIATest:testCloneWithImmutableArgs() (gas: 120548)
LibCWIATest:testCloneWithImmutableArgs(uint256,address,uint256,uint256[],uint64,uint8) (runs: 302, μ: 997437, ~: 982338)
LibCWIATest:testCloneWithImmutableArgsRevertsIfDataTooBig() (gas: 97305787)
LibCWIATest:test__codesize() (gas: 12272)
LibCloneTest:testClone() (gas: 97436)
LibCloneTest:testClone(uint256) (runs: 302, μ: 97463, ~: 97463)
LibCloneTest:testCloneDeterministic() (gas: 98317)
LibCloneTest:testCloneDeterministic(bytes32) (runs: 302, μ: 3623938, ~: 98594)
LibCloneTest:testCloneDeterministicWithImmutableArgs() (gas: 125188)
LibCloneTest:testCloneDeterministicWithImmutableArgs(bytes32) (runs: 302, μ: 7902759, ~: 130446)
LibCloneTest:testCloneWithImmutableArgs() (gas: 125654)
LibCloneTest:testCloneWithImmutableArgs(uint256) (runs: 302, μ: 2032564, ~: 125618)
LibCloneTest:testCloneWithImmutableArgsSlicing() (gas: 58131)
LibCloneTest:testCreateDeterministicERC1967(bytes32) (runs: 302, μ: 181474, ~: 128025)
LibCloneTest:testCreateDeterministicERC1967BeaconProxy(bytes32) (runs: 302, μ: 379901, ~: 360493)
LibCloneTest:testCreateDeterministicERC1967I(bytes32) (runs: 302, μ: 192199, ~: 132431)
LibCloneTest:testCreateDeterministicERC1967WithImmutableArgs(bytes32) (runs: 302, μ: 325317, ~: 137956)
LibCloneTest:testDeployDeterministicERC1967() (gas: 133493)
LibCloneTest:testDeployDeterministicERC1967(bytes32) (runs: 302, μ: 3161332, ~: 133482)
LibCloneTest:testDeployDeterministicERC1967BeaconProxy(bytes32) (runs: 302, μ: 3512113, ~: 357493)
LibCloneTest:testCloneDeterministic(bytes32) (runs: 302, μ: 3011876, ~: 98594)
LibCloneTest:testCloneDeterministicWithImmutableArgs() (gas: 125123)
LibCloneTest:testCloneDeterministicWithImmutableArgs(bytes32) (runs: 302, μ: 6958571, ~: 120120)
LibCloneTest:testCloneWithImmutableArgs() (gas: 125589)
LibCloneTest:testCloneWithImmutableArgs(uint256) (runs: 302, μ: 2999414, ~: 116213)
LibCloneTest:testCloneWithImmutableArgsSlicing() (gas: 57947)
LibCloneTest:testCreateDeterministicERC1967(bytes32) (runs: 302, μ: 173011, ~: 128025)
LibCloneTest:testCreateDeterministicERC1967BeaconProxy(bytes32) (runs: 302, μ: 377041, ~: 360493)
LibCloneTest:testCreateDeterministicERC1967I(bytes32) (runs: 302, μ: 175742, ~: 132431)
LibCloneTest:testCreateDeterministicERC1967WithImmutableArgs(bytes32) (runs: 302, μ: 452349, ~: 137435)
LibCloneTest:testDeployDeterministicERC1967() (gas: 133441)
LibCloneTest:testDeployDeterministicERC1967(bytes32) (runs: 302, μ: 2841301, ~: 133428)
LibCloneTest:testDeployDeterministicERC1967BeaconProxy(bytes32) (runs: 302, μ: 5096487, ~: 357493)
LibCloneTest:testDeployDeterministicERC1967I() (gas: 129465)
LibCloneTest:testDeployDeterministicERC1967I(bytes32) (runs: 302, μ: 2412336, ~: 129383)
LibCloneTest:testDeployDeterministicERC1967WithImmutableArgs() (gas: 166954)
LibCloneTest:testDeployDeterministicERC1967WithImmutableArgs(bytes32) (runs: 302, μ: 6025743, ~: 156687)
LibCloneTest:testDeployERC1967() (gas: 130866)
LibCloneTest:testDeployERC1967(bytes32) (runs: 302, μ: 243731, ~: 131048)
LibCloneTest:testDeployERC1967BeaconProxy(bytes32) (runs: 302, μ: 351377, ~: 294787)
LibCloneTest:testDeployDeterministicERC1967I(bytes32) (runs: 302, μ: 2388394, ~: 129378)
LibCloneTest:testDeployDeterministicERC1967WithImmutableArgs() (gas: 166875)
LibCloneTest:testDeployDeterministicERC1967WithImmutableArgs(bytes32) (runs: 302, μ: 5943394, ~: 144993)
LibCloneTest:testDeployERC1967() (gas: 130814)
LibCloneTest:testDeployERC1967(bytes32) (runs: 302, μ: 255492, ~: 130944)
LibCloneTest:testDeployERC1967BeaconProxy(bytes32) (runs: 302, μ: 352681, ~: 356764)
LibCloneTest:testDeployERC1967BeaconProxyWithImmutableArgs() (gas: 293333)
LibCloneTest:testDeployERC1967BeaconProxyWithImmutableArgs(address,bytes32) (runs: 302, μ: 27073722, ~: 260084)
LibCloneTest:testDeployERC1967BeaconProxyWithImmutableArgs(address,bytes32) (runs: 302, μ: 25125401, ~: 257289)
LibCloneTest:testDeployERC1967I() (gas: 128886)
LibCloneTest:testDeployERC1967I(bytes32) (runs: 302, μ: 129002, ~: 129002)
LibCloneTest:testDeployERC1967WithImmutableArgs() (gas: 141729)
LibCloneTest:testDeployERC1967WithImmutableArgs(bytes32) (runs: 302, μ: 5291346, ~: 154850)
LibCloneTest:testERC1967BeaconProxyGasBehavior(uint256,uint256) (runs: 302, μ: 360658, ~: 346659)
LibCloneTest:testERC1967ConstantBootstrap(address,bytes32) (runs: 302, μ: 194441, ~: 169423)
LibCloneTest:testInitCode(address) (runs: 302, μ: 242584, ~: 36601)
LibCloneTest:testDeployERC1967WithImmutableArgs() (gas: 141650)
LibCloneTest:testDeployERC1967WithImmutableArgs(bytes32) (runs: 302, μ: 6398726, ~: 143117)
LibCloneTest:testERC1967BeaconProxyGasBehavior(uint256,uint256) (runs: 302, μ: 366992, ~: 346708)
LibCloneTest:testERC1967ConstantBootstrap(address,bytes32) (runs: 302, μ: 192067, ~: 169385)
LibCloneTest:testInitCode(address) (runs: 302, μ: 255019, ~: 36820)
LibCloneTest:testInitialDeposit() (gas: 585537)
LibCloneTest:testSlicingRevertsOnZeroCodeAddress(address) (runs: 302, μ: 89981, ~: 30400)
LibCloneTest:testStartsWith(uint256) (runs: 302, μ: 29399, ~: 29361)
LibCloneTest:test__codesize() (gas: 31104)
LibCloneTest:testSlicingRevertsOnZeroCodeAddress(address) (runs: 302, μ: 94293, ~: 30411)
LibCloneTest:testStartsWith(uint256) (runs: 302, μ: 29399, ~: 29468)
LibCloneTest:test__codesize() (gas: 31019)
LibERC6551Test:testComputeAccountAddress(address,bytes32,uint256,address,uint256) (runs: 302, μ: 281634, ~: 28642)
LibERC6551Test:testContext(address,bytes32,uint256,address,uint256) (runs: 302, μ: 101743, ~: 101643)
LibERC6551Test:testInitCodeHash(address,bytes32,uint256,address,uint256) (runs: 302, μ: 228992, ~: 23818)
Expand Down Expand Up @@ -1121,20 +1121,20 @@ ReentrancyGuardTest:testRevertRecursiveDirectGuardedCall() (gas: 55123)
ReentrancyGuardTest:testRevertRecursiveIndirectGuardedCall() (gas: 56529)
ReentrancyGuardTest:testRevertRemoteCallback() (gas: 56230)
ReentrancyGuardTest:test__codesize() (gas: 4403)
SSTORE2Test:testReadRevertsOnZeroCodeAddress(address) (runs: 302, μ: 110490, ~: 30000)
SSTORE2Test:testReadSlicing() (gas: 49058)
SSTORE2Test:testReadRevertsOnZeroCodeAddress(address) (runs: 302, μ: 106851, ~: 30000)
SSTORE2Test:testReadSlicing() (gas: 48874)
SSTORE2Test:testWriteRead() (gas: 35880)
SSTORE2Test:testWriteRead(uint256,uint256) (runs: 302, μ: 1169341, ~: 83929)
SSTORE2Test:testWriteReadCounterfactual(bytes,bytes32,address) (runs: 302, μ: 4920150, ~: 108268)
SSTORE2Test:testWriteReadCustomBounds() (gas: 33982)
SSTORE2Test:testWriteRead(uint256,uint256) (runs: 302, μ: 1055846, ~: 68162)
SSTORE2Test:testWriteReadCounterfactual(bytes,bytes32,address) (runs: 302, μ: 4279229, ~: 108268)
SSTORE2Test:testWriteReadCustomBounds() (gas: 33936)
SSTORE2Test:testWriteReadCustomStartBound() (gas: 34020)
SSTORE2Test:testWriteReadDeterministic() (gas: 70156)
SSTORE2Test:testWriteReadDeterministic(bytes,bytes32) (runs: 302, μ: 3303806, ~: 96728)
SSTORE2Test:testWriteReadEmptyBound() (gas: 33780)
SSTORE2Test:testWriteReadFullBoundedRead() (gas: 35983)
SSTORE2Test:testWriteReadDeterministic(bytes,bytes32) (runs: 302, μ: 2342379, ~: 96728)
SSTORE2Test:testWriteReadEmptyBound() (gas: 33734)
SSTORE2Test:testWriteReadFullBoundedRead() (gas: 35937)
SSTORE2Test:testWriteReadFullStartBound() (gas: 33983)
SSTORE2Test:testWriteWithTooBigDataReverts() (gas: 97303641)
SSTORE2Test:test__codesize() (gas: 8506)
SSTORE2Test:test__codesize() (gas: 8479)
SafeCastLibTest:testSafeCastInt256ToInt(int256,uint256) (runs: 302, μ: 18917, ~: 24774)
SafeCastLibTest:testSafeCastInt256ToIntBench() (gas: 341694)
SafeCastLibTest:testSafeCastInt256ToIntTrickEquivalence(int256) (runs: 302, μ: 406, ~: 406)
Expand Down Expand Up @@ -1236,7 +1236,7 @@ SignatureCheckerLibTest:testERC6492PreDeploy() (gas: 1226964)
SignatureCheckerLibTest:testERC6492WithoutRevertingVerifier() (gas: 61805)
SignatureCheckerLibTest:testEmptyCalldataHelpers() (gas: 3987)
SignatureCheckerLibTest:testEtchERC6492RevertingVerifier() (gas: 56459)
SignatureCheckerLibTest:testSignatureChecker(bytes32) (runs: 302, μ: 56039, ~: 45442)
SignatureCheckerLibTest:testSignatureChecker(bytes32) (runs: 302, μ: 55960, ~: 45442)
SignatureCheckerLibTest:testSignatureCheckerOnEOAWithInvalidSignature() (gas: 21300)
SignatureCheckerLibTest:testSignatureCheckerOnEOAWithInvalidSigner() (gas: 30800)
SignatureCheckerLibTest:testSignatureCheckerOnEOAWithMatchingSignerAndSignature() (gas: 17697)
Expand Down Expand Up @@ -1264,7 +1264,7 @@ UUPSUpgradeableTest:testUpgradeToRevertWithUpgradeFailed() (gas: 18583)
UUPSUpgradeableTest:test__codesize() (gas: 6048)
UpgradeableBeaconTest:testInitializeUpgradeableSolidityBeacon() (gas: 296434)
UpgradeableBeaconTest:testInitializeUpgradeableYulBeacon() (gas: 335455)
UpgradeableBeaconTest:testUpgradeableBeacon(uint256) (runs: 302, μ: 246013, ~: 255891)
UpgradeableBeaconTest:testUpgradeableBeacon(uint256) (runs: 302, μ: 245844, ~: 255891)
UpgradeableBeaconTest:testUpgradeableSolidityBeaconOnlyFnSelectorNotRecognised() (gas: 234560)
UpgradeableBeaconTest:testUpgradeableSolidityBeaconOnlyOwnerFunctions() (gas: 260339)
UpgradeableBeaconTest:testUpgradeableYulBeaconOnlyFnSelectorNotRecognised() (gas: 172796)
Expand Down
15 changes: 3 additions & 12 deletions src/utils/LibClone.sol
Original file line number Diff line number Diff line change
Expand Up @@ -599,16 +599,13 @@ library LibClone {
assembly {
args := mload(0x40)
if iszero(lt(end, 0xffff)) { end := 0xffff }
if iszero(lt(start, 0xffff)) { start := 0xffff }
let d := sub(end, start)
if iszero(lt(d, 0xffff)) { d := 0xffff }
let d := mul(sub(end, start), lt(start, end))
extcodecopy(instance, args, add(start, 0x0d), add(d, 0x20))
if iszero(and(0xff, mload(add(args, d)))) {
let n := sub(extcodesize(instance), 0x2d)
returndatacopy(returndatasize(), returndatasize(), shr(64, n))
d := mul(gt(n, start), sub(d, mul(gt(end, n), sub(end, n))))
}
d := mul(d, lt(start, end))
mstore(args, d) // Store the length.
mstore(add(add(args, 0x20), d), 0) // Zeroize the slot after the bytes.
mstore(0x40, add(add(args, 0x40), d)) // Allocate memory.
Expand Down Expand Up @@ -1076,16 +1073,13 @@ library LibClone {
assembly {
args := mload(0x40)
if iszero(lt(end, 0xffff)) { end := 0xffff }
if iszero(lt(start, 0xffff)) { start := 0xffff }
let d := sub(end, start)
if iszero(lt(d, 0xffff)) { d := 0xffff }
let d := mul(sub(end, start), lt(start, end))
extcodecopy(instance, args, add(start, 0x1d), add(d, 0x20))
if iszero(and(0xff, mload(add(args, d)))) {
let n := sub(extcodesize(instance), 0x3d)
returndatacopy(returndatasize(), returndatasize(), shr(64, n))
d := mul(gt(n, start), sub(d, mul(gt(end, n), sub(end, n))))
}
d := mul(d, lt(start, end))
mstore(args, d) // Store the length.
mstore(add(add(args, 0x20), d), 0) // Zeroize the slot after the bytes.
mstore(0x40, add(add(args, 0x40), d)) // Allocate memory.
Expand Down Expand Up @@ -1859,16 +1853,13 @@ library LibClone {
assembly {
args := mload(0x40)
if iszero(lt(end, 0xffff)) { end := 0xffff }
if iszero(lt(start, 0xffff)) { start := 0xffff }
let d := sub(end, start)
if iszero(lt(d, 0xffff)) { d := 0xffff }
let d := mul(sub(end, start), lt(start, end))
extcodecopy(instance, args, add(start, 0x32), add(d, 0x20))
if iszero(and(0xff, mload(add(args, d)))) {
let n := sub(extcodesize(instance), 0x52)
returndatacopy(returndatasize(), returndatasize(), shr(64, n))
d := mul(gt(n, start), sub(d, mul(gt(end, n), sub(end, n))))
}
d := mul(d, lt(start, end))
mstore(args, d) // Store the length.
mstore(add(add(args, 0x20), d), 0) // Zeroize the slot after the bytes.
mstore(0x40, add(add(args, 0x40), d)) // Allocate memory.
Expand Down
5 changes: 1 addition & 4 deletions src/utils/SSTORE2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,13 @@ library SSTORE2 {
assembly {
data := mload(0x40)
if iszero(lt(end, 0xffff)) { end := 0xffff }
if iszero(lt(start, 0xffff)) { start := 0xffff }
let d := sub(end, start)
if iszero(lt(d, 0xffff)) { d := 0xffff }
let d := mul(sub(end, start), lt(start, end))
extcodecopy(pointer, add(data, 0x1f), start, add(d, 0x01))
if iszero(and(0xff, mload(add(data, d)))) {
let n := sub(extcodesize(pointer), 0x01)
returndatacopy(returndatasize(), returndatasize(), shr(64, n))
d := mul(gt(n, start), sub(d, mul(gt(end, n), sub(end, n))))
}
d := mul(d, lt(start, end))
mstore(data, d) // Store the length.
mstore(add(add(data, 0x20), d), 0) // Zeroize the slot after the bytes.
mstore(0x40, add(add(data, 0x40), d)) // Allocate memory.
Expand Down

0 comments on commit 44ffa1b

Please sign in to comment.