Skip to content

Commit

Permalink
[DDW-257] Set up Shelley cardano-node selfnode environment (#2462)
Browse files Browse the repository at this point in the history
* selfnode: switch to shelley-test-cluster

* [DDW-257] Selfnode setup

* [DDW-257] Fix build issues

* shelley-test-cluster: change path to projects.hsPkgs

* Fix yarn.lock

* Fix storybook

* [DDW-257] Fix selfnode bin names

* [DDW-257] Fix default SMASH URL handling

* [DDW-257] Genesis file update

* [DDW-257] Adds confirmation dialog when exiting selfnode

* [DDW-257] Remove unused cardano-wallet files

* [DDW-257] Fix local-cluster PID handling

* [DDW-257] Minor code improvements

* [DDW-257] Extract selfnode launcher code into a separate file

* [DDW-257] Move logging into CardanoNode

* [DDW-257] Fix wallet importers

* [DDW-257] Improve wallet importers

* [DDW-257] Updates README

* [DDW-257] Updates README

* [DDW-257] Updates README

* [DDW-257] Remove IOHK SMASH url from selfnode options

* [DDW-257] Improves wallet importer

* [DDW-257] README update

* [DDW-257] Integrate mock token metadata server into selfnode

* [DDW-257] Implements KEEP_LOCAL_CLUSTER_RUNNING env variable

* [DDW-257] Exposes eras on getNetworkParameters API response

* [DDW-257] Updates cardano-wallet and mary mnemonics

* [DDW-257] Convert all quantities to string before parsing it into BigNumber

* [DDW-257] Bump iohk-nix, Improve code

Co-authored-by: Samuel Leathers <samuel.leathers@iohk.io>
  • Loading branch information
nikolaglumac and disassembler committed Mar 19, 2021
1 parent d4e99a0 commit 65e654d
Show file tree
Hide file tree
Showing 38 changed files with 976 additions and 328 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Changelog

### Chores

- Updated `iohk-nix` to revision `bc4216c5` ([PR 2462](https://github.com/input-output-hk/daedalus/pull/2462))
- Updated `cardano-wallet` to revision `1fbb9f46` ([PR 2462](https://github.com/input-output-hk/daedalus/pull/2462))
- Re-enabled "Selfnode" environment ([PR 2462](https://github.com/input-output-hk/daedalus/pull/2462))
- Restored global link style on voting registration over screen ([PR 2453](https://github.com/input-output-hk/daedalus/pull/2453), [PR 2456](https://github.com/input-output-hk/daedalus/pull/2456))

## 4.0.2-FC3
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,31 @@ Daedalus - Cryptocurrency Wallet
#### Selfnode

1. Run `yarn nix:selfnode` from `daedalus`.
2. Run `yarn dev` from the subsequent `nix-shell`
3. Once Daedalus has started, and has gotten past the loading screen, run `yarn byron:wallet:importer` from a new terminal window. This is only required if you wish to import some funded wallets. It is also possible to import funded Yoroi wallets by running `yarn yoroi:wallet:importer` script.
2. Run `yarn dev` from the subsequent `nix-shell` (use `KEEP_LOCAL_CLUSTER_RUNNING` environment variable to keep the local cluster running after Daedalus exits: `KEEP_LOCAL_CLUSTER_RUNNING=true yarn dev`)
3. Once Daedalus has started and has gotten past the loading screen run the following commands from a new terminal window if you wish to import funded wallets:
- Byron wallets: `yarn byron:wallet:importer`
- Shelley wallets: `yarn shelley:wallet:importer`
- Mary wallets: `yarn mary:wallet:importer` (all of which contain native tokens which are visible once selfnode enters Mary era)
- Yoroi Byron wallets: `yarn yoroi:wallet:importer`
- _ITN Byron wallets:_ `yarn itn:byron:wallet:importer` **[Deprecated]**
- _ITN Shelley wallets:_ `yarn itn:shelley:wallet:importer` **[Deprecated]**

These scripts import 3 wallets by default. You can import up to 10 wallets by supplying `WALLET_COUNT` environment variable (e.g. `WALLET_COUNT=10 yarn mary:wallet:importer`).

List of all funded wallet recovery phrases can be found here: https://github.com/input-output-hk/daedalus/blob/develop/utils/api-importer/mnemonics.js

**Notes:**
- Cardano wallet process ID shown on the "Diagnostics" screen is faked and expected to match the Cardano node process ID.
- Stake pool metadata is fetched directly by default (IOHK SMASH server option is not available).
- Token metadata is fetched from a mock token metadata server which is automatically ran alongside the local cluster (there is no need to run it [manually](https://github.com/input-output-hk/daedalus#native-token-metadata-server))
- Daedalus will ask you if you wish to keep the local cluster running after it exits - this option is useful if you need to preserve local cluster state between Daedalus restarts.

| Parameter | Value
| --- | ---
| slotLength | 0.2 sec
| epochLength | 50 slots
| desiredPoolNumber | 3
| minimumUtxoValue | 1 ADA

#### Mainnet

Expand Down Expand Up @@ -91,7 +114,7 @@ Daedalus, by default, uses the following metadata server for all networks except
It's also possible to use a mock server locally by running the following command in `nix-shell` prior to starting Daedalus:
```
$ mock-token-metadata-server ./utils/cardano/native-tokens/registry.json
$ mock-token-metadata-server --port 65432 ./utils/cardano/native-tokens/registry.json
Mock metadata server running with url http://localhost:65432/
```
Expand Down
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ let
mock-token-metadata-server = (import self.sources.cardano-wallet { inherit system; gitrev = self.sources.cardano-wallet.rev; crossSystem = crossSystem walletPkgs.lib; }).mock-token-metadata-server;
cardano-shell = import self.sources.cardano-shell { inherit system; crossSystem = crossSystem shellPkgs.lib; };
cardano-cli = (import self.sources.cardano-node { inherit system; crossSystem = crossSystem nodePkgs.lib; }).cardano-cli;
local-cluster = if cluster == "selfnode" then (import self.sources.cardano-wallet { inherit system; gitrev = self.sources.cardano-wallet.rev; crossSystem = crossSystem walletPkgs.lib; }).project.hsPkgs.cardano-wallet.components.exes.local-cluster else null;
cardano-node-cluster = let
# Test wallets with known mnemonics
walletTestGenesisYaml = (self.sources.cardano-wallet + "/lib/shelley/test/data/cardano-node-shelley/genesis.yaml");
Expand Down
3 changes: 2 additions & 1 deletion nix/cardano-bridge.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ target, pkgs, cardanoWalletPkgs, runCommandCC, cardano-wallet, cardano-node, cardano-shell, cardano-cli, cardano-address, stdenv, lib }:
{ target, cardanoWalletPkgs, runCommandCC, cardano-wallet, cardano-node, cardano-shell, cardano-cli, cardano-address, lib, local-cluster ? null }:

let
commonLib = import ../lib.nix {};
Expand All @@ -17,6 +17,7 @@ in runCommandCC "daedalus-cardano-bridge" {
cp -f ${cardano-shell.haskellPackages.cardano-launcher.components.exes.cardano-launcher}/bin/cardano-launcher* .
cp -f ${cardano-node}/bin/cardano-node* .
cp -f ${cardano-cli}/bin/cardano-cli* .
${lib.optionalString (local-cluster != null) "cp -f ${local-cluster}/bin/local-cluster* ."}
${lib.optionalString (target == "x86_64-linux") ''
chmod +w -R .
for x in cardano-address cardano-node cardano-launcher cardano-cli cardano-wallet; do
Expand Down
10 changes: 5 additions & 5 deletions nix/launcher-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ let
genesisFile = mkConfigPath nodeConfigFiles "genesis.json";
topologyFile = mkConfigPath nodeConfigFiles "topology.yaml";
};
} // (lib.optionalAttrs (network == "selfnode") {
delegationCertificate = mkConfigPath nodeConfigFiles "delegation.cert";
signingKey = mkConfigPath nodeConfigFiles "signing.key";
});
} // (lib.optionalAttrs (__hasAttr "smashUrl" envCfg) {
};
} // (lib.optionalAttrs (network == "selfnode") {
selfnodeBin = mkBinPath "local-cluster";
mockTokenMetadataServerBin = mkBinPath "mock-token-metadata-server";
}) // (lib.optionalAttrs (__hasAttr "smashUrl" envCfg) {
smashUrl = envCfg.smashUrl;
}) // (lib.optionalAttrs (__hasAttr "metadataUrl" envCfg) {
metadataUrl = envCfg.metadataUrl;
Expand Down
12 changes: 6 additions & 6 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "cardano-wallet",
"rev": "f4d697a2c8f1df3acba578d9554508896d331b8d",
"sha256": "07awzp8ifgkh966qirlmr8igbx8hx5nlaw3zgflnic3lqc8672sc",
"rev": "1fbb9f46b483e9fef1d166b62e074778605cf794",
"sha256": "0bcnddpi14xg6csl4hf44x22d2gb86k8hibzqk52p077d1y2hbqp",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/f4d697a2c8f1df3acba578d9554508896d331b8d.tar.gz",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/1fbb9f46b483e9fef1d166b62e074778605cf794.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"gitignore": {
Expand Down Expand Up @@ -65,10 +65,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "60fe72cf807a4ec4409a53883d5c3af77f60f721",
"sha256": "0hpn4fsmnrrqzpj7j3fcmrjm5d3fb15vvbhjn825ipknjjvz6zwd",
"rev": "bc4216c5b0e14dbde5541763f4952f99c3c712fa",
"sha256": "0y5n3limj5dg1vgxyxafg0ky35qq7w97rr00gr3yl16xx5jrhs6w",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/60fe72cf807a4ec4409a53883d5c3af77f60f721.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/bc4216c5b0e14dbde5541763f4952f99c3c712fa.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"js-chain-libs": {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"nix:testnet": "NETWORK=testnet nix-shell --argstr nodeImplementation cardano --argstr cluster testnet",
"byron:wallet:importer": "node utils/api-importer/byron-wallet-importer.js",
"shelley:wallet:importer": "node utils/api-importer/shelley-wallet-importer.js",
"mary:wallet:importer": "node utils/api-importer/mary-wallet-importer.js",
"itn:byron:wallet:importer": "node utils/api-importer/itn-byron-wallet-importer.js",
"itn:shelley:wallet:importer": "node utils/api-importer/itn-shelley-wallet-importer.js",
"yoroi:wallet:importer": "node utils/api-importer/yoroi-wallet-importer.js",
Expand Down Expand Up @@ -177,7 +178,7 @@
"aes-js": "3.1.2",
"bech32": "2.0.0",
"bignumber.js": "9.0.1",
"bip39": "2.3.0",
"bip39": "3.0.2",
"blake2b": "2.1.3",
"blakejs": "1.1.0",
"borc": "2.1.2",
Expand All @@ -195,6 +196,7 @@
"electron-log-daedalus": "2.2.21",
"electron-store": "5.1.1",
"es6-error": "4.1.1",
"find-process": "1.4.4",
"form-data": "3.0.0",
"fs-extra": "9.0.1",
"glob": "7.1.6",
Expand All @@ -218,7 +220,6 @@
"pbkdf2": "3.0.17",
"pdfkit": "0.8.3",
"prop-types": "15.7.2",
"ps-list": "7.2.0",
"qr-image": "3.2.0",
"qrcode.react": "1.0.0",
"rc-slider": "9.5.1",
Expand Down Expand Up @@ -247,6 +248,7 @@
"shasum": "1.0.2",
"source-map-support": "0.5.19",
"spectron-fake-dialog": "0.0.1",
"tcp-port-used": "1.0.1",
"trezor-connect": "8.1.22-extended",
"unorm": "1.6.0",
"validator": "13.1.17"
Expand Down
18 changes: 15 additions & 3 deletions source/common/types/cardano-node.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ export type TlsConfig = {
key: Uint8Array,
};

export type CardanoNodeImplementations = 'cardano' | 'jormungandr';
export type CardanoNodeImplementations = 'cardano' | 'jormungandr' | 'selfnode';

export const CardanoNodeImplementationOptions: {
CARDANO: CardanoNodeImplementations,
JORMUNGANDR: CardanoNodeImplementations,
SELFNODE: CardanoNodeImplementations,
} = {
CARDANO: 'cardano',
JORMUNGANDR: 'jormungandr',
SELFNODE: 'selfnode',
};

export type NetworkNames =
Expand All @@ -23,6 +25,7 @@ export type NetworkNames =
| 'testnet'
| 'development'
| 'itn_rewards_v1'
| 'selfnode'
| string;

export type PlatformNames = 'win32' | 'linux' | 'darwin' | string;
Expand All @@ -33,6 +36,7 @@ export const NetworkNameOptions = {
testnet: 'testnet',
development: 'development',
itn_rewards_v1: 'itn_rewards_v1',
selfnode: 'selfnode',
};

export type CardanoNodeState =
Expand Down Expand Up @@ -66,6 +70,7 @@ export type CardanoPidOptions =
| 'testnet-PREVIOUS-CARDANO-PID'
| 'development-PREVIOUS-CARDANO-PID'
| 'itn_rewards_v1-PREVIOUS-CARDANO-PID'
| 'selfnode-PREVIOUS-CARDANO-PID'
| string;

export type CardanoNodeStorageKeys = {
Expand All @@ -76,7 +81,9 @@ export type CardanoNodeProcessNames =
| 'cardano-node'
| 'cardano-node.exe'
| 'jormungandr'
| 'jormungandr.exe';
| 'jormungandr.exe'
| 'local-cluster'
| 'local-cluster.exe';

export type ProcessNames = {
CARDANO_PROCESS_NAME: CardanoNodeProcessNames,
Expand All @@ -99,6 +106,11 @@ export const CardanoProcessNameOptions: {
linux: 'jormungandr',
darwin: 'jormungandr',
},
selfnode: {
win32: 'local-cluster.exe',
linux: 'local-cluster',
darwin: 'local-cluster',
},
};

/**
Expand Down Expand Up @@ -151,4 +163,4 @@ export const SHELLEY_TESTNET_NETWORK_ID = [1, 0, null];
export const STAGING_MAGIC = [633343913, 1];

// Cardano Selfnode network magic
export const SELFNODE_MAGIC = 459045235;
export const SELFNODE_MAGIC = MAINNET_MAGIC;
1 change: 1 addition & 0 deletions source/common/types/environment.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type Environment = {
isMacOS: boolean,
isLinux: boolean,
isBlankScreenFixActive: boolean,
keepLocalClusterRunning: boolean,
};

// constants
Expand Down
Loading

0 comments on commit 65e654d

Please sign in to comment.