Skip to content

Commit ee83a31

Browse files
committed
Experiment 3
1 parent 1aae034 commit ee83a31

File tree

50 files changed

+1120
-863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1120
-863
lines changed

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Alonzo/Config.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ insertConfig = do
3434
, sioPoolStats = PoolStatsConfig False
3535
, sioJsonType = JsonTypeDisable
3636
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
37-
, sioAddress = AddressTypeConfig False
37+
, sioTxOutTableType = TxOutTableTypeConfig False
3838
}
3939

4040
dncInsertOptions cfg @?= expected

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/Config/Parse.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ insertConfig = do
3434
, sioPoolStats = PoolStatsConfig False
3535
, sioJsonType = JsonTypeDisable
3636
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
37-
, sioAddress = AddressTypeConfig False
37+
, sioTxOutTableType = TxOutTableTypeConfig False
3838
}
3939

4040
dncInsertOptions cfg @?= expected

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/Parse.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ insertConfig = do
104104
, sioPoolStats = PoolStatsConfig False
105105
, sioJsonType = JsonTypeDisable
106106
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
107-
, sioAddress = AddressTypeConfig False
107+
, sioTxOutTableType = TxOutTableTypeConfig False
108108
}
109109

110110
dncInsertOptions cfg @?= expected

cardano-db-sync/src/Cardano/DbSync.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ extractSyncOptions snp aop snc =
278278
, ioPoolStats = isPoolStatsEnabled (sioPoolStats (dncInsertOptions snc))
279279
, ioGov = useGovernance
280280
, ioRemoveJsonbFromSchema = isRemoveJsonbFromSchemaEnabled (sioRemoveJsonbFromSchema (dncInsertOptions snc))
281-
, ioAddress = unAddressTypeConfig (sioAddress (dncInsertOptions snc))
281+
, ioAddress = unTxOutTableTypeConfig (sioTxOutTableType (dncInsertOptions snc))
282282
}
283283

284284
useLedger = sioLedger (dncInsertOptions snc) == LedgerEnable

cardano-db-sync/src/Cardano/DbSync/Api/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ data InsertOptions = InsertOptions
8787
, ioPoolStats :: !Bool
8888
, ioGov :: !Bool
8989
, ioRemoveJsonbFromSchema :: !Bool
90-
, ioAddress :: !DB.AddressType
90+
, ioAddress :: !DB.TxOutTableType
9191
}
9292
deriving (Show)
9393

cardano-db-sync/src/Cardano/DbSync/Config/Types.hs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Cardano.DbSync.Config.Types (
1919
GenesisHashAlonzo (..),
2020
GenesisHashConway (..),
2121
RemoveJsonbFromSchemaConfig (..),
22-
AddressTypeConfig (..),
22+
TxOutTableTypeConfig (..),
2323
SyncNodeConfig (..),
2424
SyncPreConfig (..),
2525
SyncInsertConfig (..),
@@ -68,7 +68,7 @@ import qualified Cardano.BM.Data.Configuration as Logging
6868
import qualified Cardano.Chain.Update as Byron
6969
import Cardano.Crypto (RequiresNetworkMagic (..))
7070
import qualified Cardano.Crypto.Hash as Crypto
71-
import Cardano.Db (MigrationDir, PGPassSource (..), AddressType(..))
71+
import Cardano.Db (MigrationDir, PGPassSource (..), TxOutTableType (..))
7272
import Cardano.Prelude
7373
import Cardano.Slotting.Slot (SlotNo (..))
7474
import Control.Monad (fail)
@@ -184,7 +184,7 @@ data SyncInsertOptions = SyncInsertOptions
184184
, sioPoolStats :: PoolStatsConfig
185185
, sioJsonType :: JsonTypeConfig
186186
, sioRemoveJsonbFromSchema :: RemoveJsonbFromSchemaConfig
187-
, sioAddress :: AddressTypeConfig
187+
, sioTxOutTableType :: TxOutTableTypeConfig
188188
}
189189
deriving (Eq, Show)
190190

@@ -259,8 +259,8 @@ newtype RemoveJsonbFromSchemaConfig = RemoveJsonbFromSchemaConfig
259259
}
260260
deriving (Eq, Show)
261261

262-
newtype AddressTypeConfig = AddressTypeConfig
263-
{ unAddressTypeConfig :: AddressType
262+
newtype TxOutTableTypeConfig = TxOutTableTypeConfig
263+
{ unTxOutTableTypeConfig :: TxOutTableType
264264
}
265265
deriving (Eq, Show)
266266

@@ -680,14 +680,14 @@ instance FromJSON RemoveJsonbFromSchemaConfig where
680680
instance ToJSON RemoveJsonbFromSchemaConfig where
681681
toJSON = boolToEnableDisable . isRemoveJsonbFromSchemaEnabled
682682

683-
instance FromJSON AddressTypeConfig where
684-
parseJSON = Aeson.withText "use_address_table" $ \v ->
685-
case enableDisableToAddressType v of
686-
Just g -> pure (AddressTypeConfig g)
687-
Nothing -> fail $ "unexpected use_address_table: " <> show v
683+
instance FromJSON TxOutTableTypeConfig where
684+
parseJSON = Aeson.withText "add_address_table_to_txout" $ \v ->
685+
case enableDisableToTxOutTableType v of
686+
Just g -> pure (TxOutTableTypeConfig g)
687+
Nothing -> fail $ "unexpected add_address_table_to_txout: " <> show v
688688

689-
instance ToJSON AddressTypeConfig where
690-
toJSON = addressTypeToEnableDisable . unAddressTypeConfig
689+
instance ToJSON TxOutTableTypeConfig where
690+
toJSON = addressTypeToEnableDisable . unTxOutTableTypeConfig
691691

692692
instance FromJSON OffchainPoolDataConfig where
693693
parseJSON = Aeson.withText "offchain_pool_data" $ \v ->
@@ -726,7 +726,7 @@ instance Default SyncInsertOptions where
726726
, sioPoolStats = PoolStatsConfig False
727727
, sioJsonType = JsonTypeText
728728
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
729-
, sioAddress = AddressTypeConfig False
729+
, sioTxOutTableType = TxOutTableTypeConfig False
730730
}
731731

732732
fullInsertOptions :: SyncInsertOptions
@@ -745,7 +745,7 @@ fullInsertOptions =
745745
, sioPoolStats = PoolStatsConfig True
746746
, sioJsonType = JsonTypeText
747747
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
748-
, sioAddress = AddressTypeConfig False
748+
, sioTxOutTableType = TxOutTableTypeConfig False
749749
}
750750

751751
onlyUTxOInsertOptions :: SyncInsertOptions
@@ -764,7 +764,7 @@ onlyUTxOInsertOptions =
764764
, sioPoolStats = PoolStatsConfig False
765765
, sioJsonType = JsonTypeText
766766
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
767-
, sioAddress = AddressTypeConfig False
767+
, sioTxOutTableType = TxOutTableTypeConfig False
768768
}
769769

770770
onlyGovInsertOptions :: SyncInsertOptions
@@ -791,17 +791,17 @@ disableAllInsertOptions =
791791
, sioGovernance = GovernanceConfig False
792792
, sioJsonType = JsonTypeText
793793
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
794-
, sioAddress = AddressTypeConfig False
794+
, sioTxOutTableType = TxOutTableTypeConfig False
795795
}
796796

797-
addressTypeToEnableDisable :: IsString s => AddressType -> s
798-
addressTypeToEnableDisable AddressExtended = "enable"
799-
addressTypeToEnableDisable AddressBasic = "disable"
797+
addressTypeToEnableDisable :: IsString s => TxOutTableType -> s
798+
addressTypeToEnableDisable TxOutVariant = "enable"
799+
addressTypeToEnableDisable TxOutCore = "disable"
800800

801-
enableDisableToAddressType :: (Eq s, IsString s) => s -> Maybe AddressType
802-
enableDisableToAddressType = \case
803-
"enable" -> Just AddressExtended
804-
"disable" -> Just AddressBasic
801+
enableDisableToTxOutTableType :: (Eq s, IsString s) => s -> Maybe TxOutTableType
802+
enableDisableToTxOutTableType = \case
803+
"enable" -> Just TxOutVariant
804+
"disable" -> Just TxOutCore
805805
_ -> Nothing
806806

807807
boolToEnableDisable :: IsString s => Bool -> s

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ insertTxOuts syncEnv hasConsumed disInOut blkId (address, value) = do
206206
}
207207
-- Insert the address detail config is active
208208
case ioAddress . soptInsertOptions $ envOptions syncEnv of
209-
DB.AddressExtended -> do
209+
DB.TxOutVariant -> do
210210
addrDetailId <- insertAddress
211211
DB.insertTxOutPlex hasConsumed disInOut $
212212
DB.TxOut
@@ -222,7 +222,7 @@ insertTxOuts syncEnv hasConsumed disInOut blkId (address, value) = do
222222
, DB.txOutReferenceScriptId = Nothing
223223
, DB.txOutAddressId = Just addrDetailId
224224
}
225-
DB.AddressBasic ->
225+
DB.TxOutCore ->
226226
DB.insertTxOutPlex hasConsumed disInOut $
227227
DB.TxOut
228228
{ DB.txOutTxId = txId

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

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -343,39 +343,38 @@ insertTxOut ::
343343
Byron.TxOut ->
344344
ReaderT SqlBackend m ()
345345
insertTxOut syncEnv hasConsumed bootStrap txId index txout =
346-
case ioAddress . soptInsertOptions $ envOptions syncEnv of
347-
DB.AddressExtended -> do
348-
then do
349-
addrDetailId <- insertAddress
350-
DB.insertTxOutPlex hasConsumed bootStrap $
351-
DB.TxOut
352-
{ DB.txOutTxId = txId
353-
, DB.txOutIndex = fromIntegral index
354-
, DB.txOutAddress = Nothing
355-
, DB.txOutAddressHasScript = False
356-
, DB.txOutPaymentCred = Nothing
357-
, DB.txOutStakeAddressId = Nothing
358-
, DB.txOutValue = DbLovelace (Byron.unsafeGetLovelace $ Byron.txOutValue txout)
359-
, DB.txOutDataHash = Nothing
360-
, DB.txOutInlineDatumId = Nothing
361-
, DB.txOutReferenceScriptId = Nothing
362-
, DB.txOutAddressId = Just addrDetailId
363-
}
364-
DB.AddressBasic -> do
365-
DB.insertTxOutPlex hasConsumed bootStrap $
366-
DB.TxOut
367-
{ DB.txOutTxId = txId
368-
, DB.txOutIndex = fromIntegral index
369-
, DB.txOutAddress = Just $ Text.decodeUtf8 $ Byron.addrToBase58 (Byron.txOutAddress txout)
370-
, DB.txOutAddressHasScript = False
371-
, DB.txOutPaymentCred = Nothing -- Byron does not have a payment credential.
372-
, DB.txOutStakeAddressId = Nothing -- Byron does not have a stake address.
373-
, DB.txOutValue = DbLovelace (Byron.unsafeGetLovelace $ Byron.txOutValue txout)
374-
, DB.txOutDataHash = Nothing
375-
, DB.txOutInlineDatumId = Nothing
376-
, DB.txOutReferenceScriptId = Nothing
377-
, DB.txOutAddressId = Nothing
378-
}
346+
case ioAddress . soptInsertOptions $ envOptions syncEnv of
347+
DB.TxOutVariant -> do
348+
addrDetailId <- insertAddress
349+
DB.insertTxOutPlex hasConsumed bootStrap $
350+
DB.TxOut
351+
{ DB.txOutTxId = txId
352+
, DB.txOutIndex = fromIntegral index
353+
, DB.txOutAddress = Nothing
354+
, DB.txOutAddressHasScript = False
355+
, DB.txOutPaymentCred = Nothing
356+
, DB.txOutStakeAddressId = Nothing
357+
, DB.txOutValue = DbLovelace (Byron.unsafeGetLovelace $ Byron.txOutValue txout)
358+
, DB.txOutDataHash = Nothing
359+
, DB.txOutInlineDatumId = Nothing
360+
, DB.txOutReferenceScriptId = Nothing
361+
, DB.txOutAddressId = Just addrDetailId
362+
}
363+
DB.TxOutCore -> do
364+
DB.insertTxOutPlex hasConsumed bootStrap $
365+
DB.TxOut
366+
{ DB.txOutTxId = txId
367+
, DB.txOutIndex = fromIntegral index
368+
, DB.txOutAddress = Just $ Text.decodeUtf8 $ Byron.addrToBase58 (Byron.txOutAddress txout)
369+
, DB.txOutAddressHasScript = False
370+
, DB.txOutPaymentCred = Nothing -- Byron does not have a payment credential.
371+
, DB.txOutStakeAddressId = Nothing -- Byron does not have a stake address.
372+
, DB.txOutValue = DbLovelace (Byron.unsafeGetLovelace $ Byron.txOutValue txout)
373+
, DB.txOutDataHash = Nothing
374+
, DB.txOutInlineDatumId = Nothing
375+
, DB.txOutReferenceScriptId = Nothing
376+
, DB.txOutAddressId = Nothing
377+
}
379378
where
380379
insertAddress ::
381380
(MonadBaseControl IO m, MonadIO m) =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ insertTxOuts syncEnv trce hasConsumed disInOut blkId (TxIn txInId _, txOut) = do
251251
_ <- insertStakeAddressRefIfMissing trce useNoCache (txOut ^. Core.addrTxOutL)
252252
-- TODO: use the `ioAddress` field to insert the extended address.
253253
case ioAddress . soptInsertOptions $ envOptions syncEnv of
254-
DB.AddressExtended -> do
254+
DB.TxOutVariant -> do
255255
addrDetailId <- insertAddress
256256
DB.insertTxOutPlex hasConsumed disInOut $
257257
DB.TxOut
@@ -267,7 +267,7 @@ insertTxOuts syncEnv trce hasConsumed disInOut blkId (TxIn txInId _, txOut) = do
267267
, DB.txOutReferenceScriptId = Nothing
268268
, DB.txOutAddressId = Just addrDetailId
269269
}
270-
DB.AddressBasic ->
270+
DB.TxOutCore ->
271271
DB.insertTxOutPlex hasConsumed disInOut $
272272
DB.TxOut
273273
{ DB.txOutAddress = Just $ Generic.renderAddress addr

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ insertTxOut tracer cache iopts (txId, txHash) (Generic.TxOut index addr value ma
225225
lift . insertScript tracer txId
226226
!txOut <-
227227
case ioAddress iopts of
228-
DB.AddressExtended -> do
228+
DB.TxOutVariant -> do
229229
addrId <- lift $ insertAddress addr mSaId hasScript
230230
pure
231231
DB.TxOut
@@ -241,7 +241,7 @@ insertTxOut tracer cache iopts (txId, txHash) (Generic.TxOut index addr value ma
241241
, DB.txOutTxId = txId
242242
, DB.txOutValue = Generic.coinToDbLovelace value
243243
}
244-
DB.AddressBasic ->
244+
DB.TxOutCore ->
245245
pure
246246
DB.TxOut
247247
{ DB.txOutAddress = Just addrText
@@ -259,8 +259,8 @@ insertTxOut tracer cache iopts (txId, txHash) (Generic.TxOut index addr value ma
259259
-- TODO: Unsure about what we should return here for eutxo
260260
let !eutxo =
261261
case ioAddress iopts of
262-
DB.AddressBasic -> ExtendedTxOut txHash txOut Nothing
263-
DB.AddressExtended -> ExtendedTxOut txHash txOut $ Generic.maybePaymentCred addr
262+
DB.TxOutCore -> ExtendedTxOut txHash txOut Nothing
263+
DB.TxOutVariant -> ExtendedTxOut txHash txOut $ Generic.maybePaymentCred addr
264264
!maTxOuts <- whenFalseMempty (ioMultiAssets iopts) $ insertMaTxOuts tracer cache maMap
265265
pure (eutxo, maTxOuts)
266266
where

cardano-db-sync/src/Cardano/DbSync/Fix/PlutusDataBytes.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
module Cardano.DbSync.Fix.PlutusDataBytes where
1313

1414
import Cardano.BM.Trace (Trace, logInfo, logWarning)
15-
import qualified Cardano.Db.Old.V13_0 as DB_V_13_0
15+
import qualified Cardano.Db.Version.V13_0 as DB_V_13_0
1616
import Cardano.DbSync.Api
1717
import Cardano.DbSync.Era.Shelley.Generic.Block
1818
import Cardano.DbSync.Era.Shelley.Generic.Tx.Alonzo

cardano-db-sync/src/Cardano/DbSync/Fix/PlutusScripts.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import qualified Cardano.Ledger.Core as Ledger
3131
-- import Cardano.Ledger.Plutus.Language
3232

3333
import Cardano.Db (ScriptType (..), maybeToEither)
34-
import qualified Cardano.Db.Old.V13_0 as DB_V_13_0
34+
import qualified Cardano.Db.Version.V13_0 as DB_V_13_0
3535

3636
import Cardano.BM.Trace (Trace, logInfo, logWarning)
3737

cardano-db-sync/test/Cardano/DbSync/Gen.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ syncInsertOptions =
130130
<*> (PoolStatsConfig <$> Gen.bool)
131131
<*> Gen.element [JsonTypeText, JsonTypeJsonb, JsonTypeDisable]
132132
<*> (RemoveJsonbFromSchemaConfig <$> Gen.bool)
133-
<*> (AddressTypeConfig <$> Gen.bool)
133+
<*> (TxOutTableTypeConfig <$> Gen.bool)
134134

135135
txOutConfig :: Gen TxOutConfig
136136
txOutConfig =

cardano-db-tool/src/Cardano/DbTool/Validate/BlockTxs.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ validateBlockCount (blockNo, txCountExpected) = do
7979
then Right ()
8080
else Left $ ValidateError blockNo txCountActual txCountExpected
8181

82-
-- This queries by BlockNo, the one in Cardano.Db.Query queries by BlockId.
82+
-- This queries by BlockNo, the one in Cardano.Db.Operations.Core.Query queries by BlockId.
8383
queryBlockTxCount :: MonadIO m => Word64 -> ReaderT SqlBackend m Word64
8484
queryBlockTxCount blockNo = do
8585
res <- select $ do

cardano-db/app/gen-schema-docs.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# LANGUAGE OverloadedStrings #-}
22

3-
import Cardano.Db.Schema.BaseSchema (schemaDocs)
3+
import Cardano.Db.Schema.Core.Schema (schemaDocs)
44
import Data.Text (Text)
55
import qualified Data.Text as Text
66
import qualified Data.Text.IO as Text

0 commit comments

Comments
 (0)