-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add x/farm module #362
Conversation
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { | ||
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
if err := k.AllocateRewards(ctx); err != nil { |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
if err := k.AllocateRewards(ctx); err != nil { | ||
panic(err) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
if err := k.AllocateRewards(ctx); err != nil { | ||
panic(err) | ||
} | ||
k.SetLastBlockTime(ctx, ctx.BlockTime()) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
if err := k.AllocateRewards(ctx); err != nil { | ||
panic(err) | ||
} | ||
k.SetLastBlockTime(ctx, ctx.BlockTime()) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
also: - rename some methods and variables - add spec docs skeleton
func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { | ||
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
if err := k.TerminateEndedPlans(ctx); err != nil { |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
if err := k.TerminateEndedPlans(ctx); err != nil { | ||
panic(err) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
also: - make `IncrementFarmPeriod` unexported - bump `conventional-pre-commit` version
also: - reorganize `AllocateRewards` code for better readability - implement missing gRPC query implementations
As a side note in case I forget during the future code review, the |
for denom := range totalFarmingAmtByDenom { | ||
if !totalFarmingAmtByDenom[denom].Equal(farmingAmtSumByDenom[denom]) { | ||
msg += fmt.Sprintf( | ||
"\tfarm %s total farming amount %s != sum %s\n", | ||
denom, totalFarmingAmtByDenom[denom], farmingAmtSumByDenom[denom], | ||
) | ||
cnt++ | ||
} | ||
} |
Check warning
Code scanning / CodeQL
Iteration over map
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.
Great work on the farm
module implementation!
Overall it looks good to me. I have some comments and questions below.
- The
farm
module needs to be defined inlabeler.yml
file. - There are some TODO comments that need to be resolved
this optimizes the gas usage when calling `CreatePrivatePlan`
also add explanatory comments for core logics
also add a few safety checks when sending coins
Description
The new x/farm module will be the successor of the x/farming module.
Tasks
Farm
,Unfarm
,Harvest
Split protobuf messages(Farm
,Position
, ...)RenamePlan
toFarmingPlan
?References
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes