Safe Haskell | None |
---|---|
Language | Haskell2010 |
Integration between the Shelley ledger and its corresponding (Transitional Praos) protocol.
In particular, this code supports extracting the components of the ledger state needed for protocol execution, both now and in a 2k-slot window.
Synopsis
- class ( Crypto c, DSignable c ( OCertSignable c), KESignable c ( BHBody c), VRFSignable c Seed ) => PraosCrypto c
-
class
(
ChainData
(
ChainDepState
(
Crypto
era)),
SerialisableData
(
ChainDepState
(
Crypto
era)),
Eq
(
ChainTransitionError
(
Crypto
era)),
Show
(
ChainTransitionError
(
Crypto
era)),
Show
(
LedgerView
(
Crypto
era)),
Show
(
FutureLedgerViewError
era),
STS
(
EraRule
"TICKF" era),
BaseM
(
EraRule
"TICKF" era) ~
ShelleyBase
,
Environment
(
EraRule
"TICKF" era) ~ (),
State
(
EraRule
"TICKF" era) ~
NewEpochState
era,
Signal
(
EraRule
"TICKF" era) ~
SlotNo
,
PredicateFailure
(
EraRule
"TICKF" era) ~
TickfPredicateFailure
era,
HasField
"_d" (
PParams
era)
UnitInterval
,
HasField
"_maxBBSize" (
PParams
era)
Natural
,
HasField
"_maxBHSize" (
PParams
era)
Natural
,
HasField
"_protocolVersion" (
PParams
era)
ProtVer
) =>
GetLedgerView
era
where
- currentLedgerView :: NewEpochState era -> LedgerView ( Crypto era)
- futureLedgerView :: MonadError ( FutureLedgerViewError era) m => Globals -> NewEpochState era -> SlotNo -> m ( LedgerView ( Crypto era))
-
data
LedgerView
crypto =
LedgerView
{
- lvD :: UnitInterval
- lvExtraEntropy :: ~ Nonce
- lvPoolDistr :: PoolDistr crypto
- lvGenDelegs :: GenDelegs crypto
- lvChainChecks :: ChainChecksPParams
- mkInitialShelleyLedgerView :: forall c. ShelleyGenesis ( ShelleyEra c) -> LedgerView c
- newtype FutureLedgerViewError era = FutureLedgerViewError [ PredicateFailure ( EraRule "TICKF" era)]
-
data
ChainDepState
crypto =
ChainDepState
{
- csProtocol :: !( PrtclState crypto)
- csTickn :: ! TicknState
- csLabNonce :: ! Nonce
- newtype ChainTransitionError crypto = ChainTransitionError [ PredicateFailure ( PRTCL crypto)]
- tickChainDepState :: Globals -> LedgerView crypto -> Bool -> ChainDepState crypto -> ChainDepState crypto
- updateChainDepState :: forall crypto m. ( PraosCrypto crypto, MonadError ( ChainTransitionError crypto) m) => Globals -> LedgerView crypto -> BHeader crypto -> ChainDepState crypto -> m ( ChainDepState crypto)
- reupdateChainDepState :: forall crypto. PraosCrypto crypto => Globals -> LedgerView crypto -> BHeader crypto -> ChainDepState crypto -> ChainDepState crypto
- initialChainDepState :: Nonce -> Map ( KeyHash ' Genesis crypto) ( GenDelegPair crypto) -> ChainDepState crypto
- checkLeaderValue :: forall v. VRFAlgorithm v => OutputVRF v -> Rational -> ActiveSlotCoeff -> Bool
- getLeaderSchedule :: ( Era era, Signable ( VRF ( Crypto era)) Seed , HasField "_d" ( PParams era) UnitInterval ) => Globals -> NewEpochState era -> ChainDepState ( Crypto era) -> KeyHash ' StakePool ( Crypto era) -> SignKeyVRF ( Crypto era) -> PParams era -> Set SlotNo
Documentation
class ( Crypto c, DSignable c ( OCertSignable c), KESignable c ( BHBody c), VRFSignable c Seed ) => PraosCrypto c Source #
Instances
PraosCrypto StandardCrypto Source # | |
Defined in Cardano.Protocol.TPraos.API |
class ( ChainData ( ChainDepState ( Crypto era)), SerialisableData ( ChainDepState ( Crypto era)), Eq ( ChainTransitionError ( Crypto era)), Show ( ChainTransitionError ( Crypto era)), Show ( LedgerView ( Crypto era)), Show ( FutureLedgerViewError era), STS ( EraRule "TICKF" era), BaseM ( EraRule "TICKF" era) ~ ShelleyBase , Environment ( EraRule "TICKF" era) ~ (), State ( EraRule "TICKF" era) ~ NewEpochState era, Signal ( EraRule "TICKF" era) ~ SlotNo , PredicateFailure ( EraRule "TICKF" era) ~ TickfPredicateFailure era, HasField "_d" ( PParams era) UnitInterval , HasField "_maxBBSize" ( PParams era) Natural , HasField "_maxBHSize" ( PParams era) Natural , HasField "_protocolVersion" ( PParams era) ProtVer ) => GetLedgerView era where Source #
Nothing
currentLedgerView :: NewEpochState era -> LedgerView ( Crypto era) Source #
default currentLedgerView :: HasField "_extraEntropy" ( PParams era) Nonce => NewEpochState era -> LedgerView ( Crypto era) Source #
futureLedgerView :: MonadError ( FutureLedgerViewError era) m => Globals -> NewEpochState era -> SlotNo -> m ( LedgerView ( Crypto era)) Source #
default futureLedgerView :: ( MonadError ( FutureLedgerViewError era) m, HasField "_extraEntropy" ( PParams era) Nonce ) => Globals -> NewEpochState era -> SlotNo -> m ( LedgerView ( Crypto era)) Source #
Instances
data LedgerView crypto Source #
Data required by the Transitional Praos protocol from the Shelley ledger.
LedgerView | |
|
Instances
mkInitialShelleyLedgerView :: forall c. ShelleyGenesis ( ShelleyEra c) -> LedgerView c Source #
We construct a
LedgerView
using the Shelley genesis config in the same
way as
translateToShelleyLedgerState
.
newtype FutureLedgerViewError era Source #
FutureLedgerViewError [ PredicateFailure ( EraRule "TICKF" era)] |
Instances
Eq ( PredicateFailure ( EraRule "TICKF" era)) => Eq ( FutureLedgerViewError era) Source # | |
Defined in Cardano.Protocol.TPraos.API (==) :: FutureLedgerViewError era -> FutureLedgerViewError era -> Bool Source # (/=) :: FutureLedgerViewError era -> FutureLedgerViewError era -> Bool Source # |
|
Show ( PredicateFailure ( EraRule "TICKF" era)) => Show ( FutureLedgerViewError era) Source # | |
Defined in Cardano.Protocol.TPraos.API |
Chain state operations
The chain state is an amalgam of the protocol state and the ticked nonce.
data ChainDepState crypto Source #
ChainDepState | |
|
Instances
newtype ChainTransitionError crypto Source #
ChainTransitionError [ PredicateFailure ( PRTCL crypto)] |
Instances
:: Globals | |
-> LedgerView crypto | |
-> Bool |
Are we in a new epoch? |
-> ChainDepState crypto | |
-> ChainDepState crypto |
Tick the chain state to a new epoch.
updateChainDepState :: forall crypto m. ( PraosCrypto crypto, MonadError ( ChainTransitionError crypto) m) => Globals -> LedgerView crypto -> BHeader crypto -> ChainDepState crypto -> m ( ChainDepState crypto) Source #
Update the chain state based upon a new block header.
This also updates the last applied block hash.
reupdateChainDepState :: forall crypto. PraosCrypto crypto => Globals -> LedgerView crypto -> BHeader crypto -> ChainDepState crypto -> ChainDepState crypto Source #
Re-update the chain state based upon a new block header.
This function does no validation of whether the header is internally valid or consistent with the chain it is being applied to; the caller must ensure that this is valid through having previously applied it.
initialChainDepState :: Nonce -> Map ( KeyHash ' Genesis crypto) ( GenDelegPair crypto) -> ChainDepState crypto Source #
Construct an initial chain state given an initial nonce and a set of genesis delegates.
checkLeaderValue :: forall v. VRFAlgorithm v => OutputVRF v -> Rational -> ActiveSlotCoeff -> Bool Source #
Check that the certified VRF output, when used as a natural, is valid for being slot leader.
getLeaderSchedule :: ( Era era, Signable ( VRF ( Crypto era)) Seed , HasField "_d" ( PParams era) UnitInterval ) => Globals -> NewEpochState era -> ChainDepState ( Crypto era) -> KeyHash ' StakePool ( Crypto era) -> SignKeyVRF ( Crypto era) -> PParams era -> Set SlotNo Source #
Get the (private) leader schedule for this epoch.
Given a private VRF key, returns the set of slots in which this node is eligible to lead.