Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Transitional Praos.
Transitional praos allows for the overlaying of Praos with an overlay schedule determining slots to be produced by BFT
Synopsis
- newtype MaxMajorProtVer = MaxMajorProtVer {}
- data PraosChainSelectView c = PraosChainSelectView {}
- data TPraos c
- data TPraosFields c toSign = TPraosFields {
- tpraosSignature ∷ SignedKES c toSign
- tpraosToSign ∷ toSign
- data TPraosIsLeader c = TPraosIsLeader {}
- data TPraosParams = TPraosParams {
- tpraosSlotsPerKESPeriod ∷ !Word64
- tpraosLeaderF ∷ !ActiveSlotCoeff
- tpraosSecurityParam ∷ !SecurityParam
- tpraosMaxKESEvo ∷ !Word64
- tpraosQuorum ∷ !Word64
- tpraosMaxMajorPV ∷ !MaxMajorProtVer
- tpraosMaxLovelaceSupply ∷ !Word64
- tpraosNetworkId ∷ !Network
- tpraosInitialNonce ∷ !Nonce
- tpraosSystemStart ∷ !SystemStart
- data TPraosState c = TPraosState {}
- data TPraosToSign c = TPraosToSign {}
- type TPraosValidateView c = BHeader c
- forgeTPraosFields ∷ (PraosCrypto c, KESignable c toSign, Monad m) ⇒ HotKey c m → CanBeLeader (TPraos c) → IsLeader (TPraos c) → (TPraosToSign c → toSign) → m (TPraosFields c toSign)
- mkShelleyGlobals ∷ ConsensusConfig (TPraos c) → Globals
- mkTPraosParams ∷ MaxMajorProtVer → Nonce → ShelleyGenesis era → TPraosParams
- class (Crypto c, DSignable c (OCertSignable c), KESignable c (BHBody c), VRFSignable c Seed) ⇒ PraosCrypto c
- data StandardCrypto
- data TPraosCannotForge c
- = TPraosCannotForgeKeyNotUsableYet !KESPeriod !KESPeriod
- | TPraosCannotForgeWrongVRF !(Hash c (VerKeyVRF c)) !(Hash c (VerKeyVRF c))
- tpraosCheckCanForge ∷ ConsensusConfig (TPraos c) → Hash c (VerKeyVRF c) → SlotNo → IsLeader (TPraos c) → KESInfo → Either (TPraosCannotForge c) ()
- data family ConsensusConfig p
- data family Ticked st
Documentation
newtype MaxMajorProtVer Source #
The maximum major protocol version.
This refers to the largest ledger version that this node supports.
Once the ledger protocol version (as reported by the ledger state)
exceeds this version we will consider all blocks invalid. This is
called the "obsolete node check" (see the ObsoleteNode
error
constructor).
Major ledger protocol versions are used to trigger both intra and inter era hard forks, which can potentially change the set of ledger rules that are applied.
Minor ledger protocol versions were intended to signal soft forks but they're currently unused, and they're irrelevant for the consensus logic.
For Cardano mainnet, the Shelley era has major protocol version 2. For more details, see this table
Instances
data PraosChainSelectView c Source #
View of the tip of a header fragment for chain selection.
PraosChainSelectView | |
|
Instances
Generic (PraosChainSelectView c) Source # | |||||||||||||
Defined in Ouroboros.Consensus.Protocol.Praos.Common type Rep (PraosChainSelectView c) ∷ Type → Type # from ∷ PraosChainSelectView c → Rep (PraosChainSelectView c) x # to ∷ Rep (PraosChainSelectView c) x → PraosChainSelectView c # | |||||||||||||
Crypto c ⇒ Show (PraosChainSelectView c) Source # | |||||||||||||
Defined in Ouroboros.Consensus.Protocol.Praos.Common showsPrec ∷ Int → PraosChainSelectView c → ShowS # show ∷ PraosChainSelectView c → String # showList ∷ [PraosChainSelectView c] → ShowS # | |||||||||||||
Crypto c ⇒ Eq (PraosChainSelectView c) Source # | |||||||||||||
Defined in Ouroboros.Consensus.Protocol.Praos.Common (==) ∷ PraosChainSelectView c → PraosChainSelectView c → Bool # (/=) ∷ PraosChainSelectView c → PraosChainSelectView c → Bool # | |||||||||||||
Crypto c ⇒ Ord (PraosChainSelectView c) Source # | We order between chains as follows:
IMPORTANT: This is not a complete picture of the Praos chain order, do also
consult the documentation of | ||||||||||||
Defined in Ouroboros.Consensus.Protocol.Praos.Common compare ∷ PraosChainSelectView c → PraosChainSelectView c → Ordering # (<) ∷ PraosChainSelectView c → PraosChainSelectView c → Bool # (<=) ∷ PraosChainSelectView c → PraosChainSelectView c → Bool # (>) ∷ PraosChainSelectView c → PraosChainSelectView c → Bool # (>=) ∷ PraosChainSelectView c → PraosChainSelectView c → Bool # max ∷ PraosChainSelectView c → PraosChainSelectView c → PraosChainSelectView c # min ∷ PraosChainSelectView c → PraosChainSelectView c → PraosChainSelectView c # | |||||||||||||
Crypto c ⇒ NoThunks (PraosChainSelectView c) Source # | |||||||||||||
Defined in Ouroboros.Consensus.Protocol.Praos.Common | |||||||||||||
Crypto c ⇒ ChainOrder (PraosChainSelectView c) Source # | IMPORTANT: This is not a RulesConcretely, we have
Non-transitivity of |
a | b | c | |
---|---|---|---|
Slot | 0 | 3 | 6 |
VRF | 3 | 2 | 1 |
Then we have
and preferCandidate
cfg a b
, but
not preferCandidate
b c
(despite preferCandidate
a ca < c
).
Rationale for the rules
- The abstract Consensus layer requires that we first compare based on chain
length (see Chain extension precedence in
ChainOrder
).
Consider the scenario where the hot key of a block issuer was compromised, and the attacker is now minting blocks using that identity. The actual block issuer can use their cold key to issue a new hot key with a higher opcert issue number and set up a new pool. Due to this tiebreaker rule, the blocks minted by that pool will take precedence (allowing the actual block issuer to decide on eg the block contents and the predecessor) over blocks with the same block and slot number minted by the attacker, and they will end up on the honest chain quickly, which means that the adversary can't extend any chain containing such a block as it would violate the monotonicity requirement on opcert issue numbers.
See "3.7 Block Validity and Operational Key Certificates" in "Design Specification for Delegation and Incentives in Cardano" by Kant et al for more context.
The main motivation to do VRF comparisons is to avoid the "Frankfurt problem":
With only the first two rules for the chain order, almost all blocks with equal block number are equally preferrable. Consider two block issuers minting blocks in very nearby slots. As we never change our selection from one chain to an equally preferrable one, the first block to arrive at another pool is the one to be adopted, and will be extended the next time the pool is elected if no blocks with a higher block number arrive in the meantime. We observed that this effectively incentivizes block producers to concentrate geographically (historically, in Frankfurt) in order to minimize their diffusion times. This works against the goal of geographic decentralisation.
Also, with the VRF tiebreaker, a block with a somewhat lower propagation speed has a random chance to be selected instead of the one that arrived first by pools before the next block is forged.
See
VRFTiebreakerFlavor
for more context on the exact conditions under which the VRF comparison takes place.
Defined in Ouroboros.Consensus.Protocol.Praos.Common
type ChainOrderConfig (PraosChainSelectView c) Source #
Defined in Ouroboros.Consensus.Protocol.Praos.Common
Defined in Ouroboros.Consensus.Protocol.Praos.Common
Instances
data TPraosFields c toSign Source #
TPraosFields | |
|
Instances
data TPraosIsLeader c Source #
Assembled proof that the issuer has the right to issue a block in the selected slot.
TPraosIsLeader | |
|
Instances
data TPraosParams Source #
TPraos parameters that are node independent
TPraosParams | |
|
Instances
data TPraosState c Source #
Transitional Praos consensus state.
In addition to the ChainDepState
provided by the ledger, we track the slot
number of the last applied header.
Instances
data TPraosToSign c Source #
Fields arising from transitional praos execution which must be included in the block signature.
TPraosToSign | |
|
Instances
type TPraosValidateView c = BHeader c Source #
Because we are using the executable spec, rather than implementing the protocol directly here, we have a fixed header type rather than an abstraction. So our validate view is fixed to this.
forgeTPraosFields ∷ (PraosCrypto c, KESignable c toSign, Monad m) ⇒ HotKey c m → CanBeLeader (TPraos c) → IsLeader (TPraos c) → (TPraosToSign c → toSign) → m (TPraosFields c toSign) Source #
mkShelleyGlobals ∷ ConsensusConfig (TPraos c) → Globals Source #
∷ MaxMajorProtVer | |
→ Nonce | Initial nonce |
→ ShelleyGenesis era | |
→ TPraosParams |
Crypto
class (Crypto c, DSignable c (OCertSignable c), KESignable c (BHBody c), VRFSignable c Seed) ⇒ PraosCrypto c Source #
Instances
PraosCrypto StandardCrypto | |
Defined in Cardano.Protocol.TPraos.API |
data StandardCrypto Source #
The same crypto used on the net
Instances
Crypto StandardCrypto | |
Defined in Cardano.Ledger.Crypto type HASH StandardCrypto Source # type ADDRHASH StandardCrypto Source # type DSIGN StandardCrypto Source # type KES StandardCrypto Source # type VRF StandardCrypto Source # | |
PraosCrypto StandardCrypto | |
Defined in Cardano.Protocol.TPraos.API | |
PraosCrypto StandardCrypto Source # | |
Defined in Ouroboros.Consensus.Protocol.Praos | |
type ADDRHASH StandardCrypto | |
Defined in Cardano.Ledger.Crypto | |
type DSIGN StandardCrypto | |
Defined in Cardano.Ledger.Crypto | |
type HASH StandardCrypto | |
Defined in Cardano.Ledger.Crypto | |
type KES StandardCrypto | |
Defined in Cardano.Ledger.Crypto | |
type VRF StandardCrypto | |
Defined in Cardano.Ledger.Crypto |
CannotForge
data TPraosCannotForge c Source #
Expresses that, whilst we believe ourselves to be a leader for this slot, we are nonetheless unable to forge a block.
TPraosCannotForgeKeyNotUsableYet | The KES key in our operational certificate can't be used because the current (wall clock) period is before the start period of the key. current KES period. Note: the opposite case, i.e., the wall clock period being after the
end period of the key, is caught when trying to update the key in
|
TPraosCannotForgeWrongVRF !(Hash c (VerKeyVRF c)) !(Hash c (VerKeyVRF c)) | We are a genesis delegate, but our VRF key (second argument) does not match the registered key for that delegate (first argument). |
Instances
∷ ConsensusConfig (TPraos c) | |
→ Hash c (VerKeyVRF c) | Precomputed hash of the VRF verification key |
→ SlotNo | |
→ IsLeader (TPraos c) | |
→ KESInfo | |
→ Either (TPraosCannotForge c) () |
Type 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.
Instances
Show (Ticked ()) | |
Show (Ticked (f a)) ⇒ Show ((Ticked :.: f) a) | |
NoThunks (Ticked (f a)) ⇒ NoThunks ((Ticked :.: f) a) | |
data Ticked () | |
Defined in Ouroboros.Consensus.Ticked | |
type HeaderHash (Ticked l ∷ Type) | |
Defined in Ouroboros.Consensus.Ticked | |
data Ticked (PraosState c) Source # | |
Defined in Ouroboros.Consensus.Protocol.Praos | |
data Ticked (TPraosState c) Source # | |
Defined in Ouroboros.Consensus.Protocol.TPraos |