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

The companion Leap PR for using a single execution context per wasm interface #1484

Merged
merged 7 commits into from
Aug 17, 2023

Conversation

linh2931
Copy link
Member

@linh2931 linh2931 commented Aug 8, 2023

The companion PR of EOS VM AntelopeIO/eos-vm#19 for using a single execution context per wasm interface.

Resolves #1456.

_runtime->_exec_ctx.set_module(&(_instantiated_module->get_module()));
_instantiated_module->set_context(&_runtime->_exec_ctx);
_instantiated_module->reset_max_call_depth();
_instantiated_module->reset_max_pages();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was originally worried about the case where the apply options change between apply() calls right here.

For example reset_max_call_depth() sets the context's max call depth to initial_max_call_depth which was computed based on the options passed when the backend is created,
https://github.com/AntelopeIO/eos-vm/blob/8e1d571db99ff1eecd119c299b42886f72ef40b4/include/eosio/vm/backend.hpp#L177-L180
But the max call depth that should be configured at this point in time is what the current options protocol limits are.

But a few lines down from here,

if(context.control.is_builtin_activated(builtin_protocol_feature_t::configurable_wasm_limits)) {
const wasm_config& config = context.control.get_global_properties().wasm_configuration;
opts = {config.max_pages, config.max_call_depth};
}
auto fn = [&]() {
eosio::chain::webassembly::interface iface(context);
_runtime->_bkend->initialize(&iface, opts);

The important part is the initialize() call that,
https://github.com/AntelopeIO/eos-vm/blob/8e1d571db99ff1eecd119c299b42886f72ef40b4/include/eosio/vm/backend.hpp#L198-L203
seems to set up the context correctly for each apply once WASM_LIMITS2 is activated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your careful analysis.

@linh2931 linh2931 merged commit a78b8a9 into main Aug 17, 2023
22 checks passed
@linh2931 linh2931 deleted the leap_decouple_exec_ctx branch August 17, 2023 01:24
@linh2931 linh2931 restored the leap_decouple_exec_ctx branch September 11, 2023 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not create/use/cache execution context per contract
3 participants