⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@LandynDev
Copy link

Description

I noticed the chain extensions aren't proxy aware
Functions like TransferStakeV1 use env.caller() directly as the origin - https://github.com/opentensor/subtensor/blob/main/chain-extensions/src/lib.rs#L245

If I'm understanding this right, it means the contract must be the coldkey that owns the stake and proxy relationships aren't checked. Even if a contract has valid proxy permissions, it is forced to use call_runtime with Proxy::proxy wrapping instead of chain extensions b/c of this.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

This PR does not create a breaking change.
These extensions are primarily copies of the v1 versions, just each with:

  • An additional read (for the potential proxy check)
  • A real_coldkey input parameter introduced
  • A proxy check (Applicable whenreal_coldkey != env.caller()
  • Updated RawOrigin assignments on pallet calls accordingly (to allow proxy usage)
  • This diff viewer makes the V1 -> V2 extensions changes clearly viewable: https://www.diffchecker.com/DfqcdhDj/

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Screenshots

image

Additional Notes

  • This PR does not create a breaking change, but the implementation does allow for smooth migrations from V1 chain extension usages to V2. It just requires the argument real_coldkey be passed to the extension. However, this is a little counter intuitive for future contracts that aren't acting on behalf of proxy delegations as they may think "Why do I need to pass who I am (real coldkey)?"
  • I did not benchmark and assign new weight from_parts values, but did add a read for the proxy check.

@LandynDev LandynDev marked this pull request as ready for review January 29, 2026 19:05
pallet_proxy::Pallet::<T>::find_proxy(
&real_coldkey,
&caller,
Some(ProxyType::Staking),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we check other ProxyType like Any also enable the add_stake call.

@open-junius
Copy link
Contributor

All V2 extensions are not the upgrade or replace of V1. Could use the name like proxy_xxx.
Do you consider use the unique extension to implement them all. like proxy_execute(real_coldkey: AccountId, call: RuntimeCall). like in EVM precompile https://github.com/opentensor/subtensor/blob/main/precompiles/src/proxy.rs#L146.

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.

2 participants