From d6ab278f1d19e250efbe0c8b93745a9d98541c02 Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Tue, 15 Oct 2024 14:33:15 -0600 Subject: [PATCH 1/4] Add a comment about difference in naming of VState. --- libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs index 0e7eb392e23..eec74d53325 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs @@ -352,7 +352,8 @@ deriving newtype instance Era era => ToJSON (CommitteeState era) instance Era era => ToCBOR (CommitteeState era) where toCBOR = toEraCBOR @era --- | The state that tracks the voting entities (DReps and Constitutional Committee members) +-- | The state that tracks the voting entities (DReps and Constitutional Committee +-- members). In the formal ledger specification this type is called @GState@ data VState era = VState { vsDReps :: !( Map From 41d7a6f77bbf489be8353d5fc2e4f19566822114 Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Tue, 15 Oct 2024 14:33:47 -0600 Subject: [PATCH 2/4] Make the `vsNumDormantEpochs` field strict --- libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs b/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs index eec74d53325..df4c652f51d 100644 --- a/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs +++ b/libs/cardano-ledger-core/src/Cardano/Ledger/CertState.hs @@ -361,7 +361,7 @@ data VState era = VState (DRepState (EraCrypto era)) ) , vsCommitteeState :: !(CommitteeState era) - , vsNumDormantEpochs :: EpochNo + , vsNumDormantEpochs :: !EpochNo -- ^ Number of contiguous epochs in which there are exactly zero -- active governance proposals to vote on. It is incremented in every -- EPOCH rule if the number of active governance proposals to vote on From 6aacb7ebb46e94ea9aa5dea2ee93ba4b7c0f0924 Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Tue, 15 Oct 2024 15:22:31 -0600 Subject: [PATCH 3/4] Add a comment about why multi-assets are allowed in collateral --- .../impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs b/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs index b69a054ef3c..e2b755e6c08 100644 --- a/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs +++ b/eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs @@ -261,12 +261,15 @@ validateTotalCollateral pp txBody utxoCollateral = bal = collAdaBalance txBody utxoCollateral fromAlonzoValidation = first (fmap injectFailure) --- | This validation produces the same failure as in Alonzo, but is slightly --- different then the corresponding one in Alonzo, since it is possible to add --- non-ada collateral, but only if the same amount of the same multi-asset is --- present in the collateral return output. +-- | This validation produces the same failure as in Alonzo, but is slightly different +-- then the corresponding one in Alonzo, due to addition of the collateral return output: -- --- > isAdaOnly balance +-- 1. Collateral amount can be specified exactly, thus protecting user against unnecessary +-- loss. +-- +-- 2. Collateral inputs can contain multi-assets, as long all of them are returned to the +-- `collateralReturnTxBodyL`. This design decision was also intentional, in order to +-- simplify utxo selection for collateral. validateCollateralContainsNonADA :: forall era. BabbageEraTxBody era => From c5297e082854a0c1b02a81cd1b4333c4fd239f9f Mon Sep 17 00:00:00 2001 From: Alexey Kuleshevich Date: Tue, 15 Oct 2024 15:57:08 -0600 Subject: [PATCH 4/4] Remove redundant use of `<>` `returnProposalDeposits` is never called with duplicate proposals, if it was we would have been in trouble, because then deposit would be returned into the treasury multiple times, which would be equivalent to minting ADA. Considering that this case is impossible anyways it makes more sense to use more efficient and safer `insert` instead of `insertWith (<>)` --- eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs index af9c2269763..2e41218ccf1 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Epoch.hs @@ -217,7 +217,7 @@ returnProposalDeposits removedProposals oldUMap = (RewDepUView um) , unclaimed ) - | otherwise = (um, Map.insertWith (<>) (gasId gas) (gasDeposit gas) unclaimed) + | otherwise = (um, Map.insert (gasId gas) (gasDeposit gas) unclaimed) addReward c rd = -- Deposits have been validated at this point rd {rdReward = rdReward rd <> compactCoinOrError c}