|
| 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 | + NOT_IMPLEMENTED = 501; |
| 36 | + SERVICE_UNAVAILABLE = 503; |
| 37 | +} |
| 38 | + |
| 39 | +enum HeaderType { |
| 40 | + // Prevent removed tag re-use |
| 41 | + // Uncomment after fabric-baseimage moves to 3.5.1 |
| 42 | + // reserved 7; |
| 43 | + // reserved "PEER_RESOURCE_UPDATE"; |
| 44 | + |
| 45 | + MESSAGE = 0; // Used for messages which are signed but opaque |
| 46 | + CONFIG = 1; // Used for messages which express the channel config |
| 47 | + CONFIG_UPDATE = 2; // Used for transactions which update the channel config |
| 48 | + ENDORSER_TRANSACTION = 3; // Used by the SDK to submit endorser based transactions |
| 49 | + ORDERER_TRANSACTION = 4; // Used internally by the orderer for management |
| 50 | + DELIVER_SEEK_INFO = 5; // Used as the type for Envelope messages submitted to instruct the Deliver API to seek |
| 51 | + CHAINCODE_PACKAGE = 6; // Used for packaging chaincode artifacts for install |
| 52 | + PEER_ADMIN_OPERATION = 8; // Used for invoking an administrative operation on a peer |
| 53 | + TOKEN_TRANSACTION = 9; // Used to denote transactions that invoke token management operations |
| 54 | +} |
| 55 | + |
| 56 | +// This enum enlists indexes of the block metadata array |
| 57 | +enum BlockMetadataIndex { |
| 58 | + SIGNATURES = 0; // Block metadata array position for block signatures |
| 59 | + LAST_CONFIG = 1; // Block metadata array position to store last configuration block sequence number |
| 60 | + TRANSACTIONS_FILTER = 2; // Block metadata array position to store serialized bit array filter of invalid transactions |
| 61 | + ORDERER = 3; /* Block metadata array position to store operational metadata for orderers e.g. For Kafka, |
| 62 | + this is where we store the last offset written to the local ledger */ |
| 63 | + COMMIT_HASH = 4; /* Block metadata array position to store the hash of TRANSACTIONS_FILTER, State Updates, |
| 64 | + and the COMMIT_HASH of the previous block */ |
| 65 | +} |
| 66 | + |
| 67 | +// LastConfig is the encoded value for the Metadata message which is encoded in the LAST_CONFIGURATION block metadata index |
| 68 | +message LastConfig { |
| 69 | + uint64 index = 1; |
| 70 | +} |
| 71 | + |
| 72 | +// Metadata is a common structure to be used to encode block metadata |
| 73 | +message Metadata { |
| 74 | + bytes value = 1; |
| 75 | + repeated MetadataSignature signatures = 2; |
| 76 | +} |
| 77 | + |
| 78 | +message MetadataSignature { |
| 79 | + bytes signature_header = 1; // An encoded SignatureHeader |
| 80 | + bytes signature = 2; // The signature over the concatenation of the Metadata value bytes, signatureHeader, and block header |
| 81 | +} |
| 82 | + |
| 83 | +message Header { |
| 84 | + bytes channel_header = 1; |
| 85 | + bytes signature_header = 2; |
| 86 | +} |
| 87 | + |
| 88 | +// Header is a generic replay prevention and identity message to include in a signed payload |
| 89 | +message ChannelHeader { |
| 90 | + int32 type = 1; // Header types 0-10000 are reserved and defined by HeaderType |
| 91 | + |
| 92 | + // Version indicates message protocol version |
| 93 | + int32 version = 2; |
| 94 | + |
| 95 | + // Timestamp is the local time when the message was created |
| 96 | + // by the sender |
| 97 | + google.protobuf.Timestamp timestamp = 3; |
| 98 | + |
| 99 | + // Identifier of the channel this message is bound for |
| 100 | + string channel_id = 4; |
| 101 | + |
| 102 | + // An unique identifier that is used end-to-end. |
| 103 | + // - set by higher layers such as end user or SDK |
| 104 | + // - passed to the endorser (which will check for uniqueness) |
| 105 | + // - as the header is passed along unchanged, it will be |
| 106 | + // be retrieved by the committer (uniqueness check here as well) |
| 107 | + // - to be stored in the ledger |
| 108 | + string tx_id = 5; |
| 109 | + |
| 110 | + // The epoch in which this header was generated, where epoch is defined based on block height |
| 111 | + // Epoch in which the response has been generated. This field identifies a |
| 112 | + // logical window of time. A proposal response is accepted by a peer only if |
| 113 | + // two conditions hold: |
| 114 | + // 1. the epoch specified in the message is the current epoch |
| 115 | + // 2. this message has been only seen once during this epoch (i.e. it hasn't |
| 116 | + // been replayed) |
| 117 | + uint64 epoch = 6; |
| 118 | + |
| 119 | + // Extension that may be attached based on the header type |
| 120 | + bytes extension = 7; |
| 121 | + |
| 122 | + // If mutual TLS is employed, this represents |
| 123 | + // the hash of the client's TLS certificate |
| 124 | + bytes tls_cert_hash = 8; |
| 125 | +} |
| 126 | + |
| 127 | +message SignatureHeader { |
| 128 | + // Creator of the message, a marshaled msp.SerializedIdentity |
| 129 | + bytes creator = 1; |
| 130 | + |
| 131 | + // Arbitrary number that may only be used once. Can be used to detect replay attacks. |
| 132 | + bytes nonce = 2; |
| 133 | +} |
| 134 | + |
| 135 | +// Payload is the message contents (and header to allow for signing) |
| 136 | +message Payload { |
| 137 | + |
| 138 | + // Header is included to provide identity and prevent replay |
| 139 | + Header header = 1; |
| 140 | + |
| 141 | + // Data, the encoding of which is defined by the type in the header |
| 142 | + bytes data = 2; |
| 143 | +} |
| 144 | + |
| 145 | +// Envelope wraps a Payload with a signature so that the message may be authenticated |
| 146 | +message Envelope { |
| 147 | + // A marshaled Payload |
| 148 | + bytes payload = 1; |
| 149 | + |
| 150 | + // A signature by the creator specified in the Payload header |
| 151 | + bytes signature = 2; |
| 152 | +} |
| 153 | + |
| 154 | +// This is finalized block structure to be shared among the orderer and peer |
| 155 | +// Note that the BlockHeader chains to the previous BlockHeader, and the BlockData hash is embedded |
| 156 | +// in the BlockHeader. This makes it natural and obvious that the Data is included in the hash, but |
| 157 | +// the Metadata is not. |
| 158 | +message Block { |
| 159 | + BlockHeader header = 1; |
| 160 | + BlockData data = 2; |
| 161 | + BlockMetadata metadata = 3; |
| 162 | +} |
| 163 | + |
| 164 | +// BlockHeader is the element of the block which forms the block chain |
| 165 | +// The block header is hashed using the configured chain hashing algorithm |
| 166 | +// over the ASN.1 encoding of the BlockHeader |
| 167 | +message BlockHeader { |
| 168 | + uint64 number = 1; // The position in the blockchain |
| 169 | + bytes previous_hash = 2; // The hash of the previous block header |
| 170 | + bytes data_hash = 3; // The hash of the BlockData, by MerkleTree |
| 171 | +} |
| 172 | + |
| 173 | +message BlockData { |
| 174 | + repeated bytes data = 1; |
| 175 | +} |
| 176 | + |
| 177 | +message BlockMetadata { |
| 178 | + repeated bytes metadata = 1; |
| 179 | +} |
| 180 | + |
| 181 | +// OrdererBlockMetadata defines metadata that is set by the ordering service. |
| 182 | +message OrdererBlockMetadata { |
| 183 | + LastConfig last_config = 1; |
| 184 | + bytes consenter_metadata = 2; |
| 185 | +} |
0 commit comments