Skip to content

Commit

Permalink
Merge pull request #1573 from Plutonomicon/bladyjoker/upgrading-carda…
Browse files Browse the repository at this point in the history
…no-node

Upgrade cardano-node
  • Loading branch information
klntsky authored Dec 12, 2023
2 parents 7620749 + 5c97dcf commit 1666aba
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 50 deletions.
9 changes: 5 additions & 4 deletions flake.lock

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

10 changes: 6 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@
};

# Repository with network parameters
# NOTE(bladyjoker): Cardano configurations (yaml/json) often change format and break, that's why we pin to a specific known version.
cardano-configurations = {
# Override with "path:/path/to/cardano-configurations";
url = "github:input-output-hk/cardano-configurations";
url = "github:input-output-hk/cardano-configurations?rev=d952529afdfdf6d53ce190b1bf8af990a7ae9590";
flake = false;
};
easy-purescript-nix = {
Expand All @@ -76,7 +77,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 @@ -330,8 +332,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

0 comments on commit 1666aba

Please sign in to comment.