Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ouroboros.Consensus.Protocol.Praos.Common
Contents
Description
Various things common to iterations of the Praos protocol.
Synopsis
- newtype MaxMajorProtVer = MaxMajorProtVer {}
- data PraosCanBeLeader c = PraosCanBeLeader {
- praosCanBeLeaderOpCert ∷ !(OCert c)
- praosCanBeLeaderColdVerKey ∷ !(VKey 'BlockIssuer c)
- praosCanBeLeaderSignKeyVRF ∷ !(SignKeyVRF c)
- data PraosChainSelectView c = PraosChainSelectView {}
- data VRFTiebreakerFlavor
- data PraosNonces = PraosNonces {}
- class ConsensusProtocol p ⇒ PraosProtocolSupportsNode p where
- type PraosProtocolSupportsNodeCrypto p
- getPraosNonces ∷ proxy p → ChainDepState p → PraosNonces
- getOpCertCounters ∷ proxy p → ChainDepState p → Map (KeyHash 'BlockIssuer (PraosProtocolSupportsNodeCrypto p)) Word64
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
Constructors
MaxMajorProtVer | |
Fields |
Instances
data PraosCanBeLeader c Source #
Constructors
PraosCanBeLeader | |
Fields
|
Instances
data PraosChainSelectView c Source #
View of the tip of a header fragment for chain selection.
Constructors
PraosChainSelectView | |
Fields
|
Instances
Generic (PraosChainSelectView c) Source # | |||||||||||||
Defined in Ouroboros.Consensus.Protocol.Praos.Common Associated Types type Rep (PraosChainSelectView c) ∷ Type → Type # Methods 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 Methods 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 Methods (==) ∷ 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 Methods 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
Associated Types
type ChainOrderConfig (PraosChainSelectView c) Source #
Methods
preferCandidate ∷ ChainOrderConfig (PraosChainSelectView c) → PraosChainSelectView c → PraosChainSelectView c → Bool Source #
Defined in Ouroboros.Consensus.Protocol.Praos.Common
Defined in Ouroboros.Consensus.Protocol.Praos.Common
data VRFTiebreakerFlavor Source #
When to compare the VRF tiebreakers.
Constructors
UnrestrictedVRFTiebreaker | Always compare the VRF tiebreakers. This is the behavior of all eras before Conway. Once mainnet has transitioned to Conway, we can remove this option. (The honest historical Ouroboros chain cannot rely on tiebreakers to win, so retroactively disabling the tiebreaker won't matter.) |
RestrictedVRFTiebreaker SlotNo | Only compare the VRF tiebreakers when the slot numbers differ by at most the given number of slots. The main motivation is as follows: When two blocks A and B with the same block number differ in their slot
number by more than Δ (the maximum message delay from Praos), say
|
Instances
node support
data PraosNonces Source #
Constructors
PraosNonces | |
Fields
|
class ConsensusProtocol p ⇒ PraosProtocolSupportsNode p where Source #
The node has Praos-aware code that inspects nonces in order to support some Cardano API queries that are crucial to the user exprience
The interface being used for that has grown and needs review, but we're adding to it here under time pressure. See https://github.com/IntersectMBO/cardano-node/issues/3864
Associated Types
Methods
getPraosNonces ∷ proxy p → ChainDepState p → PraosNonces Source #
getOpCertCounters ∷ proxy p → ChainDepState p → Map (KeyHash 'BlockIssuer (PraosProtocolSupportsNodeCrypto p)) Word64 Source #
Instances
PraosCrypto c ⇒ PraosProtocolSupportsNode (Praos c) Source # | |
Defined in Ouroboros.Consensus.Protocol.Praos Associated Types type PraosProtocolSupportsNodeCrypto (Praos c) Source # Methods getPraosNonces ∷ proxy (Praos c) → ChainDepState (Praos c) → PraosNonces Source # getOpCertCounters ∷ proxy (Praos c) → ChainDepState (Praos c) → Map (KeyHash 'BlockIssuer (PraosProtocolSupportsNodeCrypto (Praos c))) Word64 Source # | |
PraosCrypto c ⇒ PraosProtocolSupportsNode (TPraos c) Source # | |
Defined in Ouroboros.Consensus.Protocol.TPraos Associated Types type PraosProtocolSupportsNodeCrypto (TPraos c) Source # Methods getPraosNonces ∷ proxy (TPraos c) → ChainDepState (TPraos c) → PraosNonces Source # getOpCertCounters ∷ proxy (TPraos c) → ChainDepState (TPraos c) → Map (KeyHash 'BlockIssuer (PraosProtocolSupportsNodeCrypto (TPraos c))) Word64 Source # |