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

runtime cache size #2527

Closed
bowenwang1996 opened this issue Apr 26, 2020 · 6 comments · Fixed by #2537
Closed

runtime cache size #2527

bowenwang1996 opened this issue Apr 26, 2020 · 6 comments · Fixed by #2537
Assignees
Labels
A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc)

Comments

@bowenwang1996
Copy link
Collaborator

We cache compiled wasm modules in near-vm-runner and cache size is 1024. However, there does not seem to be a size limit of the compiled wasm module, which means that this cache can potentially be very large, if exploited by an adversary. While there is a no_cache flag, it is not turned on by default and also I assume it will compromise performance.

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

Wasm contract size is limited here: https://github.com/nearprotocol/nearcore/blob/05a82d8dd74531b21567623ab0e7e75946afea19/runtime/near-vm-logic/src/config.rs#L68

The size of the compiled contract should be proportional to the Wasm contract, at least on x86 architecture. CC @olonho to correct me if I am wrong.

@bowenwang1996
Copy link
Collaborator Author

So potentially this cache can be 4GB large? That seems a bit too much.

@MaksymZavershynskyi
Copy link
Contributor

What is our target hardware?

@bowenwang1996
Copy link
Collaborator Author

I think the minimum requirement is 4GB of memory https://docs.nearprotocol.com/docs/roles/validator/hardware

@bowenwang1996 bowenwang1996 reopened this Apr 27, 2020
@olonho
Copy link
Contributor

olonho commented Apr 27, 2020

Indeed if we'll get rather large contract, it may exhaust our resources, and it's indeed unlikely that non-optimizing compilers may produce binaries disproportionally non-linear from input+dependencies size.

@MaksymZavershynskyi
Copy link
Contributor

Okay, let's cut it down to 128 size and deal with it later, if it turns out too small. In the future, we can back the cache with the disk rather than memory only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-transaction-runtime Area: transaction runtime (transaction and receipts processing, state transition, etc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants