Skip to content

feat: add anonymity set size benchmark#154

Open
0xmad wants to merge 1 commit intomainfrom
feature/anonymity-set-size
Open

feat: add anonymity set size benchmark#154
0xmad wants to merge 1 commit intomainfrom
feature/anonymity-set-size

Conversation

@0xmad
Copy link
Copy Markdown
Contributor

@0xmad 0xmad commented Apr 9, 2026

Add anonymity set size benchmark for all the gas benchmarked projects

@0xmad 0xmad self-assigned this Apr 9, 2026
@0xmad 0xmad added the enhancement New feature or request label Apr 9, 2026
@0xmad 0xmad marked this pull request as ready for review April 9, 2026 16:41
@JohnGuilding
Copy link
Copy Markdown
Contributor

@0xmad why are we doing shieldEthReceipts.length - unshieldEthReceipts.length for anonymity set size?

@0xmad
Copy link
Copy Markdown
Contributor Author

0xmad commented Apr 9, 2026

Because we want to distinguish how many private deposits left in the pool. Withdrawals can be calculated as well because they are not part of the pool anymore.

return {
shieldEth: getAverageMetrics(shieldEthReceipts),
unshieldEth: getAverageMetrics(unshieldEthReceipts),
anonymitySetSize: shieldEthReceipts.length - unshieldEthReceipts.length,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

John:

@0xmad why are we doing shieldEthReceipts.length - unshieldEthReceipts.length for anonymity set size?

Anton:

Because we want to distinguish how many private deposits left in the pool. Withdrawals can be calculated as well because they are not part of the pool anymore.

So we actually want to get to total size of the anonymity set, not the size within a specific window. If we sample 5 weeks of blocks, we will get the net change within that window, but not the cumulative anonymity set size

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With current design, it’s not possible to fetch all the events and calculate total size of deposits.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes definitely. So I think we could also try measure anonymity set over a time window, but our operation (shield, transfer, unshield) capturing logic only measures simple transfers for many protocols. So the "unspent" anonymity set window would not account for all relevant state updates. E.g we are measuring transfers with 1 input and 1 output, but not transfers with 1 input and 2 outputs.

This is either too complex to not be worthwhile, or requires something quite involved. I'm going to leave some notes in this issue

@JohnGuilding JohnGuilding linked an issue Apr 14, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add anonymity set size benchmark

2 participants