-
Notifications
You must be signed in to change notification settings - Fork 608
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
Conversation
|
||
// Parameter store keys. | ||
var ( | ||
// KeyParamField = []byte("TODO: CHANGE ME") |
There was a problem hiding this comment.
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 {} |
There was a problem hiding this comment.
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
// 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
// TODO: uncomment once merging state-breaks. | ||
// return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) |
There was a problem hiding this comment.
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
// TODO: uncomment once merging state-breaks. | ||
// poolI := NewCosmWasmPool(poolID, msg.CodeId, msg.InstantiateMsg) | ||
// return &poolI, nil |
There was a problem hiding this comment.
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
string contract_address = 2 | ||
[ (gogoproto.moretags) = "yaml:\"contract_address\"" ]; | ||
uint64 pool_id = 3; | ||
uint64 code_id = 4; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracking discussion here: #4779
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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
There was a problem hiding this 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; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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...
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
Co-authored-by: Adam Tucker <[email protected]>
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
Copy proto definitions from feat/spike: CosmWasm Pool Type and Module #4675
model
packageTesting and Verifying
This change is a trivial rework / code cleanup without any test coverage.
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? no