snapshot-labs / sx-evm

Core smart contracts of Snapshot X for EVM
https://docs.snapshotx.xyz
22 stars 12 forks source link

audit: Optimize ActiveProposalLimiter storage reads #226

Closed Orland0x closed 1 year ago

Orland0x commented 1 year ago

closes #220

cache the struct in memory, perform the checks and updates in memory, then finally write the memory struct back to storage.

codecov[bot] commented 1 year ago

Codecov Report

Merging #226 (3742de0) into main (3bc77f3) will increase coverage by 0.04%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
+ Coverage   80.64%   80.68%   +0.04%     
==========================================
  Files          28       28              
  Lines         465      466       +1     
  Branches      111      111              
==========================================
+ Hits          375      376       +1     
  Misses         74       74              
  Partials       16       16              
Impacted Files Coverage Δ
src/utils/ActiveProposalsLimiter.sol 91.66% <100.00%> (+0.75%) :arrow_up: