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

x/gamm: Consider deleting IsActive and related checks #1904

Closed
AlpinYukseloglu opened this issue Jun 30, 2022 · 5 comments · Fixed by #2050
Closed

x/gamm: Consider deleting IsActive and related checks #1904

AlpinYukseloglu opened this issue Jun 30, 2022 · 5 comments · Fixed by #2050
Assignees
Labels
C:x/gamm Changes, features and bugs related to the gamm module. T:code-hygiene T:dev-UX

Comments

@AlpinYukseloglu
Copy link
Contributor

AlpinYukseloglu commented Jun 30, 2022

Background

Consider deleting IsActive and related checks, including getPoolForSwap(). These checks were introduced for a feature that no longer exists (namely, letting people add/remove liquidity from a pool while disallowing swaps in it). Currently, IsActive is hard-coded to return true, and every check it is used in never fails. In the spirit of not keeping code that doesn't do anything in our codebase, I think it's worth considering removing this check and its related functions.

func (pa Pool) IsActive(ctx sdk.Context) bool {
return true
}

Suggested Design

  • Remove IsActive and getPoolForSwap()
  • Replace uses of getPoolForSwap() with GetPoolAndPoke()

Acceptance Criteria

  • All existing tests pass
@AlpinYukseloglu AlpinYukseloglu added the C:x/gamm Changes, features and bugs related to the gamm module. label Jun 30, 2022
@AlpinYukseloglu AlpinYukseloglu changed the title Consider deleting IsActive and related checks x/gamm: Consider deleting IsActive and related checks Jun 30, 2022
@p0mvn
Copy link
Member

p0mvn commented Jun 30, 2022

The suggested design makes sense. This should be removed to avoid confusing people and opening up potential vectors for errors with the unused code in one of the core modules

@p0mvn
Copy link
Member

p0mvn commented Jul 4, 2022

Following up on the discussion offline:

  • Can we add a comment for the method spec explaining what the method does and why we are keeping it while it always returns true? (e.g. for emergency situations to have an ability to quickly change the logic about when a pool is active)
  • Can we have a simple unit test where we expect IsActive to always return true for now? This is to ensure that even such a basic function is covered by tests so that if anyone accidentally flips the flag, the unit test would immediately catch it

@AlpinYukseloglu
Copy link
Contributor Author

Following up on the discussion offline:

  • Can we add a comment for the method spec explaining what the method does and why we are keeping it while it always returns true? (e.g. for emergency situations to have an ability to quickly change the logic about when a pool is active)
  • Can we have a simple unit test where we expect IsActive to always return true for now? This is to ensure that even such a basic function is covered by tests so that if anyone accidentally flips the flag, the unit test would immediately catch it

Agreed for both. I think we also discussed adding a test that would cover the "flipping" functionality – @ValarDragon you briefly mentioned mock testing as an option. Do we have any examples of something like that in our codebase/how did you envision it would look?

@ValarDragon
Copy link
Member

ValarDragon commented Jul 13, 2022

Mocks refer to making a sample implementation of an interface, satisfying the minimal testing needs wanted at that spot.

This is a tool that can help generating such an interface stub, but it may be easier to just make a struct in place that implements the Pool interface.

I think its fine to leave the latter as a future issue, and for now just having a test for the IsActive functionality that roman noted sounds good to me.

@AlpinYukseloglu
Copy link
Contributor Author

Mocks refer to making a sample implementation of an interface, satisfying the minimal testing needs wanted at that spot.

This is a tool that can help generating such an interface stub, but it may be easier to just make a struct in place that implements the Pool interface.

I think its fine to leave the latter as a future issue, and for now just having a test for the IsActive functionality that roman noted sounds good to me.

Sounds good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/gamm Changes, features and bugs related to the gamm module. T:code-hygiene T:dev-UX
Projects
None yet
3 participants