Skip to content

fix(lean-imt-plus): make the package deployable on ethereum mainnet - #65

Merged
vplasencia merged 1 commit into
mainfrom
fix/lean-imt-plus-mainnet-deployability
Sep 13, 2026
Merged

vplasencia merged 1 commit into
mainfrom
fix/lean-imt-plus-mainnet-deployability

Conversation

@vplasencia

Copy link
Copy Markdown
Member

Description

Bug fix. lean-imt-plus currently can't be deployed to Ethereum mainnet.

The package compiles with viaIR: true, which also applies to the poseidon-solidity dependency. Poseidon is hand-written assembly, and the IR pipeline inflates it past the EIP-170 24576-byte limit — PoseidonT3 to 30718 B and PoseidonT4 to 34145 B. Because the hardhat network sets allowUnlimitedContractSize: true, the suite passes and the problem doesn't surface locally or in CI.

viaIR was enabled for a good reason: the nested loop in _recompute hits Stack too deep on the legacy pipeline. This PR moves the innermost node rewrite into a small _recomputeNode helper, giving it its own stack frame and removing that constraint. The package now builds on a single uniform compiler config — no viaIR, no per-file overrides.

Two smaller changes come with it:

  • runs is raised to 1000000. These libraries deploy once and are called on every tree operation, so optimizing for call gas rather than size fits them better. It also reproduces the canonical bytecode poseidon-solidity ships, so the existing deterministic deployments can be reused.
  • allowUnlimitedContractSize is removed, so the suite enforces EIP-170 from now on.

Results

contract before after / 24576
PoseidonT3 30718 ❌ 23587 ✅ 96%
PoseidonT4 34145 ❌ 14295 ✅ 58%
LeanIMTPlus 5846 7956 ✅ 32%

The corrected Poseidon build also cuts gas: insert −37%, insertMany −36%, remove −51%, update −51%.

Checklist

  • I have read and understand the contributor guidelines and code of conduct.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run yarn style without getting any errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Important

We do not accept pull requests for minor grammatical fixes (e.g., correcting typos, rewording sentences) or for fixing broken links, unless they significantly improve clarity or functionality. These contributions, while appreciated, are not a priority for merging. If you notice any of these issues, please create a GitHub Issue to report them so they can be properly tracked and addressed.

@vplasencia
vplasencia merged commit 6a12c07 into main Sep 13, 2026
14 checks passed
@vplasencia
vplasencia deleted the fix/lean-imt-plus-mainnet-deployability branch September 13, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant