wormchain: wormhole: Check for duplicate guardian addresses
When updating the guardian set via a governance action, make sure that there are no duplicate addresses in the set.
This commit is contained in:
parent
b38180bf5d
commit
2fcfb7f769
|
@ -80,9 +80,17 @@ func (k msgServer) ExecuteGovernanceVAA(goCtx context.Context, msg *types.MsgExe
|
|||
if len(payload) != 5+20*numGuardians {
|
||||
return nil, types.ErrInvalidGovernancePayloadLength
|
||||
}
|
||||
|
||||
added := make(map[string]bool)
|
||||
var keys [][]byte
|
||||
for i := 0; i < numGuardians; i++ {
|
||||
keys = append(keys, payload[5+i*20:5+i*20+20])
|
||||
k := payload[5+i*20 : 5+i*20+20]
|
||||
sk := string(k)
|
||||
if _, found := added[sk]; found {
|
||||
return nil, types.ErrDuplicateGuardianAddress
|
||||
}
|
||||
keys = append(keys, k)
|
||||
added[sk] = true
|
||||
}
|
||||
|
||||
err := k.UpdateGuardianSet(ctx, types.GuardianSet{
|
||||
|
|
|
@ -28,4 +28,5 @@ var (
|
|||
ErrConsensusSetUndefined = sdkerrors.Register(ModuleName, 1117, "no consensus set defined")
|
||||
ErrGuardianSetExpired = sdkerrors.Register(ModuleName, 1118, "guardian set expired")
|
||||
ErrNewGuardianSetHasExpiry = sdkerrors.Register(ModuleName, 1119, "new guardian set should not have expiry time")
|
||||
ErrDuplicateGuardianAddress = sdkerrors.Register(ModuleName, 1120, "guardian set has duplicate addresses")
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue