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

Do not start the ledger process when attempting to get publisher info #8036

Merged
merged 1 commit into from
Feb 23, 2021

Conversation

zenparsing
Copy link
Collaborator

@zenparsing zenparsing commented Feb 22, 2021

Resolves brave/brave-browser#14307

Submitter Checklist:

  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)
  • Requested a security/privacy review as needed

Reviewer Checklist:

  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

  • Start the browser with a clean profile and rewards console logging enabled.
  • Visit a page on github, such as https://github.com/zenparsing.
  • View the console logs.
    • Verify that no rewards initialization entries are logged to the console.

Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

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

Lgtm

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

@emerick
Copy link
Contributor

emerick commented Feb 22, 2021

@zenparsing Needs an issue in the description...

@zenparsing
Copy link
Collaborator Author

CI failed on unrelated audit-deps check.

@LaurenWags
Copy link
Member

LaurenWags commented Feb 23, 2021

Verified using

Brave	1.22.42 Chromium: 89.0.4389.58 (Official Build) nightly (x86_64)
Revision	1a139f28ecc27719439e37c6b1533cee999cb802-refs/branch-heads/4389@{#1134}
OS	macOS Version 10.15.7 (Build 19H512)

Reproduced issue with STR from original issue and 1.20.208.
Visited a media publisher site, github.com/brave/brave-core/commits.
Confirmed able to see rewards logs in terminal.

Example Logs
[25470:775:0223/105807.344020:INFO:CONSOLE(1)] "Greaselion script loaded: githubBase.ts", source: chrome-extension://eoceebklhjepohnakemchinmkdpbolgh/githubBase.bundle.js (1)
[25470:775:0223/105807.345655:INFO:CONSOLE(1)] "Greaselion script loaded: githubInlineTipping.ts", source: chrome-extension://galpopeppgfimpgpdbbkhemhcjgghmhl/githubInlineTipping.bundle.js (1)
[25470:775:0223/105807.346982:WARNING:CONSOLE(1)] "Received external message from a sender who is not allowed to send messages to this background. Origin: https://github.com, URL: https://github.com/brave/brave-core/commits", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
[25470:775:0223/105807.347905:WARNING:CONSOLE(1)] "Received external message from a sender who is not allowed to send messages to this background. Origin: https://github.com, URL: https://github.com/brave/brave-core/commits", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
[25470:775:0223/105807.696074:VERBOSE1:rewards_service_impl.cc(434)] Starting ledger process
[25470:775:0223/105807.757001:INFO:database_publisher_info.cc(151)] Response is wrong
[25470:775:0223/105807.764675:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 1
[25470:775:0223/105807.764748:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 2
[25470:775:0223/105807.764791:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 3
[25470:775:0223/105807.764939:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 4
[25470:775:0223/105807.765025:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 5
[25470:775:0223/105807.765063:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 6
[25470:775:0223/105807.765158:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 7
[25470:775:0223/105807.765288:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 8
[25470:775:0223/105807.765358:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 9
[25470:775:0223/105807.765547:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 10
[25470:775:0223/105807.765656:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 11
[25470:775:0223/105807.765711:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 12
[25470:775:0223/105807.765809:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 13
[25470:775:0223/105807.765859:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 14
[25470:775:0223/105807.766021:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 15
[25470:775:0223/105807.766077:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 16
[25470:775:0223/105807.766114:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 17
[25470:775:0223/105807.766147:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 18
[25470:775:0223/105807.766252:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 19
[25470:775:0223/105807.766308:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 20
[25470:775:0223/105807.766351:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 21
[25470:775:0223/105807.766471:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 22
[25470:775:0223/105807.766539:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 23
[25470:775:0223/105807.766634:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 24
[25470:775:0223/105807.766673:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 25
[25470:775:0223/105807.766764:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 26
[25470:775:0223/105807.766823:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 27
[25470:775:0223/105807.766860:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 28
[25470:775:0223/105807.766916:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 29
[25470:775:0223/105807.839329:VERBOSE1:state_migration.cc(50)] Fresh install, state version set to 8
[25470:775:0223/105807.840056:VERBOSE1:publisher_prefix_list_updater.cc(58)] Scheduling publisher prefix list update in 0 seconds
[25470:775:0223/105807.840641:VERBOSE1:contribution.cc(209)] Last reconcile timer set for 2.592e+06 s
[25470:775:0223/105807.841134:VERBOSE1:contribution.cc(88)] Queue timer set for 2 s
[25470:775:0223/105807.841388:VERBOSE1:promotion.cc(94)] Migrating corrupted promotions
[25470:775:0223/105807.841534:VERBOSE5:ledger_impl.cc(133)] 
[ REQUEST ]
> URL: https://api.rewards.brave.com/v1/parameters
> Method: UrlMethod::GET
[25470:775:0223/105807.841946:VERBOSE1:recovery.cc(22)] Running empty balance check...
[25470:775:0223/105807.842204:VERBOSE1:publisher_prefix_list_updater.cc(65)] Fetching publisher prefix list
[25470:775:0223/105807.842250:VERBOSE5:ledger_impl.cc(133)] 
[ REQUEST ]
> URL: https://rewards.brave.com/publishers/prefix-list
> Method: UrlMethod::GET
[25470:775:0223/105807.843183:VERBOSE5:ledger_impl.cc(133)] 
[ REQUEST ]
> URL: https://grant.rewards.brave.com/v1/promotions?migrate=true&platform=osx
> Method: UrlMethod::GET
[25470:775:0223/105807.846684:VERBOSE1:promotion.cc(589)] Promotion is empty
[25470:775:0223/105807.847933:VERBOSE1:recovery_empty_balance.cc(110)] Creds batch list is emtpy
[25470:775:0223/105807.849472:VERBOSE1:database_server_publisher_banner.cc(142)] Server publisher banner not found
[25470:775:0223/105807.849929:VERBOSE5:ledger_impl.cc(133)] 
[ REQUEST ]
> URL: https://pcdn.brave.com/publishers/prefixes/8d83
> Method: UrlMethod::GET
[25470:775:0223/105808.037272:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://pcdn.brave.com/publishers/prefixes/8d83
> Result: Success
> HTTP Code: 200
> Body: 
[25470:775:0223/105808.037678:VERBOSE1:database_server_publisher_banner.cc(43)] Empty publisher banner data, skipping insert
[25470:775:0223/105808.040131:INFO:publisher.cc(761)] Publisher info not found
[25470:775:0223/105808.045104:VERBOSE1:publisher.cc(515)] Publisher list is empty
[25470:775:0223/105808.115179:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://grant.rewards.brave.com/v1/promotions?migrate=true&platform=osx
> Result: Success
> HTTP Code: 200
> Body: {"promotions":[]}

[25470:775:0223/105808.178399:VERBOSE1:publisher_prefix_list_updater.cc(102)] Resetting publisher prefix list table
[25470:775:0223/105808.178487:VERBOSE1:database_publisher_prefix_list.cc(123)] Clearing publisher prefixes table
[25470:775:0223/105808.192886:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105808.349093:VERBOSE6:logging_util.cc(136)] 
[ RESPONSE - OnRequest ]
> Url: https://api.rewards.brave.com/v1/parameters
> Result: Success
> HTTP Code: 200
> Body: {"batRate":0.46507647477623787,"autocontribute":{"choices":[5,10,15,20,25,50,100],"defaultChoice":20},"tips":{"defaultTipChoices":[1,10,100],"defaultMonthlyChoices":[1,10,100]}}

[25470:775:0223/105808.350126:VERBOSE1:api_parameters.cc(97)] Params timer set for 11458 s
[25470:775:0223/105808.434772:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105808.682859:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105808.925014:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105809.167981:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105809.411038:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105809.666234:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105809.921265:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105810.205316:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105810.496507:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 100000 records into publisher prefix table
[25470:775:0223/105810.752663:VERBOSE1:database_publisher_prefix_list.cc(133)] Inserting 51943 records into publisher prefix table
[25470:775:0223/105810.880061:VERBOSE1:publisher_prefix_list_updater.cc(58)] Scheduling publisher prefix list update in 259199 seconds
[25470:775:0223/105810.880523:VERBOSE1:wallet_balance.cc(41)] Wallet is not created
[25470:775:0223/105810.882282:VERBOSE1:unverified.cc(52)] List is empty

Also confirmed I see connections being made in Fiddler Everywhere when using 1.20.108:

Fidder

Using 1.22.42, verified STR from github.com/brave/brave-browser/issues/14307.

Launched with
/Applications/Brave\ Browser\ Nightly.app/Contents/MacOS/Brave\ Browser\ Nightly --args --enable-logging=stderr --vmodule="*/bat-native-ledger/*"=6,"*/brave_rewards/*"=6,"*/bat-native-ads/*"=6,"*/bat-native-confirmations/*"=6,"*/brave_ads/*"=6,"*/brave_user_model/*"=6.
Confirmed no rewards messages in the logs when visiting the following sites:

Confirmed no connections made to rewards.brave.com, pcdn.brave.com, grant.rewards.brave.com, or api.rewards.brave.com in Fiddler Everywhere when visiting any of the above listed sites.


Verification PASSED on Win 10 x64 using the following build:

Using 1.22.42 CR: 89.0.4389.58, launched via the following:

C:\Program Files\BraveSoftware\Brave-Browser-Nightly\Application
λ brave.exe --args --enable-logging=stderr --vmodule=""*/bat-native-ads/*"=6,"*/brave_ads/*"=6,"*/brave_user_model/*"=6,"*/bat_ads/*"=6,"*/bat-native-ledger/*"=6,"*/brave_rewards/*"=6"

Endpoints:

  • rewards.brave.com
  • pcdn.brave.com
  • grant.rewards.brave.com
  • api.rewards.brave.com

Ensured that the above endpoints weren't being contacted by looking at the terminal output/Charles Proxy when launching Brave for the first time on a clean profile. Also ensured that the above endpoints are not being contacted when visiting the following:

* https://github.com/kjozwiak
* https://github.com/kjozwiak/RatHunter
* https://github.com/brave/brave-browser/issues/14317
* https://github.com/brave/brave-core/pull/7996
* https://twitter.com/kamiljozwiak
* https://twitter.com/bcrypt/status/1362796915063021569
* https://twitter.com/brave
* https://www.youtube.com/c/khanacademy/videos
* https://www.youtube.com/watch?v=PVqWOehVTOg
* https://www.twitch.tv/chess
* https://vimeo.com/shutupshow
* https://www.reddit.com/user/mimsyshackleford
* https://www.reddit.com/r/BATProject/comments/j1t4ya/heres_some_fanart_i_made_impossible_bat_triangle/g73pduw/?context=3

Ensured that clicking on the BAT icon via the URL or a inline Tip icon contacts rewards as per the following:

Clicking on BAT icon or inline Tip icon [3044:28716:0223/114643.234:VERBOSE1:rewards_service_impl.cc(429)] Starting ledger process [3044:28716:0223/114643.267:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 1 [3044:28716:0223/114643.268:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 2 [3044:28716:0223/114643.268:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 3 [3044:28716:0223/114643.268:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 4 [3044:28716:0223/114643.269:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 5 [3044:28716:0223/114643.269:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 6 [3044:28716:0223/114643.269:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 7 [3044:28716:0223/114643.269:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 8 [3044:28716:0223/114643.269:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 9 [3044:28716:0223/114643.269:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 10 [3044:28716:0223/114643.269:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 11 [3044:28716:0223/114643.270:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 12 [3044:28716:0223/114643.270:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 13 [3044:28716:0223/114643.270:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 14 [3044:28716:0223/114643.270:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 15 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 16 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 17 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 18 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 19 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 20 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 21 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 22 [3044:28716:0223/114643.271:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 23 [3044:28716:0223/114643.272:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 24 [3044:28716:0223/114643.272:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 25 [3044:28716:0223/114643.272:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 26 [3044:28716:0223/114643.272:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 27 [3044:28716:0223/114643.272:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 28 [3044:28716:0223/114643.272:VERBOSE1:database_migration.cc(116)] DB: Migrated to version 29 [3044:28716:0223/114643.312:VERBOSE1:state_migration.cc(50)] Fresh install, state version set to 8 [3044:28716:0223/114643.313:VERBOSE1:publisher_prefix_list_updater.cc(58)] Scheduling publisher prefix list update in 0 seconds [3044:28716:0223/114643.313:VERBOSE1:contribution.cc(216)] Last reconcile timer set for 2.592e+06 s [3044:28716:0223/114643.314:VERBOSE1:contribution.cc(89)] Queue timer set for 11 s [3044:28716:0223/114643.314:VERBOSE1:promotion.cc(95)] Migrating corrupted promotions [3044:28716:0223/114643.314:VERBOSE5:ledger_impl.cc(133)] [ REQUEST ] > URL: https://api.rewards.brave.com/v1/parameters > Method: UrlMethod::GET [3044:28716:0223/114643.314:VERBOSE1:recovery.cc(22)] Running empty balance check... [3044:28716:0223/114643.314:VERBOSE1:publisher_prefix_list_updater.cc(65)] Fetching publisher prefix list [3044:28716:0223/114643.315:VERBOSE5:ledger_impl.cc(133)] [ REQUEST ] > URL: https://rewards.brave.com/publishers/prefix-list > Method: UrlMethod::GET [3044:28716:0223/114643.315:VERBOSE5:ledger_impl.cc(133)] [ REQUEST ] > URL: https://grant.rewards.brave.com/v1/promotions?migrate=true&platform=windows > Method: UrlMethod::GET [3044:28716:0223/114643.326:VERBOSE1:promotion.cc(597)] Promotion is empty [3044:28716:0223/114643.326:VERBOSE1:database_server_publisher_banner.cc(142)] Server publisher banner not found [3044:28716:0223/114643.327:VERBOSE1:recovery_empty_balance.cc(110)] Creds batch list is emtpy [3044:28716:0223/114643.328:VERBOSE5:ledger_impl.cc(133)] [ REQUEST ] > URL: https://pcdn.brave.com/publishers/prefixes/fb67 > Method: UrlMethod::GET [3044:28716:0223/114643.465:VERBOSE6:logging_util.cc(136)] [ RESPONSE - OnRequest ] > Url: https://grant.rewards.brave.com/v1/promotions?migrate=true&platform=windows > Result: Success > HTTP Code: 200 > Body: {"promotions":[]}

[3044:28716:0223/114643.659:VERBOSE6:logging_util.cc(136)]
[ RESPONSE - OnRequest ]

Url: https://api.rewards.brave.com/v1/parameters
Result: Success
HTTP Code: 200
Body: {"batRate":0.45197560884808147,"autocontribute":{"choices":[5,10,15,20,25,50,100],"defaultChoice":20},"tips":{"defaultTipChoices":[1,10,100],"defaultMonthlyChoices":[1,10,100]}}

[3044:28716:0223/114643.659:VERBOSE1:api_parameters.cc(97)] Params timer set for 11871 s
[3044:28716:0223/114643.721:VERBOSE6:logging_util.cc(136)]
[ RESPONSE - OnRequest ]

Url: https://pcdn.brave.com/publishers/prefixes/fb67
Result: Success
HTTP Code: 200
Body:

if (profile_->GetPrefs()->GetBoolean(prefs::kAutoContributeEnabled))
return true;

auto* ads_service = brave_ads::AdsServiceFactory::GetForProfile(profile_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is definitely not the right thing to do here and the previous IsRewardsEnabled was intentionally removed. We should always be using ads::prefs::kEnabled for this checks and really this method should go away and prefs::kEnabled should be set to true/false based on the value of the other prefs as needed. cc @tmancey because ads_service->IsEnabled() should also be removed

Copy link
Collaborator

Choose a reason for hiding this comment

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

this is also the root cause of a crash in the tests because the timing of it triggers AdsService to be added twice to the dependency graph

Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -1931,6 +1931,11 @@ void RewardsServiceImpl::GetPublisherInfo(
const std::string& publisher_key,
GetPublisherInfoCallback callback) {
if (!Connected()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

unrelated to the problem mentioned below, it seems like it would make more sense to have MaybeStartProcess which checks !Connected() and checks to make sure rewards is enabled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants