@@ -66,25 +66,16 @@ impl StakingPrecompile {
66
66
}
67
67
68
68
fn add_stake ( handle : & mut impl PrecompileHandle , data : & [ u8 ] ) -> PrecompileResult {
69
- log:: error!( "++++++ add_stake data as {:?}" , data) ;
70
69
let hotkey = Self :: parse_hotkey ( data) ?. into ( ) ;
71
70
let amount: U256 = handle. context ( ) . apparent_value ;
72
71
let amount_sub =
73
72
<Runtime as pallet_evm:: Config >:: BalanceConverter :: into_substrate_balance ( amount)
74
73
. ok_or ( ExitError :: OutOfFund ) ?;
75
74
76
- log:: error!( "++++++ amount_sub {:?}" , & amount_sub) ;
77
-
78
75
let netuid_vec = data. get ( 56 ..64 ) . ok_or ( PrecompileFailure :: Error {
79
76
exit_status : ExitError :: InvalidRange ,
80
77
} ) ?;
81
-
82
- log:: error!( "++++++ netuid_vec is {:?}" , netuid_vec) ;
83
-
84
78
let netuid = Self :: parse_netuid ( netuid_vec) ?;
85
-
86
- log:: error!( "++++++ netuid is {}" , netuid) ;
87
-
88
79
// Create the add_stake call
89
80
let call = RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: < Runtime > :: add_stake {
90
81
hotkey,
@@ -95,8 +86,6 @@ impl StakingPrecompile {
95
86
Self :: dispatch ( handle, call)
96
87
}
97
88
fn remove_stake ( handle : & mut impl PrecompileHandle , data : & [ u8 ] ) -> PrecompileResult {
98
- log:: error!( "------ add_stake data as {:?}" , data) ;
99
-
100
89
let hotkey = Self :: parse_hotkey ( data) ?. into ( ) ;
101
90
102
91
// We have to treat this as uint256 (because of Solidity ABI encoding rules, it pads uint64),
@@ -110,21 +99,10 @@ impl StakingPrecompile {
110
99
<Runtime as pallet_evm:: Config >:: BalanceConverter :: into_substrate_balance ( amount)
111
100
. ok_or ( ExitError :: OutOfFund ) ?;
112
101
113
- log:: error!( "------ add_stake amount as {:?}" , amount) ;
114
-
115
102
let netuid_vec = data. get ( 88 ..96 ) . ok_or ( PrecompileFailure :: Error {
116
103
exit_status : ExitError :: InvalidRange ,
117
104
} ) ?;
118
-
119
- log:: error!( "------ netuid_vec is {:?}" , netuid_vec) ;
120
-
121
105
let netuid = Self :: parse_netuid ( netuid_vec) ?;
122
- log:: error!( "------ add_stake netuid as {:?}" , netuid) ;
123
-
124
- // let netuid =
125
- // Self::parse_netuid(data.get(64..72).unwrap_or(Err(PrecompileFailure::Error {
126
- // exit_status: ExitError::InvalidRange,
127
- // })?))?;
128
106
129
107
let call = RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: < Runtime > :: remove_stake {
130
108
hotkey,
@@ -146,28 +124,19 @@ impl StakingPrecompile {
146
124
}
147
125
148
126
fn parse_netuid ( data : & [ u8 ] ) -> Result < u16 , PrecompileFailure > {
149
- log:: error!( "++++++ parse_netuid data is {:?}" , & data) ;
150
-
151
127
let netuid = data
152
128
. get ( 0 ..8 )
153
129
. map ( U256 :: from_big_endian)
154
130
. ok_or ( ExitError :: InvalidRange ) ?;
155
131
156
- log:: error!( "++++++ parse_netuid is {:?}" , & netuid) ;
157
-
158
132
let u16_max_u256 = U256 :: from ( u16:: MAX ) ;
159
133
160
- log:: error!( "++++++ parse_netuid u16_max_u256 {:?}" , & u16_max_u256) ;
161
-
162
134
if netuid > u16_max_u256 {
163
135
// if netuid.as_u128() > u16::MAX as u128 {
164
136
return Err ( PrecompileFailure :: Error {
165
137
exit_status : ExitError :: InvalidRange ,
166
138
} ) ;
167
139
}
168
-
169
- log:: error!( "++++++ parse_netuid netuid.as_u32() {:?}" , & netuid. as_u32( ) ) ;
170
-
171
140
Ok ( netuid. as_u32 ( ) as u16 )
172
141
}
173
142
0 commit comments