Skip to content

Commit

Permalink
Adjust Deposits event
Browse files Browse the repository at this point in the history
The tx hash is used to associate the event with the tx since the events within
a block can appear out of order. The adjustment from deposits to deposits
change is useful for db-sync.
  • Loading branch information
kderme committed Dec 13, 2022
1 parent c06776a commit 04ffbb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions docs/LedgerEvents.md
Expand Up @@ -94,11 +94,12 @@ It is related to the other rewards events by the property:
RupdEvent - RestrainedRewards = Total
```

### `TotalDeposits totalDeposits`
### `TotalDeposits txHash depositChange`

This event happens for every transaction, it contains the sum of all the deposits
paid by the given transaction (both stake credential registration deposits and
stake pool registration deposits).
stake pool registration deposits) minus the sum of all refunds. It also contains
the transaction hash.

### `RegisterPool poolID`
This event happens for every new stake pool registration certificate.
Expand Down
5 changes: 3 additions & 2 deletions eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Utxo.hs
Expand Up @@ -58,6 +58,7 @@ import Cardano.Ledger.Core
import qualified Cardano.Ledger.Crypto as CC
import Cardano.Ledger.Keys (GenDelegs)
import Cardano.Ledger.Rules.ValidationMode (Inject (..), Test, runTest)
import Cardano.Ledger.SafeHash (SafeHash, hashAnnotated)
import Cardano.Ledger.Shelley.AdaPots (consumedTxBody, producedTxBody)
import Cardano.Ledger.Shelley.Era (ShelleyEra, ShelleyUTXO)
import Cardano.Ledger.Shelley.LedgerState (DPState (..), keyTxRefunds, totalTxDeposits)
Expand Down Expand Up @@ -136,7 +137,7 @@ data UtxoEnv era
deriving instance Show (PParams era) => Show (UtxoEnv era)

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

data ShelleyUtxoPredFailure era
Expand Down Expand Up @@ -427,8 +428,8 @@ utxoInductive = do

let refunded = keyTxRefunds pp dpstate txb
let totalDeposits' = totalTxDeposits pp dpstate txb
tellEvent $ TotalDeposits totalDeposits'
let depositChange = totalDeposits' Val.<-> refunded
tellEvent $ TotalDeposits (hashAnnotated txb) depositChange
pure $! updateUTxOState u txb depositChange ppup'

-- | The ttl field marks the top of an open interval, so it must be strictly
Expand Down

0 comments on commit 04ffbb8

Please sign in to comment.