Skip to content

Commit 90970f6

Browse files
Unify configuration option names used in ValidatorApp Scan and Sequencer configs (#3569)
Fixes #3496 [ci] Signed-off-by: Pasindu Tennage <pasindu.tennage@digitalasset.com>
1 parent 796680b commit 90970f6

File tree

8 files changed

+60
-45
lines changed

8 files changed

+60
-45
lines changed

apps/app/src/main/scala/org/lfdecentralizedtrust/splice/config/SpliceConfig.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,11 @@ object SpliceConfig {
711711
)
712712
_ <- Either.cond(
713713
conf.domains.global.trustedSynchronizerConfig.forall(c =>
714-
c.sequencerNames.length >= c.threshold
714+
c.svNames.length >= c.threshold
715715
),
716716
(),
717717
ConfigValidationFailed(
718-
"Configuration error: Length of sequencerNames should be greater than or equal to threshold."
718+
"Configuration error: Length of svNames should be greater than or equal to threshold."
719719
),
720720
)
721721
_ <- Either.cond(

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ValidatorSequencerConnectionIntegrationTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ValidatorSequencerConnectionIntegrationTest
4242
global = c.domains.global.copy(
4343
trustedSynchronizerConfig = Some(
4444
ValidatorTrustedSynchronizerConfig(
45-
sequencerNames = NonEmptyList.of(getSvName(1), getSvName(2), getSvName(3)),
45+
svNames = NonEmptyList.of(getSvName(1), getSvName(2), getSvName(3)),
4646
threshold = 2,
4747
)
4848
)
@@ -56,7 +56,7 @@ class ValidatorSequencerConnectionIntegrationTest
5656
)
5757
.withManualStart
5858

59-
"validator with 'sequencerNames' set in config connects to specified sequencers and tracks URL changes of sequencers" in {
59+
"validator with 'svNames' set in config connects to specified sequencers and tracks URL changes of sequencers" in {
6060
implicit env =>
6161
startAllSync(
6262
sv1Backend,

apps/validator/src/main/scala/org/lfdecentralizedtrust/splice/validator/config/ValidatorAppConfig.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ case class ValidatorDecentralizedSynchronizerConfig(
110110

111111
case class ValidatorTrustedSynchronizerConfig(
112112
/** static list of trusted sequencer names to connect to.
113-
* sequencerNames is mutually exclusive with `url`.
113+
* svNames is mutually exclusive with `url`.
114114
*/
115-
sequencerNames: NonEmptyList[String],
115+
svNames: NonEmptyList[String],
116116

117117
/** parameter to specify the BFT threshold for the domain connections.
118118
* If not specified, f +1 will be used.

apps/validator/src/main/scala/org/lfdecentralizedtrust/splice/validator/domain/DomainConnector.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class DomainConnector(
214214
)
215215
val svFilteredSequencers = config.domains.global.trustedSynchronizerConfig match {
216216
case Some(config) =>
217-
val allowedNamesSet = config.sequencerNames.toList.toSet
217+
val allowedNamesSet = config.svNames.toList.toSet
218218
logger.debug(
219219
s"Filtering sequencers to only include: ${allowedNamesSet.toList.mkString(", ")}"
220220
)

cluster/helm/splice-validator/templates/validator.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ spec:
133133
- name: ADDITIONAL_CONFIG_STATIC_SEQUENCER_URL
134134
value: canton.validator-apps.validator_backend.domains.global.url = {{ .Values.decentralizedSynchronizerUrl | quote }}
135135
{{ else if .Values.synchronizer -}}
136-
{{- if eq .Values.synchronizer.connectionType "trusted-url" }}
136+
{{- if eq .Values.synchronizer.connectionType "trust-single" }}
137137
- name: ADDITIONAL_CONFIG_SYNCHRONIZER_URL
138138
value: canton.validator-apps.validator_backend.domains.global.url = {{ .Values.synchronizer.url | quote }}
139-
{{- else if eq .Values.synchronizer.connectionType "trusted-svs" }}
140-
- name: ADDITIONAL_CONFIG_SYNCHRONIZER_NAMES
141-
value: canton.validator-apps.validator_backend.domains.global.sequencer-names = {{ .Values.synchronizer.sequencerNames | toJson}}
139+
{{- else if eq .Values.synchronizer.connectionType "bft-custom" }}
140+
- name: ADDITIONAL_CONFIG_SYNCHRONIZER_TRUSTED
141+
value: |
142+
canton.validator-apps.validator_backend.domains.global.trusted-synchronizer-config.sv-names = {{ .Values.synchronizer.svNames | toJson}}
143+
canton.validator-apps.validator_backend.domains.global.trusted-synchronizer-config.threshold = {{ .Values.synchronizer.threshold }}
142144
{{- end }}
143145
{{ end }}
144146
{{- range $ii, $domain := .Values.extraDomains }}

cluster/helm/splice-validator/tests/validator_test.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ tests:
236236
- it: "uses synchronizer.url when provided"
237237
set:
238238
synchronizer:
239-
connectionType: "trusted-url"
239+
connectionType: "trust-single"
240240
url: "https://new-sequencer.mock.com"
241241
documentSelector:
242242
path: kind
@@ -246,15 +246,19 @@ tests:
246246
path: spec.template.spec.containers[?(@.name=='validator-app')].env[?(@.name=='ADDITIONAL_CONFIG_SYNCHRONIZER_URL')].value
247247
pattern: 'canton\.validator-apps\.validator_backend\.domains\.global\.url = "https://new-sequencer\.mock\.com"'
248248

249-
- it: "uses synchronizer.sequencerNames as a JSON array when provided"
249+
- it: "uses synchronizer.svNames as a JSON array when provided"
250250
set:
251251
synchronizer:
252-
connectionType: "trusted-svs"
253-
sequencerNames: [ "sequencer-1", "sequencer-2" ]
252+
connectionType: "bft-custom"
253+
svNames: [ "sequencer-1", "sequencer-2" ]
254+
threshold: 2
254255
documentSelector:
255256
path: kind
256257
value: Deployment
257258
asserts:
258259
- matchRegex:
259-
path: spec.template.spec.containers[?(@.name=='validator-app')].env[?(@.name=='ADDITIONAL_CONFIG_SYNCHRONIZER_NAMES')].value
260-
pattern: 'canton\.validator-apps\.validator_backend\.domains\.global\.sequencer-names = \["sequencer-1","sequencer-2"\]'
260+
path: spec.template.spec.containers[?(@.name=='validator-app')].env[?(@.name=='ADDITIONAL_CONFIG_SYNCHRONIZER_TRUSTED')].value
261+
pattern: 'canton\.validator-apps\.validator_backend\.domains\.global\.trusted-synchronizer-config\.sv-names = \["sequencer-1","sequencer-2"\]'
262+
- matchRegex:
263+
path: spec.template.spec.containers[?(@.name=='validator-app')].env[?(@.name=='ADDITIONAL_CONFIG_SYNCHRONIZER_TRUSTED')].value
264+
pattern: 'canton\.validator-apps\.validator_backend\.domains\.global\.trusted-synchronizer-config\.threshold = 2'

cluster/helm/splice-validator/values.schema.json

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,27 @@
1616
"connectionType": {
1717
"type": "string",
1818
"enum": [
19-
"from-scan",
20-
"trusted-url",
21-
"trusted-svs"
19+
"trust-single",
20+
"bft",
21+
"bft-custom"
2222
]
2323
},
24-
"sequencerNames": {
24+
"url": {
25+
"type": "string",
26+
"description": "Trusted sequencer Url."
27+
},
28+
"svNames": {
2529
"type": "array",
2630
"items": {
2731
"type": "string"
2832
},
2933
"default": [],
30-
"description": "Optional list of trusted sequencer / SV names."
34+
"description": "list of trusted sequencer / SV names. Optional unless connectionType is bft-custom."
3135
},
32-
"url": {
33-
"type": "string",
34-
"description": "Trusted sequencer Url."
36+
"threshold": {
37+
"type": "integer",
38+
"minimum": 0,
39+
"description": "bft-custom threshold. Optional unless connectionType is bft-custom."
3540
}
3641
}
3742
},
@@ -54,7 +59,7 @@
5459
},
5560
"threshold": {
5661
"type": "integer",
57-
"default": 0,
62+
"minimum": 0,
5863
"description": "bft-custom threshold. Optional unless scan-type is bft-custom."
5964
},
6065
"trustedSvs": {
@@ -590,52 +595,51 @@
590595
"if": {
591596
"required": ["synchronizer"],
592597
"properties": {
593-
"synchronizer": {
594-
"required": ["connectionType"]
595-
}
598+
"synchronizer": { "required": ["connectionType"] }
596599
}
597600
},
598601
"then": {
599602
"allOf": [
600603
{
601604
"if": {
602-
"properties": { "synchronizer": { "properties": { "connectionType": { "const": "from-scan" } } } }
605+
"properties": { "synchronizer": { "properties": { "connectionType": { "const": "bft" } } } }
603606
},
604607
"then": {
605608
"properties": {
606609
"synchronizer": {
607-
"properties": {
608-
"url": { "not": {} },
609-
"sequencerNames": { "not": {} }
610-
}
610+
"not": { "required": ["url", "svNames", "threshold"] }
611611
}
612612
}
613613
}
614614
},
615615
{
616616
"if": {
617-
"properties": { "synchronizer": { "properties": { "connectionType": { "const": "trusted-url" } } } }
617+
"properties": { "synchronizer": { "properties": { "connectionType": { "const": "trust-single" } } } }
618618
},
619619
"then": {
620620
"properties": {
621621
"synchronizer": {
622622
"required": ["url"],
623-
"properties": { "sequencerNames": { "not": {} } }
623+
"properties": {
624+
"url": { "minLength": 1 },
625+
"svNames": false,
626+
"threshold": false
627+
}
624628
}
625629
}
626630
}
627631
},
628632
{
629633
"if": {
630-
"properties": { "synchronizer": { "properties": { "connectionType": { "const": "trusted-svs" } } } }
634+
"properties": { "synchronizer": { "properties": { "connectionType": { "const": "bft-custom" } } } }
631635
},
632636
"then": {
633637
"properties": {
634638
"synchronizer": {
635-
"required": ["sequencerNames"],
639+
"required": ["svNames", "threshold"],
636640
"properties": {
637-
"url": { "not": {} },
638-
"sequencerNames": { "minItems": 1 }
641+
"url": false,
642+
"svNames": { "minItems": 1 }
639643
}
640644
}
641645
}

cluster/pulumi/common-validator/src/config.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,24 @@ import { z } from 'zod';
1313
export const SynchronizerConfigSchema = z.union([
1414
z
1515
.object({
16-
connectionType: z.literal('trusted-url'),
16+
connectionType: z.literal('trust-single'),
1717
url: z.string().min(1),
1818
})
1919
.strict(),
2020
z
2121
.object({
22-
connectionType: z.literal('trusted-svs'),
23-
sequencerNames: z.array(z.string()).min(1),
22+
connectionType: z.literal('bft-custom'),
23+
svNames: z.array(z.string()).min(1),
24+
threshold: z.number().int().min(1),
2425
})
25-
.strict(),
26+
.strict()
27+
.refine(data => data.svNames.length >= data.threshold, {
28+
message: 'svNames length must be greater than or equal to the threshold',
29+
path: ['threshold'], // Point the error to the threshold field
30+
}),
2631
z
2732
.object({
28-
connectionType: z.literal('from-scan').default('from-scan'),
33+
connectionType: z.literal('bft').default('bft'),
2934
})
3035
.strict(),
3136
]);

0 commit comments

Comments
 (0)