pancakeswap / pancake-v4-core

GNU General Public License v2.0
51 stars 33 forks source link

Investigate test failure in `CLPool.t.sol` #38

Open ChefMist opened 5 months ago

ChefMist commented 5 months ago

from this job https://github.com/pancakeswap/pancake-v4-core/actions/runs/8996481967/job/24713051330 which runs after merging https://github.com/pancakeswap/pancake-v4-core/pull/30

Though it seems that the test didn't fail due to the change. this are the params which can trigger the test failure locally even after reverting the changes in src/pool-cl/libraries/LiquidityMath.sol from https://github.com/pancakeswap/pancake-v4-core/pull/30

test/pool-cl/libraries/CLPool.t.sol

function testSwap(
        uint160 sqrtPriceX96,
        CLPool.ModifyLiquidityParams memory modifyLiquidityParams,
        CLPool.SwapParams memory swapParams,
        uint24 swapFee
    ) public {
        sqrtPriceX96 = 4295128739;
        modifyLiquidityParams = CLPool.ModifyLiquidityParams({
                owner: 0x0000000000000000000000000000000000000000,
                tickLower: 0,
                tickUpper: 295988,
                liquidityDelta: 63654653689537733100209589053550,
                tickSpacing: 1
            });

        swapParams = CLPool.SwapParams({
                tickSpacing: 0,
                zeroForOne: false,
                amountSpecified: 170141183460469231731687303715884105728,
                sqrtPriceLimitX96: 211765884121348748676852868765138027
            });

        ......
    }
ChefMist commented 5 months ago

this test also fail when done the below. checkout to an older commit: https://github.com/pancakeswap/pancake-v4-core/commit/2eb67b3e17c681c5a1ee7a31dbd7128c30cd6968

1. git checkout 2eb67b3e17c681c5a1ee7a31dbd7128c30cd6968
2. run testSwap with those param
3. forge test and see the error
chefburger commented 4 months ago

Unfortunately, this has not been solved, check detail reason & temp workaround: https://github.com/pancakeswap/pancake-v4-core/blob/756629a62eebc3a80bd029458b2656721bbe24c2/test/pool-cl/libraries/CLPool.t.sol#L102