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

[DDW-433] Expose Cardano Node states to the UI #1118

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b5df029
[DEVOPS-998] [CO-354] Update cardano-sl to latest 1.3.1
rvl Oct 1, 2018
42a0144
Merge pull request #1104 from input-output-hk/devops-998-cardano-sl
rvl Oct 3, 2018
43857e7
[DDW-433] Expose Cardano node states on the Loading screen
nikolaglumac Oct 11, 2018
f481be7
Merge branch 'develop' into feature/ddw-433-expose-cardano-node-state…
nikolaglumac Oct 11, 2018
e6bac59
Merge branch 'develop' into feature/ddw-433-expose-cardano-node-state…
nikolaglumac Oct 12, 2018
9e313e3
Merge branch 'develop' into feature/ddw-433-expose-cardano-node-state…
nikolaglumac Oct 12, 2018
8e3cd08
Merge branch 'develop' into feature/ddw-433-expose-cardano-node-state…
nikolaglumac Oct 12, 2018
007f486
[DDW-433] Improve restarting link UX on Network Status screen
nikolaglumac Oct 12, 2018
85e6308
[DDW-433] Bump cardano version
nikolaglumac Oct 14, 2018
626f416
Merge branch 'develop' into feature/ddw-433-expose-cardano-node-state…
nikolaglumac Oct 15, 2018
95f4cce
[DDW-433] add unrecoverable state to cardano node
DominikGuzei Oct 15, 2018
f91bb08
[DDW-433] increase update wait timeout to 60 seconds
DominikGuzei Oct 15, 2018
1f83c91
[DDW-433] Add status message for Cardano Node unrecoverable state
nikolaglumac Oct 15, 2018
41de9b9
Merge branch 'develop' into feature/ddw-433-expose-cardano-node-state…
nikolaglumac Oct 15, 2018
1b13091
[DDW-433] Add CHANGELOG entry
nikolaglumac Oct 15, 2018
d30f9b0
[DDW-433] Fix isNodeSyncing state logic
nikolaglumac Oct 15, 2018
f58ada2
[DDW-433] Fix remainingUnsyncedBlocks presentation on the NetworkStat…
nikolaglumac Oct 15, 2018
ee6435a
[DDW-433] Bump cardano version
nikolaglumac Oct 15, 2018
f80e4b5
[DDW-433] Remove unnecessary dot at the end of loading screen messages
nikolaglumac Oct 16, 2018
4901736
Merge branch 'develop' into feature/ddw-433-expose-cardano-node-state…
nikolaglumac Oct 16, 2018
6ef5d0a
[DDW-433] Inject missing Japanese translations
nikolaglumac Oct 16, 2018
298c227
[DDW-433] Merge release/0.11.1 branch and fix conflicts
nikolaglumac Oct 16, 2018
9061f2d
[DDW-440] Bump Daedalus version in package.json and CHANGELOG
nikolaglumac Oct 16, 2018
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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Changelog
=========

## vNext
## 0.12.0
=======

### Features
Expand All @@ -15,7 +15,7 @@ Changelog
- Implemented "New data layer migration" screen ([PR 1096](https://github.com/input-output-hk/daedalus/pull/1096))
- Implemented sending of `cert` and `key` with API requests in order to enable 2-way TLS authentication ([PR 1072](https://github.com/input-output-hk/daedalus/pull/1072))
- Implemented support for Cardano node "structured logging" ([PR 1092](https://github.com/input-output-hk/daedalus/pull/1092), [PR 1122](https://github.com/input-output-hk/daedalus/pull/1122))
- Implemented the IPC driven Cardano node / Daedalus communication ([PR 1075](https://github.com/input-output-hk/daedalus/pull/1075), [PR 1107](https://github.com/input-output-hk/daedalus/pull/1107), [PR 1109](https://github.com/input-output-hk/daedalus/pull/1109), [PR 1115](https://github.com/input-output-hk/daedalus/pull/1115), [PR 1119](https://github.com/input-output-hk/daedalus/pull/1119))
- Implemented the IPC driven Cardano node / Daedalus communication ([PR 1075](https://github.com/input-output-hk/daedalus/pull/1075), [PR 1107](https://github.com/input-output-hk/daedalus/pull/1107), [PR 1109](https://github.com/input-output-hk/daedalus/pull/1109), [PR 1115](https://github.com/input-output-hk/daedalus/pull/1115), [PR 1118](https://github.com/input-output-hk/daedalus/pull/1118), [PR 1119](https://github.com/input-output-hk/daedalus/pull/1119))
- Improved the loading UX ([PR 723](https://github.com/input-output-hk/daedalus/pull/723))
- Improved the NTP check handling ([PR 1086](https://github.com/input-output-hk/daedalus/pull/1086))
- Improved the transaction details text selection ([PR 1073](https://github.com/input-output-hk/daedalus/pull/1073), [PR 1095](https://github.com/input-output-hk/daedalus/pull/1095))
Expand Down
4 changes: 2 additions & 2 deletions cardano-sl-src.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"url": "https://github.com/input-output-hk/cardano-sl",
"rev": "993d6be21d0aa57f5232f17ef67f9d2e15172ced",
"sha256": "15y8b116km1v7yxkfhskjsqy31xiban2zpkkzaxz6dra49hm9hy9",
"rev": "a75d9d3c3f43786347e80bccf6d7cf9d12a98c0a",
"sha256": "04sld17bg2rh64gm45ypnq7nhfy17qgwqds2ncn9hx5dgcvvwia8",
"fetchSubmodules": false
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "daedalus",
"productName": "Daedalus",
"version": "0.11.1",
"version": "0.12.0",
"description": "Cryptocurrency Wallet",
"main": "./dist/main/index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion source/common/types/cardanoNode.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const NetworkNameOptions = {

export type CardanoNodeState = (
'stopped' | 'starting' | 'running' | 'stopping' | 'updating' |
'updated' | 'crashed' | 'errored' | 'exiting'
'updated' | 'crashed' | 'errored' | 'exiting' | 'unrecoverable'
);

export const CardanoNodeStates: {
Expand All @@ -36,6 +36,7 @@ export const CardanoNodeStates: {
UPDATED: CardanoNodeState;
CRASHED: CardanoNodeState;
ERRORED: CardanoNodeState;
UNRECOVERABLE: CardanoNodeState;
} = {
STARTING: 'starting',
RUNNING: 'running',
Expand All @@ -46,6 +47,7 @@ export const CardanoNodeStates: {
UPDATED: 'updated',
CRASHED: 'crashed',
ERRORED: 'errored',
UNRECOVERABLE: 'unrecoverable',
};

export type CardanoPidOptions = (
Expand Down
12 changes: 10 additions & 2 deletions source/main/cardano/CardanoNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type StateTransitions = {
onUpdated: () => void,
onCrashed: (code: number, signal: string) => void,
onError: (error: Error) => void,
onUnrecoverable: () => void,
}

type CardanoNodeIpcMessage = {
Expand Down Expand Up @@ -181,7 +182,7 @@ export class CardanoNode {
if (!nodeCanBeStarted) {
return Promise.reject('CardanoNode: Cannot be started.');
}
if (!isForced && this._startupTries >= config.startupMaxRetries) {
if (this._isUnrecoverable(config) && !isForced) {
return Promise.reject('CardanoNode: Too many startup retries.');
}
// Setup
Expand Down Expand Up @@ -412,6 +413,8 @@ export class CardanoNode {
this._changeToState(CardanoNodeStates.STOPPED);
} else if (this._state === CardanoNodeStates.UPDATING && code === CARDANO_UPDATE_EXIT_CODE) {
this._changeToState(CardanoNodeStates.UPDATED);
} else if (this._isUnrecoverable(_config)) {
this._changeToState(CardanoNodeStates.UNRECOVERABLE);
} else {
this._changeToState(CardanoNodeStates.CRASHED, code, signal);
}
Expand All @@ -437,6 +440,7 @@ export class CardanoNode {
case CardanoNodeStates.UPDATING: return _transitionListeners.onUpdating();
case CardanoNodeStates.UPDATED: return _transitionListeners.onUpdated();
case CardanoNodeStates.CRASHED: return _transitionListeners.onCrashed(...args);
case CardanoNodeStates.UNRECOVERABLE: return _transitionListeners.onUnrecoverable();
default:
}
}
Expand Down Expand Up @@ -599,6 +603,10 @@ export class CardanoNode {
} catch (_) {
await this._ensureCurrentCardanoNodeIsNotRunning();
}
}
};

_isUnrecoverable = (config: CardanoNodeConfig) => (
this._startupTries >= config.startupMaxRetries
);

}
5 changes: 3 additions & 2 deletions source/main/cardano/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const startCardanoNode = (node: CardanoNode, launcherConfig: Object) => {
startupMaxRetries: 5,
shutdownTimeout: 30000,
killTimeout: 30000,
updateTimeout: 20000,
updateTimeout: 60000,
};
return node.start(config);
};
Expand Down Expand Up @@ -76,7 +76,8 @@ export const setupCardano = (
Logger.info(`CardanoNode crashed with code ${code}. Restarting in ${restartTimeout}ms …`);
setTimeout(() => restartCardanoNode(cardanoNode), restartTimeout);
},
onError: () => {}
onError: () => {},
onUnrecoverable: () => {}
});
startCardanoNode(cardanoNode, launcherConfig);

Expand Down
98 changes: 92 additions & 6 deletions source/renderer/app/components/loading/Loading.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React, { Component } from 'react';
import { includes } from 'lodash';
import SVGInline from 'react-svg-inline';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
Expand All @@ -9,14 +10,51 @@ import { ButtonSkin } from 'react-polymorph/lib/skins/simple/ButtonSkin';
import SystemTimeErrorOverlay from './SystemTimeErrorOverlay';
import LoadingSpinner from '../widgets/LoadingSpinner';
import daedalusLogo from '../../assets/images/daedalus-logo-loading-grey.inline.svg';
import { CardanoNodeStates } from '../../../../common/types/cardanoNode.types';
import styles from './Loading.scss';
import type { ReactIntlMessage } from '../../types/i18nTypes';
import type { CardanoNodeState } from '../../../../common/types/cardanoNode.types';
import { REPORT_ISSUE_TIME_TRIGGER } from '../../config/timingConfig';

let connectingInterval = null;
let syncingInterval = null;

const messages = defineMessages({
starting: {
id: 'loading.screen.startingCardanoMessage',
defaultMessage: '!!!Starting Cardano node',
description: 'Message "Starting Cardano node" on the loading screen.'
},
stopping: {
id: 'loading.screen.stoppingCardanoMessage',
defaultMessage: '!!!Stopping Cardano node',
description: 'Message "Stopping Cardano node" on the loading screen.'
},
stopped: {
id: 'loading.screen.stoppedCardanoMessage',
defaultMessage: '!!!Cardano node stopped',
description: 'Message "Cardano node stopped" on the loading screen.'
},
updating: {
id: 'loading.screen.updatingCardanoMessage',
defaultMessage: '!!!Updating Cardano node',
description: 'Message "Updating Cardano node" on the loading screen.'
},
updated: {
id: 'loading.screen.updatedCardanoMessage',
defaultMessage: '!!!Cardano node updated',
description: 'Message "Cardano node updated" on the loading screen.'
},
crashed: {
id: 'loading.screen.crashedCardanoMessage',
defaultMessage: '!!!Cardano node crashed',
description: 'Message "Cardano node crashed" on the loading screen.'
},
unrecoverable: {
id: 'loading.screen.unrecoverableCardanoMessage',
defaultMessage: '!!!Unable to start Cardano node. Please submit a support request.',
description: 'Message "Unable to start Cardano node. Please submit a support request." on the loading screen.'
},
connecting: {
id: 'loading.screen.connectingToNetworkMessage',
defaultMessage: '!!!Connecting to network',
Expand Down Expand Up @@ -45,7 +83,7 @@ const messages = defineMessages({
reportIssueButtonLabel: {
id: 'loading.screen.reportIssue.buttonLabel',
defaultMessage: '!!!Report an issue',
description: 'Report an issue button label on the loading .'
description: 'Report an issue button label on the loading.'
},
});

Expand All @@ -58,6 +96,7 @@ type State = {
type Props = {
currencyIcon: string,
apiIcon: string,
cardanoNodeState: ?CardanoNodeState,
hasBeenConnected: boolean,
isConnected: boolean,
isSynced: boolean,
Expand Down Expand Up @@ -166,13 +205,44 @@ export default class Loading extends Component<Props, State> {
}
};

_getConnectingMessage = () => (
this.props.hasBeenConnected ? messages.reconnecting : messages.connecting
);
_getConnectingMessage = () => {
const { cardanoNodeState, hasBeenConnected } = this.props;
let connectingMessage;
switch (cardanoNodeState) {
case null:
case CardanoNodeStates.STARTING:
connectingMessage = messages.starting;
break;
case CardanoNodeStates.STOPPING:
case CardanoNodeStates.EXITING:
connectingMessage = messages.stopping;
break;
case CardanoNodeStates.STOPPED:
connectingMessage = messages.stopped;
break;
case CardanoNodeStates.UPDATING:
connectingMessage = messages.updating;
break;
case CardanoNodeStates.UPDATED:
connectingMessage = messages.updated;
break;
case CardanoNodeStates.CRASHED:
case CardanoNodeStates.ERRORED:
connectingMessage = messages.crashed;
break;
case CardanoNodeStates.UNRECOVERABLE:
connectingMessage = messages.unrecoverable;
break;
default: // also covers CardanoNodeStates.RUNNING state
connectingMessage = hasBeenConnected ? messages.reconnecting : messages.connecting;
}
return connectingMessage;
};

_renderLoadingScreen = () => {
const { intl } = this.context;
const {
cardanoNodeState,
isConnected,
isSystemTimeCorrect,
isSynced,
Expand All @@ -186,9 +256,21 @@ export default class Loading extends Component<Props, State> {
} = this.props;

if (!isConnected) {
const finalCardanoNodeStates = [
CardanoNodeStates.STOPPED,
CardanoNodeStates.UPDATED,
CardanoNodeStates.CRASHED,
CardanoNodeStates.ERRORED,
CardanoNodeStates.UNRECOVERABLE
];
const headlineClasses = classNames([
styles.headline,
includes(finalCardanoNodeStates, cardanoNodeState) ? styles.withoutAnimation : null,
]);

return (
<div className={styles.connecting}>
<h1 className={styles.headline}>
<h1 className={headlineClasses}>
{intl.formatMessage(this._getConnectingMessage())}
</h1>
</div>
Expand Down Expand Up @@ -229,6 +311,7 @@ export default class Loading extends Component<Props, State> {
render() {
const { intl } = this.context;
const {
cardanoNodeState,
currencyIcon,
apiIcon,
isConnected,
Expand Down Expand Up @@ -264,7 +347,10 @@ export default class Loading extends Component<Props, State> {
const apiLoadingLogo = apiIcon;

const canReportConnectingIssue = (
!isConnected && connectingTime >= REPORT_ISSUE_TIME_TRIGGER
!isConnected && (
connectingTime >= REPORT_ISSUE_TIME_TRIGGER ||
cardanoNodeState === CardanoNodeStates.UNRECOVERABLE
)
);
const canReportSyncingIssue = (
isConnected && !isSynced && syncingTime >= REPORT_ISSUE_TIME_TRIGGER
Expand Down
4 changes: 3 additions & 1 deletion source/renderer/app/components/loading/Loading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ $adaLogoWidth: 43px;
color: var(--theme-connecting-text-color);
.headline {
overflow: visible;
@include animated-ellipsis($width: 16px);
&:not(.withoutAnimation) {
@include animated-ellipsis($width: 16px);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const messages = defineMessages({

type Props = {
logFiles: LogFiles,
compressedLogsFile: ?string,
onCancel: Function,
onSubmit: Function,
onSubmitManually: Function,
Expand Down Expand Up @@ -151,7 +152,7 @@ export default class BugReportDialog extends Component<Props, State> {
this.props.onGetLogs();
}

componentWillReceiveProps(nextProps: Object) {
componentWillReceiveProps(nextProps: Props) {
const compressedLogsFileChanged = (
!this.props.compressedLogsFile &&
!!nextProps.compressedLogsFile
Expand Down
Loading