sawtooth 0.8.0

Hyperledger Sawtooth is an enterprise blockchain platform for building distributed ledger applications and networks.
Documentation
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
// Copyright 2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// -----------------------------------------------------------------------------

syntax = "proto3";

// --== Data Structures ==--

message ConsensusPeerMessageHeader {
  // Public key for the component internal to the validator that
  // signed the message
  bytes signer_id = 1;

  // The sha512 hash of the encoded message
  bytes content_sha512 = 2;
  // Interpretation is left to the consensus engine implementation
  string message_type = 5;

  // Used to identify the consensus engine that produced this message
  string name = 3;
  string version = 4;
}

// A consensus-related message sent between peers
message ConsensusPeerMessage {
  // The serialized version of the ConsensusPeerMessageHeader
  bytes header = 1;

  // The signature derived from signing the header
  bytes header_signature = 3;

  // The opaque payload to send to other nodes
  bytes content = 2;
}

// All information about a block that is relevant to consensus
message ConsensusBlock {
  bytes block_id = 1;
  bytes previous_id = 2;
  // The id of peer that signed this block
  bytes signer_id = 3;
  uint64 block_num = 4;
  bytes payload = 5;
  // A summary of the contents of the block
  bytes summary = 6;
}

// Information about a peer that is relevant to consensus
message ConsensusPeerInfo {
  // The unique id for this peer. This can be correlated with the signer id
  // on consensus blocks.
  bytes peer_id = 1;
}

// A settings key-value pair
message ConsensusSettingsEntry {
  string key = 1;
  string value = 2;
}

// A state key-value pair
message ConsensusStateEntry {
  string address = 1;
  bytes data = 2;
}

// --== Registration ==--

// Sent to connect with the validator
message ConsensusRegisterRequest {
  message Protocol {
    string name = 1;
    string version = 2;
  }

  // The name of this consensus engine
  string name = 1;
  // The version of this consensus engine
  string version = 2;
  // Any additional name/version pairs the consensus engine supports
  repeated Protocol additional_protocols = 3;
}

message ConsensusRegisterResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;
  }

  Status status = 1;

  // Startup Info
  ConsensusBlock chain_head = 2;
  repeated ConsensusPeerInfo peers = 3;
  ConsensusPeerInfo local_peer_info = 4;
}

// --== Notifications ==--

// The following are notifications provided by the validator to the consensus
// engine. An ack should be sent in response to all notifications.

// - P2P -

// A new peer was added
message ConsensusNotifyPeerConnected {
  ConsensusPeerInfo peer_info = 1;
}

// An existing peer was dropped
message ConsensusNotifyPeerDisconnected {
  bytes peer_id = 1;
}

// A new message was received from a peer
message ConsensusNotifyPeerMessage {
  // The message sent
  ConsensusPeerMessage message = 1;
  // The node that sent the message, not necessarily the node that created it
  bytes sender_id = 2;
}

// - Blocks -

// A new block was received and passed initial consensus validation
message ConsensusNotifyBlockNew {
  ConsensusBlock block = 1;
}

// This block can be committed successfully
message ConsensusNotifyBlockValid {
  bytes block_id = 1;
}

// This block cannot be committed successfully
message ConsensusNotifyBlockInvalid {
  bytes block_id = 1;
}

// This block has been committed
message ConsensusNotifyBlockCommit {
  bytes block_id = 1;
}

// The engine has been activated
message ConsensusNotifyEngineActivated {
  // Startup Info
  ConsensusBlock chain_head = 1;
  repeated ConsensusPeerInfo peers = 2;
  ConsensusPeerInfo local_peer_info = 3;
}

// The engine has been deactivated
message ConsensusNotifyEngineDeactivated {}

// Confirm that the notification was received. The validator message
// correlation id is used to determine which notification this is an ack for.
message ConsensusNotifyAck {}

// --== Services Provided ==--

// The following are services provided by the validator to the consensus
// engine. All service messages have at a minimum the following possible return
// statuses:
//
//    STATUS_UNSET
//        No status was set by the validator, this should never happen
//    OK
//        The request was completed successfully
//    BAD_REQUEST
//        The request was malformed in some way
//    SERVICE_ERROR
//        The validator failed to perform the request
//    NOT_READY
//        The validator is not accepting requests, usually because it is still
//        starting up
//    NOT_ACTIVE_ENGINE
//        The consensus engine making the request is not the active engine
//
// Additionally, messages may have the following additional return statuses:
//
//    INVALID_STATE
//        The request is not valid given the current state of the validator
//    UNKNOWN_BLOCK
//        No block with the given id could be found
//    UNKNOWN_PEER
//        No peer with the given id could be found

// - P2P Messaging -

// Send a consensus message to a specific, connected peer
message ConsensusSendToRequest {
  // Payload to send to peer
  //
  // NOTE: This payload will be wrapped up in a ConsensusPeerMessage struct,
  // which includes computing its SHA-512 digest, inserting this engine's
  // registration info, and the validator's public key, and signing everything
  // with the validator's private key.
  bytes content = 1;
  string message_type = 3;

  // Peer that this message is destined for
  bytes receiver_id = 2;
}

message ConsensusSendToResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_PEER = 5;

    NOT_ACTIVE_ENGINE = 6;
  }
  Status status = 1;
}

// Broadcast a consensus message to all peers
message ConsensusBroadcastRequest {
  // Payload to broadcast peers
  //
  // NOTE: This payload will be wrapped up in a ConsensusPeerMessage struct,
  // which includes computing its SHA-512 digest, inserting this engine's
  // registration info, and the validator's public key, and signing everything
  // with the validator's private key.
  bytes content = 1;
  string message_type = 2;
}

message ConsensusBroadcastResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;
    NOT_ACTIVE_ENGINE = 5;
  }
  Status status = 1;
}

// - Block Creation -

// Initialize a new block built on the block with the given previous id and
// begin adding batches to it. If no previous id is specified, the current
// head will be used.
message ConsensusInitializeBlockRequest {
  bytes previous_id = 1;
}

message ConsensusInitializeBlockResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    INVALID_STATE = 5;
    UNKNOWN_BLOCK = 6;

    NOT_ACTIVE_ENGINE = 7;
  }
  Status status = 1;
}

// Stop adding batches to the current block and return a summary of its
// contents.
message ConsensusSummarizeBlockRequest {}

message ConsensusSummarizeBlockResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    INVALID_STATE = 5;
    BLOCK_NOT_READY = 6;

    NOT_ACTIVE_ENGINE = 7;
  }
  Status status = 1;

  // A summary of the block contents
  bytes summary = 2;
}

// Insert the given consensus data into the block and sign it. If this call is
// successful, the consensus engine will receive the block afterwards.
message ConsensusFinalizeBlockRequest {
  // The consensus data to include in the finalized block
  bytes data = 1;
}

message ConsensusFinalizeBlockResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    INVALID_STATE = 5;
    BLOCK_NOT_READY = 6;

    NOT_ACTIVE_ENGINE = 7;
  }
  Status status = 1;

  // The block id of the newly created block
  bytes block_id = 2;
}

// Stop adding batches to the current block and abandon it.
message ConsensusCancelBlockRequest {}

message ConsensusCancelBlockResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    INVALID_STATE = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
}

// - Block Directives -

// Request that, for each block block in order, the block is checked to
// determine whether the block can be committed successfully or not. Blocks
// may be checked in parallel. If a new request arrives, it overrides the
// previous request allowing the engine to reprioritize the list of blocks to
// check.
//
// NOTE: OK does not mean the blocks will all commit successfully, only that
// the directive was received successfully. The engine must listen for
// notifications from the consuming component to learn if the blocks would
// commit or not.
message ConsensusCheckBlocksRequest {
  repeated bytes block_ids = 1;
}

message ConsensusCheckBlocksResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_BLOCK = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
}

// Request that the block be committed. This request fails if the block has
// not already been checked.
//
// NOTE: OK does not mean the block has been committed, only that the directive
// was received successfully. The engine must listen for notifications from the
// consuming component to learn when the block commits.
message ConsensusCommitBlockRequest {
  bytes block_id = 1;
}

message ConsensusCommitBlockResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_BLOCK = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
}

// Inform the consuming component that this block is no longer being considered
// and can be held or freed as needed.
message ConsensusIgnoreBlockRequest {
  bytes block_id = 1;
}

message ConsensusIgnoreBlockResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_BLOCK = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
}

// Fail this block and any of its descendants and purge them as needed.
message ConsensusFailBlockRequest {
  bytes block_id = 1;
}

message ConsensusFailBlockResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_BLOCK = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
}

// - Queries -

// Retrieve consensus-related information about blocks. If some blocks could
// not be found, only the blocks that could be found will be returned.
message ConsensusBlocksGetRequest {
  repeated bytes block_ids = 1;
}

message ConsensusBlocksGetResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_BLOCK = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
  repeated ConsensusBlock blocks = 2;
}

// Retrieve consensus-related information about the chain head.
message ConsensusChainHeadGetRequest {}

message ConsensusChainHeadGetResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    NO_CHAIN_HEAD = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
  ConsensusBlock block = 2;
}

// Read the values of these settings from state as of the given block. If some
// values settings keys cannot be found, the keys that were found will be
// returned.
message ConsensusSettingsGetRequest {
  bytes block_id = 1;
  repeated string keys = 2;
}

message ConsensusSettingsGetResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_BLOCK = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
  repeated ConsensusSettingsEntry entries = 2;
}

// Read the data at these addresses from state as of the given block. If some
// addresses cannot be found, state at the addresses that were found will be
// returned.
message ConsensusStateGetRequest {
  bytes block_id = 1;
  repeated string addresses = 2;
}

message ConsensusStateGetResponse {
  enum Status {
    STATUS_UNSET = 0;
    OK = 1;
    BAD_REQUEST = 2;
    SERVICE_ERROR = 3;
    NOT_READY = 4;

    UNKNOWN_BLOCK = 5;

    NOT_ACTIVE_ENGINE = 6;
  }

  Status status = 1;
  repeated ConsensusStateEntry entries = 2;
}