Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Incorrect activity types logged #34

Open
ch40s opened this issue Jan 27, 2022 · 3 comments
Open

Incorrect activity types logged #34

ch40s opened this issue Jan 27, 2022 · 3 comments

Comments

@ch40s
Copy link

ch40s commented Jan 27, 2022

Comparing the bot's output with Helium Explorer and Hotspotty, I noticed that some activity types are incorrect:

  • "Witness Beacon" used instead of "Challenged Beaconer"
  • "Witness Beacon (Invalid)" used instead of "Broadcasted Beacon"
  • "Witness Beacon (Invalid)" instead of "Witness Beacon"
@ch40s
Copy link
Author

ch40s commented Jan 27, 2022

Example for the 3rd use case:

I picked a random hotspot and compared the bot's output with Helium Explorer. According to the Helium Explorer the hotspot had a "Witness Beacon" activity, 18 witnesses in total, 1 invalid but not from the hotspot we are looking up. The bot's output was //Witness Beacon (Invalid) because of the if statement below (I added some debug logging to find out):

else if(activity['path'][0]['receipt'] === null){
   type = '//Witness Beacon (Invalid)';
}

Field parsing from the API is correct in my opinion because the receipt field was null indeed so I assume that the API results are not interpreted correctly. In this case the result should be defined by the following code snippet instead:

else {
type = '.Witness Beacon';
for(witness of activity['path'][0]['witnesses']){
   if (witness['gateway'] === hotspot){
      type = '.Witness Beacon';
      if(witness['is_valid'] === false){
         type = '//Witness Beacon (Invalid)';
         details = formatType(witness['invalid_reason']);
         meta = 'RSSI: ' + witness['signal'].toString() + 'dBm SNR: ' + witness['snr'].toFixed(1) + ' dB';
      }
   }
}

That's a redacted snippet from that block in API results that had the valid witness in Explorer and invalid in the bot:

{"type":"poc_receipts_v1",
"time":...,
"secret":"...",
"request_block_hash":"...",
"path":
[{"witnesses":
 [
 {"timestamp":...},
 {"timestamp":...},
 ...
 {"timestamp":...}
 ],
"receipt":null,
"geocode":{...},
"challengee_owner"..."challengee":"..."
}]

@ch40s
Copy link
Author

ch40s commented Jan 27, 2022

Another example, the bot says "Witness Beacon" and the Explorer says "Broadcasted Beacon" for the same event.

activity['path'][0]['receipt']['gateway'] returns the actual hotspot ID which means it should be logged as .Sent Beacon however that doesn't work for some reason. I'm wondering if allActivity.hotspot does not contain the hotspot ID.

@ch40s
Copy link
Author

ch40s commented Jan 27, 2022

My assumption was right, allActivity.hotspot does not contain the hotspot ID because allActivity is overwritten so allActivity.hotspot is undefined in those if statements.

Adding const hotspot = allActivity.hotspot; at the beginning of formatHotspotActivity(allActivity) and using hotspot in those if statements later solves the problem for me and brings accurate results. This fixes more inconsistencies that I had noticed, like "Witness Beacon (Invalid)" instead of "Witness Beacon" in some cases.

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

No branches or pull requests

1 participant