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

cardano-node-9.1 backport: Implement a fix for inability to deserialize pointers in Conway #4591

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
4 changes: 4 additions & 0 deletions eras/shelley/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Version history for `cardano-ledger-shelley`

## 1.12.3.0

* Fix deserialization of `IncrementalStake` in Conway era: #4591

## 1.12.2.0

*
Expand Down
2 changes: 1 addition & 1 deletion eras/shelley/impl/cardano-ledger-shelley.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-shelley
version: 1.12.2.0
version: 1.12.3.0
license: Apache-2.0
maintainer: [email protected]
author: IOHK
Expand Down
12 changes: 10 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/LedgerState/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Cardano.Ledger.BaseTypes (
StrictMaybe (..),
)
import Cardano.Ledger.Binary (
DecCBOR (decCBOR),
DecCBOR (decCBOR, dropCBOR),
DecShareCBOR (Share, decShareCBOR, decSharePlusCBOR),
EncCBOR (encCBOR),
FromCBOR (..),
Expand All @@ -38,6 +38,9 @@ import Cardano.Ledger.Binary (
decodeRecordNamed,
decodeRecordNamedT,
encodeListLen,
enforceDecoderVersion,
ifDecoderVersionAtLeast,
natVersion,
toPlainDecoder,
)
import Cardano.Ledger.Binary.Coders (Decode (From, RecD), Encode (..), decode, encode, (!>), (<!))
Expand Down Expand Up @@ -79,6 +82,7 @@ import Data.Default.Class (Default, def)
import Data.Group (Group, invert)
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Proxy
import Data.VMap (VB, VMap, VP)
import GHC.Generics (Generic)
import Lens.Micro
Expand Down Expand Up @@ -239,7 +243,11 @@ instance Crypto c => DecShareCBOR (IncrementalStake c) where
decShareCBOR credInterns =
decodeRecordNamed "Stake" (const 2) $ do
stake <- decShareCBOR (credInterns, mempty)
IStake stake <$> decCBOR
let dropPtrs =
mempty
<$ enforceDecoderVersion (natVersion @8) (dropCBOR (Proxy @(Map Ptr (CompactForm Coin))))
ptrs <- ifDecoderVersionAtLeast (natVersion @9) dropPtrs decCBOR
pure $ IStake stake ptrs

instance Semigroup (IncrementalStake c) where
(IStake a b) <> (IStake c d) = IStake (Map.unionWith (<>) a c) (Map.unionWith (<>) b d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ instance Arbitrary AccountState where
shrink = genericShrink

instance Crypto c => Arbitrary (IncrementalStake c) where
arbitrary = IStake <$> arbitrary <*> arbitrary
arbitrary = IStake <$> arbitrary <*> pure mempty -- Once in Conway Ptrs Map will be removed
shrink = genericShrink

------------------------------------------------------------------------------------------
Expand Down