Skip to content

Commit fc2fa0b

Browse files
committed
Fix foreign interface for ENTITIES
1 parent c7409b9 commit fc2fa0b

2 files changed

Lines changed: 31 additions & 28 deletions

File tree

src/Ledger/Dijkstra/Foreign/Certs.agda

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ instance
3333
• withName "DelegEnv"
3434
Conv-DelegEnv = autoConvert DelegEnv
3535

36+
HsTy-GovCertEnv = autoHsType GovCertEnv
37+
⊣ withConstructor "MkGovCertEnv"
38+
• fieldPrefix "gce"
39+
Conv-GovCertEnv = autoConvert GovCertEnv
40+
3641
HsTy-PState = autoHsType PState
3742
⊣ withConstructor "MkPState"
3843
• fieldPrefix "ps"
@@ -49,32 +54,11 @@ instance
4954
• fieldPrefix "gs"
5055
Conv-GState = autoConvert GState
5156

52-
-- CertEnv needs a wrapper because the votes field uses GovVote
53-
-- which requires non-trivial conversion through GovVote'.
54-
55-
record CertEnv' : Type where
56-
field
57-
epoch : Epoch
58-
pp : PParams
59-
votes : List GovVote'
60-
wdrls : RewardAddress ⇀ Coin
61-
coldCreds : ℙ Credential
62-
directDeposits : DirectDeposits
63-
64-
instance
65-
HsTy-CertEnv' = autoHsType CertEnv'
57+
HsTy-CertEnv = autoHsType CertEnv
6658
⊣ withConstructor "MkCertEnv"
6759
• withName "CertEnv"
6860
• fieldPrefix "ce"
69-
Conv-CertEnv' = autoConvert CertEnv'
70-
71-
mkCertEnv' : Convertible CertEnv CertEnv'
72-
mkCertEnv' = λ where
73-
.to ce let module ce = CertEnv ce in record { epoch = ce.epoch ; pp = ce.pp ; votes = to ce.votes ; wdrls = ce.wdrls ; coldCreds = ce.coldCreds ; directDeposits = ce.directDeposits }
74-
.from ce let module ce = CertEnv' ce in record { epoch = ce.epoch ; pp = ce.pp ; votes = from ce.votes ; wdrls = ce.wdrls ; coldCreds = ce.coldCreds ; directDeposits = ce.directDeposits }
75-
76-
HsTy-CertEnv = mkHsType CertEnv (HsType CertEnv')
77-
Conv-CertEnv = mkCertEnv' ⨾ Conv-CertEnv'
61+
Conv-CertEnv = autoConvert CertEnv
7862

7963
-- Computational step functions
8064

@@ -88,7 +72,7 @@ pool-step = to (compute Computational-POOL)
8872

8973
{-# COMPILE GHC pool-step as poolStep #-}
9074

91-
govcert-step : HsType (CertEnv GState DCert ComputationResult String GState)
75+
govcert-step : HsType (GovCertEnv GState DCert ComputationResult String GState)
9276
govcert-step = to (compute Computational-GOVCERT)
9377

9478
{-# COMPILE GHC govcert-step as govCertStep #-}

src/Ledger/Dijkstra/Foreign/Entities.agda

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,31 @@ open import Ledger.Core.Foreign.Address
1212
open import Ledger.Dijkstra.Foreign.HSStructures
1313
open import Ledger.Dijkstra.Foreign.Gov.Core
1414
open import Ledger.Dijkstra.Foreign.PParams
15-
open import Ledger.Dijkstra.Foreign.Cert
15+
open import Ledger.Dijkstra.Specification.Entities DummyGovStructure
1616
open import Ledger.Dijkstra.Specification.Entities.Properties.Computational DummyGovStructure
1717

1818
open Computational
1919

20-
entities-step : HsType (CertEnv CertState List DCert ComputationResult String CertState)
21-
entities-step = to (compute Computational-ENTITIES)
20+
record EntitiesEnv' : Type where
21+
field
22+
epoch : Epoch
23+
pp : PParams
24+
votes : List GovVote'
25+
withdrawals : RewardAddress ⇀ Coin
26+
coldCredentials : ℙ Credential
27+
directDeposits : DirectDeposits
2228

23-
{-# COMPILE GHC entities-step as entitiesStep #-}
29+
instance
30+
HsTy-EntitiesEnv' = autoHsType EntitiesEnv'
31+
⊣ withConstructor "MkEntitiesEnv"
32+
• withName "EntitiesEnv"
33+
• fieldPrefix "ce"
34+
Conv-EntitiesEnv' = autoConvert EntitiesEnv'
35+
36+
mkEntitiesEnv' : Convertible EntitiesEnv EntitiesEnv'
37+
mkEntitiesEnv' = λ where
38+
.to ee let module ee = EntitiesEnv ee in record { epoch = ee.epoch ; pp = ee.pp ; votes = to ee.votes ; withdrawals = ee.withdrawals ; coldCredentials = ee.coldCredentials ; directDeposits = ee.directDeposits }
39+
.from ee let module ee = EntitiesEnv' ee in record { epoch = ee.epoch ; pp = ee.pp ; votes = from ee.votes ; withdrawals = ee.withdrawals ; coldCredentials = ee.coldCredentials ; directDeposits = ee.directDeposits }
40+
41+
HsTy-EntitiesEnv = mkHsType EntitiesEnv (HsType EntitiesEnv')
42+
Conv-EntitiesEnv = mkEntitiesEnv' ⨾ Conv-EntitiesEnv'

0 commit comments

Comments
 (0)