github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/protos/consensus.proto (about) 1 // Copyright 2018 Intel Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // ----------------------------------------------------------------------------- 15 16 syntax = "proto3"; 17 18 // --== Data Structures ==-- 19 20 // A consensus-related message sent between peers 21 message ConsensusPeerMessage { 22 // Interpretation is left to the consensus engine implementation 23 string message_type = 1; 24 25 // The opaque payload to send to other nodes 26 bytes content = 2; 27 28 // Used to identify the consensus engine that produced this message 29 string name = 3; 30 string version = 4; 31 } 32 33 // All information about a block that is relevant to consensus 34 message ConsensusBlock { 35 bytes block_id = 1; 36 bytes previous_id = 2; 37 // The id of peer that signed this block 38 bytes signer_id = 3; 39 uint64 block_num = 4; 40 bytes payload = 5; 41 // A summary of the contents of the block 42 bytes summary = 6; 43 } 44 45 // Information about a peer that is relevant to consensus 46 message ConsensusPeerInfo { 47 // The unique id for this peer. This can be correlated with the signer id 48 // on consensus blocks. 49 bytes peer_id = 1; 50 } 51 52 // A settings key-value pair 53 message ConsensusSettingsEntry { 54 string key = 1; 55 string value = 2; 56 } 57 58 // A state key-value pair 59 message ConsensusStateEntry { 60 string address = 1; 61 bytes data = 2; 62 } 63 64 // --== Registration ==-- 65 66 // Sent to connect with the validator 67 message ConsensusRegisterRequest { 68 // The name of this consensus engine 69 string name = 1; 70 // The version of this consensus engine 71 string version = 2; 72 } 73 74 message ConsensusRegisterResponse { 75 enum Status { 76 STATUS_UNSET = 0; 77 OK = 1; 78 BAD_REQUEST = 2; 79 SERVICE_ERROR = 3; 80 NOT_READY = 4; 81 } 82 83 Status status = 1; 84 85 // Startup Info 86 ConsensusBlock chain_head = 2; 87 repeated ConsensusPeerInfo peers = 3; 88 ConsensusPeerInfo local_peer_info = 4; 89 } 90 91 // --== Notifications ==-- 92 93 // The following are notifications provided by the validator to the consensus 94 // engine. An ack should be sent in response to all notifications. 95 96 // - P2P - 97 98 // A new peer was added 99 message ConsensusNotifyPeerConnected { 100 ConsensusPeerInfo peer_info = 1; 101 } 102 103 // An existing peer was dropped 104 message ConsensusNotifyPeerDisconnected { 105 bytes peer_id = 1; 106 } 107 108 // A new message was received from a peer 109 message ConsensusNotifyPeerMessage { 110 ConsensusPeerMessage message = 1; 111 bytes sender_id = 2; 112 } 113 114 // - Blocks - 115 116 // A new block was received and passed initial consensus validation 117 message ConsensusNotifyBlockNew { 118 ConsensusBlock block = 1; 119 } 120 121 // This block can be committed successfully 122 message ConsensusNotifyBlockValid { 123 bytes block_id = 1; 124 } 125 126 // This block cannot be committed successfully 127 message ConsensusNotifyBlockInvalid { 128 bytes block_id = 1; 129 } 130 131 // This block has been committed 132 message ConsensusNotifyBlockCommit { 133 bytes block_id = 1; 134 } 135 136 // Confirm that the notification was received. The validator message 137 // correlation id is used to determine which notification this is an ack for. 138 message ConsensusNotifyAck {} 139 140 // --== Services Provided ==-- 141 142 // The following are services provided by the validator to the consensus 143 // engine. All service messages have at a minimum the following possible return 144 // statuses: 145 // 146 // STATUS_UNSET 147 // No status was set by the validator, this should never happen 148 // OK 149 // The request was completed successfully 150 // BAD_REQUEST 151 // The request was malformed in some way 152 // SERVICE_ERROR 153 // The validator failed to perform the request 154 // NOT_READY 155 // The validator is not accepting requests, usually because it is still 156 // starting up 157 // 158 // Additionally, messages may have the following additional return statuses: 159 // 160 // INVALID_STATE 161 // The request is not valid given the current state of the validator 162 // UNKNOWN_BLOCK 163 // No block with the given id could be found 164 // UNKNOWN_PEER 165 // No peer with the given id could be found 166 167 // - P2P Messaging - 168 169 // Send a consensus message to a specific, connected peer 170 message ConsensusSendToRequest { 171 ConsensusPeerMessage message = 1; 172 bytes peer_id = 2; 173 } 174 175 message ConsensusSendToResponse { 176 enum Status { 177 STATUS_UNSET = 0; 178 OK = 1; 179 BAD_REQUEST = 2; 180 SERVICE_ERROR = 3; 181 NOT_READY = 4; 182 183 UNKNOWN_PEER = 5; 184 } 185 Status status = 1; 186 } 187 188 // Broadcast a consensus message to all peers 189 message ConsensusBroadcastRequest { 190 ConsensusPeerMessage message = 1; 191 } 192 193 message ConsensusBroadcastResponse { 194 enum Status { 195 STATUS_UNSET = 0; 196 OK = 1; 197 BAD_REQUEST = 2; 198 SERVICE_ERROR = 3; 199 NOT_READY = 4; 200 } 201 Status status = 1; 202 } 203 204 // - Block Creation - 205 206 // Initialize a new block built on the block with the given previous id and 207 // begin adding batches to it. If no previous id is specified, the current 208 // head will be used. 209 message ConsensusInitializeBlockRequest { 210 bytes previous_id = 1; 211 } 212 213 message ConsensusInitializeBlockResponse { 214 enum Status { 215 STATUS_UNSET = 0; 216 OK = 1; 217 BAD_REQUEST = 2; 218 SERVICE_ERROR = 3; 219 NOT_READY = 4; 220 221 INVALID_STATE = 5; 222 UNKNOWN_BLOCK = 6; 223 } 224 Status status = 1; 225 } 226 227 // Stop adding batches to the current block and return a summary of its 228 // contents. 229 message ConsensusSummarizeBlockRequest {} 230 231 message ConsensusSummarizeBlockResponse { 232 enum Status { 233 STATUS_UNSET = 0; 234 OK = 1; 235 BAD_REQUEST = 2; 236 SERVICE_ERROR = 3; 237 NOT_READY = 4; 238 239 INVALID_STATE = 5; 240 BLOCK_NOT_READY = 6; 241 } 242 Status status = 1; 243 244 // A summary of the block contents 245 bytes summary = 2; 246 } 247 248 // Insert the given consensus data into the block and sign it. If this call is 249 // successful, the consensus engine will receive the block afterwards. 250 message ConsensusFinalizeBlockRequest { 251 // The consensus data to include in the finalized block 252 bytes data = 1; 253 } 254 255 message ConsensusFinalizeBlockResponse { 256 enum Status { 257 STATUS_UNSET = 0; 258 OK = 1; 259 BAD_REQUEST = 2; 260 SERVICE_ERROR = 3; 261 NOT_READY = 4; 262 263 INVALID_STATE = 5; 264 BLOCK_NOT_READY = 6; 265 } 266 Status status = 1; 267 268 // The block id of the newly created block 269 bytes block_id = 2; 270 } 271 272 // Stop adding batches to the current block and abandon it. 273 message ConsensusCancelBlockRequest {} 274 275 message ConsensusCancelBlockResponse { 276 enum Status { 277 STATUS_UNSET = 0; 278 OK = 1; 279 BAD_REQUEST = 2; 280 SERVICE_ERROR = 3; 281 NOT_READY = 4; 282 283 INVALID_STATE = 5; 284 } 285 286 Status status = 1; 287 } 288 289 // - Block Directives - 290 291 // Request that, for each block block in order, the block is checked to 292 // determine whether the block can be committed successfully or not. Blocks 293 // may be checked in parallel. If a new request arrives, it overrides the 294 // previous request allowing the engine to reprioritize the list of blocks to 295 // check. 296 // 297 // NOTE: OK does not mean the blocks will all commit successfully, only that 298 // the directive was received successfully. The engine must listen for 299 // notifications from the consuming component to learn if the blocks would 300 // commit or not. 301 message ConsensusCheckBlocksRequest { 302 repeated bytes block_ids = 1; 303 } 304 305 message ConsensusCheckBlocksResponse { 306 enum Status { 307 STATUS_UNSET = 0; 308 OK = 1; 309 BAD_REQUEST = 2; 310 SERVICE_ERROR = 3; 311 NOT_READY = 4; 312 313 UNKNOWN_BLOCK = 5; 314 } 315 316 Status status = 1; 317 } 318 319 // Request that the block be committed. This request fails if the block has 320 // not already been checked. 321 // 322 // NOTE: OK does not mean the block has been committed, only that the directive 323 // was received successfully. The engine must listen for notifications from the 324 // consuming component to learn when the block commits. 325 message ConsensusCommitBlockRequest { 326 bytes block_id = 1; 327 } 328 329 message ConsensusCommitBlockResponse { 330 enum Status { 331 STATUS_UNSET = 0; 332 OK = 1; 333 BAD_REQUEST = 2; 334 SERVICE_ERROR = 3; 335 NOT_READY = 4; 336 337 UNKNOWN_BLOCK = 5; 338 } 339 340 Status status = 1; 341 } 342 343 // Inform the consuming component that this block is no longer being considered 344 // and can be held or freed as needed. 345 message ConsensusIgnoreBlockRequest { 346 bytes block_id = 1; 347 } 348 349 message ConsensusIgnoreBlockResponse { 350 enum Status { 351 STATUS_UNSET = 0; 352 OK = 1; 353 BAD_REQUEST = 2; 354 SERVICE_ERROR = 3; 355 NOT_READY = 4; 356 357 UNKNOWN_BLOCK = 5; 358 } 359 360 Status status = 1; 361 } 362 363 // Fail this block and any of its descendants and purge them as needed. 364 message ConsensusFailBlockRequest { 365 bytes block_id = 1; 366 } 367 368 message ConsensusFailBlockResponse { 369 enum Status { 370 STATUS_UNSET = 0; 371 OK = 1; 372 BAD_REQUEST = 2; 373 SERVICE_ERROR = 3; 374 NOT_READY = 4; 375 376 UNKNOWN_BLOCK = 5; 377 } 378 379 Status status = 1; 380 } 381 382 // - Queries - 383 384 // Retrieve consensus-related information about blocks. If some blocks could 385 // not be found, only the blocks that could be found will be returned. 386 message ConsensusBlocksGetRequest { 387 repeated bytes block_ids = 1; 388 } 389 390 message ConsensusBlocksGetResponse { 391 enum Status { 392 STATUS_UNSET = 0; 393 OK = 1; 394 BAD_REQUEST = 2; 395 SERVICE_ERROR = 3; 396 NOT_READY = 4; 397 398 UNKNOWN_BLOCK = 5; 399 } 400 401 Status status = 1; 402 repeated ConsensusBlock blocks = 2; 403 } 404 405 // Retrieve consensus-related information about the chain head. 406 message ConsensusChainHeadGetRequest {} 407 408 message ConsensusChainHeadGetResponse { 409 enum Status { 410 STATUS_UNSET = 0; 411 OK = 1; 412 BAD_REQUEST = 2; 413 SERVICE_ERROR = 3; 414 NOT_READY = 4; 415 416 NO_CHAIN_HEAD = 5; 417 } 418 419 Status status = 1; 420 ConsensusBlock block = 2; 421 } 422 423 // Read the values of these settings from state as of the given block. If some 424 // values settings keys cannot be found, the keys that were found will be 425 // returned. 426 message ConsensusSettingsGetRequest { 427 bytes block_id = 1; 428 repeated string keys = 2; 429 } 430 431 message ConsensusSettingsGetResponse { 432 enum Status { 433 STATUS_UNSET = 0; 434 OK = 1; 435 BAD_REQUEST = 2; 436 SERVICE_ERROR = 3; 437 NOT_READY = 4; 438 439 UNKNOWN_BLOCK = 5; 440 } 441 442 Status status = 1; 443 repeated ConsensusSettingsEntry entries = 2; 444 } 445 446 // Read the data at these addresses from state as of the given block. If some 447 // addresses cannot be found, state at the addresses that were found will be 448 // returned. 449 message ConsensusStateGetRequest { 450 bytes block_id = 1; 451 repeated string addresses = 2; 452 } 453 454 message ConsensusStateGetResponse { 455 enum Status { 456 STATUS_UNSET = 0; 457 OK = 1; 458 BAD_REQUEST = 2; 459 SERVICE_ERROR = 3; 460 NOT_READY = 4; 461 462 UNKNOWN_BLOCK = 5; 463 } 464 465 Status status = 1; 466 repeated ConsensusStateEntry entries = 2; 467 }