-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 example of execution limits using fuel consumption #2869
Add example of execution limits using fuel consumption #2869
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
Ah it looks like CI is failing when it's running the examples, as it expects that all examples pass successfully. Could the example be updated to not return a failure code? (e.g. catch the error) Also I think our CI verifies that all examples are available in both C and Rust, so I think that at least a stub program will be needed for a C example? |
Ah, that could be it. Thanks for the pointer, adding a C stub now. EDIT: This may take a bit, figuring out how to build and run the C examples on a mac now. |
Added a C example. I'm not particularly confident in the error handling and cleanup code there. I think I handle the error codes from I'm not sure about the semantics of the |
That all looks great to me, thanks! |
…nce#2869) * Add example of execution limits using fuel consumption * run rustfmt * Use a more naive WAT implementation * Catch error and return cleanly * Add a C example to demonstrate fuel consumption * Add error handling for add_fuel
This is a quick example of using the "fuel consumption" logic introduced in #2611.
It computes larger and larger Fibonacci numbers (using the expensive recursive algorithm) until the computation requires more than 10k fuel.