Skip to content

Commit

Permalink
[DDW-1228] Use P2P configs from cardano-playground
Browse files Browse the repository at this point in the history
  • Loading branch information
michalrus committed Jan 19, 2024
1 parent 5aa1fb7 commit 7cb4334
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 49 deletions.
35 changes: 17 additions & 18 deletions flake.lock

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

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-22.11-darwin";
cardano-wallet-unpatched.url = "github:cardano-foundation/cardano-wallet/rc-latest";
cardano-wallet-unpatched.flake = false; # otherwise, +10k quadratic dependencies in flake.lock…
cardano-world.url = "github:input-output-hk/cardano-world/d751a12be1dd4e5e2bd3bafaf4c254390469292d";
cardano-world.flake = false; # otherwise, +19k quadratic dependencies in flake.lock…
cardano-playground.url = "github:input-output-hk/cardano-playground";
cardano-playground.flake = false; # otherwise, +9k dependencies in flake.lock…
cardano-shell.url = "github:input-output-hk/cardano-shell/0d1d5f036c73d18e641412d2c58d4acda592d493";
cardano-shell.flake = false;
tullia.url = "github:input-output-hk/tullia";
Expand Down
5 changes: 2 additions & 3 deletions nix/internal/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ rec {
aarch64-darwin = nodeFlake.packages.aarch64-darwin;
}.${targetSystem};

cardanoWorldFlake = (flake-compat { src = inputs.cardano-world; }).defaultNix.outputs;

inherit (walletFlake.legacyPackages.${pkgs.system}.pkgs) cardanoLib;

daedalus-bridge = pkgs.lib.genAttrs sourceLib.installerClusters (cluster: import ./cardano-bridge.nix {
Expand All @@ -96,8 +94,9 @@ rec {

mkLauncherConfigs = { devShell ? false, cluster }: import ./launcher-config.nix {
inherit devShell;
inherit cardanoLib cardanoWorldFlake;
inherit cardanoLib;
inherit (pkgs) system runCommand lib;
inherit (inputs) cardano-playground;
network = cluster;
os = {
x86_64-windows = "windows";
Expand Down
37 changes: 11 additions & 26 deletions nix/internal/launcher-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
, topologyOverride ? null
, configOverride ? null
, genesisOverride ? null
, cardanoWorldFlake
, cardano-playground
, system
}:

Expand All @@ -20,49 +20,37 @@

let
clustersAvailable = rec {
mainnet = fromCardanoWorld "mainnet";
mainnet = fromCardanoPlayground "mainnet";
mainnet_flight = mainnet;
shelley_qa = fromCardanoWorld "shelley_qa";
vasil_dev = fromCardanoWorld "vasil-dev";
preprod = fromCardanoWorld "preprod";
preview = fromCardanoWorld "preview";
shelley_qa = fromCardanoPlayground "shelley_qa";
vasil_dev = fromCardanoPlayground "vasil-dev";
preprod = fromCardanoPlayground "preprod";
preview = fromCardanoPlayground "preview";
};

fromCardanoWorld = envName: let
fromCardanoPlayground = envName: let
originalFiles = builtins.path {
name = "cardano-world-config-${envName}";
path = cardanoWorldFlake.${system}.cardano.packages.cardano-config-html-internal + "/config/" + envName;
name = "cardano-playground-config-${envName}";
path = cardano-playground + ("/static/book.play.dev.cardano.org/environments/" + envName);
};

originalNodeConfig = builtins.fromJSON (builtins.unsafeDiscardStringContext (
builtins.readFile (originalFiles + "/config.json")));

topology = builtins.fromJSON (builtins.unsafeDiscardStringContext (
builtins.readFile (originalFiles + "/topology.json")));

topologyFirstAccessPoint = builtins.head (builtins.head topology.publicRoots).accessPoints;

isP2P = originalNodeConfig ? EnableP2P && originalNodeConfig.EnableP2P;

nodeConfig = originalNodeConfig // {
ConwayGenesisFile = originalFiles + "/" + originalNodeConfig.ConwayGenesisFile;
AlonzoGenesisFile = originalFiles + "/" + originalNodeConfig.AlonzoGenesisFile;
ByronGenesisFile = originalFiles + "/" + originalNodeConfig.ByronGenesisFile;
ShelleyGenesisFile = originalFiles + "/" + originalNodeConfig.ShelleyGenesisFile;
minSeverity = "Info"; # XXX: Needed for sync % updates.
EnableP2P = false; # XXX: Doesn’t work behind NAT? Let’s use the legacy topology.
};
in {
cluster = envName;
networkName = envName;
cardanoEnv = {
inherit nodeConfig;
} // (if isP2P then {
relaysNew = topologyFirstAccessPoint.address;
edgePort = topologyFirstAccessPoint.port;
} else {
topologyFile = originalFiles + "/topology.json";
});
};
};

dirSep = if os == "windows" then "\\" else "/";
Expand Down Expand Up @@ -245,10 +233,7 @@ let
genesisFile'.selfnode = ../../utils/cardano/selfnode/genesis.json;
genesisFile'.local = (__fromJSON nodeConfig).GenesisFile;
in if (genesisOverride != null) then genesisOverride else if (network == "selfnode" || network == "local") then genesisFile'.${network} else envCfg.nodeConfig.ByronGenesisFile;
normalTopologyFile = if network == "selfnode" then envCfg.topology else cardanoLib.mkEdgeTopology {
inherit (envCfg) edgePort;
edgeNodes = [ envCfg.relaysNew ];
};
normalTopologyFile = if network == "selfnode" then envCfg.topology else throw "no longer supported";
localTopology = cardanoLib.mkEdgeTopology {
edgePort = 30001;
edgeNodes = [ "127.0.0.1" ];
Expand Down

0 comments on commit 7cb4334

Please sign in to comment.