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

Allow better override of wasmVM in x/wasm keeper #1494

Merged
merged 3 commits into from
Jul 18, 2023
Merged

Conversation

ethanfrey
Copy link
Member

The current code always creates one VM and then possibly overrides it with the options. However, creating the wasmVm will also create directories and initialize Rust structs that are not cleanly deleted. It would be better to never create it in the first place if it is overridden later.

This PR pushes the initialization towards the end of NewKeeper for this. A concrete use-case is in creating a wasmvm.VM externally and passing it in for more control, which will likely be necessary with ibc wasm light client.

@ethanfrey ethanfrey requested a review from alpe as a code owner July 10, 2023 09:25
@@ -63,6 +59,16 @@ func NewKeeper(
for _, o := range opts {
o.apply(keeper)
}
// only set the wasmvm if no one set this in the options
// NewVM does a lot, so better not to create it and silently drop it.
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for bringing this up! Unfortunately, the implementation conflicts with the WithWasmEngineDecorator now that requires the object to exist.
I will come up with some solution

@faddat
Copy link
Contributor

faddat commented Jul 17, 2023

Hey guys, I want to mention -- I susepct that some of this is actually addressed by moving to wazero, but I don't really have a decent starting place.

The thinking is like this:

  • cgo bad
  • type conversions error prone

therefore move to a pure go way of running the wasm.

@alpe
Copy link
Member

alpe commented Jul 17, 2023

@faddat thanks for the head up! The use case Ethan wants to solve is:

creating a wasmvm.VM externally and passing it in ... which will likely be necessary with ibc wasm light client.

@codecov
Copy link

codecov bot commented Jul 18, 2023

Codecov Report

Merging #1494 (f0a1032) into main (52a7a6a) will increase coverage by 0.05%.
The diff coverage is 91.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1494      +/-   ##
==========================================
+ Coverage   58.17%   58.23%   +0.05%     
==========================================
  Files          64       64              
  Lines        8460     8475      +15     
==========================================
+ Hits         4922     4935      +13     
- Misses       3130     3131       +1     
- Partials      408      409       +1     
Impacted Files Coverage Δ
x/wasm/keeper/keeper_cgo.go 93.75% <80.00%> (+1.15%) ⬆️
x/wasm/keeper/options.go 78.18% <100.00%> (+2.18%) ⬆️

... and 1 file with indirect coverage changes

@alpe alpe merged commit 07700a1 into main Jul 18, 2023
16 checks passed
@alpe alpe deleted the better-wasmvm-override branch July 18, 2023 15:42
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.

None yet

3 participants