Skip to content

Commit 4d89bef

Browse files
committed
revert change
1 parent c8ed5c9 commit 4d89bef

File tree

4 files changed

+43
-31
lines changed

4 files changed

+43
-31
lines changed

evm-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"scripts": {
3-
"test": "mocha --timeout 999999 --retries 3 --file src/setup.ts --require ts-node/register test/alphaPool*test.ts"
3+
"test": "mocha --timeout 999999 --retries 3 --file src/setup.ts --require ts-node/register test/*test.ts"
44
},
55
"keywords": [],
66
"author": "",

pallets/subtensor/src/staking/move_stake.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,9 @@ impl<T: Config> Pallet<T> {
126126
destination_netuid: NetUid,
127127
alpha_amount: AlphaCurrency,
128128
) -> dispatch::DispatchResult {
129-
log::error!("================== {} {}", file!(), line!());
129+
log::error!("alpha_amount is {:?} ", alpha_amount.to_u64());
130130
// Ensure the extrinsic is signed by the origin_coldkey.
131131
let coldkey = ensure_signed(origin)?;
132-
log::error!("================== {} {}", file!(), line!());
133132

134133
// Validate input and move stake
135134
let tao_moved = Self::transition_stake_internal(
@@ -146,11 +145,13 @@ impl<T: Config> Pallet<T> {
146145
false,
147146
)?;
148147

148+
log::error!("tao_moved is {} ", tao_moved.to_u64());
149+
149150
// 9. Emit an event for logging/monitoring.
150151
log::debug!(
151152
"StakeTransferred(origin_coldkey: {coldkey:?}, destination_coldkey: {destination_coldkey:?}, hotkey: {hotkey:?}, origin_netuid: {origin_netuid:?}, destination_netuid: {destination_netuid:?}, amount: {tao_moved:?})"
152153
);
153-
log::error!("================== {} {}", file!(), line!());
154+
154155
Self::deposit_event(Event::StakeTransferred(
155156
coldkey,
156157
destination_coldkey,
@@ -159,7 +160,9 @@ impl<T: Config> Pallet<T> {
159160
destination_netuid,
160161
tao_moved,
161162
));
162-
log::error!("================== {} {}", file!(), line!());
163+
164+
log::error!("tao_moved {}", tao_moved.to_u64());
165+
163166
// 10. Return success.
164167
Ok(())
165168
}
@@ -311,17 +314,15 @@ impl<T: Config> Pallet<T> {
311314
check_transfer_toggle: bool,
312315
set_limit: bool,
313316
) -> Result<TaoCurrency, DispatchError> {
314-
log::error!("================== {} {}", file!(), line!());
315317
// Cap the alpha_amount at available Alpha because user might be paying transaxtion fees
316318
// in Alpha and their total is already reduced by now.
317319
let alpha_available = Self::get_stake_for_hotkey_and_coldkey_on_subnet(
318320
origin_hotkey,
319321
origin_coldkey,
320322
origin_netuid,
321323
);
322-
log::error!("================== {} {}", file!(), line!());
324+
323325
let alpha_amount = alpha_amount.min(alpha_available);
324-
log::error!("================== {} {}", file!(), line!());
325326

326327
// Calculate the maximum amount that can be executed
327328
let max_amount = if origin_netuid != destination_netuid {
@@ -333,7 +334,8 @@ impl<T: Config> Pallet<T> {
333334
} else {
334335
alpha_amount
335336
};
336-
log::error!("================== {} {}", file!(), line!());
337+
338+
log::error!("alpha_amount is {:?} ", &max_amount);
337339
// Validate user input
338340
Self::validate_stake_transition(
339341
origin_coldkey,
@@ -347,20 +349,20 @@ impl<T: Config> Pallet<T> {
347349
maybe_allow_partial,
348350
check_transfer_toggle,
349351
)?;
350-
log::error!("================== {} {}", file!(), line!());
352+
351353
// Calculate the amount that should be moved in this operation
352354
let move_amount = if alpha_amount < max_amount {
353355
alpha_amount
354356
} else {
355357
max_amount
356358
};
357-
log::error!("================== {} {}", file!(), line!());
359+
360+
log::error!("move_amount is {:?} ", move_amount.to_u64());
358361

359362
if origin_netuid != destination_netuid {
360363
// Any way to charge fees that works
361364
let drop_fee_origin = origin_netuid == NetUid::ROOT;
362365
let drop_fee_destination = !drop_fee_origin;
363-
log::error!("================== {} {}", file!(), line!());
364366

365367
// do not pay remove fees to avoid double fees in moves transactions
366368
let tao_unstaked = Self::unstake_from_subnet(
@@ -371,17 +373,16 @@ impl<T: Config> Pallet<T> {
371373
T::SwapInterface::min_price().into(),
372374
drop_fee_origin,
373375
)?;
376+
log::error!("tao_unstaked is {:?} ", tao_unstaked.to_u64());
374377

375378
// Stake the unstaked amount into the destination.
376379
// Because of the fee, the tao_unstaked may be too low if initial stake is low. In that case,
377380
// do not restake.
378381
if tao_unstaked >= DefaultMinStake::<T>::get() {
379-
log::error!("================== {} {}", file!(), line!());
380382
// If the coldkey is not the owner, make the hotkey a delegate.
381383
if Self::get_owning_coldkey_for_hotkey(destination_hotkey) != *destination_coldkey {
382384
Self::maybe_become_delegate(destination_hotkey);
383385
}
384-
log::error!("================== {} {}", file!(), line!());
385386

386387
Self::stake_into_subnet(
387388
destination_hotkey,
@@ -396,7 +397,6 @@ impl<T: Config> Pallet<T> {
396397

397398
Ok(tao_unstaked)
398399
} else {
399-
log::error!("================== {} {}", file!(), line!());
400400
Self::transfer_stake_within_subnet(
401401
origin_coldkey,
402402
origin_hotkey,

pallets/subtensor/src/staking/stake_utils.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,10 @@ impl<T: Config> Pallet<T> {
861861
netuid,
862862
alpha,
863863
);
864+
log::error!(
865+
"actual_alpha_decrease is {} ",
866+
actual_alpha_decrease.to_u64()
867+
);
864868

865869
// Increase alpha on destination keys
866870
let actual_alpha_moved = Self::increase_stake_for_hotkey_and_coldkey_on_subnet(
@@ -869,6 +873,7 @@ impl<T: Config> Pallet<T> {
869873
netuid,
870874
actual_alpha_decrease,
871875
);
876+
log::error!("actual_alpha_moved is {} ", actual_alpha_moved.to_u64());
872877

873878
// Calculate TAO equivalent based on current price (it is accurate because
874879
// there's no slippage in this move)
@@ -878,6 +883,7 @@ impl<T: Config> Pallet<T> {
878883
.saturating_mul(U96F32::saturating_from_num(actual_alpha_moved))
879884
.saturating_to_num::<u64>()
880885
.into();
886+
log::error!("tao_equivalent is {} ", tao_equivalent.to_u64());
881887

882888
// Ensure tao_equivalent is above DefaultMinStake
883889
ensure!(
@@ -1107,68 +1113,68 @@ impl<T: Config> Pallet<T> {
11071113
maybe_allow_partial: Option<bool>,
11081114
check_transfer_toggle: bool,
11091115
) -> Result<(), Error<T>> {
1110-
log::error!("================== {} {}", file!(), line!());
1116+
11111117
// Ensure stake transition is actually happening
11121118
if origin_coldkey == destination_coldkey && origin_hotkey == destination_hotkey {
11131119
ensure!(origin_netuid != destination_netuid, Error::<T>::SameNetuid);
11141120
}
1115-
log::error!("================== {} {}", file!(), line!());
1121+
11161122
Self::ensure_stake_operation_limit_not_exceeded(
11171123
origin_hotkey,
11181124
origin_coldkey,
11191125
origin_netuid.into(),
11201126
)?;
1121-
log::error!("================== {} {}", file!(), line!());
1127+
11221128

11231129
// Ensure that both subnets exist.
11241130
ensure!(
11251131
Self::if_subnet_exist(origin_netuid),
11261132
Error::<T>::SubnetNotExists
11271133
);
1128-
log::error!("================== {} {}", file!(), line!());
1134+
11291135
if origin_netuid != destination_netuid {
11301136
ensure!(
11311137
Self::if_subnet_exist(destination_netuid),
11321138
Error::<T>::SubnetNotExists
11331139
);
11341140
}
1135-
log::error!("================== {} {}", file!(), line!());
1141+
11361142

11371143
ensure!(
11381144
SubtokenEnabled::<T>::get(origin_netuid),
11391145
Error::<T>::SubtokenDisabled
11401146
);
1141-
log::error!("================== {} {}", file!(), line!());
1147+
11421148

11431149
ensure!(
11441150
SubtokenEnabled::<T>::get(destination_netuid),
11451151
Error::<T>::SubtokenDisabled
11461152
);
1147-
log::error!("================== {} {}", file!(), line!());
1153+
11481154
// Ensure that the origin hotkey account exists
11491155
ensure!(
11501156
Self::hotkey_account_exists(origin_hotkey),
11511157
Error::<T>::HotKeyAccountNotExists
11521158
);
1153-
log::error!("================== {} {}", file!(), line!());
1159+
11541160
// Ensure that the destination hotkey account exists
11551161
ensure!(
11561162
Self::hotkey_account_exists(destination_hotkey),
11571163
Error::<T>::HotKeyAccountNotExists
11581164
);
1159-
log::error!("================== {} {}", file!(), line!());
1165+
11601166
// Ensure there is enough stake in the origin subnet.
11611167
let origin_alpha = Self::get_stake_for_hotkey_and_coldkey_on_subnet(
11621168
origin_hotkey,
11631169
origin_coldkey,
11641170
origin_netuid,
11651171
);
1166-
log::error!("================== {} {}", file!(), line!());
1172+
11671173
ensure!(
11681174
alpha_amount <= origin_alpha,
11691175
Error::<T>::NotEnoughStakeToWithdraw
11701176
);
1171-
log::error!("================== {} {}", file!(), line!());
1177+
11721178
// If origin and destination netuid are different, do the swap-related checks
11731179
if origin_netuid != destination_netuid {
11741180
// Ensure that the stake amount to be removed is above the minimum in tao equivalent.
@@ -1183,25 +1189,25 @@ impl<T: Config> Pallet<T> {
11831189
TaoCurrency::from(tao_equivalent) > DefaultMinStake::<T>::get(),
11841190
Error::<T>::AmountTooLow
11851191
);
1186-
log::error!("================== {} {}", file!(), line!());
1192+
11871193
// Ensure that if partial execution is not allowed, the amount will not cause
11881194
// slippage over desired
11891195
if let Some(allow_partial) = maybe_allow_partial {
11901196
if !allow_partial {
1191-
log::error!("================== {} {}", file!(), line!());
1197+
11921198
ensure!(alpha_amount <= max_amount, Error::<T>::SlippageTooHigh);
11931199
}
11941200
}
11951201
}
11961202

11971203
if check_transfer_toggle {
1198-
log::error!("================== {} {}", file!(), line!());
1204+
11991205
// Ensure transfer is toggled.
12001206
ensure!(
12011207
TransferToggle::<T>::get(origin_netuid),
12021208
Error::<T>::TransferDisallowed
12031209
);
1204-
log::error!("================== {} {}", file!(), line!());
1210+
12051211
if origin_netuid != destination_netuid {
12061212
ensure!(
12071213
TransferToggle::<T>::get(destination_netuid),

precompiles/src/staking.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,14 @@ where
194194
destination_netuid: U256,
195195
amount_alpha: U256,
196196
) -> EvmResult<()> {
197-
log::error!("================== {} {}", file!(), line!());
197+
log::error!("++++++++++++++++++ {} {}", file!(), line!());
198198
let account_id = handle.caller_account_id::<R>();
199+
log::error!("account id is {:?} ", &account_id);
200+
log::error!("destination_coldkey is {:?} ", &destination_coldkey);
201+
log::error!("hotkey is {:?} ", &hotkey);
202+
log::error!("origin_netuid is {:?} ", &origin_netuid);
203+
log::error!("destination_netuid is {:?} ", &destination_netuid);
204+
log::error!("amount_alpha is {:?} ", &amount_alpha);
199205
let destination_coldkey = R::AccountId::from(destination_coldkey.0);
200206
let hotkey = R::AccountId::from(hotkey.0);
201207
let origin_netuid = try_u16_from_u256(origin_netuid)?;

0 commit comments

Comments
 (0)