Conversation
cb43abb to
8904841
Compare
let (_, rewards) = tokio::join!(
// run rewards for poc and dc
rewarder::reward_poc_and_dc(
&pool,
&hex_boosting_client,
&mobile_rewards_client,
&speedtest_avg_client,
&epoch,
dec!(0.0001)
),
receive_expected_rewards(&mut mobile_rewards)
);When I tried to run |
This will be because the filesink writer awaits a oneshot response to indicate the file/s have been written to disk. If you do not call |
|
Other than clippy not being happy, this all looks good to me. |
cbf911e to
af92443
Compare
dc181f8 to
3e6cb65
Compare
Making the internal member hexes private will make it easier to change the implementation when device type is introduced.
A cell can be boosted more than once. Old boosts will retain device_type of ::All. Any boost matching the device_type accumulates into the multiplier. ex: 3 boost with a multiplier of 10, will multiply by 30.
The device_type column is assumed to be a jsonb, because the device_type column for the `mobile_hotspot_infos` table is an enum, and a jsonb field. It's nullable, which will represent boosting a hex for ALL device types. Otherwise, a camelcase value mapping to the DeviceTypeV0 in helium-program-library. https://github.com/helium/helium-program-library/blob/master/programs/hexboosting/src/state.rs This is different from the snake_case values used with protobufs.
With type hints enabled, `hex` shows up as a `BoostedHex` going into a function that expects `BoostedHex`. Renaming to `hex_proto` will hopefully clear up the need for the type casting.
This test uses a single type of radio to reduce adding noise to rewards by factors other than hex boosting. The first pass of the test calculates rewards for 2 radios with no boosted hexes to prove they are in equal standing. The second pass boosts only the hex for single radio, but with multiple BoostedHexDeviceType's to ensure they accumulate.
There was not enough custom functionality to warrant owning a BoostedHexDeviceType enum of our own.
* Refactor to use BoostedHexes methods Making the internal member hexes private will make it easier to change the implementation when device type is introduced. * Add device type to boosted hex info * refactor metadata_db tests to make test clearer also makes it easier to add new tests * remove expired boosted hexes when streaming from db * ensure no tests are written with expired boosted hexes * optimize by computing end_ts in db query Thanks for the query help Brian! By precomputing the end timestamp of a boosted hex, we can not have to stream all the hexes out of the db just to throw them away. * fixup after rebase - remove unused imports - remove old refactor return types * make boosted hex test function more explicit If the expired check had been made a global check, the ability to use BoostedHexes for modified hexes would have broken at runtime. The attempt here is to make very explicit during testing how to meet the same contract as the database queries for boosted hexes. I think there are still some cracks, but we can narrow in on those as we find them. For now, I think naming test constructor functions is a good start.
There is another test for same device types across hexes. This test is for different types in the same hex. The 2nd unboosted hex serves the purpose of giving us a relative baseline so we don't need to hardcode values into the test.
It becomes more difficult to compare ratios with radio_reward_v2 because boosted rewards are scaled. In many of the test we were hoping to have nice ratios (1:10) of poc_rewards. However, this was mostly because a radio would have received 0 boosted_rewards. Checking that ratio is impossible. We can however check the coverage_points (now that they mean points, and not rewards) for the expected ratio, and rely on other tests to ensure we're calculating poc_reward amount correctly.
3e6cb65 to
33f0f88
Compare
helium/proto#401
helium/helium-program-library#634
BoostedHexInfo.device_typeaddedBecause legacy boosts exists (
NULLin the database mapping toBoostedHexDeviceType::All), a single hex can now be considered boosted more than a single time.BoostedHexescarriesnnumber of boosts per cell.When asking for the current multiplier of a hex, the device type in question must be provided. All boosts that apply are combined.
parse_boosted_hex_info_from_databasetestBecause this project does not control the metadata db, I wanted to make sure
BoostedHexDeviceTypewould correctly serialize as a part ofBoostedHexInfo.Looking at the helium-program-library implementation it wasn't clear how
DeviceTypeV0would make it's way into the database. There is a similar fieldDeviceTypeinmobile_hotspot_infosthat has also uses a rust enum that is present as ajsonbcolumn.If that assumption turns out to be false, updating the test should lead us to the glory of correctly serializing
device_type.BoostedHexesand "expired boosts"@bbalser and I talked about
BoostedHexesonly ever containing non-expired boosts.Ideally, that would occur at the level of mobile-config when boosted hexes are being streamed out of the db. However, boosted hexes do not have a
end_tsfield that is easily queryable, and I'm not comfortable at this point in time putting that much math into a sql query.I tried at each next level. In the end, I decided to give up on that goal for this PR. Tests using
BoostedHexesdirectly would not have a way to enforce the contract of only holding actively boosted hexes, and now didn't feel like the correct time to dive into those tests to find a way they could.