From f438383ea2d0f16cd26d7c594e7f3e41bfa966b9 Mon Sep 17 00:00:00 2001 From: violet Date: Wed, 4 Sep 2024 15:33:52 -0400 Subject: [PATCH] fix: use consumerID for consumer chains if available --- chain/cosmos/ics.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/chain/cosmos/ics.go b/chain/cosmos/ics.go index 4f6e83e92..9a77bbd1d 100644 --- a/chain/cosmos/ics.go +++ b/chain/cosmos/ics.go @@ -245,6 +245,16 @@ func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additi return err } + consumerID := c.cfg.ChainID + consumerChains, _, err := c.Provider.GetNode().ExecQuery(ctx, "provider", "list-consumer-chains") + if err != nil { + return err + } + consumerChain := gjson.GetBytes(consumerChains, fmt.Sprintf("chains.#(chain_id=%q)", c.cfg.ChainID)) + if consumerChain.Get("consumer_id").Exists() { + consumerID = consumerChain.Get("consumer_id").String() + } + // Copy provider priv val keys to these nodes for i, val := range c.Provider.Validators { i := i @@ -265,7 +275,7 @@ func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additi return fmt.Errorf("failed to get consumer validator pubkey: %w", err) } keyStr := strings.TrimSpace(string(key)) - _, err = c.Provider.Validators[i].ExecTx(ctx, valKey, "provider", "assign-consensus-key", c.cfg.ChainID, keyStr) + _, err = c.Provider.Validators[i].ExecTx(ctx, valKey, "provider", "assign-consensus-key", consumerID, keyStr) if err != nil { return fmt.Errorf("failed to assign consumer validator pubkey: %w", err) } @@ -313,7 +323,7 @@ func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additi return err } - ccvStateMarshaled, _, err := c.Provider.GetNode().ExecQuery(ctx, "provider", "consumer-genesis", c.cfg.ChainID) + ccvStateMarshaled, _, err := c.Provider.GetNode().ExecQuery(ctx, "provider", "consumer-genesis", consumerID) if err != nil { return fmt.Errorf("failed to query provider for ccv state: %w", err) }