logo
Formal Ledger Specification
Epoch
Initializing search
    GitHub
    • Home
    • Preliminaries
    • Core
    • Conway
    • Dijkstra
    • Appendix
    GitHub
    • Home
      • Guide for Contributors
      • Introduction
      • Properties
      • Notation
      • Introduction
        • Address
        • Crypto
        • Epoch
      • Introduction
        • Abstract
        • BlockBody
          • Properties
            • Computational
        • Certs
          • Properties
            • Computational
            • PoV
            • PoVLemmas
            • VoteDelegsVDeleg
        • Chain
          • Properties
            • Computational
            • CredDepsEqualDomRwds
            • EpochStep
            • GovDepsMatch
            • PParamsWellFormed
        • Enact
          • Properties
            • Computational
        • Epoch
          • Properties
            • Computational
            • ConstRwds
            • ExpiredDReps
            • GovDepsMatch
            • NoPropSameDReps
        • Fees
        • Gov
          • Base
          • Actions
          • Properties
            • Computational
            • ChangePPGroup
        • Ledger
          • Properties
            • Base
            • Computational
            • GovDepsMatch
            • PoV
        • PoolReap
            • Computational
        • PParams
        • Properties
        • Ratify
          • Properties
            • Computational
        • Rewards
            • Computational
        • RewardUpdate
          • Properties
            • Computational
        • Script
          • Base
          • ScriptPurpose
          • Timelock
          • Validation
          • Base
          • Coin
          • ValueSet
          • ValueVector
        • Transaction
        • Utxo
          • Properties
            • Base
            • Computational
            • GenMinspend
            • MinSpend
            • PoV
        • Utxow
          • Properties
            • Computational
          • GovStructure
      • Introduction
      • Abstract
      • Certs
        • Actions
        • Base
      • PParams
      • Script
        • Validation
      • TokenAlgebra
      • Transaction
        • Definitions
        • Essential Agda
          • Bootstrapping Governance
          • Bootstrapping EnactState
        • Prelude
        • Ledger
        • Ledger.Core
        • Ledger.Prelude
          • Base
            • HSTypes
            • Util
          • HasCoin
          • Instances
          • Numeric
            • PositiveNat
            • UnitInterval
          • STS
          • ComputationalRelation
          • TypeClasses
            • TypeClasses
            • HasSubset
            • HasSubtract
              • Instance
          • Convertible
            • Deriving
            • DerivingTest
          • HaskellTypes
            • Deriving
        • MyDebugOptions
          • Examples
            • HelloWorld
            • SucceedIfNumber
              • Datum
                • Cleanup
                • Close
                • Deposit
                • Lib
                • OffChain
                • Open
                • Start
                • Transfer
                • Withdraw
                • Trace
              • Validator
              • Datum
                • Close
                • Exchange
                • Lib
                • OffChain
                • Start
                • Update
                • Trace
              • Validator
              • Datum
                • AddSig
                • Lib
                • OffChain
                • Open
                • Pay
                • Propose
                • Trace
              • Validator
              • Datum
                • AddSig
                • Cancel
                • Cleanup
                • Lib
                • OffChain
                • Open
                • Pay
                • Propose
                • Trace
              • Validator
          • AbstractImplementation
          • LedgerImplementation
          • Lib
          • Prelude
          • SymbolicData
          • Ledger.Dijkstra
          • Ledger.PreConway
              • NewPP
                • Properties
              • PPUp
                • Properties
            • NewPP
              • Properties
            • PPUp
              • Properties
          • Ledger.Conway
            • ExternalFunctions
            • HSLedger
              • Address
              • BaseTypes
              • Cert
              • Certs
              • Chain
              • Core
              • Enact
              • Epoch
              • ExternalStructures
              • Gov
                • Core
                • Actions
              • Ledger
              • NewEpoch
              • PParams
              • Ratify
              • Rewards
              • Transaction
              • Utxo
          • Conformance
            • Certs
              • Properties
            • Chain
              • Properties
            • Epoch
              • Properties
            • Equivalence
              • Bisimilarity
              • Certs
              • Convert
              • Deposits
              • Map
              • Utxo
            • Gov
            • Ledger
              • Properties
            • Properties
            • Rewards
            • Script
            • Utxo
              • Properties
            • Utxow
              • Properties

    Epoch

    module Ledger.Conway.Foreign.HSLedger.Epoch where
    
    open import Ledger.Conway.Foreign.HSLedger.BaseTypes
    open import Ledger.Conway.Foreign.HSLedger.Enact
    open import Ledger.Conway.Foreign.HSLedger.Ledger
    open import Ledger.Conway.Foreign.HSLedger.PParams
    open import Ledger.Conway.Foreign.HSLedger.Ratify
    open import Ledger.Conway.Foreign.HSLedger.Rewards
    
    open import Ledger.Conway.Conformance.Equivalence.Convert
    open import Ledger.Conway.Conformance.Epoch it it
    open import Ledger.Conway.Conformance.Epoch.Properties it it
    
    module EpochSpec where
      open import Ledger.Conway.Specification.Epoch it it public
      open import Ledger.Conway.Specification.Epoch.Properties.Computational it it public
    
    import Data.String as S
    
    instance
      Show-EPOCH : ∀ {eps e eps'} → Show (_ EpochSpec.⊢ eps ⇀⦇ e ,EPOCH⦈ eps')
      Show-EPOCH .show (EpochSpec.EPOCH (s , r , pr)) =
        "EPOCH\n" S.++ "SNAP" S.++ " POOLREAP"
    
    instance
      HsTy-EpochState = autoHsType EpochState ⊣ withConstructor "MkEpochState"
                                              • fieldPrefix "es"
      Conv-EpochState = autoConvert EpochState
    
    -- An implementation of EPOCH that connects the conformance state
    -- with the specification rule.
    
    epoch-step
      : HsType (⊤ → EpochState → Epoch → ComputationResult ⊥ (EpochState × String))
    epoch-step _ epochSt e =
      let r = EpochSpec.Computational-EPOCH .computeProof _ (conv (from epochSt)) e
      in case r of λ where
        (success (s , p)) → to (success (conv s , show p))
    
    {-# COMPILE GHC epoch-step as epochStep #-}
    
    Previous
    Enact
    Next
    ExternalStructures
    Made with Material for MkDocs