Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Merge pull request #151 from input-output-hk/ksaric/CAD-2581
Browse files Browse the repository at this point in the history
[CAD-2581] Use the general db-sync plugins system to implement SMASH.
  • Loading branch information
ksaric authored Feb 18, 2021
2 parents 3ee97e4 + 0c905eb commit 479fc6d
Show file tree
Hide file tree
Showing 19 changed files with 374 additions and 1,176 deletions.
58 changes: 33 additions & 25 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
index-state: 2020-11-15T00:00:00Z
index-state: 2021-01-08T00:00:00Z

packages:
./smash
./smash-sync
./smash-servant-types

constraints:
Expand All @@ -11,10 +10,12 @@ constraints:
-- systemd-2.3.0 requires at least network 3.1.1.0 but it doesn't declare
-- that dependency
, network >= 3.1.1.0
, prometheus >= 2.1.2
, persistent-postgresql >= 2.11.0.1

-- -----------------------------------------------------------------------------
-- Disable all tests by defauly and yhen enable specific tests in this repo
package smash
ghc-options: -Wall -Werror -Wredundant-constraints -Wincomplete-uni-patterns -Wincomplete-record-updates -Wpartial-fields -Wunused-imports

------------------------------------------------------------------------------

tests: False

Expand All @@ -24,44 +25,53 @@ package smash
package smash-servant-types
tests: True

-- These are needed because Nix is doing something crazy.
package cardano-api
tests: False

package cardano-node
tests: False

package ouroboros-consensus-cardano
tests: False

test-show-details: direct

-- -----------------------------------------------------------------------------
------------------------------------------------------------------------------

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-db-sync
tag: 3cf868ec8c06265e4b670ac737af640d716e5ef7
--sha256: 152yhay3riak41saz5s5zdhlkb5c5iqpy1gw1rvwjp6rwg1mc77n
tag: d5aa846e0751227aa6461084d6ea0567535f752e
--sha256: 0xhm53yycjp6zgqzx6l3hvmgl3046g276qq7vx2wbhljwwqvvk15
subdir:
cardano-sync
cardano-db
cardano-db-sync
cardano-db-sync-extended

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 2574600da11065937c1f07e4b234ecb451016a2e
--sha256: 0nq8bpzsr3fd2i59a6s6qb6slpymjh47zv57wlifjfvhh0xlgmpx
tag: b364d925e0a72689ecba40dd1f4899f76170b894
--sha256: 0igb4gnzlwxy1h40vy5s1aysmaa04wypxn7sn67qy6din7ysmad3
subdir:
binary
binary/test
cardano-crypto-class
cardano-crypto-tests
cardano-crypto-praos
slotting

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-crypto
tag: 2547ad1e80aeabca2899951601079408becbc92c
--sha256: 1p2kg2w02q5w1cvqzhfhqmxviy4xrzada3mmb096j2n6hfr20kri
tag: f73079303f663e028288f9f4a9e08bcca39a923e
--sha256: 1n87i15x54s0cjkh3nsxs4r1x016cdw1fypwmr68936n3xxsjn6q

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: 581767d1329f3f702e332af08355e81a0f85333e
--sha256: 198p4v2bi36y6x512w35qycvjm7nds7jf8qh7r84pj1qsy43vf7w
tag: 097890495cbb0e8b62106bcd090a5721c3f4b36f
--sha256: 0i3y9n0rsyarvhfqzzzjccqnjgwb9fbmbs6b7vj40afjhimf5hcj
subdir:
byron/crypto
byron/crypto/test
Expand All @@ -79,22 +89,19 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-node
tag: 400d18092ce604352cf36fe5f105b0d7c78be074
--sha256: 19r4mamm9bxc1hz32qgsrfnrfxwp4pgnb4d28fzai3izznil03vi
tag: 9a7331cce5e8bc0ea9c6bfa1c28773f4c5a7000f
--sha256: 1scffi7igv4kj93bpjf8yibcaq0sskfikmm00f7r6q031l53y50c
subdir:
cardano-api
cardano-api/test
cardano-cli
cardano-config
cardano-node
cardano-node-chairman
hedgehog-extras

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: 742e8525b96bf4b66fb61a00c8298d75d7931d5e
--sha256: 1132r58bjgdcf7yz3n77nlrkanqcmpn5b5km4nw151yar2dgifsv
tag: ee4e7b547a991876e6b05ba542f4e62909f4a571
--sha256: 0dg6ihgrn5mgqp95c4f11l6kh9k3y75lwfqf47hdp554w7wyvaw6
subdir:
cardano-prelude
cardano-prelude-test
Expand Down Expand Up @@ -123,8 +130,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: c2bd6814e231bfd48059f306ef486b830e524aa8
--sha256: 0sjp5i4szp5nf1dkwang5w8pydjx5p22by8wisihs1410rxgwd7n
tag: 6cb9052bde39472a0555d19ade8a42da63d3e904
--sha256: 0rz4acz15wda6yfc7nls6g94gcwg2an5zibv0irkxk297n76gkmg
subdir:
cardano-client
io-sim
Expand All @@ -140,3 +147,4 @@ source-repository-package
typed-protocols-examples
network-mux
Win32-network

2 changes: 1 addition & 1 deletion nix/pkgs.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# our packages overlay
pkgs: _: with pkgs;
let
compiler = config.haskellNix.compiler or "ghc865";
compiler = config.haskellNix.compiler or "ghc8102";
src = haskell-nix.haskellLib.cleanGit {
name = "smash-src";
src = ../.;
Expand Down
12 changes: 6 additions & 6 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "4c42100df06a0a1d976e5e883a3eedf053d8b91f",
"sha256": "0rkwldvw0qcwssjm72iqw4z3l1xyh0n0fs5jfm35jr62s84z6085",
"rev": "42b10678ff45cd1bd668093c3a9bcb093d5c1760",
"sha256": "0bianzf3y17qikx3cbzcr587hnljg3fgnax7y93nn4s9q2b8w283",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/4c42100df06a0a1d976e5e883a3eedf053d8b91f.tar.gz",
"url": "https://github.com/input-output-hk/haskell.nix/archive/42b10678ff45cd1bd668093c3a9bcb093d5c1760.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"iohk-nix": {
Expand All @@ -29,10 +29,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "f0542228f98a2590e0f39c507b364321995ad802",
"sha256": "0yhgjg4bj7cv1lmrb9ig2iapv1mslhn6m750zn2x0n1a3ll267yh",
"rev": "4efc38924c64c23a582c84950c8c25f72ff049cc",
"sha256": "0nhwyrd0xc72yj5q3jqa2wl4khp4g7n72i45cxy2rgn9nrp8wqh0",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/f0542228f98a2590e0f39c507b364321995ad802.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/4efc38924c64c23a582c84950c8c25f72ff049cc.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
1 change: 1 addition & 0 deletions schema/force-resync.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ TRUNCATE pool;
TRUNCATE retired_pool;
TRUNCATE pool_metadata_fetch_error CASCADE;
TRUNCATE block;
TRUNCATE meta;
21 changes: 21 additions & 0 deletions schema/migration-2-0008-20210215.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Persistent generated migration.

CREATE FUNCTION migrate() RETURNS void AS $$
DECLARE
next_version int ;
BEGIN
SELECT stage_two + 1 INTO next_version FROM schema_version ;
IF next_version = 8 THEN
ALTER TABLE "meta" DROP COLUMN "protocol_const";
ALTER TABLE "meta" DROP COLUMN "slot_duration";
ALTER TABLE "meta" DROP COLUMN "slots_per_epoch";
-- Hand written SQL statements can be added here.
UPDATE schema_version SET stage_two = 8 ;
RAISE NOTICE 'DB has been migrated to stage_two version %', next_version ;
END IF ;
END ;
$$ LANGUAGE plpgsql ;

SELECT migrate() ;

DROP FUNCTION migrate() ;
2 changes: 0 additions & 2 deletions smash-servant-types/src/Cardano/SMASH/DBSync/Db/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import Cardano.Prelude

import Data.Aeson (ToJSON (..), (.=), object, Value (..))

import Data.ByteString.Char8 (ByteString)

import Cardano.SMASH.DBSync.Db.Types


Expand Down
5 changes: 5 additions & 0 deletions smash-servant-types/src/Cardano/SMASH/Types.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}

module Cardano.SMASH.Types
Expand Down Expand Up @@ -355,6 +356,10 @@ instance FromHttpApiData TimeStringFormat where
parsedTime = parseTimeM False defaultTimeLocale timeFormat $ toS queryParam
in TimeStringFormat <$> parsedTime

-- Required for the above, error with newer GHC versions
instance MonadFail (Either Text) where
fail = Left . toS

instance ToParamSchema TimeStringFormat

-- |The data for returning the health check for SMASH.
Expand Down
Loading

0 comments on commit 479fc6d

Please sign in to comment.