diff --git a/neurons/miner.py b/neurons/miner.py index fef99b8..4367469 100644 --- a/neurons/miner.py +++ b/neurons/miner.py @@ -104,15 +104,22 @@ def __init__(self): tplr.logger.info(f'\nWallet: {self.wallet}\nSubtensor: {self.subtensor}\nMetagraph: {self.metagraph}\nUID: {self.uid}') # Init bucket. - # try: - # tplr.logger.info(f'bucket_name: {tplr.config.BUCKET_SECRETS["bucket_name"]}') - # commitment = self.chain_manager.get_commitment(self.uid) - # if tplr.config.BUCKET_SECRETS["bucket_name"] != commitment.name: - # raise ValueError('') - # except Exception: - # tplr.commit(self.subtensor, self.wallet, self.config.netuid) - # tplr.logger.info('Bucket:' + tplr.config.BUCKET_SECRETS["bucket_name"]) - tplr.commit(self.subtensor, self.wallet, self.config.netuid) + try: + tplr.logger.info(f'bucket_name: {tplr.config.BUCKET_SECRETS["bucket_name"]}') + commitment = self.chain_manager.get_commitment(self.uid) + current_bucket = tplr.Bucket( + name=tplr.config.BUCKET_SECRETS["bucket_name"], + account_id=tplr.config.BUCKET_SECRETS["account_id"], + access_key_id=tplr.config.BUCKET_SECRETS["access_key_id"], + secret_access_key=tplr.config.BUCKET_SECRETS["secret_access_key"] + ) + if current_bucket != commitment: + # TODO: Handle mismatched commitments + raise ValueError("Bucket commitment data does not match.") + raise ValueError('') + except Exception: + tplr.commit(self.subtensor, self.wallet, self.config.netuid) + tplr.logger.info('Bucket:' + tplr.config.BUCKET_SECRETS["bucket_name"]) # Init Wandb. # Ensure the wandb directory exists diff --git a/neurons/validator.py b/neurons/validator.py index 236e8bc..a9949a7 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -102,15 +102,23 @@ def __init__(self): tplr.logger.info(f'\nWallet: {self.wallet}\nSubtensor: {self.subtensor}\nMetagraph: {self.metagraph}\nUID: {self.uid}') # Init bucket. - # try: - # tplr.logger.info(f'bucket_name: {tplr.config.BUCKET_SECRETS["bucket_name"]}') - # commitment = self.chain_manager.get_commitment(self.uid) - # if tplr.config.BUCKET_SECRETS["bucket_name"] != commitment.name: - # raise ValueError('') - # except Exception: - # tplr.commit(self.subtensor, self.wallet, self.config.netuid) - # tplr.logger.info('Bucket:' + tplr.config.BUCKET_SECRETS["bucket_name"]) - tplr.commit(self.subtensor, self.wallet, self.config.netuid) + try: + tplr.logger.info(f'bucket_name: {tplr.config.BUCKET_SECRETS["bucket_name"]}') + commitment = self.chain_manager.get_commitment(self.uid) + current_bucket = tplr.Bucket( + name=tplr.config.BUCKET_SECRETS["bucket_name"], + account_id=tplr.config.BUCKET_SECRETS["account_id"], + access_key_id=tplr.config.BUCKET_SECRETS["access_key_id"], + secret_access_key=tplr.config.BUCKET_SECRETS["secret_access_key"] + ) + if current_bucket != commitment: + # TODO: Handle mismatched commitments + raise ValueError("Bucket commitment data does not match.") + raise ValueError('') + except Exception: + tplr.commit(self.subtensor, self.wallet, self.config.netuid) + tplr.logger.info('Bucket:' + tplr.config.BUCKET_SECRETS["bucket_name"]) + # tplr.commit(self.subtensor, self.wallet, self.config.netuid) # Init Wandb. # Ensure the wandb directory exists