Skip to content

feat: add origin AccountId to StakeAdded/StakeRemoved events#2459

Open
altis0725 wants to merge 3 commits intoopentensor:mainfrom
altis0725:feat/stake-event-origin-accountid
Open

feat: add origin AccountId to StakeAdded/StakeRemoved events#2459
altis0725 wants to merge 3 commits intoopentensor:mainfrom
altis0725:feat/stake-event-origin-accountid

Conversation

@altis0725
Copy link

Fixes #311

Summary

  • Add origin (T::AccountId) as the first field of StakeAdded and StakeRemoved events to identify which account initiated the staking operation
  • The origin is the coldkey for direct extrinsic calls and the lease coldkey for automated distributions
  • Update all emit sites in stake_utils.rs (stake_into_subnet, unstake_from_subnet, transfer_stake_within_subnet) to propagate the origin parameter
  • Bump spec_version 380 → 381 for the event metadata change

Test plan

  • Added test_add_stake_event_has_origin asserting StakeAdded origin == coldkey
  • Added test_remove_stake_event_has_origin asserting StakeRemoved origin == coldkey
  • Updated test_do_move_event_emission to verify origin in both StakeRemoved and StakeAdded during move operations
  • CI compilation and existing test suite pass

🤖 Generated with Claude Code

altis0725 and others added 3 commits February 25, 2026 22:46
Fixes opentensor#311

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Bump spec_version 380 -> 381 for event metadata breaking change
- Clarify origin field documentation (coldkey from ensure_signed)
- Add test_add_stake_event_has_origin to verify origin field in events

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update event comments to accurately describe origin semantics for both
  extrinsic calls and automated distributions (leasing)
- Add test_remove_stake_event_has_origin for StakeRemoved origin assertion
- Add StakeRemoved/StakeAdded origin assertions to move_stake event test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@altis0725 altis0725 force-pushed the feat/stake-event-origin-accountid branch from 737952e to 8f099f5 Compare February 25, 2026 13:47
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.

Add the origin AccountId to StakeAdded and StakeRemoved events

1 participant