Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add neuron certificate handling #750

Merged
merged 12 commits into from
Sep 29, 2024

Conversation

andreea-popescu-reef
Copy link
Contributor

Description

implemented logic for neuron certificate discovery and storage:

  • add neuronInfo_getNeuronCertificate: ( netuid, hotkey ) --> certificate pallet storage for neuron certificates
  • add fn get_neuron_certificate(netuid, neuron_uid) rpc to be called via bittensor library to fetch the certificate for a particular neuron
  • add fn serve_axon_tls(..., certificate) as an alternative for existing serve_axon taking an additional certificate parameter and storing it

compatible with older versions of bittensor as it doesn't modify the behaviour of existing rpc calls.

Checklist

  • Added tests for intended behaviors
  • Added tests for error and/or panic states
  • Updated relevant documentation
  • Tracked rustfmt changes
  • No new compiler warnings

@distributedstatemachine
Copy link
Collaborator

On seconds thoughts, adding the new extrinsic ensures backwards compatibility , so a bit undecided here

#[derive(Decode, Encode, Default, TypeInfo, PartialEq, Eq, Clone, Debug)]
pub struct NeuronCertificate {
/// The neuron certificate.
pub certificate: Vec<u8>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it a bounded vector instead? There should be a limit of how much data can an axon store on-chain.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to add freeze_struct, even for this simple struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add freeze_struct

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreea-popescu-reef what about the using a bounded vec ? Have you tested with actual certificate sizes to see how much data it is ?

Copy link
Contributor Author

@andreea-popescu-reef andreea-popescu-reef Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for an ECDSA public key we would need 256bits. To support multiple algorithms 512bits should be enough for the key plus some additional bits to determine the algoritthm so let's reserve 520bits.
I'd also rename the certificate field - public_key would be more appropiate
does that sound good?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not about the naming , but more about people being able to dump arbitrary data (potentialy 5 MB worth) into the field. This is why we are suggesting a bounded vec. It would also be nice to see some tests showing those bounds are enforced

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made the changes

pallets/subtensor/src/subnets/serving.rs Show resolved Hide resolved
@andreea-popescu-reef andreea-popescu-reef marked this pull request as ready for review August 31, 2024 07:49
@distributedstatemachine distributedstatemachine dismissed their stale review September 25, 2024 22:54

need to revert changes to runtime api

Copy link
Contributor

@ppolewicz ppolewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest revert refactor in an area of the code that doesn't have tests and we really, really want to get this PR merged, so we'll come back to that refactor in a separate PR

runtime/src/lib.rs Outdated Show resolved Hide resolved
runtime/src/lib.rs Outdated Show resolved Hide resolved
runtime/src/lib.rs Outdated Show resolved Hide resolved
runtime/src/lib.rs Outdated Show resolved Hide resolved
runtime/src/lib.rs Outdated Show resolved Hide resolved
@unconst unconst merged commit cb72b4f into opentensor:devnet-ready Sep 29, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants