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

add support for unallocated IOT rewards #675

Merged
merged 11 commits into from
Jan 8, 2024

Conversation

andymck
Copy link
Contributor

@andymck andymck commented Nov 30, 2023

Linked proto PR: helium/proto#384

@andymck andymck force-pushed the andymck/iot-unallocated-rewards-support branch from 51e9c25 to d7b9a3e Compare December 12, 2023 13:03
@andymck andymck force-pushed the andymck/iot-unallocated-rewards-support branch from 46cbd95 to cb9ccd0 Compare January 2, 2024 15:09
@andymck andymck marked this pull request as ready for review January 4, 2024 13:51
@andymck andymck force-pushed the andymck/iot-unallocated-rewards-support branch from a5f6ea3 to f53ae67 Compare January 5, 2024 13:27
iot_verifier/Cargo.toml Outdated Show resolved Hide resolved
@andymck andymck force-pushed the andymck/iot-unallocated-rewards-support branch from d385a8d to 6749669 Compare January 5, 2024 14:39
tracing::info!(
%total_dc_shares,
%total_dc_transfer_rewards_used,
%dc_transfer_rewards_unused,
%dc_transfer_rewards_per_share,
"data transfer rewards"
);
self.beacon_rewards_per_share = beacon_rewards_per_share;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these values defaulted before this function is called? If so, this function should be a constructor, not a &mut function. Could be a pretty dangerous footgun

Copy link
Contributor Author

@andymck andymck Jan 7, 2024

Choose a reason for hiding this comment

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

Addressed in sep PR via this commit: 79925fa

@@ -898,14 +934,22 @@ mod test {
reward_shares_in_dec(dec!(150), dec!(350), gw6_dc_spend),
); // 0.0150, 0.0350

let gw_shares = GatewayShares { shares };
let mut gw_shares = GatewayShares {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing this, construct a new set of gateway shares from an iterator of hashmaps

Copy link
Contributor Author

@andymck andymck Jan 7, 2024

Choose a reason for hiding this comment

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

Addressed in sep PR via this commit: 79925fa

Cargo.toml Outdated Show resolved Hide resolved
iot_verifier/src/reward_share.rs Outdated Show resolved Hide resolved
+ gateway_reward.beacon_amount
+ gateway_reward.witness_amount;
(
total_gateway_reward,
Copy link
Contributor

Choose a reason for hiding this comment

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

does including this total serve any purpose other than testing? wouldn't it be cleaner to just grab the reward message and sum the three reward categories in the test if that's the only place it's used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is used in the rewarder, to accumulate the final u64 value of each gateway reward and from this to work out the final unallocated reward amount

iot_verifier/tests/rewarder_operations.rs Outdated Show resolved Hide resolved
iot_verifier/src/rewarder.rs Show resolved Hide resolved
Copy link
Contributor

@jeffgrunewald jeffgrunewald left a comment

Choose a reason for hiding this comment

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

approved. i still think at a later time i'd like to see the way we calculate total allocated rewards more closely mirror how we calculate the total_shares() method on GatewayRewardShares, i.e. all at one time and independently of other operations in the same method since the into_iot_reward_shares method now seems a bit overloaded computing a total decimal of bones, converting the reward shares to the proto type and writing them to the file sink client.

@andymck andymck merged commit 7aaf177 into main Jan 8, 2024
1 check passed
@andymck andymck deleted the andymck/iot-unallocated-rewards-support branch January 8, 2024 14:59
@andymck
Copy link
Contributor Author

andymck commented Jan 8, 2024

approved. i still think at a later time i'd like to see the way we calculate total allocated rewards more closely mirror how we calculate the total_shares() method on GatewayRewardShares, i.e. all at one time and independently of other operations in the same method since the into_iot_reward_shares method now seems a bit overloaded computing a total decimal of bones, converting the reward shares to the proto type and writing them to the file sink client.

total_allocated_rewards is accumulated as part of the into_iot_reward_shares iterator in order to avoid having to make a third or distrinct pass over the shares map. into_iot_reward_shares generates the reward proto after converting the reward decimal value to a u64 value. This conversion is done as we cannot reward fractional bones. Both the proto definition and total_allocated_rewards require this u64 value, hence why the iterator returns that u64 value.

Note: into_iot_reward_shares It doesnt actually write the proto to the filesink. That is performed in the rewarder itself.

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

Successfully merging this pull request may close these issues.

4 participants