code-423n4 / 2021-09-defiprotocol-findings

1 stars 0 forks source link

Gas saving: pack struct #237

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

goatbug

Vulnerability details

Impact

2 slots instead of 3

Proof of Concept

struct Bounty {
    address token;
    uint256 amount;
    bool active;
}

having token and active lines consecutive can pack those two values into single 256 bit slot. Result is packing this struct into 2 256 slots as opposed to 3.

Tools Used

Recommended Mitigation Steps

GalloDaSballo commented 2 years ago

Finding is valid, address and bool can pack together