subtensor icon indicating copy to clipboard operation
subtensor copied to clipboard

Enable Caller Context Preservation in Chain Extension for Staking Operations

Open khemrajregmi opened this issue 8 months ago • 4 comments

Is your feature request related to a problem? Please describe.

At present, whenever a contract invokes the chain extension, the extension assigns the contract itself as the caller. This results in:

  • Loss of the original transaction sender context
  • Inability for users to move or manage their stake via contract calls
  • Limited composability for DeFi and staking abstractions

Describe the solution you'd like

Expected Behavior

The chain extension should support preserving or forwarding the original caller context (msg.sender equivalent), allowing:

  • Users to interact with staking logic through contracts
  • Stake operations to be executed on behalf of the actual caller, not the contract
  • More flexible and composable contract-based staking mechanisms

Proposed Solution

Introduce a modified or new chain extension that:

  • Allows passing the original caller as the effective actor in staking operations
  • Alternatively, provides a mechanism to explicitly specify the caller context when invoking the extension
  • Ensures proper authorization and security checks to prevent misuse

Describe alternatives you've considered

No response

Additional context

No response

khemrajregmi avatar Mar 31 '26 07:03 khemrajregmi

Alternatively, provides a mechanism to explicitly specify the caller context when invoking the extension

I prefer we use the different functions to specify the origin is contract or caller.

open-junius avatar Mar 31 '26 12:03 open-junius

Hi @open-junius , are you working on this right now? If not, would you mind if I take it on? I’d love to contribute.

statxc avatar Apr 01 '26 01:04 statxc

@statxc yes, I am on it. you can help to review the PR, it will be ready soon. thanks!

open-junius avatar Apr 01 '26 02:04 open-junius

Does delegate_call solve this issue for you?

camfairchild avatar Apr 08 '26 14:04 camfairchild