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

Ledger table entries removed after payment is processed #12245

Closed
srirambv opened this issue Dec 11, 2017 · 12 comments
Closed

Ledger table entries removed after payment is processed #12245

srirambv opened this issue Dec 11, 2017 · 12 comments

Comments

@srirambv
Copy link
Collaborator

Description

Ledger table entries removed after payment is processed

Steps to Reproduce

  1. Clear existing profile
  2. Launch browser from console with LEDGER_ENVIRONMENT=staging <path to browser>
  3. Enable payments, Claim free tokens
  4. Visit 5-6 sites to add them in the ledger table
  5. Close browser and change reconcileStamp in session-store-1 and ledger-state.json file to an older date to trigger payment process
  6. Start browser with LEDGER_NO_FUZZING=true LEDGER_VERBOSE=true LEDGER_ENVIRONMENT=staging <path to browser>, ensure Next contribution reads Overdue
  7. Wait till the payment is processed and the Next contribution reads proper date and account balance is reduced
  8. Quit and relaunch browser with LEDGER_NO_FUZZING=true LEDGER_VERBOSE=true LEDGER_ENVIRONMENT=staging <path to browser>
  9. Wait for a couple of minutes, some of the ledger entries disappear from the list

Actual result:
Ledger table entries removed after payment is processed.
https://youtu.be/pKeH_n2Ll6M

Expected result:
Ledger table entries should not be lost when browser is quit and relaunched

Reproduces how often:
100%

Brave Version

about:brave info:

Brave 0.19.113
rev 043c506
Muon 4.5.25
libchromiumcontent 63.0.3239.84
V8 6.3.292.46
Node.js 7.9.0
Update Channel Release
OS Platform Microsoft Windows
OS Release 10.0.16299
OS Architecture x64

Reproducible on current live release:
Not sure. Yet to verify

Additional Information

#9938
cc: @kjozwiak @LaurenWags @mrose17 @evq

@srirambv srirambv added 0.19.x issue first seen in 0.19.x bug cr63 feature/rewards initiative/bat-payments OS/Windows priority/P2 Crashes. Loss of data. Severe memory leak. labels Dec 11, 2017
@srirambv srirambv added this to the 0.19.x + C63 (Release Channel) milestone Dec 11, 2017
@srirambv
Copy link
Collaborator Author

Payment history has different ledger entries compared to what is shown on the ledger table. Some of the deleted entries are restored and gets removed again
table

@bsclifton
Copy link
Member

This may be intended behavior- since the voting process takes place, all entries used during that process may be getting removed (so that it won’t count them again)

@mrose17 @evq could you help clarify? I can start to look into the code to double check

@srirambv
Copy link
Collaborator Author

Same behaviour on production wallet as well.

@srirambv
Copy link
Collaborator Author

I found something interesting. When I close the browser and open nothing happens to the table. When I switched to the inactive tabs which were having the sites from the table, most entries vanished from the ledger table and finally 3-4 of them were back on the ledger table

@bsclifton
Copy link
Member

Confirmed with @mrose17 - the ledger should ALWAYS keep the last 30 days of activity (ex: items would only fall off the list off if 30 days went by)

Assigning myself to check this out

@bsclifton bsclifton assigned bsclifton and unassigned NejcZdovc Dec 11, 2017
@brave brave deleted a comment from cryptoaddict1 Dec 11, 2017
@bsclifton
Copy link
Member

bsclifton commented Dec 12, 2017

@NejcZdovc is this intentional?

During the prune synopsis, it calls an action (which saves synopsis)... but then it also saves synopsis itself

}
const json = synopsis.toJSON()
if (!json || !json.publishers) {
return state
}
appActions.onPruneSynopsis(json.publishers)
return ledgerState.saveSynopsis(state, json.publishers)
}

case appConstants.APP_ON_PRUNE_SYNOPSIS:
{
const publishers = action.get('publishers')
if (publishers == null) {
break
}
state = ledgerState.saveSynopsis(state, publishers)
break
}

@NejcZdovc
Copy link
Contributor

@bsclifton yes this is intentionally. So we need to save this new state into our state, because when pruning actually happens is here

const data = (synopsis) && (ballots > 0) && synopsisNormalizer(state, null, false, true)
, where we don't return state back. But we also need to call ledgerState.saveSynopsis so that we have up to date state (same as in the action) which we can use then in run function

@bsclifton
Copy link
Member

bsclifton commented Dec 12, 2017

@NejcZdovc ah ok- makes sense. Thanks for the explanation 😄 When I was debugging, I saw that and it definitely caught my eye (even though I reviewed the original PR LOL)

@srirambv the history issue you also reported may be related to this. After you see the entry disappear, can you please try hitting Ctrl + R and see if it refreshes?

@LaurenWags @kjozwiak if my suspicion is correct, this bug would only be happening on Windows. Are either of you able to repro on macOS?

@srirambv
Copy link
Collaborator Author

@bsclifton Am unable to reproduce the issue consistently now on the latest build. Entries are not getting removed when I follow the steps from initial issue

@bsclifton
Copy link
Member

@srirambv awesome- I'd like to propose closing the issue until we see it again and can confirm the above (do the entries re-show if you do Ctrl + R)

@srirambv
Copy link
Collaborator Author

Sounds good. Will try to reproduce and see if Ctrl+R brings back the entries 👍

@srirambv
Copy link
Collaborator Author

Unable to reproduce on 0.19.117. All entries are retained even after payment is processed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants