Skip to content

Feat: Proxy aware chain extensions#2383

Open
LandynDev wants to merge 6 commits intoopentensor:devnet-readyfrom
LandynDev:feat/proxy-aware-chain-exts
Open

Feat: Proxy aware chain extensions#2383
LandynDev wants to merge 6 commits intoopentensor:devnet-readyfrom
LandynDev:feat/proxy-aware-chain-exts

Conversation

@LandynDev
Copy link

@LandynDev LandynDev commented Jan 29, 2026

Description

I noticed that the V1 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.
This introduces a new chain extension to wrap runtime calls with correct proxy perms.

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

Unit Tests:
image

Local E2E tests: ink! contract using new ProxyCall chain extension

The solution cli command maps to a smart contract function that will use the new proxy_call chain extension in order to transfer_stake of the bounty amount to the miner. (Notice miner has no balance before)
image

Can see here that transfer_stake succeeded as miners wallet balance received the transfer. Shows that these changes now allow the contract to act on behalf of its delegated permissions via chain extension
image

Additional Notes

@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.

@LandynDev
Copy link
Author

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.

Went ahead and went this direction, was simplest.
Updated PR descr. with added testing from these simplified changes
Thanks for the review

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