Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new QueryStakePoolDefaultVote #1373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ouroboros-consensus-cardano/changelog.d/js-ntc20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Breaking

* Use new `NodeToClientV_20`.
* Expose new query `QueryStakePoolDefaultVote` in new `ShelleyNodeToClientVersion12`.
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,6 +46,7 @@ instance SupportedNetworkProtocolVersion (ShelleyBlock proto era) where
, (NodeToClientV_17, ShelleyNodeToClientVersion9)
, (NodeToClientV_18, ShelleyNodeToClientVersion10)
, (NodeToClientV_19, ShelleyNodeToClientVersion11)
, (NodeToClientV_20, ShelleyNodeToClientVersion12)
]

latestReleasedNodeVersion = latestReleasedNodeVersionDefault
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -733,13 +743,15 @@ 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
v8 = ShelleyNodeToClientVersion8
v9 = ShelleyNodeToClientVersion9
v10 = ShelleyNodeToClientVersion10
v11 = ShelleyNodeToClientVersion11
v12 = ShelleyNodeToClientVersion12

{-------------------------------------------------------------------------------
Auxiliary
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ::
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions ouroboros-consensus/changelog.d/jasagredo-ntc20.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Non-Breaking

* Use new `NodeToClientV_20`.
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ nodeToClientVersionToQueryVersion x = case x of
NodeToClientV_17 -> QueryVersion2
NodeToClientV_18 -> QueryVersion2
NodeToClientV_19 -> QueryVersion2
NodeToClientV_20 -> QueryVersion2
Loading