-
Notifications
You must be signed in to change notification settings - Fork 208
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: CNS-962-user-spec-implementation #1505
base: main
Are you sure you want to change the base?
Changes from 10 commits
1ad1f44
1579241
58829d2
483cae8
5b718b0
7779667
bc9ddd5
201d125
dd85e14
01c19f6
2a428a2
09c2d5f
ad77459
0408d11
c5d1cd1
b6d7ac6
803020a
f9c5426
6925623
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,5 @@ message Spec { | |
]; | ||
uint64 shares = 19; | ||
string identity = 20; | ||
bool user_spec = 21; | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,7 +277,7 @@ func (k msgServer) RelayPayment(goCtx context.Context, msg *types.MsgRelayPaymen | |
utils.LogLavaEvent(ctx, logger, types.RelayPaymentEventName, successDetails, "New Proof Of Work Was Accepted") | ||
|
||
cuAfterQos := rewardedCUDec.TruncateInt().Uint64() | ||
err = k.chargeCuToSubscriptionAndCreditProvider(ctx, project, relay, cuAfterQos) | ||
err = k.chargeCuToSubscriptionAndCreditProvider(ctx, project, relay, cuAfterQos, spec.UserSpec) | ||
if err != nil { | ||
return nil, utils.LavaFormatError("Failed charging CU to project and subscription", err) | ||
} | ||
|
@@ -393,7 +393,7 @@ func (k EpochCuCache) updateProvidersComplainerCU(ctx sdk.Context, unresponsiveP | |
return nil | ||
} | ||
|
||
func (k Keeper) chargeCuToSubscriptionAndCreditProvider(ctx sdk.Context, project projectstypes.Project, relay *types.RelaySession, cuAfterQos uint64) error { | ||
func (k Keeper) chargeCuToSubscriptionAndCreditProvider(ctx sdk.Context, project projectstypes.Project, relay *types.RelaySession, cuAfterQos uint64, userSpec bool) error { | ||
epoch := uint64(relay.Epoch) | ||
|
||
err := k.projectsKeeper.ChargeComputeUnitsToProject(ctx, project, epoch, relay.CuSum) | ||
omerlavanet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -406,7 +406,7 @@ func (k Keeper) chargeCuToSubscriptionAndCreditProvider(ctx sdk.Context, project | |
return fmt.Errorf("failed to add CU to the subscription") | ||
} | ||
|
||
err = k.subscriptionKeeper.AddTrackedCu(ctx, sub.Consumer, relay.Provider, relay.SpecId, cuAfterQos, sub.Block) | ||
err = k.subscriptionKeeper.AddTrackedCu(ctx, sub.Consumer, relay.Provider, relay.SpecId, cuAfterQos, sub.Block, userSpec) | ||
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. Ensure the new parameter The addition of the |
||
if err != nil { | ||
return err | ||
} | ||
|
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.
Consider adding more detailed error messages or handling for the
chargeCuToSubscriptionAndCreditProvider
function.This function now includes a
userSpec
boolean which affects the charging logic. However, the error messages could be more descriptive to help in debugging, especially sinceuserSpec
influences the flow. Consider enhancing the error handling to provide more context about the failure, particularly howuserSpec
impacts the outcome.