Skip to content

Commit 62acf4e

Browse files
committed
1 parent 07180cc commit 62acf4e

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

x/gov/keeper/msg_server.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,33 @@ func (k msgServer) UpdateParams(goCtx context.Context, msg *v1.MsgUpdateParams)
272272
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
273273
}
274274

275+
// before params change, trigger an update of the last min deposit
276+
ctx := sdk.UnwrapSDKContext(goCtx)
277+
blockTime := ctx.BlockTime()
278+
minDeposit := k.GetMinDeposit(ctx)
279+
newMinDeposit := v1.GetNewMinDeposit(msg.Params.MinDepositThrottler.FloorValue, minDeposit, math.LegacyOneDec())
280+
281+
if !minDeposit.Equal(newMinDeposit) {
282+
k.LastMinDeposit.Set(ctx, v1.LastMinDeposit{
283+
Value: newMinDeposit,
284+
Time: &blockTime,
285+
})
286+
}
287+
288+
minInitialDeposit := k.GetMinInitialDeposit(ctx)
289+
newMinInitialDeposit := v1.GetNewMinDeposit(msg.Params.MinInitialDepositThrottler.FloorValue, minInitialDeposit, math.LegacyOneDec())
290+
291+
if !minInitialDeposit.Equal(newMinInitialDeposit) {
292+
k.LastMinInitialDeposit.Set(ctx, v1.LastMinDeposit{
293+
Value: newMinInitialDeposit,
294+
Time: &blockTime,
295+
})
296+
}
297+
275298
if err := msg.Params.ValidateBasic(); err != nil {
276299
return nil, err
277300
}
278301

279-
ctx := sdk.UnwrapSDKContext(goCtx)
280302
if err := k.Params.Set(ctx, msg.Params); err != nil {
281303
return nil, err
282304
}

0 commit comments

Comments
 (0)