OpenZeppelin / OpenZeppelin/openzeppelin-contracts

Add `Uint128Heap`, `Uint64Heap` & `Uint32Heap`

Open
#6,767 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

idea
Dominant language
Solidity
Stars
27.2k
Forks
12.4k
Avg merge
2d 19h
Merged PRs (30d)
33

Description

Add Uint128Heap, Uint64Heap and Uint32Heap next to existing Uint256Heap to benefit from packing.

[...]
    struct Uint128Heap {
        uint128[] tree;
    }
[...]
    struct Uint64Heap {
        uint64[] tree;
    }
[...]
    struct Uint32Heap {
        uint32[] tree;
    }

Most of the logic for all variants can be shared into a Heap.sol.eta.

Numbers from Claude:

Warm (build+drain, one tx), total gas vs `Uint256Heap`: **128 −31%, 64 −51%, 32 −61%**.

Cold per-op (`vm.cool` before each), insert / pop:

| width | insert | pop |
|------:|-------:|----:|
| 256 | 43,604 | 35,940 |
| 128 | 22,003 | 32,366 |
| 64  | 19,714 | 27,246 |
| 32  | 16,969 | 22,666 |

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing Uint256Heap implementation and the proposed Heap.sol.eta abstraction. Add Uint128Heap, Uint64Heap, and Uint32Heap alongside it, sharing the common heap logic, then verify that each variant supports the same operations and delivers the intended packed-storage behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
solidity
Domain
blockchain
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.