Skip to content

Use uint256 iterators in MerkleTree loops #5414

@heueristik

Description

@heueristik

🧐 Motivation

The current MerkleTree.sol contract contains two for loops, both of which use uint32 as an iterator when iterating from 0 to uint8 treeDepth. This is not optimal and uint256 should be used to minimize conversions.

📝 Details

Use uint256 for the iterators in MerkleTree.sol

for (uint32 i = 0; i < treeDepth; ++i) {

for (uint32 i = 0; i < treeDepth; i++) {

to save gas.

While on it, you can also change the for loops in the Heap.t.sol test.

for (uint32 i = 1; i < heap.length(); ++i) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions