Skip to content

perf(contracts): internal compress#558

Open
philsippl wants to merge 2 commits into
mainfrom
ps/reduce-poseidon2-gas
Open

perf(contracts): internal compress#558
philsippl wants to merge 2 commits into
mainfrom
ps/reduce-poseidon2-gas

Conversation

@philsippl
Copy link
Copy Markdown
Collaborator

Makes the function compress internal, which leads to the compiler inlining the function in the caller contract instead of DELEGATECALL'ing it.

Of course only updates (and single insertions) benefit from this, not the (storage dominated) batch insertion hotpath.

Hash Function Before (public) After (internal) Change
Poseidon2T2 7,357 gas 6,360 gas -13.5%

Updates (1000-leaf tree, depth 30)

  public internal savings
fs update leaf 0 427,473 395,557 -31,916 (-7.5%)
fs update leaf 500 427,574 395,658 -31,916 (-7.5%)
fs update leaf 999 423,458 391,542 -31,916 (-7.5%)

insertMany (per-leaf average)

public internal savings
fs insertMany(10) 138,170 134,393
fs insertMany(100) 60,518 59,303
fs insertMany(1000) 53,261 52,274

@philsippl philsippl requested a review from a team as a code owner March 16, 2026 11:21
@philsippl philsippl changed the title internal compress perf(contracts): internal compress Mar 16, 2026
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.

2 participants