Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Proof of concept implementation of Praos
Synopsis
- data HotKey c
- = HotKey !Period !(SignKeyKES (PraosKES c))
- | HotKeyPoisoned
- newtype HotKeyEvolutionError = HotKeyEvolutionError Period
- data Praos c
- newtype PraosChainDepState c = PraosChainDepState {
- praosHistory ∷ [BlockInfo c]
- newtype PraosEvolvingStake = PraosEvolvingStake (Map EpochNo StakeDist)
- data PraosExtraFields c = PraosExtraFields {
- praosCreator ∷ CoreNodeId
- praosRho ∷ CertifiedVRF (PraosVRF c) (Natural, SlotNo, VRFType)
- praosY ∷ CertifiedVRF (PraosVRF c) (Natural, SlotNo, VRFType)
- data PraosFields crypto typeBeingSigned = PraosFields {
- praosSignature ∷ SignedKES (PraosKES crypto) typeBeingSigned
- praosExtraFields ∷ PraosExtraFields crypto
- data PraosParams = PraosParams {}
- emptyPraosEvolvingStake ∷ PraosEvolvingStake
- evolveKey ∷ PraosCrypto c ⇒ SlotNo → HotKey c → (HotKey c, UpdateInfo (HotKey c) HotKeyEvolutionError)
- forgePraosFields ∷ (PraosCrypto c, Signable (PraosKES c) toSign, HasCallStack) ⇒ PraosProof c → HotKey c → (PraosExtraFields c → toSign) → PraosFields c toSign
- class (KESAlgorithm (PraosKES c), VRFAlgorithm (PraosVRF c), HashAlgorithm (PraosHash c), Typeable c, Typeable (PraosVRF c), Condense (SigKES (PraosKES c)), Signable (PraosVRF c) (Natural, SlotNo, VRFType), ContextKES (PraosKES c) ~ (), ContextVRF (PraosVRF c) ~ ()) ⇒ PraosCrypto (c ∷ Type) where
- data PraosMockCrypto
- data PraosStandardCrypto
- data PraosValidateView c = ∀ signed.Signable (PraosKES c) signed ⇒ PraosValidateView (PraosFields c signed) signed
- data PraosValidationError c
- = PraosInvalidSlot SlotNo SlotNo
- | PraosUnknownCoreId CoreNodeId
- | PraosInvalidSig String (VerKeyKES (PraosKES c)) Natural (SigKES (PraosKES c))
- | PraosInvalidCert (VerKeyVRF (PraosVRF c)) (Natural, SlotNo, VRFType) Natural (CertVRF (PraosVRF c))
- | PraosInsufficientStake Double Natural
- praosValidateView ∷ (SignedHeader hdr, Signable (PraosKES c) (Signed hdr)) ⇒ (hdr → PraosFields c (Signed hdr)) → hdr → PraosValidateView c
- data BlockInfo c = BlockInfo {}
- data family ConsensusConfig p
- data family Ticked st
Documentation
The key used for the given period or a stub Poisoned value.
A key will be poisoned if it failed to evolve by updateKES
, and will remain
poisoned forever after that.
HotKey | |
| |
HotKeyPoisoned |
Instances
Generic (HotKey c) Source # | |
PraosCrypto c ⇒ Show (HotKey c) Source # | |
PraosCrypto c ⇒ NoThunks (HotKey c) Source # | |
type Rep (HotKey c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos type Rep (HotKey c) = D1 ('MetaData "HotKey" "Ouroboros.Consensus.Mock.Protocol.Praos" "ouroboros-consensus-0.21.0.0-inplace-unstable-mock-block" 'False) (C1 ('MetaCons "HotKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Period) :*: S1 ('MetaSel ('Nothing ∷ Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 (SignKeyKES (PraosKES c)))) :+: C1 ('MetaCons "HotKeyPoisoned" 'PrefixI 'False) (U1 ∷ Type → Type)) |
newtype HotKeyEvolutionError Source #
Instances
An uninhabited type representing the Praos protocol.
Instances
newtype PraosChainDepState c Source #
The chain dependent state, in this case as it is a mock, we just will store a list of BlockInfos that allow us to look into the past.
Instances
newtype PraosEvolvingStake Source #
An association from epoch to stake distributions.
Should be used when checking if someone is the leader of a particular slot. This is sufficiently good for a mock protocol as far as consensus is concerned. It is not strictly necessary that the stake distribution is computed from previous epochs, as we just need to consider that:
1) an attacker cannot influence it. 2) all the nodes agree on the same value for each Slot.
Each pair stores the stake distribution established by the end of the epoch
in the first item of the pair. See latestEvolvedStakeDistAsOfEpoch
for the
intended interface.
If no value is returned, that means we are checking the stake before any
changes have happened so we should consult instead the praosInitialStake
.
Instances
data PraosExtraFields c Source #
Fields that should be included in the signature
PraosExtraFields | |
|
Instances
Generic (PraosExtraFields c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos type Rep (PraosExtraFields c) ∷ Type → Type # from ∷ PraosExtraFields c → Rep (PraosExtraFields c) x # to ∷ Rep (PraosExtraFields c) x → PraosExtraFields c # | |
PraosCrypto c ⇒ Show (PraosExtraFields c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos showsPrec ∷ Int → PraosExtraFields c → ShowS # show ∷ PraosExtraFields c → String # showList ∷ [PraosExtraFields c] → ShowS # | |
PraosCrypto c ⇒ Eq (PraosExtraFields c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos (==) ∷ PraosExtraFields c → PraosExtraFields c → Bool # (/=) ∷ PraosExtraFields c → PraosExtraFields c → Bool # | |
PraosCrypto c ⇒ NoThunks (PraosExtraFields c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type Rep (PraosExtraFields c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos |
data PraosFields crypto typeBeingSigned Source #
The fields that Praos required in the header
PraosFields | |
|
Instances
data PraosParams Source #
Praos parameters that are node independent
PraosParams | |
|
Instances
Generic PraosParams Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos type Rep PraosParams ∷ Type → Type # from ∷ PraosParams → Rep PraosParams x # to ∷ Rep PraosParams x → PraosParams # | |
NoThunks PraosParams Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type Rep PraosParams Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos type Rep PraosParams = D1 ('MetaData "PraosParams" "Ouroboros.Consensus.Mock.Protocol.Praos" "ouroboros-consensus-0.21.0.0-inplace-unstable-mock-block" 'False) (C1 ('MetaCons "PraosParams" 'PrefixI 'True) (S1 ('MetaSel ('Just "praosLeaderF") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Double) :*: (S1 ('MetaSel ('Just "praosSecurityParam") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SecurityParam) :*: S1 ('MetaSel ('Just "praosSlotsPerEpoch") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Word64)))) |
evolveKey ∷ PraosCrypto c ⇒ SlotNo → HotKey c → (HotKey c, UpdateInfo (HotKey c) HotKeyEvolutionError) Source #
To be used in conjunction with, e.g., modifyMVar
.
NOTE: when the key's period is after the target period, we shouldn't use
it, but we currently do. In real TPraos we check this in
tpraosCheckCanForge
.
forgePraosFields ∷ (PraosCrypto c, Signable (PraosKES c) toSign, HasCallStack) ⇒ PraosProof c → HotKey c → (PraosExtraFields c → toSign) → PraosFields c toSign Source #
Create a PraosFields using a proof, a key and the data to be signed.
It is done by signing whatever is extracted from the extra fields by mkToSign
and storing the signature and the extra fields on a PraosFields
.
Tags
class (KESAlgorithm (PraosKES c), VRFAlgorithm (PraosVRF c), HashAlgorithm (PraosHash c), Typeable c, Typeable (PraosVRF c), Condense (SigKES (PraosKES c)), Signable (PraosVRF c) (Natural, SlotNo, VRFType), ContextKES (PraosKES c) ~ (), ContextVRF (PraosVRF c) ~ ()) ⇒ PraosCrypto (c ∷ Type) Source #
Instances
data PraosMockCrypto Source #
Instances
PraosCrypto PraosMockCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos type PraosKES PraosMockCrypto Source # type PraosVRF PraosMockCrypto Source # type PraosHash PraosMockCrypto Source # | |
type PraosHash PraosMockCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type PraosKES PraosMockCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type PraosVRF PraosMockCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos |
data PraosStandardCrypto Source #
Instances
PraosCrypto PraosStandardCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type PraosHash PraosStandardCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type PraosKES PraosStandardCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type PraosVRF PraosStandardCrypto Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos |
data PraosValidateView c Source #
A validate view is an association from the (signed
) value to the
PraosFields
that contains the signature that sign it.
In this mock implementation, this could have been simplified to use
SignedSimplePraos
but from the consensus point of view, it is not relevant
which actual value is being signed, that's why we use the existential.
∀ signed.Signable (PraosKES c) signed ⇒ PraosValidateView (PraosFields c signed) signed |
data PraosValidationError c Source #
An error that can arise during validation
PraosInvalidSlot SlotNo SlotNo | |
PraosUnknownCoreId CoreNodeId | |
PraosInvalidSig String (VerKeyKES (PraosKES c)) Natural (SigKES (PraosKES c)) | |
PraosInvalidCert (VerKeyVRF (PraosVRF c)) (Natural, SlotNo, VRFType) Natural (CertVRF (PraosVRF c)) | |
PraosInsufficientStake Double Natural |
Instances
Generic (PraosValidationError c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos type Rep (PraosValidationError c) ∷ Type → Type # from ∷ PraosValidationError c → Rep (PraosValidationError c) x # to ∷ Rep (PraosValidationError c) x → PraosValidationError c # | |
PraosCrypto c ⇒ Show (PraosValidationError c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos showsPrec ∷ Int → PraosValidationError c → ShowS # show ∷ PraosValidationError c → String # showList ∷ [PraosValidationError c] → ShowS # | |
PraosCrypto c ⇒ Eq (PraosValidationError c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos (==) ∷ PraosValidationError c → PraosValidationError c → Bool # (/=) ∷ PraosValidationError c → PraosValidationError c → Bool # | |
PraosCrypto c ⇒ NoThunks (PraosValidationError c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos | |
type Rep (PraosValidationError c) Source # | |
Defined in Ouroboros.Consensus.Mock.Protocol.Praos |
praosValidateView ∷ (SignedHeader hdr, Signable (PraosKES c) (Signed hdr)) ⇒ (hdr → PraosFields c (Signed hdr)) → hdr → PraosValidateView c Source #
Convenience constructor for PraosValidateView
Type instances
Instances
data family ConsensusConfig p Source #
Static configuration required to run the consensus protocol
Every method in the ConsensusProtocol
class takes the consensus
configuration as a parameter, so having this as a data family rather than a
type family resolves most ambiguity.
Defined out of the class so that protocols can define this type without having to define the entire protocol at the same time (or indeed in the same module).
Instances
data family Ticked st Source #
" Ticked " piece of state, either LedgerState
or ChainDepState
Ticking refers to the passage of time (the ticking of the clock). When a
piece of state is marked as ticked, it means that time-related changes have
been applied to the state. There are exactly two methods in the interface
that do that: tickChainDepState
and
applyChainTickLedgerResult
.
Also note that a successful forecast
must equal
forecastFor
(ledgerViewForecastAt
cfg st)
slot
. Thus a
protocolLedgerView
cfg
(applyChainTick
cfg slot st)LedgerView
can only be projected
from a Ticked
state, but cannot itself be ticked.
Some examples of time related changes:
- Scheduled delegations might have been applied in Byron
- New leader schedule computed for Shelley
- Transition from Byron to Shelley activated in the hard fork combinator.
- Nonces switched out at the start of a new epoch.