Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vm): Allow caching signature verification #3505

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

slowli
Copy link
Contributor

@slowli slowli commented Jan 20, 2025

What ❔

Allows caching signature verification (more precisely, ecrecover output for L2 transactions using the default AA) in the fast VM.

Why ❔

Signature verification takes ~50% of the execution time for "simple" transactions (e.g., base token and ERC-20 token transfers), so caching it may improve performance.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zkstack dev fmt and zkstack dev lint.

@slowli slowli force-pushed the aov-pla-1082-allow-caching-signature-verification branch from baa4632 to dc959de Compare January 21, 2025 15:17
Copy link
Contributor Author

@slowli slowli left a comment

Choose a reason for hiding this comment

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

The PR doesn't include the ability to disable signature verification in the state keeper (and maybe other places, e.g., in subsequent gas estimation / tx submission VM runs). I'd prefer for it to be implemented in a separate PR.

Locally (on an M2 Max Macbook), disabling signature verification improves performance ~2x on simple transactions, like base / ERC-20 token transfers:

fill_bootloader/transfer/1000
    time:   [274.78 ms 277.20 ms 281.97 ms]
    thrpt:  [3.5465 Kelem/s 3.6075 Kelem/s 3.6393 Kelem/s]
fill_bootloader/no_sigs/transfer/1000
    time:   [138.68 ms 139.63 ms 140.68 ms]
    thrpt:  [7.1085 Kelem/s 7.1615 Kelem/s 7.2109 Kelem/s]

Curiously, this doesn't translate to the instruction-counting bench; there, disabling signature verification only leads to ~10% instruction count / estimated cycle count improvement.

A potential alternative would be to switch the default AA for "signature-less" execution with one that skips signature verification. The downside is having to keep multiple default AA implementation, and it could have unobvious pitfalls (e.g., IIUC, the default AA bytecode hash must be the same regardless of the implementation, so for the signature-less one, it won't correspond to the actual bytecode).

core/lib/multivm/src/versions/vm_fast/vm.rs Outdated Show resolved Hide resolved
@slowli slowli marked this pull request as ready for review January 22, 2025 08:42
joonazan
joonazan previously approved these changes Jan 22, 2025
perekopskiy
perekopskiy previously approved these changes Jan 28, 2025
@slowli slowli dismissed stale reviews from perekopskiy and joonazan via abfedd6 January 30, 2025 11:05
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.

3 participants