Skip to content

Commit

Permalink
fix: use consumerID for consumer chains if available
Browse files Browse the repository at this point in the history
  • Loading branch information
fastfadingviolets committed Sep 4, 2024
1 parent c9e34af commit f438383
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions chain/cosmos/ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit f438383

Please sign in to comment.