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

Add rough gas pricing for crypto APIs #758

Closed
ethanfrey opened this issue Jan 27, 2021 · 1 comment · Fixed by #804
Closed

Add rough gas pricing for crypto APIs #758

ethanfrey opened this issue Jan 27, 2021 · 1 comment · Fixed by #804

Comments

@ethanfrey
Copy link
Member

Part of #751
Builds on #757

All these exposed entry points need to charge gas. We start with some rough values that can be addressed later.

Cosmos SDK charges 1000 sdk gas for one secp256k1 signature verification. We currently use a factor of 100 to convert sdk gas to wasm gas.

Thus, we should start with a pricing of 100_000 gas for a secp256k1 verification (for any of the 3 formats). We can do some rough benchmarking of ed25519 vs secp256k1 on a linux i686 machine and then use the relative cost to pick gas costs for that verification (eg. if it is 30% slower, it should be 130_000 gas).

We should revisit this pricing later using more detailed benchmarking, once we close the final point of #670 (which would provide a consistent mapping from wasm gas -> cpu time on a given machine). Currently two contracts with the same gas may have a disparity in cpu time based on which instructions they use (some are more expensive to execute, but they are all charged the same gas)

@webmaster128
Copy link
Member

webmaster128 commented Feb 16, 2021

In order to get there, we should have benchmarks in place for

  • secp256k1_verify
  • secp256k1_recover_pubkey
  • ed25519_verify
  • ed25519_batch_verify (this one is hard because the input determines the runtime a lot)

Then we can calculate the gas cost relative to secp256k1_verify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants