Skip to content

Commit 2943192

Browse files
authored
use nodesets everywhere (#1773)
* use nodesets everywhere * review fixes
1 parent d828d47 commit 2943192

35 files changed

+185
-207
lines changed

book/src/framework/components/chainlink/nodeset.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ This component requires some Blockchain to be deployed, add this to config
4141

4242
Then configure NodeSet
4343
```toml
44-
[nodeset]
44+
[[nodesets]]
4545
# unique NodeSet name
4646
name = "don"
4747
# amount of Chainlink nodes to spin up
@@ -55,17 +55,17 @@ Then configure NodeSet
5555
# P2P API port range start, each new node get port incremented (host machine)
5656
p2p_port_range_start = 12000
5757

58-
[nodeset.db]
58+
[nodesets.db]
5959
# PostgreSQL image version and tag
6060
image = "postgres:12.0"
6161
# Pulls the image every time if set to 'true', used like that in CI. Can be set to 'false' to speed up local runs
6262
pull_image = false
6363
# PostgreSQL volume name
6464
volume_name = ""
6565

66-
[[nodeset.node_specs]]
66+
[[nodesets.node_specs]]
6767

68-
[nodeset.node_specs.node]
68+
[nodesets.node_specs.node]
6969
# custom ports that plugins may need to expose and map to the host machine
7070
custom_ports = [14000, 14001]
7171
# A list of paths to capability binaries
@@ -96,16 +96,16 @@ Then configure NodeSet
9696
"""
9797

9898
# Outputs are the results of deploying a component that can be used by another component
99-
[nodeset.out]
99+
[nodesets.out]
100100
# If 'use_cache' equals 'true' we skip component setup when we run the test and return the outputs
101101
use_cache = true
102102

103103
# Describes deployed or external Chainlink nodes
104-
[[nodeset.out.cl_nodes]]
104+
[[nodesets.out.cl_nodes]]
105105
use_cache = true
106106

107107
# Describes deployed or external Chainlink node
108-
[nodeset.out.cl_nodes.node]
108+
[nodesets.out.cl_nodes.node]
109109
# API user name
110110
api_auth_user = '[email protected]'
111111
# API password
@@ -115,15 +115,15 @@ Then configure NodeSet
115115
p2p_url = "http://127.0.0.1:32996"
116116
url = "http://127.0.0.1:33096"
117117
# Describes PostgreSQL instance
118-
[nodeset.out.cl_nodes.postgresql]
118+
[nodesets.out.cl_nodes.postgresql]
119119
# PostgreSQL connection string
120120
# in case of using external database can be overriden
121121
url = "postgresql://chainlink:[email protected]:33094/chainlink?sslmode=disable"
122122

123123
# Can have more than one node, fields are the same, see above ^^
124-
[[nodeset.out.cl_nodes]]
125-
[nodeset.out.cl_nodes.node]
126-
[nodeset.out.cl_nodes.postgresql]
124+
[[nodesets.out.cl_nodes]]
125+
[nodesets.out.cl_nodes.node]
126+
[nodesets.out.cl_nodes.postgresql]
127127
...
128128
```
129129

@@ -141,7 +141,7 @@ import (
141141

142142
type Config struct {
143143
BlockchainA *blockchain.Input `toml:"blockchain_a" validate:"required"`
144-
NodeSet *ns.Input `toml:"nodeset" validate:"required"`
144+
NodeSets []*ns.Input `toml:"nodesets" validate:"required"`
145145
}
146146

147147
func TestMe(t *testing.T) {

book/src/framework/components/external.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ For example, to integrate with remote `k8s` environment you can use `CTF_CONFIGS
2020
http_url = "http://127.0.0.1:8545"
2121
ws_url = "ws://127.0.0.1:8545"
2222

23-
[nodeset]
23+
[[nodesets]]
2424

25-
[[nodeset.node_specs]]
25+
[[nodesets.node_specs]]
2626
...
2727

28-
[nodeset.out]
28+
[nodesets.out]
2929
use_cache = true
3030

31-
[[nodeset.out.cl_nodes]]
31+
[[nodesets.out.cl_nodes]]
3232
use_cache = true
3333

34-
[nodeset.out.cl_nodes.node]
34+
[nodesets.out.cl_nodes.node]
3535
# set up your user/password for API authorization
3636
api_auth_user = '[email protected]'
3737
api_auth_password = 'fj293fbBnlQ!f9vNs'
3838
# set up each node URLs
3939
p2p_url = "http://127.0.0.1:12000"
4040
url = "http://127.0.0.1:10000"
4141

42-
[nodeset.out.cl_nodes.postgresql]
42+
[nodesets.out.cl_nodes.postgresql]
4343
# set up a database URL so tests can connect to your database if needed
4444
url = "postgresql://chainlink:[email protected]:13000/db_0?sslmode=disable"
4545

book/src/framework/components/state.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ Defaults are:
1212
- [NodeSet](../components/chainlink/nodeset.md) (Delve debugger): `40000..400XX` (if you are using debug image)
1313
- Shared `PostgreSQL` volume is called `postgresql_data`
1414
```
15-
[nodeset]
15+
[[nodesets]]
1616
# HTTP API port range start, each new node get port incremented (host machine)
1717
http_port_range_start = 10000
1818
# P2P API port range start, each new node get port incremented (host machine)
1919
p2p_port_range_start = 12000
2020
```
2121
- [PostgreSQL](../components/chainlink/nodeset.md): `13000` (we do not allow to have multiple databases for now, for simplicity)
2222
```
23-
[nodeset.node_specs.db]
23+
[nodesets.node_specs.db]
2424
# PostgreSQL volume name
2525
volume_name = "a"
2626
# PostgreSQL port (host machine)
@@ -34,7 +34,7 @@ When you run `ctf d rm` database volume will be **removed**.
3434

3535
One node set is enough for any kind of testing, if you need more nodes consider extending your existing node set:
3636
```
37-
[nodeset]
37+
[[nodesets]]
3838
nodes = 10
3939
```
4040
</div>
@@ -43,17 +43,17 @@ One node set is enough for any kind of testing, if you need more nodes consider
4343

4444
You can also define a custom set of ports for any node.
4545
```toml
46-
[nodeset]
46+
[[nodesets]]
4747
name = "don"
4848
nodes = 5
4949
override_mode = "each"
5050

51-
[nodeset.db]
51+
[nodesets.db]
5252
image = "postgres:12.0"
5353

54-
[[nodeset.node_specs]]
54+
[[nodesets.node_specs]]
5555

56-
[nodeset.node_specs.node]
56+
[nodesets.node_specs.node]
5757
# here we defined 2 new ports to listen and mapped them to our host machine
5858
# syntax is "host:docker"
5959
custom_ports = ["14000:15000"]

book/src/framework/nodeset_capabilities.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ Create a configuration file `smoke.toml`
2020
type = "anvil"
2121
docker_cmd_params = ["-b", "1"]
2222

23-
[nodeset]
23+
[[nodesets]]
2424
name = "don"
2525
nodes = 5
2626
override_mode = "all"
2727

28-
[nodeset.db]
28+
[nodesets.db]
2929
image = "postgres:12.0"
3030

31-
[[nodeset.node_specs]]
31+
[[nodesets.node_specs]]
3232

33-
[nodeset.node_specs.node]
33+
[nodesets.node_specs.node]
3434
# path to your capability binaries
3535
capabilities = ["./kvstore"]
3636
# default capabilities directory

book/src/framework/nodeset_compatibility.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,45 @@ Create a configuration file `smoke.toml`
88
type = "anvil"
99
docker_cmd_params = ["-b", "1"]
1010

11-
[nodeset]
11+
[[nodesets]]
1212
name = "don"
1313
nodes = 5
1414
override_mode = "each"
1515

16-
[nodeset.db]
16+
[nodesets.db]
1717
image = "postgres:12.0"
1818

19-
[[nodeset.node_specs]]
19+
[[nodesets.node_specs]]
2020

21-
[nodeset.node_specs.node]
21+
[nodesets.node_specs.node]
2222
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
2323
user_config_overrides = " [Log]\n level = 'info'\n "
2424
user_secrets_overrides = ""
2525

26-
[[nodeset.node_specs]]
26+
[[nodesets.node_specs]]
2727

28-
[nodeset.node_specs.node]
28+
[nodesets.node_specs.node]
2929
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
3030
user_config_overrides = " [Log]\n level = 'info'\n "
3131
user_secrets_overrides = ""
3232

33-
[[nodeset.node_specs]]
33+
[[nodesets.node_specs]]
3434

35-
[nodeset.node_specs.node]
35+
[nodesets.node_specs.node]
3636
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
3737
user_config_overrides = " [Log]\n level = 'info'\n "
3838
user_secrets_overrides = ""
3939

40-
[[nodeset.node_specs]]
40+
[[nodesets.node_specs]]
4141

42-
[nodeset.node_specs.node]
42+
[nodesets.node_specs.node]
4343
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
4444
user_config_overrides = " [Log]\n level = 'info'\n "
4545
user_secrets_overrides = ""
4646

47-
[[nodeset.node_specs]]
47+
[[nodesets.node_specs]]
4848

49-
[nodeset.node_specs.node]
49+
[nodesets.node_specs.node]
5050
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
5151
user_config_overrides = " [Log]\n level = 'info'\n "
5252
user_secrets_overrides = ""

book/src/framework/nodeset_docker_rebuild.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Create a configuration file `smoke.toml`
88
type = "anvil"
99
docker_cmd_params = ["-b", "1"]
1010

11-
[nodeset]
11+
[[nodesets]]
1212
name = "don"
1313
nodes = 5
1414
override_mode = "all"
1515

16-
[nodeset.db]
16+
[nodesets.db]
1717
image = "postgres:12.0"
1818

19-
[[nodeset.node_specs]]
19+
[[nodesets.node_specs]]
2020

21-
[nodeset.node_specs.node]
21+
[nodesets.node_specs.node]
2222
# Dockerfile path is relative to "docker_ctx"
2323
docker_file = "core/chainlink.Dockerfile"
2424
docker_ctx = "../.."

book/src/framework/nodeset_environment.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Create a configuration file `smoke.toml`
88
type = "anvil"
99
docker_cmd_params = ["-b", "1"]
1010

11-
[nodeset]
11+
[[nodesets]]
1212
name = "don"
1313
nodes = 5
1414
override_mode = "all"
1515

16-
[nodeset.db]
16+
[nodesets.db]
1717
image = "postgres:12.0"
1818

19-
[[nodeset.node_specs]]
19+
[[nodesets.node_specs]]
2020

21-
[nodeset.node_specs.node]
21+
[nodesets.node_specs.node]
2222
image = "public.ecr.aws/chainlink/chainlink:v2.17.0"
2323
```
2424

framework/.changeset/v0.7.3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Use nodesets slice everywhere to ease multi-DON configuration

framework/components/simple_node_set/node_set.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,9 @@ func sharedDBSetup(in *Input, bcOut *blockchain.Output) (*Output, error) {
111111
eg := &errgroup.Group{}
112112
mu := &sync.Mutex{}
113113
for i := 0; i < in.Nodes; i++ {
114-
var overrideIdx int
114+
overrideIdx := i
115115
var nodeName string
116-
switch in.OverrideMode {
117-
case "each":
118-
overrideIdx = i
119-
case "all":
120-
overrideIdx = 0
116+
if in.OverrideMode == "all" {
121117
if len(in.NodeSpecs[overrideIdx].Node.CustomPorts) > 0 {
122118
return nil, fmt.Errorf("custom_ports can be used only with override_mode = 'each'")
123119
}

framework/components/simple_node_set/nodeset_test.go

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,7 @@ func checkBasicOutputs(t *testing.T, output *ns.Output) {
3939

4040
func TestSmokeComponentDockerNodeSetSharedDB(t *testing.T) {
4141
testCases := []testCase{
42-
{
43-
name: "2 nodes cluster, override mode 'all'",
44-
bcInput: &blockchain.Input{
45-
Type: "anvil",
46-
Image: "f4hrenh9it/foundry",
47-
Port: "8545",
48-
ChainID: "31337",
49-
},
50-
nodeSetInput: &ns.Input{
51-
Name: "don-1",
52-
Nodes: 2,
53-
OverrideMode: "all",
54-
DbInput: &postgres.Input{
55-
Image: "postgres:12.0",
56-
},
57-
NodeSpecs: []*clnode.Input{
58-
{
59-
Node: &clnode.NodeInput{
60-
Image: "public.ecr.aws/chainlink/chainlink:v2.17.0",
61-
Name: "cl-node",
62-
},
63-
},
64-
},
65-
},
66-
assertion: func(t *testing.T, output *ns.Output) {
67-
checkBasicOutputs(t, output)
68-
},
69-
},
42+
// only 'each' mode is available when using as code to simplify configuration
7043
{
7144
name: "2 nodes cluster, override mode 'each'",
7245
bcInput: &blockchain.Input{

0 commit comments

Comments
 (0)