Move around stuff in sc_network (#5847)

This commit is contained in:
Pierre Krieger
2020-04-30 15:08:38 +02:00
committed by GitHub
parent c09bb1f350
commit 929bd07bef
13 changed files with 172 additions and 160 deletions
@@ -0,0 +1,60 @@
// Schema definition for block request/response messages.
syntax = "proto3";
package api.v1;
// Block enumeration direction.
enum Direction {
// Enumerate in ascending order (from child to parent).
Ascending = 0;
// Enumerate in descending order (from parent to canonical child).
Descending = 1;
}
// Request block data from a peer.
message BlockRequest {
// Bits of block data to request.
uint32 fields = 1;
// Start from this block.
oneof from_block {
// Start with given hash.
bytes hash = 2;
// Start with given block number.
bytes number = 3;
}
// End at this block. An implementation defined maximum is used when unspecified.
bytes to_block = 4; // optional
// Sequence direction.
Direction direction = 5;
// Maximum number of blocks to return. An implementation defined maximum is used when unspecified.
uint32 max_blocks = 6; // optional
}
// Response to `BlockRequest`
message BlockResponse {
// Block data for the requested sequence.
repeated BlockData blocks = 1;
}
// Block data sent in the response.
message BlockData {
// Block header hash.
bytes hash = 1;
// Block header if requested.
bytes header = 2; // optional
// Block body if requested.
repeated bytes body = 3; // optional
// Block receipt if requested.
bytes receipt = 4; // optional
// Block message queue if requested.
bytes message_queue = 5; // optional
// Justification if requested.
bytes justification = 6; // optional
// True if justification should be treated as present but empty.
// This hack is unfortunately necessary because shortcomings in the protobuf format otherwise
// doesn't make in possible to differentiate between a lack of justification and an empty
// justification.
bool is_empty_justification = 7; // optional, false if absent
}
@@ -0,0 +1,19 @@
// Schema definition for finality proof request/responses.
syntax = "proto3";
package api.v1.finality;
// Request a finality proof from a peer.
message FinalityProofRequest {
// SCALE-encoded hash of the block to request.
bytes block_hash = 1;
// Opaque chain-specific additional request data.
bytes request = 2;
}
// Response to a finality proof request.
message FinalityProofResponse {
// Opaque chain-specific finality proof. Empty if no such proof exists.
bytes proof = 1; // optional
}
@@ -0,0 +1,120 @@
// Schema definition for light client messages.
syntax = "proto3";
package api.v1.light;
// A pair of arbitrary bytes.
message Pair {
// The first element of the pair.
bytes fst = 1;
// The second element of the pair.
bytes snd = 2;
}
// Enumerate all possible light client request messages.
message Request {
oneof request {
RemoteCallRequest remote_call_request = 1;
RemoteReadRequest remote_read_request = 2;
RemoteHeaderRequest remote_header_request = 3;
RemoteReadChildRequest remote_read_child_request = 4;
RemoteChangesRequest remote_changes_request = 5;
}
}
// Enumerate all possible light client response messages.
message Response {
oneof response {
RemoteCallResponse remote_call_response = 1;
RemoteReadResponse remote_read_response = 2;
RemoteHeaderResponse remote_header_response = 3;
RemoteChangesResponse remote_changes_response = 4;
}
}
// Remote call request.
message RemoteCallRequest {
// Block at which to perform call.
bytes block = 2;
// Method name.
string method = 3;
// Call data.
bytes data = 4;
}
// Remote call response.
message RemoteCallResponse {
// Execution proof.
bytes proof = 2;
}
// Remote storage read request.
message RemoteReadRequest {
// Block at which to perform call.
bytes block = 2;
// Storage keys.
repeated bytes keys = 3;
}
// Remote read response.
message RemoteReadResponse {
// Read proof.
bytes proof = 2;
}
// Remote storage read child request.
message RemoteReadChildRequest {
// Block at which to perform call.
bytes block = 2;
// Child Storage key, this is relative
// to the child type storage location.
bytes storage_key = 3;
// Storage keys.
repeated bytes keys = 6;
}
// Remote header request.
message RemoteHeaderRequest {
// Block number to request header for.
bytes block = 2;
}
// Remote header response.
message RemoteHeaderResponse {
// Header. None if proof generation has failed (e.g. header is unknown).
bytes header = 2; // optional
// Header proof.
bytes proof = 3;
}
/// Remote changes request.
message RemoteChangesRequest {
// Hash of the first block of the range (including first) where changes are requested.
bytes first = 2;
// Hash of the last block of the range (including last) where changes are requested.
bytes last = 3;
// Hash of the first block for which the requester has the changes trie root. All other
// affected roots must be proved.
bytes min = 4;
// Hash of the last block that we can use when querying changes.
bytes max = 5;
// Storage child node key which changes are requested.
bytes storage_key = 6; // optional
// Storage key which changes are requested.
bytes key = 7;
}
// Remote changes response.
message RemoteChangesResponse {
// Proof has been generated using block with this number as a max block. Should be
// less than or equal to the RemoteChangesRequest::max block number.
bytes max = 2;
// Changes proof.
repeated bytes proof = 3;
// Changes tries roots missing on the requester' node.
repeated Pair roots = 4;
// Missing changes tries roots proof.
bytes roots_proof = 5;
}