Feat/recycle burn chain exts#2560
Conversation
|
Thanks for the contribution. Can you add the ticket for the requirement? I am wondering the extension like AddStakeRecycleV1, who really want to do it. just confirm all is from the real requirements. |
Just got it ticketed up here - #2564 Particular snippet from the issue to elaborate on the AddStakeBurn + AddStakeRecycle funcs and why those 2 are included:
|
|
Looks good to me, please fix the 'Cargo fmt' |
👍 |
Strip development log::info!/log::error! calls from dispatch entry and AddStakeRecycleV1 handler. Normalize AddStakeRecycleV1 to use the same concise ? pattern as all other handlers.
e527c74 to
1c4f180
Compare
|
it also needed |
|
Addressed the review feedback:
@evgeny-s / @open-junius if you could give this a re-look when you have a chance, thanks Commit of changes: 65357d3 |
chain-extensions/src/lib.rs
Outdated
|
|
||
| match call_result { | ||
| Ok(_) => { | ||
| env.write_output(&amount.encode()) |
There was a problem hiding this comment.
I can see you remove the real_amount, and put the amount into result directly. but it could be wrong if the amount is more than you staked. So I suggest we can update the recycle_alpha function with the real recycled alpha as result, or doesn't return any value in RecycleAlphaV1. and the same for burn function.
There was a problem hiding this comment.
Good call, I got it updated w this commit - 60dffb3
Trying to keep the diff concise with what i add/change. Reran unit tests and passing

Description
Add 4 new chain extension functions (IDs 16-19) enabling WASM smart contracts to recycle and burn alpha stake.
RecycleAlphaV1(16): Recycle alpha stakeBurnAlphaV1(17): Burn alpha stakeAddStakeRecycleV1(18): Atomically add TAO stake then recycleAddStakeBurnV1(19): Atomically add TAO stake then burnAll functions return the actual alpha amount via the output buffer.
Related Issue(s)
Closes #2564
Type of Change
Breaking Change
No breaking changes. Existing chain extension functions (IDs 0-15) are unaffected. New function IDs 16-19 are additive.
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyAdditional Notes
7 unit tests cover: success paths for all 4 functions, root subnet rejection, nonexistent subnet, and insufficient balance. E2E validated on localnet with an ink! contract calling
add_stake_recyclevia chain extension.I also ran some local E2E testing with a local running subtensor chain (with the new extensions), deployed contract, etc.
Screenshot 1 shows:
Screenshot 2 shows:
Unit tests successfully passing:
