feat(chain-extensions): add claim-root-with-hotkey for contract root-basket claims - #3099
Open
Benup211 wants to merge 5 commits into
Open
feat(chain-extensions): add claim-root-with-hotkey for contract root-basket claims#3099Benup211 wants to merge 5 commits into
Benup211 wants to merge 5 commits into
Conversation
…basket claims Exposes function 37 (ClaimRootWithHotkeyV1) so an ink! contract that holds root stake as a coldkey can claim its per-validator basket entitlement through the 0x1000 chain extension. The contract is the coldkey; realized TAO is staked back to root on the hotkey and the realized amount is returned. Basket work is bounded to MAX_ROOT_CLAIM_WORK and charged upfront (no post-dispatch refund), mirroring the signed extrinsic's admission gate.
|
@Benup211 is attempting to deploy a commit to the RaoFoundation Team on Vercel. A member of the Team first needs to authorize it. |
…laim-root-with-hotkey Seeds the hotkey's root basket with MAX_ROOT_CLAIM_WORK + 1 escrow rows and asserts ClaimRootWithHotkeyV1 returns RuntimeError before charging any weight.
UnArbosSix
requested changes
Sep 1, 2026
UnArbosSix
left a comment
Collaborator
There was a problem hiding this comment.
Successful contract claims can leave the root-staker coldkey index inconsistent. The new chain-extension arm calls do_root_claim(caller, vec![hotkey]) directly and returns the payout, but never calls maybe_add_coldkey_index(&caller). The normal claim_root_with_hotkey extrinsic explicitly does exactly that after do_root_claim, so this is a real semantic difference between the two entry points, not incidental cleanup.
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.
Description
Adds a new chain-extension function (
ClaimRootWithHotkeyV1, id 39) so an pallet/ink! contract that holds root (netuid 0) stake as a coldkey can claim its per-validator basket entitlement through the0x1000chain extension.do_root_claim(env.caller(), vec![hotkey])is invoked with the contract address as the origin.RootClaimOutcome::tao) is written back so the contract can update its own bookkeeping.MAX_ROOT_CLAIM_WORK(256) before charging any weight, mirroring the rows clause of the signed extrinsic'sroot_claim_fits_declared_budgetadmission gate. The fullclaim_root(MAX_ROOT_CLAIM_WORK)weight is then charged viaenv.charge_weight(a chain extension has no post-dispatch weight refund).Files changed:
chain-extensions/src/types.rs— addClaimRootWithHotkeyV1 = 39toFunctionIdchain-extensions/src/lib.rs— dispatch arm (decode → bound → charge weight → claim → write output)chain-extensions/src/tests.rs—claim_root_with_hotkey_noop_returns_zero(success path: full 256-unit charge, zero payout) andclaim_root_with_hotkey_rejects_basket_above_envelope(257-row basket →RuntimeError, no weight charged)Related Issue(s)
None.
Type of Change
Breaking Change
No breaking change. This is purely additive: a new chain-extension function id (39) and dispatch arm. Existing function ids 0–38 and their SCALE encodings are unchanged.
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyScreenshots (if applicable)
N/A
Additional Notes
MoveStakeLimitV1,CallerMoveStakeLimitV1) were taken by release-448, so this function landed on 39. The discriminant and roundtrip tests assert16..=39.spec_versionbump (or theno-spec-version-bumplabel) — left for the release train / maintainer to coordinate.cargo test -p subtensor-chain-extensions— 57 passed, 0 failed (incl. both claim tests)cargo clippy -p subtensor-chain-extensions --all-targets— cleancargo fmt -p subtensor-chain-extensions -- --check— clean./scripts/fix_rust.shwas not run (it auto-commits workspace-wide).claim_root(MAX_ROOT_CLAIM_WORK)charge with a pre-charge row-count bound is deliberate — unlike the signed extrinsic (which declares the same 256-unit envelope and refunds post-dispatch down toroot_claim_actual_weight), a chain extension has no post-dispatch refund, so the envelope must be charged in full and oversized baskets rejected before any weight is charged.