masa-finance / masa-bittensor

Bittensor Subnet Config
https://masa.ai
MIT License
9 stars 11 forks source link

Miner / Validator Version Control #167

Closed grantdfoster closed 1 month ago

grantdfoster commented 1 month ago

Description

We need to leverage some sort of version control to ensure that Validators and Miners are running the latest code, similar to how the Masa Protocol functions. It was suggested to look into the Axon object itself, as metadata there gets reported to the metagraph, and it's possible we could enforce versioning from there. Also worth asking around in the Bittensor Discord dev channels for ideas.

grantdfoster commented 1 month ago

The hyperparameter weights_version is used to set a specific validator version on the subnet, ensuring code consistency across validators. This is captured in the version_key when we call subtensor.set_weights, as in:

# Set the weights on chain via our subtensor connection.
result, msg = self.subtensor.set_weights(
    wallet=self.wallet,
    netuid=self.config.netuid,
    uids=uint_uids,
    weights=uint_weights,
    wait_for_finalization=False,
    wait_for_inclusion=False,
    version_key=self.spec_version,
)

There is not such an on-chain guard that like for miners, though after conversations on subnet 2 w/ the dev, you can leverage / look into the Axon metadata here

More about how subnet 2 manages this here

grantdfoster commented 1 month ago

One aspect that is strange is that our current weights_version on the subnet is 0, whereas our validators are sending 10 in their version key, i.e. version 0.1.0. It seems weights are being set correctly despite the mismatch. One thought is that when you set a weights_version of 0 on the subnet, it allows all of them. Will test this theory on devnet where I control a subnet.

grantdfoster commented 1 month ago

I have verified that when validators are running a __spec_version__ that is less than what is defined in the weights_version hyperparameter, they are not able to set weights! This is great. Added to the production setup ticket, but it will be important that we set this value to 1 when we launch the subnet on production. Similarly, I have made an edit to __version__ in the validator to be 0.0.1. The logic is such that 1.0.0 == 100, 0.1.0 == 10, etc.