mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
fix!: avoid float calculations in PlatformShare (#5604)
## Issue being fixed or feature implemented avoid potential discrepancies in block reward calculations ## What was done? use integers (int64_t) only when dealing with block rewards, no float/double ## How Has This Been Tested? run tests ## Breaking Changes might fork off on devnets that use previous version ## Checklist: - [x] 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 made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
This commit is contained in:
parent
ce9cfff0d6
commit
2004a855d9
@ -344,10 +344,9 @@ void FillBlockPayments(const CSporkManager& sporkManager, CGovernanceManager& go
|
|||||||
|
|
||||||
CAmount PlatformShare(const CAmount reward)
|
CAmount PlatformShare(const CAmount reward)
|
||||||
{
|
{
|
||||||
constexpr double platformShare = 0.375;
|
const CAmount platformReward = reward * 375 / 1000;
|
||||||
const CAmount platformReward = reward * platformShare;
|
bool ok = MoneyRange(platformReward);
|
||||||
assert(MoneyRange(platformReward));
|
assert(ok);
|
||||||
|
|
||||||
return platformReward;
|
return platformReward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ class AssetLocksTest(DashTestFramework):
|
|||||||
all_mn_rewards = platform_reward + owner_reward + operator_reward
|
all_mn_rewards = platform_reward + owner_reward + operator_reward
|
||||||
all_mn_rewards += 1 * 0.75
|
all_mn_rewards += 1 * 0.75
|
||||||
assert_equal(all_mn_rewards, bt['coinbasevalue'] * 0.75) # 75/25 mn/miner reward split
|
assert_equal(all_mn_rewards, bt['coinbasevalue'] * 0.75) # 75/25 mn/miner reward split
|
||||||
assert_equal(platform_reward, int(all_mn_rewards * 0.375)) # 0.375 platform share
|
assert_equal(platform_reward, all_mn_rewards * 375 // 1000) # 0.375 platform share
|
||||||
assert_equal(platform_reward, 2555399792)
|
assert_equal(platform_reward, 2555399792)
|
||||||
assert_equal(new_total, self.get_credit_pool_balance())
|
assert_equal(new_total, self.get_credit_pool_balance())
|
||||||
node.generate(1)
|
node.generate(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user