diff --git a/ouroboros-consensus-cardano/changelog.d/js-ntc20.md b/ouroboros-consensus-cardano/changelog.d/js-ntc20.md new file mode 100644 index 0000000000..db1064d1ae --- /dev/null +++ b/ouroboros-consensus-cardano/changelog.d/js-ntc20.md @@ -0,0 +1,4 @@ +### Breaking + +* Use new `NodeToClientV_20`. +* Expose new query `QueryStakePoolDefaultVote` in new `ShelleyNodeToClientVersion12`. diff --git a/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs b/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs index e4297052e7..7a011400ef 100644 --- a/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs +++ b/ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs @@ -313,19 +313,19 @@ pattern CardanoNodeToClientVersion14 = ) -- | The hard fork enabled, and the Shelley, Allegra, Mary, Alonzo and Babbage --- and Conway eras enabled, using 'ShelleyNodeToClientVersion11' for the +-- and Conway eras enabled, using 'ShelleyNodeToClientVersion12' for the -- Shelley-based eras. pattern CardanoNodeToClientVersion15 :: BlockNodeToClientVersion (CardanoBlock c) pattern CardanoNodeToClientVersion15 = HardForkNodeToClientEnabled HardForkSpecificNodeToClientVersion3 ( EraNodeToClientEnabled ByronNodeToClientVersion1 - :* EraNodeToClientEnabled ShelleyNodeToClientVersion11 - :* EraNodeToClientEnabled ShelleyNodeToClientVersion11 - :* EraNodeToClientEnabled ShelleyNodeToClientVersion11 - :* EraNodeToClientEnabled ShelleyNodeToClientVersion11 - :* EraNodeToClientEnabled ShelleyNodeToClientVersion11 - :* EraNodeToClientEnabled ShelleyNodeToClientVersion11 + :* EraNodeToClientEnabled ShelleyNodeToClientVersion12 + :* EraNodeToClientEnabled ShelleyNodeToClientVersion12 + :* EraNodeToClientEnabled ShelleyNodeToClientVersion12 + :* EraNodeToClientEnabled ShelleyNodeToClientVersion12 + :* EraNodeToClientEnabled ShelleyNodeToClientVersion12 + :* EraNodeToClientEnabled ShelleyNodeToClientVersion12 :* Nil ) diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs index 957bddce67..73a219fc95 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/NetworkProtocolVersion.hs @@ -26,6 +26,9 @@ data ShelleyNodeToClientVersion = -- | New queries introduced: GetBigLedgerPeerSnapshot | ShelleyNodeToClientVersion11 + + -- | New queries introduced: QueryStakePoolDefaultVote + | ShelleyNodeToClientVersion12 deriving (Show, Eq, Ord, Enum, Bounded) instance HasNetworkProtocolVersion (ShelleyBlock proto era) where @@ -43,6 +46,7 @@ instance SupportedNetworkProtocolVersion (ShelleyBlock proto era) where , (NodeToClientV_17, ShelleyNodeToClientVersion9) , (NodeToClientV_18, ShelleyNodeToClientVersion10) , (NodeToClientV_19, ShelleyNodeToClientVersion11) + , (NodeToClientV_20, ShelleyNodeToClientVersion12) ] latestReleasedNodeVersion = latestReleasedNodeVersionDefault diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs index e48b281ecd..69405f1164 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs @@ -323,6 +323,11 @@ data instance BlockQuery (ShelleyBlock proto era) :: Type -> Type where GetBigLedgerPeerSnapshot :: BlockQuery (ShelleyBlock proto era) LedgerPeerSnapshot + QueryStakePoolDefaultVote + :: CG.ConwayEraGov era + => KeyHash 'StakePool (EraCrypto era) + -> BlockQuery (ShelleyBlock proto era) CG.DefaultVote + -- WARNING: please add new queries to the end of the list and stick to this -- order in all other pattern matches on queries. This helps in particular -- with the en/decoders, as we want the CBOR tags to be ordered. @@ -490,6 +495,8 @@ instance (ShelleyCompatible proto era, ProtoCrypto proto ~ crypto) ledgerPeers = second (fmap stakePoolRelayAccessPoint) <$> getPeers lst bigLedgerPeers = accumulateBigLedgerStake ledgerPeers in LedgerPeerSnapshot (slot, bigLedgerPeers) + QueryStakePoolDefaultVote stakePool -> + SL.queryStakePoolDefaultVote st stakePool where lcfg = configLedger $ getExtLedgerCfg cfg globals = shelleyLedgerGlobals lcfg @@ -653,6 +660,8 @@ instance SameDepIndex (BlockQuery (ShelleyBlock proto era)) where sameDepIndex GetFuturePParams{} _ = Nothing sameDepIndex GetBigLedgerPeerSnapshot GetBigLedgerPeerSnapshot = Just Refl sameDepIndex GetBigLedgerPeerSnapshot _ = Nothing + sameDepIndex QueryStakePoolDefaultVote{} QueryStakePoolDefaultVote{} = Just Refl + sameDepIndex QueryStakePoolDefaultVote{} _ = Nothing deriving instance Eq (BlockQuery (ShelleyBlock proto era) result) deriving instance Show (BlockQuery (ShelleyBlock proto era) result) @@ -694,6 +703,7 @@ instance ShelleyCompatible proto era => ShowQuery (BlockQuery (ShelleyBlock prot GetRatifyState {} -> show GetFuturePParams {} -> show GetBigLedgerPeerSnapshot -> show + QueryStakePoolDefaultVote {} -> show -- | Is the given query supported by the given 'ShelleyNodeToClientVersion'? querySupportedVersion :: BlockQuery (ShelleyBlock proto era) result -> ShelleyNodeToClientVersion -> Bool @@ -733,6 +743,7 @@ querySupportedVersion = \case GetRatifyState {} -> (>= v9) GetFuturePParams {} -> (>= v10) GetBigLedgerPeerSnapshot -> (>= v11) + QueryStakePoolDefaultVote {} -> (>= v12) -- WARNING: when adding a new query, a new @ShelleyNodeToClientVersionX@ -- must be added. See #2830 for a template on how to do this. where @@ -740,6 +751,7 @@ querySupportedVersion = \case v9 = ShelleyNodeToClientVersion9 v10 = ShelleyNodeToClientVersion10 v11 = ShelleyNodeToClientVersion11 + v12 = ShelleyNodeToClientVersion12 {------------------------------------------------------------------------------- Auxiliary @@ -862,6 +874,8 @@ encodeShelleyQuery query = case query of CBOR.encodeListLen 1 <> CBOR.encodeWord8 33 GetBigLedgerPeerSnapshot -> CBOR.encodeListLen 1 <> CBOR.encodeWord8 34 + QueryStakePoolDefaultVote stakePoolKey -> + CBOR.encodeListLen 2 <> CBOR.encodeWord8 35 <> LC.toEraCBOR @era stakePoolKey decodeShelleyQuery :: forall era proto. ShelleyBasedEra era @@ -924,6 +938,7 @@ decodeShelleyQuery = do (1, 32) -> requireCG $ return $ SomeSecond GetRatifyState (1, 33) -> requireCG $ return $ SomeSecond GetFuturePParams (1, 34) -> return $ SomeSecond GetBigLedgerPeerSnapshot + (2, 35) -> requireCG $ SomeSecond . QueryStakePoolDefaultVote <$> LC.fromEraCBOR @era _ -> failmsg "invalid" encodeShelleyResult :: @@ -966,6 +981,7 @@ encodeShelleyResult _v query = case query of GetRatifyState {} -> LC.toEraCBOR @era GetFuturePParams {} -> LC.toEraCBOR @era GetBigLedgerPeerSnapshot -> toCBOR + QueryStakePoolDefaultVote {} -> toCBOR decodeShelleyResult :: forall proto era result. ShelleyCompatible proto era @@ -1008,6 +1024,7 @@ decodeShelleyResult _v query = case query of GetRatifyState {} -> LC.fromEraCBOR @era GetFuturePParams {} -> LC.fromEraCBOR @era GetBigLedgerPeerSnapshot -> fromCBOR + QueryStakePoolDefaultVote {} -> fromCBOR -- | The stake snapshot returns information about the mark, set, go ledger snapshots for a pool, -- plus the total active stake for each snapshot that can be used in a 'sigma' calculation. diff --git a/ouroboros-consensus/changelog.d/jasagredo-ntc20.md b/ouroboros-consensus/changelog.d/jasagredo-ntc20.md new file mode 100644 index 0000000000..a78d5576db --- /dev/null +++ b/ouroboros-consensus/changelog.d/jasagredo-ntc20.md @@ -0,0 +1,3 @@ +### Non-Breaking + +* Use new `NodeToClientV_20`. diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Ledger/Query/Version.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Ledger/Query/Version.hs index 5eea4d6674..38611e0054 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Ledger/Query/Version.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Ledger/Query/Version.hs @@ -24,3 +24,4 @@ nodeToClientVersionToQueryVersion x = case x of NodeToClientV_17 -> QueryVersion2 NodeToClientV_18 -> QueryVersion2 NodeToClientV_19 -> QueryVersion2 + NodeToClientV_20 -> QueryVersion2