Skip to content

Commit a6f276a

Browse files
authored
Merge pull request #4890 from IntersectMBO/lehins/invert-mempool
Invert mempool
2 parents 185a428 + c46c716 commit a6f276a

File tree

40 files changed

+193
-326
lines changed

40 files changed

+193
-326
lines changed

eras/allegra/impl/src/Cardano/Ledger/Allegra.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE FlexibleInstances #-}
33
{-# LANGUAGE ScopedTypeVariables #-}
4+
{-# LANGUAGE TypeApplications #-}
45
{-# LANGUAGE UndecidableInstances #-}
56
{-# OPTIONS_GHC -Wno-orphans #-}
67

@@ -19,7 +20,7 @@ import Cardano.Ledger.Allegra.Translation ()
1920
import Cardano.Ledger.Allegra.Tx ()
2021
import Cardano.Ledger.Allegra.TxSeq ()
2122
import Cardano.Ledger.Allegra.UTxO ()
22-
import Cardano.Ledger.Shelley.API (ApplyBlock, ApplyTx)
23+
import Cardano.Ledger.Shelley.API
2324

2425
type Allegra = AllegraEra
2526

@@ -29,6 +30,7 @@ type Allegra = AllegraEra
2930
-- Mempool instances
3031
--------------------------------------------------------------------------------
3132

32-
instance ApplyTx AllegraEra
33+
instance ApplyTx AllegraEra where
34+
applyTxValidation = ruleApplyTxValidation @"LEDGER"
3335

3436
instance ApplyBlock AllegraEra

eras/alonzo/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.13.0.0
44

5+
* Remove `reapplyAlonzoTx` as no longer needed.
56
* Add `TxInfoResult` data family, `mkTxInfoResult` and `lookupTxInfoResult` to `EraPlutusContext`
67
* Add `lookupTxInfoResultImpossible` helper
78
* Add `TxInfoResult era` parameter to `toPlutusWithContext` and `mkPlutusWithContext`

eras/alonzo/impl/cardano-ledger-alonzo.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ library
9191
deepseq,
9292
mempack,
9393
microlens,
94-
mtl,
9594
nothunks,
9695
plutus-ledger-api >=1.37,
9796
set-algebra >=1.0,

eras/alonzo/impl/src/Cardano/Ledger/Alonzo.hs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Cardano.Ledger.Alonzo (
1414
AlonzoTxBody,
1515
AlonzoScript,
1616
AlonzoTxAuxData,
17-
reapplyAlonzoTx,
1817
)
1918
where
2019

@@ -30,39 +29,17 @@ import Cardano.Ledger.Alonzo.TxAuxData (AlonzoTxAuxData)
3029
import Cardano.Ledger.Alonzo.TxBody (AlonzoTxBody, AlonzoTxOut)
3130
import Cardano.Ledger.Alonzo.TxWits ()
3231
import Cardano.Ledger.Alonzo.UTxO ()
33-
import Cardano.Ledger.Core
3432
import Cardano.Ledger.Mary.Value (MaryValue)
3533
import Cardano.Ledger.Plutus.Data ()
36-
import Cardano.Ledger.Rules.ValidationMode (applySTSNonStatic)
3734
import Cardano.Ledger.Shelley.API
38-
import Control.Arrow (left)
39-
import Control.Monad.Except (MonadError, liftEither)
40-
import Control.Monad.Reader (runReader)
41-
import Control.State.Transition.Extended (TRC (TRC))
4235

4336
type Alonzo = AlonzoEra
4437

4538
{-# DEPRECATED Alonzo "In favor of `AlonzoEra`" #-}
4639

4740
-- =====================================================
4841

49-
reapplyAlonzoTx ::
50-
forall era m.
51-
(ApplyTx era, MonadError (ApplyTxError era) m) =>
52-
Globals ->
53-
MempoolEnv era ->
54-
MempoolState era ->
55-
Validated (Tx era) ->
56-
m (MempoolState era)
57-
reapplyAlonzoTx globals env state vtx =
58-
let res =
59-
flip runReader globals
60-
. applySTSNonStatic
61-
@(EraRule "LEDGER" era)
62-
$ TRC (env, state, extractTx vtx)
63-
in liftEither . left ApplyTxError $ res
64-
6542
instance ApplyTx AlonzoEra where
66-
reapplyTx = reapplyAlonzoTx
43+
applyTxValidation = ruleApplyTxValidation @"LEDGER"
6744

6845
instance ApplyBlock AlonzoEra

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Ledger.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ ledgerTransition ::
127127
) =>
128128
TransitionRule (someLEDGER era)
129129
ledgerTransition = do
130-
TRC (LedgerEnv slot mbCurEpochNo txIx pp account _, LedgerState utxoSt certState, tx) <-
130+
TRC (LedgerEnv slot mbCurEpochNo txIx pp account, LedgerState utxoSt certState, tx) <-
131131
judgmentContext
132132
let txBody = tx ^. bodyTxL
133133

eras/alonzo/test-suite/src/Test/Cardano/Ledger/Alonzo/Trace.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ instance
7171
LedgerEnv (SlotNo 0) Nothing minBound
7272
<$> genEraPParams @era geConstants
7373
<*> genAccountState geConstants
74-
<*> pure False
7574

7675
sigGen genenv env state = genTx genenv env state
7776

eras/babbage/impl/src/Cardano/Ledger/Babbage.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE FlexibleInstances #-}
33
{-# LANGUAGE ScopedTypeVariables #-}
4+
{-# LANGUAGE TypeApplications #-}
45
{-# LANGUAGE UndecidableInstances #-}
56
{-# OPTIONS_GHC -Wno-orphans #-}
67

@@ -14,7 +15,6 @@ module Cardano.Ledger.Babbage (
1415
)
1516
where
1617

17-
import Cardano.Ledger.Alonzo (reapplyAlonzoTx)
1818
import Cardano.Ledger.Alonzo.Scripts (AlonzoScript (..))
1919
import Cardano.Ledger.Alonzo.TxAuxData (AlonzoTxAuxData (..))
2020
import Cardano.Ledger.Babbage.Era (BabbageEra)
@@ -33,6 +33,6 @@ type Babbage = BabbageEra
3333
-- =====================================================
3434

3535
instance ApplyTx BabbageEra where
36-
reapplyTx = reapplyAlonzoTx
36+
applyTxValidation = ruleApplyTxValidation @"LEDGER"
3737

3838
instance ApplyBlock BabbageEra

eras/conway/impl/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 1.19.0.0
44

5+
* Remove `ConwayMempoolPredFailure` and `ConwayMempoolEvent`
6+
* Switch to `MEMPOOL` rule to be the entry point for `ApplyTx` instead of `LEDGER` and invert their
7+
ivocation.
58
* Added `ToCBOR` and `FromCBOR` instances for `DefaultVote`.
69
* Made the fields of predicate failures and environments lazy
710
* Add `MemPack` instance for `PlutusScript ConwayEra`

eras/conway/impl/cardano-ledger-conway.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ library testlib
180180
plutus-ledger-api,
181181
prettyprinter,
182182
small-steps >=1.1,
183+
text,
183184

184185
executable huddle-cddl
185186
main-is: Main.hs

eras/conway/impl/src/Cardano/Ledger/Conway.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{-# LANGUAGE DataKinds #-}
22
{-# LANGUAGE FlexibleInstances #-}
33
{-# LANGUAGE ScopedTypeVariables #-}
4+
{-# LANGUAGE TypeApplications #-}
45
{-# LANGUAGE UndecidableInstances #-}
56
{-# OPTIONS_GHC -Wno-orphans #-}
67

@@ -10,7 +11,6 @@ module Cardano.Ledger.Conway (
1011
)
1112
where
1213

13-
import Cardano.Ledger.Alonzo (reapplyAlonzoTx)
1414
import Cardano.Ledger.Babbage.TxBody ()
1515
import Cardano.Ledger.Conway.Era (ConwayEra)
1616
import Cardano.Ledger.Conway.Governance (RunConwayRatify (..))
@@ -30,7 +30,7 @@ type Conway = ConwayEra
3030
-- =====================================================
3131

3232
instance ApplyTx ConwayEra where
33-
reapplyTx = reapplyAlonzoTx
33+
applyTxValidation = ruleApplyTxValidation @"MEMPOOL"
3434

3535
instance ApplyBlock ConwayEra
3636

0 commit comments

Comments
 (0)