From 25cde6ff63b8005c16ee9d13ade3584cbae10ff4 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:39:50 +0000 Subject: [PATCH] fix(dogfood): add `operator` stateful validation The dogfood module accepts a list of validators as input. These validators must be registered within the operator module for the chain's ChainID. --- x/dogfood/keeper/genesis.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/x/dogfood/keeper/genesis.go b/x/dogfood/keeper/genesis.go index 14bea8ccc..2b9421f77 100644 --- a/x/dogfood/keeper/genesis.go +++ b/x/dogfood/keeper/genesis.go @@ -34,6 +34,14 @@ func (k Keeper) InitGenesis( for _, val := range genState.InitialValSet { // #nosec G703 // already validated consKey, _ := operatortypes.HexStringToPubKey(val.PublicKey) + // #nosec G601 // this only fails if the key is of a type not already defined. + consAddr, _ := operatortypes.TMCryptoPublicKeyToConsAddr(consKey) + found, _ := k.operatorKeeper.GetOperatorAddressForChainIDAndConsAddr( + ctx, ctx.ChainID(), consAddr, + ) + if !found { + panic(fmt.Sprintf("operator not found: %s", consAddr)) + } out = append(out, abci.ValidatorUpdate{ PubKey: *consKey, Power: val.Power,