Skip to content

Commit c86a2ef

Browse files
committed
Remove redundant tx_out fields
1 parent fd98ed6 commit c86a2ef

File tree

16 files changed

+9
-47
lines changed

16 files changed

+9
-47
lines changed

cardano-chain-gen/test/Test/Cardano/Db/Mock/Validate.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ module Test.Cardano.Db.Mock.Validate (
4242

4343
import Cardano.Db
4444
import qualified Cardano.Db as DB
45+
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
4546
import Cardano.DbSync.Era.Shelley.Generic.Util
4647
import qualified Cardano.Ledger.Address as Ledger
4748
import Cardano.Ledger.BaseTypes
@@ -197,8 +198,8 @@ assertAddrValues ::
197198
IO ()
198199
assertAddrValues env ix expected sta = do
199200
addr <- assertRight $ resolveAddress ix sta
200-
let addrBs = Ledger.serialiseAddr addr
201-
q = queryAddressOutputs addrBs
201+
let address = Generic.renderAddress addr
202+
q = queryAddressOutputs address
202203
assertEqBackoff env q expected defaultDelays "Unexpected Balance"
203204

204205
assertRight :: Show err => Either err a -> IO a

cardano-db-sync/src/Cardano/DbSync/Era/Byron/Genesis.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module Cardano.DbSync.Era.Byron.Genesis (
1111
) where
1212

1313
import Cardano.BM.Trace (Trace, logInfo)
14-
import qualified Cardano.Binary as Binary
1514
import qualified Cardano.Chain.Common as Byron
1615
import qualified Cardano.Chain.Genesis as Byron
1716
import qualified Cardano.Chain.UTxO as Byron
@@ -209,7 +208,6 @@ insertTxOuts hasConsumed disInOut blkId (address, value) = do
209208
{ DB.txOutTxId = txId
210209
, DB.txOutIndex = 0
211210
, DB.txOutAddress = Text.decodeUtf8 $ Byron.addrToBase58 address
212-
, DB.txOutAddressRaw = Binary.serialize' address
213211
, DB.txOutAddressHasScript = False
214212
, DB.txOutPaymentCred = Nothing
215213
, DB.txOutStakeAddressId = Nothing

cardano-db-sync/src/Cardano/DbSync/Era/Byron/Insert.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ module Cardano.DbSync.Era.Byron.Insert (
1212

1313
import Cardano.BM.Trace (Trace, logDebug, logInfo)
1414
import Cardano.Binary (serialize')
15-
import qualified Cardano.Binary as Binary
16-
17-
-- Import all 'cardano-ledger' functions and data types qualified so they do not
18-
-- clash with the Cardano.Db functions and data types which are also imported
19-
-- qualified.
2015
import qualified Cardano.Chain.Block as Byron hiding (blockHash)
2116
import qualified Cardano.Chain.Common as Byron
2217
import qualified Cardano.Chain.UTxO as Byron
@@ -327,7 +322,6 @@ insertTxOut _tracer hasConsumed bootStrap txId index txout =
327322
{ DB.txOutTxId = txId
328323
, DB.txOutIndex = fromIntegral index
329324
, DB.txOutAddress = Text.decodeUtf8 $ Byron.addrToBase58 (Byron.txOutAddress txout)
330-
, DB.txOutAddressRaw = Binary.serialize' (Byron.txOutAddress txout)
331325
, DB.txOutAddressHasScript = False
332326
, DB.txOutPaymentCred = Nothing -- Byron does not have a payment credential.
333327
, DB.txOutStakeAddressId = Nothing -- Byron does not have a stake address.

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Alonzo.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,12 @@ fromAlonzoTx ioExtraPlutus mprices (blkIndex, tx) =
119119
TxOut
120120
{ txOutIndex = index
121121
, txOutAddress = txOut ^. Core.addrTxOutL
122-
, txOutAddressRaw = SBS.fromShort bs
123122
, txOutAdaValue = ada
124123
, txOutMaValue = maMap
125124
, txOutScript = Nothing
126125
, txOutDatum = getMaybeDatumHash $ strictMaybeToMaybe mDataHash
127126
}
128127
where
129-
bs = Ledger.unCompactAddr $ txOut ^. Core.compactAddrTxOutL
130128
MaryValue ada (MultiAsset maMap) = txOut ^. Core.valueTxOutL
131129
mDataHash = txOut ^. Alonzo.dataHashTxOutL
132130

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Babbage.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import Cardano.DbSync.Era.Shelley.Generic.Tx.Alonzo
1919
import Cardano.DbSync.Era.Shelley.Generic.Tx.Shelley
2020
import Cardano.DbSync.Era.Shelley.Generic.Tx.Types
2121
import Cardano.DbSync.Era.Shelley.Generic.Witness
22-
import qualified Cardano.Ledger.Address as Ledger
2322
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
2423
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo
2524
import Cardano.Ledger.Babbage.Core as Core hiding (Tx, TxOut)
@@ -31,7 +30,6 @@ import qualified Cardano.Ledger.Era as Ledger
3130
import Cardano.Ledger.Mary.Value (MaryValue (..), MultiAsset (..))
3231
import qualified Cardano.Ledger.Plutus.Data as Alonzo
3332
import Cardano.Prelude
34-
import qualified Data.ByteString.Short as SBS
3533
import qualified Data.Map.Strict as Map
3634
import Lens.Micro
3735
import Ouroboros.Consensus.Shelley.Eras (StandardBabbage, StandardCrypto)
@@ -123,14 +121,12 @@ fromTxOut index txOut =
123121
TxOut
124122
{ txOutIndex = index
125123
, txOutAddress = txOut ^. Core.addrTxOutL
126-
, txOutAddressRaw = SBS.fromShort bs
127124
, txOutAdaValue = ada
128125
, txOutMaValue = maMap
129126
, txOutScript = fromScript <$> strictMaybeToMaybe mScript
130127
, txOutDatum = fromDatum datum
131128
}
132129
where
133-
bs = Ledger.unCompactAddr $ txOut ^. Core.compactAddrTxOutL
134130
MaryValue ada (MultiAsset maMap) = txOut ^. Core.valueTxOutL
135131
datum = txOut ^. Core.datumTxOutL
136132
mScript = txOut ^. Core.referenceScriptTxOutL

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Mary.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ import Cardano.DbSync.Era.Shelley.Generic.Tx.Allegra (getInterval, getScripts)
1111
import Cardano.DbSync.Era.Shelley.Generic.Tx.Shelley
1212
import Cardano.DbSync.Era.Shelley.Generic.Tx.Types
1313
import Cardano.DbSync.Era.Shelley.Generic.Witness
14-
import qualified Cardano.Ledger.Address as Ledger
1514
import qualified Cardano.Ledger.Core as Core
1615
import Cardano.Ledger.Mary.TxBody
1716
import Cardano.Ledger.Mary.Value (MaryValue (..), MultiAsset (..))
1817
import qualified Cardano.Ledger.Shelley.Tx as ShelleyTx
1918
import Cardano.Prelude
20-
import qualified Data.ByteString.Short as SBS
2119
import Lens.Micro ((^.))
2220
import Ouroboros.Consensus.Cardano.Block (StandardMary)
2321

@@ -63,14 +61,12 @@ fromMaryTx (blkIndex, tx) =
6361
TxOut
6462
{ txOutIndex = index
6563
, txOutAddress = txOut ^. Core.addrTxOutL
66-
, txOutAddressRaw = SBS.fromShort bs
6764
, txOutAdaValue = ada
6865
, txOutMaValue = maMap
6966
, txOutScript = Nothing
7067
, txOutDatum = NoDatum -- Mary does not support plutus data
7168
}
7269
where
73-
bs = Ledger.unCompactAddr $ txOut ^. Core.compactAddrTxOutL
7470
MaryValue ada (MultiAsset maMap) = txOut ^. Core.valueTxOutL
7571

7672
(invBefore, invAfter) = getInterval txBody

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Shelley.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import Cardano.DbSync.Era.Shelley.Generic.Script (fromMultiSig)
3232
import Cardano.DbSync.Era.Shelley.Generic.Tx.Types
3333
import Cardano.DbSync.Era.Shelley.Generic.Util
3434
import Cardano.DbSync.Era.Shelley.Generic.Witness
35-
import qualified Cardano.Ledger.Address as Ledger
3635
import Cardano.Ledger.BaseTypes (TxIx (..), strictMaybeToMaybe)
3736
import Cardano.Ledger.Coin (Coin (..))
3837
import qualified Cardano.Ledger.Core as Core
@@ -45,7 +44,6 @@ import Cardano.Ledger.Shelley.TxCert
4544
import Cardano.Prelude
4645
import qualified Data.Aeson as Aeson
4746
import qualified Data.ByteString.Lazy.Char8 as LBS
48-
import qualified Data.ByteString.Short as SBS
4947
import qualified Data.Map.Strict as Map
5048
import Lens.Micro ((^.))
5149
import Ouroboros.Consensus.Cardano.Block (StandardCrypto, StandardShelley)
@@ -112,14 +110,11 @@ mkTxOut txBody = zipWith fromTxOut [0 ..] $ toList (txBody ^. Core.outputsTxBody
112110
TxOut
113111
{ txOutIndex = index
114112
, txOutAddress = txOut ^. Core.addrTxOutL
115-
, txOutAddressRaw = SBS.fromShort bs
116113
, txOutAdaValue = txOut ^. Core.valueTxOutL
117114
, txOutMaValue = mempty -- Shelley does not support multi-assets
118115
, txOutScript = Nothing
119116
, txOutDatum = NoDatum -- Shelley does not support plutus data
120117
}
121-
where
122-
bs = Ledger.unCompactAddr $ txOut ^. Core.compactAddrTxOutL
123118

124119
fromTxIn :: ShelleyTx.TxIn StandardCrypto -> TxIn
125120
fromTxIn (ShelleyTx.TxIn (ShelleyTx.TxId txid) (TxIx w64)) =

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Tx/Types.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ data TxIn = TxIn
9191
data TxOut = TxOut
9292
{ txOutIndex :: !Word64
9393
, txOutAddress :: !(Ledger.Addr StandardCrypto)
94-
, txOutAddressRaw :: !ByteString
9594
, txOutAdaValue :: !Coin
9695
, txOutMaValue :: !(Map (PolicyID StandardCrypto) (Map AssetName Integer))
9796
, txOutScript :: Maybe TxScript

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import Cardano.DbSync.Era.Shelley.Insert
2121
import Cardano.DbSync.Era.Util (liftLookupFail)
2222
import Cardano.DbSync.Error
2323
import Cardano.DbSync.Util
24-
import qualified Cardano.Ledger.Address as Ledger
2524
import qualified Cardano.Ledger.Coin as Ledger
2625
import qualified Cardano.Ledger.Core as Core
2726
import Cardano.Ledger.Credential (Credential (KeyHashObj))
@@ -247,7 +246,6 @@ insertTxOuts trce hasConsumed disInOut blkId (ShelleyTx.TxIn txInId _, txOut) =
247246
{ DB.txOutTxId = txId
248247
, DB.txOutIndex = 0
249248
, DB.txOutAddress = Generic.renderAddress addr
250-
, DB.txOutAddressRaw = Ledger.serialiseAddr addr
251249
, DB.txOutAddressHasScript = hasScript
252250
, DB.txOutPaymentCred = Generic.maybePaymentCred addr
253251
, DB.txOutStakeAddressId = Nothing -- No stake addresses in Shelley Genesis
@@ -258,7 +256,6 @@ insertTxOuts trce hasConsumed disInOut blkId (ShelleyTx.TxIn txInId _, txOut) =
258256
}
259257
where
260258
addr = txOut ^. Core.addrTxOutL
261-
262259
hasScript = maybe False Generic.hasCredScript (Generic.getPaymentCred addr)
263260

264261
-- Insert pools and delegations coming from Genesis.

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ prepareTxOut ::
395395
(DB.TxId, ByteString) ->
396396
Generic.TxOut ->
397397
ExceptT SyncNodeError (ReaderT SqlBackend m) (ExtendedTxOut, [MissingMaTxOut])
398-
prepareTxOut tracer cache iopts (txId, txHash) (Generic.TxOut index addr addrRaw value maMap mScript dt) = do
398+
prepareTxOut tracer cache iopts (txId, txHash) (Generic.TxOut index addr value maMap mScript dt) = do
399399
mSaId <- lift $ insertStakeAddressRefIfMissing tracer cache addr
400400
mDatumId <-
401401
whenFalseEmpty (ioPlutusExtra iopts) Nothing $
@@ -410,7 +410,6 @@ prepareTxOut tracer cache iopts (txId, txHash) (Generic.TxOut index addr addrRaw
410410
{ DB.txOutTxId = txId
411411
, DB.txOutIndex = index
412412
, DB.txOutAddress = Generic.renderAddress addr
413-
, DB.txOutAddressRaw = addrRaw
414413
, DB.txOutAddressHasScript = hasScript
415414
, DB.txOutPaymentCred = Generic.maybePaymentCred addr
416415
, DB.txOutStakeAddressId = mSaId
@@ -434,7 +433,7 @@ insertCollateralTxOut ::
434433
(DB.TxId, ByteString) ->
435434
Generic.TxOut ->
436435
ExceptT SyncNodeError (ReaderT SqlBackend m) ()
437-
insertCollateralTxOut tracer cache iopts (txId, _txHash) (Generic.TxOut index addr addrRaw value maMap mScript dt) = do
436+
insertCollateralTxOut tracer cache iopts (txId, _txHash) (Generic.TxOut index addr value maMap mScript dt) = do
438437
mSaId <- lift $ insertStakeAddressRefIfMissing tracer cache addr
439438
mDatumId <-
440439
whenFalseEmpty (ioPlutusExtra iopts) Nothing $
@@ -451,7 +450,6 @@ insertCollateralTxOut tracer cache iopts (txId, _txHash) (Generic.TxOut index ad
451450
{ DB.collateralTxOutTxId = txId
452451
, DB.collateralTxOutIndex = index
453452
, DB.collateralTxOutAddress = Generic.renderAddress addr
454-
, DB.collateralTxOutAddressRaw = addrRaw
455453
, DB.collateralTxOutAddressHasScript = hasScript
456454
, DB.collateralTxOutPaymentCred = Generic.maybePaymentCred addr
457455
, DB.collateralTxOutStakeAddressId = mSaId

0 commit comments

Comments
 (0)