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(superfluid/gov): configure unpool whitelist via gov prop #3512

Merged
merged 13 commits into from
Nov 26, 2022
Merged

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Nov 24, 2022

Closes: #XXX

What is the purpose of the change

Add the ability to configure the unpool whitelist via gov prop.

The new gov prop takes the list of pool ids and isOverwriteFlag. If the flag is true, the old pool ids are discarded. If false, the old pool ids are merged with the new.

Brief Changelog

Testing and Verifying

  • uni tests added
  • localnet test
# Create 3 pools by running the below 3 times
osmosisd tx gamm create-pool --pool-file=tests/e2e/scripts/nativeDenomPool.json  --from lo-test1 --keyring-backend test -b=block

# Fails because pool id 4 does not exist
osmosisd tx gov submit-proposal update-unpool-whitelist --pool-ids "4" --title "test" --description "test"  --from lo-test1 --keyring-backend test -b=block

# Succesfully creates proposal
osmosisd tx gov submit-proposal update-unpool-whitelist --pool-ids "1, 2, 3" --title "test" --description "test"  --from lo-test1 --keyring-backend test -b=block

Upon enabling whitelist, it is still impossible to run:

# Fails with message not activated.
 osmosisd tx superfluid unpool-whitelisted-pool 1 --from lo-test1 --keyring-backend test -b=bloc

We should enable that message in a separate PR.

Documentation and Release Note

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

@github-actions github-actions bot added C:app-wiring Changes to the app folder C:x/superfluid labels Nov 24, 2022
@p0mvn p0mvn added V:state/compatible/no_backport State machine compatible PR, depends on prior breaks V:state/compatible/backport State machine compatible PR, should be backported and removed V:state/compatible/no_backport State machine compatible PR, depends on prior breaks labels Nov 24, 2022
@github-actions github-actions bot added the C:CLI label Nov 24, 2022
@p0mvn p0mvn marked this pull request as ready for review November 25, 2022 02:19
@p0mvn p0mvn requested a review from a team November 25, 2022 02:19
x/superfluid/keeper/gov/suite_test.go Outdated Show resolved Hide resolved
x/superfluid/keeper/gov/suite_test.go Outdated Show resolved Hide resolved
@p0mvn p0mvn added V:state/breaking State machine breaking PR A:backport/v13.x backport patches to v13.x branch and removed V:state/compatible/backport State machine compatible PR, should be backported labels Nov 25, 2022

// GetIfFound gets key from store
// returns a boolean indicating whether value exists for the given key and error
func GetIfFound(store store.KVStore, key []byte, result proto.Message) (found bool, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

Can be changed later / can discuss in an issue, should not block this PR. Perhaps this should be called HasWithType ?

e.g. if we were masters of the store interface

store.HasProtoMsg("myKey", types.Pool)

Has to indicate its a bool (rather than assuming you'd get the object back)

OR is proto.Message here actually mutated? If so lets update the comment, but this doesn't actually make sense to me as an API.

Why don't just make a method called Get thats the same as MustGet, but returns an error instead of panics?

@@ -10,23 +10,25 @@ import (
func ProposalSetSuperfluidAssetsRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler {
return govrest.ProposalRESTHandler{
SubRoute: "set-superfluid-assets",
Handler: newSetSuperfluidAssetsHandler(clientCtx),
Copy link
Member

@ValarDragon ValarDragon Nov 25, 2022

Choose a reason for hiding this comment

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

idk whats going on here, but IIRC this REST folder doesn't matter for anything / should be deleted, so not blocking

Copy link
Member Author

Choose a reason for hiding this comment

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

For each of these, the handler is the same - no-op. I just made a shared no-op function for all of these but yes it's unimportant

Copy link
Member

@ValarDragon ValarDragon Nov 25, 2022

Choose a reason for hiding this comment

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

ah that makes sense! Nice :)

Copy link
Member

@ValarDragon ValarDragon left a comment

Choose a reason for hiding this comment

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

Looks great to me! Can we just sanity check that we have an existing test for ensuring that unpooling doesn't work for pools not in whitelist?

Comment on lines +157 to +161
func (suite *KeeperTestSuite) TestHandleUnpoolWhiteListChange() {
const (
testTitle = "test title"
testDescription = "test description"
)
Copy link
Member

Choose a reason for hiding this comment

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

Great job on the test!

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.

Well done 👍

Args: cobra.ExactArgs(0),
Short: "Update unpool whitelist proposal",
Long: "This proposal will update the unpool whitelist if passed. " +
"Every pool id must be valid. If proposal passes, and the pool id is invalid, the proposal will not take any effect. " +
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we run GetPoolAndPoke in ValidateBasic to prevent this from happening?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately, we don't have access to the gamm keeper in ValidateBasic().

However, I found out that gov module attempts to test-run the proposal with cache context before allowing it to be submitted:
https://github.com/osmosis-labs/cosmos-sdk/blob/870132d311d162fdbe0e92fcc0a42ee3889afd0d/x/gov/keeper/proposal.go#L22-L29

So if pool doesn't exist, it will not be submitted. I will change the wording

@p0mvn p0mvn merged commit 404cf9b into main Nov 26, 2022
@p0mvn p0mvn deleted the roman/unpool branch November 26, 2022 02:55
mergify bot pushed a commit that referenced this pull request Nov 26, 2022
* feat(superfluid/gov): configure unpool whitelist via gov prop

* cli and amino registrateions

* linter

* Update x/superfluid/keeper/gov/suite_test.go

* Update x/superfluid/keeper/gov/suite_test.go

* add tests for GetIfFound (#3145)

* add tests for GetIfFound

* refactor

* cli fix

* cli updates

* remove message not activated

* Update x/superfluid/types/gov.go

Co-authored-by: Dev Ojha <[email protected]>

* correct CLI wording

* GetIfFound godoc

Co-authored-by: Hieu Vu <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
(cherry picked from commit 404cf9b)
@p0mvn
Copy link
Member Author

p0mvn commented Nov 26, 2022

Looks great to me! Can we just sanity check that we have an existing test for ensuring that unpooling doesn't work for pools not in whitelist?

Test added: #3532

ValarDragon pushed a commit that referenced this pull request Nov 27, 2022
…#3531)

* feat(superfluid/gov): configure unpool whitelist via gov prop

* cli and amino registrateions

* linter

* Update x/superfluid/keeper/gov/suite_test.go

* Update x/superfluid/keeper/gov/suite_test.go

* add tests for GetIfFound (#3145)

* add tests for GetIfFound

* refactor

* cli fix

* cli updates

* remove message not activated

* Update x/superfluid/types/gov.go

Co-authored-by: Dev Ojha <[email protected]>

* correct CLI wording

* GetIfFound godoc

Co-authored-by: Hieu Vu <[email protected]>
Co-authored-by: Dev Ojha <[email protected]>
(cherry picked from commit 404cf9b)

Co-authored-by: Roman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v13.x backport patches to v13.x branch C:app-wiring Changes to the app folder C:CLI C:x/superfluid V:state/breaking State machine breaking PR
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants