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

Don't run checkLibwasmVersion automatically on start #1338

Merged
merged 7 commits into from
Apr 20, 2023

Conversation

webmaster128
Copy link
Member

@webmaster128 webmaster128 commented Apr 14, 2023

While this check makes sense in the happy path, there are many occasions when the version of the Go project wasmvm and the library diverge. This can be any patch to either of them. Especially Go's dummy versioning makes it easy for the versions to be different.

Now when a chain integrates wasmd like here it suddenly becomes very difficult to skip this check. At least I don't see a way to do it without forking wasmd.

The idea of this PR is to keep CheckLibwasmVersion available but don't force-run it. This way callers can use the function but easily disable it then they need to.

Ping @jhernandezb who kindof invented this check.

@webmaster128 webmaster128 changed the base branch from main to releases/v0.31.x April 14, 2023 20:22
@webmaster128 webmaster128 changed the title [don't merge] Don't run checkLibwasmVersion automatically on start (0.31.0) Don't run checkLibwasmVersion automatically on start (0.31) Apr 14, 2023
@jhernandezb
Copy link
Contributor

This makes sense to me, letting apps having more control on how to perform the check is better IMO.

@webmaster128 webmaster128 changed the base branch from releases/v0.31.x to releases/v0.3x April 17, 2023 20:37
@webmaster128 webmaster128 changed the title Don't run checkLibwasmVersion automatically on start (0.31) Don't run checkLibwasmVersion automatically on start Apr 17, 2023
@alpe alpe added backport/v0.3x Backport patches to sdk45 release branch backport/main Backport patches to main branch and removed backport/v0.3x Backport patches to sdk45 release branch labels Apr 19, 2023
x/wasm/module.go Outdated Show resolved Hide resolved
@webmaster128 webmaster128 added this to the v0.32.0 milestone Apr 19, 2023
@alpe alpe requested a review from pinosu April 20, 2023 07:50
@alpe alpe marked this pull request as ready for review April 20, 2023 07:50
@alpe
Copy link
Member

alpe commented Apr 20, 2023

This is hard to test via unit test. wasmd start -h should show the new flag.

Copy link
Contributor

@pinosu pinosu left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member Author

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

This is hard to test via unit test.

You can test it manually by using wasmvm main. This now has the 1.2.3 libwasmvm build and but some intermediate wasmvm version.

x/wasm/module.go Outdated
// An alternative method to obtain the libwasmvm version loaded at runtime is executing
// `wasmd query wasm libwasmvm-version`.
func CheckLibwasmVersion(cmd *cobra.Command, args []string) error {
skip, err := cmd.Flags().GetBool(flagWasmSkipWasmVMVersionCheck)
Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't it be nicer to move this switch to the caller code? Then CheckLibwasmVersion always performs a check (when called)

Copy link
Member

Choose a reason for hiding this comment

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

TBH, I went for the quickest solution. But with the method public, you have a point. The skip condition should be outside and the expected version passed.

x/wasm/module.go Outdated
//
// An alternative method to obtain the libwasmvm version loaded at runtime is executing
// `wasmd query wasm libwasmvm-version`.
func CheckLibwasmVersion(cmd *cobra.Command, args []string) error {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we change this back to private or leave it available to folks building their own AddModuleInitFlags?

Copy link
Member Author

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Beautiful

@alpe
Copy link
Member

alpe commented Apr 20, 2023

I had tested the fix manually with wasmvm main and got Error: libwasmversion mismatch. got: 1.2.3; expected: v1.2.4-0.20230420114732-347b6bb6a155. The flag allowed me to bypass this as expected.

@alpe alpe merged commit 0929168 into releases/v0.3x Apr 20, 2023
mergify bot pushed a commit that referenced this pull request Apr 20, 2023
* Don't run checkLibwasmVersion automatically on start

* Remove unused preRunFn, chainPreRuns

* Add documentation to CheckLibwasmVersion

* Add skip wasmvm version flag

* Linter false positive

* Review feedback

* Pass expected version

---------

Co-authored-by: Alex Peters <alpe@users.noreply.github.com>
(cherry picked from commit 0929168)

# Conflicts:
#	x/wasm/module.go
@webmaster128 webmaster128 deleted the 0.31.0-unchecked branch April 20, 2023 15:03
@webmaster128
Copy link
Member Author

Thank you for finishing this!

alpe added a commit that referenced this pull request Apr 21, 2023
Don't run checkLibwasmVersion automatically on start (backport #1338)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/main Backport patches to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants