ENS - K42's results

Decentralized naming for wallets, websites, & more.

General Information

Platform: Code4rena

Start Date: 05/10/2023

Pot Size: $33,050 USDC

Total HM: 1

Participants: 54

Period: 6 days

Judge: hansfriese

Id: 294

League: ETH

ENS

Findings Distribution

Researcher Performance

Rank: 39/54

Findings: 1

Award: $8.19

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: windhustler

Also found by: 0xhex, 0xta, JCK, K42, MatricksDeCoder, MrPotatoMagic, SAQ, SY_S, SovaSlava, aslanbek, d3e4, danb, hunter_w3b, lukejohn

Labels

bug
G (Gas Optimization)
grade-b
sufficient quality report
G-13

Awards

8.1878 USDC - $8.19

External Links

Gas(Mana) Optimization Report for ENS by K42

Possible Gas(Mana) Optimizations in ERC20MultiDelegate.sol

Possible Optimization 1 = Use a Mapping specifically for Proxy Addresses:

  • Instead of calculating the proxy address every time, store it in a mapping after the first calculation.

After Optimization:

mapping(address => address) public proxyAddresses;

// Then update:
function deployProxyDelegatorIfNeeded(address delegate) internal returns (address) {
    if (proxyAddresses[delegate] == address(0)) {
        // ... (existing code)
        proxyAddresses[delegate] = proxyAddress;
    }
    return proxyAddresses[delegate];
}
  • Estimated gas saved: Approximately 5,000 - 8,000 gas per retrieval. Safe as long as the mapping is updated correctly. Reduces the need for EXTCODESIZE and KECCAK256.

Possible Optimization 2 = Better optimize loop in _delegateMulti():

  • Use a single loop for all operations instead of separate loops for burning and minting.

After Optimization:

for (uint i = 0; i < maxLen; i++) {
    // ... (existing code)
    if (i < sourcesLength) {
        _burn(msg.sender, sources[i], amounts[i]);
    }
    if (i < targetsLength) {
        _mint(msg.sender, targets[i], amounts[i], "");
    }
}
  • Estimated gas saved = Approximately 1,000 - 2,000 gas per loop iteration. Completely safe as long as loop conditions are met.

#0 - c4-pre-sort

2023-10-13T13:42:41Z

141345 marked the issue as sufficient quality report

#1 - c4-judge

2023-10-24T17:03:31Z

hansfriese marked the issue as grade-b

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