Skip to content

Commit

Permalink
Merge pull request #4576 from IntersectMBO/lehins/remove-max-min-pv-f…
Browse files Browse the repository at this point in the history
…rom-constants

Remove `minMajorPV` and `maxMajorPV` from `Constants`
  • Loading branch information
lehins authored Aug 28, 2024
2 parents 012647a + 3930ced commit 129e15a
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 43 deletions.
4 changes: 2 additions & 2 deletions eras/allegra/impl/cardano-ledger-allegra.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-allegra
version: 1.6.0.0
version: 1.6.0.1
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -68,7 +68,7 @@ library
cardano-crypto-class,
cardano-ledger-binary ^>=1.3,
cardano-ledger-core ^>=1.14,
cardano-ledger-shelley ^>=1.13,
cardano-ledger-shelley >=1.13 && <1.15,
cardano-strict-containers,
cardano-slotting,
cborg,
Expand Down
4 changes: 2 additions & 2 deletions eras/alonzo/impl/cardano-ledger-alonzo.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-alonzo
version: 1.10.2.0
version: 1.10.2.1
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -81,7 +81,7 @@ library
cardano-ledger-binary ^>=1.3,
cardano-ledger-core ^>=1.14,
cardano-ledger-mary ^>=1.7,
cardano-ledger-shelley ^>=1.13,
cardano-ledger-shelley >=1.13 && <1.15,
cardano-slotting,
cardano-strict-containers,
containers,
Expand Down
6 changes: 3 additions & 3 deletions eras/alonzo/test-suite/cardano-ledger-alonzo-test.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-alonzo-test
version: 1.2.1.3
version: 1.2.1.4
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -48,8 +48,8 @@ library
cardano-ledger-binary:{cardano-ledger-binary, testlib} >=1.0,
cardano-ledger-core:{cardano-ledger-core, testlib} >=1.11,
cardano-ledger-allegra >=1.2,
cardano-ledger-shelley:{cardano-ledger-shelley, testlib} >=1.6,
cardano-ledger-shelley-test >=1.2,
cardano-ledger-shelley:{cardano-ledger-shelley, testlib} >=1.14,
cardano-ledger-shelley-test >=1.4.1,
cardano-ledger-shelley-ma-test >=1.2,
cardano-ledger-mary >=1.4,
cardano-protocol-tpraos >=1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ genAlonzoPParams ::
Constants ->
Gen (PParams (AlonzoEra c))
genAlonzoPParams constants = do
let constants' = constants {minMajorPV = natVersion @5}
-- This ensures that "_d" field is not 0, and that the major protocol version
-- is large enough to not trigger plutus script failures
-- (no bultins are alllowed before major version 5).
maryPP <- Shelley.genPParams @(MaryEra c) constants'
maryPP' <- Shelley.genPParams @(MaryEra c) constants
let maryPP = maryPP' & ppProtocolVersionL .~ ProtVer (natVersion @5) 0
prices = Prices minBound minBound
coinPerWord <- CoinPerWord . Coin <$> choose (1, 5)
let prices = Prices minBound minBound
-- prices <- Prices <$> (Coin <$> choose (100, 5000)) <*> (Coin <$> choose (100, 5000))
let maxTxExUnits = ExUnits (5 * bigMem + 1) (5 * bigStep + 1)
-- maxTxExUnits <- ExUnits <$> (choose (100, 5000)) <*> (choose (100, 5000))
Expand Down
4 changes: 2 additions & 2 deletions eras/babbage/impl/cardano-ledger-babbage.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-babbage
version: 1.9.0.0
version: 1.9.0.1
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -77,7 +77,7 @@ library
cardano-ledger-binary ^>=1.3,
cardano-ledger-core ^>=1.14,
cardano-ledger-mary ^>=1.7,
cardano-ledger-shelley ^>=1.13,
cardano-ledger-shelley >=1.13 && <1.15,
cardano-strict-containers,
containers,
deepseq,
Expand Down
2 changes: 1 addition & 1 deletion eras/conway/impl/cardano-ledger-conway.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ library
cardano-ledger-babbage ^>=1.9,
cardano-ledger-core ^>=1.14,
cardano-ledger-mary ^>=1.7,
cardano-ledger-shelley ^>=1.13,
cardano-ledger-shelley >=1.13 && <1.15,
cardano-slotting,
cardano-strict-containers,
containers,
Expand Down
4 changes: 2 additions & 2 deletions eras/mary/impl/cardano-ledger-mary.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-mary
version: 1.7.0.0
version: 1.7.0.1
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -77,7 +77,7 @@ library
cardano-ledger-allegra ^>=1.6,
cardano-ledger-binary ^>=1.3,
cardano-ledger-core ^>=1.14,
cardano-ledger-shelley ^>=1.13,
cardano-ledger-shelley >=1.13 && <1.15,
containers,
deepseq,
groups,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-shelley-ma-test
version: 1.2.2.3
version: 1.2.2.4
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -49,7 +49,7 @@ library
containers,
hashable,
cardano-ledger-shelley-test >=1.1,
cardano-ledger-shelley:{cardano-ledger-shelley, testlib} >=1.12 && <1.14,
cardano-ledger-shelley:{cardano-ledger-shelley, testlib} >=1.12 && <1.15,
cardano-strict-containers,
microlens,
mtl,
Expand Down
6 changes: 5 additions & 1 deletion eras/shelley/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Version history for `cardano-ledger-shelley`

## 1.13.1.0
## 1.14.0.0

* Added `EncCBOR` instances for:
* `UtxoEnv`
* `CertEnv`

### `testlib`

* Remove `minMajorPV` and `maxMajorPV` from `Constants`

## 1.13.0.0

* Add `translateToShelleyLedgerStateFromUtxo`
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.13.1.0
version: 1.14.0.0
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module Test.Cardano.Ledger.Shelley.Constants (
)
where

import Cardano.Ledger.BaseTypes (Version, natVersion)
import Cardano.Ledger.Coin (Coin (..))
import Data.Word (Word64)

Expand Down Expand Up @@ -93,8 +92,6 @@ data Constants = Constants
, maxTreasury :: Integer
, minReserves :: Integer
, maxReserves :: Integer
, minMajorPV :: Version
, maxMajorPV :: Version
, genTxStableUtxoSize :: Int
-- ^ When generating Tx, we want the UTxO size to fluctuate around this point. If
-- it gets too small, we can't balance the fee, too large it gets too complicated.
Expand Down Expand Up @@ -146,8 +143,6 @@ defaultConstants =
, maxTreasury = 10000000
, minReserves = 1000000
, maxReserves = 10000000
, minMajorPV = natVersion @2
, maxMajorPV = maxBound
, genTxStableUtxoSize = 100
, genTxUtxoIncrement = 3
}
2 changes: 1 addition & 1 deletion eras/shelley/test-suite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Version history for `cardano-ledger-shelley-test`

## 1.4.0.4
## 1.4.1.0

*

Expand Down
4 changes: 2 additions & 2 deletions eras/shelley/test-suite/cardano-ledger-shelley-test.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: cardano-ledger-shelley-test
version: 1.4.0.3
version: 1.4.1.0
license: Apache-2.0
maintainer: operations@iohk.io
author: IOHK
Expand Down Expand Up @@ -79,7 +79,7 @@ library
cardano-ledger-binary:{cardano-ledger-binary, testlib} >=1.3,
cardano-ledger-byron,
cardano-ledger-core:{cardano-ledger-core, testlib} >=1.11 && <1.15,
cardano-ledger-shelley:{cardano-ledger-shelley, testlib} >=1.12 && <1.14,
cardano-ledger-shelley:{cardano-ledger-shelley, testlib} >=1.14,
cardano-protocol-tpraos:{cardano-protocol-tpraos, testlib} >=1.0.1,
cardano-slotting:{cardano-slotting, testlib},
cborg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ genIntervalInThousands lower upper =
unsafeBoundRational <$> genRationalInThousands lower upper

genPParams ::
forall era.
(EraPParams era, ProtVerAtMost era 4, ProtVerAtMost era 6) =>
Constants ->
Gen (PParams era)
genPParams c@Constants {maxMinFeeA, maxMinFeeB, minMajorPV, maxMajorPV} = do
genPParams c@Constants {maxMinFeeA, maxMinFeeB} = do
let lowMajorPV = eraProtVerLow @era
highMajorPV = eraProtVerHigh @era
minFeeA <- genInteger 0 (unCoin maxMinFeeA)
minFeeB <- genInteger 0 (unCoin maxMinFeeB)
(maxBBSize, maxTxSize, maxBHSize) <- szGen
Expand All @@ -115,7 +118,7 @@ genPParams c@Constants {maxMinFeeA, maxMinFeeB, minMajorPV, maxMajorPV} = do
tau <- genTau
d <- genDecentralisationParam
extraEntropy <- genExtraEntropy
protocolVersion <- genProtocolVersion minMajorPV maxMajorPV
protocolVersion <- genProtocolVersion lowMajorPV highMajorPV
minUTxOValue <- genMinUTxOValue
minPoolCost <- genMinPoolCost
pure $
Expand Down Expand Up @@ -236,7 +239,8 @@ genShelleyPParamsUpdate ::
Constants ->
PParams era ->
Gen (PParamsUpdate era)
genShelleyPParamsUpdate c@Constants {maxMinFeeA, maxMinFeeB, maxMajorPV} pp = do
genShelleyPParamsUpdate c@Constants {maxMinFeeA, maxMinFeeB} pp = do
let highMajorPV = succ (eraProtVerHigh @era)
-- TODO generate Maybe types so not all updates are full
minFeeA <- genM $ genInteger 0 (unCoin maxMinFeeA)
minFeeB <- genM $ genInteger 0 (unCoin maxMinFeeB)
Expand All @@ -253,7 +257,7 @@ genShelleyPParamsUpdate c@Constants {maxMinFeeA, maxMinFeeB, maxMajorPV} pp = do
tau <- genM genTau
d <- genM genDecentralisationParam
extraEntropy <- genM genExtraEntropy
protocolVersion <- genM $ genNextProtocolVersion pp maxMajorPV
protocolVersion <- genM $ genNextProtocolVersion pp highMajorPV
minUTxOValue <- genM genMinUTxOValue
minPoolCost <- genM genMinPoolCost
pure $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ module Test.Cardano.Ledger.Shelley.Rules.Chain (
import Cardano.Ledger.BHeaderView (BHeaderView)
import Cardano.Ledger.BaseTypes (
BlocksMade (..),
Globals (..),
Nonce (..),
ShelleyBase,
StrictMaybe (..),
Expand Down Expand Up @@ -111,15 +110,13 @@ import Cardano.Protocol.TPraos.Rules.Prtcl (
import Cardano.Protocol.TPraos.Rules.Tickn
import Cardano.Slotting.Slot (SlotNo, WithOrigin (..))
import Control.DeepSeq (NFData)
import Control.Monad.Trans.Reader (asks)
import Control.State.Transition (
Embed (..),
STS (..),
TRC (..),
TransitionRule,
failBecause,
judgmentContext,
liftSTS,
trans,
)
import Data.Default.Class (Default, def)
Expand Down Expand Up @@ -303,8 +300,7 @@ instance

chainTransition ::
forall era.
( STS (CHAIN era)
, Embed (EraRule "BBODY" era) (CHAIN era)
( Embed (EraRule "BBODY" era) (CHAIN era)
, Environment (EraRule "BBODY" era) ~ BbodyEnv era
, State (EraRule "BBODY" era) ~ ShelleyBbodyState era
, Signal (EraRule "BBODY" era) ~ Block (BHeaderView (EraCrypto era)) era
Expand Down Expand Up @@ -346,8 +342,13 @@ chainTransition =
chainChecksData = pparamsToChainChecksPParams pp
bhView = makeHeaderView bh

maxpv <- liftSTS $ asks maxMajorPV
case chainChecks maxpv chainChecksData bhView of
-- We allow one protocol version higher than the current era's maximum, because
-- that is the way we can get out of the current era into the next one. We test
-- this functionality with application of PParamsUpdate that initiate an upgrade
-- to the next era. This, of course, works properly only with HFC (Hard Fork
-- Combinator), which is implemented in consensus, but for the purpose of the
-- CHAIN test this is OK.
case chainChecks (succ (eraProtVerHigh @era)) chainChecksData bhView of
Right () -> pure ()
Left e -> failBecause (RealChainPredicateFailure e)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Test.Cardano.Ledger.Shelley.Rules.TestChain (
)

import Cardano.Ledger.Address (Addr (..))
import Cardano.Ledger.BaseTypes (natVersion)
import Cardano.Ledger.Coin
import Cardano.Ledger.Compactible (fromCompact)
import Cardano.Ledger.Core
Expand Down Expand Up @@ -54,7 +53,7 @@ import qualified Data.Map.Strict as Map
import Data.Proxy
import qualified Data.VMap as VMap
import Lens.Micro hiding (ix)
import Test.Cardano.Ledger.Shelley.Constants (defaultConstants, maxMajorPV)
import Test.Cardano.Ledger.Shelley.Constants (defaultConstants)
import Test.Cardano.Ledger.Shelley.Generator.Core (GenEnv)
import Test.Cardano.Ledger.Shelley.Generator.EraGen (EraGen (..))
import Test.Cardano.Ledger.Shelley.Generator.ShelleyEraGen ()
Expand Down Expand Up @@ -87,7 +86,7 @@ incrStakeComputationTest ::
TestTree
incrStakeComputationTest =
testProperty "incremental stake calc" $
forAllChainTrace @era longTraceLen defaultConstants {maxMajorPV = natVersion @8} $ \tr -> do
forAllChainTrace @era longTraceLen defaultConstants $ \tr -> do
let ssts = sourceSignalTargets tr

conjoin . concat $
Expand Down Expand Up @@ -152,7 +151,7 @@ incrStakeComparisonTest ::
TestTree
incrStakeComparisonTest Proxy =
testProperty "Incremental stake distribution at epoch boundaries agrees" $
forAllChainTrace traceLen (defaultConstants {maxMajorPV = natVersion @8}) $ \tr ->
forAllChainTrace traceLen defaultConstants $ \tr ->
conjoin $
map (\(SourceSignalTarget _ target _) -> checkIncrementalStake @era ((nesEs . chainNes) target)) $
filter (not . sameEpoch) (sourceSignalTargets tr)
Expand Down
2 changes: 1 addition & 1 deletion libs/cardano-ledger-api/cardano-ledger-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ library
cardano-ledger-conway >=1.13 && <1.18,
cardano-ledger-core ^>=1.14,
cardano-ledger-mary ^>=1.7,
cardano-ledger-shelley ^>=1.13,
cardano-ledger-shelley >=1.13 && <1.15,
cardano-strict-containers,
containers,
FailT,
Expand Down

0 comments on commit 129e15a

Please sign in to comment.