Skip to content

Commit d0c87fb

Browse files
committed
fix last stuffs
1 parent b037619 commit d0c87fb

4 files changed

Lines changed: 21 additions & 9 deletions

File tree

subvortex/core/metagraph/metagraph.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ async def start(self):
109109
axons
110110
)
111111

112+
# Get the last udpate
113+
last_update = await self.database.get_neuron_last_updated()
114+
112115
# Determine whether a resync is needed
113116
time_to_resync = block - last_synced_block >= sync_interval
114117
must_resync = (
@@ -117,15 +120,20 @@ async def start(self):
117120
or has_axons_changed
118121
or has_missing_country
119122
or time_to_resync
123+
or last_update is None
120124
)
121125

122126
if not must_resync:
123127
btul.logging.debug(
124128
"No changes detected; skipping sync.",
125129
prefix=self.settings.logging_name,
126130
)
127-
continue
131+
132+
# Notify listener the metagraph is ready
133+
ready = await self._notify_if_needed(ready)
128134

135+
continue
136+
129137
if has_axons_changed:
130138
reason = "hotkey/IP changes detected"
131139
elif has_missing_country:
@@ -143,7 +151,9 @@ async def start(self):
143151
)
144152

145153
# Sync from chain and update Redis
146-
axons, has_missing_country = await self._resync()
154+
axons, has_missing_country = await self._resync(
155+
last_update=last_update
156+
)
147157

148158
# Store the sync block
149159
last_synced_block = block
@@ -202,7 +212,7 @@ async def stop(self):
202212
f"✅ MetagraphObserver service stopped", prefix=self.settings.logging_name
203213
)
204214

205-
async def _resync(self) -> dict[str, str]:
215+
async def _resync(self, last_update: bool) -> dict[str, str]:
206216
await self.metagraph.sync(subtensor=self.subtensor, lite=False)
207217
btul.logging.debug(
208218
"📡 Full metagraph sync complete", prefix=self.settings.logging_name
@@ -247,7 +257,7 @@ async def _resync(self) -> dict[str, str]:
247257
else None
248258
)
249259
)
250-
260+
251261
except sccc.CountryApiException as e:
252262
btul.logging.error(f"🚨 Country API failure: {e}")
253263
btul.logging.warning(
@@ -257,7 +267,9 @@ async def _resync(self) -> dict[str, str]:
257267
# Wait for the longest rate limit to expire (ensures all APIs are available)
258268
if e.rate_limited:
259269
max_wait = max(e.rate_limited.values())
260-
btul.logging.info(f"⏰ Waiting {max_wait:.0f}s for all APIs to recover...")
270+
btul.logging.info(
271+
f"⏰ Waiting {max_wait:.0f}s for all APIs to recover..."
272+
)
261273
await asyncio.sleep(max_wait)
262274
else:
263275
await asyncio.sleep(60) # Default wait if no rate limit info
@@ -399,7 +411,7 @@ async def _resync(self) -> dict[str, str]:
399411
updated_neurons
400412
)
401413

402-
if updated_neurons or neurons_to_delete:
414+
if last_update is None or updated_neurons or neurons_to_delete:
403415
block = await self.subtensor.get_current_block()
404416
not self.settings.dry_run and await self.database.set_last_updated(block)
405417
btul.logging.debug(

subvortex/core/shared/substrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ async def get_owner_hotkey(substrate: AsyncSubstrateInterface, netuid: int):
6666
module="SubtensorModule", storage_function="SubnetOwnerHotkey", params=[netuid]
6767
)
6868

69-
return result.value
69+
return result.value if hasattr(result, "value") else result
7070

7171

7272
def get_weights_min_stake(substrate: SubstrateInterface):

subvortex/miner/neuron/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ async def _blacklist(self, synapse: Synapse) -> typing.Tuple[bool, str]:
415415
synapse_type = type(synapse).__name__
416416

417417
# Whitelist the subnet owner hotkey
418-
owner_hotkey = get_owner_hotkey(self.subtensor.substrate, self.config.netuid)
418+
owner_hotkey = await get_owner_hotkey(self.subtensor.substrate, self.config.netuid)
419419
if caller == owner_hotkey:
420420
return False, "Hotkey recognized!"
421421

subvortex/validator/neuron/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ async def run(self):
385385
# Signal the neuron has finished
386386
self.run_complete.set()
387387

388-
async def _shutdown(self):
388+
async def shutdown(self):
389389
btul.logging.info("Waiting validator to complete its work...")
390390

391391
# Wait the neuron to stop

0 commit comments

Comments
 (0)