Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ testUnclaimedRewards_withCoupons = do
dso = app.dso
validator = alice.primaryParty
round = Round 0
weight = None

validatorLivenessActivityRecord2 <- submitMulti [app.dso] [] $ createCmd ValidatorLivenessActivityRecord with
dso = app.dso
validator = provider1Validator.primaryParty
round = Round 0
weight = None

svRewardCoupon1 <- submitMulti [app.dso, provider2.primaryParty] [] $ createCmd SvRewardCoupon with
dso = app.dso
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ test_ValidatorFaucet = do
map (._2) coupons === [ValidatorLivenessActivityRecord with
dso = app.dso
validator = aliceValidator.primaryParty
round]
round
weight = None]

let checkActivityRecordsDoNotExist round = do
[] <- queryFilter @ValidatorLivenessActivityRecord app.dso (\co -> co.round == round)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ summaryExample1 = OpenMiningRoundSummary with
totalValidatorRewardCoupons = 10000.0
totalFeaturedAppRewardCoupons = 400.0
totalUnfeaturedAppRewardCoupons = 9600.0
optTotalValidatorFaucetCoupons = Some 50
optTotalValidatorFaucetCoupons = None
optTotalValidatorLivenessActivityRecords = Some 50.0
totalSvRewardWeight = 100

expectedParameters_E1_0_0p5 : IssuingRoundParameters
Expand Down Expand Up @@ -130,7 +131,8 @@ summaryExamplNoActivity = OpenMiningRoundSummary with
totalValidatorRewardCoupons = 0.0
totalFeaturedAppRewardCoupons = 0.0
totalUnfeaturedAppRewardCoupons = 0.0
optTotalValidatorFaucetCoupons = Some 0
optTotalValidatorFaucetCoupons = None
optTotalValidatorLivenessActivityRecords = Some 0.0
totalSvRewardWeight = 0

expectedParameters_NoActivity_0_0p5 : IssuingRoundParameters
Expand Down Expand Up @@ -159,7 +161,8 @@ summaryExample3 = OpenMiningRoundSummary with
totalValidatorRewardCoupons = 200.0
totalFeaturedAppRewardCoupons = 100.0
totalUnfeaturedAppRewardCoupons = 100.0
optTotalValidatorFaucetCoupons = Some 50
optTotalValidatorFaucetCoupons = None
optTotalValidatorLivenessActivityRecords = Some 50.0
totalSvRewardWeight = 2


Expand Down Expand Up @@ -190,7 +193,8 @@ summaryExampleLargeSvRewardWeight = OpenMiningRoundSummary with
totalValidatorRewardCoupons = 0.0
totalFeaturedAppRewardCoupons = 0.0
totalUnfeaturedAppRewardCoupons = 0.0
optTotalValidatorFaucetCoupons = Some 0
optTotalValidatorFaucetCoupons = None
optTotalValidatorLivenessActivityRecords = Some 0.0
totalSvRewardWeight = 240 * 10000 -- total weight is 240 and it is represented in basis points

expectedParameters_LargeSvRewardWeight_10plus : IssuingRoundParameters
Expand All @@ -210,6 +214,3 @@ testLargeSvRewardWeight = script do

let actual = computeIssuingRoundParameters tickDuration amuletPrice issuanceConfig_10plus summaryExampleLargeSvRewardWeight
expectedParameters_LargeSvRewardWeight_10plus === actual



5 changes: 4 additions & 1 deletion daml/splice-amulet-test/daml/Splice/Scripts/Util.daml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ setupValidator' app name = do
contactPoint = name <> "@example.com"
lastUpdatedAt = now
lastActiveAt = Some now
weight = None
kind = None

userId <- validateUserId name
-- TODO(#2957): remove read-as DSO party.
Expand Down Expand Up @@ -263,7 +265,8 @@ runNextIssuanceInternal app amuletPrice = do
totalFeaturedAppRewardCoupons = sum [ c.amount | (_, c) <- appRewardCoupons, c.featured]
totalUnfeaturedAppRewardCoupons = sum [ c.amount | (_, c) <- appRewardCoupons, not (c.featured)]
totalSvRewardWeight = sum [ c.weight | (_, c) <- svRewardCoupons]
optTotalValidatorFaucetCoupons = Some (length validatorFaucetCoupons + length validatorLivenessActivityRecords)
optTotalValidatorFaucetCoupons = None
optTotalValidatorLivenessActivityRecords = Some (intToDecimal (length validatorFaucetCoupons) + sum [ fromOptional 1.0 c.weight | (_, c) <- validatorLivenessActivityRecords ])

-- create issuing mining round
submitExerciseAmuletRulesByKey app [app.dso] [] AmuletRules_MiningRound_StartIssuing with
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-amulet/daml/Splice/AmuletRules.daml
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ summarizeAndConsumeInputs csum dso sender inps = do
totalValidatorRewardAmount = s.totalValidatorRewardAmount
totalUnclaimedActivityRecordAmount = s.totalUnclaimedActivityRecordAmount
totalValidatorFaucetAmount =
s.totalValidatorFaucetAmount + getIssuingMiningRoundIssuancePerValidatorFaucetCoupon miningRound
s.totalValidatorFaucetAmount + getIssuingMiningRoundIssuancePerValidatorFaucetCoupon miningRound * fromOptional 1.0 record.weight
totalSvRewardAmount = s.totalSvRewardAmount
totalHoldingFees = s.totalHoldingFees
amountArchivedAsOfRoundZero = s.amountArchivedAsOfRoundZero
Expand Down
14 changes: 10 additions & 4 deletions daml/splice-amulet/daml/Splice/Issuance.daml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ data OpenMiningRoundSummary = OpenMiningRoundSummary with
totalUnfeaturedAppRewardCoupons : Decimal
totalSvRewardWeight : Int
optTotalValidatorFaucetCoupons : Optional Int
optTotalValidatorLivenessActivityRecords : Optional Decimal -- ^ Replaces optTotalValidatorFaucetCoupons
-- ^ Introduced as part of CIP-3.
deriving (Eq, Show)

getTotalValidatorFaucetCoupons : OpenMiningRoundSummary -> Int
getTotalValidatorFaucetCoupons = fromOptional 0 . (.optTotalValidatorFaucetCoupons)
getTotalValidatorFaucetCoupons : OpenMiningRoundSummary -> Decimal
getTotalValidatorFaucetCoupons OpenMiningRoundSummary{optTotalValidatorLivenessActivityRecords, optTotalValidatorFaucetCoupons} =
case (optTotalValidatorLivenessActivityRecords, optTotalValidatorFaucetCoupons) of
(Some _, Some _) -> error "Only optTotalValidatorLivenessActivityRecords or optTotalValidatorFaucetCoupons must be set but not both"
(Some a, None) -> a
(None, Some a) -> intToDecimal a
(None, None) -> 0.0

-- | Parameters to use in a round that issues amulet as rewards for collected coupons.
data IssuingRoundParameters = IssuingRoundParameters with
Expand All @@ -80,7 +86,7 @@ validateOpenMiningRoundSummary summary = do
require "totalValidatorRewardCoupons >= 0.0" (summary.totalValidatorRewardCoupons >= 0.0)
require "totalFeaturedAppRewardCoupons >= 0.0" (summary.totalFeaturedAppRewardCoupons >= 0.0)
require "totalUnfeaturedAppRewardCoupons >= 0.0" (summary.totalUnfeaturedAppRewardCoupons >= 0.0)
require "totalValidatorFaucetCoupons >= 0" (getTotalValidatorFaucetCoupons summary >= 0)
require "totalValidatorFaucetCoupons >= 0" (getTotalValidatorFaucetCoupons summary >= 0.0)

computeIssuingRoundParameters : RelTime -> Decimal -> IssuanceConfig -> OpenMiningRoundSummary -> IssuingRoundParameters
computeIssuingRoundParameters tickDuration amuletPrice config summary =
Expand Down Expand Up @@ -123,7 +129,7 @@ computeIssuingRoundParameters tickDuration amuletPrice config summary =
validatorFaucetIssuance = computeIssuanceTranche
validatorRewardIssuance.unclaimedRewards
(getValidatorFaucetCap config / amuletPrice)
(intToDecimal $ getTotalValidatorFaucetCoupons summary)
(getTotalValidatorFaucetCoupons summary)

unfeaturedAppIssuance = computeIssuanceTranche
(amuletsToIssueInRound * config.appRewardPercentage)
Expand Down
7 changes: 7 additions & 0 deletions daml/splice-amulet/daml/Splice/ValidatorLicense.daml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import Splice.Round
import Splice.Types
import Splice.Util

data LicenseKind = OperatorLicense | NonOperatorLicense
deriving (Eq, Show)

data FaucetState = FaucetState with
firstReceivedFor : Round -- ^ The first round for which a coupon was received.
lastReceivedFor : Round -- ^ The last round for which a coupon was received.
Expand Down Expand Up @@ -56,6 +59,8 @@ template ValidatorLicense with
faucetState : Optional FaucetState
metadata : Optional ValidatorLicenseMetadata
lastActiveAt : Optional Time -- ^ Last time this validator was active. Tracked to get a view on the set of validator nodes that are up and running.
weight : Optional Decimal -- ^ Weight of the activity records produced by this license. Determined through SV votes. If not set, weight is 1.0
kind : Optional LicenseKind -- ^ Type of license: OperatorLicense or NonOperatorLicense. If not set, kind is OperatorLicense
where
signatory dso -- sponsor is not a signatory as that complicates re-issuing crates
observer validator -- not a signatory to simplify the creation of the license as part of onboarding
Expand Down Expand Up @@ -99,6 +104,7 @@ template ValidatorLicense with
dso
validator
round = openRound.round
weight

return ValidatorLicense_RecordValidatorLivenessActivityResult with ..

Expand Down Expand Up @@ -198,6 +204,7 @@ template ValidatorLivenessActivityRecord with
dso : Party
validator : Party
round : Round
weight : Optional Decimal
where
signatory dso
observer validator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ initDecentralizedSynchronizerWithAmuletPrice isDevNet initialRound amuletPrice =
decentralizedSynchronizer = initialDsoDecentralizedSynchronizerConfig
nextScheduledSynchronizerUpgrade = None
voteCooldownTime = None -- use default value of 1 minute
validatorLicenseInstructionTimeout = None -- use default value of 1 hour
let amuletConfig = defaultAmuletConfig
let ansRulesConfig = defaultAnsRulesConfig

Expand Down Expand Up @@ -264,7 +265,8 @@ runNextIssuanceD app amuletPrice = do
totalFeaturedAppRewardCoupons = sum [ c.amount | (_, c) <- appRewardCoupons, c.featured]
totalUnfeaturedAppRewardCoupons = sum [ c.amount | (_, c) <- appRewardCoupons, not (c.featured)]
totalSvRewardWeight = sum [ c.weight | (_, c) <- svRewardCoupons]
optTotalValidatorFaucetCoupons = Some (length validatorFaucetCoupons + length validatorLivenessActivityRecords)
optTotalValidatorFaucetCoupons = None
optTotalValidatorLivenessActivityRecords = Some (intToDecimal $ length validatorFaucetCoupons + length validatorLivenessActivityRecords)

-- create issuing mining round
submitExerciseAmuletRulesByKey app [app.dso] [] AmuletRules_MiningRound_StartIssuing with
Expand Down
Loading