diff --git a/sin-executor/config/config.go b/sin-executor/config/config.go index 015bce6cda..586e24b41e 100644 --- a/sin-executor/config/config.go +++ b/sin-executor/config/config.go @@ -9,7 +9,7 @@ import ( // Config is the config for the Synapse module. type Config struct { // Chains is a map of chain IDs to execution service contract addresses. - Chains map[int]ChainConfig `yaml:"chains"` + Chains []ChainConfig `yaml:"chains"` // OmnirpcURL is the URL of the Omni RPC. OmnirpcURL string `yaml:"omnirpc_url"` // Database is the database config. @@ -21,6 +21,8 @@ type Config struct { } type ChainConfig struct { + // ChainID is the chain ID. + ChainID int `yaml:"id"` // ExecutionService is the address of the execution service contract. ExecutionService string `yaml:"execution_service"` // Client is the address of the interchain client contract. diff --git a/sin-executor/executor/executor.go b/sin-executor/executor/executor.go index c8f323277b..f8fee0c4e6 100644 --- a/sin-executor/executor/executor.go +++ b/sin-executor/executor/executor.go @@ -3,11 +3,12 @@ package executor import ( "context" "fmt" - "github.com/synapsecns/sanguine/core" - "github.com/synapsecns/sanguine/sin-executor/contracts/executionservice" "math/big" "time" + "github.com/synapsecns/sanguine/core" + "github.com/synapsecns/sanguine/sin-executor/contracts/executionservice" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -60,10 +61,10 @@ func NewExecutor(ctx context.Context, handler metrics.Handler, cfg config.Config executor.chainListeners = make(map[int]listener.ContractListener) executor.clientContracts = make(map[int]*interchainclient.InterchainClientRef) - for chainID, chainCfg := range cfg.Chains { + for _, chainCfg := range cfg.Chains { executionService := common.HexToAddress(chainCfg.ExecutionService) interchainClient := common.HexToAddress(chainCfg.Client) - chainClient, err := executor.client.GetChainClient(ctx, chainID) + chainClient, err := executor.client.GetChainClient(ctx, chainCfg.ChainID) if err != nil { return nil, fmt.Errorf("could not get chain client: %w", err) } @@ -72,9 +73,9 @@ func NewExecutor(ctx context.Context, handler metrics.Handler, cfg config.Config if err != nil { return nil, fmt.Errorf("could not get chain listener: %w", err) } - executor.chainListeners[chainID] = chainListener + executor.chainListeners[chainCfg.ChainID] = chainListener - executor.clientContracts[chainID], err = interchainclient.NewInterchainClientRef(interchainClient, chainClient) + executor.clientContracts[chainCfg.ChainID], err = interchainclient.NewInterchainClientRef(interchainClient, chainClient) if err != nil { return nil, fmt.Errorf("could not get synapse module ref: %w", err) } @@ -226,8 +227,8 @@ func (e *Executor) startChainIndexers(ctx context.Context) error { g, ctx := errgroup.WithContext(ctx) // TODO: good chance we wanna prepare these chain listeners up front and then listen later. - for chainID := range e.cfg.Chains { - chainID := chainID // capture func litera + for _, chain := range e.cfg.Chains { + chainID := chain.ChainID // capture func litera g.Go(func() error { err := e.runChainIndexer(ctx, chainID) diff --git a/sin-executor/executor/suite_test.go b/sin-executor/executor/suite_test.go index b33d717ed6..be5a876942 100644 --- a/sin-executor/executor/suite_test.go +++ b/sin-executor/executor/suite_test.go @@ -3,6 +3,10 @@ package executor_test import ( "context" "errors" + "math/big" + "sync" + "testing" + "github.com/Flaque/filet" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -22,9 +26,6 @@ import ( "github.com/synapsecns/sanguine/sin-executor/contracts/interchainclient" "github.com/synapsecns/sanguine/sin-executor/executor" "github.com/synapsecns/sanguine/sin-executor/testutil" - "math/big" - "sync" - "testing" ) // InterchainSuite is a test suite for the interchain package. @@ -135,12 +136,14 @@ func (i *InterchainSuite) makeExecutor() { destOwner, execServiceDest := i.deployManager.GetExecutionService(i.GetTestContext(), i.destChain) cfg := config.Config{ - Chains: map[int]config.ChainConfig{ - 1: { + Chains: []config.ChainConfig{ + { + ChainID: 1, ExecutionService: execServiceOrigin.Address().String(), Client: i.originModule.Address().String(), }, - 2: { + { + ChainID: 2, ExecutionService: execServiceDest.Address().String(), Client: i.destModule.Address().String(), },