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 92fb097
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions chain/cosmos/ics.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,17 @@ 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()
}
panic(consumerID)

// Copy provider priv val keys to these nodes
for i, val := range c.Provider.Validators {
i := i
Expand All @@ -265,7 +276,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 +324,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 92fb097

Please sign in to comment.