code-423n4 / 2023-12-particle-findings

2 stars 1 forks source link

Gas Optimizations #63

Open c4-bot-4 opened 11 months ago

c4-bot-4 commented 11 months ago

See the markdown file with the details of this report here.

c4-judge commented 11 months ago

0xleastwood marked the issue as selected for report

c4-judge commented 11 months ago

0xleastwood marked the issue as grade-a

wukong-particle commented 11 months ago

What a nice trick to learn for G1, thanks!

Re G4, so we should modify it into the following, right?

struct Info {
         uint40 tokenId;
         uint128 liquidity;
         uint24 token0PremiumPortion;
         uint24 token1PremiumPortion;
         uint32 startTime;
         bool zeroForOne;
         uint256 feeGrowthInside0LastX128;
         uint256 feeGrowthInside1LastX128;
}

Also, I thought bool is 1 bit (enough to encode), why is it 8 bits?

c4-sponsor commented 11 months ago

wukong-particle (sponsor) confirmed

romeroadrian commented 11 months ago
struct Info {
         uint40 tokenId;
         uint128 liquidity;
         uint24 token0PremiumPortion;
         uint24 token1PremiumPortion;
         uint32 startTime;
         bool zeroForOne;
         uint256 feeGrowthInside0LastX128;
         uint256 feeGrowthInside1LastX128;
}

yes, that's correct. Even if a bool takes a single bit, these are always encoded as 1 byte.