Skip to content

feat(power): read the stashed fuel in the grid snapshot - #335

Merged
JonSteinn merged 2 commits into
mainfrom
feat/snapshot-stashed-fuel
Dec 1, 2026
Merged

JonSteinn merged 2 commits into
mainfrom
feat/snapshot-stashed-fuel

Conversation

@JonSteinn

@JonSteinn JonSteinn commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Read the stashed fuel in the grid snapshot

GridSnapshot (what projected_snapshot returns) now carries stashed: the exact fuel of every uninstalled bay, by component id, as stored. Stashed fuel never burns, so it's copied from the grid with no projection. One read now gives the whole grid including its stashes; before, an off-chain reader had to know each uninstalled bay's id to call stashed_fuel per bay.

  • stashed is the last field. Decoders that reject trailing bytes break until they read it: go-services decodes the snapshot strictly (pkg/bcs), so this has to deploy together with its regenerated powergrid bindings
  • It changes the layout of a store struct, which a compatible Sui upgrade doesn't allow, so it ships with a fresh publish, as dev is redeployed per release
  • New getter snapshot_stashed
  • Tests: the shared snapshot-equals-views assertion now also compares the stash with the grid's, and a new test checks a bay uninstalled with fuel appears in the snapshot's stash and no longer among its bays. All 253 power Move tests pass (sui-tools testnet-v1.78.0)
  • world-sdk: parseProjectedSnapshot decodes it as stashed: StashedBay[] (bay id plus the fuel amounts); the snapshot integration test checks it decodes
  • ADR 0005: the projected_snapshot entry mentions the stash

Why: the creation service reports a creation's power state to the game from this snapshot, and the game needs the fuel held by uninstalled bays.

🤖 Generated with Claude Code

GridSnapshot now carries the exact fuel of every uninstalled bay, as
stored, so one projected_snapshot read gives the whole grid including its
stashes. The field is last, so decoders that don't read it keep working.
@JonSteinn
JonSteinn marked this pull request as ready for review December 1, 2026 11:18
@JonSteinn
JonSteinn requested a review from a team as a code owner December 1, 2026 11:18

@0xxlegolas 0xxlegolas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Copilot AI 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.

🟡 Changes recommended

The new StashedBay type is missing from the package root exports, preventing SDK consumers from importing it through the only exposed entry point.

1 open issue
What changed in this PR

Extends the power-grid snapshot with fuel retained by uninstalled bays, allowing off-chain consumers to read installed bays and stashes in one call.

Changes:

  • Adds stored stash data to GridSnapshot and exposes snapshot_stashed.
  • Updates the SDK snapshot schema and decoder with StashedBay[].
  • Adds Move stash assertions, an SDK empty-stash check, and ADR documentation.
File Description
sdk/​world-sdk/​src/​packages/​power.ts Defines and decodes stashed fuel in snapshots.
sdk/​world-sdk/​src/​__integration__/​power-snapshot.test.ts Checks decoding of an empty stash.
docs/​adr/​0005-onchain-power-network.md Documents stash inclusion in the snapshot.
contracts/​power/​tests/​pool_tests.move Compares snapshot stashes with stored grid stashes.
contracts/​power/​tests/​fuel_bay_tests.move Checks that an uninstalled fueled bay appears only in the stash.
contracts/​power/​sources/​power_grid.move Adds the stash field, populates it without projection, and provides a getter.

Review effort: Balanced

Comment thread sdk/world-sdk/src/packages/power.ts Resolved
@JonSteinn
JonSteinn merged commit e9396f4 into main Dec 1, 2026
4 checks passed
@JonSteinn
JonSteinn deleted the feat/snapshot-stashed-fuel branch December 1, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants