Skip to content

Commit df9ae51

Browse files
Add remove_stake_full_limit precompile.
1 parent b4368fb commit df9ae51

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,7 @@ mod dispatches {
24512451
) -> DispatchResult {
24522452
let account_id = crate::ensure_evm_origin(<T as Config>::RuntimeOrigin::from(origin))?;
24532453
let verified_evm_origin = RawOrigin::Signed(account_id);
2454-
2454+
24552455
Self::do_move_stake(
24562456
verified_evm_origin.into(),
24572457
origin_hotkey,
@@ -2477,7 +2477,7 @@ mod dispatches {
24772477
) -> DispatchResult {
24782478
let account_id = crate::ensure_evm_origin(<T as Config>::RuntimeOrigin::from(origin))?;
24792479
let verified_evm_origin = RawOrigin::Signed(account_id);
2480-
2480+
24812481
Self::do_transfer_stake(
24822482
verified_evm_origin.into(),
24832483
destination_coldkey,
@@ -2488,32 +2488,21 @@ mod dispatches {
24882488
)
24892489
}
24902490

2491-
/// swap_stake with EVM origin
2491+
/// remove_stake_full_limit with EVM origin
24922492
#[pallet::call_index(129)]
2493-
#[pallet::weight((
2494-
Weight::from_parts(351_300_000, 0)
2495-
.saturating_add(T::DbWeight::get().reads(32))
2496-
.saturating_add(T::DbWeight::get().writes(17)),
2497-
DispatchClass::Operational,
2498-
Pays::Yes
2499-
))]
2500-
pub fn swap_stake(
2493+
#[pallet::weight((Weight::from_parts(398_000_000, 10142)
2494+
.saturating_add(T::DbWeight::get().reads(30_u64))
2495+
.saturating_add(T::DbWeight::get().writes(14_u64)), DispatchClass::Normal, Pays::Yes))]
2496+
pub fn remove_stake_full_limit_evm(
25012497
origin: OriginFor<T>,
25022498
hotkey: T::AccountId,
2503-
origin_netuid: NetUid,
2504-
destination_netuid: NetUid,
2505-
alpha_amount: AlphaCurrency,
2499+
netuid: NetUid,
2500+
limit_price: Option<u64>,
25062501
) -> DispatchResult {
25072502
let account_id = crate::ensure_evm_origin(<T as Config>::RuntimeOrigin::from(origin))?;
25082503
let verified_evm_origin = RawOrigin::Signed(account_id);
2509-
2510-
Self::do_swap_stake(
2511-
verified_evm_origin.into(),
2512-
hotkey,
2513-
origin_netuid,
2514-
destination_netuid,
2515-
alpha_amount,
2516-
)
2504+
2505+
Self::do_remove_stake_full_limit(verified_evm_origin.into(), hotkey, netuid, limit_price)
25172506
}
25182507
}
25192508
}

precompiles/src/staking.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,15 @@ where
135135
let account_id = handle.caller_account_id::<R>();
136136
let hotkey = R::AccountId::from(hotkey.0);
137137
let netuid = try_u16_from_u256(netuid)?;
138-
let call = pallet_subtensor::Call::<R>::remove_stake_full_limit {
138+
let call = pallet_subtensor::Call::<R>::remove_stake_full_limit_evm {
139139
hotkey,
140140
netuid: netuid.into(),
141141
limit_price,
142142
};
143143

144-
handle.try_dispatch_runtime_call::<R, _>(call, RawOrigin::Signed(account_id))
144+
let evm_origin = R::EvmOriginHelper::make_evm_origin(account_id);
145+
146+
handle.try_dispatch_runtime_call_with_custom_origin::<R, _>(call, evm_origin)
145147
}
146148

147149
#[precompile::public("removeStakeFull(bytes32,uint256)")]

0 commit comments

Comments
 (0)