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

[CL Incentives] Scale gas cost for new incentives by number of existing incentives #4517

Closed
Tracked by #3991
AlpinYukseloglu opened this issue Mar 6, 2023 · 0 comments · Fixed by #4638
Closed
Tracked by #3991
Labels
F: concentrated-liquidity Tracking the development of concentrated liquidity feature to improve filtering on the project board

Comments

@AlpinYukseloglu
Copy link
Contributor

AlpinYukseloglu commented Mar 6, 2023

Background

The current implementation of incentive creation allows for a DoS vector where a user can spam new incentives with dust amounts. Since our reward calculation is linear in the number of incentive records, this exposes the chain to being forced to run unbounded compute.

To combat this, we should scale gas costs for creating incentives by the number of existing incentive records.

Suggested Design

  • I propose we add a base gas fee amount and charge baseGas * len(existingIncentiveRecordsForUptime) on each incentive record add
  • Implement getting incentive records by uptime (move up minUptime in key and make function)
  • Add the following constant to concentrated-liquidity/types/constants.go:
BaseGasFeeForNewIncentive = 10_000
  • Add the following logic right before setIncentiveRecord in createIncentive:
// Get all incentive records for uptime
existingRecordsForUptime, err := k.GetAllIncentiveRecordsForUptime(ctx, poolId, minUptime)

// Fixed gas consumption per swap to prevent spam
ctx.GasMeter().ConsumeGas(uint64(types.BaseGasFeeForNewIncentive) * len(existingRecordsForUptime), "balancer swap computation")

Acceptance Criteria

  • All new and existing tests pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: concentrated-liquidity Tracking the development of concentrated liquidity feature to improve filtering on the project board
Projects
Archived in project
1 participant