@@ -4,26 +4,90 @@ package sync;
44
55option go_package = "github.com/ava-labs/avalanchego/proto/pb/sync" ;
66
7+ // Request represents a request for information during syncing.
78message Request {
89 oneof message {
910 RangeProofRequest range_proof_request = 1 ;
1011 ChangeProofRequest change_proof_request = 2 ;
1112 }
1213}
1314
15+ // A RangeProofRequest requests the key-value pairs in a given key range
16+ // at a specific revision.
1417message RangeProofRequest {
15- bytes root = 1 ;
16- bytes start = 2 ;
17- bytes end = 3 ;
18+ bytes root_hash = 1 ;
19+ bytes start_key = 2 ;
20+ bytes end_key = 3 ;
1821 uint32 key_limit = 4 ;
1922 uint32 bytes_limit = 5 ;
2023}
2124
25+ // A ChangeProofRequest requests the changes between two revisions.
2226message ChangeProofRequest {
23- bytes start_root = 1 ;
24- bytes end_root = 2 ;
25- bytes start = 3 ;
26- bytes end = 4 ;
27+ bytes start_root_hash = 1 ;
28+ bytes end_root_hash = 2 ;
29+ bytes start_key = 3 ;
30+ bytes end_key = 4 ;
2731 uint32 key_limit = 5 ;
2832 uint32 bytes_limit = 6 ;
2933}
34+
35+ // KeyValue represents a single key and its value.
36+ message KeyValue {
37+ bytes key = 1 ;
38+ bytes value = 2 ;
39+ }
40+
41+ // KeyChange is a change for a key from one revision to another.
42+ // If the value is None, the key was deleted.
43+ message KeyChange {
44+ bytes key = 1 ;
45+ MaybeBytes value = 2 ;
46+ }
47+
48+ // SerializedPath is the serialized representation of a path.
49+ message SerializedPath {
50+ uint32 nibble_length = 1 ;
51+ bytes value = 2 ;
52+ }
53+
54+ // MaybeBytes is an option wrapping bytes.
55+ message MaybeBytes {
56+ bytes value = 1 ;
57+ // If false, this is None.
58+ bool is_nothing = 2 ;
59+ }
60+
61+ // ProofNode is a node in a merkle proof.
62+ message ProofNode {
63+ SerializedPath key = 1 ;
64+ MaybeBytes value_or_hash = 2 ;
65+ map <uint32 , bytes > children = 3 ;
66+ }
67+
68+ // RangeProof is the response to a RangeProofRequest.
69+ message RangeProof {
70+ repeated ProofNode start = 1 ;
71+ repeated ProofNode end = 2 ;
72+ repeated KeyValue key_values = 3 ;
73+ }
74+
75+ // ChangeProof is a possible response to a ChangeProofRequest.
76+ // It only consists of a proof of the smallest changed key,
77+ // the highest changed key, and the keys that have changed
78+ // between those. Some keys may be deleted (hence
79+ // the use of KeyChange instead of KeyValue).
80+ message ChangeProof {
81+ bool had_roots_in_history = 1 ; // TODO remove
82+ repeated ProofNode start_proof = 2 ;
83+ repeated ProofNode end_proof = 3 ;
84+ repeated KeyChange key_changes = 4 ;
85+ }
86+
87+ // ChangeProofResponse is the response for a ChangeProofRequest.
88+ message ChangeProofResponse {
89+ oneof response {
90+ ChangeProof change_proof = 1 ;
91+ RangeProof range_proof = 2 ;
92+ }
93+ }
0 commit comments