Skip to content
This repository was archived by the owner on Apr 7, 2021. It is now read-only.

Commit 377d266

Browse files
authored
Merge pull request #99 from input-output-hk/KtorZ/cardano-db-sync-bump-6.0.0
upgrade cardano-db-sync's dependency to 6.x.x
2 parents 02d915e + ffcf75a commit 377d266

37 files changed

+2927
-627
lines changed

cabal.project

Lines changed: 250 additions & 348 deletions
Large diffs are not rendered by default.

cabal.project.freeze

Lines changed: 2490 additions & 0 deletions
Large diffs are not rendered by default.

docker-compose.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: "3.5"
33
services:
44
postgres:
55
image: postgres:11.5-alpine
6+
command: postgres -c 'max_pred_locks_per_transaction=128' -c 'max_locks_per_transaction=128'
67
environment:
78
- POSTGRES_LOGGING=true
89
- POSTGRES_DB_FILE=/run/secrets/postgres_db
@@ -14,6 +15,8 @@ services:
1415
- postgres_db
1516
volumes:
1617
- postgres:/var/lib/postgresql/data
18+
ports:
19+
- 5432:5432
1720
restart: on-failure
1821
logging:
1922
driver: "json-file"
@@ -22,7 +25,7 @@ services:
2225
max-file: "20"
2326

2427
cardano-node:
25-
image: inputoutput/cardano-node:${CARDANO_NODE_VERSION:-1.18.0}
28+
image: inputoutput/cardano-node:${CARDANO_NODE_VERSION:-1.21.1}
2629
environment:
2730
- NETWORK=${NETWORK:-mainnet}
2831
volumes:
@@ -35,7 +38,7 @@ services:
3538
max-file: "10"
3639

3740
cardano-db-sync:
38-
image: inputoutput/cardano-db-sync:${CARDANO_DB_SYNC_VERSION:-3.1.0}
41+
image: inputoutput/cardano-db-sync:${CARDANO_DB_SYNC_VERSION:-6.0.0}
3942
environment:
4043
- NETWORK=${NETWORK:-mainnet}
4144
- POSTGRES_HOST=postgres
@@ -57,7 +60,7 @@ services:
5760
max-file: "10"
5861

5962
cardano-explorer-api:
60-
image: inputoutput/cardano-explorer-api:${CARDANO_EXPLORER_API_VERSION:-2.1.3}
63+
image: inputoutput/cardano-explorer-api:${CARDANO_EXPLORER_API_VERSION:-3.0.0}
6164
depends_on:
6265
- postgres
6366
- cardano-db-sync
@@ -79,7 +82,7 @@ services:
7982
max-file: "10"
8083

8184
cardano-submit-api:
82-
image: inputoutput/cardano-submit-api:${CARDANO_SUBMIT_API_VERSION:-2.1.3}
85+
image: inputoutput/cardano-submit-api:${CARDANO_SUBMIT_API_VERSION:-3.0.0}
8386
environment:
8487
- NETWORK=${NETWORK:-mainnet}
8588
depends_on:

explorer-api/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 3.0.0 -- October 2020
4+
5+
* Upgrade dependencies to more recent version of the Cardano eco-system (cardano-db-sync-6.0.0)
6+
37
## 2.1.3 -- August 2020
48

59
* Fix bug regarding Shelley addresses not being decoded correctly (#75)

explorer-api/app/Explorer/Web/Validate/GenesisAddress.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ extractAddresses = List.map cgaiCardanoAddress
5858
genRandomPageNo :: MonadIO m => PageSize -> SqlPersistT m (Either LookupFail PageNo)
5959
genRandomPageNo (PageSize pageSize) = do
6060
res <- select . from $ \ (txOut `InnerJoin` tx `InnerJoin` blk) -> do
61-
on (blk ^. BlockId ==. tx ^. TxBlock)
61+
on (blk ^. BlockId ==. tx ^. TxBlockId)
6262
on (tx ^. TxId ==. txOut ^. TxOutTxId)
63-
where_ (isNothing (blk ^. BlockPrevious))
63+
where_ (isNothing (blk ^. BlockPreviousId))
6464
pure countRows
6565
case listToMaybe res of
6666
Nothing -> pure $ Left (DbLookupMessage "genRandomPageNo: Empty Block table")

explorer-api/app/Explorer/Web/Validate/Random.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ queryRandomRedeemAddress :: MonadIO m => ReaderT SqlBackend m (Either LookupFail
6969
queryRandomRedeemAddress = do
7070
res <- select . from $ \ (tx `InnerJoin` txOut) -> do
7171
-- Block 1 contains all the TxOuts from the Genesis Distribution.
72-
where_ (tx ^. TxBlock ==. val (mkBlockId 1))
72+
where_ (tx ^. TxBlockId ==. val (mkBlockId 1))
7373
on (tx ^. TxId ==. txOut ^. TxOutTxId)
7474
firstRandomRow
7575
pure (txOut ^. TxOutAddress)

explorer-api/cardano-explorer-api.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cabal-version: >= 1.10
33
-- http://haskell.org/cabal/users-guide/
44

55
name: cardano-explorer-api
6-
version: 2.1.3
6+
version: 3.0.0
77
synopsis: A Block Explorer for the Cardano network
88
description:
99
homepage: https://github.com/input-output-hk/cardano-explorer

explorer-api/src/Explorer/Web/Api/HttpBridge/AddressBalance.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ module Explorer.Web.Api.HttpBridge.AddressBalance
66
) where
77

88
import Cardano.Db
9-
( EntityField (..), queryNetworkName, txOutUnspentP )
9+
( DbLovelace (..), EntityField (..), queryNetworkName, txOutUnspentP )
1010
import Control.Monad.IO.Class
1111
( MonadIO )
1212
import Data.ByteString.Char8
1313
( ByteString )
1414
import Data.Text
1515
( Text )
1616
import Data.Word
17-
( Word16, Word64 )
17+
( Word16 )
1818
import Database.Esqueleto
1919
( InnerJoin (..), Value (..), from, on, select, val, where_, (==.), (^.) )
2020
import Database.Persist.Sql
@@ -64,17 +64,17 @@ addressBalance (CNetwork networkName) (CAddress addrTxt) =
6464
queryAddressBalance :: MonadIO m => Text -> SqlPersistT m [CAddressBalance]
6565
queryAddressBalance addrTxt = do
6666
rows <- select . from $ \ (tx `InnerJoin` txOut) -> do
67-
on (tx ^. TxId ==. txOut ^. TxOutTxId)
68-
txOutUnspentP txOut
69-
where_ (txOut ^. TxOutAddress ==. val addrTxt)
70-
pure (txOut ^. TxOutAddress, tx ^. TxHash, txOut ^. TxOutIndex, txOut ^. TxOutValue)
67+
on (tx ^. TxId ==. txOut ^. TxOutTxId)
68+
txOutUnspentP txOut
69+
where_ (txOut ^. TxOutAddress ==. val addrTxt)
70+
pure (txOut ^. TxOutAddress, tx ^. TxHash, txOut ^. TxOutIndex, txOut ^. TxOutValue)
7171
pure $ map convert rows
7272
where
73-
convert :: (Value Text, Value ByteString, Value Word16, Value Word64) -> CAddressBalance
73+
convert :: (Value Text, Value ByteString, Value Word16, Value DbLovelace) -> CAddressBalance
7474
convert (Value addr, Value txhash, Value index, Value coin) =
7575
CAddressBalance
7676
{ cuaAddress = addr
7777
, cuaTxHash = bsBase16Encode txhash
7878
, cuaIndex = index
79-
, cuaCoin = coin
79+
, cuaCoin = unDbLovelace coin
8080
}

explorer-api/src/Explorer/Web/Api/Legacy/AddressSummary.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Explorer.Web.Api.Legacy.AddressSummary
99
) where
1010

1111
import Cardano.Db
12-
( EntityField (..), TxId, unValue3 )
12+
( DbLovelace (..), EntityField (..), TxId, unValue3 )
1313
import Control.Monad.IO.Class
1414
( MonadIO )
1515
import Control.Monad.Trans.Except.Extra
@@ -23,7 +23,7 @@ import Data.Text
2323
import Data.Time.Clock
2424
( UTCTime )
2525
import Data.Word
26-
( Word16, Word64 )
26+
( Word16 )
2727
import Database.Esqueleto
2828
( InnerJoin (..)
2929
, Value (..)
@@ -110,15 +110,15 @@ queryNonRedeemSummary :: MonadIO m => CChainTip -> Text -> SqlPersistT m CAddres
110110
queryNonRedeemSummary chainTip addr = do
111111
inrows <- select . from $ \ (blk `InnerJoin` tx `InnerJoin` txOut) -> do
112112
on (tx ^. TxId ==. txOut ^. TxOutTxId)
113-
on (blk ^. BlockId ==. tx ^. TxBlock)
113+
on (blk ^. BlockId ==. tx ^. TxBlockId)
114114
where_ (txOut ^. TxOutAddress ==. val addr)
115115
pure (tx ^. TxId, tx ^. TxHash, blk ^. BlockTime)
116116
-- This needs to be distinct to avoid duplicate rows.
117117
outrows <- select . distinct . from $ \ (blk `InnerJoin` tx `InnerJoin` txIn `InnerJoin` txOut) -> do
118118
on (txIn ^. TxInTxOutId ==. txOut ^. TxOutTxId
119119
&&. txIn ^. TxInTxOutIndex ==. txOut ^. TxOutIndex)
120120
on (tx ^. TxId ==. txIn ^. TxInTxInId)
121-
on (blk ^. BlockId ==. tx ^. TxBlock)
121+
on (blk ^. BlockId ==. tx ^. TxBlockId)
122122
where_ (txOut ^. TxOutAddress ==. val addr)
123123
pure (tx ^. TxId, tx ^. TxHash, blk ^. BlockTime)
124124

@@ -159,29 +159,29 @@ queryCTxBriefs xs = do
159159
queryTxInputs :: MonadIO m => [TxId] -> SqlPersistT m [(TxId, [CTxAddressBrief])]
160160
queryTxInputs txids = do
161161
rows <- select . distinct . from $ \(tx `InnerJoin` txIn `InnerJoin` txOut `InnerJoin` txInTx) -> do
162-
on (txInTx ^. TxId ==. txIn ^. TxInTxOutId)
162+
on (txInTx ^. TxId ==. txOut ^. TxOutTxId)
163163
on (txIn ^. TxInTxOutId ==. txOut ^. TxOutTxId
164164
&&. txIn ^. TxInTxOutIndex ==. txOut ^. TxOutIndex)
165165
on (tx ^. TxId ==. txIn ^. TxInTxInId)
166166
where_ (txIn ^. TxInTxInId `in_` valList txids)
167167
pure (tx ^. TxId, txOut ^. TxOutAddress, txOut ^. TxOutValue, txInTx ^. TxHash, txOut ^. TxOutIndex, txInTx ^. TxSize ==. val 0)
168168
pure $ map collapseTxGroup (groupOn fst $ map convert rows)
169169
where
170-
convert :: (Value TxId, Value Text, Value Word64, Value ByteString, Value Word16, Value Bool) -> (TxId, CTxAddressBrief)
170+
convert :: (Value TxId, Value Text, Value DbLovelace, Value ByteString, Value Word16, Value Bool) -> (TxId, CTxAddressBrief)
171171
convert (Value txid, Value addr, Value coin, Value txh, Value index, Value isGenesisTx) =
172172
( txid
173173
, if isGenesisTx
174174
then
175175
CTxAddressBrief
176176
{ ctaAddress = CAddress addr
177-
, ctaAmount = fromIntegral coin
177+
, ctaAmount = fromIntegral $ unDbLovelace coin
178178
, ctaTxHash = genesisDistributionTxHash
179179
, ctaTxIndex = 0
180180
}
181181
else
182182
CTxAddressBrief
183183
{ ctaAddress = CAddress addr
184-
, ctaAmount = fromIntegral coin
184+
, ctaAmount = fromIntegral $ unDbLovelace coin
185185
, ctaTxHash = CTxHash $ CHash (bsBase16Encode txh)
186186
, ctaTxIndex = fromIntegral index
187187
}
@@ -195,12 +195,12 @@ queryTxOutputs txids = do
195195
pure (tx ^. TxId, txOut ^. TxOutAddress, txOut ^. TxOutValue, tx ^. TxHash, txOut ^. TxOutIndex)
196196
pure $ map collapseTxGroup (groupOn fst $ map convert rows)
197197
where
198-
convert :: (Value TxId, Value Text, Value Word64, Value ByteString, Value Word16) -> (TxId, CTxAddressBrief)
198+
convert :: (Value TxId, Value Text, Value DbLovelace, Value ByteString, Value Word16) -> (TxId, CTxAddressBrief)
199199
convert (Value txid, Value addr, Value coin, Value txhash, Value index) =
200200
( txid
201201
, CTxAddressBrief
202202
{ ctaAddress = CAddress addr
203-
, ctaAmount = fromIntegral coin
203+
, ctaAmount = fromIntegral $ unDbLovelace coin
204204
, ctaTxHash = CTxHash . CHash $ bsBase16Encode txhash
205205
, ctaTxIndex = fromIntegral index
206206
}

explorer-api/src/Explorer/Web/Api/Legacy/BlockAddress.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Explorer.Web.Api.Legacy.BlockAddress
66
) where
77

88
import Cardano.Db
9-
( EntityField (..), TxId, unValue3 )
9+
( DbLovelace (..), EntityField (..), TxId, unValue3 )
1010
import Control.Monad.IO.Class
1111
( MonadIO )
1212
import Control.Monad.Trans.Except.Extra
@@ -24,7 +24,7 @@ import Data.Time.Clock
2424
import Data.Time.Clock.POSIX
2525
( utcTimeToPOSIXSeconds )
2626
import Data.Word
27-
( Word16, Word64 )
27+
( Word16 )
2828
import Database.Esqueleto
2929
( InnerJoin (..)
3030
, Value (..)
@@ -104,7 +104,7 @@ queryRedeemSummary chainTip blkHash addrTxt = do
104104
pure (txOut ^. TxOutValue)
105105
case rows of
106106
[] -> pure $ Left (Internal "queryRedeemSummary: Address not found")
107-
[value] -> Right <$> queryRedeemed (fromIntegral $ unValue value)
107+
[value] -> Right <$> queryRedeemed (fromIntegral $ unDbLovelace $ unValue value)
108108
_ -> pure $ Left (Internal "queryRedeemSummary: More than one entry")
109109
where
110110
queryRedeemed :: MonadIO m => CCoin -> SqlPersistT m CAddressSummary
@@ -116,7 +116,7 @@ queryRedeemSummary chainTip blkHash addrTxt = do
116116
on (txIn ^. TxInTxOutId ==. txOut0 ^. TxOutTxId
117117
&&. txIn ^. TxInTxOutIndex ==. txOut0 ^. TxOutIndex)
118118
on (tx ^. TxId ==. txIn ^. TxInTxInId)
119-
on (blk ^. BlockId ==. tx ^. TxBlock)
119+
on (blk ^. BlockId ==. tx ^. TxBlockId)
120120
where_ (blk ^. BlockHash <=. val blkHash)
121121
where_ (txOut0 ^. TxOutAddress ==. val addrTxt)
122122
pure (tx ^. TxHash, blk ^. BlockTime, txOut1 ^. TxOutAddress)
@@ -180,7 +180,7 @@ queryAddressSummary :: MonadIO m => CChainTip -> ByteString -> Text -> SqlPersis
180180
queryAddressSummary chainTip blkHash addr = do
181181
inrows <- select . from $ \ (blk `InnerJoin` tx `InnerJoin` txOut) -> do
182182
on (tx ^. TxId ==. txOut ^. TxOutTxId)
183-
on (blk ^. BlockId ==. tx ^. TxBlock)
183+
on (blk ^. BlockId ==. tx ^. TxBlockId)
184184
where_ (blk ^. BlockHash <=. val blkHash)
185185
where_ (txOut ^. TxOutAddress ==. val addr)
186186
pure (tx ^. TxId, tx ^. TxHash, blk ^. BlockTime)
@@ -189,7 +189,7 @@ queryAddressSummary chainTip blkHash addr = do
189189
on (txIn ^. TxInTxOutId ==. txOut ^. TxOutTxId
190190
&&. txIn ^. TxInTxOutIndex ==. txOut ^. TxOutIndex)
191191
on (tx ^. TxId ==. txIn ^. TxInTxInId)
192-
on (blk ^. BlockId ==. tx ^. TxBlock)
192+
on (blk ^. BlockId ==. tx ^. TxBlockId)
193193
where_ (blk ^. BlockHash <=. val blkHash)
194194
where_ (txOut ^. TxOutAddress ==. val addr)
195195
pure (tx ^. TxId, tx ^. TxHash, blk ^. BlockTime)
@@ -248,12 +248,12 @@ queryTxOutputs txids = do
248248

249249
-- -------------------------------------------------------------------------------------------------
250250

251-
convert :: (Value TxId, Value Text, Value Word64, Value ByteString, Value Word16) -> (TxId, CTxAddressBrief)
251+
convert :: (Value TxId, Value Text, Value DbLovelace, Value ByteString, Value Word16) -> (TxId, CTxAddressBrief)
252252
convert (Value txid, Value addr, Value coin, Value txhash, Value index) =
253253
( txid
254254
, CTxAddressBrief
255255
{ ctaAddress = CAddress addr
256-
, ctaAmount = fromIntegral coin
256+
, ctaAmount = fromIntegral $ unDbLovelace coin
257257
, ctaTxHash = CTxHash . CHash $ bsBase16Encode txhash
258258
, ctaTxIndex = fromIntegral index
259259
}

0 commit comments

Comments
 (0)