Skip to content

Commit 87146c3

Browse files
committed
refactor
1 parent df2dfd0 commit 87146c3

5 files changed

Lines changed: 1181 additions & 742 deletions

File tree

deployment/ccip/shared/stateview/evm/state.go

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package evm
22

33
import (
4-
"context"
54
"errors"
65
"fmt"
76

@@ -476,22 +475,6 @@ func (c CCIPChainState) ValidateOnRamp(
476475
return nil
477476
}
478477

479-
// chainSelFromConfigs extracts the chain selector from CCIPHome configs,
480-
// falling back through active→candidate for both commit and exec.
481-
func chainSelFromConfigs(commit, exec ccip_home.GetAllConfigs) uint64 {
482-
sel := commit.ActiveConfig.Config.ChainSelector
483-
if sel == 0 {
484-
sel = commit.CandidateConfig.Config.ChainSelector
485-
}
486-
if sel == 0 {
487-
sel = exec.ActiveConfig.Config.ChainSelector
488-
if sel == 0 {
489-
sel = exec.CandidateConfig.Config.ChainSelector
490-
}
491-
}
492-
return sel
493-
}
494-
495478
// ValidateRouter validates the router contract and returns all connected v1.6 chains.
496479
// v16ActiveChains filters out legacy v1.5 lane entries in mixed environments.
497480
func (c CCIPChainState) ValidateRouter(e cldf.Environment, isTestRouter bool, v16ActiveChains map[uint64]bool) ([]uint64, error) {
@@ -554,37 +537,6 @@ func (c CCIPChainState) ValidateRouter(e cldf.Environment, isTestRouter bool, v1
554537
return v16ConnectedChains, nil
555538
}
556539

557-
// V16ActiveChainSelectors returns chain selectors with an active or candidate
558-
// v1.6 DON config in CCIPHome. Home chain only.
559-
func (c CCIPChainState) V16ActiveChainSelectors(ctx context.Context) (map[uint64]bool, error) {
560-
if c.CCIPHome == nil {
561-
return nil, errors.New("no CCIPHome contract found in the state")
562-
}
563-
if c.CapabilityRegistry == nil {
564-
return nil, errors.New("no CapabilityRegistry contract found in the state")
565-
}
566-
ccipDons, err := shared.GetCCIPDonsFromCapRegistry(ctx, c.CapabilityRegistry)
567-
if err != nil {
568-
return nil, fmt.Errorf("failed to get CCIP DONs from capability registry: %w", err)
569-
}
570-
callOpts := &bind.CallOpts{Context: ctx}
571-
active := make(map[uint64]bool, len(ccipDons))
572-
for _, don := range ccipDons {
573-
commitConfigs, err := c.CCIPHome.GetAllConfigs(callOpts, don.Id, uint8(types.PluginTypeCCIPCommit))
574-
if err != nil {
575-
continue
576-
}
577-
execConfigs, err := c.CCIPHome.GetAllConfigs(callOpts, don.Id, uint8(types.PluginTypeCCIPExec))
578-
if err != nil {
579-
continue
580-
}
581-
if chainSel := chainSelFromConfigs(commitConfigs, execConfigs); chainSel != 0 {
582-
active[chainSel] = true
583-
}
584-
}
585-
return active, nil
586-
}
587-
588540
// ValidateRMNRemote validates the RMNRemote contract to check if all wired contracts are synced with state
589541
// and returns whether RMN is enabled for the chain on the RMNRemote
590542
// It validates whether RMNRemote is in sync with the RMNHome contract

0 commit comments

Comments
 (0)