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

Create TotalDeposits events during all eras #3404

Merged
merged 2 commits into from
May 18, 2023
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/allegra/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Introduction of `TxCert` and `EraTxCert`
* Add `EraTxCert` and `ShelleyEraTxCert` instances to `AllegraEra`
* Fix an issue where `TotalDeposits` didn't appear on Allegra and Mary era

## 1.1.1.0

Expand Down
7 changes: 5 additions & 2 deletions eras/allegra/impl/src/Cardano/Ledger/Allegra/Rules/Utxo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

module Cardano.Ledger.Allegra.Rules.Utxo (
AllegraUTXO,
AllegraUtxoEvent (..),
AllegraUtxoPredFailure (..),
validateOutsideValidityIntervalUTxO,
)
Expand Down Expand Up @@ -50,6 +51,7 @@ import Cardano.Ledger.Rules.ValidationMode (
Test,
runTest,
)
import Cardano.Ledger.SafeHash (SafeHash, hashAnnotated)
import Cardano.Ledger.Shelley.Governance
import Cardano.Ledger.Shelley.LedgerState (PPUPPredFailure, keyTxRefunds, totalTxDeposits)
import qualified Cardano.Ledger.Shelley.LedgerState as Shelley
Expand Down Expand Up @@ -131,8 +133,9 @@ instance
) =>
NoThunks (AllegraUtxoPredFailure era)

newtype AllegraUtxoEvent era
data AllegraUtxoEvent era
= UpdateEvent (Event (EraRule "PPUP" era))
| TotalDeposits (SafeHash (EraCrypto era) EraIndependentTxBody) Coin

-- | The UTxO transition rule for the Allegra era.
utxoTransition ::
Expand Down Expand Up @@ -202,7 +205,7 @@ utxoTransition = do

let refunded = keyTxRefunds pp dpstate txb
let depositChange = totalTxDeposits pp dpstate txb Val.<-> refunded

tellEvent $ TotalDeposits (hashAnnotated txb) depositChange
pure $! Shelley.updateUTxOState pp u txb depositChange ppup'

-- | Ensure the transaction is within the validity window.
Expand Down
1 change: 1 addition & 0 deletions eras/alonzo/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Add `EraPlutusContext 'PlutusV1` instance to `AlonzoEra`
* Rename `transTxCert` to `transShelleyTxCert`
* Remove `witsVKeyNeeded`, in favor of the one from `cardano-ledger-shelley`
* Fix an issue where `TotalDeposits` didn't appear on Alonzo era

## 1.2.0.0

Expand Down
5 changes: 4 additions & 1 deletion eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ import Cardano.Ledger.BaseTypes (
)
import Cardano.Ledger.Binary (DecCBOR (..), EncCBOR (..), serialize')
import Cardano.Ledger.Binary.Coders
import Cardano.Ledger.Coin (Coin)
import Cardano.Ledger.Core
import Cardano.Ledger.Rules.ValidationMode (Inject (..), lblStatic)
import Cardano.Ledger.SafeHash (SafeHash, hashAnnotated)
import Cardano.Ledger.Shelley.Governance (EraGovernance (GovernanceState), ShelleyPPUPState)
import Cardano.Ledger.Shelley.LedgerState (
PPUPPredFailure,
Expand Down Expand Up @@ -142,6 +144,7 @@ instance

data AlonzoUtxosEvent era
= AlonzoPpupToUtxosEvent (Event (EraRule "PPUP" era))
| TotalDeposits (SafeHash (EraCrypto era) EraIndependentTxBody) Coin
| SuccessfulPlutusScriptsEvent (NonEmpty PlutusDebug)
| FailedPlutusScriptsEvent (NonEmpty PlutusDebug)

Expand Down Expand Up @@ -247,7 +250,7 @@ scriptsValidateTransition = do
protVer = pp ^. ppProtocolVersionL
refunded = keyTxRefunds pp dpstate txBody
depositChange = totalTxDeposits pp dpstate txBody <-> refunded

tellEvent $ TotalDeposits (hashAnnotated txBody) depositChange
() <- pure $! traceEvent validBegin ()

scriptsTransition slot pp tx utxo $ \case
Expand Down
1 change: 1 addition & 0 deletions eras/babbage/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Add `EraTxCert` and `ShelleyEraTxCert` instances to `BabbageEra`
* Add `EraPlutusContext 'PlutusV1` instance to `BabbageEra`
* Add `EraPlutusContext 'PlutusV2` instance to `BabbageEra`
* Fix an issue where `TotalDeposits` didn't appear on Babbage era

## 1.2.0.0

Expand Down
2 changes: 2 additions & 0 deletions eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxos.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import Cardano.Ledger.Babbage.Era (BabbageUTXOS)
import Cardano.Ledger.Babbage.Tx
import Cardano.Ledger.BaseTypes (ShelleyBase, epochInfo, strictMaybeToMaybe, systemStart)
import Cardano.Ledger.Binary (EncCBOR (..))
import Cardano.Ledger.SafeHash (hashAnnotated)
import Cardano.Ledger.Shelley.LedgerState (
PPUPPredFailure,
UTxOState (..),
Expand Down Expand Up @@ -168,6 +169,7 @@ scriptsYes = do
{- depositChange := (totalDeposits pp poolParams txcerts txb) − refunded -}
protVer = pp ^. ppProtocolVersionL
depositChange = totalTxDeposits pp dpstate txBody <-> refunded
tellEvent $ TotalDeposits (hashAnnotated txBody) depositChange
sysSt <- liftSTS $ asks systemStart
ei <- liftSTS $ asks epochInfo

Expand Down