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

[Wallet] Prompt user to restart app when turning off Forno a second time #1708

Merged
merged 27 commits into from
Nov 14, 2019

Conversation

annakaz
Copy link
Contributor

@annakaz annakaz commented Nov 14, 2019

Description

Currently, when users start geth twice in one app session (for example, Forno -> geth -> Forno -> geth, or geth -> Forno -> geth), the app fails to switch to geth the second time. Now, the app shows a modal prompting users to restart the app when they are starting geth for the second time in a session. When the app restarts geth works fine.

For some reason starting geth a second time in a single app session leads to a minimum gas price error, because it cannot find the Gold Token address as geth does not think it is deployed. Had done some geth debugging with help from Kevin but no clear solution, so adding this modal as a workaround for now.

Also fixes an issue where switching on Forno leads to the app thinking it's disconnected until the app is restarted. This was not caught before because the disconnect behavior was conflated with long block times.

Tested

On pilot:
Started in Forno, sent a transaction, turned it off, turned it on, turned it off, modal pops up- restarted app and sent transaction in geth mode.

Other changes

Remove some unused icons
Added snapshot tests for GethAwareButton, FeeExchangeIcon

Related issues

Backwards compatibility

Yes

Copy link
Contributor

@jmrossy jmrossy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good! Just a few small comments

@@ -43,6 +43,7 @@ export function* waitForGethConnectivity() {

function* waitForGethInstance() {
const zeroSyncMode = yield select(zeroSyncSelector)
Logger.error(TAG, `zeroSync mode: ${zeroSyncMode}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why .error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this log 👍

@@ -372,7 +376,7 @@ export function* addAccountToWeb3Keystore(key: string, currentAccount: string, p
)
yield put(setAccountInWeb3Keystore(account))
} catch (e) {
Logger.debug(TAG + '@addAccountToWeb3Keystore', 'Failed to import raw key')
Logger.debug(TAG + '@addAccountToWeb3Keystore', `Failed to import raw key: ${e}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use .error here which can take e as the 3rd param? It formats the exception messages nicely

@@ -417,17 +421,29 @@ export function* ensureAccountInWeb3Keystore() {
}

export function* switchToGethFromZeroSync() {
Logger.debug(TAG + 'Switching to geth from zeroSync..')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, not +

// there is an issue where it cannot find deployed contracts.
// Restarting the app fixes this issue.
yield call(navigate, Screens.WalletHome)
Logger.debug(TAG + 'Showed message')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

}

onPressRestartModal = () => {
this.props.toggleZeroSyncMode(false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming has me a bit confused here. Any reason we dispatch this action here instead of restarting the app as the name says? I see below that the restart logic is in the saga instead, any reason we don't have it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I updated the name to onPressToggleWithRestartModal.

The restart logic is in the saga because we have to wait for geth to be turned on before restarting the app. Putting the restart logic here would require dispatching an action after the syncMode is done switching, and listening for that to know when to restart.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@codecov
Copy link

codecov bot commented Nov 14, 2019

Codecov Report

Merging #1708 into master will decrease coverage by 0.16%.
The diff coverage is 37.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1708      +/-   ##
==========================================
- Coverage   74.43%   74.26%   -0.17%     
==========================================
  Files         279      277       -2     
  Lines        7589     7617      +28     
  Branches      666      669       +3     
==========================================
+ Hits         5649     5657       +8     
- Misses       1825     1845      +20     
  Partials      115      115
Flag Coverage Δ
#mobile 74.26% <37.93%> (-0.17%) ⬇️
Impacted Files Coverage Δ
packages/mobile/test/schemas.ts 100% <ø> (ø) ⬆️
packages/mobile/src/images/Images.ts 100% <ø> (ø) ⬆️
packages/mobile/src/web3/reducer.ts 47.05% <0%> (-2.95%) ⬇️
packages/mobile/src/utils/AppRestart.ts 47.05% <0%> (-2.95%) ⬇️
packages/mobile/src/app/ErrorScreen.tsx 92.3% <100%> (ø) ⬆️
packages/mobile/src/web3/selectors.ts 83.33% <100%> (+3.33%) ⬆️
packages/mobile/src/app/AppLoading.tsx 81.81% <100%> (ø) ⬆️
packages/mobile/src/geth/saga.ts 23.25% <16.66%> (-0.56%) ⬇️
packages/mobile/src/app/saga.ts 58.33% <25%> (-0.71%) ⬇️
packages/mobile/src/account/CeloLite.tsx 79.41% <61.11%> (-20.59%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 236ce42...afca2ab. Read the comment docs.

@annakaz
Copy link
Contributor Author

annakaz commented Nov 14, 2019

Added snapshot tests for some unrelated components (GethAwareButton, FeeExchangeIcon) to increase code coverage

@annakaz annakaz assigned jmrossy and unassigned annakaz Nov 14, 2019
@jmrossy jmrossy assigned annakaz and unassigned jmrossy Nov 14, 2019
@annakaz annakaz added the automerge Have PR merge automatically when checks pass label Nov 14, 2019
@celo-ci-bot-user celo-ci-bot-user merged commit 7feadc0 into master Nov 14, 2019
@celo-ci-bot-user celo-ci-bot-user deleted the annakaz/forno-modal branch November 14, 2019 19:23
aaronmgdr added a commit that referenced this pull request Nov 15, 2019
* master: (81 commits)
  Make styling more consistent in validator quick start and add password prompt to account:unlock (#1731)
  New Version for contractkit (#1727)
  Remove end-to-end attestations test from circle (#1739)
  Added helper function to get the list of current validators (#1713)
  Fix flaky end-to-end transfer, protocol unit tests (#1734)
  Add AccountClaim to Metadata (#1663)
  [Wallet] Set default gradle properties (#1629)
  Update genesis block after adding parent signatures to block header (#1732)
  Removed end-to-end-geth-integration-sync-test job in workflow (#1730)
  Change the event we emit when selecting issuers (#1706)
  [Wallet] Prompt user to restart app when turning off Forno a second time (#1708)
  Check in spanish verification translations (#1726)
  [Wallet] Style fixes on iOS for verification and backup flows (#1718)
  [Wallet] Reset isRedeemingInvite on rehydrate (#1716)
  Adjust e2e transfer and governance tests to match new fee distribution and eliminate ProposerFraction (#1585)
  [Wallet] Add more local currencies (#1698)
  Switch to correct cluster when fauceting (#1687)
  [Wallet] Use the country of the phone number for determining the default local currency (#1684)
  [Wallet] Limit QR code scanner to 1 code per second (#1676)
  Update Dark backgrounds text color (#1677)
  ...

# Conflicts:
#	packages/web/pages/_app.tsx
#	packages/web/src/dev/BuildPage.tsx
#	packages/web/src/dev/Cover.tsx
#	packages/web/src/dev/StackSection.tsx
#	yarn.lock
aaronmgdr added a commit that referenced this pull request Nov 26, 2019
* master: (70 commits)
  Make styling more consistent in validator quick start and add password prompt to account:unlock (#1731)
  New Version for contractkit (#1727)
  Remove end-to-end attestations test from circle (#1739)
  Added helper function to get the list of current validators (#1713)
  Fix flaky end-to-end transfer, protocol unit tests (#1734)
  Add AccountClaim to Metadata (#1663)
  [Wallet] Set default gradle properties (#1629)
  Update genesis block after adding parent signatures to block header (#1732)
  Removed end-to-end-geth-integration-sync-test job in workflow (#1730)
  Change the event we emit when selecting issuers (#1706)
  [Wallet] Prompt user to restart app when turning off Forno a second time (#1708)
  Check in spanish verification translations (#1726)
  [Wallet] Style fixes on iOS for verification and backup flows (#1718)
  [Wallet] Reset isRedeemingInvite on rehydrate (#1716)
  Adjust e2e transfer and governance tests to match new fee distribution and eliminate ProposerFraction (#1585)
  [Wallet] Add more local currencies (#1698)
  Switch to correct cluster when fauceting (#1687)
  [Wallet] Use the country of the phone number for determining the default local currency (#1684)
  [Wallet] Limit QR code scanner to 1 code per second (#1676)
  Update Dark backgrounds text color (#1677)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
5 participants