Multiple address
/ID mappings can be combined into a single mapping
of an address
/ID to a struct
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.
https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Staking.sol#L19-L24
Gas savings
Manual review
Consider combining multiple mapping
s of the same type into one mapping
to a struct
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.