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

Service Provider Rewards and Promotions #867

Merged
merged 31 commits into from
Oct 3, 2024
Merged

Commits on Oct 2, 2024

  1. Add promotion funds workspace

    This workspace is all about dealing with Service Provider Promotion Fund
    allocation.
    
    HIP-114
    https://github.com/helium/HIP/blob/main/0114-incentive-escrow-fund-for-subscriber-referrals.md
    
    Service Provider Promotions are stored in CarrierV0 on Solana.
    To keep the mobile-verifier from talking to a chain, this service will
    periodically check Solana and compare Service Providers allocations to
    what is stored in S3.
    
    If the values have changed, a new file will be output to a bucket for
    the mobile-verifier rewarder to read from.
    
    NOTE: Allocation Values are stored in Bps (Basis Points)
    https://www.investopedia.com/terms/b/basispoint.asp
    
    ** Commands
    
    *** ./promotion_fund write-solana
    
    Fetch Allocation values from Solana and write them to S3.
    This command _always_ writes an S3 file.
    
    *** ./promotion_fund print-s3
    
    Using the lookback time in the provided settings file, show the
    Allocation values this service would start up with.
    
    *** ./promotion_fund server
    
    Start a server that reads from S3, then checks with Solana periodically
    for updated Allocatino values. Writing new files when needed.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    e6d99c7 View commit details
    Browse the repository at this point in the history
  2. Supporting material for promotion_fund workspace

    - ingest promotion rewards, nothing will be done with them until the
      processor is added into mobile-verifier.
    - dump reward files
    - add sp_allocations dummy field to rewarder output
    - reward indexer mobile promotion type added
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    19db98f View commit details
    Browse the repository at this point in the history
  3. use existing reward_types for reward_indexer

    Otherwise inserting a new reward would match on the address and
    continually change the reward_type column for no reason.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    ff39335 View commit details
    Browse the repository at this point in the history
  4. update proto

    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    97b0c57 View commit details
    Browse the repository at this point in the history
  5. Add Continuous struct helper for file_source

    Default trait impls cannot be added to functions, but they can be added
    to structs. This struct keeps us from needing to do the gross blank
    generic filling in when we want a continuous file source with a decode
    other than MsgDecodeFileInfoPollerParser.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    882aadb View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    eb97f57 View commit details
    Browse the repository at this point in the history
  7. Swap over Service Provider rewards to use percents

    Rather than always dealing with conrete numbers, now that Service
    Providers can allocate a percentage of their rewards to promotions for
    subscribers or gateways, it becomes easier to speak of everything in
    percentages.
    
    This is a quick overview of what a more detailed overview you will find
    in the PR.
    
    For every Service Provider (SP) we figure out how much of the total
    rewards allocation they are being awarded for data transfer. We get the
    percent they have allocated for promotions (essentially from solana, but
    really s3), and we determine which percentage of the _total rewards
    allocation_ that is.
    
    If a SP is getting 50% of the total rewards, and they allocate 20% of
    those rewards to promotions, then the SP will receive 40% of the total,
    and promotions from them will represent 10% of the total.
    
    We do that for all SPs. The unallocated percentage is then distributed
    to the promotions of each SP. If there is more than enough unallocated
    left over, each SP get's a matched percentage of the whole to what they
    set aside. When there is not enough, they get a percentage equal to
    their initial rewards percentage.
    
    This is to keep a service provider from getting the bulk of extra
    rewards by settings aside a large amount for promotions, and receiving
    little in rewards for data transfer, but getting more for matching.
    
    A SP may never receive more in matched rewards than they have allocated
    themselves.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    754a380 View commit details
    Browse the repository at this point in the history
  8. Wrap everything in a service provider type

    This makes invocations of rewarding look very consistent
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    d3a4241 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    1dfe1da View commit details
    Browse the repository at this point in the history
  10. remove unused code

    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    be4e610 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    1f16e7a View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    7d44da2 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    1632262 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    9167d53 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    72c7706 View commit details
    Browse the repository at this point in the history
  16. the nature of the math has changed

    because we're dealing with percentages, and not doing bankers rounding
    or nearest even, the likelihood that a calculation comes out extremely
    close to a hole number then gets rounded down is increased. Especially
    when dealing with percentages to the 7th decimal point and a base number
    in the trillions.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    df41d2c View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    4c0c05e View commit details
    Browse the repository at this point in the history
  18. stub for reporting sp allocations

    I'm hoping there's an easy way to do this someone can point me to
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    9c17404 View commit details
    Browse the repository at this point in the history
  19. rename collection class for consistency

    it get a bit verbose with all the service_provider flying around, but I
    think it will be rather helpful when you only have the type and it
    hasn't been aliased.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    1012a00 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    4c50dc3 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    5b972bd View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    d088627 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    7100362 View commit details
    Browse the repository at this point in the history
  24. Found a rounding error

    truncating to 5 decimal places for a % can result in the summed
    allocation exceeding 100%.
    
    Thanks proptest
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    02c031a View commit details
    Browse the repository at this point in the history
  25. Discussion has been had

    It has been noted that in tests a single bone is okay, as long as we're
    not going over the allocated bones
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    3ad8630 View commit details
    Browse the repository at this point in the history
  26. commit commit

    let's not have the worst of both worlds where we comment out unused
    code.
    Remove the printlns, they're not hard to add back in if you need them.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    bd19088 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    1f48208 View commit details
    Browse the repository at this point in the history
  28. Service Providers can use multiple keys for dc_transfer

    For accounting reasons, Service Providers can have multiple payer keys
    listed. We need to ensuure all their dc transfer are accumulated into
    their service provider entry when we are generating rewards.
    michaeldjeffrey committed Oct 2, 2024
    Configuration menu
    Copy the full SHA
    1abf203 View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    6d0ba72 View commit details
    Browse the repository at this point in the history

Commits on Oct 3, 2024

  1. Configuration menu
    Copy the full SHA
    c02d5ca View commit details
    Browse the repository at this point in the history
  2. Read Service Provider Promotion values from unique bucket

    - Add settings `promotion_ingest`
    michaeldjeffrey committed Oct 3, 2024
    Configuration menu
    Copy the full SHA
    41ef60e View commit details
    Browse the repository at this point in the history