Skip to content

Output mobile rewards to iceberg tables#1163

Merged
michaeldjeffrey merged 5 commits into
mainfrom
bbalser/rewards/iceberg
Mar 27, 2026
Merged

Output mobile rewards to iceberg tables#1163
michaeldjeffrey merged 5 commits into
mainfrom
bbalser/rewards/iceberg

Conversation

@bbalser
Copy link
Copy Markdown
Collaborator

@bbalser bbalser commented Mar 26, 2026

  1. Add rewarders writing to iceberg (98147d5) — The main feature. Adds 5 new Iceberg table writers for
    mobile reward data in mobile_verifier/src/iceberg/:
    • radio_reward.rs — proof of coverage rewards per radio
    • radio_reward_covered_hex.rs — hex-level coverage details
    • gateway_reward.rs — data transfer rewards
    • service_provider_reward.rs — service provider rewards
    • unallocated_reward.rs — unallocated rewards

Also adds the RewardWriters/RewardTransactions orchestration in mod.rs, wires them into rewarder.rs to write
reward data during reward calculation, and initializes them in cli/server.rs. Test files are updated to pass
the new writer through.
2. Rename reward tables (7711ee0) — Moves the 5 reward tables from the poc namespace to rewards, and renames
them: radio_rewards → proof_of_coverage, radio_reward_covered_hexes → covered_hexes, gateway_rewards →
data_transfer, service_provider_rewards → service_provider, unallocated_rewards → unallocated.
3. Refactor variable name (188cdb5) — Minor variable rename cleanup.

#[derive(Debug, Clone, Trino, Serialize, Deserialize, PartialEq)]
pub struct IcebergGatewayReward {
hotspot_key: String,
dc_transfer_reward: i64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we use u64 for all the fields we know will never be negative? Also matches the proto already.

fn from(share: &MobileRewardShare) -> Self {
let reward = match &share.reward {
Some(ProtoReward::GatewayReward(r)) => r,
other => panic!("expected GatewayReward, got {other:?}"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are panicking now?

@michaeldjeffrey michaeldjeffrey force-pushed the bbalser/rewards/iceberg branch from 188cdb5 to 5c267f8 Compare March 26, 2026 21:23
* Implement Copy for DeviceType

DeviceType is a simple enum, which makes it a prime candidate for
implementing copy so we don’t have to worry about managing references to
it.

* Move ToProtoDecimal up to lib, add companion FromProtoDecimal

This type is useful in tests and in the main rewarder logic when we’re
making protos for mobile reward shares.

Also adding a companion `FromProtoDecimal` to try and keep our to/from
different Decimal types all in one place.

* Refactor Iceberg mappings

In rewarder.rs, I changed the `.into_rewards()` calls to return an
interator of the type of reward rather than a `MobileRewardShare`. This
allows us to not have to worry about unwrapping options for types that
we know exist.

The `panic!()`s were removed becuase we no longer have to unwrap the
reward type from the `MobileRewardShare`, and we have a bit better type
checking on our conversions.

This comes in extra handy when needing to map them into iceberg table
types. And allows us to pass in the epoch periods as `DateTime<Utc>`
rather than extracting them back out from `u64` timestamps into
`DateTime<FixedOffset>`.

I also went through and removed all the `i64` uses for fields that can
never carry negative numbers.
Thanks Clippy, you’re the best
@michaeldjeffrey michaeldjeffrey merged commit d95ccad into main Mar 27, 2026
31 checks passed
@michaeldjeffrey michaeldjeffrey deleted the bbalser/rewards/iceberg branch March 27, 2026 17:45
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.

3 participants