Skip to content

Commit 840d957

Browse files
canton-network-daDA Automation
andauthored
Update Splice from CCI (#349)
Signed-off-by: DA Automation <splice-maintainers@digitalasset.com> Co-authored-by: DA Automation <splice-maintainers@digitalasset.com>
1 parent 48f7a11 commit 840d957

File tree

18 files changed

+236
-126
lines changed

18 files changed

+236
-126
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package org.lfdecentralizedtrust.splice.integration.tests
22

3+
import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{
4+
ConfigurableApp,
5+
updateAutomationConfig,
6+
}
37
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
48
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.IntegrationTest
9+
import org.lfdecentralizedtrust.splice.sv.automation.singlesv.LocalSequencerConnectionsTrigger
510
import org.lfdecentralizedtrust.splice.util.SpliceUtil.defaultIssuanceCurve
611
import org.lfdecentralizedtrust.splice.util.{SvTestUtil, TimeTestUtil, WalletTestUtil}
712

@@ -16,6 +21,14 @@ class ScanWithGradualStartsTimeBasedIntegrationTest
1621
override def environmentDefinition: SpliceEnvironmentDefinition =
1722
EnvironmentDefinition
1823
.simpleTopology4SvsWithSimTime(this.getClass.getSimpleName)
24+
.addConfigTransforms((_, config) =>
25+
updateAutomationConfig(ConfigurableApp.Sv)(
26+
// SVs's sequencer connection choice is not relevant to this test
27+
// but the reconciliation can cause flakiness
28+
// TODO(#8300): Unpause again once this reconciliation is less disruptive
29+
_.withPausedTrigger[LocalSequencerConnectionsTrigger]
30+
)(config)
31+
)
1932
.withManualStart
2033

2134
"initialize a scan app that joins late" in { implicit env =>

apps/common/src/main/scala/org/lfdecentralizedtrust/splice/environment/PackageVersionSupport.scala

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
package org.lfdecentralizedtrust.splice.environment
55

66
import com.digitalasset.canton.data.CantonTimestamp
7+
import com.digitalasset.canton.logging.pretty.Pretty
8+
import com.digitalasset.canton.logging.pretty.Pretty.{param, prettyOfClass}
79
import com.digitalasset.canton.topology.{PartyId, SynchronizerId}
810
import com.digitalasset.canton.tracing.TraceContext
11+
import com.digitalasset.canton.util.ShowUtil.ShowStringSyntax
912
import com.digitalasset.daml.lf.data.Ref.PackageVersion
1013
import com.digitalasset.daml.lf.language.Ast
1114
import org.lfdecentralizedtrust.splice.codegen.java.splice.amuletrules.AmuletRules
1215
import org.lfdecentralizedtrust.splice.environment.PackageIdResolver.HasAmuletRules
16+
import org.lfdecentralizedtrust.splice.environment.PackageVersionSupport.FeatureSupport
1317
import org.lfdecentralizedtrust.splice.util.AmuletConfigSchedule
1418

1519
import scala.concurrent.{ExecutionContext, Future}
@@ -18,19 +22,19 @@ trait PackageVersionSupport {
1822

1923
def supportsValidatorLicenseMetadata(parties: Seq[PartyId], now: CantonTimestamp)(implicit
2024
tc: TraceContext
21-
): Future[Boolean] = {
25+
): Future[FeatureSupport] = {
2226
isDarSupported(parties, PackageIdResolver.Package.SpliceAmulet, now, DarResources.amulet_0_1_3)
2327
}
2428

2529
def supportsValidatorLicenseActivity(parties: Seq[PartyId], now: CantonTimestamp)(implicit
2630
tc: TraceContext
27-
): Future[Boolean] = {
31+
): Future[FeatureSupport] = {
2832
isDarSupported(parties, PackageIdResolver.Package.SpliceAmulet, now, DarResources.amulet_0_1_3)
2933
}
3034

3135
def supportsPruneAmuletConfigSchedule(parties: Seq[PartyId], now: CantonTimestamp)(implicit
3236
tc: TraceContext
33-
): Future[Boolean] = {
37+
): Future[FeatureSupport] = {
3438
isDarSupported(
3539
parties,
3640
PackageIdResolver.Package.SpliceDsoGovernance,
@@ -41,7 +45,7 @@ trait PackageVersionSupport {
4145

4246
def supportsMergeDuplicatedValidatorLicense(parties: Seq[PartyId], now: CantonTimestamp)(implicit
4347
tc: TraceContext
44-
): Future[Boolean] = {
48+
): Future[FeatureSupport] = {
4549
isDarSupported(
4650
parties,
4751
PackageIdResolver.Package.SpliceDsoGovernance,
@@ -52,7 +56,7 @@ trait PackageVersionSupport {
5256

5357
def supportsLegacySequencerConfig(parties: Seq[PartyId], now: CantonTimestamp)(implicit
5458
tc: TraceContext
55-
): Future[Boolean] = {
59+
): Future[FeatureSupport] = {
5660
isDarSupported(
5761
parties,
5862
PackageIdResolver.Package.SpliceDsoGovernance,
@@ -63,13 +67,13 @@ trait PackageVersionSupport {
6367

6468
def supportsValidatorLivenessActivityRecord(parties: Seq[PartyId], now: CantonTimestamp)(implicit
6569
tc: TraceContext
66-
): Future[Boolean] = {
70+
): Future[FeatureSupport] = {
6771
isDarSupported(parties, PackageIdResolver.Package.SpliceAmulet, now, DarResources.amulet_0_1_5)
6872
}
6973

7074
def supportsDsoRulesCreateExternalPartyAmuletRules(parties: Seq[PartyId], now: CantonTimestamp)(
7175
implicit tc: TraceContext
72-
): Future[Boolean] = {
76+
): Future[FeatureSupport] = {
7377
isDarSupported(
7478
parties,
7579
PackageIdResolver.Package.SpliceDsoGovernance,
@@ -80,7 +84,7 @@ trait PackageVersionSupport {
8084

8185
def supportsNewGovernanceFlow(parties: Seq[PartyId], now: CantonTimestamp)(implicit
8286
tc: TraceContext
83-
): Future[Boolean] = {
87+
): Future[FeatureSupport] = {
8488
isDarSupported(
8589
parties,
8690
PackageIdResolver.Package.SpliceDsoGovernance,
@@ -107,7 +111,7 @@ trait PackageVersionSupport {
107111
metadata: Ast.PackageMetadata,
108112
)(implicit
109113
tc: TraceContext
110-
): Future[Boolean]
114+
): Future[FeatureSupport]
111115

112116
}
113117

@@ -120,18 +124,28 @@ class AmuletRulesPackageVersionSupport private[environment] (amuletRules: HasAmu
120124
packageId: PackageIdResolver.Package,
121125
at: CantonTimestamp,
122126
metadata: Ast.PackageMetadata,
123-
)(implicit tc: TraceContext): Future[Boolean] = {
127+
)(implicit tc: TraceContext): Future[FeatureSupport] = {
124128
basedOnCurrentAmuletRules { amuletRules =>
125129
val packageVersion = metadata.version
126130
val packageConfig = AmuletConfigSchedule(amuletRules).getConfigAsOf(at).packageConfig
127131
val activeVersion = PackageIdResolver.readPackageVersion(packageConfig, packageId)
128-
packageVersion >= activeVersion
132+
val isSupported = packageVersion >= activeVersion
133+
val activePackageId = DarResources
134+
.lookupPackageMetadata(
135+
metadata.name,
136+
activeVersion,
137+
)
138+
.map(_.packageId)
139+
FeatureSupport(
140+
isSupported,
141+
activePackageId.toList,
142+
)
129143
}
130144
}
131145

132146
private def basedOnCurrentAmuletRules(
133-
condition: AmuletRules => Boolean
134-
)(implicit tc: TraceContext): Future[Boolean] = {
147+
condition: AmuletRules => FeatureSupport
148+
)(implicit tc: TraceContext): Future[FeatureSupport] = {
135149
amuletRules.getAmuletRules().map(amuletRules => condition(amuletRules.payload))
136150
}
137151

@@ -148,7 +162,7 @@ class TopologyAwarePackageVersionSupport private[environment] (
148162
packageId: PackageIdResolver.Package,
149163
at: CantonTimestamp,
150164
metadata: Ast.PackageMetadata,
151-
)(implicit tc: TraceContext): Future[Boolean] = {
165+
)(implicit tc: TraceContext): Future[FeatureSupport] = {
152166
connection
153167
.getSupportedPackageVersion(
154168
synchronizerId,
@@ -157,15 +171,38 @@ class TopologyAwarePackageVersionSupport private[environment] (
157171
at,
158172
)
159173
.map(
160-
_.exists { packageReference =>
174+
_.filter { packageReference =>
161175
PackageVersion.assertFromString(packageReference.packageVersion) >= metadata.version
162176
}
163177
)
178+
.map { supportedPackages =>
179+
supportedPackages.fold(FeatureSupport(supported = false, Seq.empty))(packageReference =>
180+
FeatureSupport(
181+
supported = true,
182+
Seq(
183+
packageReference.packageId
184+
),
185+
)
186+
)
187+
}
164188
}
165189
}
166190

167191
object PackageVersionSupport {
168192

193+
case class FeatureSupport(
194+
supported: Boolean,
195+
packageIds: Seq[String],
196+
)
197+
198+
object FeatureSupport {
199+
200+
implicit val featureSupportPretty: Pretty[FeatureSupport] = prettyOfClass(
201+
param("supported", t => t.supported),
202+
param("prefferredPackageIds", _.packageIds.map(_.singleQuoted)),
203+
)
204+
}
205+
169206
def createPackageVersionSupport(
170207
enableCantonPackageSelection: Boolean,
171208
amuletRules: HasAmuletRules,

apps/common/src/main/scala/org/lfdecentralizedtrust/splice/environment/SpliceLedgerConnection.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,7 @@ class SpliceLedgerConnection(
876876
disclosedContracts: DisclosedContracts,
877877
priority: CommandPriority,
878878
deadline: Option[NonNegativeFiniteDuration] = None,
879+
preferredPackageIds: Seq[String] = Seq.empty,
879880
) {
880881
private type DedupNotSpecifiedYet = CmdId =:= Any
881882
private type SynchronizerIdRequired = DomId <:< SynchronizerId
@@ -885,6 +886,7 @@ class SpliceLedgerConnection(
885886
synchronizerId: DomId0 = this.synchronizerId,
886887
disclosedContracts: DisclosedContracts = this.disclosedContracts,
887888
deadline: Option[NonNegativeFiniteDuration] = this.deadline,
889+
preferredPackageIds: Seq[String] = this.preferredPackageIds,
888890
): submit[C, CmdId0, DomId0] =
889891
new submit(
890892
actAs,
@@ -895,6 +897,7 @@ class SpliceLedgerConnection(
895897
disclosedContracts,
896898
priority,
897899
deadline,
900+
preferredPackageIds,
898901
)
899902

900903
def withDedup(commandId: CommandId, deduplicationOffset: Long)(implicit
@@ -904,6 +907,12 @@ class SpliceLedgerConnection(
904907
commandIdDeduplicationOffset = (commandId, deduplicationOffset)
905908
)
906909

910+
def withPrefferedPackage(packageIds: Seq[String]): submit[C, CmdId, DomId] = {
911+
copy(
912+
preferredPackageIds = packageIds
913+
)
914+
}
915+
907916
def withDedup(commandId: CommandId, deduplicationConfig: DedupConfig)(implicit
908917
cid: DedupNotSpecifiedYet
909918
): submit[C, (CommandId, DedupConfig), DomId] =
@@ -989,6 +998,7 @@ class SpliceLedgerConnection(
989998
disclosedContracts = disclosedContracts,
990999
waitFor = waitFor,
9911000
deadline = deadline,
1001+
preferredPackageIds = preferredPackageIds,
9921002
)
9931003
)(getOffsetAndResult)
9941004

apps/common/src/main/scala/org/lfdecentralizedtrust/splice/environment/ledger/api/LedgerClient.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ private[environment] class LedgerClient(
211211
disclosedContracts: DisclosedContracts,
212212
waitFor: SubmitAndWaitFor[Z],
213213
deadline: Option[NonNegativeFiniteDuration] = None,
214+
preferredPackageIds: Seq[String] = Seq.empty,
214215
)(implicit ec: ExecutionContext, traceContext: TraceContext): Future[Z] = {
215216
val commandsBuilder = CommandsOuterClass.Commands.newBuilder
216217
.setSynchronizerId(synchronizerId)
@@ -221,6 +222,7 @@ private[environment] class LedgerClient(
221222
.addAllCommands {
222223
commands.map(_.toProtoCommand).asJava
223224
}
225+
.addAllPackageIdSelectionPreference(preferredPackageIds.asJava)
224226
.addAllDisclosedContracts(disclosedContracts.toLedgerApiDisclosedContracts.asJava)
225227
deduplicationConfig match {
226228
case DedupOffset(offset) =>

apps/common/src/main/scala/org/lfdecentralizedtrust/splice/http/HttpFeatureSupportHandler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ trait HttpFeatureSupportHandler extends Spanning with NamedLogging {
3434
),
3535
CantonTimestamp.now(),
3636
)
37-
.map { supportNewsGovernanceFlow =>
37+
.map { featureSupport =>
3838
FeatureSupportResponse(
39-
supportNewsGovernanceFlow
39+
featureSupport.supported
4040
)
4141
}
4242
}

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/ScanApp.scala

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,20 @@ class ScanApp(
215215
config.spliceInstanceNames.nameServiceNameAcronym.toLowerCase(),
216216
)
217217
synchronizerId <- appInitStep("Get synchronizer id") {
218-
store
219-
.lookupAmuletRules()
220-
.map(
221-
_.fold(
222-
throw Status.NOT_FOUND
223-
.withDescription("Amulet rules not yet available")
224-
.asRuntimeException()
225-
)(
226-
_.state.fold(
227-
identity,
228-
throw Status.NOT_FOUND
229-
.withDescription("Amulet rules in fllight")
230-
.asRuntimeException(),
231-
)
218+
retryProvider.getValueWithRetries(
219+
RetryFor.WaitingOnInitDependency,
220+
"amulet synchronizer id",
221+
"amulet rules synchronizer id",
222+
store.getAmuletRulesWithState().map {
223+
_.state.fold(
224+
identity,
225+
throw Status.FAILED_PRECONDITION
226+
.withDescription("Amulet rules in fllight")
227+
.asRuntimeException(),
232228
)
233-
)
229+
},
230+
logger,
231+
)
234232
}
235233
packageVersionSupport = PackageVersionSupport.createPackageVersionSupport(
236234
config.parameters.enableCantonPackageSelection,

apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/SvApp.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ object SvApp {
12691269
logger.debug("Trying to create validator license for SV party")
12701270
val dsoParty = store.key.dsoParty
12711271
for {
1272-
supportsValidatorLicenseMetadata <- packageVersionSupport
1272+
validatorLicenseMetadataFeatureSupport <- packageVersionSupport
12731273
.supportsValidatorLicenseMetadata(
12741274
Seq(dsoParty, svParty),
12751275
clock.now,
@@ -1279,9 +1279,11 @@ object SvApp {
12791279
svParty.toProtoPrimitive,
12801280
svParty.toProtoPrimitive,
12811281
Some(BuildInfo.compiledVersion)
1282-
.filter(_ => supportsValidatorLicenseMetadata)
1282+
.filter(_ => validatorLicenseMetadataFeatureSupport.supported)
1283+
.toJava,
1284+
Some(config.contactPoint)
1285+
.filter(_ => validatorLicenseMetadataFeatureSupport.supported)
12831286
.toJava,
1284-
Some(config.contactPoint).filter(_ => supportsValidatorLicenseMetadata).toJava,
12851287
)
12861288
)
12871289
_ <- dsoStoreWithIngestion.connection
@@ -1290,6 +1292,7 @@ object SvApp {
12901292
readAs = Seq(dsoParty),
12911293
cmd,
12921294
)
1295+
.withPrefferedPackage(validatorLicenseMetadataFeatureSupport.packageIds)
12931296
.withDedup(
12941297
commandId = SpliceLedgerConnection.CommandId(
12951298
"org.lfdecentralizedtrust.splice.sv.createSvValidatorLicense",

apps/sv/src/main/scala/org/lfdecentralizedtrust/splice/sv/admin/http/HttpSvHandler.scala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -749,17 +749,18 @@ class HttpSvHandler(
749749
for {
750750
dsoRules <- dsoStore.getDsoRules()
751751
now = clock.now
752-
supportsValidatorLicenseMetadata <- packageVersionSupport.supportsValidatorLicenseMetadata(
753-
Seq(svParty, candidateParty, dsoParty),
754-
now,
755-
)
752+
validatorLicenseMetadataFeatureSupport <- packageVersionSupport
753+
.supportsValidatorLicenseMetadata(
754+
Seq(svParty, candidateParty, dsoParty),
755+
now,
756+
)
756757
cmds = Seq(
757758
dsoRules.exercise(
758759
_.exerciseDsoRules_OnboardValidator(
759760
svParty.toProtoPrimitive,
760761
candidateParty.toProtoPrimitive,
761-
version.filter(_ => supportsValidatorLicenseMetadata).toJava,
762-
contactPoint.filter(_ => supportsValidatorLicenseMetadata).toJava,
762+
version.filter(_ => validatorLicenseMetadataFeatureSupport.supported).toJava,
763+
contactPoint.filter(_ => validatorLicenseMetadataFeatureSupport.supported).toJava,
763764
)
764765
),
765766
validatorOnboarding.exercise(
@@ -769,6 +770,7 @@ class HttpSvHandler(
769770
_ <- dsoStoreWithIngestion.connection
770771
.submit(Seq(svParty), Seq(dsoParty), cmds)
771772
.withSynchronizerId(dsoRules.domain)
773+
.withPrefferedPackage(validatorLicenseMetadataFeatureSupport.packageIds)
772774
.noDedup // No command-dedup required, as the ValidatorOnboarding contract is archived
773775
.yieldUnit()
774776
} yield ()

0 commit comments

Comments
 (0)