Feat: Proxy aware chain extensions#2383
Feat: Proxy aware chain extensions#2383LandynDev wants to merge 6 commits intoopentensor:devnet-readyfrom
Conversation
chain-extensions/src/lib.rs
Outdated
| pallet_proxy::Pallet::<T>::find_proxy( | ||
| &real_coldkey, | ||
| &caller, | ||
| Some(ProxyType::Staking), |
There was a problem hiding this comment.
Should we check other ProxyType like Any also enable the add_stake call.
|
All V2 extensions are not the upgrade or replace of V1. Could use the name like proxy_xxx. |
Went ahead and went this direction, was simplest. |
Description
I noticed that the V1 chain extensions aren't proxy aware
Functions like
TransferStakeV1useenv.caller()directly as the origin - https://github.com/opentensor/subtensor/blob/main/chain-extensions/src/lib.rs#L245If 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::proxywrapping instead of chain extensions b/c of this.Type of Change
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
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyScreenshots
Unit Tests:

Local E2E tests: ink! contract using new
ProxyCallchain extensionThe

solutioncli command maps to a smart contract function that will use the newproxy_callchain extension in order totransfer_stakeof the bounty amount to the miner. (Notice miner has no balance before)Can see here that

transfer_stakesucceeded 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 extensionAdditional Notes