@@ -26,18 +26,20 @@ module Cardano.Ledger.Conway.Rules.Utxo (
2626import Cardano.Ledger.Allegra.Rules (AllegraUtxoPredFailure , shelleyToAllegraUtxoPredFailure )
2727import qualified Cardano.Ledger.Allegra.Rules as Allegra (AllegraUtxoPredFailure (.. ))
2828import Cardano.Ledger.Alonzo.Rules (
29- AlonzoUtxoEvent ,
29+ AlonzoUtxoEvent ( .. ) ,
3030 AlonzoUtxoPredFailure ,
3131 AlonzoUtxosPredFailure ,
3232 )
3333import qualified Cardano.Ledger.Alonzo.Rules as Alonzo (
34- AlonzoUtxoEvent (UtxosEvent ),
3534 AlonzoUtxoPredFailure (.. ),
3635 )
37- import Cardano.Ledger.Babbage.Rules (BabbageUtxoPredFailure )
36+ import Cardano.Ledger.Babbage.Rules (
37+ BabbageUtxoPredFailure ,
38+ babbageUtxoValidation ,
39+ updateUTxOStateByTxValidity ,
40+ )
3841import qualified Cardano.Ledger.Babbage.Rules as Babbage (
3942 BabbageUtxoPredFailure (.. ),
40- utxoTransition ,
4143 )
4244import Cardano.Ledger.BaseTypes (
4345 Mismatch (.. ),
@@ -65,13 +67,16 @@ import Cardano.Ledger.Conway.Rules.Utxos (
6567 ConwayUtxosPredFailure (.. ),
6668 )
6769import Cardano.Ledger.Plutus (ExUnits )
68- import qualified Cardano.Ledger.Shelley.LedgerState as Shelley (UTxOState )
69- import Cardano.Ledger.Shelley.Rules (ShelleyUtxoPredFailure , UtxoEnv (.. ))
70- import qualified Cardano.Ledger.Shelley.Rules as Shelley (UtxoEnv , validSizeComputationCheck )
71- import Cardano.Ledger.State (EraCertState (.. ), EraUTxO )
70+ import Cardano.Ledger.Shelley.LedgerState (UTxOState (.. ))
71+ import Cardano.Ledger.Shelley.Rules (
72+ ShelleyUtxoPredFailure ,
73+ UtxoEnv (.. ),
74+ validSizeComputationCheck ,
75+ )
76+ import Cardano.Ledger.State (EraCertState (.. ), EraStake , EraUTxO )
7277import Cardano.Ledger.TxIn (TxIn )
7378import Control.DeepSeq (NFData )
74- import Control.State.Transition.Extended ( Embed ( .. ), STS ( .. ))
79+ import Control.State.Transition.Extended
7580import Data.List.NonEmpty (NonEmpty )
7681import Data.Map.NonEmpty (NonEmptyMap )
7782import Data.Set.NonEmpty (NonEmptySet )
@@ -174,7 +179,7 @@ instance InjectRuleFailure "UTXO" ShelleyUtxoPredFailure ConwayEra where
174179 allegraToConwayUtxoPredFailure
175180 . shelleyToAllegraUtxoPredFailure
176181
177- instance InjectRuleFailure " UTXO" Allegra. AllegraUtxoPredFailure ConwayEra where
182+ instance InjectRuleFailure " UTXO" AllegraUtxoPredFailure ConwayEra where
178183 injectFailure = allegraToConwayUtxoPredFailure
179184
180185instance InjectRuleFailure " UTXO" AlonzoUtxosPredFailure ConwayEra where
@@ -216,6 +221,36 @@ instance
216221 ) =>
217222 NFData (ConwayUtxoPredFailure era )
218223
224+ conwayUtxoTransition ::
225+ forall era .
226+ ( EraUTxO era
227+ , EraCertState era
228+ , BabbageEraTxBody era
229+ , AlonzoEraTx era
230+ , EraStake era
231+ , InjectRuleFailure " UTXO" ShelleyUtxoPredFailure era
232+ , InjectRuleFailure " UTXO" AllegraUtxoPredFailure era
233+ , InjectRuleFailure " UTXO" AlonzoUtxoPredFailure era
234+ , InjectRuleFailure " UTXO" BabbageUtxoPredFailure era
235+ , Environment (EraRule " UTXO" era ) ~ UtxoEnv era
236+ , State (EraRule " UTXO" era ) ~ UTxOState era
237+ , Signal (EraRule " UTXO" era ) ~ Tx TopTx era
238+ , BaseM (EraRule " UTXO" era ) ~ ShelleyBase
239+ , STS (EraRule " UTXO" era )
240+ , Event (EraRule " UTXO" era ) ~ AlonzoUtxoEvent era
241+ , -- In this function we we call the UTXOS rule, so we need some assumptions
242+ Environment (EraRule " UTXOS" era ) ~ PParams era
243+ , State (EraRule " UTXOS" era ) ~ UTxOState era
244+ , Signal (EraRule " UTXOS" era ) ~ Tx TopTx era
245+ , Embed (EraRule " UTXOS" era ) (EraRule " UTXO" era )
246+ ) =>
247+ TransitionRule (EraRule " UTXO" era )
248+ conwayUtxoTransition = do
249+ TRC (UtxoEnv _ pp certState, utxos, tx) <- judgmentContext
250+ babbageUtxoValidation
251+ updatedUtxos <- trans @ (EraRule " UTXOS" era ) $ TRC (pp, utxos, tx)
252+ updateUTxOStateByTxValidity pp certState (utxosGovState utxos) tx updatedUtxos
253+
219254--------------------------------------------------------------------------------
220255-- ConwayUTXO STS
221256--------------------------------------------------------------------------------
@@ -225,35 +260,36 @@ instance
225260 ( EraTx era
226261 , EraUTxO era
227262 , ConwayEraTxBody era
228- , AlonzoEraTxWits era
263+ , AlonzoEraTx era
264+ , EraStake era
229265 , EraRule " UTXO" era ~ ConwayUTXO era
230266 , InjectRuleFailure " UTXO" ShelleyUtxoPredFailure era
231267 , InjectRuleFailure " UTXO" AllegraUtxoPredFailure era
232268 , InjectRuleFailure " UTXO" AlonzoUtxoPredFailure era
233269 , InjectRuleFailure " UTXO" BabbageUtxoPredFailure era
234270 , InjectRuleFailure " UTXO" ConwayUtxoPredFailure era
235271 , Embed (EraRule " UTXOS" era ) (ConwayUTXO era )
236- , Environment (EraRule " UTXOS" era ) ~ Shelley. UtxoEnv era
237- , State (EraRule " UTXOS" era ) ~ Shelley. UTxOState era
272+ , Environment (EraRule " UTXOS" era ) ~ PParams era
273+ , State (EraRule " UTXOS" era ) ~ UTxOState era
238274 , Signal (EraRule " UTXOS" era ) ~ Tx TopTx era
239275 , PredicateFailure (EraRule " UTXO" era ) ~ ConwayUtxoPredFailure era
240276 , EraCertState era
241277 , SafeToHash (TxWits era )
242278 ) =>
243279 STS (ConwayUTXO era )
244280 where
245- type State (ConwayUTXO era ) = Shelley. UTxOState era
281+ type State (ConwayUTXO era ) = UTxOState era
246282 type Signal (ConwayUTXO era ) = Tx TopTx era
247- type Environment (ConwayUTXO era ) = Shelley. UtxoEnv era
283+ type Environment (ConwayUTXO era ) = UtxoEnv era
248284 type BaseM (ConwayUTXO era ) = ShelleyBase
249285 type PredicateFailure (ConwayUTXO era ) = ConwayUtxoPredFailure era
250286 type Event (ConwayUTXO era ) = AlonzoUtxoEvent era
251287
252288 initialRules = []
253289
254- transitionRules = [Babbage. utxoTransition @ era ]
290+ transitionRules = [conwayUtxoTransition ]
255291
256- assertions = [Shelley. validSizeComputationCheck]
292+ assertions = [validSizeComputationCheck]
257293
258294instance
259295 ( Era era
@@ -264,7 +300,7 @@ instance
264300 Embed (ConwayUTXOS era ) (ConwayUTXO era )
265301 where
266302 wrapFailed = UtxosFailure
267- wrapEvent = Alonzo. UtxosEvent
303+ wrapEvent = UtxosEvent
268304
269305--------------------------------------------------------------------------------
270306-- Serialisation
@@ -381,7 +417,7 @@ alonzoToConwayUtxoPredFailure = \case
381417allegraToConwayUtxoPredFailure ::
382418 forall era .
383419 EraRuleFailure " PPUP" era ~ VoidEraRule " PPUP" era =>
384- Allegra. AllegraUtxoPredFailure era ->
420+ AllegraUtxoPredFailure era ->
385421 ConwayUtxoPredFailure era
386422allegraToConwayUtxoPredFailure = \ case
387423 Allegra. BadInputsUTxO x -> BadInputsUTxO x
0 commit comments