Skip to content

Make the player statement limit a dynamic parameter - #206

Open
tindzk wants to merge 7 commits into
mainfrom
feat/tn-player-statement-limit-parameter
Open

tindzk wants to merge 7 commits into
mainfrom
feat/tn-player-statement-limit-parameter

Conversation

@tindzk

@tindzk tindzk commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The player statement limit is now a dynamic parameter. The game pallet records the allowance it grants to live players and revokes that amount instead of the current limit. When the next game processes players, it moves every live player to the changed limit. A migration stores the allowance that players held before the upgrade.

@tindzk tindzk changed the title Fix personhood statement allowance after a limit change Make the player statement limit a dynamic parameter Oct 23, 2026
@tindzk tindzk added D2-no audit No audit is needed C0-non-breaking This PR is not a breaking change for any runtime consuming it. labels Nov 2, 2026
@tindzk
tindzk marked this pull request as ready for review November 5, 2026 08:11
@tindzk
tindzk requested a review from a team November 5, 2026 08:11
);
let mut iterator = Players::<T>::iter_from_key(target_player.clone());
let mut credits_awarded = 0;
// Worst case: the player moves to a next limit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the weights need a regen for this.

Comment thread pallets/game/src/tests.rs Resolved
Comment thread pallets/game/src/lib.rs Resolved
Comment thread pallets/game/src/lib.rs Resolved
@agustinustheo

Copy link
Copy Markdown
Member

Let me trigger the weight regen for you.

/cmd bench --pallet indiv_pallet_game

@tindzk

tindzk commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

/cmd bench --pallet indiv_pallet_game

@github-actions

Copy link
Copy Markdown
Contributor

Command "bench --pallet indiv_pallet_game" has started 🚀 See logs here

@command-bot-individuality-commun

Copy link
Copy Markdown

Command "bench --pallet indiv_pallet_game" has finished ✅ See logs here

Runtime weight deviation:
Base:    upstream/main @ 55705d24ce40  (merge-base)
Current: HEAD

[!] 1 extrinsic above threshold (|Δ| ≥ 10% in ref_time or proof_size)

── runtimes/next-people-paseo · weights/indiv_pallet_game.rs ───────────────────

   bench machine (base -> current)
     CPU       Intel(R) Xeon(R) CPU @ 2.60GHz   (same)
     hostname  parity-weights-d44ca621f02d4812 -> parity-weights-e1b49a2b09e23484
     date      2026-11-16 -> 2026-11-24
     sampling  STEPS: 50, REPEAT: 20   (same)

🔺 indiv_pallet_game::player_process_step1                        ref_time +20.9% (1.2× slower)

   METRIC       BASE       CURRENT       DELTA
   ref_time     0.28 ms   -> 0.33 ms      +0.06 ms    (+20.9%)  ◀
   proof_size   4,111     -> 4,111        unchanged
   db reads     6         -> 8            +2          (+33.3%)
   db writes    1         -> 1            unchanged

   time breakdown
     computation   +0.01 ms
     db access     +0.05 ms

   storage (base -> current)
   • Game::PlayerStatementLimits  new  ->  r:1 w:0    added
   • Parameters::Parameters       new  ->  r:1 w:0    added

1 file scanned · 1 extrinsic above 10% threshold
measured at documented component maxima - pass --max NAME=VALUE for charge-site maxima

@gui1117 gui1117 left a comment

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.

Looks good to me

Comment thread pallets/game/src/lib.rs
} else {
limit.into()
}
}

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.

maybe we should fix sp-statement-store to not remove when one dimension is non-zero. this looks like a very tricky API.

Comment thread pallets/game/src/lib.rs
}

/// Return `PlayerStatementLimit`, or zero when one of its dimensions is zero.
fn player_statement_limit() -> BoundedStatementAllowance {

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.

maybe let's rename this function, it is too close to player_statement_limits I think we should avoid using it directly, so we can make the name more in this direction, like dynamic_player_statement_limit.

Comment thread pallets/game/src/lib.rs
if next != limits.next {
PlayerStatementLimits::<T>::put(PlayerStatementLimitsRecord { next, ..limits });
}
}

@gui1117 gui1117 Nov 24, 2026 •

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.

maybe we could move it into its own function and the code at the end too, then we write down on top of PlayerStatementLimits that is must never be read/write directly but instead use the manager in the module player_statement_limit::PlayerStatementLimitManager. and put all those functions there. Similar to coinage and recycler_manager::RecyclerManager.

But also it is ok as it is.

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

Labels

C0-non-breaking This PR is not a breaking change for any runtime consuming it. D2-no audit No audit is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants