diff --git a/cabal.project b/cabal.project index df313c70e04..85730848e95 100644 --- a/cabal.project +++ b/cabal.project @@ -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 diff --git a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs index fd5d3ac52c9..95c474106cb 100644 --- a/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs +++ b/ouroboros-consensus-shelley/src/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs @@ -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 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 <> ")" @@ -410,6 +426,7 @@ encodeShelleyResult query = case query of GetCurrentPParams -> toCBOR GetProposedPParamsUpdates -> toCBOR GetStakeDistribution -> toCBOR + GetFilteredUTxO {} -> toCBOR decodeShelleyResult :: Crypto c @@ -422,3 +439,4 @@ decodeShelleyResult query = case query of GetCurrentPParams -> fromCBOR GetProposedPParamsUpdates -> fromCBOR GetStakeDistribution -> fromCBOR + GetFilteredUTxO {} -> fromCBOR diff --git a/ouroboros-consensus-shelley/test/Test/Consensus/Shelley/Ledger.hs b/ouroboros-consensus-shelley/test/Test/Consensus/Shelley/Ledger.hs index 4cbe22913a1..f7f7f168e49 100644 --- a/ouroboros-consensus-shelley/test/Test/Consensus/Shelley/Ledger.hs +++ b/ouroboros-consensus-shelley/test/Test/Consensus/Shelley/Ledger.hs @@ -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)) diff --git a/stack.yaml b/stack.yaml index ba9ca2b9829..be5073a95f1 100644 --- a/stack.yaml +++ b/stack.yaml @@ -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