forked from ten-protocol/go-ten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenclave.proto
300 lines (244 loc) · 8.13 KB
/
enclave.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
syntax = "proto3";
option go_package = "enclave/rpc/generated";
package generated;
// TODO - Remove these comments which duplicate those in common/enclave.go.
service EnclaveProto {
// Status is used to check whether the server is ready for requests.
rpc Status(StatusRequest) returns (StatusResponse) {}
// Attestation - Produces an attestation report which will be used to request the shared secret from another enclave.
rpc Attestation(AttestationRequest) returns (AttestationResponse) {}
// GenerateSecret - the genesis enclave is responsible with generating the secret entropy
rpc GenerateSecret(GenerateSecretRequest) returns (GenerateSecretResponse) {}
// Init - initialise an enclave with a seed received by another enclave
rpc InitEnclave(InitEnclaveRequest) returns (InitEnclaveResponse) {}
// ProduceGenesis - the genesis enclave produces the genesis rollup
rpc ProduceGenesis(ProduceGenesisRequest) returns (ProduceGenesisResponse) {}
// Start - start speculative execution
rpc Start(StartRequest) returns (StartResponse) {}
// SubmitBlock - Used for the host to submit blocks to the enclave, these may be:
// a. historic block - if the enclave is behind and in the process of catching up with the L1 state
// b. the latest block published by the L1, to which the enclave should respond with a rollup
// It is the responsibility of the host to gossip the returned rollup
// For good functioning the caller should always submit blocks ordered by height
// submitting a block before receiving ancestors of it, will result in it being ignored
rpc SubmitBlock(SubmitBlockRequest) returns (SubmitBlockResponse) {}
// SubmitTx - user transactions
rpc SubmitTx(SubmitTxRequest) returns (SubmitTxResponse) {}
// ExecuteOffChainTransaction - returns the result of executing the smart contract as a user, encrypted with the
// viewing key corresponding to the `from` field
rpc ExecuteOffChainTransaction(OffChainRequest) returns (OffChainResponse) {}
// GetTransactionCount - returns the nonce of the wallet with the given address.
rpc GetTransactionCount(GetTransactionCountRequest) returns (GetTransactionCountResponse) {}
// Stop gracefully stops the enclave
rpc Stop(StopRequest) returns (StopResponse) {}
// GetTransaction returns a transaction given its Signed Hash, returns nil, false when Transaction is unknown
rpc GetTransaction(GetTransactionRequest) returns (GetTransactionResponse) {}
// GetTransaction returns a transaction receipt given the transaction's signed hash, encrypted with the viewing key
// corresponding to the original transaction submitter
rpc GetTransactionReceipt(GetTransactionReceiptRequest) returns (GetTransactionReceiptResponse) {}
// GetRollup returns a rollup given its hash, returns nil, false when the rollup is unknown
rpc GetRollup(GetRollupRequest) returns (GetRollupResponse) {}
// AddViewingKey adds a viewing key to the enclave
rpc AddViewingKey(AddViewingKeyRequest) returns (AddViewingKeyResponse) {}
// GetBalance returns the address's balance on the Obscuro network, encrypted with the viewing key corresponding to
// the address
rpc GetBalance(GetBalanceRequest) returns (GetBalanceResponse) {}
// GetCode returns the code stored at the given address in the state for the given rollup height or rollup hash
rpc GetCode(GetCodeRequest) returns (GetCodeResponse) {}
rpc Subscribe(SubscribeRequest) returns (SubscribeResponse) {}
rpc Unsubscribe(UnsubscribeRequest) returns (UnsubscribeResponse) {}
// EstimateGas returns the estimation of gas used for the given transactions
rpc EstimateGas(EstimateGasRequest) returns (EstimateGasResponse) {}
rpc GetLogs(GetLogsRequest) returns (GetLogsResponse) {}
}
message StatusRequest {}
message StatusResponse {
int32 status = 1;
string error = 2;
}
message AttestationRequest {}
message AttestationResponse {
AttestationReportMsg attestationReportMsg = 1;
}
message GenerateSecretRequest {}
message GenerateSecretResponse {
bytes encryptedSharedEnclaveSecret = 1;
}
message InitEnclaveRequest {
bytes encryptedSharedEnclaveSecret = 1;
}
message InitEnclaveResponse {
string error = 1;}
message ProduceGenesisRequest {
bytes blockHash = 1;
}
message ProduceGenesisResponse {
BlockSubmissionResponseMsg blockSubmissionResponse = 1;
}
message StartRequest {
bytes encodedBlock = 1;
}
message StartResponse {}
message SubmitBlockRequest {
bytes encodedBlock = 1;
bool isLatest = 2;
}
message SubmitBlockResponse {
BlockSubmissionResponseMsg blockSubmissionResponse = 1;
}
message SubmitTxRequest {
bytes encryptedTx = 1;
}
message SubmitTxResponse {
bytes encryptedHash = 1;
}
message OffChainRequest {
bytes encryptedParams = 1;
}
message OffChainResponse {
bytes result = 1;
bytes error = 2;
}
message GetTransactionCountRequest {
bytes encryptedParams = 1;
}
message GetTransactionCountResponse {
bytes result = 1;
string error = 2;
}
message StopRequest {}
message StopResponse {}
message GetTransactionRequest {
bytes encryptedParams = 1;
}
message GetTransactionResponse {
bytes encryptedTx = 1;
}
message GetTransactionReceiptRequest {
bytes encryptedParams = 1;
}
message GetTransactionReceiptResponse {
bytes encryptedTxReceipt = 1;
}
message GetRollupRequest {
bytes rollupHash = 1;
}
message GetRollupResponse {
ExtRollupMsg extRollup = 2;
}
message AddViewingKeyRequest {
bytes viewingKey = 1;
bytes signature = 2;
}
message AddViewingKeyResponse {}
message GetBalanceRequest {
bytes encryptedParams = 1;
}
message GetBalanceResponse {
bytes encryptedBalance = 1;
}
message GetCodeRequest {
bytes address = 1;
bytes rollupHash = 2;
}
message GetCodeResponse {
bytes code = 1;
}
message SubscribeRequest {
bytes id = 1;
bytes encryptedSubscription = 2;
}
message SubscribeResponse {}
message UnsubscribeRequest {
bytes id = 1;
}
message UnsubscribeResponse {}
message EstimateGasRequest {
bytes encryptedParams = 1;
}
message EstimateGasResponse {
bytes encryptedResponse = 1;
}
message GetLogsRequest {
bytes encryptedParams = 1;
}
message GetLogsResponse {
bytes encryptedResponse = 1;
}
// Nested message types.
message AttestationReportMsg {
bytes Report = 1; // The actual report bytes so it can be shared and verified by other nodes
bytes PubKey = 2; // Public key to encrypt traffic back to this enclave
bytes Owner = 3;
string HostAddress = 4; // The IP address on which the host can be contacted by other Obscuro hosts for peer-to-peer communication
}
message BlockSubmissionResponseMsg {
BlockHeaderMsg blockHeader = 1;
ExtRollupMsg producedRollup = 2;
bool ingestedNewRollup = 3;
HeaderMsg rollupHead = 4;
repeated SecretResponseMsg producedSecretResponses = 5;
bytes subscribedLogs = 6;
BlockSubmissionErrorMsg error = 7; // todo: avoid errors in Response objects, perhaps using gRPC Status responses
}
message BlockSubmissionErrorMsg {
string cause = 1; // error cause description
bytes l1Head = 2; // hash for the L1 head block in enclave's view of the canonical chain
}
message ExtRollupMsg {
HeaderMsg header = 1;
repeated bytes txHashes = 2;
bytes txs = 3;
}
message HeaderMsg {
bytes ParentHash = 1;
bytes Node = 2;
bytes Nonce = 3;
bytes Proof = 4;
bytes Root = 5;
bytes TxHash = 6;
uint64 Number = 7;
bytes Bloom = 8;
bytes ReceiptHash = 9;
bytes Extra = 10;
bytes R = 11;
bytes S = 12;
repeated WithdrawalMsg Withdrawals = 13;
bytes UncleHash = 14;
bytes Coinbase = 15;
uint64 Difficulty = 16;
uint64 GasLimit = 17;
uint64 GasUsed = 18;
uint64 Time = 19;
bytes MixDigest = 20;
uint64 BaseFee = 21;
uint64 RollupNonce = 22;
}
message SecretResponseMsg {
bytes Secret = 1;
bytes RequesterID = 2;
string HostAddress = 3;
}
message WithdrawalMsg {
bytes amount = 1;
bytes recipient = 2;
bytes contract = 3;
}
message BlockHeaderMsg {
bytes ParentHash = 1;
bytes UncleHash = 2;
bytes Coinbase = 3;
bytes Root = 4;
bytes TxHash = 5;
bytes ReceiptHash = 6;
bytes Bloom = 7;
uint64 Difficulty = 8;
uint64 Number = 9;
uint64 GasLimit = 10;
uint64 GasUsed = 11;
uint64 Time = 12;
bytes Extra = 13;
bytes MixDigest = 14;
uint64 Nonce = 15;
uint64 BaseFee = 16;
}