Skip to content
Merged
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
24 changes: 12 additions & 12 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -159,43 +159,43 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bda15b9fa712bf9063ff7312dddef6f8d70e3f8e
--sha256: 138sbsfyhp1wm8yhiiafqzhi6sfcpp1xkwpyd28qckj2mxf8z6n0
tag: d10508f3094fa8c429ce371255129fbc9e9418a0
--sha256: 1q3qaq23br1zfxw7n1jb2l2hcfa0gyh2f3asi8xqrwj1dffkr2ls
subdir: semantics/executable-spec

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bda15b9fa712bf9063ff7312dddef6f8d70e3f8e
--sha256: 138sbsfyhp1wm8yhiiafqzhi6sfcpp1xkwpyd28qckj2mxf8z6n0
tag: d10508f3094fa8c429ce371255129fbc9e9418a0
--sha256: 1q3qaq23br1zfxw7n1jb2l2hcfa0gyh2f3asi8xqrwj1dffkr2ls
subdir: byron/ledger/executable-spec

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bda15b9fa712bf9063ff7312dddef6f8d70e3f8e
--sha256: 138sbsfyhp1wm8yhiiafqzhi6sfcpp1xkwpyd28qckj2mxf8z6n0
tag: d10508f3094fa8c429ce371255129fbc9e9418a0
--sha256: 1q3qaq23br1zfxw7n1jb2l2hcfa0gyh2f3asi8xqrwj1dffkr2ls
subdir: byron/chain/executable-spec

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bda15b9fa712bf9063ff7312dddef6f8d70e3f8e
--sha256: 138sbsfyhp1wm8yhiiafqzhi6sfcpp1xkwpyd28qckj2mxf8z6n0
tag: d10508f3094fa8c429ce371255129fbc9e9418a0
--sha256: 1q3qaq23br1zfxw7n1jb2l2hcfa0gyh2f3asi8xqrwj1dffkr2ls
subdir: shelley/chain-and-ledger/dependencies/non-integer

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bda15b9fa712bf9063ff7312dddef6f8d70e3f8e
--sha256: 138sbsfyhp1wm8yhiiafqzhi6sfcpp1xkwpyd28qckj2mxf8z6n0
tag: d10508f3094fa8c429ce371255129fbc9e9418a0
--sha256: 1q3qaq23br1zfxw7n1jb2l2hcfa0gyh2f3asi8xqrwj1dffkr2ls
subdir: shelley/chain-and-ledger/executable-spec

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: bda15b9fa712bf9063ff7312dddef6f8d70e3f8e
--sha256: 138sbsfyhp1wm8yhiiafqzhi6sfcpp1xkwpyd28qckj2mxf8z6n0
tag: d10508f3094fa8c429ce371255129fbc9e9418a0
--sha256: 1q3qaq23br1zfxw7n1jb2l2hcfa0gyh2f3asi8xqrwj1dffkr2ls
subdir: shelley/chain-and-ledger/executable-spec/test

source-repository-package
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import qualified Shelley.Spec.Ledger.LedgerState as SL
import qualified Shelley.Spec.Ledger.PParams as SL
import qualified Shelley.Spec.Ledger.STS.Chain as STS
import qualified Shelley.Spec.Ledger.TxData as SL
import qualified Shelley.Spec.Ledger.UTxO as SL

import Ouroboros.Consensus.Shelley.Ledger.Block
import Ouroboros.Consensus.Shelley.Ledger.Config
Expand Down Expand Up @@ -249,6 +250,9 @@ instance TPraosCrypto c => QueryLedger (ShelleyBlock c) where
:: Query (ShelleyBlock c) (SL.ProposedPPUpdates c)
GetStakeDistribution
:: Query (ShelleyBlock c) (SL.PoolDistr c)
GetFilteredUTxO
:: Set (SL.Addr c)
-> Query (ShelleyBlock c) (SL.UTxO c)

answerQuery globals query st = case query of
GetLedgerTip -> ledgerTip st
Expand All @@ -258,6 +262,7 @@ instance TPraosCrypto c => QueryLedger (ShelleyBlock c) where
GetCurrentPParams -> getPParams $ shelleyState st
GetProposedPParamsUpdates -> getProposedPPUpdates $ shelleyState st
GetStakeDistribution -> SL.nesPd $ shelleyState st
GetFilteredUTxO addrs -> SL.getFilteredUTxO (shelleyState st) addrs

eqQuery GetLedgerTip GetLedgerTip
= Just Refl
Expand Down Expand Up @@ -286,6 +291,13 @@ instance TPraosCrypto c => QueryLedger (ShelleyBlock c) where
= Just Refl
eqQuery GetStakeDistribution _
= Nothing
eqQuery (GetFilteredUTxO addrs) (GetFilteredUTxO addrs')
| addrs == addrs'
= Just Refl
| otherwise
= Nothing
eqQuery (GetFilteredUTxO _) _
= Nothing

deriving instance Eq (Query (ShelleyBlock c) result)
deriving instance Show (Query (ShelleyBlock c) result)
Expand All @@ -297,6 +309,7 @@ instance Crypto c => ShowQuery (Query (ShelleyBlock c)) where
showResult GetCurrentPParams = show
showResult GetProposedPParamsUpdates = show
showResult GetStakeDistribution = show
showResult (GetFilteredUTxO {}) = show

{-------------------------------------------------------------------------------
ValidateEnvelope
Expand Down Expand Up @@ -384,6 +397,8 @@ encodeShelleyQuery query = case query of
CBOR.encodeListLen 1 <> CBOR.encodeWord8 4
GetStakeDistribution ->
CBOR.encodeListLen 1 <> CBOR.encodeWord8 5
GetFilteredUTxO addrs ->
CBOR.encodeListLen 2 <> CBOR.encodeWord8 6 <> toCBOR addrs

decodeShelleyQuery :: Crypto c => Decoder s (Some (Query (ShelleyBlock c)))
decodeShelleyQuery = do
Expand All @@ -396,6 +411,7 @@ decodeShelleyQuery = do
(1, 3) -> return $ Some GetCurrentPParams
(1, 4) -> return $ Some GetProposedPParamsUpdates
(1, 5) -> return $ Some GetStakeDistribution
(2, 6) -> Some . GetFilteredUTxO <$> fromCBOR
_ -> fail $
"decodeShelleyQuery: invalid (len, tag): (" <>
show len <> ", " <> show tag <> ")"
Expand All @@ -410,6 +426,7 @@ encodeShelleyResult query = case query of
GetCurrentPParams -> toCBOR
GetProposedPParamsUpdates -> toCBOR
GetStakeDistribution -> toCBOR
GetFilteredUTxO {} -> toCBOR

decodeShelleyResult
:: Crypto c
Expand All @@ -422,3 +439,4 @@ decodeShelleyResult query = case query of
GetCurrentPParams -> fromCBOR
GetProposedPParamsUpdates -> fromCBOR
GetStakeDistribution -> fromCBOR
GetFilteredUTxO {} -> fromCBOR
Original file line number Diff line number Diff line change
Expand Up @@ -651,5 +651,8 @@ instance Eq (Some (Query Block)) where
Some GetProposedPParamsUpdates == _ = False
Some GetStakeDistribution == Some GetStakeDistribution = True
Some GetStakeDistribution == _ = False
Some (GetFilteredUTxO addrs) == Some (GetFilteredUTxO addrs') =
addrs == addrs'
Some (GetFilteredUTxO _) == _ = False

deriving instance Show (Some (Query Block))
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extra-deps:
- slotting

- git: https://github.com/input-output-hk/cardano-ledger-specs
commit: bda15b9fa712bf9063ff7312dddef6f8d70e3f8e
commit: d10508f3094fa8c429ce371255129fbc9e9418a0
subdirs:
- byron/chain/executable-spec
- byron/ledger/executable-spec
Expand Down