ouroboros-consensus:unstable-mock-block
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Mock.Ledger.Stake

Synopsis

Stakeholders

data StakeHolder Source #

Constructors

StakeCore CoreNodeId

Stake of a core node

StakeEverybodyElse

Stake for everybody else (we don't need to distinguish)

Address distribution

type AddrDist = Map Addr NodeId Source #

Mapping from addresses to node IDs

This is needed in order to assign stake to nodes.

Stake distribution

newtype StakeDist Source #

In the mock setup, only core nodes have stake

INVARIANT: The rationals should sum to 1.

equalStakeDist ∷ AddrDist → StakeDist Source #

Stake distribution where every address has equal state

genesisStakeDist ∷ AddrDist → StakeDist Source #

Genesis stake distribution

totalStakes ∷ Map Addr NodeId → Utxo → Map StakeHolder Amount Source #

Compute stakes of all nodes

The Nothing value holds the total stake of all addresses that don't get mapped to a NodeId.

Type family instances

data family Ticked (st ∷ k) ∷ k 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 forecastFor (ledgerViewForecastAt cfg st) slot must equal protocolLedgerView cfg (applyChainTick cfg slot st). Thus a 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.

Ticked is used mainly in two ways:

  • Ticked (Ext)LedgerState where its kind gets concretized to StateKind -> StateKind
  • Ticked (HeaderState blk) where its kind gets concretized to Type -> Type

Instances

Instances details
Show (Ticked ()) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

showsPrec ∷ Int → Ticked () → ShowS #

show ∷ Ticked () → String #

showList ∷ [Ticked ()] → ShowS #

ChainDepStateSupportsPeras (Ticked (ChainDepState (BlockProtocol blk))) ⇒ ChainDepStateSupportsPeras (Ticked (HeaderState blk)) Source # 
Instance details

Defined in Ouroboros.Consensus.HeaderValidation

ChainDepStateSupportsPeras (Ticked (PBftState c)) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT

ChainDepStateSupportsPeras (Ticked (PraosChainDepState c)) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Protocol.Praos

ChainDepStateSupportsPeras (Ticked ()) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.Abstract

Methods

getEpochNonce ∷ Ticked () → Nonce Source #

HasLedgerTables (Ticked LedgerState) TestBlock # 
Instance details

Defined in Test.Ouroboros.Storage.TestBlock

Methods

projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState TestBlock mk → LedgerTables TestBlock mk Source #

withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState TestBlock any → LedgerTables TestBlock mk → Ticked LedgerState TestBlock mk Source #

HasLedgerTables (Ticked LedgerState) TestBlock # 
Instance details

Defined in Test.Util.TestBlock

Methods

projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState TestBlock mk → LedgerTables TestBlock mk Source #

withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState TestBlock any → LedgerTables TestBlock mk → Ticked LedgerState TestBlock mk Source #

(NoThunks (TxIn blk), NoThunks (TxOut blk), HasLedgerTables (Ticked LedgerState) blk) ⇒ HasLedgerTables (Ticked ExtLedgerState) blk Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

Methods

projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked ExtLedgerState blk mk → LedgerTables blk mk Source #

withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked ExtLedgerState blk any → LedgerTables blk mk → Ticked ExtLedgerState blk mk Source #

LedgerTablesAreTrivial (Ticked LedgerState) TestBlock # 
Instance details

Defined in Test.Ouroboros.Storage.TestBlock

Methods

convertMapKind ∷ ∀ (mk ∷ MapKind) (mk' ∷ MapKind). Ticked LedgerState TestBlock mk → Ticked LedgerState TestBlock mk' Source #

LedgerTablesAreTrivial (Ticked LedgerState) TestBlock # 
Instance details

Defined in Test.Util.TestBlock

Methods

convertMapKind ∷ ∀ (mk ∷ MapKind) (mk' ∷ MapKind). Ticked LedgerState TestBlock mk → Ticked LedgerState TestBlock mk' Source #

(Bridge m a, HasLedgerTables (Ticked LedgerState) m) ⇒ HasLedgerTables (Ticked LedgerState) (DualBlock m a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Methods

projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState (DualBlock m a) mk → LedgerTables (DualBlock m a) mk Source #

withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState (DualBlock m a) any → LedgerTables (DualBlock m a) mk → Ticked LedgerState (DualBlock m a) mk Source #

HasLedgerTables (Ticked LedgerState) (SimpleBlock c ext) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

Methods

projectLedgerTables ∷ ∀ (mk ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState (SimpleBlock c ext) mk → LedgerTables (SimpleBlock c ext) mk Source #

withLedgerTables ∷ ∀ (mk ∷ MapKind) (any ∷ MapKind). (CanMapMK mk, CanMapKeysMK mk, ZeroableMK mk) ⇒ Ticked LedgerState (SimpleBlock c ext) any → LedgerTables (SimpleBlock c ext) mk → Ticked LedgerState (SimpleBlock c ext) mk Source #

Bridge m a ⇒ GetTip (Ticked LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

Methods

getTip ∷ ∀ (mk ∷ MapKind). Ticked LedgerState (DualBlock m a) mk → Point (Ticked LedgerState (DualBlock m a)) Source #

GetTip (Ticked LedgerState TestBlock) # 
Instance details

Defined in Test.Ouroboros.Storage.TestBlock

Methods

getTip ∷ ∀ (mk ∷ MapKind). Ticked LedgerState TestBlock mk → Point (Ticked LedgerState TestBlock) Source #

GetTip (Ticked LedgerState (TestBlockWith ptype)) # 
Instance details

Defined in Test.Util.TestBlock

Methods

getTip ∷ ∀ (mk ∷ MapKind). Ticked LedgerState (TestBlockWith ptype) mk → Point (Ticked LedgerState (TestBlockWith ptype)) Source #

GetTip (Ticked LedgerState (SimpleBlock c ext)) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

Methods

getTip ∷ ∀ (mk ∷ MapKind). Ticked LedgerState (SimpleBlock c ext) mk → Point (Ticked LedgerState (SimpleBlock c ext)) Source #

IsLedger LedgerState blk ⇒ GetTip (Ticked ExtLedgerState blk) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

Methods

getTip ∷ ∀ (mk ∷ MapKind). Ticked ExtLedgerState blk mk → Point (Ticked ExtLedgerState blk) Source #

LedgerStateSupportsPeras (Ticked LedgerState (DualBlock m a)) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

LedgerStateSupportsPeras (Ticked LedgerState TestBlock) # 
Instance details

Defined in Test.Ouroboros.Storage.TestBlock

Methods

getPoolDistr ∷ Ticked LedgerState TestBlock EmptyMK → PoolDistr Source #

getPerasParams ∷ proxy blk → Ticked LedgerState TestBlock EmptyMK → PerasParams blk Source #

LedgerStateSupportsPeras (Ticked LedgerState (TestBlockWith ptype)) # 
Instance details

Defined in Test.Util.TestBlock

Methods

getPoolDistr ∷ Ticked LedgerState (TestBlockWith ptype) EmptyMK → PoolDistr Source #

getPerasParams ∷ proxy blk → Ticked LedgerState (TestBlockWith ptype) EmptyMK → PerasParams blk Source #

LedgerStateSupportsPeras (Ticked LedgerState (SimpleBlock c ext)) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

CanStowLedgerTables (Ticked LedgerState (SimpleBlock c ext)) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

Generic (Ticked LedgerState (TestBlockWith ptype) mk) # 
Instance details

Defined in Test.Util.TestBlock

Associated Types

type Rep (Ticked LedgerState (TestBlockWith ptype) mk) 
Instance details

Defined in Test.Util.TestBlock

type Rep (Ticked LedgerState (TestBlockWith ptype) mk) = D1 ('MetaData "Ticked" "Test.Util.TestBlock" "ouroboros-consensus-4.0.0.0-inplace-unstable-consensus-testlib" 'True) (C1 ('MetaCons "TickedTestLedger" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTickedTestLedger") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LedgerState (TestBlockWith ptype) mk))))

Methods

from ∷ Ticked LedgerState (TestBlockWith ptype) mk → Rep (Ticked LedgerState (TestBlockWith ptype) mk) x #

to ∷ Rep (Ticked LedgerState (TestBlockWith ptype) mk) x → Ticked LedgerState (TestBlockWith ptype) mk #

Generic (Ticked LedgerState (SimpleBlock c ext) mk) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

Associated Types

type Rep (Ticked LedgerState (SimpleBlock c ext) mk) 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

type Rep (Ticked LedgerState (SimpleBlock c ext) mk) = D1 ('MetaData "Ticked" "Ouroboros.Consensus.Mock.Ledger.Block" "ouroboros-consensus-4.0.0.0-inplace-unstable-mock-block" 'True) (C1 ('MetaCons "TickedSimpleLedgerState" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTickedSimpleLedgerState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LedgerState (SimpleBlock c ext) mk))))

Methods

from ∷ Ticked LedgerState (SimpleBlock c ext) mk → Rep (Ticked LedgerState (SimpleBlock c ext) mk) x #

to ∷ Rep (Ticked LedgerState (SimpleBlock c ext) mk) x → Ticked LedgerState (SimpleBlock c ext) mk #

(SimpleCrypto c, Typeable ext, Show (LedgerState (SimpleBlock c ext) mk)) ⇒ Show (Ticked LedgerState (SimpleBlock c ext) mk) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

Methods

showsPrec ∷ Int → Ticked LedgerState (SimpleBlock c ext) mk → ShowS #

show ∷ Ticked LedgerState (SimpleBlock c ext) mk → String #

showList ∷ [Ticked LedgerState (SimpleBlock c ext) mk] → ShowS #

NoThunks (Ticked LedgerState (DualBlock m a) mk) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

(NoThunksMK mk, NoThunks (PayloadDependentState ptype mk)) ⇒ NoThunks (Ticked LedgerState (TestBlockWith ptype) mk) # 
Instance details

Defined in Test.Util.TestBlock

Methods

noThunks ∷ Context → Ticked LedgerState (TestBlockWith ptype) mk → IO (Maybe ThunkInfo) Source #

wNoThunks ∷ Context → Ticked LedgerState (TestBlockWith ptype) mk → IO (Maybe ThunkInfo) Source #

showTypeOf ∷ Proxy (Ticked LedgerState (TestBlockWith ptype) mk) → String Source #

(SimpleCrypto c, Typeable ext) ⇒ NoThunks (Ticked LedgerState (SimpleBlock c ext) TrackingMK) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

Show (Ticked (f a)) ⇒ Show (((Ticked ∷ Type → Type) :.: f) a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

showsPrec ∷ Int → ((Ticked ∷ Type → Type) :.: f) a → ShowS #

show ∷ ((Ticked ∷ Type → Type) :.: f) a → String #

showList ∷ [((Ticked ∷ Type → Type) :.: f) a] → ShowS #

NoThunks (Ticked (f a)) ⇒ NoThunks (((Ticked ∷ Type → Type) :.: f) a) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

Methods

noThunks ∷ Context → ((Ticked ∷ Type → Type) :.: f) a → IO (Maybe ThunkInfo) Source #

wNoThunks ∷ Context → ((Ticked ∷ Type → Type) :.: f) a → IO (Maybe ThunkInfo) Source #

showTypeOf ∷ Proxy (((Ticked ∷ Type → Type) :.: f) a) → String Source #

data Ticked () Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

data Ticked (HardForkChainDepState xs ∷ Type) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Protocol

data Ticked (HeaderState blk ∷ Type) Source # 
Instance details

Defined in Ouroboros.Consensus.HeaderValidation

data Ticked (PBftState c ∷ Type) Source # 
Instance details

Defined in Ouroboros.Consensus.Protocol.PBFT

newtype Ticked (WrapChainDepState blk ∷ Type) Source # 
Instance details

Defined in Ouroboros.Consensus.TypeFamilyWrappers

data Ticked (PraosChainDepState c ∷ Type) Source #

Ticking the Praos chain dep state has no effect

For the real Praos implementation, ticking is crucial, as it determines the point where the "nonce under construction" is swapped out for the "active" nonce. However, for the mock implementation, we keep the full history, and choose the right nonce from that; this means that ticking has no effect.

We do however need access to the ticked stake distribution.

Instance details

Defined in Ouroboros.Consensus.Mock.Protocol.Praos

type HeaderHash (Ticked l blk ∷ k2) Source # 
Instance details

Defined in Ouroboros.Consensus.Ticked

type HeaderHash (Ticked l blk ∷ k2) = HeaderHash (l blk)
data Ticked ExtLedgerState (blk ∷ Type) (mk ∷ MapKind) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Extended

newtype Ticked LedgerState TestBlock (mk ∷ MapKind) # 
Instance details

Defined in Test.Ouroboros.Storage.TestBlock

newtype Ticked LedgerState TestBlock (mk ∷ MapKind) = TickedTestLedger {}
data Ticked LedgerState (HardForkBlock xs ∷ Type) (mk ∷ MapKind) Source # 
Instance details

Defined in Ouroboros.Consensus.HardFork.Combinator.Ledger

newtype Ticked LedgerState (TestBlockWith ptype ∷ Type) (mk ∷ MapKind) # 
Instance details

Defined in Test.Util.TestBlock

newtype Ticked LedgerState (TestBlockWith ptype ∷ Type) (mk ∷ MapKind) = TickedTestLedger {}
data Ticked LedgerState (DualBlock m a ∷ Type) (mk ∷ MapKind) Source # 
Instance details

Defined in Ouroboros.Consensus.Ledger.Dual

newtype Ticked LedgerState (SimpleBlock c ext ∷ Type) (mk ∷ MapKind) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

type Rep (Ticked LedgerState (TestBlockWith ptype) mk) # 
Instance details

Defined in Test.Util.TestBlock

type Rep (Ticked LedgerState (TestBlockWith ptype) mk) = D1 ('MetaData "Ticked" "Test.Util.TestBlock" "ouroboros-consensus-4.0.0.0-inplace-unstable-consensus-testlib" 'True) (C1 ('MetaCons "TickedTestLedger" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTickedTestLedger") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LedgerState (TestBlockWith ptype) mk))))
type Rep (Ticked LedgerState (SimpleBlock c ext) mk) Source # 
Instance details

Defined in Ouroboros.Consensus.Mock.Ledger.Block

type Rep (Ticked LedgerState (SimpleBlock c ext) mk) = D1 ('MetaData "Ticked" "Ouroboros.Consensus.Mock.Ledger.Block" "ouroboros-consensus-4.0.0.0-inplace-unstable-mock-block" 'True) (C1 ('MetaCons "TickedSimpleLedgerState" 'PrefixI 'True) (S1 ('MetaSel ('Just "getTickedSimpleLedgerState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (LedgerState (SimpleBlock c ext) mk))))