Repository navigation
feat(power): read the stashed fuel in the grid snapshot - #335
Merged
Merged
Conversation
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
marked this pull request as ready for review
December 1, 2026 11:18
Contributor
There was a problem hiding this comment.
🟡 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
GridSnapshotand exposessnapshot_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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Read the stashed fuel in the grid snapshot
GridSnapshot(whatprojected_snapshotreturns) now carriesstashed: 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 callstashed_fuelper bay.stashedis 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 regeneratedpowergridbindingsstorestruct, which a compatible Sui upgrade doesn't allow, so it ships with a fresh publish, asdevis redeployed per releasesnapshot_stashedtestnet-v1.78.0)world-sdk:parseProjectedSnapshotdecodes it asstashed: StashedBay[](bay id plus the fuel amounts); the snapshot integration test checks it decodesprojected_snapshotentry mentions the stashWhy: 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