Skip to content

Commit 569418b

Browse files
committed
enhance oracle participant params check
1 parent f966c04 commit 569418b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

x/dlc/keeper/msg_server.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ func (m msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParam
5353

5454
ctx := sdk.UnwrapSDKContext(goCtx)
5555

56-
if len(msg.Params.AllowedOracleParticipants) != 0 {
57-
baseParticipants := m.tssKeeper.AllowedDKGParticipants(ctx)
58-
59-
if len(baseParticipants) != 0 {
60-
for _, p := range msg.Params.AllowedOracleParticipants {
61-
if !slices.Contains(baseParticipants, p) {
62-
return nil, errorsmod.Wrap(types.ErrInvalidParams, "oracle participant not authorized")
63-
}
56+
baseParticipants := m.tssKeeper.AllowedDKGParticipants(ctx)
57+
58+
if len(msg.Params.AllowedOracleParticipants) != 0 && len(baseParticipants) != 0 {
59+
for _, p := range msg.Params.AllowedOracleParticipants {
60+
if !slices.Contains(baseParticipants, p) {
61+
return nil, errorsmod.Wrap(types.ErrInvalidParams, "oracle participant not authorized")
6462
}
6563
}
64+
} else if len(baseParticipants) != 0 {
65+
if msg.Params.OracleParticipantNum > uint32(len(baseParticipants)) {
66+
return nil, errorsmod.Wrapf(types.ErrInvalidParams, "oracle participant number cannot be greater than allowed participant number %d", len(baseParticipants))
67+
}
6668
}
6769

6870
m.SetParams(ctx, msg.Params)

0 commit comments

Comments
 (0)