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

feat: x/cosmwasmpool proto and query boilerplate #4764

Merged
merged 9 commits into from
Mar 29, 2023

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Mar 28, 2023

Closes: #XXX

What is the purpose of the change

Merging protos and query boilerplate from:
#4675

Note that there are no parameters or queries at this moment. However, we will likely need to add some. Since all wiring is already setup in #4675, I suggest we merge this as is and remove if unused at the end.

No actual logic changes or state breaks in this PR.

Brief Changelog

  1. Copy proto definitions from feat/spike: CosmWasm Pool Type and Module #4675

make proto-all

make run-querygen
  1. Copy minimum dependency imports and wiring. Namely,
  • params
  • keeper declaration and param methods
  • expected keeper interfaces in types
  • keys in types
  • pool store model in model package

Testing and Verifying

This change is a trivial rework / code cleanup without any test coverage.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable


// Parameter store keys.
var (
// KeyParamField = []byte("TODO: CHANGE ME")
Copy link
Member Author

@p0mvn p0mvn Mar 28, 2023

Choose a reason for hiding this comment

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

Note to reviewer: revisit having parameters is tracked in #4765


option go_package = "github.com/osmosis-labs/osmosis/v15/x/cosmwasmpool/types";

service Msg {}
Copy link
Member Author

@p0mvn p0mvn Mar 28, 2023

Choose a reason for hiding this comment

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

Note to reviewer revisit having messages is tracked in: #4765

Comment on lines +16 to +24
// TODO: remove nolint once added.
// nolint: unused
poolmanagerKeeper types.PoolManagerKeeper
// TODO: remove nolint once added.
// nolint: unused
contractKeeper types.ContractKeeper
// TODO: remove nolint once added.
// nolint: unused
wasmKeeper types.WasmKeeper
Copy link
Member Author

@p0mvn p0mvn Mar 28, 2023

Choose a reason for hiding this comment

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

Note to reviewer: TODOs are tracked in: #4765

Copy link
Contributor

Choose a reason for hiding this comment

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

WasmKeeper allows for Create and Instantiate. Normally we pass a PermissionedKeeper so that it can't add new codes. I think it's ok, but if we want to be restrictive we can pass a PermissionedKeeper with custom permissions that don't allow Create

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that this is defined in expected_keepers (I thought before it was wasm.WasmKeeper). We can definitely use a more restrictive one here. The ContractKeeper will need the permisions described above though

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'm defining the bare minimum of what interface is required by this module in types.expected_keepers.go

Comment on lines +44 to +45
// TODO: uncomment once merging state-breaks.
// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
Copy link
Member Author

Choose a reason for hiding this comment

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

Note to reviewer: TODO is tracked in

Comment on lines +75 to +77
// TODO: uncomment once merging state-breaks.
// poolI := NewCosmWasmPool(poolID, msg.CodeId, msg.InstantiateMsg)
// return &poolI, nil
Copy link
Member Author

@p0mvn p0mvn Mar 28, 2023

Choose a reason for hiding this comment

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

Note to reviewer: TODO is tracked in #4765

@p0mvn p0mvn added the V:state/compatible/no_backport State machine compatible PR, depends on prior breaks label Mar 28, 2023
@p0mvn p0mvn mentioned this pull request Mar 28, 2023
6 tasks
@p0mvn p0mvn marked this pull request as ready for review March 28, 2023 02:38
string contract_address = 2
[ (gogoproto.moretags) = "yaml:\"contract_address\"" ];
uint64 pool_id = 3;
uint64 code_id = 4;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to store the code_id? It can be retrieved from the ContractInfo (using the addr) once the contract is instantiated.

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't storing it here prevent one more query in the required path though?

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't storing it here prevent one more query in the required path though?

I think it does.

Also, I think we might want to store the code id for security purposes so that it is impossible to upgrade the contract to something malicious.

We can allow this to be upgradeable via gov prop. WDYT?

Going to make an issue to track this discussion

Copy link
Member Author

Choose a reason for hiding this comment

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

Tracking discussion here: #4779

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't storing it here prevent one more query in the required path though?

Only when the code id is being used, which is only on instantiation (AFAICT). Not sure when else we would need the code id.

Also, I think we might want to store the code id for security purposes so that it is impossible to upgrade the contract to something malicious.

We can make the contract non-upgradable by giving it no admin.

Also if we wanted to enforce this by checking the code id, we would need to query the ContractInfo on every call to see that it matches what is stored.

option (google.api.http).get =
"/osmosis/poolmanager/v1beta1/{pool_id}/estimate/single_pool_swap_exact_amount_in";
option (google.api.http).get = "/osmosis/poolmanager/v1beta1/{pool_id}/"
"estimate/single_pool_swap_exact_amount_in";
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be one line. The linter splits it, but apparently protobufs don't support that. ref #4549 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Is this confirmed? Would be really odd if the linter did something that wasn't proto compatible...

Copy link
Member Author

@p0mvn p0mvn Mar 29, 2023

Choose a reason for hiding this comment

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

I'm also not convinced this is a problem. I searched the repo and there are multiple places where this is happening.

If this is indeed an issue, we should investigate fixing the linter IMO as it is almost guaranteed it will get missed in one of the PRs

Going to follow-up on Slack

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, not sure. Just going off what Matt said. @mattverse have you confirmed that stuff breaks here? what breaks?

Copy link
Member

Choose a reason for hiding this comment

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

From what I have manually tested, I have came to a conclusion that these multiple liners are not correctly supported when they are getting converted to rest endpoints.

On the second look, it might have been just me having effect by other testing variants. Worthwhile re-testing, cannot assure that its 100% not supported

Copy link
Contributor

@nicolaslara nicolaslara left a comment

Choose a reason for hiding this comment

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

Left some notes, but in general this looks good to me

Copy link
Member

@czarcas7ic czarcas7ic left a comment

Choose a reason for hiding this comment

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

LGTM 👍

string contract_address = 2
[ (gogoproto.moretags) = "yaml:\"contract_address\"" ];
uint64 pool_id = 3;
uint64 code_id = 4;
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't storing it here prevent one more query in the required path though?

option (google.api.http).get =
"/osmosis/poolmanager/v1beta1/{pool_id}/estimate/single_pool_swap_exact_amount_in";
option (google.api.http).get = "/osmosis/poolmanager/v1beta1/{pool_id}/"
"estimate/single_pool_swap_exact_amount_in";
Copy link
Member

Choose a reason for hiding this comment

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

Is this confirmed? Would be really odd if the linter did something that wasn't proto compatible...

x/cosmwasmpool/model/msgs.go Outdated Show resolved Hide resolved
x/cosmwasmpool/model/msgs.go Outdated Show resolved Hide resolved
x/cosmwasmpool/types/params.go Outdated Show resolved Hide resolved
x/cosmwasmpool/types/params.go Outdated Show resolved Hide resolved
p0mvn and others added 2 commits March 28, 2023 20:46
@p0mvn p0mvn merged commit 1fb9da8 into main Mar 29, 2023
@p0mvn p0mvn deleted the roman/cosmwasm-pool-protos branch March 29, 2023 01:07
@p0mvn p0mvn restored the roman/cosmwasm-pool-protos branch March 29, 2023 01:12
@p0mvn p0mvn mentioned this pull request May 28, 2023
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:CLI C:x/poolmanager V:state/compatible/no_backport State machine compatible PR, depends on prior breaks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants