Skip to content

Commit

Permalink
Merge branch 'v2-integration' into release/2.2.0-ITN1
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaglumac committed Feb 20, 2020
2 parents 695f053 + 335fa9b commit 01cf841
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog

### Features

- Added "block-0" to the installers in order to speed up the initial bootstrap phase ([PR 1857](https://github.com/input-output-hk/daedalus/pull/1857))
- Implemented transactions filtering dialog on wallet "Transactions" screen ([PR 1815](https://github.com/input-output-hk/daedalus/pull/1815))

### Fixes
Expand Down
4 changes: 4 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ let
mkdir $out
cp daedalus.nsi uninstaller.nsi $out/
cp $launcherConfigPath $out/launcher-config.yaml
${lib.optionalString self.launcherConfigs.installerConfig.hasBlock0 "cp ${self.launcherConfigs.installerConfig.block0} $out/block-0.bin"}
${lib.optionalString (cluster != "selfnode") "cp ${self.launcherConfigs.jormungandr-config} $out/jormungandr-config.yaml"}
'';

Expand Down Expand Up @@ -217,6 +218,9 @@ let
if [ -f ${self.nsisFiles}/jormungandr-config.yaml ]; then
cp -v ${self.nsisFiles}/jormungandr-config.yaml .
fi
if [ -f ${self.nsisFiles}/block-0.bin ]; then
cp -v ${self.nsisFiles}/block-0.bin .
fi
cp -v ${./utils/jormungandr/selfnode/genesis.yaml} genesis.yaml
chmod -R +w .
${lib.optionalString (fudgeConfig != null) ''
Expand Down
8 changes: 5 additions & 3 deletions installers/common/MacInstaller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ main opts@Options{oBackend, oCluster, oBuildJob, oOutputDir, oTestInstaller, oSi

buildIcons oCluster
appRoot <- buildElectronApp darwinConfig installerConfig
makeComponentRoot opts appRoot darwinConfig
makeComponentRoot opts appRoot darwinConfig installerConfig
daedalusVer <- getDaedalusVersion "../package.json"

let pkg = packageFileName Macos64 oCluster daedalusVer oBackend ver oBuildJob
Expand Down Expand Up @@ -153,8 +153,8 @@ getBackendVersion :: Backend -> IO Text
getBackendVersion (Cardano bridge) = readCardanoVersionFile bridge
getBackendVersion Mantis = pure "DEVOPS-533"

makeComponentRoot :: Options -> FilePath -> DarwinConfig -> IO ()
makeComponentRoot Options{oBackend,oCluster} appRoot darwinConfig@DarwinConfig{dcAppName} = do
makeComponentRoot :: Options -> FilePath -> DarwinConfig -> InstallerConfig -> IO ()
makeComponentRoot Options{oBackend,oCluster} appRoot darwinConfig@DarwinConfig{dcAppName} InstallerConfig{hasBlock0} = do
let dir = appRoot </> "Contents/MacOS"

echo "~~~ Preparing files ..."
Expand All @@ -171,6 +171,8 @@ makeComponentRoot Options{oBackend,oCluster} appRoot darwinConfig@DarwinConfig{d
cp "jormungandr-config.yaml" (dir </> "jormungandr-config.yaml")
when (oCluster == Selfnode) $
cp "genesis.yaml" (dir </> "genesis.yaml")
when hasBlock0 $
cp "block-0.bin" (dir </> "block-0.bin")

-- Genesis (from daedalus-bridge)
--genesisFiles <- glob . encodeString $ bridge </> "config" </> "*genesis*.json"
Expand Down
1 change: 1 addition & 0 deletions installers/common/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ data InstallerConfig = InstallerConfig {
, spacedName :: Text
, macPackageName :: Text
, dataDir :: Text
, hasBlock0 :: Bool
} deriving (Generic, Show)

instance FromJSON InstallerConfig where
Expand Down
16 changes: 10 additions & 6 deletions installers/common/WindowsInstaller.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{-# LANGUAGE RecordWildCards, LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NamedFieldPuns #-}

module WindowsInstaller
( main
, writeInstallerNSIS
Expand Down Expand Up @@ -131,7 +133,7 @@ parseVersion ver =
_ -> ["0", "0", "0", "0"]

writeInstallerNSIS :: FilePath -> Version -> InstallerConfig -> Cluster -> IO ()
writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName = do
writeInstallerNSIS outName (Version fullVersion') InstallerConfig{hasBlock0,installDirectory,spacedName} clusterName = do
tempDir <- getTempDir
let fullVersion = unpack fullVersion'
viProductVersion = L.intercalate "." $ parseVersion fullVersion'
Expand All @@ -140,8 +142,8 @@ writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName =
IO.writeFile "daedalus.nsi" $ nsis $ do
_ <- constantStr "Version" (str fullVersion)
_ <- constantStr "Cluster" (str $ lshow clusterName)
_ <- constantStr "InstallDir" (str $ unpack $ installDirectory installerConfig)
_ <- constantStr "SpacedName" (str $ unpack $ spacedName installerConfig)
_ <- constantStr "InstallDir" (str $ unpack installDirectory)
_ <- constantStr "SpacedName" (str $ unpack spacedName)
name "$SpacedName ($Version)" -- The name of the installer
outFile $ str $ encodeString outName -- Where to produce the installer
unsafeInjectGlobal $ "!define MUI_ICON \"icons\\" ++ lshow clusterName ++ "\\" ++ lshow clusterName ++ ".ico\""
Expand Down Expand Up @@ -179,7 +181,7 @@ writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName =
createDirectory "$APPDATA\\$InstallDir\\Logs\\pub"
onError (delete [] "$APPDATA\\$InstallDir\\launcher.lock") $
--abort "$SpacedName $(AlreadyRunning)"
unsafeInject $ unpack $ "Abort \" " <> (installDirectory installerConfig) <> "$(AlreadyRunning)\""
unsafeInject $ unpack $ "Abort \" " <> installDirectory <> "$(AlreadyRunning)\""
iff_ (fileExists "$APPDATA\\$InstallDir\\Wallet-1.0\\open\\*.*") $
rmdir [] "$APPDATA\\$InstallDir\\Wallet-1.0\\open"
file [] "jormungandr.exe"
Expand All @@ -193,6 +195,8 @@ writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName =
--file [] "configuration.yaml"
--file [] "*genesis*.json"
file [] "launcher-config.yaml"
when hasBlock0 $
file [] "block-0.bin"
when (clusterName /= Selfnode) $
file [] "jormungandr-config.yaml"
when (clusterName == Selfnode) $
Expand All @@ -206,7 +210,7 @@ writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName =
, "DetailPrint \"liteFirewall::AddRule: $0\""
]

createShortcut "$DESKTOP\\$SpacedName.lnk" (daedalusShortcut $ spacedName installerConfig)
createShortcut "$DESKTOP\\$SpacedName.lnk" (daedalusShortcut spacedName)

-- Uninstaller
let
Expand All @@ -230,7 +234,7 @@ writeInstallerNSIS outName (Version fullVersion') installerConfig clusterName =
createDirectory "$SMPROGRAMS/$SpacedName"
createShortcut "$SMPROGRAMS/$SpacedName/Uninstall $SpacedName.lnk"
[Target "$INSTDIR/uninstall.exe", IconFile "$INSTDIR/uninstall.exe", IconIndex 0]
createShortcut "$SMPROGRAMS/$SpacedName/$SpacedName.lnk" (daedalusShortcut $ installDirectory installerConfig)
createShortcut "$SMPROGRAMS/$SpacedName/$SpacedName.lnk" (daedalusShortcut installDirectory)
return ()

lshow :: Show a => a -> String
Expand Down
2 changes: 1 addition & 1 deletion installers/nix/linux.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let
daedalus-config = runCommand "daedalus-config" {} ''
mkdir -pv $out
cd $out
cp ${builtins.toFile "launcher-config.yaml" (builtins.toJSON launcherConfigs.launcherConfig)} $out/launcher-config.yaml
cp ${writeText "launcher-config.yaml" (builtins.toJSON launcherConfigs.launcherConfig)} $out/launcher-config.yaml
'';
# closure size TODO list
# electron depends on cups, which depends on avahi
Expand Down
18 changes: 16 additions & 2 deletions nix/launcher-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ let
logsPrefix.windows = "Logs";
logsPrefix.macos64 = "${dataDir.${os}}/Logs";

block0Bin.linux = envCfg.block0bin;
block0Bin.windows = "\${DAEDALUS_INSTALL_DIRECTORY}\\block-0.bin";
block0Bin.macos64 = "\${DAEDALUS_INSTALL_DIRECTORY}/block-0.bin";

cfgPathForOs = {
windows = "\${DAEDALUS_INSTALL_DIRECTORY}\\jormungandr-config.yaml";
macos64 = "\${DAEDALUS_INSTALL_DIRECTORY}/jormungandr-config.yaml";
Expand All @@ -54,8 +58,12 @@ let
finalJormungandrCfgPath = if devShell then jormungandrConfigForCluster else cfgPathForOs.${os};

walletArgs = [
"launch"
"launch" ] ++
(if (envCfg ? block0bin) then [
"--genesis-block" block0Bin.${os}
] else [
"--genesis-block-hash" "${jormungandrLib.environments.${environment}.genesisHash}"
]) ++ [
"--state-dir" dataDir.${os}
"--sync-tolerance" "${jormungandrLib.environments.${environment}.syncTolerance}"
"--random-port"
Expand Down Expand Up @@ -94,18 +102,23 @@ let
nodeTimeoutSec = 60;
tlsPath = null;
x509ToolPath = null;
cluster = environment;

updateWindowsRunner = if os == "windows" then "Installer.bat" else "";
updaterPath = "/foo";
updaterArgs = [];
updateArchive = "/bar";
};
hasBlock0 = (environment != "selfnode") && envCfg ? block0bin;
installerConfig = {
installDirectory = if os == "linux" then "Daedalus/${environment}" else spacedName;
inherit spacedName;
macPackageName = "Daedalus${environment}";
dataDir = dataDir.${os};
};
inherit hasBlock0;
} // (lib.optionalAttrs hasBlock0 {
block0 = envCfg.block0bin;
});
in {
inherit launcherConfig installerConfig;
jormungandr-config = jormungandrConfigForCluster;
Expand All @@ -119,5 +132,6 @@ in {
${lib.optionalString (environment != "selfnode") "cp ${jormungandrConfigForCluster} jormungandr-config.yaml"}
cp $installerConfigPath installer-config.json
cp $launcherConfigPath launcher-config.yaml
${lib.optionalString (installerConfig.hasBlock0) "cp ${installerConfig.block0} block-0.bin"}
'';
}
8 changes: 4 additions & 4 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"iohk-nix": {
"branch": "jorm-version-0.8.10",
"branch": "master",
"description": "nix scripts shared across projects",
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "15e22b07388d24bf6aa2a67fb7f41a7dd4b746a5",
"sha256": "1jz7sj2pwp7l4y2i2qp5j0jymjqj2a3v65khp7wsfwnvg1giswzm",
"rev": "b34f11f205afbd11a69cab45d57cd8ebb2746713",
"sha256": "14cnfw479gha7ljifai9zchmpsq4652f3q2vvsibslfd6sgnl4js",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/15e22b07388d24bf6aa2a67fb7f41a7dd4b746a5.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/b34f11f205afbd11a69cab45d57cd8ebb2746713.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"js-chain-libs": {
Expand Down
3 changes: 3 additions & 0 deletions scripts/build-installer-unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ pushd installers
" --out-dir ${APP_NAME}")
nix-build .. -A launcherConfigs.cfg-files --argstr os macos64 --argstr cluster "${cluster}" -o cfg-files
cp -v cfg-files/{installer-config.json,launcher-config.yaml} .
if [ -f cfg-files/block-0.bin ]; then
cp -v cfg-files/block-0.bin .
fi
cp -vf ../utils/jormungandr/selfnode/genesis.yaml .
if [ "${cluster}" != selfnode ]; then
cp -v cfg-files/jormungandr-config.yaml .
Expand Down
2 changes: 2 additions & 0 deletions source/main/cardano/CardanoNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export type CardanoNodeConfig = {
shutdownTimeout: number, // Milliseconds to wait for cardano-node to gracefully shutdown
killTimeout: number, // Milliseconds to wait for cardano-node to be killed
updateTimeout: number, // Milliseconds to wait for cardano-node to update itself
cluster: string,
};

const CARDANO_UPDATE_EXIT_CODE = 20;
Expand Down Expand Up @@ -305,6 +306,7 @@ export class CardanoNode {
nodeImplementation,
cliBin,
stateDir: config.workingDir,
cluster: config.cluster,
});

this._node = node;
Expand Down
4 changes: 3 additions & 1 deletion source/main/cardano/CardanoWalletLauncher.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type WalletOpts = {
nodeImplementation: 'jormungandr' | 'cardano-node',
stateDir: string,
logStream: any,
cluster: string,
};

export async function CardanoWalletLauncher(
Expand All @@ -28,6 +29,7 @@ export async function CardanoWalletLauncher(
stateDir,
path,
walletArgs,
cluster,
} = walletOpts;
const walletStdio: string[] = ['pipe', 'pipe', 'pipe', 'ipc'];
const nodePath = dirname(nodeBin);
Expand All @@ -47,7 +49,7 @@ export async function CardanoWalletLauncher(
case 'jormungandr':
// This configuration is for the selfnode only
// The selfnode is identified by the unique genesis-block wallet arg
if (walletArgs.findIndex(arg => arg === '--genesis-block') > -1) {
if (cluster === 'selfnode') {
await configureJormungandrDeps(cliBin, stateDir);
Object.assign(envVariables, {
CARDANO_WALLET_STAKE_POOL_REGISTRY_URL:
Expand Down
2 changes: 2 additions & 0 deletions source/main/cardano/setupCardanoNodeMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const startCardanoNode = (
cliBin,
nodeBin,
nodeImplementation,
cluster,
} = launcherConfig;
const walletArgs = prepareArgs(launcherConfig);
const logFilePath = `${logsPrefix}/pub/`;
Expand All @@ -54,6 +55,7 @@ const startCardanoNode = (
tlsPath,
walletArgs,
workingDir,
cluster,
startupTimeout: NODE_STARTUP_TIMEOUT,
startupMaxRetries: NODE_STARTUP_MAX_RETRIES,
shutdownTimeout: NODE_SHUTDOWN_TIMEOUT,
Expand Down
1 change: 1 addition & 0 deletions source/main/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type LauncherConfig = {
logsPrefix: string,
nodeLogConfig: string,
nodeTimeoutSec: number,
cluster: string,
configuration: {
filePath: string,
key: string,
Expand Down

0 comments on commit 01cf841

Please sign in to comment.