Skip to content

Commit

Permalink
Add short circuit to optimize gas for regular ERC20s
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloTruck committed Oct 18, 2024
1 parent 7b75659 commit e29bde5
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 106 deletions.
134 changes: 67 additions & 67 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ ERC1155Test:testSafeTransferFromToEOA() (gas: 93167)
ERC1155Test:testSafeTransferFromToEOA(uint256,uint256,bytes,uint256,address,bytes) (runs: 256, μ: 95702, ~: 97464)
ERC1155Test:testSafeTransferFromToERC1155Recipient() (gas: 739583)
ERC1155Test:testSafeTransferFromToERC1155Recipient(uint256,uint256,bytes,uint256,bytes) (runs: 256, μ: 773221, ~: 765729)
ERC20Invariants:invariantBalanceSum() (runs: 256, calls: 128000, reverts: 78753)
ERC20Test:invariantMetadata() (runs: 256, calls: 128000, reverts: 85921)
ERC20Invariants:invariantBalanceSum() (runs: 256, calls: 128000, reverts: 78125)
ERC20Test:invariantMetadata() (runs: 256, calls: 128000, reverts: 86260)
ERC20Test:testApprove() (gas: 31058)
ERC20Test:testApprove(address,uint256) (runs: 256, μ: 31202, ~: 31280)
ERC20Test:testBurn() (gas: 56970)
Expand Down Expand Up @@ -147,23 +147,23 @@ ERC20Test:testTransfer() (gas: 60272)
ERC20Test:testTransfer(address,uint256) (runs: 256, μ: 60328, ~: 60484)
ERC20Test:testTransferFrom() (gas: 83777)
ERC20Test:testTransferFrom(address,uint256,uint256) (runs: 256, μ: 91352, ~: 92841)
ERC4626Test:invariantMetadata() (runs: 256, calls: 128000, reverts: 100409)
ERC4626Test:testFailDepositWithNoApproval() (gas: 13478)
ERC4626Test:testFailDepositWithNotEnoughApproval() (gas: 87114)
ERC4626Test:invariantMetadata() (runs: 256, calls: 128000, reverts: 100543)
ERC4626Test:testFailDepositWithNoApproval() (gas: 13384)
ERC4626Test:testFailDepositWithNotEnoughApproval() (gas: 87020)
ERC4626Test:testFailDepositZero() (gas: 7780)
ERC4626Test:testFailMintWithNoApproval() (gas: 13417)
ERC4626Test:testFailMintWithNoApproval() (gas: 13323)
ERC4626Test:testFailRedeemWithNoShareAmount() (gas: 32342)
ERC4626Test:testFailRedeemWithNotEnoughShareAmount() (gas: 203752)
ERC4626Test:testFailRedeemWithNotEnoughShareAmount() (gas: 203658)
ERC4626Test:testFailRedeemZero() (gas: 7967)
ERC4626Test:testFailWithdrawWithNoUnderlyingAmount() (gas: 32289)
ERC4626Test:testFailWithdrawWithNotEnoughUnderlyingAmount() (gas: 203716)
ERC4626Test:testMetadata(string,string) (runs: 256, μ: 1470108, ~: 1473598)
ERC4626Test:testMintZero() (gas: 54716)
ERC4626Test:testMultipleMintDepositRedeemWithdraw() (gas: 412502)
ERC4626Test:testSingleDepositWithdraw(uint128) (runs: 256, μ: 201714, ~: 201720)
ERC4626Test:testSingleMintRedeem(uint128) (runs: 256, μ: 201640, ~: 201645)
ERC4626Test:testVaultInteractionsForSomeoneElse() (gas: 286587)
ERC4626Test:testWithdrawZero() (gas: 52577)
ERC4626Test:testFailWithdrawWithNotEnoughUnderlyingAmount() (gas: 203622)
ERC4626Test:testMetadata(string,string) (runs: 256, μ: 1473317, ~: 1476809)
ERC4626Test:testMintZero() (gas: 54622)
ERC4626Test:testMultipleMintDepositRedeemWithdraw() (gas: 411900)
ERC4626Test:testSingleDepositWithdraw(uint128) (runs: 256, μ: 201564, ~: 201569)
ERC4626Test:testSingleMintRedeem(uint128) (runs: 256, μ: 201490, ~: 201495)
ERC4626Test:testVaultInteractionsForSomeoneElse() (gas: 286286)
ERC4626Test:testWithdrawZero() (gas: 52483)
ERC6909Test:testApprove() (gas: 31572)
ERC6909Test:testApprove(address,uint256,uint256) (runs: 256, μ: 31715, ~: 31793)
ERC6909Test:testBurn() (gas: 35411)
Expand Down Expand Up @@ -191,7 +191,7 @@ ERC6909Test:testTransferFromWithApproval() (gas: 91890)
ERC6909Test:testTransferFromWithApproval(address,address,uint256,uint256,uint256) (runs: 256, μ: 93876, ~: 94697)
ERC6909Test:testTransferFromWithInfiniteApproval() (gas: 91541)
ERC6909Test:testTransferFromWithInfiniteApproval(address,address,uint256,uint256,uint256) (runs: 256, μ: 93483, ~: 94262)
ERC721Test:invariantMetadata() (runs: 256, calls: 128000, reverts: 72577)
ERC721Test:invariantMetadata() (runs: 256, calls: 128000, reverts: 72441)
ERC721Test:testApprove() (gas: 78427)
ERC721Test:testApprove(address,uint256) (runs: 256, μ: 78637, ~: 78637)
ERC721Test:testApproveAll() (gas: 31063)
Expand Down Expand Up @@ -496,69 +496,69 @@ SafeCastLibTest:testSafeCastTo80(uint256) (runs: 256, μ: 2736, ~: 2736)
SafeCastLibTest:testSafeCastTo88(uint256) (runs: 256, μ: 2755, ~: 2755)
SafeCastLibTest:testSafeCastTo96() (gas: 536)
SafeCastLibTest:testSafeCastTo96(uint256) (runs: 256, μ: 2800, ~: 2800)
SafeTransferLibTest:testApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 3246, ~: 2187)
SafeTransferLibTest:testApproveWithMissingReturn() (gas: 30844)
SafeTransferLibTest:testApproveWithMissingReturn(address,uint256,bytes) (runs: 256, μ: 31454, ~: 31681)
SafeTransferLibTest:testApproveWithReturnsTooMuch() (gas: 31227)
SafeTransferLibTest:testApproveWithReturnsTooMuch(address,uint256,bytes) (runs: 256, μ: 31900, ~: 32127)
SafeTransferLibTest:testApproveWithStandardERC20() (gas: 30997)
SafeTransferLibTest:testApproveWithStandardERC20(address,uint256,bytes) (runs: 256, μ: 31648, ~: 31875)
SafeTransferLibTest:testFailApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 86243, ~: 78035)
SafeTransferLibTest:testFailApproveWithNonContract() (gas: 3222)
SafeTransferLibTest:testFailApproveWithNonContract(address,address,uint256,bytes) (runs: 256, μ: 4302, ~: 4311)
SafeTransferLibTest:testFailApproveWithReturnsFalse() (gas: 5731)
SafeTransferLibTest:testFailApproveWithReturnsFalse(address,uint256,bytes) (runs: 256, μ: 6563, ~: 6557)
SafeTransferLibTest:testFailApproveWithReturnsTooLittle() (gas: 5672)
SafeTransferLibTest:testFailApproveWithReturnsTooLittle(address,uint256,bytes) (runs: 256, μ: 6571, ~: 6565)
SafeTransferLibTest:testFailApproveWithReturnsTwo(address,uint256,bytes) (runs: 256, μ: 6579, ~: 6573)
SafeTransferLibTest:testFailApproveWithReverting() (gas: 5628)
SafeTransferLibTest:testFailApproveWithReverting(address,uint256,bytes) (runs: 256, μ: 6508, ~: 6502)
SafeTransferLibTest:testApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 3256, ~: 2187)
SafeTransferLibTest:testApproveWithMissingReturn() (gas: 30866)
SafeTransferLibTest:testApproveWithMissingReturn(address,uint256,bytes) (runs: 256, μ: 31476, ~: 31703)
SafeTransferLibTest:testApproveWithReturnsTooMuch() (gas: 31133)
SafeTransferLibTest:testApproveWithReturnsTooMuch(address,uint256,bytes) (runs: 256, μ: 31806, ~: 32033)
SafeTransferLibTest:testApproveWithStandardERC20() (gas: 30903)
SafeTransferLibTest:testApproveWithStandardERC20(address,uint256,bytes) (runs: 256, μ: 31554, ~: 31781)
SafeTransferLibTest:testFailApproveWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 87459, ~: 78057)
SafeTransferLibTest:testFailApproveWithNonContract() (gas: 3244)
SafeTransferLibTest:testFailApproveWithNonContract(address,address,uint256,bytes) (runs: 256, μ: 4277, ~: 4333)
SafeTransferLibTest:testFailApproveWithReturnsFalse() (gas: 5753)
SafeTransferLibTest:testFailApproveWithReturnsFalse(address,uint256,bytes) (runs: 256, μ: 6585, ~: 6579)
SafeTransferLibTest:testFailApproveWithReturnsTooLittle() (gas: 5694)
SafeTransferLibTest:testFailApproveWithReturnsTooLittle(address,uint256,bytes) (runs: 256, μ: 6593, ~: 6587)
SafeTransferLibTest:testFailApproveWithReturnsTwo(address,uint256,bytes) (runs: 256, μ: 6601, ~: 6595)
SafeTransferLibTest:testFailApproveWithReverting() (gas: 5534)
SafeTransferLibTest:testFailApproveWithReverting(address,uint256,bytes) (runs: 256, μ: 6414, ~: 6408)
SafeTransferLibTest:testFailTransferETHToContractWithoutFallback() (gas: 7244)
SafeTransferLibTest:testFailTransferETHToContractWithoutFallback(uint256,bytes) (runs: 256, μ: 7988, ~: 8055)
SafeTransferLibTest:testFailTransferFromWithGarbage(address,address,uint256,bytes,bytes) (runs: 256, μ: 125174, ~: 117511)
SafeTransferLibTest:testFailTransferFromWithNonContract() (gas: 3234)
SafeTransferLibTest:testFailTransferFromWithNonContract(address,address,address,uint256,bytes) (runs: 256, μ: 4378, ~: 4433)
SafeTransferLibTest:testFailTransferFromWithReturnsFalse() (gas: 13751)
SafeTransferLibTest:testFailTransferFromWithReturnsFalse(address,address,uint256,bytes) (runs: 256, μ: 14681, ~: 14676)
SafeTransferLibTest:testFailTransferFromWithReturnsTooLittle() (gas: 13654)
SafeTransferLibTest:testFailTransferFromWithReturnsTooLittle(address,address,uint256,bytes) (runs: 256, μ: 14606, ~: 14601)
SafeTransferLibTest:testFailTransferFromWithReturnsTwo(address,address,uint256,bytes) (runs: 256, μ: 14733, ~: 14728)
SafeTransferLibTest:testFailTransferFromWithGarbage(address,address,uint256,bytes,bytes) (runs: 256, μ: 127531, ~: 117533)
SafeTransferLibTest:testFailTransferFromWithNonContract() (gas: 3256)
SafeTransferLibTest:testFailTransferFromWithNonContract(address,address,address,uint256,bytes) (runs: 256, μ: 4436, ~: 4455)
SafeTransferLibTest:testFailTransferFromWithReturnsFalse() (gas: 13773)
SafeTransferLibTest:testFailTransferFromWithReturnsFalse(address,address,uint256,bytes) (runs: 256, μ: 14703, ~: 14698)
SafeTransferLibTest:testFailTransferFromWithReturnsTooLittle() (gas: 13676)
SafeTransferLibTest:testFailTransferFromWithReturnsTooLittle(address,address,uint256,bytes) (runs: 256, μ: 14628, ~: 14623)
SafeTransferLibTest:testFailTransferFromWithReturnsTwo(address,address,uint256,bytes) (runs: 256, μ: 14755, ~: 14750)
SafeTransferLibTest:testFailTransferFromWithReverting() (gas: 9757)
SafeTransferLibTest:testFailTransferFromWithReverting(address,address,uint256,bytes) (runs: 256, μ: 10685, ~: 10680)
SafeTransferLibTest:testFailTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 92122, ~: 84104)
SafeTransferLibTest:testFailTransferWithNonContract() (gas: 3200)
SafeTransferLibTest:testFailTransferWithNonContract(address,address,uint256,bytes) (runs: 256, μ: 4278, ~: 4287)
SafeTransferLibTest:testFailTransferWithReturnsFalse() (gas: 8647)
SafeTransferLibTest:testFailTransferWithReturnsFalse(address,uint256,bytes) (runs: 256, μ: 9567, ~: 9561)
SafeTransferLibTest:testFailTransferWithReturnsTooLittle() (gas: 8631)
SafeTransferLibTest:testFailTransferWithReturnsTooLittle(address,uint256,bytes) (runs: 256, μ: 9507, ~: 9501)
SafeTransferLibTest:testFailTransferWithReturnsTwo(address,uint256,bytes) (runs: 256, μ: 9539, ~: 9533)
SafeTransferLibTest:testFailTransferWithReverting() (gas: 8609)
SafeTransferLibTest:testFailTransferWithReverting(address,uint256,bytes) (runs: 256, μ: 9466, ~: 9460)
SafeTransferLibTest:testFailTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 93432, ~: 84126)
SafeTransferLibTest:testFailTransferWithNonContract() (gas: 3222)
SafeTransferLibTest:testFailTransferWithNonContract(address,address,uint256,bytes) (runs: 256, μ: 4253, ~: 4309)
SafeTransferLibTest:testFailTransferWithReturnsFalse() (gas: 8669)
SafeTransferLibTest:testFailTransferWithReturnsFalse(address,uint256,bytes) (runs: 256, μ: 9589, ~: 9583)
SafeTransferLibTest:testFailTransferWithReturnsTooLittle() (gas: 8653)
SafeTransferLibTest:testFailTransferWithReturnsTooLittle(address,uint256,bytes) (runs: 256, μ: 9529, ~: 9523)
SafeTransferLibTest:testFailTransferWithReturnsTwo(address,uint256,bytes) (runs: 256, μ: 9561, ~: 9555)
SafeTransferLibTest:testFailTransferWithReverting() (gas: 8515)
SafeTransferLibTest:testFailTransferWithReverting(address,uint256,bytes) (runs: 256, μ: 9372, ~: 9366)
SafeTransferLibTest:testTransferETH() (gas: 34592)
SafeTransferLibTest:testTransferETH(address,uint256,bytes) (runs: 256, μ: 37340, ~: 37953)
SafeTransferLibTest:testTransferFromWithGarbage(address,address,uint256,bytes,bytes) (runs: 256, μ: 2859, ~: 2298)
SafeTransferLibTest:testTransferFromWithMissingReturn() (gas: 49283)
SafeTransferLibTest:testTransferFromWithMissingReturn(address,address,uint256,bytes) (runs: 256, μ: 49430, ~: 49706)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch() (gas: 49889)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch(address,address,uint256,bytes) (runs: 256, μ: 50124, ~: 50399)
SafeTransferLibTest:testTransferFromWithStandardERC20() (gas: 47700)
SafeTransferLibTest:testTransferFromWithStandardERC20(address,address,uint256,bytes) (runs: 256, μ: 47895, ~: 48175)
SafeTransferLibTest:testTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 3339, ~: 2187)
SafeTransferLibTest:testTransferWithMissingReturn() (gas: 36846)
SafeTransferLibTest:testTransferWithMissingReturn(address,uint256,bytes) (runs: 256, μ: 37389, ~: 37705)
SafeTransferLibTest:testTransferWithReturnsTooMuch() (gas: 37205)
SafeTransferLibTest:testTransferWithReturnsTooMuch(address,uint256,bytes) (runs: 256, μ: 37726, ~: 38042)
SafeTransferLibTest:testTransferWithStandardERC20() (gas: 36811)
SafeTransferLibTest:testTransferWithStandardERC20(address,uint256,bytes) (runs: 256, μ: 37376, ~: 37692)
SafeTransferLibTest:testTransferETH(address,uint256,bytes) (runs: 256, μ: 37330, ~: 37953)
SafeTransferLibTest:testTransferFromWithGarbage(address,address,uint256,bytes,bytes) (runs: 256, μ: 2899, ~: 2298)
SafeTransferLibTest:testTransferFromWithMissingReturn() (gas: 49300)
SafeTransferLibTest:testTransferFromWithMissingReturn(address,address,uint256,bytes) (runs: 256, μ: 49516, ~: 49725)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch() (gas: 49814)
SafeTransferLibTest:testTransferFromWithReturnsTooMuch(address,address,uint256,bytes) (runs: 256, μ: 50118, ~: 50325)
SafeTransferLibTest:testTransferFromWithStandardERC20() (gas: 47624)
SafeTransferLibTest:testTransferFromWithStandardERC20(address,address,uint256,bytes) (runs: 256, μ: 47889, ~: 48101)
SafeTransferLibTest:testTransferWithGarbage(address,uint256,bytes,bytes) (runs: 256, μ: 3349, ~: 2187)
SafeTransferLibTest:testTransferWithMissingReturn() (gas: 36868)
SafeTransferLibTest:testTransferWithMissingReturn(address,uint256,bytes) (runs: 256, μ: 37411, ~: 37727)
SafeTransferLibTest:testTransferWithReturnsTooMuch() (gas: 37111)
SafeTransferLibTest:testTransferWithReturnsTooMuch(address,uint256,bytes) (runs: 256, μ: 37632, ~: 37948)
SafeTransferLibTest:testTransferWithStandardERC20() (gas: 36717)
SafeTransferLibTest:testTransferWithStandardERC20(address,uint256,bytes) (runs: 256, μ: 37282, ~: 37598)
SignedWadMathTest:testFailWadDivOverflow(int256,int256) (runs: 256, μ: 344, ~: 329)
SignedWadMathTest:testFailWadDivZeroDenominator(int256) (runs: 256, μ: 296, ~: 296)
SignedWadMathTest:testFailWadMulEdgeCase() (gas: 286)
SignedWadMathTest:testFailWadMulEdgeCase2() (gas: 309)
SignedWadMathTest:testFailWadMulOverflow(int256,int256) (runs: 256, μ: 349, ~: 319)
SignedWadMathTest:testWadDiv(uint256,uint256,bool,bool) (runs: 256, μ: 5711, ~: 5714)
SignedWadMathTest:testWadMul(uint256,uint256,bool,bool) (runs: 256, μ: 5759, ~: 5762)
WETHInvariants:invariantTotalSupplyEqualsBalance() (runs: 256, calls: 128000, reverts: 58461)
WETHInvariants:invariantTotalSupplyEqualsBalance() (runs: 256, calls: 128000, reverts: 58472)
WETHTest:testDeposit() (gas: 63535)
WETHTest:testDeposit(uint256) (runs: 256, μ: 64971, ~: 65880)
WETHTest:testFallbackDeposit() (gas: 63249)
Expand Down
Loading

0 comments on commit e29bde5

Please sign in to comment.