sherlock-audit / 2023-12-ubiquity-judging

2 stars 2 forks source link

r0ck3tz - Missing alignment of storage to 256 may result in excessive gas consumption #121

Closed sherlock-admin closed 9 months ago

sherlock-admin commented 9 months ago

r0ck3tz

medium

Missing alignment of storage to 256 may result in excessive gas consumption

Summary

The protocol uses namespaced storage layout ERC-7201 across all contracts but incorrectly defines the storage location.

Vulnerability Detail

The storage location should be aligned to 256 which is an optimization in anticipation of gas schedule changes after the Verkle state tree migration, which may cause groups of 256 storage slots to become warm all at once.

Impact

Not aligning storage to 256 will result in significantly higher gas consumption.

Code Snippet

Tool used

Manual Review

Recommendation

It is recommended to align the storage location to 256 by setting the last byte of the hash to 0:

& ~bytes32(uint256(0xff))
sherlock-admin2 commented 9 months ago

1 comment(s) were left on this issue during the judging contest.

auditsea commented:

Gas

sherlock-admin2 commented 9 months ago

1 comment(s) were left on this issue during the judging contest.

auditsea commented:

Gas

nevillehuang commented 9 months ago

Invalid, gas optimization findings are not valid based on sherlock rules

  1. Gas optimizations: The user/protocol ends up paying a little extra gas because of this issue.