Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport cardano node fix #1576

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 46 additions & 29 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@

# Plutip server related inputs
plutip = {
url = "github:mlabs-haskell/plutip/1bf0b547cd3689c727586abb8385c008fb2a3d1c";
url = "github:mlabs-haskell/plutip?ref=gergely/version-bump";
# TODO(bladyjoker): Why are we overriding inputs here?
inputs = {
nixpkgs.follows = "nixpkgs";
iohk-nix.follows = "iohk-nix";
Expand Down Expand Up @@ -324,8 +325,8 @@
# it (i.e. `nix develop`)
default = (psProjectFor (nixpkgsFor system)).devShell;

# This can be used with `nix develop .#hsDevShell
hsDevShell = self.hsFlake.${system}.devShell;
# This can be used with `nix develop .#devPlutipServer` to work with `./plutip-server`
devPlutipServer = ((plutipServerFor system).flake { }).devShell;
});

packages = perSystem (system:
Expand Down
63 changes: 29 additions & 34 deletions nix/runtime.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ rec {
# to change the values after calling `buildCtlRuntime`
node = {
port = 3001;
# the version of the node to use, corresponds to the image version tag,
# i.e. `"inputoutput/cardano-node:${tag}"`
tag = "1.35.4";
};
ogmios = { port = 1337; };
postgres = {
Expand Down Expand Up @@ -98,10 +95,15 @@ rec {
nodeSocketPath = "/ipc/node.socket";
bindPort = port: "${toString port}:${toString port}";
defaultServices = with config; {
# TODO make this use `cardano-node` from flake inputs
cardano-node = {
image.contents = [
# Note: Required, fixes issue with "Failed to start all.. subscriptions".
# Creates the /etc/services file.
pkgs.iana-etc
pkgs.coreutils
];
service = {
image = "inputoutput/cardano-node:${node.tag}";
useHostStore = true;
ports = [ (bindPort node.port) ];
volumes = [
"${config.cardano-configurations}/network/${config.network.name}/cardano-node:/config"
Expand All @@ -110,49 +112,42 @@ rec {
"${nodeIpcVol}:/ipc"
];
command = [
"run"
"--config"
"/config/config.json"
"--database-path"
"/data/db"
"--socket-path"
"${nodeSocketPath}"
"--topology"
"/config/topology.json"
"${pkgs.bash}/bin/sh"
"-c"
''
${inputs.cardano-node.packages."${pkgs.system}".cardano-node}/bin/cardano-node run \
--config /config/config.json \
--database-path /data/db \
--socket-path "${nodeSocketPath}" \
--topology /config/topology.json
''
];
};
};
# TODO make this use `kupo` from flake inputs
kupo = {
service = {
image = "cardanosolutions/kupo:${kupo.tag}";
useHostStore = true;
ports = [ (bindPort kupo.port) ];
volumes = [
"${config.cardano-configurations}/network/${config.network.name}:/config"
"${nodeIpcVol}:/ipc"
"${kupoDbVol}:/kupo-db"
];
command = [
"--node-config"
"/config/cardano-node/config.json"
"--node-socket"
"${nodeSocketPath}"
"--since"
"${kupo.since}"
"--match"
"${"${kupo.match}"}"
"--host"
"0.0.0.0"
"--workdir"
"kupo-db"
] ++ (
pkgs.lib.lists.optional kupo.pruneUtxo "--prune-utxo"
) ++ (
pkgs.lib.lists.optional kupo.deferDbIndexes "--defer-db-indexes"
);
"${pkgs.bash}/bin/sh"
"-c"
''
${inputs.kupo-nixos.packages.${pkgs.system}.kupo}/bin/kupo \
--node-config /config/cardano-node/config.json \
--node-socket "${nodeSocketPath}" \
--since "${kupo.since}" \
--match "${kupo.match}" \
--host "0.0.0.0" \
--workdir kupo-db ${pkgs.lib.strings.optionalString kupo.pruneUtxo "--prune-utxo"} ${pkgs.lib.strings.optionalString kupo.deferDbIndexes "--defer-db-indexes"}
''
];
};
};
# TODO make this use `ogmios` from flake inputs
ogmios = {
service = {
useHostStore = true;
Expand Down
9 changes: 2 additions & 7 deletions plutip-server/cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ repository cardano-haskell-packages
-- Align index-states with cardano-wallet
index-state: 2023-06-06T00:00:00Z

index-state:
, hackage.haskell.org 2023-06-06T00:00:00Z
, cardano-haskell-packages 2023-06-05T06:39:32Z

packages: ./.

tests: true
Expand Down Expand Up @@ -111,9 +107,8 @@ source-repository-package
--sha256: 04q58c82wy6x9nkwqbvcxbv6s61fx08h5kf62sb511aqp08id4bb
subdir: generated


source-repository-package
type: git
location: https://github.com/mlabs-haskell/plutip.git
tag: d060231ebf20383cbdc854a4664fd66a5815aedc
--sha256: 0yydxf1f0mdx2ypnas987bnr7fmz0l1255rid5l9f4ajagd4bfry
tag: 1bf0b547cd3689c727586abb8385c008fb2a3d1c
--sha256: sha256-7ZhZUDhlFvV2us4G27iAk6lHezKS/4WA07NQn88VtQU=
1 change: 1 addition & 0 deletions plutip-server/plutip-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ executable plutip-server
, wai-cors
, wai-logger
, warp
, wai-extra

other-modules:
Api
Expand Down
3 changes: 2 additions & 1 deletion plutip-server/src/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Api.Handlers (
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Reader (runReaderT)
import Data.Kind (Type)
import Network.Wai.Middleware.RequestLogger as Logger
import Network.Wai.Middleware.Cors qualified as Cors
import Servant (
Application,
Expand Down Expand Up @@ -42,7 +43,7 @@ type Api =
:> Post '[JSON] StopClusterResponse

app :: Env -> Application
app = Cors.cors (const $ Just policy) . serve api . appServer
app = Logger.logStdout . Cors.cors (const $ Just policy) . serve api . appServer
where
policy :: Cors.CorsResourcePolicy
policy =
Expand Down