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

feat(platform)!: total credits on platform query and fix for reward distribution #2032

Merged
merged 31 commits into from
Aug 13, 2024

Conversation

QuantumExplorer
Copy link
Member

@QuantumExplorer QuantumExplorer commented Aug 2, 2024

Issue being fixed or feature implemented

While we could ask Platform for the total number of credits in Platform, this was not taking into consideration promised rewards due to the core block height increase.

What was done?

Created a new query that will get the total number of credits in Platform, but also the current unpaid epoch and it's start block height. With all this information we can calculate the total credits in Platform with rewards taken into account. Something that should match what Core has (except if there are identity funding state transactions that have not been used).

How Has This Been Tested?

Added a few tests to make sure this was working.

Breaking Changes

This is not a breaking change.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

pauldelucia
pauldelucia previously approved these changes Aug 2, 2024
@QuantumExplorer QuantumExplorer changed the title feat: total credits on platform query feat(platform)!: total credits on platform query and fix for reward distribution Aug 8, 2024
@ogabrielides ogabrielides added this to the v1.1 milestone Aug 8, 2024
shumkov
shumkov previously approved these changes Aug 13, 2024
@@ -109,6 +82,15 @@ pub struct CoreConfig {
pub check_tx_rpc: CheckTxCoreRpcConfig,
}

impl Default for CoreConfig {
Copy link
Member

@shumkov shumkov Aug 13, 2024

Choose a reason for hiding this comment

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

Minor: this impl can be derived

use lazy_static::lazy_static;
use std::collections::HashMap;

lazy_static! {
Copy link
Member

@shumkov shumkov Aug 13, 2024

Choose a reason for hiding this comment

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

Minor: preferable to use LazyCell

@@ -38,10 +40,21 @@ impl<C> Platform<C> {
return Ok(None);
};

let start_block_core_height = if unpaid_epoch.epoch_index == 0 {
Copy link
Member

@shumkov shumkov Aug 13, 2024

Choose a reason for hiding this comment

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

Minor: use constant GENESIS_EPOCH

shumkov
shumkov previously approved these changes Aug 13, 2024
@shumkov shumkov changed the base branch from v1.0-dev to v1.1-dev August 13, 2024 09:20
@shumkov shumkov merged commit 3b190dd into v1.1-dev Aug 13, 2024
9 checks passed
@shumkov shumkov deleted the feat/totalCreditsOnPlatformQuery branch August 13, 2024 09:21
@thephez thephez added the dapi-endpoint DAPI endpoint addition or modification label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dapi-endpoint DAPI endpoint addition or modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants