Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Hardening for ledger errors #11950

Merged
merged 3 commits into from
Nov 15, 2017
Merged

Hardening for ledger errors #11950

merged 3 commits into from
Nov 15, 2017

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented Nov 14, 2017

Fixes #11936
Fixes #11945

Changes contain two fixes:

  • for any calls: if a 403 is received back and proxy is enabled, ledger will disable proxy and try again
  • for transitionWalletToBat: if busyP returns a truthy value, transitionWalletToBat will be retried up to 3 times before quitting.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@bsclifton bsclifton added the priority/P2 Crashes. Loss of data. Severe memory leak. label Nov 14, 2017
@bsclifton bsclifton self-assigned this Nov 14, 2017
let fakeClock

before(function () {
fakeClock = sinon.useFakeTimers()
Copy link
Member Author

Choose a reason for hiding this comment

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

This is needed because code paths hitting setTimeout() will cause unit tests to crash (seemingly randomly) and in some cases hang. When the fake timer is destroyed, all methods registered with setTimeout are cleaned up.

console.log('ledger client is currently busy; transition will be retried on next launch')
return
}
const delayTime = random.randomInt({ min: 1, max: 500 })
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add higher values, because now we are setting timeout between 1ms and 500ms

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed 👍

@codecov-io
Copy link

codecov-io commented Nov 14, 2017

Codecov Report

Merging #11950 into master will increase coverage by 0.15%.
The diff coverage is 92.85%.

@@            Coverage Diff             @@
##           master   #11950      +/-   ##
==========================================
+ Coverage   53.21%   53.37%   +0.15%     
==========================================
  Files         274      274              
  Lines       26014    26031      +17     
  Branches     4167     4169       +2     
==========================================
+ Hits        13844    13893      +49     
+ Misses      12170    12138      -32
Flag Coverage Δ
#unittest 53.37% <92.85%> (+0.15%) ⬆️
Impacted Files Coverage Δ
app/browser/api/ledger.js 44.65% <92.85%> (+2.35%) ⬆️

bsclifton added a commit that referenced this pull request Nov 14, 2017
…re giving up)

Along with previous commits, this fixes #11936

Auditors: @NejcZdovc, @evq

includes updated min/max values per #11950 (review)
@@ -2160,7 +2167,13 @@ const transitionWalletToBat = () => {
}

if (client.busyP()) {
console.log('ledger client is currently busy; transition will be retried on next launch')
if (++busyRetryCount > 3) {
console.log('ledger client is currently busy; transition will be retried on next launch')
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 hide transition overlay when busy fails for the third time?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if it makes sense to hide it without providing a work-around. We don't want to encourage using the old servers indefinitely- I think it would be better to update the transition screen to provide a community link about stuck transitions.

cc: @alexwykoff

@alexwykoff
Copy link
Contributor

Is 403 the only case or is it also common for firewalls to redirect to a 'this site is blocked...' with a 200?

@bsclifton
Copy link
Member Author

@alexwykoff good question- I'm not sure

@bsclifton
Copy link
Member Author

bsclifton commented Nov 15, 2017

UPDATE: I confirmed Websense and Barracuda content filters should be using HTTP status code 403 by default for blocked content... however, the DENY action can be customized.

The only "true" way to do this would be to fetch a static page on the PIA host and hash it. If that hash is correct, the user has access. Otherwise, they may be on a proxy which is redirecting the content

@bsclifton bsclifton requested a review from petemill November 15, 2017 00:24
mrose17 and others added 2 commits November 14, 2017 21:24
bsclifton added a commit that referenced this pull request Nov 15, 2017
…re giving up)

Along with previous commits, this fixes #11936

Auditors: @NejcZdovc, @evq

includes updated min/max values per #11950 (review)
…re giving up)

Along with previous commits, this fixes #11936

Auditors: @NejcZdovc, @evq

includes updated min/max values per #11950 (review)
Copy link
Member

@bbondy bbondy left a comment

Choose a reason for hiding this comment

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

lgtm

@bsclifton bsclifton merged commit c369861 into master Nov 15, 2017
@bsclifton bsclifton deleted the issue-11945 branch November 15, 2017 04:35
bsclifton added a commit that referenced this pull request Nov 15, 2017
Hardening for ledger errors
bsclifton added a commit that referenced this pull request Nov 15, 2017
Hardening for ledger errors
bsclifton added a commit that referenced this pull request Nov 15, 2017
Hardening for ledger errors
@bsclifton
Copy link
Member Author

master c369861
0.21.x 82ef6f1
0.20.x aa91496
0.19.x a949f74

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature/rewards priority/P2 Crashes. Loss of data. Severe memory leak. QA/test-plan-required
Projects
None yet
7 participants