-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathsnapshot.proto
117 lines (100 loc) · 3.16 KB
/
snapshot.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
syntax = "proto3";
import "p2p/proto/common.proto";
import "p2p/proto/sync/state.proto";
import "p2p/proto/class.proto";
option go_package = "github.com/starknet-io/starknet-p2pspecs/p2p/proto/snapshot";
message PatriciaNode {
message Edge {
uint32 length = 1;
Felt252 path = 2; // as bits of left/right
Felt252 value = 3;
}
message Binary {
Felt252 left = 1;
Felt252 right = 2;
}
oneof node {
Edge edge = 1;
Binary binary = 2;
}
}
// non leaf nodes required to build the trie given the range (leaves)
message PatriciaRangeProof {
repeated PatriciaNode nodes = 1;
}
// leafs of the contract state tree
message ContractState {
Address address = 1; // the key
Hash class = 2;
Hash storage = 3; // patricia
uint64 nonce = 4;
}
// request a range from the contract state tree that matches the given root (block)
// starts at 'start' and ends no more than 'end'.
// the result is (ContractRange+, PatriciaRangeProof)*
message ContractRangeRequest {
uint32 domain = 1; // volition
Hash state_root = 2;
Address start = 3;
Address end = 4;
uint32 chunks_per_proof = 5; // how many ContractRange items to send before sending a proof
}
// stream of leaves in the contracts tree
message ContractRange {
repeated ContractState state = 1;
}
message ContractRangeResponse {
optional Hash root = 1; // may not appear if Fin is sent to end the whole response
optional Hash contracts_root = 2;// may not appear if Fin is sent to end the whole response
optional Hash classes_root = 3;// may not appear if Fin is sent to end the whole response
oneof responses {
ContractRange range = 4;
Fin fin = 5;
}
}
message Classes {
uint32 domain = 1;
repeated Class classes = 2;
}
// duplicate of GetContractRange. Can introduce a 'type' instead.
// result is (Classes+, PatriciaRangeProof)*
message ClassRangeRequest {
Hash root = 1;
Hash start = 2;
Hash end = 3;
uint32 chunks_per_proof = 4;
}
message ClassRangeResponse {
optional Hash root = 1; // may not appear if Fin is sent to end the whole response
optional Hash contracts_root = 2;// may not appear if Fin is sent to end the whole response
optional Hash classes_root = 3;// may not appear if Fin is sent to end the whole response
oneof responses {
Classes classes = 4;
Fin fin = 5;
}
}
// A position in some contract's state tree is identified by the state tree's root and the key in it
message StorageLeafQuery {
Hash contract_storage_root = 1;
Felt252 key = 2;
}
message StorageRangeQuery {
StorageLeafQuery start = 1;
StorageLeafQuery end = 2;
}
// result is (ContractStorageRange+, PatriciaRangeProof)*
message ContractStorageRequest {
uint32 domain = 1; // volition
Hash state_root = 2;
repeated StorageRangeQuery query = 3;
}
message ContractStorage {
repeated ContractStoredValue keyValue = 2;
}
message ContractStorageResponse {
optional Hash state_root = 1; // may not appear if Fin is sent to end the whole response
oneof responses {
ContractStorage storage = 2;
Fin fin = 3;
}
}