Skip to content

Commit

Permalink
Report for issue #40 updated by SaeedAlipoor01988
Browse files Browse the repository at this point in the history
  • Loading branch information
code423n4 committed Feb 26, 2023
1 parent fc5631e commit f60e2d2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions data/SaeedAlipoor01988-G.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ manually
######### Multiple address/ID mappings can be combined into a single mapping of an address/ID to a struct, where appropriate #########

#### Impact
Saves a storage slot for the mapping. Depending on the circumstances and sizes of types, can avoid a Gsset (20000 gas) per mapping combined. Reads and subsequent writes can also be cheaper when a function requires both values and they both fit in the same storage slot. Finally, if both fields are accessed in the same function, can save ~42 gas per access due to not having to recalculate the key’s keccak256 hash (Gkeccak256 - 30 gas) and that calculation’s associated stack operations.
Saves a storage slot for mapping. Depending on the circumstances and sizes of types, can avoid a Gsset (20000 gas) per mapping combined. Reads and subsequent writes can also be cheaper when a function requires both values and they both fit in the same storage slot. Finally, if both fields are accessed in the same function, can save ~42 gas per access due to not having to recalculate the key’s keccak256 hash (Gkeccak256 - 30 gas) and that calculation’s associated stack operations.

yieldingPercentage and yieldingAmount and yieldGenerator and yieldClaimThreshold are used together in the _rebalance function once and can be placed in a single slot.

another case is in the DefaultPool contract, at lines 30 and 31, if we create a struct and remove these 2 mappings, this can save on gas deployment!

// struct collateral{
// uint collAmount;
// uint LUSDDebt;
// }
// mapping(address => collateral) internal collateralTracker;

yieldingPercentage and yieldingAmount and yieldGenerator and yieldClaimThreshold are used together in the _rebalance function once and can be placed in a single slot:

#### Findings:
https://github.com/code-423n4/2023-02-ethos/blob/73687f32b934c9d697b97745356cdf8a1f264955/Ethos-Core/contracts/ActivePool.sol#L44
Expand Down

0 comments on commit f60e2d2

Please sign in to comment.