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

Optimize gas estimation running time #124

Merged
merged 2 commits into from
Jun 26, 2023

Commits on Jun 26, 2023

  1. Optimize gas estimation running time

    Optimize gas estimation running time with two approaches:
    1. Don't call any storage methods on SSTORE during gas estimation.
    Instead, return early if we are in gas estimation (Commit = false). For
    that to work, make sure that on SLOAD, we first lookup the ciphertext
    hash in memory and, if found, use it without going to storage. That
    improves performance by not doing heavy work of splitting a ciphertext
    to 32 byte slots and persisting it to a memory-backed store for no
    reason.
    2. When importing a random ciphertext during gas estimation, do not use
    public key encryption. Instead, just genearate an unique hash for the
    random ciphertext by utilizing a counter that is part of the EVM itself.
    That improves performance by not doing public key encryption and
    serialization just to compute a ciphertext hash (handle).
    dartdart26 committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    8d44bc7 View commit details
    Browse the repository at this point in the history
  2. Use hash(counter) instead of just counter as handle

    Rationale is that SSTORE charges less for zeroes. Using hash(counter),
    we make gas estimation close to random ciphertext bytes.
    dartdart26 committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    ac05771 View commit details
    Browse the repository at this point in the history