Skip to content

Conversation

@tmpolaczyk
Copy link
Contributor

We have a small bug in pallet_inflation_rewards, where we calculate the reward per chain based on the total number of registered chains, regardless of whether they have collators or not. This case doesn't happen in any live runtime because we have enough collators for all chains (for now).

In the case of some chains without collators, there is a portion of the inflation that always goes to the parachain bond. This PR fixes this, increasing the rewards_per_chain in that case. It doesn't affect inflation, the total inflated value is still the same. (except in the edge case where we have 0 collators, because now we won't mint anything).

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

WASM runtime size check:

Compared to target branch

dancebox runtime: 1900 KB (+4 KB) ⚠️

flashbox runtime: 1128 KB (no changes) ✅

dancelight runtime: 2668 KB (+12 KB) 🚨

starlight runtime: 2580 KB (+12 KB) 🚨

container chain template simple runtime: 1472 KB (no changes) ✅

container chain template frontier runtime: 1832 KB (no changes) ✅

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Coverage Report

(master)

@@                               Coverage Diff                               @@
##           master   tomasz-inflation-only-chains-with-collators      +/-   ##
===============================================================================
+ Coverage   71.03%                                        71.31%   +0.28%     
  Files         550                                           550              
+ Lines       75341                                         76090     +749     
===============================================================================
+ Hits        53516                                         54262     +746     
+ Misses      21825                                         21828       +3     
Files Changed Coverage
/chains/integration-tests/dancebox-runtime-tests/src/tests/integration_test.rs 99.62% (-0.06%)
/chains/orchestrator-paras/runtime/flashbox/src/tests/integration_test.rs 99.76% (-0.08%)
/chains/orchestrator-relays/runtime/dancelight/src/tests/inflation_rewards.rs 98.71% (+0.50%)
/chains/orchestrator-relays/runtime/dancelight/src/weights/pallet_pooled_staking.rs 9.62% (+9.62%)
/chains/orchestrator-relays/runtime/starlight/src/tests/inflation_rewards.rs 98.71% (+0.50%)
/chains/orchestrator-relays/runtime/starlight/src/weights/pallet_pooled_staking.rs 9.62% (+9.62%)
/pallets/inflation-rewards/src/lib.rs 89.31% (+0.14%)
/pallets/registrar/src/lib.rs 89.47% (-0.05%)

Coverage generated

@tmpolaczyk tmpolaczyk marked this pull request as ready for review December 2, 2025 15:02
@tmpolaczyk tmpolaczyk added A8-mergeoncegreen Pull request is reviewed well. breaking Needs to be mentioned in breaking changes B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. R9-allruntimes change affects all runtimes V-1700 change to incorporate in runtime 1700 labels Dec 2, 2025

let all_rewards = RewardsPortion::get() * summary.inflation;
// rewards are shared between the 2 paras
let orchestrator_rewards = all_rewards / 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is actually the collator reward and not the orchestrator one right? The name confused me a bit initially.

const expectedOrchestratorReward = chainRewards / 3n;
const reward = await filterRewardFromOrchestrator(events, account);
expect(reward).to.equal(expectedOrchestratorReward);
expect(reward).to.equal(expectedOrchestratorReward + 1n);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this +1? Is it related to rounding errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wish I knew, because if I put +1 starlight tests fail, and if I don't then dancelight tests fail 😂

await polkadotJs.query.system.account(DANCELIGHT_BOND)
).data.free.toBigInt();

expectedAmountParachainBond += (issuance * 3n) / 10n + dust + 1n;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here for the +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A8-mergeoncegreen Pull request is reviewed well. B7-runtimenoteworthy Changes should be noted in any runtime-upgrade release notes breaking Needs to be mentioned in breaking changes D5-nicetohaveaudit⚠️ PR contains trivial changes to logic that should be properly reviewed. R9-allruntimes change affects all runtimes V-1700 change to incorporate in runtime 1700

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants