# 期限切れと重複を片付ける

> SVが実行する期限切れや重複を片付けるchoiceが、どのコントラクトを受け取るかと、重複した価格の投票を片付ける道を、表と2つの図で追います。

- URL: https://cardene.dev/diagrams/canton-dso-housekeeping
- 公開日: 2026-11-21
- 更新日: 2026-11-21
- トピック: Blockchain
- タグ: Canton
- 親の図解: [DSOの投票とConfirmation](https://cardene.dev/diagrams/canton-dso-governance.md): DSOがSVの投票とconfirmationで行動を決めて実行する仕組みを、章の中の図解で追います。

`DsoRules`のchoiceには、controllerが`sv`で、AmuletやCNSの名前のコントラクトを受け取る物があります。
そこで、この頁では、期限切れと重複を片付けるchoiceが、どのコントラクトを受け取り、重複した価格の投票をどう片付けるかを追います。

前の頁「Confirmationで定期の行動を進める」では、confirmationを集めて行動を実行する道と、投票の行動と自動の行動の分かれ方を見ました。

https://cardene.dev/diagrams/canton-dso-confirm

signatoryとchoiceとcontrollerは、Damlでコントラクトと操作の認可を表す語で、「誰が変更を頼めるかを決める」の頁で見ました。

https://cardene.dev/diagrams/canton-ledger-authorization

Optionalは、値がある時と無い時を分ける型で、値が無い時はNoneです。
`DsoRules`は、DSOの規則のコントラクトです。
Amuletは、Canton Coinを実装するコードの総称で、「Canton Networkの用語を引く」の頁で見ました。

https://cardene.dev/diagrams/canton-network-glossary

CNSは、Canton Name Serviceの略で、partyが人が読める名前を買い、自分のpartyに結び付けられるようにする名前の登録簿のサービスです。
`AmuletPriceVote`と`SvRewardState`は、「DSOがSVごとに追う状態」の頁で見たtemplateです。

https://cardene.dev/diagrams/canton-sv-state

図Aの葉と図Bの箱の名前は、価格の投票が`AmuletPriceVote`、CNSの名前が`AnsEntry`、ロックされたAmuletが`LockedAmulet`、サブスクリプションが`SubscriptionIdleState`のことです。
送金の事前承認は、`transferPreapprovalCid`の指すコントラクトのことです。
memberのtrafficは`MemberTraffic`、SVの報酬の状態は`SvRewardState`、未請求の報酬は`UnclaimedReward`、validatorのlicenseは`ValidatorLicense`のことで、`ValidatorLicense`は「licenseで活動を報告する」の頁で見ました。

https://cardene.dev/diagrams/canton-validator-license

## 片付けるコントラクトの区分

次の図Aでは、SVが片付けるコントラクトを、choiceの名前の区分ごとに追います。
この図では、片付けるコントラクトを根に、期限切れの物、マージする物、価格の投票の3つを枝、コントラクトの種類を葉にして、枝は、区分とコントラクトの種類の関係だけに引きます。
区分は、この頁の表に載せたchoiceを、名前に`Expire`と`Merge`と`GarbageCollect`を含むかで分けます。
段2から段4は区分ごとに追う段で、起きる順を示しません。

```dragon
mind 片付けるコントラクトの区分

step 区分に分ける
  say この図では、この頁の表に載せたchoiceが片付けるコントラクトを、名前で、期限切れの物とマージする物と価格の投票に分けます。
  idea root as 片付けるコントラクト [color: coin]
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]

step 期限切れの側
  say 期限切れの側のchoiceは、AmuletとロックされたAmulet、CNSの名前、サブスクリプション、送金の事前承認を受け取ります。
  idea e as "期限切れのコントラクト" of root [color: blue]
  idea e1 as "Amulet" of e
  idea e2 as "ロックされたAmulet" of e
  idea e5 as "CNSの名前" of e
  idea e6 as "サブスクリプション" of e
  idea e7 as "送金の事前承認" of e
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]

step マージする側
  say マージする側のchoiceは、memberのtrafficと、SVの報酬の状態と、未請求の報酬と、validatorのlicenseのコントラクトをリストで受け取ります。
  idea m as "マージするコントラクト" of root [color: blue]
  idea m1 as "memberのtraffic" of m
  idea m2 as "SVの報酬の状態" of m
  idea m3 as "未請求の報酬" of m
  idea m4 as "validatorのlicense" of m
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]

step 価格の投票の側
  say 価格の投票を片付けるchoiceは、外されたSVの価格の投票と、重複した価格の投票を片付けます。
  idea g as "価格の投票" of root [color: blue]
  idea g1 as "外されたSVの価格の投票" of g
  idea g2 as "重複した価格の投票" of g
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]
```

## 名前にExpireを含むchoice

次の表のchoiceは、この頁が扱うchoiceのうち、名前に`Expire`か`Expired`を含む物で、どれもcontrollerが`sv`です。
`V2`の付いたchoiceは同じ行に並べ、返す物も同じ順に並べます。

| choice | controller | 受け取る物 | 返す物 |
|---|---|---|---|
| `DsoRules_Amulet_Expire`と`DsoRules_Amulet_ExpireV2` | `sv` | `Amulet`のIDの`cid`と、`Amulet_Expire`か`Amulet_ExpireV2`の`choiceArg`と、Optionalの`sv` | `DsoRules_Amulet_ExpireResult`と`DsoRules_Amulet_ExpireV2Result` |
| `DsoRules_Amulet_ExpireTransferInstructions` | `sv` | `amuletRulesCid`と、型が`AmuletRules_Amulet_ExpireTransferInstructions`の`transferInsts`と、`sv` | `DsoRules_Amulet_ExpireTransferInstructionsResult` |
| `DsoRules_LockedAmulet_ExpireAmulet`と`DsoRules_LockedAmulet_ExpireAmuletV2` | `sv` | `LockedAmulet`のIDの`cid`と、`LockedAmulet_ExpireAmulet`か`LockedAmulet_ExpireAmuletV2`の`choiceArg`と、Optionalの`sv` | `DsoRules_LockedAmulet_ExpireAmuletResult`と`DsoRules_LockedAmulet_ExpireAmuletV2Result` |
| `DsoRules_ExpireAmuletAllocations` | `sv` | 型が`ExternalPartyAmuletRules`の`extAmuletRulesCid`と、型が`ExternalPartyAmuletRules_ExpireAmuletAllocations`の`expireAllocations`と、`sv` | `DsoRules_ExpireAmuletAllocationsResult` |
| `DsoRules_ExpireAnsEntry` | `sv` | `AnsEntry`のIDの`ansEntryCid`と、型が`AnsEntry_Expire`の`choiceArg`と、Optionalの`sv` | `DsoRules_ExpireAnsEntryResult` |
| `DsoRules_ExpireSubscription` | `sv` | `ansEntryContextCid`と、`subscriptionIdleStateCid`と、型が`SubscriptionIdleState_ExpireSubscription`の`choiceArg`と、Optionalの`sv` | `DsoRules_ExpireSubscriptionResult` |
| `DsoRules_ExpireTransferPreapproval` | `sv` | `transferPreapprovalCid`と、Optionalの`sv` | `DsoRules_ExpireTransferPreapprovalResult` |
| `DsoRules_ClaimExpiredRewards` | `sv` | `amuletRulesCid`と、型が`AmuletRules_ClaimExpiredRewards`の`choiceArg`と、Optionalの`sv` | `DsoRules_ClaimExpiredRewardsResult` |

## CNSの名前とサブスクリプションのchoice

次の表のchoiceも、controllerが`sv`で、`ansEntryContextCid`を受け取ります。

| choice | controller | 受け取る物 | 返す物 |
|---|---|---|---|
| `DsoRules_CollectEntryRenewalPayment` | `sv` | `ansEntryContextCid`と、型が`AnsEntryContext_CollectEntryRenewalPayment`の`choiceArg`と、Optionalの`sv` | `DsoRules_CollectEntryRenewalPaymentResult` |
| `DsoRules_TerminateSubscription` | `sv` | `ansEntryContextCid`と、型が`TerminatedSubscription`の`terminatedSubscriptionCid`と、Optionalの`sv` | `DsoRules_TerminateSubscriptionResult` |

## コントラクトをマージするchoice

次の表のchoiceは、名前に`Merge`を含み、コントラクトのリストを受け取ります。
`DsoRules_MergeSvRewardState`は、不具合#12495が生んだ重複のコントラクトを片付けるためだけにあり、今後は重複が起きないはずです。
`DsoRules_MergeValidatorLicense`は、重複した古いlicenseを消し、`lastReceivedFor`のroundが最も大きいlicenseを1つ作り直します。
このchoiceも、今後は重複が起きないはずです。

| choice | controller | 受け取る物 | 返す物 |
|---|---|---|---|
| `DsoRules_MergeMemberTrafficContracts` | `sv` | `amuletRulesCid`と、`MemberTraffic`のリストの`trafficCids`と、Optionalの`sv` | `DsoRules_MergeMemberTrafficContractsResult` |
| `DsoRules_MergeSvRewardState` | `sv` | `svName`と、`SvRewardState`のリストの`rewardStateCids`と、Optionalの`sv` | `DsoRules_MergeSvRewardStateResult` |
| `DsoRules_MergeUnclaimedRewards` | `sv` | `amuletRulesCid`と、`UnclaimedReward`のリストの`unclaimedRewardCids`と、Optionalの`sv` | `DsoRules_MergeUnclaimedRewardsResult` |
| `DsoRules_MergeValidatorLicense` | `sv` | `validatorLicenseCids`と、Optionalの`sv` | `DsoRules_MergeValidatorLicenseResult` |

マージするchoiceの戻り値は、1つのコントラクトのIDです。
次の表が、結果の型ごとの欄です。

| 結果の型 | 欄 |
|---|---|
| `DsoRules_MergeMemberTrafficContractsResult` | `memberTraffic` |
| `DsoRules_MergeSvRewardStateResult` | `svRewardState` |
| `DsoRules_MergeUnclaimedRewardsResult` | `unclaimedReward` |
| `DsoRules_MergeValidatorLicenseResult` | `validatorLicense` |

## 重複した価格の投票を片付ける道

`DsoRules_GarbageCollectAmuletPriceVotes`は、外されたSVの`AmuletPriceVote`と、SVを外してすぐに足し直した時に生じうる重複の投票を片付けます。
このchoiceは、`DsoRules`のコントラクトに対する`OnAssignedContractTrigger`として動くことを想定しています。
SVを外す時に、そのSVの`AmuletPriceVote`をアーカイブしないのは、アーカイブすると、そのSVがちょうどよい時に投票を更新して、自分を外すことを妨げられるからです。
このchoiceのコードは、`AmuletPriceVote`を残し続ける形に替えて外す見込みです。

次の図Bでは、外されたSVの価格の投票が、片付けられるまでを追います。
この図では、箱を、SVとDsoRulesと価格の投票の3つで描き、線は、SVがchoiceを実行する場面と、choiceが価格の投票を片付ける場面にだけ引きます。
段1と段4と段5は、線を置かず、価格の投票とchoiceの動かし方と見込みを言う段です。

```dragon
sequence 重複した価格の投票を片付ける道

box S as SV [note: choiceを実行する, color: rose, icon: user]
box D as DsoRules [note: DSOの規則, color: slate, icon: layers]
box P as 価格の投票 [note: 片付ける対象, color: blue, icon: card]

step 価格の投票を残す
  say SVを外す時は、そのSVの価格の投票をアーカイブしません。アーカイブすると、そのSVがちょうどよい時に価格の投票を更新して、自分を外すことを妨げられるためです。
  act P: 外してもアーカイブしない
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]

step choiceを実行する
  say SVが、片付けるchoiceを実行します。choiceは、価格の投票のIDのリストと、価格の投票のIDのリストのリストを受け取ります。
  S -> D: 実行
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]

step 価格の投票を片付ける
  say choiceは、外されたSVの価格の投票と、SVを外してすぐに足し直した時に生じうる重複した価格の投票を片付けます。
  D -> P: 片付ける
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]

step 動かし方
  say このchoiceは、DsoRulesのコントラクトに対して動くことを想定しています。
  act D: DsoRulesに対して動く想定
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]

step コードの見込み
  say このchoiceのコードは、価格の投票を残し続ける形に替えて、外す見込みです。
  act D: 外す見込み
  source CantonのSplice.DsoRules [url: https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules]
```

次の表が、このchoiceです。

| choice | controller | 受け取る物 | 返す物 |
|---|---|---|---|
| `DsoRules_GarbageCollectAmuletPriceVotes` | `sv` | `AmuletPriceVote`のリストの`nonSvVoteCids`と、`AmuletPriceVote`のリストのリストの`duplicateVoteCids`と、Optionalの`sv` | `DsoRules_GarbageCollectAmuletPriceVotesResult` |

## 結果の型の欄

次の表が、片付けるchoiceの結果の型ごとの欄です。

| 結果の型 | 欄 |
|---|---|
| `DsoRules_Amulet_ExpireResult` | `expireSum`。型は`AmuletExpireSummary` |
| `DsoRules_Amulet_ExpireV2Result` | `expireSum`。型は`AmuletExpireV2Summary` |
| `DsoRules_Amulet_ExpireTransferInstructionsResult` | `result` |
| `DsoRules_LockedAmulet_ExpireAmuletResult` | `expireSum`。型は`AmuletExpireSummary` |
| `DsoRules_LockedAmulet_ExpireAmuletV2Result` | `expireSum`。型は`AmuletExpireV2Summary` |
| `DsoRules_ClaimExpiredRewardsResult` | `unclaimedReward`。型はOptionalの`UnclaimedReward` |
| `DsoRules_CollectEntryRenewalPaymentResult` | `ansEntry`と`subscriptionState`。型はそれぞれ`AnsEntry`と`SubscriptionIdleState` |
| `DsoRules_ExpireAmuletAllocationsResult` | `result`。型は`ExternalPartyAmuletRules_ExpireAmuletAllocationsResult` |

次の戻り値の型は、欄を持ちません。

| 欄を持たない結果の型 |
|---|
| `DsoRules_ArchiveOutdatedElectionRequestResult` |
| `DsoRules_ArchiveSvOnboardingRequestResult` |
| `DsoRules_BootstrapExternalPartyConfigStateResult` |
| `DsoRules_ExpireAnsEntryResult` |
| `DsoRules_ExpireStaleConfirmationResult` |
| `DsoRules_ExpireSubscriptionResult` |
| `DsoRules_ExpireSvOnboardingRequestResult` |
| `DsoRules_ExpireTransferPreapprovalResult` |
| `DsoRules_ExpireUnallocatedUnclaimedActivityRecordResult` |
| `DsoRules_GarbageCollectAmuletPriceVotesResult` |
| `DsoRules_RevokeFeaturedAppRightResult` |
| `DsoRules_TerminateSubscriptionResult` |

## 次に読む頁

次の章「CIPの統治の手続き」の頁「CIPが承認され効力を持つまで」は、CIPの種類と、誰がどう提案し、どの段を経て議論と投票を受け、いつ効力を持つかを追います。

https://cardene.dev/diagrams/canton-cip-process

## 出典

https://docs.canton.network/sdks-tools/api-reference/splice-daml/splice-dso-governance/splice-dsorules
