gRPC Protocol

The BitTensor gRPC protocol definition can be found here. The following define the communications protocol and message types that travel between nodes/instances of Bittensor.

Bittensor service.

  • Service definition for tensor processing servers.
  • RPC Methods:
Method Description Returns
Forward (TensorMessage) Forward tensor request. TensorMessage
Backward (TensorMessage)
Backward tensor request
(i.e. pass gradients back)
TensorMessage

Metagraph service.

  • Service definition for a cache for sharing bittensor synapses.
  • This will be replaced by a Blockchain in the future, and is for testing purposes only.
Method Description Returns
Gossip (GossipBatch)
Use gossip protocol to find
other peers on the network.
GossipBatch

GossipBatch message.

  • Batch of neuron service definitions.
  • Gossip message sent across the wire to bootstrap to peers.
GossipBatch Payload Description
STRING version [required] Identifies protocol version for backward compatibility.
REPEATED STRING peers [required] List of metagraph peer addresses.
SYNAPSE synapses Synapse endpoint definitions.

DataType enum.

  • Used for serialization/deserialization of messages as they travel through the wire.
  • Data types can be UNKNOWN, FLOAT32, INT32, INT64, or UTF8.
  • Described here.

Modality enum.

  • Modality of the message (TEXT, IMAGE, TENSOR).
  • Described here.

TensorMessage message.

  • The primary protobuf message object passed between tensor processing servers.
  • Contains a payload of 1 or more serialized tensors and their definitions.
    • version – Indentifies protocol version for backward compatibility.
    • neuron_key – Public key of the caller.
  • Also contains information to identity and verify the sender.
TensorMessage Payload Description
STRING version [required] Identifies protocol version for backward compatibility.
STRING neuron_key [required]
Public key of the calling server. This is used to
identify the calling server (i.e. neuron) to
the synapse of the receiving server (i.e.
the receiving synapse).
STRING synapse_key [required]
Public key of the receiving synapse. This is used to
identify which synapse to query behind the endpoint,
as an endpoint may have multiple synapses.
INT64 nounce [optional]
Incrementing nounce to identify message ordering.
Used ensure with signature to protect against
spoofing attacks.
BYTES signature [optional]
Digital signature linking the nounce, neuron_key
and synapse_key. This prevents spoofing attacks
where an adversary sends messages pretending
to be other peers.
TENSOR tensors [required]
1 or more tensors passed on the wire. This is the
whole point of having a TensorMessage,
and thus is required.

Tensor message.

  • A serialized tensor object created using the serializer class.
  • Essentially used to describe a tensor being passed on the wire.
Tensor Payload Description
STRING version [required] Identifies protocol version for backward compatibility.
BYTES buffer [required]
Serialized raw tensor content. Since this is serialized,
this representation can be used for all tensor types.
The purpose of this serialization is to reduce overhead
during RPC calls by avoiding the serialization of
many repeated small items.
repeated INT64 shape [required] Tensor shape.
DataType dtype [required]
The tensor datatype. Used for serialization
and deserialization.
Modality modality [required] Modality of the message (TEXT, IMAGE, TENSOR)
bool requires_grad [optional] Whether or not this tensor require a gradient.

Synapse message.

  • “Synapse” or “Expert” endpoint definition.
  • This fully describes a tensor processing service for Bittensor (as well as hivemind).
Synapse Payload Description
STRING version [required] Identifies protocol version for backward compatibility.
STRING neuron_key [required]
Public key of the calling neuron.
This is used to identify the calling server (i.e. neuron) to
the synapse of the receiving server
(i.e. the receiving synapse). Links this synapse definition
to the containing neuron-account.
STRING synapse_key [required]
Public key of this synapse.
This is used to identify which synapse to query
behind the endpoint, as an endpoint may have
multiple synapses.
STRING address [required] Synapse ip address.
STRING port [required] Synapse endpoint listening port.
STRING block_hash [required] Hash of latest chain block service definition creation.
STRING nounce [optional] Incrementing nounce.
STRING proof_of_work [optional]
Work hash which ensures service definition creation
was computationally expensive. Protects the network
cache from flooding attacks.
STRING signature [optional]
Public_key signature for this synapse definition.
Ensures that the connected neuron_key signed this proto.