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

Enable wasm mint bindings #1445

Merged
merged 14 commits into from
May 16, 2022
Merged

Conversation

maurolacy
Copy link
Contributor

Closes / Related to: #1029

What is the purpose of the change

Re-instate the CoswmWasm message handlers for Mint and FullDenom. Related to osmosis-labs/bindings#25 on the Rust side.

Brief change log

  • Uncomment the Mint-related code.
  • Implemented Mint using TokenFactory.
  • Implemented FullDenom in terms of TokenFactory.

Testing and Verifying

Uncommented and adapted already existing tests.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes. For the CosmWasm side)
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (will do)
  • How is the feature or change documented? (not documented)

@maurolacy maurolacy requested a review from a team May 7, 2022 15:14
@maurolacy maurolacy force-pushed the enable-mint-bindings branch from 015ec4f to 2734e3c Compare May 7, 2022 18:58
@codecov-commenter
Copy link

codecov-commenter commented May 7, 2022

Codecov Report

Merging #1445 (44f26ed) into main (f56fbe5) will decrease coverage by 0.42%.
The diff coverage is 16.39%.

@@            Coverage Diff             @@
##             main    #1445      +/-   ##
==========================================
- Coverage   19.82%   19.40%   -0.43%     
==========================================
  Files         202      229      +27     
  Lines       27685    31452    +3767     
==========================================
+ Hits         5489     6102     +613     
- Misses      21175    24237    +3062     
- Partials     1021     1113      +92     
Impacted Files Coverage Δ
app/wasm/bindings/query.go 0.00% <ø> (ø)
x/epochs/client/cli/query.go 0.00% <ø> (ø)
x/gamm/client/cli/query.go 36.74% <0.00%> (-0.36%) ⬇️
x/gamm/pool-models/stableswap/msgs.go 0.00% <0.00%> (ø)
x/gamm/pool-models/stableswap/pool.go 0.00% <0.00%> (ø)
x/gamm/pool-models/stableswap/stableswap_pool.go 0.00% <0.00%> (ø)
.../gamm/pool-models/stableswap/stableswap_pool.pb.go 0.58% <0.00%> (-0.09%) ⬇️
x/gamm/types/pool.go 0.00% <ø> (ø)
x/incentives/client/cli/query.go 0.00% <ø> (ø)
x/incentives/keeper/distribute.go 61.00% <0.00%> (ø)
... and 53 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5227c05...44f26ed. Read the comment docs.

@maurolacy maurolacy force-pushed the enable-mint-bindings branch from 2734e3c to 289b1dd Compare May 8, 2022 07:19
Copy link
Contributor

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

One test I would like to see (minting the same subdenom twice). Otherwise good to merge.

One open question for the Osmosis core devs before this is tagged. But please don't block merging this, we can enhance it in a follow up.

app/wasm/message_plugin.go Show resolved Hide resolved
app/wasm/message_plugin.go Show resolved Hide resolved

msgServer := tokenfactorykeeper.NewMsgServerImpl(*f)

// Check if denom already exists
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, this is the critical question.

Assuming we never set any metadata that is not present in the MintTokens command, this works great and makes a simple API.

However, if they plan to add more metadata there, we will want a separate command to run once to register the metadata (and another to query it?).

Copy link
Contributor

Choose a reason for hiding this comment

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

I would merge this as is (we can test stuff with it), but have a discussion with @ValarDragon and @sunnya97 before tagging an Osmosis release.

If they want to add more required metadata, they should add it in Go and we should expose it in Rust now. Otherwise, it will most likely be a breaking contract API change, which we want very much to avoid.

app/wasm/message_plugin.go Show resolved Hide resolved
app/wasm/test/custom_msg_test.go Show resolved Hide resolved
app/wasm/test/messages_test.go Show resolved Hide resolved
Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

LGTM once CI is passing

app/wasm/message_plugin.go Show resolved Hide resolved
app/wasm/testdata/version.txt Show resolved Hide resolved
@@ -2,6 +2,7 @@ package wasm

Copy link
Member

Choose a reason for hiding this comment

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

Can we make this a wasm_test package as well as all of the other test files:

  • custom_msg_test.go
  • custom_query_test.go
  • messages_test.go
  • queries_test.go

Let's not block merge on this but creating an issue for that would be great!

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reasoning here?

Basically, the default is usually the same package, and there are valid reasons to make it a separate wasm_test package, but it is good to discuss which one to prefer

@maurolacy maurolacy force-pushed the enable-mint-bindings branch from 6d8c061 to bff2f7e Compare May 10, 2022 09:14
Copy link
Collaborator

@mconcat mconcat left a comment

Choose a reason for hiding this comment

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

LGTM!

@ValarDragon
Copy link
Member

I don't have permission to update the branch, but once its updated lets go ahead and merge this in

@maurolacy maurolacy force-pushed the enable-mint-bindings branch from 8e46fe3 to 1d54f4b Compare May 16, 2022 05:45
@maurolacy maurolacy force-pushed the enable-mint-bindings branch from 1d54f4b to a64b13f Compare May 16, 2022 05:50
@mergify mergify bot merged commit 23ff223 into osmosis-labs:main May 16, 2022
@maurolacy maurolacy deleted the enable-mint-bindings branch May 16, 2022 06:00
@nicolaslara
Copy link
Contributor

@maurolacy What process did you use here to update app/wasm/testdata/osmo_reflect.wasm. I tried updating it to run the tests in my branch (#1484) by compiling it in (https://github.com/osmosis-labs/osmosis-bindings/pull/4) and copying the resulting .wasm file but keep getting:

=== RUN   TestLockTokensMsg
    custom_query_test.go:312:
        	Error Trace:	custom_query_test.go:312
        	            				custom_query_test.go:37
        	            				custom_msg_test.go:607
        	Error:      	Received unexpected error:

        	            	github.com/cosmos/cosmos-sdk/x/gov/keeper.Keeper.SubmitProposal
        	            		/Users/nicolas/go/pkg/mod/github.com/osmosis-labs/[email protected]/x/gov/keeper/proposal.go:24
        	            	github.com/osmosis-labs/osmosis/v7/app/wasm/test.storeReflectCode
        	            		/Users/nicolas/devel/osmosis/app/wasm/test/custom_query_test.go:311
        	            	github.com/osmosis-labs/osmosis/v7/app/wasm/test.SetupCustomApp
        	            		/Users/nicolas/devel/osmosis/app/wasm/test/custom_query_test.go:37
        	            	github.com/osmosis-labs/osmosis/v7/app/wasm/test.TestLockTokensMsg
        	            		/Users/nicolas/devel/osmosis/app/wasm/test/custom_msg_test.go:607
        	            	code bytes cannot be longer than 819200 bytes: exceeds limit: invalid request: invalid proposal content
        	Test:       	TestLockTokensMsg
--- FAIL: TestLockTokensMsg (0.06s)
FAIL
FAIL	github.com/osmosis-labs/osmosis/v7/app/wasm/test	0.669s
FAIL

Is there something I'm missing there?

@maurolacy
Copy link
Contributor Author

maurolacy commented May 24, 2022

I just updated it manually. That's why the version.txt file has a commit id (from the osmosis-bindings repository). No, sorry, this comment is outdated.

If you use the committed version of the wasm file, you should be good to go for tests.

@nicolaslara
Copy link
Contributor

@maurolacy thanks for the quick reply! ...Using the committed version I get the a "variant missing" error. Which makes sense, since that wasm file doesn't have information about the new type I've added on osmosis-bindings

=== RUN   TestLockTokensMsg
    custom_msg_test.go:638:
        	Error Trace:	custom_msg_test.go:638
        	Error:      	Received unexpected error:

        	            	github.com/CosmWasm/wasmd/x/wasm/keeper.Keeper.execute
        	            		/Users/nicolas/go/pkg/mod/github.com/osmosis-labs/[email protected]/x/wasm/keeper/keeper.go:354
        	            	github.com/CosmWasm/wasmd/x/wasm/keeper.PermissionedKeeper.Execute
        	            		/Users/nicolas/go/pkg/mod/github.com/osmosis-labs/[email protected]/x/wasm/keeper/contract_keeper.go:51
        	            	github.com/osmosis-labs/osmosis/v7/app/wasm/test.executeCustom
        	            		/Users/nicolas/devel/osmosis/app/wasm/test/custom_msg_test.go:543
        	            	github.com/osmosis-labs/osmosis/v7/app/wasm/test.TestLockTokensMsg
        	            		/Users/nicolas/devel/osmosis/app/wasm/test/custom_msg_test.go:637
        	            	Error parsing into type osmo_reflect::msg::ExecuteMsg: unknown variant `lock_tokens`, expected `mint_tokens` or `swap`: execute wasm contract failed
        	Test:       	TestLockTokensMsg
--- FAIL: TestLockTokensMsg (0.36s)
FAIL
FAIL	github.com/osmosis-labs/osmosis/v7/app/wasm/test	0.952s
FAIL

@nicolaslara
Copy link
Contributor

nicolaslara commented May 24, 2022

ahh, I think I know what the problem is. I hadn't finished the mock in multitest.rs. I'll fix that and report back.

That wasn't it. Clearly the internal tests of the rust package shouldn't affect the go test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants