-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4912: Add slotsInEpoch and slotsToEpochEnd to query tip command r=newhoggy a=newhoggy Example output: ``` CARDANO_NODE_SOCKET_PATH=example/node-pool1/node.sock cardano-cli query tip --testnet-magic 42 { "block": 768, "epoch": 33, "era": "Alonzo", "hash": "4ca7fd3a9827e74f98e779a8ae333dc6fa3b69832cb11fdbab7af215eb68b1ee", "slot": 16814, "slotsInEpoch": 314, "slotsToEpochEnd": 186, "syncProgress": "100.00" } ``` Resolves #3878 4915: Tip hash metrics r=newhoggy a=newhoggy Salvaging this PR #2006 Related to #801 4922: Deploy Haddock for merge to master only r=newhoggy a=newhoggy To merge changes from this PR #3012 Co-authored-by: John Ky <[email protected]> Co-authored-by: Luke Nadur <[email protected]> Co-authored-by: James Browning <[email protected]>
- Loading branch information
Showing
8 changed files
with
201 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
name: "Haddock documentation" | ||
|
||
on: [push] | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE GADTs #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
module Cardano.Tracing.HasIssuer | ||
( BlockIssuerVerificationKeyHash (..) | ||
, HasIssuer (..) | ||
) where | ||
|
||
import Data.ByteString (ByteString) | ||
import Data.SOP.Strict | ||
|
||
import Cardano.Api (serialiseToRawBytes, verificationKeyHash) | ||
import Cardano.Api.Byron (VerificationKey (ByronVerificationKey)) | ||
import Cardano.Api.Shelley (VerificationKey (StakePoolVerificationKey)) | ||
import qualified Cardano.Chain.Block as Byron | ||
import Cardano.Ledger.Crypto (StandardCrypto) | ||
import qualified Cardano.Ledger.Shelley.API as Shelley | ||
|
||
import Ouroboros.Consensus.Byron.Ledger.Block (ByronBlock, Header (..)) | ||
import Ouroboros.Consensus.HardFork.Combinator (HardForkBlock, Header (..), | ||
OneEraHeader (..)) | ||
import Ouroboros.Consensus.Shelley.Ledger.Block (Header (..), ShelleyBlock) | ||
|
||
import Ouroboros.Consensus.Shelley.Protocol.Abstract | ||
|
||
-- | Block issuer verification key hash. | ||
data BlockIssuerVerificationKeyHash | ||
= BlockIssuerVerificationKeyHash !ByteString | ||
-- ^ Serialized block issuer verification key hash. | ||
| NoBlockIssuer | ||
-- ^ There is no block issuer. | ||
-- | ||
-- For example, this could be relevant for epoch boundary blocks (EBBs), | ||
-- genesis blocks, etc. | ||
deriving (Eq, Show) | ||
|
||
-- | Get the block issuer verification key hash from a block header. | ||
class HasIssuer blk where | ||
-- | Given a block header, return the serialized block issuer verification | ||
-- key hash. | ||
getIssuerVerificationKeyHash :: Header blk -> BlockIssuerVerificationKeyHash | ||
|
||
instance HasIssuer ByronBlock where | ||
getIssuerVerificationKeyHash byronBlkHdr = | ||
case byronHeaderRaw byronBlkHdr of | ||
Byron.ABOBBlockHdr hdr -> | ||
BlockIssuerVerificationKeyHash | ||
. serialiseToRawBytes | ||
. verificationKeyHash | ||
. ByronVerificationKey | ||
$ Byron.headerIssuer hdr | ||
Byron.ABOBBoundaryHdr _ -> NoBlockIssuer | ||
|
||
instance | ||
( ProtoCrypto protocol ~ StandardCrypto | ||
, ProtocolHeaderSupportsProtocol protocol | ||
) => HasIssuer (ShelleyBlock protocol era) where | ||
getIssuerVerificationKeyHash shelleyBlkHdr = | ||
BlockIssuerVerificationKeyHash | ||
. serialiseToRawBytes | ||
. verificationKeyHash | ||
. StakePoolVerificationKey | ||
$ toStakePoolKey issuer | ||
where | ||
-- We don't support a "block issuer" key role in @cardano-api@, so we'll | ||
-- just convert it to a stake pool key. | ||
toStakePoolKey | ||
:: Shelley.VKey 'Shelley.BlockIssuer era | ||
-> Shelley.VKey 'Shelley.StakePool era | ||
toStakePoolKey vk = Shelley.VKey (Shelley.unVKey vk) | ||
|
||
issuer = pHeaderIssuer (shelleyHeaderRaw shelleyBlkHdr) | ||
|
||
instance All HasIssuer xs => HasIssuer (HardForkBlock xs) where | ||
getIssuerVerificationKeyHash = | ||
hcollapse | ||
. hcmap (Proxy @HasIssuer) (K . getIssuerVerificationKeyHash) | ||
. getOneEraHeader | ||
. getHardForkHeader |
Oops, something went wrong.