Skip to content

Commit

Permalink
NodeSDK - update to latest protos
Browse files Browse the repository at this point in the history
Pull in latest fabric proto files and apply changes
to the Node code. No function changes.

Change-Id: I3c672c1c61a08943d05cdc6b7423d3dce2711b18
Signed-off-by: Bret Harrison <beharrison@nc.rr.com>
  • Loading branch information
harrisob committed Jan 19, 2017
1 parent 7eef633 commit 0b53987
Show file tree
Hide file tree
Showing 15 changed files with 238 additions and 321 deletions.
28 changes: 13 additions & 15 deletions hfc/lib/Chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ var grpc = require('grpc');
var logger = utils.getLogger('Chain.js');

var _ccProto = grpc.load(__dirname + '/protos/peer/chaincode.proto').protos;
var _ccProposalProto = grpc.load(__dirname + '/protos/peer/chaincode_proposal.proto').protos;
var _ccTransProto = grpc.load(__dirname + '/protos/peer/chaincode_transaction.proto').protos;
var _transProto = grpc.load(__dirname + '/protos/peer/fabric_transaction.proto').protos;
var _proposalProto = grpc.load(__dirname + '/protos/peer/fabric_proposal.proto').protos;
var _responseProto = grpc.load(__dirname + '/protos/peer/fabric_proposal_response.proto').protos;
var _transProto = grpc.load(__dirname + '/protos/peer/transaction.proto').protos;
var _proposalProto = grpc.load(__dirname + '/protos/peer/proposal.proto').protos;
var _responseProto = grpc.load(__dirname + '/protos/peer/proposal_response.proto').protos;
var _mspPrProto = grpc.load(__dirname + '/protos/common/msp_principal.proto').common;
var _commonProto = grpc.load(__dirname + '/protos/common/common.proto').common;
var _configurationProto = grpc.load(__dirname + '/protos/common/configuration.proto').common;
Expand Down Expand Up @@ -477,7 +475,7 @@ var Chain = class {
// creation_items.push(chainCreatorsItem.getConfigurationItem().toBuffer());

var ingressPolicy = new _ordererConfigurationProto.IngressPolicy();
ingressPolicy.setName(chainCreatorPolicyName);
ingressPolicy.setNames([chainCreatorPolicyName]);
var ingressPolicyItem = buildSignedConfigurationItem(
configItemChainHeader,
orderer_type,
Expand All @@ -489,7 +487,7 @@ var Chain = class {
creation_items.push(ingressPolicyItem.getConfigurationItem().toBuffer());

var egressPolicy = new _ordererConfigurationProto.EgressPolicy();
egressPolicy.setName(chainCreatorPolicyName);
egressPolicy.setNames([chainCreatorPolicyName]);
var egressPolicyItem = buildSignedConfigurationItem(
configItemChainHeader,
orderer_type,
Expand Down Expand Up @@ -772,7 +770,7 @@ var Chain = class {
chaincodeID: {
name: request.chaincodeId
},
ctorMsg: {
input: {
args: args
}
};
Expand All @@ -794,7 +792,7 @@ var Chain = class {
chaincodeID: {
name: 'lccc'
},
ctorMsg: {
input: {
args: [Buffer.from('deploy', 'utf8'), Buffer.from('default', 'utf8'), chaincodeDeploymentSpec.toBuffer()]
}
};
Expand Down Expand Up @@ -887,7 +885,7 @@ var Chain = class {
chaincodeID: {
name: request.chaincodeId
},
ctorMsg: {
input: {
args: args
}
};
Expand Down Expand Up @@ -986,13 +984,13 @@ var Chain = class {
endorsements.push(proposalResponse.endorsement);
}

var chaincodeEndorsedAction = new _ccTransProto.ChaincodeEndorsedAction();
var chaincodeEndorsedAction = new _transProto.ChaincodeEndorsedAction();
chaincodeEndorsedAction.setProposalResponsePayload(proposalResponse.payload);
chaincodeEndorsedAction.setEndorsements(endorsements);

var chaincodeActionPayload = new _ccTransProto.ChaincodeActionPayload();
var chaincodeActionPayload = new _transProto.ChaincodeActionPayload();
chaincodeActionPayload.setAction(chaincodeEndorsedAction);
var chaincodeProposalPayloadNoTrans = _ccProposalProto.ChaincodeProposalPayload.decode(chaincodeProposal.payload);
var chaincodeProposalPayloadNoTrans = _proposalProto.ChaincodeProposalPayload.decode(chaincodeProposal.payload);
chaincodeProposalPayloadNoTrans.transient = null;
var payload_hash = this.cryptoPrimitives.hash(chaincodeProposalPayloadNoTrans.toBuffer());
chaincodeActionPayload.setChaincodeProposalPayload(Buffer.from(payload_hash, 'hex'));
Expand Down Expand Up @@ -1085,7 +1083,7 @@ var Chain = class {
cciSpec.setChaincodeSpec(invokeSpec);
// cciSpec.setIdGenerationAlg('');

let cc_payload = new _ccProposalProto.ChaincodeProposalPayload();
let cc_payload = new _proposalProto.ChaincodeProposalPayload();
cc_payload.setInput(cciSpec.toBuffer());
//cc_payload.setTransient(null); // TODO application-level confidentiality related

Expand Down Expand Up @@ -1265,7 +1263,7 @@ function buildChainHeader(type, chain_id, tx_id, epoch, chaincode_id) {
let chaincodeID = new _ccProto.ChaincodeID();
chaincodeID.setName(chaincode_id);

let headerExt = new _ccProposalProto.ChaincodeHeaderExtension();
let headerExt = new _proposalProto.ChaincodeHeaderExtension();
headerExt.setChaincodeID(chaincodeID);

chainHeader.setExtension(headerExt.toBuffer());
Expand Down
2 changes: 1 addition & 1 deletion hfc/lib/Peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var utils = require('./utils.js');
var Remote = require('./Remote');
var grpc = require('grpc');

var _serviceProto = grpc.load(__dirname + '/protos/peer/fabric_service.proto').protos;
var _serviceProto = grpc.load(__dirname + '/protos/peer/peer.proto').protos;

var logger = utils.getLogger('Peer.js');

Expand Down
25 changes: 24 additions & 1 deletion hfc/lib/protos/common/configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ message ConfigurationItem {
Policy = 0; // Implies that the Value is a marshaled Policy message, and may be referred to by Key as a ModificationPolicy
Chain = 1; // Marshaled format for this type is yet to be determined
Orderer = 2; // Marshaled format for this type is yet to be determined
Peer = 3; // Marshaled format for this type is yet to be determined
Peer = 3; // Marshaled format for this type is yet to be determined
MSP = 4; // Marshaled MSPConfig proto
}
ChainHeader Header = 1; // The header which ties this configuration to a particular chain
ConfigurationType Type = 2; // The type of configuration this is.
Expand Down Expand Up @@ -116,3 +117,25 @@ message SignaturePolicy {
NOutOf From = 2;
}
}


// HashingAlgorithm is encoded into the configuration transaction as a configuration item of type Chain
// with a Key of "HashingAlgorithm" and a Value of HashingAlgorithm as marshaled protobuf bytes
message HashingAlgorithm {
// Currently supported algorithms are: SHAKE256
string name = 1;
}

// BlockDataHashingStructure is encoded into the configuration transaction as a configuration item of
// type Chain with a Key of "BlockDataHashingStructure" and a Value of HashingAlgorithm as marshaled protobuf bytes
message BlockDataHashingStructure {
// width specifies the width of the Merkle tree to use when computing the BlockDataHash
// in order to replicate flat hashing, set this width to MAX_UINT32
uint32 width = 1;
}

// OrdererAddresses is encoded into the configuration transaction as a configuration item of type Chain
// with a Key of "OrdererAddresses" and a Value of OrdererAddresses as marshaled protobuf bytes
message OrdererAddresses {
repeated string addresses = 1;
}
28 changes: 18 additions & 10 deletions hfc/lib/protos/orderer/configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ message BatchSize {
// The byte count of the serialized messages in a batch cannot
// exceed this value.
uint32 absoluteMaxBytes = 2;
// The byte count of the serialized messages in a batch should not
// exceed this value.
uint32 preferredMaxBytes = 3;
}

message BatchTimeout {
Expand All @@ -64,20 +67,25 @@ message CreationPolicy {
bytes digest = 2;
}

// IngressPolicy is the name of the policy which incoming Broadcast messages are filtered against
message IngressPolicy {
string name = 1;
// IngressPolicyNames is the set of policy names which incoming Broadcast signatures are filtered against
message IngressPolicyNames {
// A list of policies, in evaluation these are 'or'-ed, note this is not a proper policy
// because implementing referential policies in a general way is difficult, and dangerous
repeated string names = 1;
}

// EgressPolicy is the name of the policy which incoming Deliver messages are filtered against
message EgressPolicy {
string name = 1;
// EgressPolicyNames is the set of policy names which incoming Deliver signatures are filtered against
message EgressPolicyNames {
// A list of policies, in evaluation these are 'or'-ed, note this is not a proper policy
// because implementing referential policies in a general way is difficult, and dangerous
repeated string names = 1;
}

message ChainCreators {
// A list of policies, any of which may be specified as the chain creation
// policy in a chain creation request
repeated string policies = 1;
// ChainCreationPolicyNames is the set of policies which may be invoked for chain creation
message ChainCreationPolicyNames {
// A list of policies, in evaluation these are 'or'-ed, note this is not a proper policy
// because implementing referential policies in a general way is difficult, and dangerous
repeated string names = 1;
}

// Carries a list of bootstrap brokers, i.e. this is not the exclusive set of
Expand Down
File renamed without changes.
22 changes: 18 additions & 4 deletions hfc/lib/protos/peer/chaincode.proto
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ message ChaincodeSpec {

Type type = 1;
ChaincodeID chaincodeID = 2;
ChaincodeInput ctorMsg = 3;
ChaincodeInput input = 3;
int32 timeout = 4;
ConfidentialityLevel confidentialityLevel = 5;
bytes metadata = 6;
repeated string attributes = 7;
}

// Specify the deployment of a chaincode.
Expand Down Expand Up @@ -105,6 +102,21 @@ message ChaincodeInvocationSpec {
string idGenerationAlg = 2;
}

// ChaincodeProposalContext contains proposal data that we send to the chaincode
// container shim and allow the chaincode to access through the shim interface.
message ChaincodeProposalContext {

// Creator corresponds to SignatureHeader.Creator
bytes creator = 1;

// Transient corresponds to ChaincodeProposalPayload.Transient
// TODO: The transient field is supposed to carry application-specific
// data. They might be realted to access-control, encryption and so on.
// To simply access to this data, replacing bytes with a map
// is the next step to be carried.
bytes transient = 2;
}

message ChaincodeMessage {

enum Type {
Expand Down Expand Up @@ -132,6 +144,8 @@ message ChaincodeMessage {
bytes payload = 3;
string txid = 4;

ChaincodeProposalContext proposalContext = 5;

//event emmited by chaincode. Used only with Init or Invoke.
// This event is then stored (currently)
//with Block.NonHashData.TransactionResult
Expand Down
137 changes: 0 additions & 137 deletions hfc/lib/protos/peer/chaincode_proposal.proto

This file was deleted.

Loading

0 comments on commit 0b53987

Please sign in to comment.