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

Gas Calculation per function #116

Open
AchalaSB opened this issue Feb 11, 2020 · 5 comments
Open

Gas Calculation per function #116

AchalaSB opened this issue Feb 11, 2020 · 5 comments
Assignees
Labels
🎉 enhancement New feature or request

Comments

@AchalaSB
Copy link

Can we calculate Cost for each function using go-wasmer?( something like ethereum is doing)
Ex: if we are executing simple rust code to add two numbers, need to know the cost for + operator.

I see there are implementation in wasmer/pull/450
But didn't get how exactly cost is calculating. where is cost table here?
Is there any doc to understand this?

Thanks

@AchalaSB AchalaSB added the ❓ question Further information is requested label Feb 11, 2020
@AdamSLevy
Copy link
Contributor

The docs on metering are very sparse. The implementation in Rust is here: https://github.com/wasmerio/wasmer/blob/master/lib/middleware-common/src/metering.rs

That is some middleware that injects metering code at module compilation. This functionality is not exposed in either the Go or C APIs in the main release of wasmer and this library, unfortunately. It's not impossible to get it working though. A number of branches that are a little stale now, but work, are out there that implement the necessary APIs in the Rust -> C bridge and C -> Go bridge.

Another thing to be aware of is that the metering as currently implemented is buggy and can miss some functions that exceed the set limit. See wasmerio/wasmer#999

@Hywan
Copy link
Contributor

Hywan commented Feb 13, 2020

We can make it a higher priority. As @AdamSLevy said, we must first support middleware in the C API, then in Go.

@Hywan Hywan added 🎉 enhancement New feature or request and removed ❓ question Further information is requested labels Feb 13, 2020
@Hywan Hywan self-assigned this Feb 13, 2020
@Rathil
Copy link

Rathil commented Sep 29, 2021

@Hywan Tell me, is there a plan to add this functionality?

@hnfgns
Copy link

hnfgns commented Jul 30, 2022

@Hywan adding this to C runtime is a great idea. one can look at this issue as an important enhancement to the security model currently offered. hosts can prevent some attack vectors through this feature imo.

@alanorwick
Copy link

Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎉 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants