Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 2325968

Browse files
authored
fix: LSM Bond Factor Validation (#637)
* bond factor fix * changelog * tests
1 parent 745ce1a commit 2325968

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
## [Unreleased]
3838

39+
### Bug Fixes
40+
41+
- [#637](https://github.com/persistenceOne/pstake-native/pull/637) LSM bond factor validation fix.
42+
3943
## [v2.3.0] - 2023-09-06
4044

4145
### Features

x/liquidstakeibc/types/msgs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ func (m *MsgUpdateHostChain) ValidateBasic() error {
298298
}
299299

300300
// -1 is the default bond factor value
301-
if !bondFactor.Equal(sdk.NewDec(-1)) || bondFactor.GTE(sdk.ZeroDec()) {
302-
return sdkerrors.ErrInvalidRequest.Wrapf("invalid validator bond factor value should be -1 == bond factor >= 0")
301+
if bondFactor.LT(sdk.ZeroDec()) && !bondFactor.Equal(sdk.NewDec(-1)) {
302+
return sdkerrors.ErrInvalidRequest.Wrapf("invalid validator bond factor value should be bond_factor == -1 || bond_factor >= 0")
303303
}
304304
case KeyMinimumDeposit:
305305
minimumDeposit, ok := sdk.NewIntFromString(update.Value)

x/liquidstakeibc/types/msgs_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,24 @@ func TestMsgUpdateHostChain(t *testing.T) {
231231
}, {
232232
Key: types.KeyMinimumDeposit,
233233
Value: "1",
234+
}, {
235+
Key: types.KeyLSMValidatorCap,
236+
Value: "0",
237+
}, {
238+
Key: types.KeyLSMValidatorCap,
239+
Value: "1",
240+
}, {
241+
Key: types.KeyLSMValidatorCap,
242+
Value: "0.5",
243+
}, {
244+
Key: types.KeyLSMBondFactor,
245+
Value: "-1",
246+
}, {
247+
Key: types.KeyLSMBondFactor,
248+
Value: "250",
249+
}, {
250+
Key: types.KeyLSMBondFactor,
251+
Value: "0",
234252
}, {
235253
Key: types.KeyActive,
236254
Value: "true",
@@ -307,6 +325,18 @@ func TestMsgUpdateHostChain(t *testing.T) {
307325
}, {
308326
Key: types.KeyRedemptionFee,
309327
Value: "invalidDec",
328+
}, {
329+
Key: types.KeyLSMValidatorCap,
330+
Value: "-0.5",
331+
}, {
332+
Key: types.KeyLSMValidatorCap,
333+
Value: "2",
334+
}, {
335+
Key: types.KeyLSMBondFactor,
336+
Value: "-0.5",
337+
}, {
338+
Key: types.KeyLSMBondFactor,
339+
Value: "-1.5",
310340
}, {
311341
Key: types.KeyMinimumDeposit,
312342
Value: "0",

0 commit comments

Comments
 (0)