Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
156d119
Add `DijkstraEra era` to `CardanoEra era`
Jimbo4350 Jul 30, 2025
2872eda
Add `ShelleyBasedEraDijkstra` to `ShelleyBasedEra era`
Jimbo4350 Jul 30, 2025
dda8797
Add Dijkstra era to eons
Jimbo4350 Jul 30, 2025
704d11d
Add `DijkstraEra` to `Era era`
Jimbo4350 Jul 30, 2025
7a86381
COMBINE ME: cabal file updates
Jimbo4350 Jul 30, 2025
5be60e0
Update `QueryInShelleyBasedEra era result`
Jimbo4350 Jul 30, 2025
3a8826d
Update `makeShelleyTransactionBody` with Dijkstra era
Jimbo4350 Jul 30, 2025
e63bb2c
Update ledger types `PParamUpdatePurpose`, `CommitteePurpose` and
Jimbo4350 Jul 30, 2025
63ad603
Propagate `ChainAccountState`
Jimbo4350 Jul 30, 2025
b483de7
Consensus related Dijkstra changes
Jimbo4350 Jul 30, 2025
0d8ee49
Temporary Cardano.Api.LedgerState Dijkstra update
Jimbo4350 Jul 30, 2025
730ff11
Update TxOut rendering to handle Dijkstra era
Jimbo4350 Jul 30, 2025
ca28c36
Update `eraSpecificLedgerTxBody` with Dijkstra era
Jimbo4350 Jul 30, 2025
d91aedc
Update `decodeBigLedgerPeerSnapshot` to support snapshot SRV names
Jimbo4350 Jul 30, 2025
338a657
Update generators with PlutusScriptV4
Jimbo4350 Jul 30, 2025
acdff31
Introduce PlutusScriptV4
Jimbo4350 Jul 30, 2025
3437b94
Propagate Dijkstra era
Jimbo4350 Jul 30, 2025
0a737a6
Merge with PlutusV4 intro
Jimbo4350 Jul 30, 2025
5229ec3
Merge with propagate Dikstra
Jimbo4350 Jul 30, 2025
6e832cb
REMOVE ME: Add ledger and consensus SRPs
Jimbo4350 Jul 30, 2025
8330132
Update nix flake
Jimbo4350 Jul 30, 2025
f3ca538
Update cardano-rpc with PlutusV4
Jimbo4350 Jul 31, 2025
6d81484
Implement `executeLocalStateQueryExprWithVersion`
Jimbo4350 Jul 31, 2025
4904a0d
Fix parseHardForkTriggers
Jimbo4350 Jul 31, 2025
2da81eb
Fix cardano-rpc-test for protocol parameters roundtrip
carbolymer Aug 1, 2025
673e4a8
Update flake lock and ouroboros-network and plutus patches
palas Aug 1, 2025
65013af
Update wasm cache
palas Aug 1, 2025
1efbb74
Merge with: Consensus related Dijkstra change
Aug 7, 2025
faab1c2
Use exampleDijkstraGenesis value
Aug 7, 2025
7b8fa12
Fix cabal-gild CI failure
Aug 7, 2025
0eeff17
Run formolu
Aug 7, 2025
a93eab2
Fix HLS CI job
carbolymer Aug 11, 2025
79b9c02
Address lints
palas Aug 12, 2025
64e62e7
Update `ouroboros-consensus` stanza
palas Aug 12, 2025
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
Prev Previous commit
Next Next commit
Update QueryInShelleyBasedEra era result
- QueryAccountState returns `ChainAccountState` instead of
  `AccountState`
- Use updated consensus queries `GetStakeDistribution2` and  `GetPoolDistr2`
  • Loading branch information
Jimbo4350 authored and Jordan Millar committed Aug 8, 2025
commit 5be60e068ca3331ecdd1982cb775dab939b30579
10 changes: 8 additions & 2 deletions cardano-api/src/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import Ouroboros.Consensus.Byron.Ledger qualified as Consensus
import Ouroboros.Consensus.Cardano.Block qualified as Consensus
import Ouroboros.Consensus.HardFork.Combinator qualified as Consensus
import Ouroboros.Consensus.Shelley.Ledger qualified as Consensus
import Ouroboros.Consensus.Shelley.Protocol.Abstract qualified as Consensus
import Ouroboros.Network.Block qualified as Consensus

import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), object, withObject, (.:), (.=))
Expand Down Expand Up @@ -153,6 +152,12 @@ instance Show (Block era) where
( showString "ShelleyBlock ShelleyBasedEraConway "
. showsPrec 11 block
)
showsPrec p (ShelleyBlock ShelleyBasedEraDijkstra block) =
showParen
(p >= 11)
( showString "ShelleyBlock ShelleyBasedEraDijkstra "
. showsPrec 11 block
)

getBlockTxs :: forall era. Block era -> [Tx era]
getBlockTxs = \case
Expand All @@ -167,7 +172,6 @@ getShelleyBlockTxs
:: forall era ledgerera blockheader
. ShelleyLedgerEra era ~ ledgerera
=> Consensus.ShelleyCompatible (ConsensusProtocol era) ledgerera
=> Consensus.ShelleyProtocolHeader (ConsensusProtocol era) ~ blockheader
=> ShelleyBasedEra era
-> Ledger.Block blockheader ledgerera
-> [Tx era]
Expand Down Expand Up @@ -203,6 +207,7 @@ fromConsensusBlock = \case
Consensus.BlockAlonzo b' -> BlockInMode cardanoEra $ ShelleyBlock ShelleyBasedEraAlonzo b'
Consensus.BlockBabbage b' -> BlockInMode cardanoEra $ ShelleyBlock ShelleyBasedEraBabbage b'
Consensus.BlockConway b' -> BlockInMode cardanoEra $ ShelleyBlock ShelleyBasedEraConway b'
Consensus.BlockDijkstra b' -> BlockInMode cardanoEra $ ShelleyBlock ShelleyBasedEraDijkstra b'

toConsensusBlock
:: ()
Expand All @@ -217,6 +222,7 @@ toConsensusBlock = \case
BlockInMode _ (ShelleyBlock ShelleyBasedEraAlonzo b') -> Consensus.BlockAlonzo b'
BlockInMode _ (ShelleyBlock ShelleyBasedEraBabbage b') -> Consensus.BlockBabbage b'
BlockInMode _ (ShelleyBlock ShelleyBasedEraConway b') -> Consensus.BlockConway b'
BlockInMode _ (ShelleyBlock ShelleyBasedEraDijkstra b') -> Consensus.BlockDijkstra b'

-- ----------------------------------------------------------------------------
-- Block headers
Expand Down
43 changes: 28 additions & 15 deletions cardano-api/src/Cardano/Api/Query/Internal/Type/QueryInMode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import Cardano.Api.Certificate.Internal
import Cardano.Api.Consensus.Internal.Mode
import Cardano.Api.Era.Internal.Case
import Cardano.Api.Era.Internal.Core
import Cardano.Api.Era.Internal.Eon.ConwayEraOnwards
import Cardano.Api.Era.Internal.Eon.ShelleyBasedEra
import Cardano.Api.Genesis.Internal.Parameters
import Cardano.Api.HasTypeProxy (HasTypeProxy (..), Proxy)
Expand All @@ -93,12 +94,11 @@ import Cardano.Ledger.Api qualified as L
import Cardano.Ledger.Api.State.Query qualified as L
import Cardano.Ledger.Binary
import Cardano.Ledger.Binary.Plain qualified as Plain
import Cardano.Ledger.CertState qualified as L
import Cardano.Ledger.Coin qualified as L
import Cardano.Ledger.Conway.State qualified as L
import Cardano.Ledger.Credential qualified as Shelley
import Cardano.Ledger.Shelley.API qualified as Shelley
import Cardano.Ledger.Shelley.Core qualified as Core
import Cardano.Ledger.Shelley.LedgerState qualified as L
import Cardano.Slotting.EpochInfo (hoistEpochInfo)
import Cardano.Slotting.Slot (WithOrigin (..))
import Cardano.Slotting.Time (SystemStart (..))
Expand All @@ -116,9 +116,8 @@ import Ouroboros.Consensus.Ledger.Query qualified as Consensus
import Ouroboros.Consensus.Protocol.Abstract qualified as Consensus
import Ouroboros.Consensus.Shelley.Ledger qualified as Consensus
import Ouroboros.Consensus.Shelley.Ledger.Query.Types qualified as Consensus
import Ouroboros.Consensus.Shelley.Protocol.Abstract (ProtoCrypto)
import Ouroboros.Network.Block (Serialised (..))
import Ouroboros.Network.PeerSelection.LedgerPeers.Type (LedgerPeerSnapshot)
import Ouroboros.Network.PeerSelection.LedgerPeers.Type
import Ouroboros.Network.Protocol.LocalStateQuery.Client (Some (..))

import Codec.Serialise qualified as CBOR
Expand Down Expand Up @@ -286,7 +285,7 @@ data QueryInShelleyBasedEra era result where
:: Set StakeCredential
-> QueryInShelleyBasedEra era (Map StakeCredential L.Coin)
QueryAccountState
:: QueryInShelleyBasedEra era L.AccountState
:: QueryInShelleyBasedEra era L.ChainAccountState
QueryConstitution
:: QueryInShelleyBasedEra era (L.Constitution (ShelleyLedgerEra era))
QueryGovState
Expand Down Expand Up @@ -406,7 +405,7 @@ decodePoolState (SerialisedPoolState (Serialised ls)) =

newtype SerialisedPoolDistribution era
= SerialisedPoolDistribution
(Serialised (Consensus.PoolDistr StandardCrypto))
(Serialised Shelley.PoolDistr)

newtype PoolDistribution era = PoolDistribution
{ unPoolDistr :: Consensus.PoolDistr StandardCrypto
Expand Down Expand Up @@ -477,15 +476,15 @@ fromLedgerUTxO sbe (Shelley.UTxO utxo) =
$ utxo

fromShelleyPoolDistr
:: Consensus.PoolDistr StandardCrypto
:: Shelley.PoolDistr
-> Map (Hash StakePoolKey) Rational
fromShelleyPoolDistr =
-- TODO: write an appropriate property to show it is safe to use
-- Map.fromListAsc or to use Map.mapKeysMonotonic
fromList
. map (bimap StakePoolKeyHash Consensus.individualPoolStake)
. map (bimap StakePoolKeyHash Shelley.individualPoolStake)
. toList
. Consensus.unPoolDistr
. Shelley.unPoolDistr

fromShelleyDelegations
:: Map
Expand Down Expand Up @@ -564,7 +563,7 @@ toConsensusQueryShelleyBased sbe = \case
QueryProtocolParameters ->
Some (consensusQueryInEraInMode era Consensus.GetCurrentPParams)
QueryStakeDistribution ->
Some (consensusQueryInEraInMode era Consensus.GetStakeDistribution)
Some (consensusQueryInEraInMode era Consensus.GetStakeDistribution2)
QueryUTxO QueryUTxOWhole ->
Some (consensusQueryInEraInMode era Consensus.GetUTxOWhole)
QueryUTxO (QueryUTxOByAddress addrs) ->
Expand Down Expand Up @@ -613,7 +612,7 @@ toConsensusQueryShelleyBased sbe = \case
)
QueryPoolDistribution poolIds ->
Some
(consensusQueryInEraInMode era (Consensus.GetCBOR (Consensus.GetPoolDistr (getPoolIds <$> poolIds))))
(consensusQueryInEraInMode era (Consensus.GetCBOR (Consensus.GetPoolDistr2 (getPoolIds <$> poolIds))))
where
getPoolIds :: Set PoolId -> Set (Shelley.KeyHash Shelley.StakePool)
getPoolIds = Set.map (\(StakePoolKeyHash kh) -> kh)
Expand All @@ -640,7 +639,9 @@ toConsensusQueryShelleyBased sbe = \case
QueryDRepState creds ->
caseShelleyToBabbageOrConwayEraOnwards
(const $ error "toConsensusQueryShelleyBased: QueryDRepState is only available in the Conway era")
(const $ Some (consensusQueryInEraInMode era (Consensus.GetDRepState creds)))
( \w ->
Some (consensusQueryInEraInMode era (conwayEraOnwardsConstraints w $ Consensus.GetDRepState creds))
)
sbe
QueryDRepStakeDistr dreps ->
caseShelleyToBabbageOrConwayEraOnwards
Expand Down Expand Up @@ -727,6 +728,7 @@ consensusQueryInEraInMode erainmode b =
AlonzoEra -> Consensus.QueryIfCurrentAlonzo b
BabbageEra -> Consensus.QueryIfCurrentBabbage b
ConwayEra -> Consensus.QueryIfCurrentConway b
DijkstraEra -> Consensus.QueryIfCurrentDijkstra b

-- ----------------------------------------------------------------------------
-- Conversions of query results from the consensus types.
Expand Down Expand Up @@ -849,6 +851,18 @@ fromConsensusQueryResult (QueryInEra (QueryInShelleyBasedEra ShelleyBasedEraConw
)
r'
_ -> fromConsensusQueryResultMismatch
fromConsensusQueryResult (QueryInEra (QueryInShelleyBasedEra ShelleyBasedEraDijkstra q)) q' r' =
case q' of
Consensus.BlockQuery (Consensus.QueryIfCurrentDijkstra q'') ->
bimap
fromConsensusEraMismatch
( fromConsensusQueryResultShelleyBased
ShelleyBasedEraDijkstra
q
q''
)
r'
_ -> fromConsensusQueryResultMismatch

-- This function is written like this so that we have exhaustive pattern checking
-- on the @QueryInShelleyBasedEra era result@ value. Don't change the top-level
Expand All @@ -858,7 +872,6 @@ fromConsensusQueryResultShelleyBased
. HasCallStack
=> ShelleyLedgerEra era ~ ledgerera
=> ConsensusProtocol era ~ protocol
=> ProtoCrypto protocol ~ StandardCrypto
=> ShelleyBasedEra era
-> QueryInShelleyBasedEra era result
-> Consensus.BlockQuery (Consensus.ShelleyBlock protocol ledgerera) fp result'
Expand All @@ -884,7 +897,7 @@ fromConsensusQueryResultShelleyBased sbe sbeQuery q' r' =
_ -> fromConsensusQueryResultMismatch
QueryStakeDistribution ->
case q' of
Consensus.GetStakeDistribution -> fromShelleyPoolDistr r'
Consensus.GetStakeDistribution2 -> fromShelleyPoolDistr r'
_ -> fromConsensusQueryResultMismatch
QueryUTxO QueryUTxOWhole ->
case q' of
Expand Down Expand Up @@ -939,7 +952,7 @@ fromConsensusQueryResultShelleyBased sbe sbeQuery q' r' =
_ -> fromConsensusQueryResultMismatch
QueryPoolDistribution{} ->
case q' of
Consensus.GetCBOR Consensus.GetPoolDistr{} ->
Consensus.GetCBOR Consensus.GetPoolDistr2{} ->
SerialisedPoolDistribution r'
_ -> fromConsensusQueryResultMismatch
QueryStakeSnapshot{} ->
Expand Down