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

Worst case CPU soak test #3119

Open
MaksymZavershynskyi opened this issue Aug 8, 2020 · 6 comments
Open

Worst case CPU soak test #3119

MaksymZavershynskyi opened this issue Aug 8, 2020 · 6 comments
Assignees
Labels
A-contract-runtime Area: contract compilation and execution, virtual machines, etc T-contract-runtime Team: issues relevant to the contract runtime team

Comments

@MaksymZavershynskyi
Copy link
Contributor

MaksymZavershynskyi commented Aug 8, 2020

Motivation

We are currently using a cryptographic primitive computation to estimate the relationship between the number of CPU instructions and the time which leads to relationship between the number of CPU instructions and gas. This might lead us to underestimating the cost of runtime operations, including Wasm operations, which might open the potential abuse vector. However, we need to make sure it accounts for the worst possible case – it should mostly miss CPU cache and it should mostly use the most expensive CPU instructions.

Goal

We need to write code in Rust and execute it as native. This code should exercise the worst case scenario for CPU and try to maximize <time passed>/<number of CPU instructions> ratio. It should run long enough to minimize the volatility of the computed ratio. It cannot use thread-specific primitives like atomics or OS-level primitives like threads, it is very desirable if it uses only CPU instructions that are used by popular Wasm backends during Wasm execution. In examples of what it can try to do: it can try to miss the CPU cache as much as possible, it can try to utilize only the most expensive CPU instruction.

@MaksymZavershynskyi MaksymZavershynskyi added the A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc) label Aug 8, 2020
@bowenwang1996
Copy link
Collaborator

What kind of CPU are we doing the benchmark on?

@bowenwang1996 bowenwang1996 added A-contract-runtime Area: contract compilation and execution, virtual machines, etc T-contract-runtime Team: issues relevant to the contract runtime team and removed A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc) labels Jun 29, 2021
@bowenwang1996
Copy link
Collaborator

@olonho I believe you developed something similar. Is this issue already addressed?

@stale
Copy link

stale bot commented Sep 27, 2021

This issue has been automatically marked as stale because it has not had recent activity in the last 2 months.
It will be closed in 7 days if no further activity occurs.
Thank you for your contributions.

@stale stale bot added the S-stale label Sep 27, 2021
@bowenwang1996
Copy link
Collaborator

@olonho @matklad

@stale stale bot removed the S-stale label Sep 27, 2021
@matklad
Copy link
Contributor

matklad commented Sep 29, 2021

Yeah, we still need to get more principle and reproducible mappin from CPU instructions to gas cost. Though, I don't think we need to target the worst-case instructions necessary -- attackers can't force specific CPU instructions, they can force specific wasm code or host funtion calls. It might be the case that some host function today uses more wall-clock time than number of cpu instructions, but this can be for the variaty of reasons (like doing IO).

Doesn't feel like a high priority issue to address to me, as it is dominated by issues with todays gas counter () and the IO costs (we still haven't switched to costs which account for IO).

@stale
Copy link

stale bot commented Dec 28, 2021

This issue has been automatically marked as stale because it has not had recent activity in the last 2 months.
It will be closed in 7 days if no further activity occurs.
Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contract-runtime Area: contract compilation and execution, virtual machines, etc T-contract-runtime Team: issues relevant to the contract runtime team
Projects
None yet
Development

No branches or pull requests

6 participants