Skip to content

Commit

Permalink
deployment/ccip/changeset: use singular GetChainConfig (#15601)
Browse files Browse the repository at this point in the history
* deployment/ccip/changeset: use singular GetChainConfig

Use the singular GetChainConfig method on CCIPHome to get the chain
config of a particular chain instead of GetAllChainConfigs.

* more info in error
  • Loading branch information
makramkd authored Dec 10, 2024
1 parent 0e0d19e commit 4eca0ec
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions deployment/ccip/changeset/cs_add_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,14 @@ func (a AddDonAndSetCandidateChangesetConfig) Validate(e deployment.Environment,
}

// check that chain config is set up for the new chain
// TODO: feels like we should just have a getter for a particular chain, this pagination
// logic seems a bit out of place here.
allConfigs, err := state.Chains[a.HomeChainSelector].CCIPHome.GetAllChainConfigs(nil, big.NewInt(0), big.NewInt(100))
chainConfig, err := state.Chains[a.HomeChainSelector].CCIPHome.GetChainConfig(nil, a.NewChainSelector)
if err != nil {
return nil, fmt.Errorf("get all chain configs: %w", err)
}
var found bool
for _, chainConfig := range allConfigs {
if chainConfig.ChainSelector == a.NewChainSelector {
found = true
break
}
}
if !found {
return nil, fmt.Errorf("chain config not set for chain %d", a.NewChainSelector)

// FChain should never be zero if a chain config is set in CCIPHome
if chainConfig.FChain == 0 {
return nil, fmt.Errorf("chain config not set up for new chain %d", a.NewChainSelector)
}

err = a.CCIPOCRParams.Validate()
Expand Down

0 comments on commit 4eca0ec

Please sign in to comment.