Description: In SoulboundProfileNFT.sol
, the tokenURI
function performs multiple separate storage reads from the same struct, which is inefficient. Instead of loading the entire struct into memory once, it loads each field separately.
Impact:
Each storage read (SLOAD) costs ~100 gas
Current implementation uses 3 separate SLOADs (~300 gas)
This happens every time tokenURI is called
Proof of Concept:
Current implementation with multiple storage reads:
Recommended Mitigation: Cache the struct in memory with a single SLOAD:
This optimization:
Reduces storage reads from 3 to 1
Memory reads (MLOAD) are much cheaper (3 gas) than storage reads (SLOAD)
Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.
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.