-
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
Distribution, expand the ignored distributios set #7250
Merged
+121
−18
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f36a0b1
Expand spam filter
ValarDragon 4ab9536
Update comment
ValarDragon 36a6f63
add changelog
czarcas7ic 23ab392
Merge branch 'main' into dev/refine_spam_filter
mattverse 424c6f5
Merge branch 'main' into dev/refine_spam_filter
czarcas7ic 5cf383a
add skipSpamGaugeDistribute test
czarcas7ic 91de47c
Merge branch 'main' into dev/refine_spam_filter
czarcas7ic 8da4e45
lint
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -637,24 +637,9 @@ func (k Keeper) distributeInternal( | |
} | ||
} else { | ||
// This is a standard lock distribution flow that assumes that we have locks associated with the gauge. | ||
if len(locks) == 0 { | ||
return nil, nil | ||
} | ||
|
||
// In this case, remove redundant cases. | ||
// Namely: gauge empty OR gauge coins undistributable. | ||
if remainCoins.Empty() { | ||
ctx.Logger().Debug(fmt.Sprintf("gauge debug, this gauge is empty, why is it being ran %d. Balancer code", gauge.Id)) | ||
err := k.updateGaugePostDistribute(ctx, gauge, totalDistrCoins) | ||
return totalDistrCoins, err | ||
} | ||
|
||
// Remove some spam gauges, is state compatible. | ||
// If they're to pool 1 they can't distr at this small of a quantity. | ||
if remainCoins.Len() == 1 && remainCoins[0].Amount.LTE(osmomath.NewInt(10)) && gauge.DistributeTo.Denom == "gamm/pool/1" && remainCoins[0].Denom != "uosmo" { | ||
ctx.Logger().Debug(fmt.Sprintf("gauge debug, this gauge is perceived spam, skipping %d", gauge.Id)) | ||
err := k.updateGaugePostDistribute(ctx, gauge, totalDistrCoins) | ||
return totalDistrCoins, err | ||
isSpam, totaltotalDistrCoins, err := k.skipSpamGaugeDistribute(ctx, locks, gauge, totalDistrCoins, remainCoins) | ||
if isSpam { | ||
return totaltotalDistrCoins, err | ||
} | ||
|
||
// This is a standard lock distribution flow that assumes that we have locks associated with the gauge. | ||
|
@@ -713,6 +698,28 @@ func (k Keeper) distributeInternal( | |
return totalDistrCoins, err | ||
} | ||
|
||
func (k Keeper) skipSpamGaugeDistribute(ctx sdk.Context, locks []*lockuptypes.PeriodLock, gauge types.Gauge, totalDistrCoins sdk.Coins, remainCoins sdk.Coins) (bool, sdk.Coins, error) { | ||
if len(locks) == 0 { | ||
return true, nil, nil | ||
} | ||
|
||
// In this case, remove redundant cases. | ||
// Namely: gauge empty OR gauge coins undistributable. | ||
if remainCoins.Empty() { | ||
ctx.Logger().Debug(fmt.Sprintf("gauge debug, this gauge is empty, why is it being ran %d. Balancer code", gauge.Id)) | ||
err := k.updateGaugePostDistribute(ctx, gauge, totalDistrCoins) | ||
return true, totalDistrCoins, err | ||
} | ||
|
||
// Remove some spam gauges that are not worth distributing. (We ignore the denom stake because of tests.) | ||
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.
LOL, cant we just inc the tests to be greater than 100?? 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. yeah but its pain |
||
if remainCoins.Len() == 1 && remainCoins[0].Amount.LTE(osmomath.NewInt(100)) && remainCoins[0].Denom != "stake" { | ||
ctx.Logger().Debug(fmt.Sprintf("gauge debug, this gauge is perceived spam, skipping %d", gauge.Id)) | ||
err := k.updateGaugePostDistribute(ctx, gauge, totalDistrCoins) | ||
return true, totalDistrCoins, err | ||
} | ||
return false, totalDistrCoins, nil | ||
} | ||
|
||
func checkBigInt(bi *big.Int) { | ||
if bi.BitLen() > sdkmath.MaxBitLen { | ||
panic("overflow") | ||
|
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.
I think it'd be worth creating unit test for this as well
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.
Added 5cf383a