Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,14 @@ func Run() error {
priceAPI := price.NewPricerProxy(multiPricer)
evmSignHandler := evmMessage.NewSignHandler(coordinator, host, communication, keyshareStore)

chainConfigs := config.MergeChainConfigs(configuration.ChainConfigs, *solverConfig)

var hubPoolContract across.TokenMatcher
acrossPools := make(map[uint64]common.Address)
lifiOutputSettlers := make(map[uint64]string)
repayerAddresses := make(map[uint64]common.Address)
tokens := make(map[uint64]map[string]config.TokenConfig)
for _, chainConfig := range configuration.ChainConfigs {
for _, chainConfig := range chainConfigs {
switch chainConfig["type"] {
case "evm":
{
Expand Down Expand Up @@ -230,7 +232,7 @@ func Run() error {
Tokens: tokens,
}

for _, chainConfig := range configuration.ChainConfigs {
for _, chainConfig := range chainConfigs {
switch chainConfig["type"] {
case "evm":
{
Expand Down
40 changes: 40 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

"github.com/creasty/defaults"
"github.com/imdario/mergo"
solverConfig "github.com/sprintertech/solver-config/go/config"
"github.com/sprintertech/solver-sdk/pkg/chains/caip"
"github.com/sprintertech/sprinter-signing/config/relayer"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -135,6 +137,44 @@ func compareDomainID(a, b interface{}) bool {
return false
}

// MergeChainConfigs fills in chains that are present in the shared solver
// config but were not manually configured, deriving their endpoint from the
// solver config's transport so a chain can be supported without a manual
// chain config entry. Manually configured fields always take precedence.
func MergeChainConfigs(chainConfigs []map[string]interface{}, solverConfig solverConfig.SolverConfig) []map[string]interface{} {
for caipID, c := range solverConfig.Chains {
id, err := caip.CAIPToChainID(caipID)
if err != nil {
continue
}

if chainExists(chainConfigs, id) {
continue
}

cc := map[string]interface{}{
"id": id,
"type": "evm",
"name": fmt.Sprintf("chain-%d", id),
"endpoint": c.Transport.HTTP[0],
}
chainConfigs = append(chainConfigs, cc)
}

return chainConfigs
}

func chainExists(chainConfigs []map[string]interface{}, chainID uint64) bool {
for _, cc := range chainConfigs {
ccID := cc["id"].(uint64)
if ccID == chainID {
return true
}
}

return false
}

var (
// Flags for running the app
StagingFlagName = "staging"
Expand Down
66 changes: 66 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"testing"
"time"

solverConfig "github.com/sprintertech/solver-config/go/config"
"github.com/sprintertech/sprinter-signing/config"
"github.com/sprintertech/sprinter-signing/config/relayer"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -579,3 +580,68 @@ func (s *GetConfigTestSuite) Test_GetConfigFromFile() {
})
}
}

type MergeChainConfigsTestSuite struct {
suite.Suite
}

func TestRunMergeChainConfigsTestSuite(t *testing.T) {
suite.Run(t, new(MergeChainConfigsTestSuite))
}

func (s *MergeChainConfigsTestSuite) Test_MergeChainConfigs_AddsChainFromSolverConfig() {
solverChains := map[string]solverConfig.Chain{
"eip155:10": {
Transport: solverConfig.Transport{
HTTP: []string{"https://chain10.example"},
},
},
}

merged := config.MergeChainConfigs(nil, solverConfig.SolverConfig{Chains: solverChains})

s.Len(merged, 1)
s.Equal(map[string]interface{}{
"id": uint64(10),
"type": "evm",
"name": "chain-10",
"endpoint": "https://chain10.example",
}, merged[0])
}

func (s *MergeChainConfigsTestSuite) Test_MergeChainConfigs_ManuallyConfiguredChainNotOverwritten() {
solverChains := map[string]solverConfig.Chain{
"eip155:10": {
Transport: solverConfig.Transport{
HTTP: []string{"https://chain10.example"},
},
},
}

manual := []map[string]interface{}{
{
"id": uint64(10),
"endpoint": "https://custom.example",
"admin": "adminAddress",
},
}

merged := config.MergeChainConfigs(manual, solverConfig.SolverConfig{Chains: solverChains})

s.Equal(manual, merged)
}

func (s *MergeChainConfigsTestSuite) Test_MergeChainConfigs_KeepsManualOnlyChains() {
manual := []map[string]interface{}{
{
"id": uint64(99),
"type": "evm",
"endpoint": "https://manual-only.example",
"name": "manual99",
},
}

merged := config.MergeChainConfigs(manual, solverConfig.SolverConfig{})

s.Equal(manual, merged)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/spf13/cobra v1.10.2
github.com/spf13/viper v1.9.0
github.com/sprintertech/solver-config/go v0.0.0-20260819115035-7b1b83250ca4
github.com/sprintertech/solver-sdk v1.1.1-0.20260825101026-32c00a9704e6
github.com/sprintertech/solver-sdk v1.1.1-0.20260827154133-1e8cff30b44b
github.com/stretchr/testify v1.11.1
github.com/sygmaprotocol/sygma-core v0.0.0-20250304150334-bd39ac4f7b82
go.opentelemetry.io/otel v1.39.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,8 @@ github.com/sprintertech/solver-sdk v1.1.1-0.20260821104752-6a3c113a5958 h1:++m9Z
github.com/sprintertech/solver-sdk v1.1.1-0.20260821104752-6a3c113a5958/go.mod h1:6euNIW0DgGI/RfIvpZJgnvoVcd1PmzE1T20C0dXnyrc=
github.com/sprintertech/solver-sdk v1.1.1-0.20260825101026-32c00a9704e6 h1:0bfmInjG3+ak7E65LVBVOQxArztBSZw49iNY9dpfS8I=
github.com/sprintertech/solver-sdk v1.1.1-0.20260825101026-32c00a9704e6/go.mod h1:A9fQAvneC86+z0ib2cb+yTOV84olOqcBZxomj1pe3bc=
github.com/sprintertech/solver-sdk v1.1.1-0.20260827154133-1e8cff30b44b h1:Xfr0QWclvoL0OGtjMrFTxoDU66JQHwBR8u1LdRYLba8=
github.com/sprintertech/solver-sdk v1.1.1-0.20260827154133-1e8cff30b44b/go.mod h1:A9fQAvneC86+z0ib2cb+yTOV84olOqcBZxomj1pe3bc=
github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
Expand Down
Loading