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

Check ppuCoinsPerUTxOBytes well-formedness #4650

Merged
merged 1 commit into from
Sep 30, 2024
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
1 change: 1 addition & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.17.0.0

* Added protocol version argument to `ppuWellFormed`
* Add `ConwayMempoolEvent` type
* Add `MempoolEvent` to `ConwayLedgerEvent`
* Add `Mempool` module, `ConwayMEMPOOL` and `ConwayMempoolPredFailure`
Expand Down
7 changes: 5 additions & 2 deletions eras/conway/impl/src/Cardano/Ledger/Conway/PParams.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ import Cardano.Ledger.Plutus.CostModels (
mkCostModels,
)
import Cardano.Ledger.Plutus.Language (Language (PlutusV3))
import Cardano.Ledger.Shelley.HardForks (bootstrapPhase)
import Cardano.Ledger.Val (Val (..))
import Control.DeepSeq (NFData (..), rwhnf)
import Data.Aeson hiding (Encoding, Value, decode, encode)
Expand All @@ -140,7 +141,7 @@ import Numeric.Natural (Natural)

class BabbageEraPParams era => ConwayEraPParams era where
modifiedPPGroups :: PParamsUpdate era -> Set PPGroups
ppuWellFormed :: PParamsUpdate era -> Bool
ppuWellFormed :: ProtVer -> PParamsUpdate era -> Bool

hkdPoolVotingThresholdsL :: HKDFunctor f => Lens' (PParamsHKD f era) (HKD f PoolVotingThresholds)
hkdDRepVotingThresholdsL :: HKDFunctor f => Lens' (PParamsHKD f era) (HKD f DRepVotingThresholds)
Expand Down Expand Up @@ -750,7 +751,7 @@ instance Crypto c => BabbageEraPParams (ConwayEra c) where

instance Crypto c => ConwayEraPParams (ConwayEra c) where
modifiedPPGroups (PParamsUpdate ppu) = conwayModifiedPPGroups ppu
ppuWellFormed ppu =
ppuWellFormed pv ppu =
and
[ -- Numbers
isValid (/= 0) ppuMaxBBSizeL
Expand All @@ -764,6 +765,8 @@ instance Crypto c => ConwayEraPParams (ConwayEra c) where
isValid (/= zero) ppuPoolDepositL
, isValid (/= zero) ppuGovActionDepositL
, isValid (/= zero) ppuDRepDepositL
, bootstrapPhase pv
|| isValid ((/= zero) . unCoinPerByte) ppuCoinsPerUTxOByteL
, ppu /= emptyPParamsUpdate
]
where
Expand Down
9 changes: 5 additions & 4 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Rules/Gov.hs
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,12 @@ checkBootstrapVotes pp votes
_ -> isBootstrapAction $ gasAction gas
| otherwise = pure ()

actionWellFormed :: ConwayEraPParams era => GovAction era -> Test (ConwayGovPredFailure era)
actionWellFormed ga = failureUnless isWellFormed $ MalformedProposal ga
actionWellFormed ::
ConwayEraPParams era => ProtVer -> GovAction era -> Test (ConwayGovPredFailure era)
actionWellFormed pv ga = failureUnless isWellFormed $ MalformedProposal ga
where
isWellFormed = case ga of
ParameterChange _ ppd _ -> ppuWellFormed ppd
ParameterChange _ ppd _ -> ppuWellFormed pv ppd
_ -> True

mkGovActionState ::
Expand Down Expand Up @@ -443,7 +444,7 @@ govTransition = do
failOnJust badHardFork id

-- PParamsUpdate well-formedness check
runTest $ actionWellFormed pProcGovAction
runTest $ actionWellFormed (pp ^. ppProtocolVersionL) pProcGovAction

-- Deposit check
let expectedDep = pp ^. ppGovActionDepositL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ wfPParamsUpdateSpec =
collateralPercentage
_MaxCollateralInputs
-- Babbage
_coinsPerUTxOByte
coinsPerUTxOByte
-- Conway
_poolVotingThresholds
_drepVotingThresholds
Expand All @@ -501,5 +501,6 @@ wfPParamsUpdateSpec =
, govActionDeposit /=. lit (SJust mempty)
, dRepDeposit /=. lit (SJust mempty)
, costModels ==. lit (SNothing) -- NOTE: this is because the cost
, coinsPerUTxOByte /=. lit (SJust mempty)
-- model generator is way too slow
]