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

BBODY refscript size check #4450

Merged
merged 8 commits into from
Jul 2, 2024
4 changes: 2 additions & 2 deletions eras/alonzo/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Version history for `cardano-ledger-alonzo`

## 1.9.0.1
## 1.10.0.0

*
* Rename `bbodyTransition` to `alonzoBbodyTransition` and change its type signature

## 1.9.0.0

Expand Down
2 changes: 1 addition & 1 deletion 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.9.0.0
version: 1.10.0.0
license: Apache-2.0
maintainer: [email protected]
author: IOHK
Expand Down
44 changes: 25 additions & 19 deletions eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Bbody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Cardano.Ledger.Alonzo.Rules.Bbody (
AlonzoBBODY,
AlonzoBbodyPredFailure (..),
AlonzoBbodyEvent (..),
bbodyTransition,
alonzoBbodyTransition,
) where

import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure)
Expand Down Expand Up @@ -70,7 +70,6 @@ import Control.State.Transition (
trans,
(?!),
)
import Data.Kind (Type)
import Data.Sequence (Seq)
import qualified Data.Sequence.Strict as StrictSeq
import Data.Typeable
Expand Down Expand Up @@ -175,15 +174,15 @@ instance
-- ========================================
-- The STS instance

bbodyTransition ::
forall (someBBODY :: Type -> Type) era.
( STS (someBBODY era)
, Signal (someBBODY era) ~ Block (BHeaderView (EraCrypto era)) era
, PredicateFailure (someBBODY era) ~ AlonzoBbodyPredFailure era
, BaseM (someBBODY era) ~ ShelleyBase
, State (someBBODY era) ~ ShelleyBbodyState era
, Environment (someBBODY era) ~ BbodyEnv era
, Embed (EraRule "LEDGERS" era) (someBBODY era)
alonzoBbodyTransition ::
forall era.
( STS (EraRule "BBODY" era)
, Signal (EraRule "BBODY" era) ~ Block (BHeaderView (EraCrypto era)) era
, InjectRuleFailure "BBODY" AlonzoBbodyPredFailure era
, BaseM (EraRule "BBODY" era) ~ ShelleyBase
, State (EraRule "BBODY" era) ~ ShelleyBbodyState era
, Environment (EraRule "BBODY" era) ~ BbodyEnv era
, Embed (EraRule "LEDGERS" era) (EraRule "BBODY" era)
, Environment (EraRule "LEDGERS" era) ~ ShelleyLedgersEnv era
, State (EraRule "LEDGERS" era) ~ LedgerState era
, Signal (EraRule "LEDGERS" era) ~ Seq (Tx era)
Expand All @@ -193,8 +192,8 @@ bbodyTransition ::
, Tx era ~ AlonzoTx era
, AlonzoEraPParams era
) =>
TransitionRule (someBBODY era)
bbodyTransition =
TransitionRule (EraRule "BBODY" era)
alonzoBbodyTransition =
judgmentContext
>>= \( TRC
( BbodyEnv pp account
Expand All @@ -208,14 +207,18 @@ bbodyTransition =

actualBodySize
== fromIntegral (bhviewBSize bh)
?! ShelleyInAlonzoBbodyPredFailure
( WrongBlockBodySizeBBODY actualBodySize (fromIntegral $ bhviewBSize bh)
?! injectFailure
( ShelleyInAlonzoBbodyPredFailure
( WrongBlockBodySizeBBODY actualBodySize (fromIntegral $ bhviewBSize bh)
)
)

actualBodyHash
== bhviewBHash bh
?! ShelleyInAlonzoBbodyPredFailure
( InvalidBodyHashBBODY @era actualBodyHash (bhviewBHash bh)
?! injectFailure
( ShelleyInAlonzoBbodyPredFailure
( InvalidBodyHashBBODY @era actualBodyHash (bhviewBHash bh)
)
)

ls' <-
Expand All @@ -241,7 +244,8 @@ bbodyTransition =
let txTotal, ppMax :: ExUnits
txTotal = foldMap totExUnits txs
ppMax = pp ^. ppMaxBlockExUnitsL
pointWiseExUnits (<=) txTotal ppMax ?! TooManyExUnits txTotal ppMax
pointWiseExUnits (<=) txTotal ppMax
?! injectFailure (TooManyExUnits txTotal ppMax)

pure $
BbodyState @era
Expand All @@ -254,6 +258,8 @@ bbodyTransition =

instance
( DSignable (EraCrypto era) (Hash (EraCrypto era) EraIndependentTxBody)
, EraRule "BBODY" era ~ AlonzoBBODY era
, InjectRuleFailure "BBODY" AlonzoBbodyPredFailure era
, Embed (EraRule "LEDGERS" era) (AlonzoBBODY era)
, Environment (EraRule "LEDGERS" era) ~ ShelleyLedgersEnv era
, State (EraRule "LEDGERS" era) ~ LedgerState era
Expand Down Expand Up @@ -283,7 +289,7 @@ instance
type Event (AlonzoBBODY era) = AlonzoBbodyEvent era

initialRules = []
transitionRules = [bbodyTransition @AlonzoBBODY]
transitionRules = [alonzoBbodyTransition @era]

instance
( Era era
Expand Down
2 changes: 1 addition & 1 deletion eras/babbage/impl/cardano-ledger-babbage.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ library
cardano-crypto-class,
cardano-data >=1.2,
cardano-ledger-allegra ^>=1.5,
cardano-ledger-alonzo ^>=1.9,
cardano-ledger-alonzo >=1.9 && <1.11,
cardano-ledger-binary ^>=1.3,
cardano-ledger-core ^>=1.13,
cardano-ledger-mary ^>=1.6,
Expand Down
2 changes: 2 additions & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.16.0.0

* Add `maxRefScriptSizePerBlock` and `maxRefScriptSizePerTx` to `Cardano.Ledger.Conway.Rules`
* Add `ConwayBBODY` and `ConwayBbodyPredFailure` type for BBody rule
* Added `ConwayCommitteeIsUnknown` predicate failure to `ConwayGovCertPredFailure`
* Added `ceCurrentCommittee` and `ceCommitteeProposals` to `CertEnv`
* Added `certsCurrentCommittee` and `certsCommitteeProposals` to `CertsEnv`
Expand Down
3 changes: 2 additions & 1 deletion eras/conway/impl/cardano-ledger-conway.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ library
cardano-data >=1.2.1,
cardano-ledger-binary >=1.3.2,
cardano-ledger-allegra ^>=1.5,
cardano-ledger-alonzo ^>=1.9,
cardano-ledger-alonzo ^>=1.10,
cardano-ledger-babbage ^>=1.8,
cardano-ledger-core ^>=1.13.2,
cardano-ledger-mary ^>=1.6,
Expand Down Expand Up @@ -117,6 +117,7 @@ library testlib
Test.Cardano.Ledger.Conway.Binary.Regression
Test.Cardano.Ledger.Conway.ImpTest
Test.Cardano.Ledger.Conway.Imp
Test.Cardano.Ledger.Conway.Imp.BbodySpec
Test.Cardano.Ledger.Conway.Imp.EpochSpec
Test.Cardano.Ledger.Conway.Imp.EnactSpec
Test.Cardano.Ledger.Conway.Imp.GovSpec
Expand Down
6 changes: 3 additions & 3 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Era.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

module Cardano.Ledger.Conway.Era (
ConwayEra,
ConwayBBODY,
ConwayCERT,
ConwayDELEG,
ConwayGOVCERT,
Expand All @@ -19,7 +20,6 @@ module Cardano.Ledger.Conway.Era (
ConwayRATIFY,
) where

import Cardano.Ledger.Alonzo.Rules (AlonzoBBODY)
import Cardano.Ledger.Babbage (BabbageEra)
import Cardano.Ledger.Core
import Cardano.Ledger.Crypto (Crypto)
Expand Down Expand Up @@ -131,9 +131,9 @@ data ConwayUTXO era

type instance EraRule "UTXO" (ConwayEra c) = ConwayUTXO (ConwayEra c)

-- Rules inherited from Alonzo
data ConwayBBODY era

type instance EraRule "BBODY" (ConwayEra c) = AlonzoBBODY (ConwayEra c)
type instance EraRule "BBODY" (ConwayEra c) = ConwayBBODY (ConwayEra c)

-- Rules inherited from Shelley

Expand Down
3 changes: 2 additions & 1 deletion eras/conway/impl/src/Cardano/Ledger/Conway/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# OPTIONS_GHC -Wno-orphans #-}

module Cardano.Ledger.Conway.Rules (
module Cardano.Ledger.Conway.Rules.Bbody,
module Cardano.Ledger.Conway.Rules.Cert,
module Cardano.Ledger.Conway.Rules.Deleg,
module Cardano.Ledger.Conway.Rules.GovCert,
Expand All @@ -23,7 +24,7 @@ where

import Cardano.Ledger.Conway.Core (EraRuleEvent, InjectRuleEvent (..))
import Cardano.Ledger.Conway.Era (ConwayEra)
import Cardano.Ledger.Conway.Rules.Bbody ()
import Cardano.Ledger.Conway.Rules.Bbody
import Cardano.Ledger.Conway.Rules.Cert
import Cardano.Ledger.Conway.Rules.Certs
import Cardano.Ledger.Conway.Rules.Deleg
Expand Down
Loading