Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/web-ui/cosmos-kit/co…
Browse files Browse the repository at this point in the history
…re-2.7.8
  • Loading branch information
faddat authored Dec 10, 2023
2 parents 4b10120 + b065c99 commit 9c8a2bc
Show file tree
Hide file tree
Showing 11 changed files with 336 additions and 52 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
name: build quicksilver
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20.11"
env:
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
name: test quicksilver
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20.11"
env:
Expand Down Expand Up @@ -123,7 +123,7 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20.5"
- name: Run simulation tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19.5
# Initializes the CodeQL tools for scanning.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20.11"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'
cache: false
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}

- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20.5"

Expand All @@ -57,7 +57,7 @@ jobs:
needs: build-and-push-image
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.20.5"
id: go
Expand All @@ -74,7 +74,7 @@ jobs:
needs: build-and-push-image
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.20.5"
id: go
Expand All @@ -91,7 +91,7 @@ jobs:
needs: build-and-push-image
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.20.5"
id: go
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20.5"

Expand Down
23 changes: 0 additions & 23 deletions x/interchainstaking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,29 +416,6 @@ func (k *Keeper) SetValidatorForZone(ctx sdk.Context, zone *types.Zone, data []b
return nil
}

func (k *Keeper) UpdateWithdrawalRecordsForSlash(ctx sdk.Context, zone *types.Zone, valoper string, delta sdk.Dec) error {
var err error
k.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, types.WithdrawStatusUnbond, func(_ int64, record types.WithdrawalRecord) bool {
recordSubAmount := sdkmath.ZeroInt()
distr := record.Distribution
for _, d := range distr {
if d.Valoper != valoper {
continue
}
newAmount := sdk.NewDec(int64(d.Amount)).Quo(delta).TruncateInt()
thisSubAmount := sdkmath.NewInt(int64(d.Amount)).Sub(newAmount)
recordSubAmount = recordSubAmount.Add(thisSubAmount)
d.Amount = newAmount.Uint64()
k.Logger(ctx).Info("Updated withdrawal record due to slashing", "valoper", valoper, "old_amount", d.Amount, "new_amount", newAmount.Int64(), "sub_amount", thisSubAmount.Int64())
}
record.Distribution = distr
record.Amount = record.Amount.Sub(sdk.NewCoin(zone.BaseDenom, recordSubAmount))
k.SetWithdrawalRecord(ctx, record)
return false
})
return err
}

func (k *Keeper) depositInterval(ctx sdk.Context) zoneItrFn {
return func(index int64, zone *types.Zone) (stop bool) {
if zone.DepositAddress != nil {
Expand Down
37 changes: 37 additions & 0 deletions x/interchainstaking/keeper/withdrawal_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package keeper
import (
"encoding/binary"
"encoding/hex"
"fmt"
"time"

sdkmath "cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -222,3 +225,37 @@ func (k *Keeper) AllZoneUnbondingRecords(ctx sdk.Context, chainID string) []type
})
return records
}

func (k *Keeper) UpdateWithdrawalRecordsForSlash(ctx sdk.Context, zone *types.Zone, valoper string, delta sdk.Dec) error {
var err error
k.IterateZoneStatusWithdrawalRecords(ctx, zone.ChainId, types.WithdrawStatusUnbond, func(_ int64, record types.WithdrawalRecord) bool {
recordSubAmount := sdkmath.ZeroInt()
distr := record.Distribution
for _, d := range distr {
if d.Valoper != valoper {
continue
}
distAmount := sdk.NewDec(int64(d.Amount))
if distAmount.IsNegative() {
err = fmt.Errorf("distAmount cannot be negative; suspected overflow")
return true
}

newAmount := distAmount.Quo(delta).TruncateInt()
thisSubAmount := distAmount.TruncateInt().Sub(newAmount)
recordSubAmount = recordSubAmount.Add(thisSubAmount)
d.Amount = newAmount.Uint64()
k.Logger(ctx).Info("Updated withdrawal record due to slashing", "valoper", valoper, "old_amount", d.Amount, "new_amount", newAmount.Int64(), "sub_amount", thisSubAmount.Int64())
}
record.Distribution = distr
subAmount := sdk.NewCoins(sdk.NewCoin(zone.BaseDenom, recordSubAmount))
if !record.Amount.IsAllGT(subAmount) {
err = fmt.Errorf("deductedTotal cannot contain negative coins; suspected overflow")
return true
}
record.Amount = record.Amount.Sub(subAmount...)
k.SetWithdrawalRecord(ctx, record)
return false
})
return err
}
Loading

0 comments on commit 9c8a2bc

Please sign in to comment.