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

Adds recovery path for may payout problem #5495

Merged
merged 1 commit into from
May 11, 2020
Merged

Adds recovery path for may payout problem #5495

merged 1 commit into from
May 11, 2020

Conversation

NejcZdovc
Copy link
Contributor

@NejcZdovc NejcZdovc commented May 8, 2020

Resolves brave/brave-browser#9684

You can find diagram of what we do here https://github.com/brave/rewards/blob/master/monodraw/may_ads_payout_recovery.svg

Submitter Checklist:

Test Plan:

plan 1:

  • start browser from the master
  • enable rewards
  • fetch promotions
  • claim promotion
  • make sure that promotion was claimed
  • close the browser
  • open db and clear unblinded_tokens table. Change change status of promotion to 1 and creds_batch status to 3. Set [] for public_keys in promotion table
  • start browser from this PR
  • make sure that balance is now displayed correctly

plan 2:

  • start browser from the master
  • enable rewards
  • fetch promotions
  • claim promotion
  • make sure that promotion was claimed
  • close the browser
  • open db and change status of promotion to 1 and creds_batch status to 3. Override signed_creds value with blinded_creds value.
  • start browser from this PR
  • make sure that in the logs you see post out to /promotions/reportclobberedclaims
  • open db and check that promotion has status 6 and creds_batch has status 5

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@NejcZdovc NejcZdovc self-assigned this May 8, 2020
@NejcZdovc NejcZdovc force-pushed the recover-payout branch 2 times, most recently from d68cbcf to 8fd7e4c Compare May 8, 2020 14:53
@NejcZdovc NejcZdovc added this to the 1.10.x - Nightly milestone May 8, 2020
@NejcZdovc NejcZdovc marked this pull request as ready for review May 11, 2020 16:24
@NejcZdovc NejcZdovc requested a review from gdregalo as a code owner May 11, 2020 16:24
@NejcZdovc NejcZdovc requested a review from a team May 11, 2020 18:06
@@ -34,7 +34,7 @@ const char kUseRewardsStagingServer[] = "brave.rewards.use_staging_server";
const char kStatePromotionLastFetchStamp[] =
"brave.rewards.promotion_last_fetch_stamp";
const char kStatePromotionCorruptedMigrated[] =
"brave.rewards.promotion_corrupted_migrated";
"brave.rewards.promotion_corrupted_migrated2";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can just update this to 2 as we do the same thing that we do with version 1 and more

Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

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

LGTM

@NejcZdovc NejcZdovc added CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux CI/skip-macos-x64 Do not run CI builds for macOS x64 labels May 11, 2020
@NejcZdovc
Copy link
Contributor Author

CI was aborted on windows, restarting

@kjozwiak
Copy link
Member

kjozwiak commented May 12, 2020

Verification PASSED on macOS 10.15.4 x64 Catalina using the following build:

Brave | 1.10.48 Chromium: 81.0.4044.138 (Official Build) nightly (64-bit)
-- | --
Revision | 8c6c7ba89cc9453625af54f11fd83179e23450fa-refs/branch-heads/4044@{#999}
OS | macOS Version 10.15.4 (Build 19E287)

Case #1 (x2)

  • launched 1.10.46 CR: 81.0.4044.138 using --args --log-level=2 --enable-logging=stderr --rewards=staging=true
  • accepted the UGP promotion after enabling rewards via the panel and closed the browser
  • opened publisher_info_db using DB Browser for SQLite
  • removed all the entries under the unblinded_tokens table
  • changed public_keys to [] under the promotion table
  • changed status to 1 under the promotion table
  • changed status to 3 under the creds_batch table
  • save publisher_info_db (write changes) and exit DB Browser for SQLite
  • launched 1.10.46 CR: 81.0.4044.138 using --args --log-level=2 --enable-logging=stderr --rewards=staging=true and you'll notice that the balance displays 0.00 BAT
  • launch 1.10.48 CR: 81.0.4044.138 using --args --log-level=2 --enable-logging=stderr --rewards=staging=true and you'll notice that the balance displays 20.00 BAT
  • tip https://laurenwags.github.io, https://duckduckgo.com

Before removing the "unblinded_tokens" table

Screen Shot 2020-05-12 at 1 46 22 AM

After removing the "unblinded_tokens" table

Screen Shot 2020-05-12 at 1 41 34 AM

Changing "promotion" table

Screen Shot 2020-05-12 at 1 47 34 AM

Changing "creds_batch" table

Screen Shot 2020-05-12 at 1 48 20 AM

Broken state after the above changes

Screen Shot 2020-05-12 at 2 01 29 AM

Case #2 (x2)

  • launched 1.10.46 CR: 81.0.4044.138 using --args --log-level=2 --enable-logging=stderr --rewards=staging=true
  • accepted the UGP promotion after enabling rewards via the panel and closed the browser
  • opened publisher_info_db using DB Browser for SQLite
  • changed status to 1 under the promotion table
  • changed status to 3 under the creds_batch table
  • replace signed_creds with blinded_creds in the creds_batch table
  • save publisher_info_db (write changes) and exit DB Browser for SQLite
  • launch 1.10.48 CR: 81.0.4044.138 using --args --log-level=2 --enable-logging=stderr --rewards=staging=true
[ REQUEST ]
> url: https://grant.rewards.bravesoftware.com/v2/promotions/reportclobberedclaims
> method: UrlMethod::POST
> content: {"claimIds":["29ab8b87-45f8-47c3-a684-d0cd253b8547"]}
> contentType: application/json; charset=utf-8
[ END REQUEST ]
  • opened publisher_info_db using DB Browser for SQLite
  • ensure that the status under promotion is 6
  • ensure that the status under creds_batch is 5

Changing "status" under the "promotion" table

Screen Shot 2020-05-12 at 2 11 29 AM

Changing "status" and "signed_creds" under the "creds_batch" table

Screen Shot 2020-05-12 at 2 16 55 AM

"status" under the "promotion" table after upgrading

Screen Shot 2020-05-12 at 2 20 23 AM

"status" under the "creds_batch" table after upgrading

Screen Shot 2020-05-12 at 2 20 41 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-macos-x64 Do not run CI builds for macOS x64 feature/rewards
Projects
None yet
Development

Successfully merging this pull request may close these issues.

May ads payout recovery
5 participants