Aura Finance contest - minhquanym's results

Providing optimal incentives for VotingEscrow systems.

General Information

Platform: Code4rena

Start Date: 11/05/2022

Pot Size: $150,000 USDC

Total HM: 23

Participants: 93

Period: 14 days

Judge: LSDan

Total Solo HM: 18

Id: 123

League: ETH

Aura Finance

Findings Distribution

Researcher Performance

Rank: 90/93

Findings: 1

Award: $83.25

🌟 Selected for report: 0

🚀 Solo Findings: 0

1. Save gas by keeping track of nextEpochDate instead of reading from storage.

Details

In AuraLocker._checkpointEpoch(), there is a while loop to fill epoch gaps until the next epoch date. Each iter, it reads from storage 4 times (2 in the while condition, 2 when calculate nextEpochDate). In fact, nextEpochDate can be kept track simply by adding rewardsDuration each epoch.

Proof of concept

https://github.com/code-423n4/2022-05-aura/blob/4989a2077546a5394e3650bf3c224669a0f7e690/contracts/AuraLocker.sol#L334-L335

Use variable nextEpochDate to cache like this

uint256 nextEpochDate = uint256(epochs[epochs.length - 1].date); while (nextEpockDate != currentEpoch) { uint256 nextEpochDate = nextEpockDate.add(rewardsDuration); epochs.push(Epoch({ supply: 0, date: uint32(nextEpochDate) })); }
AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter