Skip to content

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

Merged
linh2931 merged 7 commits intomainfrom
leap_decouple_exec_ctx
Aug 17, 2023
Merged

The companion Leap PR for using a single execution context per wasm interface#1484
linh2931 merged 7 commits intomainfrom
leap_decouple_exec_ctx

Conversation

@linh2931
Copy link
Contributor

@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
Contributor

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
Contributor 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
@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