Skip to content

Commit

Permalink
fix: LSM Bond Factor Validation (#637)
Browse files Browse the repository at this point in the history
* bond factor fix

* changelog

* tests
  • Loading branch information
kruspy authored Sep 6, 2023
1 parent 745ce1a commit 2325968
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Bug Fixes

- [#637](https://github.com/persistenceOne/pstake-native/pull/637) LSM bond factor validation fix.

## [v2.3.0] - 2023-09-06

### Features
Expand Down
4 changes: 2 additions & 2 deletions x/liquidstakeibc/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ func (m *MsgUpdateHostChain) ValidateBasic() error {
}

// -1 is the default bond factor value
if !bondFactor.Equal(sdk.NewDec(-1)) || bondFactor.GTE(sdk.ZeroDec()) {
return sdkerrors.ErrInvalidRequest.Wrapf("invalid validator bond factor value should be -1 == bond factor >= 0")
if bondFactor.LT(sdk.ZeroDec()) && !bondFactor.Equal(sdk.NewDec(-1)) {
return sdkerrors.ErrInvalidRequest.Wrapf("invalid validator bond factor value should be bond_factor == -1 || bond_factor >= 0")
}
case KeyMinimumDeposit:
minimumDeposit, ok := sdk.NewIntFromString(update.Value)
Expand Down
30 changes: 30 additions & 0 deletions x/liquidstakeibc/types/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,24 @@ func TestMsgUpdateHostChain(t *testing.T) {
}, {
Key: types.KeyMinimumDeposit,
Value: "1",
}, {
Key: types.KeyLSMValidatorCap,
Value: "0",
}, {
Key: types.KeyLSMValidatorCap,
Value: "1",
}, {
Key: types.KeyLSMValidatorCap,
Value: "0.5",
}, {
Key: types.KeyLSMBondFactor,
Value: "-1",
}, {
Key: types.KeyLSMBondFactor,
Value: "250",
}, {
Key: types.KeyLSMBondFactor,
Value: "0",
}, {
Key: types.KeyActive,
Value: "true",
Expand Down Expand Up @@ -307,6 +325,18 @@ func TestMsgUpdateHostChain(t *testing.T) {
}, {
Key: types.KeyRedemptionFee,
Value: "invalidDec",
}, {
Key: types.KeyLSMValidatorCap,
Value: "-0.5",
}, {
Key: types.KeyLSMValidatorCap,
Value: "2",
}, {
Key: types.KeyLSMBondFactor,
Value: "-0.5",
}, {
Key: types.KeyLSMBondFactor,
Value: "-1.5",
}, {
Key: types.KeyMinimumDeposit,
Value: "0",
Expand Down

0 comments on commit 2325968

Please sign in to comment.