Skip to content

Commit 3da7aa7

Browse files
authored
core/config/docs: config enhancements (#17091)
1 parent e2ae857 commit 3da7aa7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+259
-777
lines changed

GNUmakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ gomodtidy: gomods ## Run go mod tidy on all modules.
3939

4040
.PHONY: tidy
4141
tidy: gomodtidy ## Tidy all modules and add to git.
42-
git add '**go.*'
42+
git add '**go.*' 'plugins/plugins.public.yaml'
4343

4444
.PHONY: docs
4545
docs: ## Install and run pkgsite to view Go docs

core/cmd/blocks_commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func Test_ReplayFromBlock(t *testing.T) {
4444
require.NoError(t, set.Set("chain-id", "1"))
4545
require.NoError(t, set.Set("family", "evm"))
4646
c = cli.NewContext(nil, set, nil)
47-
require.ErrorContains(t, client.ReplayFromBlock(c), "does not match any local chains")
47+
require.ErrorContains(t, client.ReplayFromBlock(c), "chain id does not exist: 1")
4848

4949
// Incorrect chain family
5050
require.NoError(t, set.Set("chain-id", "5"))

core/cmd/node_commands_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestShell_IndexEVMNodes(t *testing.T) {
9898

9999
func solanaStartNewApplication(t *testing.T, cfgs ...*solcfg.TOMLConfig) *cltest.TestApplication {
100100
for i := range cfgs {
101-
cfgs[i].Chain.SetDefaults()
101+
cfgs[i].SetDefaults()
102102
}
103103
return startNewApplicationV2(t, func(c *chainlink.Config, s *chainlink.Secrets) {
104104
c.Solana = cfgs

core/cmd/shell_remote_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestShell_ReplayBlocks(t *testing.T) {
139139
require.NoError(t, set.Set("chain-id", "12345678"))
140140
require.NoError(t, set.Set("family", "evm"))
141141
c := cli.NewContext(nil, set, nil)
142-
assert.ErrorContains(t, client.ReplayFromBlock(c), "chain id does not match any local chains")
142+
assert.ErrorContains(t, client.ReplayFromBlock(c), "chain id does not exist: 12345678") //nolint:testifylint // non-fatal
143143

144144
require.NoError(t, set.Set("chain-id", testutils.FixtureChainID.String()))
145145
c = cli.NewContext(nil, set, nil)

core/cmd/shell_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,40 +360,39 @@ func TestSetupSolanaRelayer(t *testing.T) {
360360

361361
// config 3 chains but only enable 2 => should only be 2 relayer
362362
nEnabledChains := 2
363-
chainCfg := solcfg.Chain{}
364-
chainCfg.SetDefaults()
363+
365364
tConfig := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {
366365
c.Solana = solcfg.TOMLConfigs{
367366
&solcfg.TOMLConfig{
368367
ChainID: ptr[string]("solana-id-1"),
369368
Enabled: ptr(true),
370-
Chain: chainCfg,
371369
Nodes: []*solcfg.Node{},
372370
},
373371
&solcfg.TOMLConfig{
374372
ChainID: ptr[string]("solana-id-2"),
375373
Enabled: ptr(true),
376-
Chain: chainCfg,
377374
Nodes: []*solcfg.Node{},
378375
},
379376
&solcfg.TOMLConfig{
380377
ChainID: ptr[string]("disabled-solana-id-1"),
381378
Enabled: ptr(false),
382-
Chain: chainCfg,
383379
Nodes: []*solcfg.Node{},
384380
},
385381
}
382+
for i := range c.Solana {
383+
c.Solana[i].SetDefaults()
384+
}
386385
})
387386

388387
t2Config := configtest.NewGeneralConfig(t, func(c *chainlink.Config, s *chainlink.Secrets) {
389388
c.Solana = solcfg.TOMLConfigs{
390389
&solcfg.TOMLConfig{
391390
ChainID: ptr[string]("solana-id-1"),
392391
Enabled: ptr(true),
393-
Chain: solcfg.Chain{},
394392
Nodes: []*solcfg.Node{},
395393
},
396394
}
395+
c.Solana[0].SetDefaults()
397396
})
398397

399398
rf := chainlink.RelayerFactory{
@@ -432,16 +431,15 @@ func TestSetupSolanaRelayer(t *testing.T) {
432431
&solcfg.TOMLConfig{
433432
ChainID: ptr[string]("dupe"),
434433
Enabled: ptr(true),
435-
Chain: chainCfg,
436-
Nodes: []*solcfg.Node{},
437434
},
438435
&solcfg.TOMLConfig{
439436
ChainID: ptr[string]("dupe"),
440437
Enabled: ptr(true),
441-
Chain: chainCfg,
442-
Nodes: []*solcfg.Node{},
443438
},
444439
}
440+
for i := range c.Solana {
441+
c.Solana[i].SetDefaults()
442+
}
445443
})
446444
dupCfg := chainlink.SolanaFactoryConfig{
447445
TOMLConfigs: duplicateConfig.SolanaConfigs(),

core/config/docs/chains-evm.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# EVM defaults depend on ChainID:
22
#
3-
# **EXTENDED**
43
[[EVM]]
54
# ChainID is the EVM chain ID. Mandatory.
65
ChainID = '1' # Example

core/config/docs/chains-solana.toml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# ChainID is the Solana chain ID. Must be one of: mainnet, testnet, devnet, localnet. Mandatory.
33
ChainID = 'mainnet' # Example
44
# Enabled enables this chain.
5-
Enabled = false # Default
5+
Enabled = true # Default
66
# BlockTime specifies the average time between blocks on this chain
77
BlockTime = '500ms' # Default
88
# BalancePollPeriod is the rate to poll for SOL balance and update Prometheus metrics.
@@ -59,6 +59,24 @@ EstimateComputeUnitLimit = false # Default
5959
# LogPollerStartingLookback
6060
LogPollerStartingLookback = '24h0m0s' # Default
6161

62+
[Solana.Workflow]
63+
# AcceptanceTimeout is the default timeout for a tranmission to be accepted on chain
64+
AcceptanceTimeout = '45s' # Default
65+
# ForwarderAddress is the keystone forwarder program address on chain.
66+
ForwarderAddress = '14grJpemFaf88c8tiVb77W7TYg2W3ir6pfkKz3YjhhZ5' # Example
67+
# ForwarderState is the keystone forwarder program state account on chain.
68+
ForwarderState = '14grJpemFaf88c8tiVb77W7TYg2W3ir6pfkKz3YjhhZ5' # Example
69+
# FromAddress is Address of the transmitter key to use for workflow writes.
70+
FromAddress = '4BJXYkfvg37zEmBbsacZjeQDpTNx91KppxFJxRqrz48e' # Example
71+
# GasLimitDefault is the default gas limit for workflow transactions.
72+
GasLimitDefault = 300_000 # Default
73+
# Local defines if relayer runs against local devnet
74+
Local = false # Default
75+
# PollPeriod is the default poll period for checking transmission state
76+
PollPeriod = '3s' # Default
77+
# TxAcceptanceState is the default acceptance state for writer DON tranmissions.
78+
TxAcceptanceState = 3 # Default
79+
6280
[Solana.MultiNode]
6381
# Enabled enables the multinode feature.
6482
Enabled = false # Default
@@ -95,24 +113,6 @@ FinalityTagEnabled = true # Default
95113
# FinalizedBlockOffset is the offset from the finalized block to use for finality tags.
96114
FinalizedBlockOffset = 0 # Default
97115

98-
[Solana.Workflow]
99-
# AcceptanceTimeout is the default timeout for a tranmission to be accepted on chain
100-
AcceptanceTimeout = '45s' # Default
101-
# PollPeriod is the default poll period for checking transmission state
102-
PollPeriod = '3s' # Default
103-
# ForwarderAddress is the keystone forwarder program address on chain.
104-
ForwarderAddress = '14grJpemFaf88c8tiVb77W7TYg2W3ir6pfkKz3YjhhZ5' # Example
105-
# ForwarderState is the keystone forwarder program state account on chain.
106-
ForwarderState = '14grJpemFaf88c8tiVb77W7TYg2W3ir6pfkKz3YjhhZ5' # Example
107-
# FromAddress is Address of the transmitter key to use for workflow writes.
108-
FromAddress = '4BJXYkfvg37zEmBbsacZjeQDpTNx91KppxFJxRqrz48e' # Example
109-
# GasLimitDefault is the default gas limit for workflow transactions.
110-
GasLimitDefault = 300_000 # Default
111-
# TxAcceptanceState is the default acceptance state for writer DON tranmissions.
112-
TxAcceptanceState = 3 # Default
113-
# Local determines whether Relayer runs against a local devnet
114-
Local = false # Default
115-
116116
[[Solana.Nodes]]
117117
# Name is a unique (per-chain) identifier for this node.
118118
Name = 'primary' # Example

core/config/docs/cmd/generate/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"flag"
77
"fmt"
88
"os"
9-
"path"
9+
"path/filepath"
1010

1111
"github.com/smartcontractkit/chainlink/v2/core/config/docs"
1212
)
@@ -26,11 +26,11 @@ func main() {
2626
fmt.Fprintf(os.Stderr, "invalid secrets docs: %v\n", err)
2727
os.Exit(1)
2828
}
29-
if err = os.WriteFile(path.Join(*outDir, "CONFIG.md"), []byte(c), 0600); err != nil {
29+
if err = os.WriteFile(filepath.Join(*outDir, "CONFIG.md"), []byte(c), 0600); err != nil {
3030
fmt.Fprintf(os.Stderr, "failed to write config docs: %v\n", err)
3131
os.Exit(1)
3232
}
33-
if err = os.WriteFile(path.Join(*outDir, "SECRETS.md"), []byte(s), 0600); err != nil {
33+
if err = os.WriteFile(filepath.Join(*outDir, "SECRETS.md"), []byte(s), 0600); err != nil {
3434
fmt.Fprintf(os.Stderr, "failed to write secrets docs: %v\n", err)
3535
os.Exit(1)
3636
}

core/config/docs/defaults.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import (
55
"strings"
66

77
"github.com/smartcontractkit/chainlink-common/pkg/config"
8+
"github.com/smartcontractkit/chainlink-common/pkg/config/configdoc"
89
pgcommon "github.com/smartcontractkit/chainlink-common/pkg/sqlutil/pg"
910

1011
"github.com/smartcontractkit/chainlink/v2/core/config/toml"
11-
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest"
1212
)
1313

1414
var (
1515
defaults toml.Core
1616
)
1717

1818
func init() {
19-
if err := cfgtest.DocDefaultsOnly(strings.NewReader(coreTOML), &defaults, config.DecodeTOML); err != nil {
19+
if err := configdoc.DefaultsOnly(strings.NewReader(coreTOML), &defaults, config.DecodeTOML); err != nil {
2020
log.Fatalf("Failed to initialize defaults from docs: %v", err)
2121
}
2222
}

core/config/docs/defaults_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package docs
33
import (
44
"testing"
55

6-
"github.com/smartcontractkit/chainlink/v2/core/services/chainlink/cfgtest"
6+
"github.com/smartcontractkit/chainlink-common/pkg/config/configtest"
77
)
88

99
func TestCoreDefaults_notNil(t *testing.T) {
10-
cfgtest.AssertFieldsNotNil(t, CoreDefaults())
10+
configtest.AssertFieldsNotNil(t, CoreDefaults())
1111
}

0 commit comments

Comments
 (0)