Skip to content

[Wallet] Clean up forno mode#2584

Merged
annakaz merged 18 commits intomasterfrom
annakaz/forno
Feb 4, 2020
Merged

[Wallet] Clean up forno mode#2584
annakaz merged 18 commits intomasterfrom
annakaz/forno

Conversation

@annakaz
Copy link
Copy Markdown
Contributor

@annakaz annakaz commented Jan 28, 2020

Description

Fixes a couple bugs when the app that only appear when the app is build with FORNO_ENABLED_INITIALLY=true. The geth saga starts unnecessarily, and the web3 sync can fail if geth isn't yet connected. This fixes it by only starting gethSaga when not in forno mode, and by waiting for geth to be connected before checking web3 sync.

Note that the bulk of this PR is the forno/zeroSync rename so I have annotated the non rename changes to make it easier to review. This rename is necessary because while I had initially used zeroSync mode to make it clear the app is not syncing, we have been using the term forno internally (not zeroSync) so wanted to make the codebase consistent.

Tested

Tested a default forno build turning on and off forno. Tested a default geth build turning on and off forno.

Related issues

// Starting geth a second time this app session which will
// require an app restart, so show restart modal
this.showSwitchOffModal()
handleFornoToggle = (fornoMode: boolean) => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixes if else- if switching off forno mode, show the modal if need be, else just turn it off. If switching on forno mode, show switch on modal.

Previously, if switching off forno mode and modal not necessary, this would switch forno on (opposite of intended behavior)

yield put(setGethConnected(true))
}

export function* gethSagaIfNecessary() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only start geth saga if using geth

isGethConnectedSelector,
getNetworkConnected,
(gethConnected, networkConnected) => gethConnected && networkConnected
(fornoEnabled, gethConnected, networkConnected) =>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only care if gethConnected if geth is being using

render() {
const { t, appConnected, appSynced } = this.props
const { t, appConnected, appSynced, fornoEnabled } = this.props
const appSyncedIfNecessary = appSynced || fornoEnabled
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only care if app is synced if geth is being used

Comment thread packages/mobile/src/web3/saga.ts Outdated

switchWeb3ProviderForSyncMode(false)
// Ensure web3 is fully synced using new provider
yield take(GethActions.SET_GETH_CONNECTED)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Wait for geth to be connected before starting web3 sync

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, updated!

@annakaz annakaz requested review from a team, i1skn and jeanregisser January 28, 2020 23:49
@annakaz
Copy link
Copy Markdown
Contributor Author

annakaz commented Jan 28, 2020

Note that #2583 was introduced by #2526 as I did not test with a default forno build

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 29, 2020

Codecov Report

Merging #2584 into master will increase coverage by 0.12%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2584      +/-   ##
==========================================
+ Coverage   73.88%   74.01%   +0.12%     
==========================================
  Files         558      559       +1     
  Lines       13859    13932      +73     
  Branches     1433     1378      -55     
==========================================
+ Hits        10240    10312      +72     
+ Misses       3337     3336       -1     
- Partials      282      284       +2
Flag Coverage Δ
#mobile 74.13% <67.85%> (+0.06%) ⬆️
#web 73.84% <81.25%> (+0.21%) ⬆️
Impacted Files Coverage Δ
packages/mobile/src/send/actions.ts 100% <ø> (ø) ⬆️
packages/mobile/src/firebase/notifications.ts 46.87% <ø> (ø) ⬆️
packages/web/src/brandkit/common/Page.tsx 63.51% <ø> (ø) ⬆️
...es/mobile/src/escrow/EscrowedPaymentListScreen.tsx 100% <ø> (ø) ⬆️
.../paymentRequest/OutgoingPaymentRequestListItem.tsx 77.41% <0%> (+1.66%) ⬆️
.../paymentRequest/IncomingPaymentRequestListItem.tsx 81.25% <0%> (+9.82%) ⬆️
...es/mobile/src/verify/VerificationLoadingScreen.tsx 78.72% <100%> (ø) ⬆️
packages/mobile/src/firebase/actions.ts 100% <100%> (ø) ⬆️
packages/web/src/brandkit/common/CCLicense.tsx 100% <100%> (ø)
packages/mobile/src/identity/verification.ts 78.64% <100%> (+0.92%) ⬆️
... and 19 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 0c86082...2d213fd. Read the comment docs.

Copy link
Copy Markdown
Contributor

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

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

Looks great 👍 Thanks for making the naming consistent!

Copy link
Copy Markdown
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.

Looks great! Just one question about waitForGethConnectivity

@annakaz
Copy link
Copy Markdown
Contributor Author

annakaz commented Jan 30, 2020

Rearranged some forno-related state:

  • moved gethStartedThisSession to /geth as it should not be persisted across app restarts like other /geth state variables
  • moved promptFornoIfNeeded to /account
    a34b526

@annakaz annakaz merged commit 4eee470 into master Feb 4, 2020
lucasege pushed a commit that referenced this pull request Feb 4, 2020
@mcortesi mcortesi deleted the annakaz/forno branch February 14, 2020 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Wallet] Users who turn off forno should always see forno turned off [Wallet] Geth still sycning if forno initially enabled

3 participants