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-977] Add sync-tolerance parameter for jormungandr wallet #1666

Merged
merged 12 commits into from
Nov 12, 2019
Merged
3 changes: 3 additions & 0 deletions nix/launcher-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ let
"launch"
"--genesis-block-hash" "${jormungandrLib.environments.${environment}.genesisHash}"
"--state-dir" dataDir.${os}
"--sync-tolerance" "${jormungandrLib.environments.${environment}.syncTolerance}"
"--random-port"
"--"
"--config" finalJormungandrCfgPath
];
Expand All @@ -60,6 +62,7 @@ let
"--port" "8088"
"--state-dir" dataDir.${os}
"--genesis-block" "${dataDir.${os}}${dirSep}block0.bin"
"--sync-tolerance" "300s"
"--"
"--secret" "${dataDir.${os}}${dirSep}secret.yaml"
];
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": "bd3d5897659b32abbde77298cb7c665cd29fb3d5",
"sha256": "1gsk335705crpi5sz2fsakjvnyw6mk7hb2wycy984gab1xrlzz4f",
"rev": "ae3dfa0484f837eb16b1d5203236d0af694a5738",
"sha256": "03927p9g3xl8aqmkx6s5wdp8rrg4bby1jjmpx4py5c7v3wnw0529",
"type": "tarball",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/bd3d5897659b32abbde77298cb7c665cd29fb3d5.tar.gz",
"url": "https://github.com/input-output-hk/cardano-wallet/archive/ae3dfa0484f837eb16b1d5203236d0af694a5738.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"version": "v2019-10-16"
},
Expand Down Expand Up @@ -66,10 +66,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "8f1720d5890b59781a0eb7b996f8ea33cbf02850",
"sha256": "1b29krkkaqz7amwha91paa9sb4i52qjkymr0vh8rprpdkjhag1nz",
"rev": "6b60b6ffa39d68fd3cf6da4ead2658a1181833cc",
"sha256": "05qm5m9wy6n8r0jwg9vvd8hmnw3w7jif491fdmyhbvsaikfsiwr6",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/8f1720d5890b59781a0eb7b996f8ea33cbf02850.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/6b60b6ffa39d68fd3cf6da4ead2658a1181833cc.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"js-chain-libs": {
Expand Down
1 change: 0 additions & 1 deletion source/common/types/cardano-node.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ export type FaultInjectionIpcRequest = [FaultInjection, boolean];

export type CardanoStatus = {
isNodeResponding: boolean,
isNodeSubscribed: boolean,
isNodeSyncing: boolean,
isNodeInSync: boolean,
hasBeenConnected: boolean,
Expand Down
13 changes: 3 additions & 10 deletions source/common/types/logging.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,15 @@ export type StateSnapshotLogParams = {
currentLocale: string,
isConnected: boolean,
isDev: boolean,
isForceCheckingNodeTime: boolean,
isMainnet: boolean,
isNodeInSync: boolean,
isNodeResponding: boolean,
isNodeSubscribed: boolean,
isNodeSyncing: boolean,
isNodeTimeCorrect: boolean,
isStaging: boolean,
isSynced: boolean,
isSystemTimeCorrect: boolean,
isSystemTimeIgnored: boolean,
isTestnet: boolean,
latestLocalBlockTimestamp: number,
latestNetworkBlockTimestamp: number,
localBlockHeight: number,
localTimeDifference: ?number,
networkBlockHeight: number,
currentTime: string,
syncPercentage: string,
localTip: ?Object,
networkTip: ?Object,
};
23 changes: 5 additions & 18 deletions source/renderer/app/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ import type {
GetNetworkInfoResponse,
NetworkInfoResponse,
} from './network/types';
import type { NetworkInfoQueryParams } from './network/requests/getNetworkInfo';

// Nodes Types
import type {
Expand Down Expand Up @@ -1048,19 +1047,13 @@ export default class AdaApi {
}
};

getNetworkInfo = async (
queryInfoParams?: NetworkInfoQueryParams
): Promise<GetNetworkInfoResponse> => {
const isForceNTPCheck = !!queryInfoParams;
const loggerText = `AdaApi::getNetworkInfo${
isForceNTPCheck ? ' (FORCE-NTP-CHECK)' : ''
}`;
getNetworkInfo = async (): Promise<GetNetworkInfoResponse> => {
Logger.debug('AdaApi::getNetworkInfo called');
try {
const networkInfo: NetworkInfoResponse = await getNetworkInfo(
this.config,
queryInfoParams
this.config
);
Logger.debug(`${loggerText} success`, { networkInfo });
Logger.debug('AdaApi::getNetworkInfo success', { networkInfo });

/* eslint-disable-next-line camelcase */
const { sync_progress, node_tip, network_tip } = networkInfo;
Expand All @@ -1080,13 +1073,9 @@ export default class AdaApi {
epoch: get(network_tip, 'epoch_number', 0),
slot: get(network_tip, 'slot_number', 0),
},
localTimeInformation: {
status: 'available',
difference: 0,
},
};
} catch (error) {
Logger.error(`${loggerText} error`, { error });
Logger.error('AdaApi::getNetworkInfo error', { error });
// @API TODO - Inspect this implementation once TLS support is implemented on the BE
if (error.code === TlsCertificateNotValidError.API_ERROR) {
throw new TlsCertificateNotValidError();
Expand Down Expand Up @@ -1173,8 +1162,6 @@ export default class AdaApi {
};

// No implementation here but can be overwritten
getLocalTimeDifference: Function;
setLocalTimeDifference: Function;
setSyncProgress: Function;
setNextUpdate: Function;
setLatestAppVersion: Function;
Expand Down
20 changes: 6 additions & 14 deletions source/renderer/app/api/network/requests/getNetworkInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ import type { RequestConfig } from '../../common/types';
import type { NetworkInfoResponse } from '../types';
import { request } from '../../utils/request';

export type NetworkInfoQueryParams = {
force_ntp_check: boolean,
};

export const getNetworkInfo = (
config: RequestConfig,
queryInfoParams?: NetworkInfoQueryParams
config: RequestConfig
): Promise<NetworkInfoResponse> =>
request(
{
method: 'GET',
path: '/v2/network/information',
...config,
},
queryInfoParams
);
request({
method: 'GET',
path: '/v2/network/information',
...config,
});
9 changes: 0 additions & 9 deletions source/renderer/app/api/network/types.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
// @flow
export type LocalTimeInformationStatus =
| 'unavailable'
| 'pending'
| 'available';

export type TipInfo = {
epoch: number,
slot: number,
Expand All @@ -13,10 +8,6 @@ export type GetNetworkInfoResponse = {
syncProgress: number,
localTip: TipInfo,
networkTip: TipInfo,
localTimeInformation: {
status: LocalTimeInformationStatus,
difference: ?number,
},
};

export type NetworkInfoResponse = {
Expand Down
40 changes: 4 additions & 36 deletions source/renderer/app/api/utils/patchAdaApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { getNetworkInfo } from '../network/requests/getNetworkInfo';
import { getLatestAppVersion } from '../nodes/requests/getLatestAppVersion';
import { GenericApiError } from '../common/errors';
import { Logger } from '../../utils/logging';
import type { NetworkInfoQueryParams } from '../network/requests/getNetworkInfo';
import type {
GetNetworkInfoResponse,
NetworkInfoResponse,
Expand All @@ -17,28 +16,17 @@ import type {
import type { GetNewsResponse } from '../news/types';

let LATEST_APP_VERSION = null;
let LOCAL_TIME_DIFFERENCE = 0;
let SYNC_PROGRESS = null;
let NEXT_ADA_UPDATE = null;
let APPLICATION_VERSION = null;
let FAKE_NEWSFEED_JSON: ?GetNewsResponse;

export default (api: AdaApi) => {
api.getLocalTimeDifference = async () =>
Promise.resolve(LOCAL_TIME_DIFFERENCE);

api.getNetworkInfo = async (
queryInfoParams?: NetworkInfoQueryParams
): Promise<GetNetworkInfoResponse> => {
api.getNetworkInfo = async (): Promise<GetNetworkInfoResponse> => {
Logger.debug('AdaApi::getNetworkInfo (PATCHED) called');
try {
const networkInfo: NetworkInfoResponse = await getNetworkInfo(
api.config,
queryInfoParams
);
Logger.debug('AdaApi::getNetworkInfo (PATCHED) success', {
networkInfo,
});
const networkInfo: NetworkInfoResponse = await getNetworkInfo(api.config);
Logger.debug('AdaApi::getNetworkInfo (PATCHED) success', { networkInfo });

/* eslint-disable-next-line camelcase */
const { sync_progress, node_tip, network_tip } = networkInfo;
Expand All @@ -48,7 +36,7 @@ export default (api: AdaApi) => {
: get(sync_progress, 'quantity', 0);

// extract relevant data before sending to NetworkStatusStore
const response = {
return {
syncProgress: SYNC_PROGRESS || syncProgress,
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
localTip: {
epoch: get(node_tip, 'epoch_number', 0),
Expand All @@ -58,32 +46,13 @@ export default (api: AdaApi) => {
epoch: get(network_tip, 'epoch_number', 0),
slot: get(network_tip, 'slot_number', 0),
},
localTimeInformation: {
status: 'available',
difference: 0 || LOCAL_TIME_DIFFERENCE,
},
};

// Since in test environment we run multiple NTP force-checks
// we need to protect ourselves from getting punished by the NTP
// service which results in 30 second delay in NTP check response.
// In order to simulate NTP force-check we use 250ms timeout.
const isForcedTimeDifferenceCheck = !!queryInfoParams;
return isForcedTimeDifferenceCheck
? new Promise(resolve => {
setTimeout(() => resolve(response), 250);
})
: response;
} catch (error) {
Logger.error('AdaApi::getNetworkInfo (PATCHED) error', { error });
throw new GenericApiError();
}
};

api.setLocalTimeDifference = async timeDifference => {
LOCAL_TIME_DIFFERENCE = timeDifference;
};

api.setSyncProgress = async syncProgress => {
SYNC_PROGRESS = syncProgress;
};
Expand Down Expand Up @@ -170,7 +139,6 @@ export default (api: AdaApi) => {

api.resetTestOverrides = () => {
LATEST_APP_VERSION = null;
LOCAL_TIME_DIFFERENCE = 0;
NEXT_ADA_UPDATE = null;
APPLICATION_VERSION = null;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ type Props = {
hasLoadedCurrentLocale: boolean,
hasLoadedCurrentTheme: boolean,
hasUnreadNews: boolean,
isCheckingSystemTime: boolean,
isNodeResponding: boolean,
isNodeSubscribed: boolean,
isNodeSyncing: boolean,
isNodeTimeCorrect: boolean,
isNewAppVersionAvailable: boolean,
isNewAppVersionLoading: boolean,
isNewAppVersionLoaded: boolean,
Expand Down Expand Up @@ -212,10 +209,7 @@ export default class SyncingConnecting extends Component<Props, State> {
onDownloadLogs,
disableDownloadLogs,
isNodeResponding,
isNodeSubscribed,
isNodeSyncing,
isNodeTimeCorrect,
isCheckingSystemTime,
hasBeenConnected,
isTlsCertInvalid,
isNodeStopping,
Expand Down Expand Up @@ -273,10 +267,6 @@ export default class SyncingConnecting extends Component<Props, State> {
onIconClick={onStatusIconClick}
nodeState={cardanoNodeState}
isNodeResponding={isNodeResponding}
isNodeSubscribed={isNodeSubscribed}
isNodeTimeCorrect={
isCheckingSystemTime ? undefined : isNodeTimeCorrect
}
isNodeSyncing={isNodeSyncing}
/>
</div>
Expand Down
10 changes: 2 additions & 8 deletions source/renderer/app/components/status/DaedalusDiagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ import CopyToClipboard from 'react-copy-to-clipboard';
import { Tooltip } from 'react-polymorph/lib/components/Tooltip';
import { TooltipSkin } from 'react-polymorph/lib/skins/simple/TooltipSkin';
import SVGInline from 'react-svg-inline';
// import {
// ALLOWED_TIME_DIFFERENCE,
// MAX_ALLOWED_STALL_DURATION,
// } from '../../config/timingConfig';
// import { UNSYNCED_BLOCKS_ALLOWED } from '../../config/numbersConfig';
// import { getNetworkEkgUrl } from '../../utils/network';
import DialogCloseButton from '../widgets/DialogCloseButton';
import closeCrossThin from '../../assets/images/close-cross-thin.inline.svg';
import iconCopy from '../../assets/images/clipboard-ic.inline.svg';
Expand Down Expand Up @@ -372,7 +366,7 @@ type Props = {
// localBlockHeight: number,
// networkBlockHeight: number,
currentLocale: string,
onForceCheckLocalTimeDifference: Function,
// onForceCheckLocalTimeDifference: Function,
onOpenStateDirectory: Function,
onOpenExternalLink: Function,
onRestartNode: Function,
Expand Down Expand Up @@ -949,7 +943,7 @@ export default class DaedalusDiagnostics extends Component<Props, State> {
};

checkTime = () => {
this.props.onForceCheckLocalTimeDifference();
// this.props.onForceCheckLocalTimeDifference();
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
this.restoreDialogCloseOnEscKey();
};

Expand Down
2 changes: 0 additions & 2 deletions source/renderer/app/config/numbersConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ export const LOVELACES_PER_ADA = 1000000;
export const MAX_INTEGER_PLACES_IN_ADA = 11;
export const DECIMAL_PLACES_IN_ADA = 6;
export const SIMPLE_DECIMAL_PLACES_IN_ADA = 2;
export const UNSYNCED_BLOCKS_ALLOWED = 6;
export const TX_UNCONFIRMED_THRESHOLD = 6;
export const TX_AGE_POLLING_THRESHOLD = 15 * 60 * 1000; // 15 minutes | unit: milliseconds
export const MAX_NTP_RECHECKS = 3;
4 changes: 0 additions & 4 deletions source/renderer/app/config/timingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ export const DELETE_WALLET_COUNTDOWN = 10; // unit: seconds
export const FORM_VALIDATION_DEBOUNCE_WAIT = 250; // unit: milliseconds
export const NODE_UPDATE_POLL_INTERVAL = 5000; // unit: milliseconds
export const ALLOWED_TIME_DIFFERENCE = 15 * 1000000; // 15 seconds | unit: microseconds
export const MAX_ALLOWED_STALL_DURATION = isTest ? 15000 : 2 * 60 * 1000; // 2 minutes / 15 seconds (isTest = true) | unit: milliseconds
export const NETWORK_STATUS_REQUEST_TIMEOUT = 30 * 1000; // 30 seconds | unit: milliseconds
export const NETWORK_STATUS_POLL_INTERVAL = 2000; // 2 seconds | unit: milliseconds
export const NTP_IGNORE_CHECKS_GRACE_PERIOD = isTest ? 500 : 35 * 1000; // 35 seconds | unit: milliseconds
export const NTP_RECHECK_TIMEOUT = 1 * 1000; // 1 second | unit: milliseconds;
export const WALLET_UTXO_API_REQUEST_INTERVAL = 5 * 1000; // 5 seconds | unit: milliseconds
export const STAKE_POOL_TOOLTIP_HOVER_WAIT = 700; // 700 milliseconds | unit: milliseconds
export const COPY_STATE_DIRECTORY_PATH_NOTIFICATION_DURATION = 10; // unit: seconds
Expand Down
8 changes: 1 addition & 7 deletions source/renderer/app/containers/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default class Root extends Component<Props> {
isSynced,
isNodeStopping,
isNodeStopped,
isSystemTimeCorrect,
isNotEnoughDiskSpace,
} = networkStatus;

Expand Down Expand Up @@ -49,12 +48,7 @@ export default class Root extends Component<Props> {
return React.Children.only(children);
}

if (
!isSynced ||
!hasLoadedWallets ||
!isSystemTimeCorrect ||
isNotEnoughDiskSpace
) {
if (!isSynced || !hasLoadedWallets || isNotEnoughDiskSpace) {
return <LoadingPage stores={stores} actions={actions} />;
}

Expand Down
13 changes: 7 additions & 6 deletions source/renderer/app/containers/loading/LoadingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export default class LoadingPage extends Component<InjectedProps> {
}

get isSystemTimeError() {
nikolaglumac marked this conversation as resolved.
Show resolved Hide resolved
const {
isSystemTimeCorrect,
isNodeStopping,
isNodeStopped,
} = this.networkStatus;
return !isSystemTimeCorrect && !isNodeStopping && !isNodeStopped;
return false;
// const {
// isSystemTimeCorrect,
// isNodeStopping,
// isNodeStopped,
// } = this.networkStatus;
// return !isSystemTimeCorrect && !isNodeStopping && !isNodeStopped;
}

get networkStatus() {
Expand Down
Loading