feat: add per-account flags to block receiving TAO, Alpha, and locked Alpha#2746
Open
ppolewicz wants to merge 488 commits into
Open
feat: add per-account flags to block receiving TAO, Alpha, and locked Alpha#2746ppolewicz wants to merge 488 commits into
ppolewicz wants to merge 488 commits into
Conversation
… alpha! that is not needed
…ove-registry-pallet
Added eco-tests for indexer + CI job to notify the indexer team
fix timeout in ts e2e dev test
Remove pallet-registry from runtime
13 tasks
record db cost for precompile view functions
Contributor
|
cACK |
… Alpha Implements issue #2730. Adds three new storage maps (BlockReceivingTao, BlockReceivingAlpha, BlockReceivingLockedAlpha), three new extrinsics (call_index 139/140/141), and enforces the flags in transfer_tao, stake_into_subnet, and transfer_lock. Includes 9 unit tests.
… path, add benchmarks - R-1: Move TAO and Alpha block checks before unstake_from_subnet mutation in transition_stake_internal so all guards fire pre-mutation (guard-first pattern). - R-2: Add BlockReceivingAlpha check in the same-subnet branch of transition_stake_internal so same-subnet cross-coldkey transfers are also blocked. - R-5: Correct set_block_receiving_tao docstring to reflect the narrowed check scope. - R-4: Add guesstimated #[benchmark] entries for the three new extrinsics so CD can generate accurate weights later. - R-6: Add test_block_receiving_alpha_prevents_same_subnet_transfer to cover R-2.
…x coldkey swap migration - Rename BlockReceivingAlpha → ReceivingAlphaEnabled with inverted (opt-in) semantics: cross-coldkey Alpha transfers are blocked by default; coldkeys must call set_receiving_alpha_enabled(true) to receive Alpha from other coldkeys. - Remove BlockReceivingAlpha check from validate_add_stake so self-staking always works. - Add pallet getter functions: get_receiving_alpha_enabled, get_block_receiving_tao, get_block_receiving_locked_alpha. - Add three precompile view functions to StakingPrecompileV2: isReceivingTaoBlocked, isReceivingAlphaEnabled, isReceivingLockedAlphaBlocked. - R-1: Migrate all three BlockReceiving flags during coldkey swap (take+insert pattern). - R-5: Document intentional bypass of ReceivingAlphaEnabled in buy_alpha order path. - R-6: Add tests covering cross-subnet and same-subnet alpha-blocked-by-default paths.
8b4f7ca to
ed882df
Compare
Contributor
eco-tests changed — indexer review requiredThis PR modifies files under Changed files
|
…in tests The two cross-coldkey transfer tests in chain-extensions now require ReceivingAlphaEnabled=true for the destination coldkey to succeed, matching the new opt-in semantics of the alpha-transfer flag.
…rStakeFrom test The staking_precompile_v2_transfer_stake_from_consumes_allowance_and_moves_stake test performs a cross-coldkey stake transfer to the spender account, which now requires ReceivingAlphaEnabled=true under the new opt-in alpha-transfer semantics.
…er_stake test The test_transfer_stake_fees_alpha test performs a cross-coldkey stake transfer, which now requires ReceivingAlphaEnabled=true for the destination coldkey under the new opt-in alpha-transfer semantics.
…sferStake Cross-coldkey stake transfers now require the destination coldkey to have ReceivingAlphaEnabled=true. Add setReceivingAlphaEnabled utility and call it in the TypeScript E2E tests before each cross-coldkey transferStake call.
Biome requires the chained method calls on a single line.
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.
Summary
Implements issue #2730: adds the ability for a destination address to block incoming transfers of TAO, staked Alpha, and locked Alpha.
What was added
3 new storage maps in
pallet-subtensor:BlockReceivingTao<T>— per-account flag to block incoming TAO transfers (only cross-coldkey paths)BlockReceivingAlpha<T>— per-account flag to block incoming staked-Alpha transfers (user-facing entry points only; internal system re-staking is unaffected)BlockReceivingLockedAlpha<T>— per-account flag to block incoming locked-Alpha transfers3 new extrinsics (call indices 139 / 140 / 141):
set_block_receiving_tao(enabled: bool)set_block_receiving_alpha(enabled: bool)set_block_receiving_locked_alpha(enabled: bool)Each extrinsic uses
insertwhen enabling (saves storage only whentrue) andremovewhen disabling (frees storage), which avoids keeping default-falseentries in state.3 new error variants:
ReceivingTaoBlockedReceivingAlphaBlockedReceivingLockedAlphaBlocked3 new events:
BlockReceivingTaoSet { account, enabled }BlockReceivingAlphaSet { account, enabled }BlockReceivingLockedAlphaSet { account, enabled }Enforcement in existing transfer paths:
transition_stake_internal(cross-coldkey TAO transfer) checksBlockReceivingTao— hoisted before any mutations (guard-first pattern)transition_stake_internal(cross-coldkey Alpha re-stake) checksBlockReceivingAlpha— hoisted before any mutationstransition_stake_internalsame-subnet branch checksBlockReceivingAlphafor cross-coldkey transfersdo_add_stake(user-facing stake entry point) checksBlockReceivingAlphatransfer_lockchecksBlockReceivingLockedAlphaWeight benchmarks added for all three new extrinsics (
set_block_receiving_tao,set_block_receiving_alpha,set_block_receiving_locked_alpha).10 unit tests in
pallets/subtensor/src/tests/block_receiving.rscovering set/clear, blocking, and allow-after-clear for each flag, plus a new test covering the same-subnet cross-coldkey Alpha block path.Fixes applied (code review)
unstake_from_subnetmutation intransition_stake_internalso all guards fire pre-mutation.BlockReceivingAlphacheck in the same-subnet branch oftransition_stake_internalso same-subnet cross-coldkey transfers are also blocked.#[benchmark]entries for the three new extrinsics so CI can generate accurate weights.set_block_receiving_taodocstring to reflect the narrowed check scope (cross-coldkey TAO transfer only).test_block_receiving_alpha_prevents_same_subnet_transferto cover the R-2 fix.Test plan
cargo fmt -p pallet-subtensor— no formatting issuescargo clippy -p pallet-subtensor --tests— no errorscargo test -p pallet-subtensor block_receiving— 10/10 tests pass