Skip to content

Commit fe197d6

Browse files
committed
bulk consummed txout
1 parent 32129d8 commit fe197d6

File tree

95 files changed

+1797
-2316
lines changed

Some content is hidden

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

95 files changed

+1797
-2316
lines changed

.github/workflows/check-fourmolu.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
shell: bash
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717

1818
- name: Run fourmolu
19-
uses: haskell-actions/run-fourmolu@v9
19+
uses: haskell-actions/run-fourmolu@v11
2020
with:
21-
version: "0.10.1.0"
21+
version: "0.17.0.0"

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Revision history for cardano-db-sync
22

3+
## 13.7.0.0
4+
5+
### Summary
6+
- Complete migration from Persistent ORM to Hasql for direct PostgreSQL access.
7+
8+
### Performance Improvements
9+
- 3-4x faster epoch processing: ~30min → ~8min per epoch
10+
- Improved cache efficiency: Stake address hit rates increased from 57-79% to 89-99%
11+
- Reduced memory overhead: Eliminated ORM abstraction layer
12+
13+
### Compatibility
14+
- PostgreSQL schema remains unchanged
15+
- Existing database instances compatible without migration
16+
317
## 13.6.0.5
418
- Fix offchain data so it supports files up to 3MB [#1928]
519
- Upgrade to PostgreSQL 17

cabal.project

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ repository cardano-haskell-packages
1010
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee
1111

1212
index-state:
13-
, hackage.haskell.org 2025-05-23T06:30:40Z
14-
, cardano-haskell-packages 2025-05-16T20:03:45Z
13+
, hackage.haskell.org 2025-06-26T20:35:31Z
14+
, cardano-haskell-packages 2025-06-25T13:51:34Z
1515

1616
packages:
1717
cardano-db
@@ -85,16 +85,9 @@ if impl (ghc >= 9.12)
8585
-- https://github.com/kapralVV/Unique/issues/11
8686
, Unique:hashable
8787

88-
-- https://github.com/Gabriella439/Haskell-Pipes-Safe-Library/pull/70
89-
, pipes-safe:base
90-
9188
-- https://github.com/haskellari/postgresql-simple/issues/152
9289
, postgresql-simple:base
9390
, postgresql-simple:template-haskell
94-
95-
-- https://github.com/haskell-hvr/int-cast/issues/10
96-
, int-cast:base
97-
9891
-- The two following one-liners will cut off / restore the remainder of this file (for nix-shell users):
9992
-- when using the "cabal" wrapper script provided by nix-shell.
10093
-- --------------------------- 8< --------------------------

cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Conway/Scenarios.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#if __GLASGOW_HASKELL__ >= 908
77
{-# OPTIONS_GHC -Wno-x-partial #-}
8+
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
9+
{-# HLINT ignore "Use zipWith" #-}
810
#endif
911

1012
module Cardano.Mock.Forging.Tx.Conway.Scenarios (

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,6 @@ module Test.Cardano.Db.Mock.Config (
6262
txOutVariantTypeFromConfig,
6363
) where
6464

65-
import Cardano.Api (NetworkMagic (..))
66-
import qualified Cardano.Db as DB
67-
import Cardano.DbSync
68-
import Cardano.DbSync.Config
69-
import Cardano.DbSync.Config.Cardano
70-
import Cardano.DbSync.Config.Types
71-
import Cardano.DbSync.Error (runOrThrowIO)
72-
import Cardano.DbSync.Types (CardanoBlock, MetricSetters (..))
73-
import Cardano.Mock.ChainSync.Server
74-
import Cardano.Mock.Forging.Interpreter
75-
import Cardano.Node.Protocol.Shelley (readLeaderCredentials)
76-
import Cardano.Node.Types (ProtocolFilepaths (..))
77-
import Cardano.Prelude (NonEmpty ((:|)), panic, stderr, textShow, throwIO)
78-
import Cardano.SMASH.Server.PoolDataLayer
7965
import Control.Concurrent.Async (Async, async, cancel, poll)
8066
import Control.Concurrent.STM (atomically)
8167
import Control.Concurrent.STM.TMVar (
@@ -92,6 +78,11 @@ import Control.Monad.Logger (NoLoggingT)
9278
import Control.Monad.Trans.Except.Extra (runExceptT)
9379
import Control.Tracer (nullTracer)
9480
import Data.Text (Text)
81+
import System.Directory (createDirectoryIfMissing, removePathForcibly)
82+
import System.FilePath.Posix (takeDirectory, (</>))
83+
import System.IO.Silently (hSilence)
84+
85+
import Cardano.Api (NetworkMagic (..))
9586
import Ouroboros.Consensus.Block.Forging
9687
import Ouroboros.Consensus.Byron.Ledger.Mempool ()
9788
import Ouroboros.Consensus.Config (TopLevelConfig)
@@ -100,9 +91,20 @@ import qualified Ouroboros.Consensus.Node.ProtocolInfo as Consensus
10091
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
10192
import Ouroboros.Consensus.Shelley.Ledger.Mempool ()
10293
import Ouroboros.Consensus.Shelley.Node (ShelleyLeaderCredentials)
103-
import System.Directory (createDirectoryIfMissing, removePathForcibly)
104-
import System.FilePath.Posix (takeDirectory, (</>))
105-
import System.IO.Silently (hSilence)
94+
95+
import qualified Cardano.Db as DB
96+
import Cardano.DbSync
97+
import Cardano.DbSync.Config
98+
import Cardano.DbSync.Config.Cardano
99+
import Cardano.DbSync.Config.Types
100+
import Cardano.DbSync.Error (runOrThrowIO)
101+
import Cardano.DbSync.Types (CardanoBlock, MetricSetters (..))
102+
import Cardano.Mock.ChainSync.Server
103+
import Cardano.Mock.Forging.Interpreter
104+
import Cardano.Node.Protocol.Shelley (readLeaderCredentials)
105+
import Cardano.Node.Types (ProtocolFilepaths (..))
106+
import Cardano.Prelude (NonEmpty ((:|)), panic, stderr, textShow, throwIO)
107+
import Cardano.SMASH.Server.PoolDataLayer
106108

107109
data Config = Config
108110
{ topLevelConfig :: TopLevelConfig CardanoBlock
@@ -239,7 +241,7 @@ getPoolLayer env = do
239241
Left err -> throwIO $ userError err
240242
Right setting -> pure setting
241243

242-
-- Create the Hasql connection pool (using port as pool identifier, similar to your server)
244+
-- Create the Hasql connection pool, using port as pool identifier
243245
pool <- DB.createHasqlConnectionPool [connSetting] 1 -- Pool size of 1 for tests
244246
pure $
245247
postgresqlPoolDataLayer

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ insertConfig = do
3434
, sioPoolStats = PoolStatsConfig False
3535
, sioJsonType = JsonTypeDisable
3636
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
37-
, sioDbDebug = False
3837
}
3938

4039
dncInsertOptions cfg @?= expected

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,24 @@ module Test.Cardano.Db.Mock.Unit.Alonzo.Plutus (
2828
swapMultiAssets,
2929
) where
3030

31+
import Control.Monad (void)
32+
import qualified Data.Map as Map
33+
import Data.Text (Text)
34+
import Test.Tasty.HUnit (Assertion)
35+
3136
import qualified Cardano.Crypto.Hash as Crypto
32-
import Cardano.Db (TxOutVariantType (..))
33-
import qualified Cardano.Db as DB
34-
import qualified Cardano.Db.Schema.Variants.TxOutAddress as VA
35-
import qualified Cardano.Db.Schema.Variants.TxOutCore as VC
36-
import Cardano.DbSync.Era.Shelley.Generic.Util (renderAddress)
3737
import Cardano.Ledger.Coin
3838
import Cardano.Ledger.Mary.Value (MaryValue (..), MultiAsset (..), PolicyID (..))
3939
import Cardano.Ledger.Plutus.Data (hashData)
4040
import Cardano.Ledger.SafeHash (extractHash)
4141
import Cardano.Ledger.Shelley.TxCert
42+
import Ouroboros.Consensus.Cardano.Block (StandardAlonzo)
43+
44+
import Cardano.Db (TxOutVariantType (..))
45+
import qualified Cardano.Db as DB
46+
import qualified Cardano.Db.Schema.Variants.TxOutAddress as VA
47+
import qualified Cardano.Db.Schema.Variants.TxOutCore as VC
48+
import Cardano.DbSync.Era.Shelley.Generic.Util (renderAddress)
4249
import Cardano.Mock.ChainSync.Server (IOManager)
4350
import Cardano.Mock.Forging.Interpreter (withAlonzoLedgerState)
4451
import qualified Cardano.Mock.Forging.Tx.Alonzo as Alonzo
@@ -57,10 +64,6 @@ import Cardano.Mock.Forging.Types (
5764
TxEra (..),
5865
UTxOIndex (..),
5966
)
60-
import Control.Monad (void)
61-
import qualified Data.Map as Map
62-
import Data.Text (Text)
63-
import Ouroboros.Consensus.Cardano.Block (StandardAlonzo)
6467
import Test.Cardano.Db.Mock.Config (alonzoConfigDir, startDBSync, withFullConfig, withFullConfigDropDb)
6568
import Test.Cardano.Db.Mock.UnifiedApi (
6669
fillUntilNextEpoch,
@@ -75,7 +78,6 @@ import Test.Cardano.Db.Mock.Validate (
7578
assertEqQuery,
7679
assertScriptCert,
7780
)
78-
import Test.Tasty.HUnit (Assertion)
7981

8082
----------------------------------------------------------------------------------------------------------
8183
-- Plutus Spend Scripts

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ module Test.Cardano.Db.Mock.Unit.Alonzo.Simple (
55
restartDBSync,
66
) where
77

8-
import Cardano.Ledger.BaseTypes (BlockNo (BlockNo))
9-
import Cardano.Mock.ChainSync.Server (IOManager, addBlock)
10-
import Cardano.Mock.Forging.Interpreter (forgeNext)
118
import Control.Concurrent.Class.MonadSTM.Strict (MonadSTM (atomically))
129
import Control.Monad (void)
1310
import Data.Text (Text)
11+
import Test.Tasty.HUnit (Assertion, assertBool)
12+
13+
import Cardano.Ledger.BaseTypes (BlockNo (BlockNo))
1414
import Ouroboros.Network.Block (blockNo)
15+
16+
import Cardano.Mock.ChainSync.Server (IOManager, addBlock)
17+
import Cardano.Mock.Forging.Interpreter (forgeNext)
1518
import Test.Cardano.Db.Mock.Config (alonzoConfigDir, startDBSync, stopDBSync, withFullConfig, withFullConfigDropDb)
1619
import Test.Cardano.Db.Mock.Examples (mockBlock0, mockBlock1, mockBlock2)
1720
import Test.Cardano.Db.Mock.UnifiedApi (forgeNextAndSubmit)
1821
import Test.Cardano.Db.Mock.Validate (assertBlockNoBackoff)
19-
import Test.Tasty.HUnit (Assertion, assertBool)
2022

2123
forgeBlocks :: IOManager -> [(Text, Text)] -> Assertion
2224
forgeBlocks = do

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ module Test.Cardano.Db.Mock.Unit.Babbage.Plutus (
3030
swapMultiAssets,
3131
) where
3232

33+
import Control.Monad (void)
34+
import qualified Data.Map as Map
35+
import Data.Text (Text)
36+
import Test.Tasty.HUnit (Assertion)
37+
3338
import qualified Cardano.Crypto.Hash as Crypto
34-
import qualified Cardano.Db as DB
35-
import qualified Cardano.Db.Schema.Variants.TxOutAddress as VA
36-
import qualified Cardano.Db.Schema.Variants.TxOutCore as VC
37-
import Cardano.DbSync.Era.Shelley.Generic.Util (renderAddress)
3839
import Cardano.Ledger.Coin
3940
import Cardano.Ledger.Mary.Value (MaryValue (..), MultiAsset (..), PolicyID (..))
4041
import Cardano.Ledger.Plutus.Data (hashData)
@@ -50,6 +51,13 @@ import Cardano.Mock.Forging.Tx.Alonzo.ScriptsExamples (
5051
assetNames,
5152
plutusDataList,
5253
)
54+
import Ouroboros.Consensus.Cardano.Block (StandardBabbage)
55+
import Ouroboros.Network.Block (genesisPoint)
56+
57+
import qualified Cardano.Db as DB
58+
import qualified Cardano.Db.Schema.Variants.TxOutAddress as VA
59+
import qualified Cardano.Db.Schema.Variants.TxOutCore as VC
60+
import Cardano.DbSync.Era.Shelley.Generic.Util (renderAddress)
5361
import qualified Cardano.Mock.Forging.Tx.Babbage as Babbage
5462
import Cardano.Mock.Forging.Types (
5563
MockBlock (..),
@@ -58,11 +66,6 @@ import Cardano.Mock.Forging.Types (
5866
TxEra (..),
5967
UTxOIndex (..),
6068
)
61-
import Control.Monad (void)
62-
import qualified Data.Map as Map
63-
import Data.Text (Text)
64-
import Ouroboros.Consensus.Cardano.Block (StandardBabbage)
65-
import Ouroboros.Network.Block (genesisPoint)
6669
import Test.Cardano.Db.Mock.Config (babbageConfigDir, startDBSync, txOutVariantTypeFromConfig, withFullConfig, withFullConfigDropDb)
6770
import Test.Cardano.Db.Mock.UnifiedApi (
6871
fillUntilNextEpoch,
@@ -80,7 +83,6 @@ import Test.Cardano.Db.Mock.Validate (
8083
assertNonZeroFeesContract,
8184
assertScriptCert,
8285
)
83-
import Test.Tasty.HUnit (Assertion)
8486

8587
----------------------------------------------------------------------------------------------------------
8688
-- Plutus Spend Scripts

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
{-# LANGUAGE NumericUnderscores #-}
21
{-# LANGUAGE OverloadedStrings #-}
32

43
module Test.Cardano.Db.Mock.Unit.Conway.Config.JsonbInSchema (

0 commit comments

Comments
 (0)