Skip to content

Game: clear every chunk that the weight covers in the game clean-up steps - #266

Merged
andrzejSulkowski merged 6 commits into
mainfrom
as-fix-game-clear-cursor
Nov 25, 2026
Merged

andrzejSulkowski merged 6 commits into
mainfrom
as-fix-game-clear-cursor

Conversation

@andrzejSulkowski

@andrzejSulkowski andrzejSulkowski commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #264

player_process_step2 and the shuffle drain of process_cancelling cleared one chunk of 100 entries per call, but charged every chunk that the weight covered. A storage clear ignores its cursor, so each further clear in the same block walked the same keys again.

Changes

  • Each step clears every map once, with a limit sized to the remaining weight.
  • Each step charges the chunks that the clear used.
  • A clear that walks more keys than its limit raises a defensive failure.

The benchmarks do the same work as before, so the weights are not regenerated.

@andrzejSulkowski
andrzejSulkowski requested a review from a team November 23, 2026 14:58
@andrzejSulkowski andrzejSulkowski added D5-nice to have audit optional to have, meant to express "audit it if there is bandwidth" C0-non-breaking This PR is not a breaking change for any runtime consuming it. labels Nov 23, 2026
Comment thread pallets/game/src/lib.rs Resolved
Comment thread pallets/game/src/types.rs Resolved
@andrzejSulkowski
andrzejSulkowski requested a review from a team November 24, 2026 10:34
@andrzejSulkowski
andrzejSulkowski force-pushed the as-fix-game-clear-cursor branch 2 times, most recently from 63026da to 9aa2c75 Compare November 24, 2026 14:49
Comment thread pallets/game/src/lib.rs Resolved
Comment thread pallets/game/src/tests.rs Resolved
Comment thread pallets/game/src/types.rs Resolved
Comment thread pallets/game/src/lib.rs Resolved
Comment thread pallets/game/src/benchmarking.rs Resolved
@andrzejSulkowski
andrzejSulkowski merged commit dc5d719 into main Nov 25, 2026
19 of 21 checks passed
@andrzejSulkowski
andrzejSulkowski deleted the as-fix-game-clear-cursor branch November 25, 2026 14:07
andrzejSulkowski added a commit that referenced this pull request Nov 25, 2026
…cess clears (#267)

Stacked on #266.

Step 2 of the player process charged only the keys that it walked in the
index maps. `clear_game_credits` returned only a cursor, so the step
could not count the credit entries that it cleared.

## Changes

- `AwardCredits::clear_game_credits` returns the removal result and
takes no cursor.
- Step 2 charges the chunks of credit entries that it clears.

_The benchmarks do the same work as before, so the weights are not
regenerated._

---------

Signed-off-by: Andrzej Sulkowski <developer@andrzej-sulkowski.com>
Co-authored-by: theo <37565691+agustinustheo@users.noreply.github.com>
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. D5-nice to have audit optional to have, meant to express "audit it if there is bandwidth"

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants