Arbitrum Security Council Election System - caventa's results

A suite of scaling solutions providing environments with high-throughput, low-cost smart contracts, backed by industry-leading proving technology rooted in Ethereum.

General Information

Platform: Code4rena

Start Date: 03/08/2023

Pot Size: $90,500 USDC

Total HM: 6

Participants: 36

Period: 7 days

Judge: 0xean

Total Solo HM: 1

Id: 273

League: ETH

Arbitrum Foundation

Findings Distribution

Researcher Performance

Rank: 26/36

Findings: 1

Award: $38.45

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: LeoS

Also found by: 0xAnah, JCK, K42, SAAJ, Sathish9098, Udsen, caventa, dharma09, ernestognw, naman1778, petrichor, rektthecode

Labels

bug
G (Gas Optimization)
grade-b
G-10

Awards

38.4497 USDC - $38.45

External Links

See SecurityCouncilMgmtUpgradeLib#areAddressArraysEqual

function areAddressArraysEqual(address[] memory array1, address[] memory array2)
    public
    pure
    returns (bool)
    {
        if (array1.length != array2.length) {
            return false;
        }

        for (uint256 i = 0; i < array1.length; i++) {
            bool found = false;
            for (uint256 j = 0; j < array2.length; j++) {
                if (array1[i] == array2[j]) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                return false;
            }
        }

        for (uint256 i = 0; i < array2.length; i++) {
            bool found = false;
            for (uint256 j = 0; j < array1.length; j++) {
                if (array2[i] == array1[j]) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                return false;
            }
        }

        return true;
    }

can be changed to

  function areAddressArraysEqual(address[] memory array1, address[] memory array2)
    public
    pure
    returns (bool)
    {
        return keccak256(abi.encodePacked(array1)) == keccak256(abi.encodePacked(array2));
    }

Wrote 4 foundry test

  1. Using the old function, array1 and array2 have 5 same elements (Gas spent = 11524)
  2. Using the new function, array1 and array2 have 5 same elements (Gas spent = 4012)
  3. Using the old function, array1 and array2 have 5 different elements (Gas spent = 4034)
  4. Using the new function, array1 and array2 have 5 different elements (Gas spent = 4012)

#0 - c4-judge

2023-08-18T14:39:48Z

0xean 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