-
Notifications
You must be signed in to change notification settings - Fork 591
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
[Incentives Module][bugfix] Scale gas costs by denoms in gauge #4830
Conversation
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! Left a couple minor comments. Approving rn, but we should add the test case I suggested before merging.
sdk.NewCoin("atom", sdk.NewInt(99999)), | ||
), | ||
gaugeId: 1, | ||
minimumGasConsumed: uint64(2 * types.BaseGasFeeForAddRewardToGauge), |
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.
Since the base gas cost for txns like these are usually in the 10k-20k gas range, we should add a test case with many denoms (>4) to ensure that the minimumGasConsumed
check isn't passing trivially
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.
sounds good added! for 8 tokens it looks like this;
gasConsumed: 161441 tc. minimumGasConsumed: 80000
x/incentives/keeper/gauge.go
Outdated
@@ -152,6 +152,10 @@ func (k Keeper) AddToGaugeRewards(ctx sdk.Context, owner sdk.AccAddress, coins s | |||
if gauge.IsFinishedGauge(ctx.BlockTime()) { | |||
return errors.New("gauge is already completed") | |||
} | |||
|
|||
// Fixed gas consumption adding reward to gauges based on the number of coins to add | |||
ctx.GasMeter().ConsumeGas(uint64(types.BaseGasFeeForAddRewardToGauge*len(coins)), "scaling gas cost for adding to gauge rewards") |
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.
Just realized that this should actually be charging baseAmount * (len(gauge.Coins) + len(coins))
since we allow for adding multiple coins at once here. The current implementation only scales by the number of coins being added, not the ones that already exist.
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, i originally thought it was just for new denoms. I'll change it to accomodate existing denoms
Re
gasConsumed: 171474 minimumGasConsumed: 80000
@stackman27 please add a CHANGELOG entry prior to merge |
added! |
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.
Nice
Closes: #4738
What is the purpose of the change
Similarly to what we did for incentive records in CL, we should be scaling gas costs for adding to gauges to prevent spam, as distribution logic linearly iterates over all denoms in a gauge at epoch.
Add scaling gas costs to AddToGaugeRewards, similar to how we did it for incentive records
Brief Changelog
AddToGaugeRewards
, linearly increase with coins to addTesting and Verifying
added new tests
Documentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no)x/<module>/spec/
) / Osmosis docs repo / not documented)