Skip to content

Commit

Permalink
Changes from release 0.1.13 (#7)
Browse files Browse the repository at this point in the history
* Fix update script so it also works on mac.

* Update scripts/update.sh

Co-authored-by: Stanislav German-Evtushenko (SBI) <[email protected]>

* Fix copyright header handling (did not work on mac)

* Changes from release 0.1.13.

---------

Co-authored-by: Stanislav German-Evtushenko (SBI) <[email protected]>
  • Loading branch information
ray-roestenburg-da and stas-sbi authored Jul 1, 2024
1 parent 32d3186 commit 688c163
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 17 deletions.
2 changes: 1 addition & 1 deletion daml/splice-amulet-name-service-test/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-amulet-name-service-test
source: daml
version: 0.1.2
version: 0.1.3
dependencies:
- daml-prim
- daml-stdlib
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-amulet-name-service/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-amulet-name-service
source: daml
version: 0.1.2
version: 0.1.3
dependencies:
- daml-prim
- daml-stdlib
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-amulet-test/daml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-amulet-test
source: daml
version: 0.1.2
version: 0.1.3
dependencies:
- daml-prim
- daml-stdlib
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-amulet/daml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-amulet
source: daml
version: 0.1.2
version: 0.1.3
dependencies:
- daml-prim
- daml-stdlib
Expand Down
83 changes: 81 additions & 2 deletions daml/splice-amulet/daml/Splice/ValidatorLicense.daml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
module Splice.ValidatorLicense where

import DA.Action (void)
import DA.Text as Text
import DA.Time
import qualified DA.Foldable as Foldable

import Splice.Round
import Splice.Types
Expand All @@ -23,18 +26,36 @@ data ValidatorLicense_WithdrawResult = ValidatorLicense_WithdrawResult

data ValidatorLicense_CancelResult = ValidatorLicense_CancelResult

data ValidatorLicense_UpdateMetadataResult = ValidatorLicense_UpdateMetadataResult with
licenseCid : ContractId ValidatorLicense

data ValidatorLicense_ReportActiveResult = ValidatorLicense_ReportActiveResult with
licenseCid : ContractId ValidatorLicense

data ValidatorFaucetCoupon_DsoExpireResult = ValidatorFaucetCoupon_DsoExpireResult

data ValidatorLicenseMetadata = ValidatorLicenseMetadata
with
lastUpdatedAt : Time -- ^ The last time the validator metadata was updated
version : Text -- ^ The version the validator is currently on
contactPoint : Text -- ^ A contact point that can be used to reach the operator of the validator in case there are issues with the validator.
-- This can be an email address or a slack user name.
deriving (Show, Eq)

-- | The existence of a validator license is what makes a validator an (onboarded) validator.
template ValidatorLicense with
validator : Party -- ^ The validator (party) that this license is about.
sponsor : Party -- ^ The SV node that sponsored the onboarding.
dso : Party -- ^ The party representing the operations of the decentralized synchronizer.
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.

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

ensure validValidatorLicense this

-- We expect the wallet of the validator to call this choice automatically.
choice ValidatorLicense_ReceiveFaucetCoupon : ValidatorLicense_ReceiveFaucetCouponResult
Expand All @@ -59,7 +80,7 @@ template ValidatorLicense with
lastReceivedFor = openRound.round
numCouponsMissed = state.numCouponsMissed + (openRound.round.number - state.lastReceivedFor.number - 1)

licenseCid <- create this with faucetState = newFaucetState
licenseCid <- create this with faucetState = newFaucetState; lastActiveAt = Some now

couponCid <- create ValidatorFaucetCoupon with
dso
Expand All @@ -81,6 +102,65 @@ template ValidatorLicense with
do return ValidatorLicense_CancelResult


choice ValidatorLicense_UpdateMetadata : ValidatorLicense_UpdateMetadataResult
with
version : Text
contactPoint : Text
controller validator
do now <- getTime
Foldable.forA_ metadata $ \metadata -> do
require "Metadata has changed" (version /= metadata.version || contactPoint /= metadata.contactPoint)
require
("At least " <> show metadataUpdateMinInterval <> " has passed since the last metadata update")
(metadataUpdateAllowed metadata.lastUpdatedAt now)
licenseCid <- create this with
metadata = Some ValidatorLicenseMetadata with
version
lastUpdatedAt = now
contactPoint
lastActiveAt = Some now
pure (ValidatorLicense_UpdateMetadataResult licenseCid)

choice ValidatorLicense_ReportActive : ValidatorLicense_ReportActiveResult
-- ^ Choice for validators with disabled wallets to report themselves as active.
-- Validators that receive amulets will report through ReceiveFaucetCoupon.
controller validator
do now <- getTime
Foldable.forA_ lastActiveAt $ \activeAt -> do
require
("At least <> show activityReportMinInterval " <> " has passed since the last activity report")
(activityReportAllowed activeAt now)
licenseCid <- create this with
lastActiveAt = Some now
pure (ValidatorLicense_ReportActiveResult licenseCid)


metadataUpdateMinInterval : RelTime
metadataUpdateMinInterval = hours 1

activityReportMinInterval : RelTime
activityReportMinInterval = metadataUpdateMinInterval

metadataUpdateAllowed : Time -> Time -> Bool
metadataUpdateAllowed previous now =
now `subTime` previous >= metadataUpdateMinInterval

activityReportAllowed : Time -> Time -> Bool
activityReportAllowed previous now =
now `subTime` previous >= activityReportMinInterval

validValidatorLicense : ValidatorLicense -> Bool
validValidatorLicense license =
optional True validValidatorLicenseMetadata license.metadata

maxIdentifierLength : Int
maxIdentifierLength = 255

validValidatorLicenseMetadata : ValidatorLicenseMetadata -> Bool
validValidatorLicenseMetadata metadata =
Text.length metadata.contactPoint <= maxIdentifierLength &&
Text.length metadata.version <= maxIdentifierLength

template ValidatorFaucetCoupon with
dso : Party
validator : Party
Expand All @@ -97,7 +177,6 @@ template ValidatorFaucetCoupon with
void $ fetchReferenceData (ForRound with dso; round) closedRoundCid
return ValidatorFaucetCoupon_DsoExpireResult


-- instances
------------

Expand Down
2 changes: 1 addition & 1 deletion daml/splice-dso-governance-test/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-dso-governance-test
source: daml
version: 0.1.3
version: 0.1.4
dependencies:
- daml-prim
- daml-stdlib
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-dso-governance/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-dso-governance
source: daml
version: 0.1.3
version: 0.1.4
dependencies:
- daml-prim
- daml-stdlib
Expand Down
35 changes: 29 additions & 6 deletions daml/splice-dso-governance/daml/Splice/DsoRules.daml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ data DsoRules_ActionRequiringConfirmation
-- ^ Revoke a specific featured app right.
| SRARC_SetConfig DsoRules_SetConfig
-- ^ Voted action to change the `DsoRulesConfig`. Not idempotent.
| SRARC_UpdateSvRewardWeight DsoRules_UpdateSvRewardWeight
-- ^ Voted action to update the reward weight of an SV.
deriving (Eq, Show)

data AnsEntryContext_ActionRequiringConfirmation
Expand Down Expand Up @@ -183,6 +185,9 @@ data DsoRules_GarbageCollectAmuletPriceVotesResult = DsoRules_GarbageCollectAmul
data DsoRules_SetConfigResult = DsoRules_SetConfigResult with
newDsoRules : ContractId DsoRules

data DsoRules_UpdateSvRewardWeightResult = DsoRules_UpdateSvRewardWeightResult with
newDsoRules : ContractId DsoRules

data DsoRules_GrantFeaturedAppRightResult = DsoRules_GrantFeaturedAppRightResult with
featuredAppRight : ContractId FeaturedAppRight

Expand Down Expand Up @@ -721,12 +726,8 @@ template DsoRules with
else pure VRO_Expired
-- check if the request is ready to be closed
when (now < request.voteBefore) $ do
let svBeingOffboarded = case request.action of
ARC_DsoRules (SRARC_OffboardSv (DsoRules_OffboardSv with sv)) ->
fmap (.name) (Map.lookup sv svs)
_ -> None
require "All svs (except one being offboarded) must have voted to allow early closing" $
all (\m -> Some m == svBeingOffboarded || m `Map.member` request.votes) activeSvs
require "All svs must have voted to allow early closing" $
all (\m -> m `Map.member` request.votes) activeSvs
require "The outcome must be determined allow early closing" (outcome /= VRO_Expired)
-- report the result
pure DsoRules_CloseVoteRequestResult with
Expand Down Expand Up @@ -810,6 +811,22 @@ template DsoRules with
newDsoRules <- create this with config = newConfig
return DsoRules_SetConfigResult with ..

choice DsoRules_UpdateSvRewardWeight : DsoRules_UpdateSvRewardWeightResult
with
svParty : Party
newRewardWeight : Int
controller dso
do
require "New reward weight is positive" (newRewardWeight >= 0)
case Map.lookup svParty svs of
None -> fail "SV party is not registered"
Some sv -> do
let newSv = sv with svRewardWeight = newRewardWeight
let newSvs = Map.insert svParty newSv svs
newDsoRules <- create this with svs = newSvs
return DsoRules_UpdateSvRewardWeightResult with ..



-- App rights management
------------------------
Expand Down Expand Up @@ -840,15 +857,20 @@ template DsoRules with
with
sponsor : Party
validator : Party
version : Optional Text
contactPoint : Optional Text
controller sponsor
do
require "Sponsor is an SV" (sponsor `Map.member` svs)
-- create license that records in particular which SV sponsored the onboarding of the validator
now <- getTime
validatorLicense <- create ValidatorLicense with
dso
sponsor
validator
faucetState = None
metadata = fmap (\version -> ValidatorLicenseMetadata with version; contactPoint = fromOptional "" contactPoint; lastUpdatedAt = now) version
lastActiveAt = Some now
return DsoRules_OnboardValidatorResult with ..


Expand Down Expand Up @@ -1191,6 +1213,7 @@ executeActionRequiringConfirmation dsoRulesCid amuletRulesCid act = case act of
SRARC_GrantFeaturedAppRight choiceArg -> void $ exercise dsoRulesCid choiceArg
SRARC_RevokeFeaturedAppRight choiceArg -> void $ exercise dsoRulesCid choiceArg
SRARC_SetConfig choiceArg -> void $ exercise dsoRulesCid choiceArg
SRARC_UpdateSvRewardWeight choiceArg -> void $ exercise dsoRulesCid choiceArg
ARC_AnsEntryContext with .. ->
case ansEntryContextAction of
ANSRARC_CollectInitialEntryPayment choiceArg -> void $ exercise ansEntryContextCid choiceArg
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-wallet-payments/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-wallet-payments
source: daml
version: 0.1.2
version: 0.1.3
dependencies:
- daml-prim
- daml-stdlib
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-wallet-test/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-wallet-test
source: daml
version: 0.1.2
version: 0.1.3
dependencies:
- daml-prim
- daml-stdlib
Expand Down
2 changes: 1 addition & 1 deletion daml/splice-wallet/daml.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sdk-version: 3.0.0-snapshot.20240318.12913.0.v1c415c97
name: splice-wallet
source: daml
version: 0.1.2
version: 0.1.3
dependencies:
- daml-prim
- daml-stdlib
Expand Down

0 comments on commit 688c163

Please sign in to comment.