-
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
fix: genesis bug in pool incentives linking NoLock gauges and PoolIDs #6644
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1a1c939
fix: genesis bug in pool incentives
p0mvn 7b01e24
changelog
p0mvn 486c299
lint
p0mvn 1184ff2
add clarifying comment
czarcas7ic a0ed7a0
merge main
czarcas7ic e6cb9b6
Revert "merge main"
czarcas7ic aea8009
Merge branch 'main' into roman/pool-incentives-genesis-bug
czarcas7ic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,9 @@ import ( | |
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
|
||
"github.com/osmosis-labs/osmosis/osmomath" | ||
pool_incentives "github.com/osmosis-labs/osmosis/v19/x/pool-incentives" | ||
|
||
simapp "github.com/osmosis-labs/osmosis/v19/app" | ||
|
||
lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" | ||
pool_incentives "github.com/osmosis-labs/osmosis/v19/x/pool-incentives" | ||
"github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" | ||
) | ||
|
||
|
@@ -36,7 +35,7 @@ var ( | |
}, | ||
}, | ||
}, | ||
PoolToGauges: &types.PoolToGauges{ | ||
AnyPoolToInternalGauges: &types.AnyPoolToInternalGauges{ | ||
PoolToGauge: []types.PoolToGauge{ | ||
{ | ||
PoolId: 1, | ||
|
@@ -48,18 +47,14 @@ var ( | |
GaugeId: 2, | ||
Duration: time.Second, | ||
}, | ||
// This duplication with zero duration | ||
// can happen with "NoLock" gauges | ||
// where the link containing the duration | ||
// is used to signify that the gauge is internal | ||
// while the link without the duration is used | ||
// for general purpose. This redundancy is | ||
// made for convinience of plugging in the | ||
// later added "NoLock" gauge into the existing | ||
// logic without having to change majority of the queries. | ||
}, | ||
}, | ||
ConcentratedPoolToNoLockGauges: &types.ConcentratedPoolToNoLockGauges{ | ||
PoolToGauge: []types.PoolToGauge{ | ||
{ | ||
PoolId: 2, | ||
GaugeId: 2, | ||
PoolId: 3, | ||
GaugeId: 3, | ||
Duration: 0, | ||
}, | ||
}, | ||
}, | ||
|
@@ -124,7 +119,7 @@ func (s *KeeperTestSuite) TestExportGenesis() { | |
s.App.PoolIncentivesKeeper.SetLockableDurations(ctx, durations) | ||
savedDurations := s.App.PoolIncentivesKeeper.GetLockableDurations(ctx) | ||
s.Equal(savedDurations, durations) | ||
var expectedPoolToGauges types.PoolToGauges | ||
var expectedPoolToGauges types.AnyPoolToInternalGauges | ||
var gauge uint64 | ||
for _, duration := range durations { | ||
gauge++ | ||
|
@@ -139,5 +134,57 @@ func (s *KeeperTestSuite) TestExportGenesis() { | |
s.Equal(genesisExported.Params, genesis.Params) | ||
s.Equal(genesisExported.LockableDurations, durations) | ||
s.Equal(genesisExported.DistrInfo, genesis.DistrInfo) | ||
s.Equal(genesisExported.PoolToGauges, &expectedPoolToGauges) | ||
s.Equal(genesisExported.AnyPoolToInternalGauges, &expectedPoolToGauges) | ||
} | ||
|
||
// This test validates that all store indexes are set correctly | ||
// for NoLock gauges after exporting and then reimporting genesis. | ||
func (s *KeeperTestSuite) TestImportExportGenesis_ExternalNoLock() { | ||
s.SetupTest() | ||
|
||
// Prepare concentrated pool | ||
clPool := s.PrepareConcentratedPool() | ||
|
||
// Fund account to create gauge | ||
s.FundAcc(s.TestAccs[0], defaultCoins.Add(defaultCoins...)) | ||
|
||
// Create external non-perpetual gauge | ||
externalGaugeID, err := s.App.IncentivesKeeper.CreateGauge(s.Ctx, false, s.TestAccs[0], defaultCoins.Add(defaultCoins...), lockuptypes.QueryCondition{ | ||
LockQueryType: lockuptypes.NoLock, | ||
}, s.Ctx.BlockTime(), 2, clPool.GetId()) | ||
s.Require().NoError(err) | ||
|
||
// We expect internal gauge to be created first | ||
internalGaugeID := externalGaugeID - 1 | ||
|
||
// Export genesis | ||
export := s.App.PoolIncentivesKeeper.ExportGenesis(s.Ctx) | ||
|
||
// Validate that only one link for internal gauges is created | ||
s.Require().Equal(1, len(export.AnyPoolToInternalGauges.PoolToGauge)) | ||
|
||
// Validate that 2 links, one for external and one for internal gauge, are created | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified the comment to this as the last comment threw me off |
||
s.Require().Equal(2, len(export.ConcentratedPoolToNoLockGauges.PoolToGauge)) | ||
|
||
// Reset state | ||
s.SetupTest() | ||
|
||
// Import genesis | ||
s.App.PoolIncentivesKeeper.InitGenesis(s.Ctx, export) | ||
|
||
// Get the general link between external gauge ID and pool | ||
poolID, err := s.App.PoolIncentivesKeeper.GetPoolIdFromGaugeId(s.Ctx, externalGaugeID, 0) | ||
s.Require().NoError(err) | ||
s.Require().Equal(clPool.GetId(), poolID) | ||
|
||
// Get the general link between internal gauge ID and pool | ||
poolID, err = s.App.PoolIncentivesKeeper.GetPoolIdFromGaugeId(s.Ctx, internalGaugeID, 0) | ||
s.Require().NoError(err) | ||
s.Require().Equal(clPool.GetId(), poolID) | ||
|
||
// Get the internal gauge | ||
incentivesEpochDuration := s.App.IncentivesKeeper.GetEpochInfo(s.Ctx).Duration | ||
internalGaugeIDAfterImport, err := s.App.PoolIncentivesKeeper.GetPoolGaugeId(s.Ctx, poolID, incentivesEpochDuration) | ||
s.Require().NoError(err) | ||
s.Require().Equal(internalGaugeID, internalGaugeIDAfterImport) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not quite sure why these need their own message types when the underlying is the same, and the name can be changed in the actual message, but will not block on this and will not change this myself in the event this was intentional and its more of a nit.,