Skip to content

Commit c2106ec

Browse files
committed
fix according comments
1 parent 1398353 commit c2106ec

File tree

4 files changed

+2
-48
lines changed

4 files changed

+2
-48
lines changed

runtime/src/precompiles/metagraph.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ impl MetagraphPrecompile {
2121

2222
match method_id {
2323
id if id == get_method_id("getUidCount(uint16)") => Self::get_uid_count(&method_input),
24-
id if id == get_method_id("getIsSubnetRegistered(uint16)") => {
25-
Self::get_is_subnet_registered(&method_input)
26-
}
2724
id if id == get_method_id("getStake(uint16,uint16)") => Self::get_stake(&method_input),
2825
id if id == get_method_id("getRank(uint16,uint16)") => Self::get_rank(&method_input),
2926
id if id == get_method_id("getTrust(uint16,uint16)") => Self::get_trust(&method_input),
@@ -79,24 +76,6 @@ impl MetagraphPrecompile {
7976
})
8077
}
8178

82-
fn get_is_subnet_registered(data: &[u8]) -> PrecompileResult {
83-
let netuid = Self::parse_netuid(data)?;
84-
let is_registered = pallet_subtensor::Pallet::<Runtime>::if_subnet_exist(netuid);
85-
86-
let result_u256 = if is_registered {
87-
U256::from(1)
88-
} else {
89-
U256::from(0)
90-
};
91-
let mut result = [0_u8; 32];
92-
U256::to_big_endian(&result_u256, &mut result);
93-
94-
Ok(PrecompileOutput {
95-
exit_status: ExitSucceed::Returned,
96-
output: result.into(),
97-
})
98-
}
99-
10079
fn get_stake(data: &[u8]) -> PrecompileResult {
10180
let netuid = Self::parse_netuid(data)?;
10281
let uid = Self::parse_uid(get_slice(data, 32, 64)?)?;

runtime/src/precompiles/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
pub fn new() -> Self {
4040
Self(Default::default())
4141
}
42-
pub fn used_addresses() -> [H160; 10] {
42+
pub fn used_addresses() -> [H160; 11] {
4343
[
4444
hash(1),
4545
hash(2),
@@ -51,6 +51,7 @@ where
5151
hash(EDVERIFY_PRECOMPILE_INDEX),
5252
hash(BALANCE_TRANSFER_INDEX),
5353
hash(STAKING_PRECOMPILE_INDEX),
54+
hash(METAGRAPH_PRECOMPILE_INDEX),
5455
]
5556
}
5657
}

runtime/src/precompiles/solidity/metagraph.abi

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -338,25 +338,6 @@
338338
"stateMutability": "view",
339339
"type": "function"
340340
},
341-
{
342-
"inputs": [
343-
{
344-
"internalType": "uint16",
345-
"name": "netuid",
346-
"type": "uint16"
347-
}
348-
],
349-
"name": "getIsSubnetRegistered",
350-
"outputs": [
351-
{
352-
"internalType": "bool",
353-
"name": "",
354-
"type": "bool"
355-
}
356-
],
357-
"stateMutability": "view",
358-
"type": "function"
359-
},
360341
{
361342
"inputs": [
362343
{

runtime/src/precompiles/solidity/metagraph.sol

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ interface IMetagraph {
1919
* @return The count of UIDs associated with the specified netuid.
2020
*/
2121
function getUidCount(uint16 netuid) external view returns (uint16);
22-
23-
/**
24-
* @dev Checks if a subnet with the given network identifier (netuid) is registered.
25-
* @param netuid The network identifier of the subnet to check.
26-
* @return Returns true if the subnet is registered, false otherwise.
27-
*/
28-
function getIsSubnetRegistered(uint16 netuid) external view returns (bool);
2922

3023
/**
3124
* @dev Retrieves the stake amount associated with a given network identifier (netuid) and unique identifier (uid).

0 commit comments

Comments
 (0)