Skip to content

Commit

Permalink
add underflow comments, .env for casing solc path
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds committed Nov 14, 2023
1 parent 2f61eb9 commit 94398f2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
FOUNDRY_FUZZ_SEED=0x4444

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
FOUNDRY_SOLC="./bin/solc-static-linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
FOUNDRY_SOLC="./bin/solc"
fi
47 changes: 23 additions & 24 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ ClaimsTest:testCatchesUnderflowOnBurn(uint256) (runs: 100, μ: 39932, ~: 40927)
ClaimsTest:testCatchesUnderflowOnTransfer(uint256) (runs: 100, μ: 40057, ~: 41052)
ClaimsTest:testTransferToClaimsContractFails() (gas: 36413)
FeesTest:testCollectFees() (gas: 622560)
FeesTest:testHookWithdrawFeeProtocolWithdrawFee(uint16,uint16) (runs: 100, μ: 491322, ~: 495940)
FeesTest:testInitializeAllFees(uint16,uint16,uint16,uint16) (runs: 100, μ: 164951, ~: 161247)
FeesTest:testInitializeBothHookFee(uint16,uint16) (runs: 100, μ: 84942, ~: 93440)
FeesTest:testHookWithdrawFeeProtocolWithdrawFee(uint16,uint16) (runs: 100, μ: 489778, ~: 495940)
FeesTest:testInitializeAllFees(uint16,uint16,uint16,uint16) (runs: 100, μ: 164328, ~: 161230)
FeesTest:testInitializeBothHookFee(uint16,uint16) (runs: 100, μ: 85965, ~: 93440)
FeesTest:testInitializeFailsNoHook() (gas: 20233)
FeesTest:testInitializeHookProtocolSwapFee(uint16,uint16) (runs: 100, μ: 127860, ~: 133651)
FeesTest:testInitializeHookSwapFee(uint16) (runs: 100, μ: 68614, ~: 70884)
FeesTest:testInitializeHookWithdrawFee(uint16) (runs: 100, μ: 67973, ~: 70924)
FeesTest:testInitializeHookProtocolSwapFee(uint16,uint16) (runs: 100, μ: 127168, ~: 133651)
FeesTest:testInitializeHookSwapFee(uint16) (runs: 100, μ: 68387, ~: 70884)
FeesTest:testInitializeHookWithdrawFee(uint16) (runs: 100, μ: 68427, ~: 70924)
FeesTest:testInitializeWithSwapProtocolFeeAndHookFeeDifferentDirections() (gas: 584240)
FeesTest:testNoHookProtocolFee(uint16,uint16) (runs: 100, μ: 759115, ~: 765926)
FeesTest:testProtocolFeeOnWithdrawalRemainsZeroIfNoHookWithdrawalFeeSet(uint16,uint16) (runs: 100, μ: 469882, ~: 472269)
FeesTest:testNoHookProtocolFee(uint16,uint16) (runs: 100, μ: 757332, ~: 749711)
FeesTest:testProtocolFeeOnWithdrawalRemainsZeroIfNoHookWithdrawalFeeSet(uint16,uint16) (runs: 100, μ: 469564, ~: 472269)
FeesTest:testProtocolSwapFeeAndHookSwapFeeSameDirection() (gas: 604631)
FeesTest:testSwapWithProtocolFeeAllAndHookFeeAllButOnlySwapFlag() (gas: 643655)
FullMathTest:testResultOverflowsHelper() (gas: 3964)
Expand Down Expand Up @@ -69,17 +69,16 @@ HooksTest:testValidateHookAddressBeforeInitialize(uint152) (runs: 100, μ: 1859,
HooksTest:testValidateHookAddressBeforeInitializeAfterModify(uint152) (runs: 100, μ: 1806, ~: 1806)
HooksTest:testValidateHookAddressBeforeModify(uint152) (runs: 100, μ: 1818, ~: 1818)
HooksTest:testValidateHookAddressBeforeSwap(uint152) (runs: 100, μ: 1811, ~: 1811)
HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 100, μ: 4741, ~: 4686)
HooksTest:testValidateHookAddressFailsAllHooks(uint152,uint8) (runs: 100, μ: 4745, ~: 4686)
HooksTest:testValidateHookAddressFailsNoHooks(uint152,uint8) (runs: 100, μ: 4821, ~: 4751)
HooksTest:testValidateHookAddressNoHooks(uint152) (runs: 100, μ: 1867, ~: 1867)
LockDataLibraryTest:testLockerLengthAndNonzeroDeltaCount() (gas: 52364)
LockersLibrary:testLockerLengthAndNonzeroDeltaCount() (gas: 52428)
LockersLibrary:test_clear(address[]) (runs: 100, μ: 114024, ~: 111101)
LockersLibrary:test_decrementNonzeroDeltaCount() (gas: 1157)
LockersLibrary:test_decrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 122856, ~: 68325)
LockersLibrary:test_decrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 118191, ~: 62412)
LockersLibrary:test_getCurrentLocker_multipleAddressesFuzz(address[]) (runs: 100, μ: 273024, ~: 265967)
LockersLibrary:test_incrementNonzeroDeltaCount() (gas: 785)
LockersLibrary:test_incrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 73252, ~: 40716)
LockersLibrary:test_incrementNonzeroDeltaCountFuzz(uint8) (runs: 100, μ: 70468, ~: 37188)
LockersLibrary:test_pop() (gas: 1770)
LockersLibrary:test_pop_multipleAddressesFuzz(address[]) (runs: 100, μ: 240601, ~: 234397)
LockersLibrary:test_push() (gas: 1421)
Expand All @@ -98,38 +97,38 @@ PoolManagerTest:test_collectProtocolFees_initializesWithProtocolFeeIfCalled() (g
PoolManagerTest:test_collectProtocolFees_nativeToken_allowsOwnerToAccumulateFees_gas() (gas: 575352)
PoolManagerTest:test_collectProtocolFees_nativeToken_returnsAllFeesIf0IsProvidedAsParameter() (gas: 542397)
PoolManagerTest:test_donate_OneToken_gas() (gas: 452140)
PoolManagerTest:test_donate_failsIfNoLiquidity(uint160) (runs: 100, μ: 64505, ~: 64608)
PoolManagerTest:test_donate_failsIfNoLiquidity(uint160) (runs: 100, μ: 64484, ~: 64603)
PoolManagerTest:test_donate_failsIfNotInitialized() (gas: 27999)
PoolManagerTest:test_donate_failsWithIncorrectSelectors() (gas: 1420105)
PoolManagerTest:test_donate_succeedsForNativeTokensWhenPoolHasLiquidity() (gas: 440700)
PoolManagerTest:test_donate_succeedsWhenPoolHasLiquidity() (gas: 493133)
PoolManagerTest:test_donate_succeedsWithCorrectSelectors() (gas: 1393206)
PoolManagerTest:test_feeControllerSet() (gas: 39572)
PoolManagerTest:test_fetchFeeWhenController(uint160) (runs: 100, μ: 112698, ~: 112830)
PoolManagerTest:test_fetchFeeWhenController(uint160) (runs: 100, μ: 112688, ~: 112830)
PoolManagerTest:test_getPosition() (gas: 366837)
PoolManagerTest:test_initialize((address,address,uint24,int24,address),uint160) (runs: 100, μ: 18617, ~: 13942)
PoolManagerTest:test_initialize((address,address,uint24,int24,address),uint160) (runs: 100, μ: 18629, ~: 13942)
PoolManagerTest:test_initialize_failsIfTickSpaceNeg(uint160) (runs: 100, μ: 15843, ~: 15843)
PoolManagerTest:test_initialize_failsIfTickSpaceTooLarge(uint160) (runs: 100, μ: 16725, ~: 16725)
PoolManagerTest:test_initialize_failsIfTickSpaceZero(uint160) (runs: 100, μ: 15844, ~: 15844)
PoolManagerTest:test_initialize_failsWithIncorrectSelectors() (gas: 984435)
PoolManagerTest:test_initialize_forNativeTokens(uint160) (runs: 100, μ: 59222, ~: 59446)
PoolManagerTest:test_initialize_forNativeTokens(uint160) (runs: 100, μ: 59221, ~: 59445)
PoolManagerTest:test_initialize_gas() (gas: 73708)
PoolManagerTest:test_initialize_revertsWhenPoolAlreadyInitialized(uint160) (runs: 100, μ: 50377, ~: 50499)
PoolManagerTest:test_initialize_revertsWhenPoolAlreadyInitialized(uint160) (runs: 100, μ: 50388, ~: 50500)
PoolManagerTest:test_initialize_revertsWithIdenticalTokens(uint160) (runs: 100, μ: 13444, ~: 13444)
PoolManagerTest:test_initialize_revertsWithSameTokenCombo(uint160) (runs: 100, μ: 49218, ~: 49340)
PoolManagerTest:test_initialize_revertsWithSameTokenCombo(uint160) (runs: 100, μ: 49229, ~: 49341)
PoolManagerTest:test_initialize_succeedsWithCorrectSelectors() (gas: 980821)
PoolManagerTest:test_initialize_succeedsWithEmptyHooks(uint160) (runs: 100, μ: 946588, ~: 946701)
PoolManagerTest:test_initialize_succeedsWithHooks(uint160) (runs: 100, μ: 8937393460516837920, ~: 8937393460516838057)
PoolManagerTest:test_initialize_succeedsWithEmptyHooks(uint160) (runs: 100, μ: 946586, ~: 946698)
PoolManagerTest:test_initialize_succeedsWithHooks(uint160) (runs: 100, μ: 8937393460516837942, ~: 8937393460516838060)
PoolManagerTest:test_initialize_succeedsWithMaxTickSpacing(uint160) (runs: 100, μ: 50749, ~: 50862)
PoolManagerTest:test_lock_EmitsCorrectId() (gas: 18848)
PoolManagerTest:test_lock_NoOpIsOk() (gas: 50372)
PoolManagerTest:test_mint_failsIfNotInitialized() (gas: 29303)
PoolManagerTest:test_mint_failsWithIncorrectSelectors() (gas: 1176562)
PoolManagerTest:test_mint_gas() (gas: 304544)
PoolManagerTest:test_mint_succeedsForNativeTokensIfInitialized(uint160) (runs: 100, μ: 250555, ~: 267869)
PoolManagerTest:test_mint_succeedsIfInitialized(uint160) (runs: 100, μ: 254491, ~: 256272)
PoolManagerTest:test_mint_succeedsForNativeTokensIfInitialized(uint160) (runs: 100, μ: 251315, ~: 267869)
PoolManagerTest:test_mint_succeedsIfInitialized(uint160) (runs: 100, μ: 254636, ~: 256272)
PoolManagerTest:test_mint_succeedsWithCorrectSelectors() (gas: 1211340)
PoolManagerTest:test_mint_succeedsWithHooksIfInitialized(uint160) (runs: 100, μ: 8937393460517082450, ~: 8937393460517084215)
PoolManagerTest:test_mint_succeedsWithHooksIfInitialized(uint160) (runs: 100, μ: 8937393460517082660, ~: 8937393460517084226)
PoolManagerTest:test_mint_withHooks_gas() (gas: 1209319)
PoolManagerTest:test_mint_withNative_gas() (gas: 285824)
PoolManagerTest:test_setProtocolFee_updatesProtocolFeeForInitializedPool() (gas: 118065)
Expand All @@ -151,7 +150,7 @@ PoolManagerTest:test_take_failsWithNoLiquidity() (gas: 53474)
PoolManagerTest:test_take_succeedsWithPoolWithLiquidity() (gas: 469186)
PoolManagerTest:test_take_succeedsWithPoolWithLiquidityWithNativeToken() (gas: 438960)
PoolTest:testModifyPosition(uint160,(address,int24,int24,int128,int24)) (runs: 100, μ: 19911, ~: 7536)
PoolTest:testPoolInitialize(uint160,uint16,uint16,uint24) (runs: 100, μ: 16677, ~: 6430)
PoolTest:testPoolInitialize(uint160,uint16,uint16,uint24) (runs: 100, μ: 16678, ~: 6430)
PoolTest:testSwap(uint160,uint24,(int24,bool,int256,uint160)) (runs: 100, μ: 212167, ~: 7868)
SafeCastTest:testToInt128(int256) (runs: 100, μ: 1384, ~: 445)
SafeCastTest:testToInt128(uint256) (runs: 100, μ: 1084, ~: 390)
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ All contributions must follow the below standards. Maintainers will close out PR

## Setup

Run `source .env` to set FOUNDRY_SOLC to the correct solc binary.

`forge build` to get contract artifacts and dependencies for forge

## Tests
Expand Down
1 change: 0 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ via_ir = false
ffi = true
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/"}, { access = "read", path = "./out"}]
cancun = true
solc = "./bin/solc"

[profile.default.fuzz]
runs = 100
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/Lockers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ library Lockers {
}
}

/// @notice Potential to underflow.
/// Current useage ensures this will not happen because we call decrememnt with known boundaries (only up to the numer of times we call increment).
function decrementNonzeroDeltaCount() internal {
uint256 slot = NONZERO_DELTA_COUNT;
assembly {
Expand Down

0 comments on commit 94398f2

Please sign in to comment.