You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal is to implement a commit-reveal scheme for submitting weights in the Subtensor module. This scheme will require validators to submit a hashed version of their weights along with a signature during the commit phase. After a specified number of blocks (reveal tempo), validators will reveal the actual weights, which will be verified against the commit hash.
Requirements
Implement a commit_weights function that allows validators to submit a hashed version of their weights along with a signature during the commit phase.
Implement a reveal_weights function that allows validators to reveal the actual weights after the specified reveal tempo.
Ensure that commits and reveals are unique to each validator and include a signature to prevent copying.
Make the commit-reveal scheme optional and configurable per subnet.
Enforce the reveal tempo and allow commits only once within a tempo period.
Implement helper functions for the commit-reveal process and background tasks.
Provide clear error messages for issues like missing commits, hash mismatches, or timing violations.
Rust Implementation
Storage
Add the following storage item to store commit hashes, signatures, and block numbers per validator and subnet:
Implement helper functions for the commit-reveal process:
impl<T:Config>Pallet<T>{fncan_commit(netuid:u16,who:&T::AccountId) -> bool{// Check if commit-reveal is enabled for the subnet// Check if the validator hasn't committed within the current tempo```rust// ...}fnis_reveal_block(netuid:u16,commit_block:T::BlockNumber) -> bool{// Check if the current block is within the reveal tempo// ...}fnverify_signature(who:&T::AccountId,commit_hash:&T::Hash,signature:&T::Signature) -> bool{// Verify the provided signature against the commit hash and validator's public key// ...}}
Implement background tasks for cleaning up expired commits and managing the commit-reveal process.
defcan_commit(self, netuid: int, who: str) ->bool:
# Check if commit-reveal is enabled for the subnet# Check if the validator hasn't committed within```python# Check if the validator hasn't committed within the current tempo# ...passdefis_reveal_block(self, netuid: int, commit_block: int) ->bool:
# Check if the current block is within the reveal tempo# ...passdefverify_signature(self, who: str, commit_hash: str, signature: str) ->bool:
# Verify the provided signature against the commit hash and validator's public key# ...pass
Implement background tasks for cleaning up expired commits and managing the commit-reveal process.
Error Handling
Provide clear error messages in bittensor/errors.py for various scenarios, such as:
Missing commits when revealing weights
Mismatched commit hash when revealing weights
Invalid signature when committing or revealing weights
Attempting to commit weights more than once within a tempo period
Attempting to reveal weights outside the reveal tempo
Testing
Write unit tests to cover the functionality of the commit_weights and reveal_weights functions in both Rust and Python.
Write integration tests to ensure the commit-reveal scheme works as expected with the Subtensor module.
Test various error scenarios and ensure appropriate error messages are provided.
Documentation
Update the Subtensor module's documentation to include information about the commit-reveal scheme.
Provide examples and guidelines for subnet owners to configure and use the commit-reveal scheme effectively.
Update the Subtensor Python module's documentation with information and examples about the commit-reveal scheme.
Const
Python side of the code to written subtensor.commit_weights extrinsics
Commits takes the reveal tempo, how long after in terms of blocks before we
We want the owner to be able set the value, min blocks that pass before you reveal.
We want to make them subtensor primitives
subtensor helper commit reveal + set background process
We want to be careful with tempo and only allow it to be called once within a tempo
focus on the primitives
Vune
We should use signatures of weights
make it optional
The text was updated successfully, but these errors were encountered:
Instead of using commit signature, can we hash the weights, netuid, and public key of hotkey all together? The extrinsic is already signed, and a separate signature is not needed.
Should we include nonce in the plaintext before hashing too to avoid replay attacks (just in case extrinsic lifetime is longer than commit tempos)?
Decscription
The goal is to implement a commit-reveal scheme for submitting weights in the Subtensor module. This scheme will require validators to submit a hashed version of their weights along with a signature during the commit phase. After a specified number of blocks (reveal tempo), validators will reveal the actual weights, which will be verified against the commit hash.
Requirements
commit_weights
function that allows validators to submit a hashed version of their weights along with a signature during the commit phase.reveal_weights
function that allows validators to reveal the actual weights after the specified reveal tempo.Rust Implementation
Storage
Add the following storage item to store commit hashes, signatures, and block numbers per validator and subnet:
commit_weights
FunctionImplement the
commit_weights
function for the commit phase:reveal_weights
FunctionImplement the
reveal_weights
function for the reveal phase:Helper Functions
Implement helper functions for the commit-reveal process:
Implement background tasks for cleaning up expired commits and managing the commit-reveal process.
Python Implementation
commit_weights
FunctionAdd to
bittensor/subtensor.py
:reveal_weights
FunctionAdd to
bittensor/subtensor.py
:Helper Functions
Add to
bittensor/subtensor.py
:Implement background tasks for cleaning up expired commits and managing the commit-reveal process.
Error Handling
Provide clear error messages in
bittensor/errors.py
for various scenarios, such as:Testing
commit_weights
andreveal_weights
functions in both Rust and Python.Documentation
Const
Vune
The text was updated successfully, but these errors were encountered: