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

fix(slash): Fix no slash info #199

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
643a0ea
detail the return error for operator info
TimmyExogenous Sep 5, 2024
50ed377
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 6, 2024
eb69bbd
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 10, 2024
b75ee4d
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 10, 2024
ae24f6b
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 11, 2024
ff65b01
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 17, 2024
d5660be
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 19, 2024
063417a
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 20, 2024
7009f0c
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 20, 2024
dac10ab
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 23, 2024
3b58f4e
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 24, 2024
686a808
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 24, 2024
27fac4f
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 24, 2024
66bbf7e
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 25, 2024
7174462
Merge remote-tracking branch 'upstream/develop' into develop
TimmyExogenous Sep 26, 2024
333d022
fix the issue regarding no slash info
TimmyExogenous Sep 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions x/delegation/keeper/delegation_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ func (k *Keeper) DeleteStakersListForOperator(ctx sdk.Context, operator, assetID
return nil
}

func (k Keeper) HasStakerList(ctx sdk.Context, operator, assetID string) bool {
store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixStakersByOperator)
Key := assetstype.GetJoinedStoreKey(operator, assetID)
return store.Has(Key)
}

func (k Keeper) GetStakersByOperator(ctx sdk.Context, operator, assetID string) (delegationtype.StakerList, error) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), delegationtype.KeyPrefixStakersByOperator)
Key := assetstype.GetJoinedStoreKey(operator, assetID)
Expand Down
3 changes: 2 additions & 1 deletion x/operator/keeper/slash.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func (k *Keeper) SlashAssets(ctx sdk.Context, parameter *types.SlashInputInfo) (
// all shares need to be cleared if the asset amount is slashed to zero,
// otherwise there will be a problem in updating the shares when handling
// the new delegations.
if remainingAmount.IsZero() {
if remainingAmount.IsZero() &&
k.delegationKeeper.HasStakerList(ctx, parameter.Operator.String(), assetID) {
// clear the share of other stakers
stakerList, err := k.delegationKeeper.GetStakersByOperator(ctx, parameter.Operator.String(), assetID)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions x/operator/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type DelegationKeeper interface {
IterateUndelegationsByOperator(
ctx sdk.Context, operator string, heightFilter *uint64, isUpdate bool,
opFunc func(undelegation *delegationtype.UndelegationRecord) error) error
HasStakerList(ctx sdk.Context, operator, assetID string) bool
GetStakersByOperator(
ctx sdk.Context, operator, assetID string,
) (delegationtype.StakerList, error)
Expand Down
Loading