game: Clean up Merkle trees - #28
Open
tindzk wants to merge 4 commits into
Open
Conversation
Zebedeusz
approved these changes
Aug 21, 2026
|
|
||
| fn tree_deletion_xcm(encoded_call: Vec<u8>) -> Xcm<()> { | ||
| Xcm(vec![ | ||
| UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, |
Collaborator
There was a problem hiding this comment.
why WeightLimit:Unlimited and not a benchmarked weight?
Contributor
Author
There was a problem hiding this comment.
Limited(m) must cover the weight the destination (game chain) computes. We cannot benchmark it here. A hardcoded value would silently drop messages if the game chain weights change.
shawntabrizi
approved these changes
Aug 31, 2026
shawntabrizi
left a comment
Member
There was a problem hiding this comment.
This code may need a storage migration depending on when it lands.
Otherwise stale storage will mess up the state transition function.
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.
Until now, credit trees were retained indefinitely on both chains. This PR implements removal:
Lifecycle of one tree
stateDiagram-v2 state "Fully claimed" as Claimed [*] --> Stored: receive_credit_trees [*] --> Rejected: already past its deadline on arrival Stored --> Claimed: every leaf claimed Stored --> Expired: claim deadline passed, swept by bucket Claimed --> Queued: deletion queued Expired --> Queued: deletion queued Queued --> [*]: sent to the People chain Rejected --> [*]Delivery and deletion across the two chains
sequenceDiagram participant PeopleOcw as People offchain worker participant Credits as nft-credits, People participant Claims as nft-claims, Asset Hub participant AhOcw as Asset Hub offchain worker participant User as Claimant Credits->>Claims: receive_credit_trees User->>Claims: claim, mints the NFT Note over Claims: last leaf of a tree claimed,<br/>tree removed and deletion queued AhOcw->>Claims: sweep_expired_trees, one bucket Note over Claims: trees past the claim deadline removed,<br/>deletions queued AhOcw->>Claims: send_tree_deletions Claims->>Credits: receive_tree_deletions, XCM Note over Credits: named roots removed PeopleOcw->>Credits: sweep_expired_roots, one bucket Note over Credits: roots past their own deadline removed,<br/>covers for a lost messageBoth sweeps walk one bucket of wall-clock time per call. A tree's bucket is the UTC day its credits
were awarded in. A sweep therefore selects the trees that are due instead of reading every tree.
On Asset Hub, a tree is dropped 90 days after the credits were awarded, which is the claim deadline.
The People chain keeps the root it was built from for a further 30 days. That deadline is derived
from the Asset Hub one, so the two cannot drift apart. A credit inside its deadline always has a root
and its awards to prove against.
Changes
tree that arrives past its deadline is not stored. Removals queue up and go out to the People chain
as one message, both driven by the offchain worker.
message ever named.
offchain submission is shared too, so a stalled submitter behaves the same on either chain.
integrity test asserts that its sweeps fit a block and that a full deletion message fits the
channel.