wormchain: wormhole: Check for multiple validator registration.
Don't allow a tx signer to register more than one guardian validator.
This commit is contained in:
parent
2fcfb7f769
commit
727a3e869d
|
@ -1,6 +1,7 @@
|
||||||
package keeper
|
package keeper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
@ -55,6 +56,13 @@ func (k msgServer) RegisterAccountAsGuardian(goCtx context.Context, msg *types.M
|
||||||
return nil, types.ErrGuardianNotFound
|
return nil, types.ErrGuardianNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the tx signer was already registered as a guardian validator.
|
||||||
|
for _, gv := range k.GetAllGuardianValidator(ctx) {
|
||||||
|
if bytes.Equal(gv.ValidatorAddr, signer) {
|
||||||
|
return nil, types.ErrSignerAlreadyRegistered
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// register validator in store for guardian
|
// register validator in store for guardian
|
||||||
k.Keeper.SetGuardianValidator(ctx, types.GuardianValidator{
|
k.Keeper.SetGuardianValidator(ctx, types.GuardianValidator{
|
||||||
GuardianKey: guardianKeyAddr.Bytes(),
|
GuardianKey: guardianKeyAddr.Bytes(),
|
||||||
|
|
|
@ -29,4 +29,5 @@ var (
|
||||||
ErrGuardianSetExpired = sdkerrors.Register(ModuleName, 1118, "guardian set expired")
|
ErrGuardianSetExpired = sdkerrors.Register(ModuleName, 1118, "guardian set expired")
|
||||||
ErrNewGuardianSetHasExpiry = sdkerrors.Register(ModuleName, 1119, "new guardian set should not have expiry time")
|
ErrNewGuardianSetHasExpiry = sdkerrors.Register(ModuleName, 1119, "new guardian set should not have expiry time")
|
||||||
ErrDuplicateGuardianAddress = sdkerrors.Register(ModuleName, 1120, "guardian set has duplicate addresses")
|
ErrDuplicateGuardianAddress = sdkerrors.Register(ModuleName, 1120, "guardian set has duplicate addresses")
|
||||||
|
ErrSignerAlreadyRegistered = sdkerrors.Register(ModuleName, 1121, "transaction signer already registered as a guardian validator")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue