github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/protos/common/common.proto (about)

     1  /*
     2  Copyright IBM Corp. 2016 All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8                   http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  syntax = "proto3";
    18  
    19  import "google/protobuf/timestamp.proto";
    20  
    21  option go_package = "github.com/hyperledger/fabric/protos/common";
    22  option java_package = "org.hyperledger.fabric.protos.common";
    23  
    24  package common;
    25  
    26  // These status codes are intended to resemble selected HTTP status codes
    27  enum Status {
    28      UNKNOWN = 0;
    29      SUCCESS = 200;
    30      BAD_REQUEST = 400;
    31      FORBIDDEN = 403;
    32      NOT_FOUND = 404;
    33      REQUEST_ENTITY_TOO_LARGE = 413;
    34      INTERNAL_SERVER_ERROR = 500;
    35      SERVICE_UNAVAILABLE = 503;
    36  }
    37  
    38  enum HeaderType {
    39      MESSAGE = 0;                   // Used for messages which are signed but opaque
    40      CONFIG = 1;                    // Used for messages which express the channel config
    41      CONFIG_UPDATE = 2;             // Used for transactions which update the channel config
    42      ENDORSER_TRANSACTION = 3;      // Used by the SDK to submit endorser based transactions
    43      ORDERER_TRANSACTION = 4;       // Used internally by the orderer for management
    44      DELIVER_SEEK_INFO = 5;         // Used as the type for Envelope messages submitted to instruct the Deliver API to seek
    45      CHAINCODE_PACKAGE = 6;         // Used for packaging chaincode artifacts for install
    46  }
    47  
    48  // This enum enlists indexes of the block metadata array
    49  enum BlockMetadataIndex {
    50      SIGNATURES = 0;             // Block metadata array position for block signatures
    51      LAST_CONFIG = 1;            // Block metadata array position to store last configuration block sequence number
    52      TRANSACTIONS_FILTER = 2;    // Block metadata array position to store serialized bit array filter of invalid transactions
    53      ORDERER = 3;                // Block metadata array position to store operational metadata for orderers
    54                                  // e.g. For Kafka, this is where we store the last offset written to the local ledger.
    55  }
    56  
    57  // LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index
    58  message LastConfig {
    59  	uint64 index  = 1;
    60  }
    61  
    62  // Metadata is a common structure to be used to encode block metadata
    63  message Metadata {
    64      bytes value = 1;
    65      repeated MetadataSignature signatures = 2;
    66  }
    67  
    68  message MetadataSignature {
    69      bytes signature_header = 1; // An encoded SignatureHeader
    70      bytes signature = 2;       // The signature over the concatenation of the Metadata value bytes, signatureHeader, and block header
    71  }
    72  
    73  message Header {
    74      bytes channel_header = 1;
    75      bytes signature_header = 2;
    76  }
    77  
    78  // Header is a generic replay prevention and identity message to include in a signed payload
    79  message ChannelHeader {
    80      int32 type = 1; // Header types 0-10000 are reserved and defined by HeaderType
    81  
    82      // Version indicates message protocol version
    83      int32 version = 2;
    84  
    85      // Timestamp is the local time when the message was created
    86      // by the sender
    87      google.protobuf.Timestamp timestamp = 3;
    88  
    89      // Identifier of the channel this message is bound for
    90      string channel_id = 4;
    91  
    92      // An unique identifier that is used end-to-end.
    93      //  -  set by higher layers such as end user or SDK
    94      //  -  passed to the endorser (which will check for uniqueness)
    95      //  -  as the header is passed along unchanged, it will be
    96      //     be retrieved by the committer (uniqueness check here as well)
    97      //  -  to be stored in the ledger
    98      string tx_id = 5;
    99  
   100      // The epoch in which this header was generated, where epoch is defined based on block height
   101      // Epoch in which the response has been generated. This field identifies a
   102      // logical window of time. A proposal response is accepted by a peer only if
   103      // two conditions hold:
   104      // 1. the epoch specified in the message is the current epoch
   105      // 2. this message has been only seen once during this epoch (i.e. it hasn't
   106      //    been replayed)
   107      uint64 epoch = 6;
   108  
   109      // Extension that may be attached based on the header type
   110      bytes extension = 7;
   111  }
   112  
   113  message SignatureHeader {
   114      // Creator of the message, specified as a certificate chain
   115      bytes creator = 1;
   116  
   117      // Arbitrary number that may only be used once. Can be used to detect replay attacks.
   118      bytes nonce = 2;
   119  }
   120  
   121  // Payload is the message contents (and header to allow for signing)
   122  message Payload {
   123  
   124      // Header is included to provide identity and prevent replay
   125      Header header = 1;
   126  
   127      // Data, the encoding of which is defined by the type in the header
   128      bytes data = 2;
   129  }
   130  
   131  // Envelope wraps a Payload with a signature so that the message may be authenticated
   132  message Envelope {
   133      // A marshaled Payload
   134      bytes payload = 1;
   135  
   136      // A signature by the creator specified in the Payload header
   137      bytes signature = 2;
   138  }
   139  
   140  // This is finalized block structure to be shared among the orderer and peer
   141  // Note that the BlockHeader chains to the previous BlockHeader, and the BlockData hash is embedded
   142  // in the BlockHeader.  This makes it natural and obvious that the Data is included in the hash, but
   143  // the Metadata is not.
   144  message Block {
   145      BlockHeader header = 1;
   146      BlockData data = 2;
   147      BlockMetadata metadata = 3;
   148  }
   149  
   150  // BlockHeader is the element of the block which forms the block chain
   151  // The block header is hashed using the configured chain hashing algorithm
   152  // over the ASN.1 encoding of the BlockHeader
   153  message BlockHeader {
   154      uint64 number = 1; // The position in the blockchain
   155      bytes previous_hash = 2; // The hash of the previous block header
   156      bytes data_hash = 3; // The hash of the BlockData, by MerkleTree
   157  }
   158  
   159  message BlockData {
   160      repeated bytes data = 1;
   161  }
   162  
   163  message BlockMetadata {
   164      repeated bytes metadata = 1;
   165  }