Skip to content
Closed
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
14 changes: 8 additions & 6 deletions core/cmd/blocks_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/urfave/cli"

"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink"
)

Expand All @@ -20,12 +19,15 @@ func Test_ReplayFromBlock(t *testing.T) {
c.EVM[0].ChainID = (*sqlutil.Big)(big.NewInt(5))
c.EVM[0].Enabled = ptr(true)

solCfg := &config.TOMLConfig{
ChainID: ptr("devnet"),
Enabled: ptr(true),
c.Solana = chainlink.RawConfigs{
{
"ChainID": "devnet",
"Enabled": true,
"Nodes": []any{
map[string]any{"Name": "primary", "URL": "http://localhost:8899"},
},
},
}
solCfg.SetDefaults()
c.Solana = config.TOMLConfigs{solCfg}
})

client, _ := app.NewShellAndRenderer()
Expand Down
22 changes: 14 additions & 8 deletions core/cmd/node_commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"testing"

"github.com/pelletier/go-toml/v2"
gotoml "github.com/pelletier/go-toml/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -65,13 +65,13 @@ func TestShell_IndexEVMNodes(t *testing.T) {
assert.Equal(t, chainID.String(), n1.ChainID)
assert.Equal(t, cltest.FormatWithPrefixedChainID(chainID.String(), *node1.Name), n1.ID)
assert.Equal(t, *node1.Name, n1.Name)
wantConfig, err := toml.Marshal(node1)
wantConfig, err := gotoml.Marshal(node1)
require.NoError(t, err)
assert.Equal(t, string(wantConfig), n1.Config)
assert.Equal(t, chainID.String(), n2.ChainID)
assert.Equal(t, cltest.FormatWithPrefixedChainID(chainID.String(), *node2.Name), n2.ID)
assert.Equal(t, *node2.Name, n2.Name)
wantConfig2, err := toml.Marshal(node2)
wantConfig2, err := gotoml.Marshal(node2)
require.NoError(t, err)
assert.Equal(t, string(wantConfig2), n2.Config)
assertTableRenders(t, r)
Expand All @@ -97,11 +97,17 @@ func TestShell_IndexEVMNodes(t *testing.T) {
}

func solanaStartNewApplication(t *testing.T, cfgs ...*solcfg.TOMLConfig) *cltest.TestApplication {
for i := range cfgs {
cfgs[i].SetDefaults()
rawCfgs := make(chainlink.RawConfigs, len(cfgs))
for i, c := range cfgs {
c.SetDefaults()
raw, err := gotoml.Marshal(c)
require.NoError(t, err)
var m chainlink.RawConfig
require.NoError(t, gotoml.Unmarshal(raw, &m))
rawCfgs[i] = m
}
return startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Solana = cfgs
c.Solana = rawCfgs
c.EVM = nil
})
}
Expand Down Expand Up @@ -134,13 +140,13 @@ func TestShell_IndexSolanaNodes(t *testing.T) {
assert.Equal(t, id, n1.ChainID)
assert.Equal(t, cltest.FormatWithPrefixedChainID(id, *node1.Name), n1.ID)
assert.Equal(t, *node1.Name, n1.Name)
wantConfig, err := toml.Marshal(node1)
wantConfig, err := gotoml.Marshal(node1)
require.NoError(t, err)
assert.Equal(t, string(wantConfig), n1.Config)
assert.Equal(t, id, n2.ChainID)
assert.Equal(t, cltest.FormatWithPrefixedChainID(id, *node2.Name), n2.ID)
assert.Equal(t, *node2.Name, n2.Name)
wantConfig2, err := toml.Marshal(node2)
wantConfig2, err := gotoml.Marshal(node2)
require.NoError(t, err)
assert.Equal(t, string(wantConfig2), n2.Config)
assertTableRenders(t, r)
Expand Down
14 changes: 8 additions & 6 deletions core/cmd/shell_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-evm/pkg/client/clienttest"
"github.com/smartcontractkit/chainlink-solana/pkg/solana/config"
"github.com/smartcontractkit/chainlink/v2/core/auth"
"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/cmd"
Expand Down Expand Up @@ -123,12 +122,15 @@ func TestShell_ReplayBlocks(t *testing.T) {
c.EVM[0].BalanceMonitor.Enabled = ptr(false)
c.EVM[0].GasEstimator.Mode = ptr("FixedPrice")

solCfg := &config.TOMLConfig{
ChainID: ptr("devnet"),
Enabled: ptr(true),
c.Solana = chainlink.RawConfigs{
{
"ChainID": "devnet",
"Enabled": true,
"Nodes": []any{
map[string]any{"Name": "primary", "URL": "http://localhost:8899"},
},
},
}
solCfg.SetDefaults()
c.Solana = config.TOMLConfigs{solCfg}
})
client, _ := app.NewShellAndRenderer()

Expand Down
114 changes: 46 additions & 68 deletions core/cmd/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/beholder/beholdertest"
commoncfg "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/sqlutil/sqltest"
commonevents "github.com/smartcontractkit/chainlink-protos/workflows/go/common"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"

"github.com/smartcontractkit/chainlink/v2/core/cmd"
"github.com/smartcontractkit/chainlink/v2/core/internal/cltest"
Expand Down Expand Up @@ -358,70 +356,59 @@ func TestNewUserCache(t *testing.T) {
func TestSetupSolanaRelayer(t *testing.T) {
lggr := logger.TestLogger(t)
reg := plugins.NewTestLoopRegistry(lggr)
ks := &keystore.StarknetLooppSigner{StarkNet: mocks.NewStarkNet(t)}
ks := &keystore.SolanaLooppSigner{Solana: mocks.NewSolana(t)}
ksCSA := &keystore.CSASigner{CSA: mocks.NewCSA(t)}
ds := sqltest.NewNoOpDataSource()

// config 3 chains but only enable 2 => should only be 2 relayer
nEnabledChains := 2

tConfig := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Solana = solcfg.TOMLConfigs{
&solcfg.TOMLConfig{
ChainID: ptr[string]("solana-id-1"),
Enabled: ptr(true),
Nodes: []*solcfg.Node{},
c.Solana = chainlink.RawConfigs{
{
"ChainID": "solana-id-1",
"Enabled": true,
"Nodes": []any{
map[string]any{"Name": "primary", "URL": "http://localhost:8899"},
},
},
&solcfg.TOMLConfig{
ChainID: ptr[string]("solana-id-2"),
Enabled: ptr(true),
Nodes: []*solcfg.Node{},
{
"ChainID": "solana-id-2",
"Enabled": true,
"Nodes": []any{
map[string]any{"Name": "primary", "URL": "http://localhost:8898"},
},
},
&solcfg.TOMLConfig{
ChainID: ptr[string]("disabled-solana-id-1"),
Enabled: ptr(false),
Nodes: []*solcfg.Node{},
{
"ChainID": "disabled-solana-id-1",
"Enabled": false,
"Nodes": []any{
map[string]any{"Name": "primary", "URL": "http://localhost:8897"},
},
},
}
for i := range c.Solana {
c.Solana[i].SetDefaults()
}
})

t2Config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Solana = solcfg.TOMLConfigs{
&solcfg.TOMLConfig{
ChainID: ptr[string]("solana-id-1"),
Enabled: ptr(true),
Nodes: []*solcfg.Node{},
c.Solana = chainlink.RawConfigs{
{
"ChainID": "solana-id-1",
"Enabled": true,
"Nodes": []any{
map[string]any{"Name": "primary", "URL": "http://localhost:8899"},
},
},
}
c.Solana[0].SetDefaults()
})

rf := chainlink.RelayerFactory{
Logger: lggr,
LoopRegistry: reg,
}

cfg := chainlink.SolanaFactoryConfig{
TOMLConfigs: tConfig.SolanaConfigs(),
DS: ds}

// not parallel; shared state
t.Run("no plugin", func(t *testing.T) {
relayers, err := rf.NewSolana(ks, ksCSA, cfg)
require.NoError(t, err)
require.NotNil(t, relayers)
require.Len(t, relayers, nEnabledChains)
// no using plugin, so registry should be empty
require.Empty(t, reg.List())
})

t.Run("plugin", func(t *testing.T) {
t.Setenv("CL_SOLANA_CMD", "phony_solana_cmd")

relayers, err := rf.NewSolana(ks, ksCSA, cfg)
relayers, err := rf.NewSolana(ks, ksCSA, tConfig.SolanaConfigs())
require.NoError(t, err)
require.NotNil(t, relayers)
require.Len(t, relayers, nEnabledChains)
Expand All @@ -431,55 +418,46 @@ func TestSetupSolanaRelayer(t *testing.T) {

// test that duplicate enabled chains is an error when
duplicateConfig := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {
c.Solana = solcfg.TOMLConfigs{
&solcfg.TOMLConfig{
ChainID: ptr[string]("dupe"),
Enabled: ptr(true),
c.Solana = chainlink.RawConfigs{
{
"ChainID": "dupe",
"Enabled": true,
"Nodes": []any{
map[string]any{"Name": "primary", "URL": "http://localhost:8899"},
},
},
&solcfg.TOMLConfig{
ChainID: ptr[string]("dupe"),
Enabled: ptr(true),
{
"ChainID": "dupe",
"Enabled": true,
"Nodes": []any{
map[string]any{"Name": "secondary", "URL": "http://localhost:8898"},
},
},
}
for i := range c.Solana {
c.Solana[i].SetDefaults()
}
})
dupCfg := chainlink.SolanaFactoryConfig{
TOMLConfigs: duplicateConfig.SolanaConfigs(),
DS: ds,
}

// not parallel; shared state
t.Run("no plugin, duplicate chains", func(t *testing.T) {
_, err := rf.NewSolana(ks, ksCSA, dupCfg)
require.Error(t, err)
})

t.Run("plugin, duplicate chains", func(t *testing.T) {
t.Setenv("CL_SOLANA_CMD", "phony_solana_cmd")
_, err := rf.NewSolana(ks, ksCSA, dupCfg)
_, err := rf.NewSolana(ks, ksCSA, duplicateConfig.SolanaConfigs())
require.Error(t, err)
})

t.Run("plugin env parsing fails", func(t *testing.T) {
t.Setenv("CL_SOLANA_CMD", "phony_solana_cmd")
t.Setenv("CL_SOLANA_ENV", "fake_path")

_, err := rf.NewSolana(ks, ksCSA, chainlink.SolanaFactoryConfig{
TOMLConfigs: t2Config.SolanaConfigs(),
DS: ds,
})
_, err := rf.NewSolana(ks, ksCSA, t2Config.SolanaConfigs())
require.Error(t, err)
require.Contains(t, err.Error(), "failed to parse Solana env file")
require.ErrorContains(t, err, "failed to parse env file")
})

t.Run("plugin already registered", func(t *testing.T) {
t.Setenv("CL_SOLANA_CMD", "phony_solana_cmd")

_, err := rf.NewSolana(ks, ksCSA, cfg)
_, err := rf.NewSolana(ks, ksCSA, tConfig.SolanaConfigs())
require.Error(t, err)
require.Contains(t, err.Error(), "failed to create Solana LOOP command")
require.ErrorContains(t, err, "failed to create LOOP command")
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ require (
github.com/smartcontractkit/chainlink-protos/storage-service v0.3.0 // indirect
github.com/smartcontractkit/chainlink-protos/svr v1.1.1-0.20260203131522-bb8bc5c423b3 // indirect
github.com/smartcontractkit/chainlink-protos/workflows/go v0.0.0-20260323124644-faea187e6997 // indirect
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20260421131224-c46cbfe7bc6c // indirect
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20260423224337-d6f525ffc73d // indirect
github.com/smartcontractkit/chainlink-solana/contracts v0.0.0-20260421131224-c46cbfe7bc6c // indirect
github.com/smartcontractkit/chainlink-sui v0.0.0-20260409184948-5b16fae57fe0 // indirect
github.com/smartcontractkit/chainlink-sui/deployment v0.0.0-20260409184948-5b16fae57fe0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,7 @@ func NewApplication(ctx context.Context, opts ApplicationOpts) (Application, err
initOps = append(initOps, InitCosmos(relayerFactory, keyStore.Cosmos(), keyStore.CSA(), cfg.CosmosConfigs()))
}
if cfg.SolanaEnabled() {
solanaCfg := SolanaFactoryConfig{
TOMLConfigs: cfg.SolanaConfigs(),
DS: opts.DS,
}
initOps = append(initOps, InitSolana(relayerFactory, keyStore.Solana(), keyStore.CSA(), solanaCfg))
initOps = append(initOps, InitSolana(relayerFactory, keyStore.Solana(), keyStore.CSA(), cfg.SolanaConfigs()))
}
if cfg.StarkNetEnabled() {
initOps = append(initOps, InitStarknet(relayerFactory, keyStore.StarkNet(), keyStore.CSA(), cfg.StarknetConfigs()))
Expand Down
12 changes: 3 additions & 9 deletions core/services/chainlink/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
gotoml "github.com/pelletier/go-toml/v2"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"

configtoml "github.com/smartcontractkit/chainlink-evm/pkg/config/toml"
"github.com/smartcontractkit/chainlink/v2/core/config/docs"
Expand All @@ -37,7 +36,7 @@ type Config struct {

Cosmos RawConfigs `toml:",omitempty"`

Solana solcfg.TOMLConfigs `toml:",omitempty"`
Solana RawConfigs `toml:",omitempty"`

Starknet RawConfigs `toml:",omitempty"`

Expand Down Expand Up @@ -334,12 +333,7 @@ func (c *Config) setDefaults() {

c.Cosmos.SetDefaults()

for i := range c.Solana {
if c.Solana[i] == nil {
c.Solana[i] = new(solcfg.TOMLConfig)
}
c.Solana[i].SetDefaults()
}
c.Solana.SetDefaults()

c.Starknet.SetDefaults()

Expand All @@ -361,7 +355,7 @@ func (c *Config) SetFrom(f *Config) (err error) {

appendErr(c.EVM.SetFrom(&f.EVM), "EVM")
appendErr(c.Cosmos.SetFrom(f.Cosmos), "Cosmos")
appendErr(c.Solana.SetFrom(&f.Solana), "Solana")
appendErr(c.Solana.SetFrom(f.Solana), "Solana")
appendErr(c.Starknet.SetFrom(f.Starknet), "Starknet")
appendErr(c.Aptos.SetFrom(f.Aptos), "Aptos")
appendErr(c.Tron.SetFrom(f.Tron), "Tron")
Expand Down
3 changes: 1 addition & 2 deletions core/services/chainlink/config_general.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
evmcfg "github.com/smartcontractkit/chainlink-evm/pkg/config/toml"
solcfg "github.com/smartcontractkit/chainlink-solana/pkg/solana/config"

"github.com/smartcontractkit/chainlink-common/keystore/corekeys"
"github.com/smartcontractkit/chainlink-common/keystore/corekeys/p2pkey"
Expand Down Expand Up @@ -202,7 +201,7 @@ func (g *generalConfig) CosmosConfigs() RawConfigs {
return g.c.Cosmos
}

func (g *generalConfig) SolanaConfigs() solcfg.TOMLConfigs {
func (g *generalConfig) SolanaConfigs() RawConfigs {
return g.c.Solana
}

Expand Down
Loading
Loading