Skip to content

Commit 46b6bfa

Browse files
CIP-82: Update Daml model + new trigger in SV app for merging UnclaimedDevelopmentFundCoupons (#3594)
* Daml: Add support for DevelopmentFundCoupon PR reviewed in #3426 CI run #3451 Signed-off-by: Jose Velasco <jose.velasco@intellecteu.com> * CIP-82 (Scala): Add MergeUnclaimedDevelopmentFundCouponsTrigger (#3522) PR reviewed in #3522 CI run #3522 Signed-off-by: Jose Velasco <jose.velasco@intellecteu.com> * CIP-82 (DAML/Docs): Default optDevelopmentFundPercentage to 0.05 + releases notes (#3576) - Default optDevelopmentFundPercentage to 0.05 in AmuletRules_MiningRound_StartIssuing in case when None. - Account for development fund support when optDevelopmentFundPercentage is set during SV1Initializer bootstrapping. - Add release note/ PR reviewed in #3576 CI run #3576 Signed-off-by: Jose Velasco <jose.velasco@intellecteu.com> * [ci] Signed-off-by: Jose Velasco <jose.velasco@intellecteu.com> --------- Signed-off-by: Jose Velasco <jose.velasco@intellecteu.com>
1 parent f1f6b07 commit 46b6bfa

File tree

76 files changed

+1554
-121
lines changed

Some content is hidden

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

76 files changed

+1554
-121
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ object ConfigTransforms {
200200
updateAllAutomationConfigs(
201201
_.copy(rewardOperationRoundsCloseBufferDuration = NonNegativeFiniteDuration.ofMillis(100))
202202
),
203+
disableDevelopmentFund(),
203204
)
204205
}
205206

@@ -299,6 +300,9 @@ object ConfigTransforms {
299300
def disableZeroFees(): ConfigTransform =
300301
updateAllSvAppFoundDsoConfigs_(c => c.copy(zeroTransferFees = false))
301302

303+
def disableDevelopmentFund(): ConfigTransform =
304+
updateAllSvAppFoundDsoConfigs_(c => c.copy(developmentFundPercentage = Some(0.0)))
305+
302306
def updateAllValidatorAppConfigs(
303307
update: (String, ValidatorAppBackendConfig) => ValidatorAppBackendConfig
304308
): ConfigTransform =
@@ -718,6 +722,9 @@ object ConfigTransforms {
718722
}
719723
}
720724

725+
def withDevelopmentFundPercentage(percentage: BigDecimal): ConfigTransform =
726+
updateAllSvAppFoundDsoConfigs_(c => c.copy(developmentFundPercentage = Some(percentage)))
727+
721728
private def portTransform(bump: Int, c: AdminServerConfig): AdminServerConfig =
722729
c.copy(internalPort = c.internalPort.map(_ + bump))
723730

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ class AppUpgradeIntegrationTest
258258
),
259259
java.util.Optional.empty(),
260260
java.util.Optional.empty(),
261+
java.util.Optional.empty(),
261262
)
262263
val upgradeAction = new ARC_AmuletRules(
263264
new CRARC_SetConfig(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ class BootstrapPackageConfigIntegrationTest extends IntegrationTest with Splitwe
229229
),
230230
java.util.Optional.empty(),
231231
java.util.Optional.empty(),
232+
java.util.Optional.empty(),
232233
)
233234

234235
val upgradeAction = new ARC_AmuletRules(
@@ -368,6 +369,7 @@ class BootstrapPackageConfigIntegrationTest extends IntegrationTest with Splitwe
368369
amuletConfig.packageConfig,
369370
java.util.Optional.empty(),
370371
java.util.Optional.empty(),
372+
java.util.Optional.empty(),
371373
)
372374

373375
val upgradeAction = new ARC_AmuletRules(
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package org.lfdecentralizedtrust.splice.integration.tests
2+
3+
import com.digitalasset.canton.config.NonNegativeFiniteDuration
4+
import org.lfdecentralizedtrust.splice.codegen.java.splice.amulet.UnclaimedDevelopmentFundCoupon
5+
import org.lfdecentralizedtrust.splice.config.ConfigTransforms
6+
import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{
7+
ConfigurableApp,
8+
updateAutomationConfig,
9+
}
10+
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
11+
import org.lfdecentralizedtrust.splice.sv.automation.delegatebased.AdvanceOpenMiningRoundTrigger
12+
import org.lfdecentralizedtrust.splice.util.{TriggerTestUtil, WalletTestUtil}
13+
14+
@org.lfdecentralizedtrust.splice.util.scalatesttags.SpliceDsoGovernance_0_1_21
15+
class DevelopmentFundCouponIntegrationTest
16+
extends SvIntegrationTestBase
17+
with TriggerTestUtil
18+
with WalletTestUtil {
19+
20+
private val threshold = 3
21+
22+
override def environmentDefinition
23+
: org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition =
24+
EnvironmentDefinition
25+
.simpleTopology1Sv(this.getClass.getSimpleName)
26+
.addConfigTransforms((_, config) =>
27+
updateAutomationConfig(ConfigurableApp.Sv)(
28+
_.withPausedTrigger[AdvanceOpenMiningRoundTrigger]
29+
)(config)
30+
)
31+
.addConfigTransform((_, config) =>
32+
ConfigTransforms.updateInitialTickDuration(NonNegativeFiniteDuration.ofMillis(500))(config)
33+
)
34+
.addConfigTransforms((_, config) =>
35+
ConfigTransforms.updateAllSvAppConfigs_(
36+
_.copy(
37+
unclaimedDevelopmentFundCouponsThreshold = threshold
38+
)
39+
)(config)
40+
)
41+
.addConfigTransform((_, config) =>
42+
ConfigTransforms.withDevelopmentFundPercentage(0.05)(config)
43+
)
44+
45+
"UnclaimedDevelopmentFundCoupons are merged" in { implicit env =>
46+
val (_, couponAmount) = actAndCheck(
47+
"Advance 5 rounds", {
48+
Range(0, 5).foreach(_ => advanceRoundsByOneTickViaAutomation())
49+
},
50+
)(
51+
"5 UnclaimedDevelopmentFundCoupons are created, and the trigger does not merge the coupons, " +
52+
"as it only acts when the number of coupons is ≥ 2 × threshold",
53+
_ => {
54+
val coupons = sv1Backend.participantClient.ledger_api_extensions.acs
55+
.filterJava(UnclaimedDevelopmentFundCoupon.COMPANION)(dsoParty)
56+
coupons.size shouldBe 5
57+
coupons.head.data.amount
58+
},
59+
)
60+
61+
actAndCheck(
62+
"Advance one round to create one more UnclaimedDevelopmentFundCoupon, reaching 2 × threshold coupons",
63+
advanceRoundsByOneTickViaAutomation(),
64+
)(
65+
"The MergeUnclaimedDevelopmentFundCouponsTrigger is triggered and merges the smallest three coupons (threshold), " +
66+
"while keeping the remaining coupons unchanged.",
67+
_ => {
68+
sv1Backend.participantClient.ledger_api_extensions.acs
69+
.filterJava(UnclaimedDevelopmentFundCoupon.COMPANION)(dsoParty)
70+
.map(_.data.amount)
71+
.sorted shouldBe Seq(
72+
couponAmount,
73+
couponAmount,
74+
couponAmount,
75+
couponAmount.multiply(new java.math.BigDecimal(3)),
76+
)
77+
},
78+
)
79+
80+
actAndCheck(
81+
"Advance two rounds to create two more UnclaimedDevelopmentFundCoupon, " +
82+
"reaching 2 × threshold coupons and triggering a second merge",
83+
Range(0, 2).foreach(_ => advanceRoundsByOneTickViaAutomation()),
84+
)(
85+
"The MergeUnclaimedDevelopmentFundCouponsTrigger merges the `threshold` smallest coupons",
86+
_ => {
87+
sv1Backend.participantClient.ledger_api_extensions.acs
88+
.filterJava(UnclaimedDevelopmentFundCoupon.COMPANION)(dsoParty)
89+
.map(_.data.amount)
90+
.sorted shouldBe Seq(
91+
couponAmount,
92+
couponAmount,
93+
couponAmount.multiply(new java.math.BigDecimal(3)),
94+
couponAmount.multiply(new java.math.BigDecimal(3)),
95+
)
96+
},
97+
)
98+
}
99+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class DisabledWalletTimeBasedIntegrationTest
6868
val expectedMinAmount =
6969
BigDecimal(
7070
computeSvRewardInRound0(
71-
defaultIssuanceCurve.initialValue,
71+
defaultIssuanceCurve().initialValue,
7272
defaultTickDuration,
7373
dsoSize = 1,
7474
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class ScanWithGradualStartsTimeBasedIntegrationTest
143143
val svRewardPerRound =
144144
BigDecimal(
145145
computeSvRewardInRound0(
146-
defaultIssuanceCurve.initialValue,
146+
defaultIssuanceCurve().initialValue,
147147
defaultTickDuration,
148148
dsoSize = 2,
149149
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class SvReconcileSynchronizerConfigIntegrationTest extends SvIntegrationTestBase
141141
amuletConfig.packageConfig,
142142
java.util.Optional.empty(),
143143
java.util.Optional.empty(),
144+
java.util.Optional.empty(),
144145
)
145146

146147
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ class SvStateManagementIntegrationTest extends SvIntegrationTestBase with Trigge
487487
initialConfig.packageConfig,
488488
java.util.Optional.empty(),
489489
java.util.Optional.empty(),
490+
java.util.Optional.empty(),
490491
)
491492

492493
val (_, voteRequestCid) = actAndCheck(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class SvTimeBasedRewardCouponIntegrationTest
170170
}
171171

172172
val eachSvGetInRound0 =
173-
computeSvRewardInRound0(defaultIssuanceCurve.initialValue, defaultTickDuration, svs.size)
173+
computeSvRewardInRound0(defaultIssuanceCurve().initialValue, defaultTickDuration, svs.size)
174174
val sv1Party = sv1Backend.getDsoInfo().svParty
175175
val aliceValidatorParty = aliceValidatorBackend.getValidatorPartyId()
176176
val expectedAliceAmount = eachSvGetInRound0.multiply(new java.math.BigDecimal("0.3333"))

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/util/AmuletConfigUtil.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ trait AmuletConfigUtil extends TestCommon {
6464
existingAmuletConfig.packageConfig,
6565
existingAmuletConfig.transferPreapprovalFee,
6666
existingAmuletConfig.featuredAppActivityMarkerAmount,
67+
existingAmuletConfig.optDevelopmentFundManager,
6768
)
6869
}
6970

0 commit comments

Comments
 (0)