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

Expose libwasmvm version number at runtime #314

Merged
merged 4 commits into from
May 3, 2022
Merged

Conversation

webmaster128
Copy link
Member

Sometimes it's tricky for validators to get the correct .so file used with their binary. This happens when the binary is built on one system and is then deployed to multiple nodes. Go installs the .so to a very custom path in the Go installation system.

Now what we want to do is provide information of the Rust side (libwasmvm) at runtime. This way you can veryify that your wasmvm 1.2.3 dependency loaded the 1.2.3 shared library and not something old that was installed from last time such as 1.2.1.

Ideally we find a way to get this listed in the chain's long version output, e.g. in here

$ junod version --long
name: juno
server_name: junod
version: v3.1.0
commit: dd595e9ec533eabed8a7b588c64e2cc638fbf24e
build_tags: netgo,ledger
go: go version go1.17 linux/amd64
build_deps:
- filippo.io/[email protected]
- github.com/99designs/[email protected]
- github.com/ChainSafe/[email protected]
[...]
- gopkg.in/[email protected]
- nhooyr.io/[email protected]
cosmos_sdk_version: v0.45.1

With this PR the release process needs a bit more steps since the libwasmvm project version needs to be updated before the release tag is set.

Copy link
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

LGTM.

func TestLibwasmvmVersion(t *testing.T) {
version, err := LibwasmvmVersion()
require.NoError(t, err)
require.Equal(t, "1.0.0", version)
Copy link
Contributor

@maurolacy maurolacy May 3, 2022

Choose a reason for hiding this comment

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

Will this have to be updated with every version change? Better to use a VERSION tag or ref from somewhere. Perhaps some dirty code to parse the Cargo.toml from Go? That, or do some structural checks here only.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, this is a leftover from development state. Ideally we use a simple regex here to ensure we get something sane.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in 7235e1b

use std::ffi::CStr;

#[test]
fn version_works() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests.

Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

Nice one to help debug infrastructure

///
/// The string is owned by libwasmvm and must not be mutated or destroyed by the caller.
#[no_mangle]
pub extern "C" fn version_str() -> *const c_char {
Copy link
Member

Choose a reason for hiding this comment

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

Very nice

@webmaster128
Copy link
Member Author

Thank you for the reviews!

@webmaster128 webmaster128 merged commit e5b09fc into main May 3, 2022
@webmaster128 webmaster128 deleted the expose_version_number branch May 3, 2022 19:21
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.

3 participants