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

[VS Incentives]: remove gauge creation logic from CreateGroup, call CreateGauge instead #6513

Closed
Tracked by #6057
p0mvn opened this issue Sep 23, 2023 · 3 comments · Fixed by #6536
Closed
Tracked by #6057
Assignees
Labels
F: volume-splitting feat: Volume-splitting incentives

Comments

@p0mvn
Copy link
Member

p0mvn commented Sep 23, 2023

Context
Logic in CreateGroup essentially duplicaed gauge creation.

We should instead encapsulated any gauge creation inside CreateGauge and call that from CreateGroup

A/C

  • Create group gauge in CreateGauge & update tests
  • Call CreateGauge from CreateGroup
  • Minimize code duplication
@AlpinYukseloglu
Copy link
Contributor

I agree with avoiding duplicate code, but we should be careful about storing group gauges in state alongside regular gauges since we fetch all active gauges from state for distribution using a prefix iterator:

gauges = k.GetActiveGauges(ctx)

This means if we use CreateGauge for group gauges and by extension share keys/prefixes between group gauges and regular gauges, we should be careful to either skip group gauges during this distribution logic or in some other way exclude them from the regular gauge iterator

@p0mvn
Copy link
Member Author

p0mvn commented Sep 24, 2023

This is a valid concern. However, a workaround was fond and tracked:

  • In CreateGauge, if the gauge being created is a ByGroup gauge, do NOT create upcoming/active/finished ref keys. Only write it to a regular gauge index.
  • This will allow ByGroup bypassing being retrieved from state via GetActiveGauges because it reads from a store index that ByGroup was not written to:
    return k.getGaugesFromIterator(ctx, k.ActiveGaugesIterator(ctx))

Additionally, we must write the ByGroup gauge intro a regular gauge index. Otherwise, we would not be able to retrieve it in a general way from pool incentive hooks when distributing from the DisrRecords :

gauge, err := k.GetGaugeByID(ctx, gaugeID)

Lmk if this doesn't address your concern

@AlpinYukseloglu
Copy link
Contributor

It does, great!

@p0mvn p0mvn self-assigned this Sep 25, 2023
@github-project-automation github-project-automation bot moved this from Needs Triage 🔍 to Done ✅ in Osmosis Chain Development Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: volume-splitting feat: Volume-splitting incentives
Projects
Archived in project
2 participants