Hyperledger Fabric Transaction Service

Syntax:

com.ibi.agents.XDFabricAgent

Description:

This service invokes chaincode to execute a transaction on a blockchain in the Hyperledger Fabric. It starts by sending a transaction proposal request to all the configured peers. If enough proposal responses are successful (and not too many have failed), then the transaction is sent to the configured Orderers.

In synchronous mode, the service waits for the transaction event from the configured event hubs to make sure the transaction was committed to the blockchain. In asynchronous mode, the service returns immediately because a message is sent to an internal queue when the event finally arrives. An internal queue listener must be configured to read that internal queue to continue processing after the confirmation event.

The TransactionID is stored in the Special Register (SREG) named fabric.TransactionID. Upon error, the output is an error document. When successful in synchronous mode, the output document can be the input document, the chaincode return value, or the TransactionEvent. When successful in asynchronous mode, the output document is the input document.

Parameters:

The following tables list and describe the parameters for the Hyperledger Fabric Transaction service.

Main

Parameter

Description

Fabric Channel Provider

The name of the configured Hyperledger Fabric Channel provider.

Chaincode Name

The name of the chaincode to call.

Chaincode Path

The path of the chaincode to call.

Chaincode Version

The version of the chaincode to call.

Minimum Successful Proposals

Minimum number of successful proposals required to send the transaction to the Orderers.

Maximum Failed Proposals

Maximum number of failed proposals tolerated. The transaction will not be sent to the Orderers if there are more failed proposals.

Return

Determines the contents of the output document. Ignored if asynchronous mode is selected.

In the Main group of parameters, the service refers to the Fabric Channel Provider by name to gain access to the reconstructed Channel. The chaincode name, path and version are determined when the chaincode is installed. The path is similar to a namespace and is not related to a path in the file system. The chaincode must already be installed before calling the Hyperledger Fabric Transaction service.

The Hyperledger Fabric Transaction service has a simple acceptance criterion to decide if the transaction is sent to the Orderers to be committed to the blockchain. There must be a minimum number of successful proposals and the number of failed proposals cannot exceed a maximum. This simple criterion is used by the service as an optimization. It does not have to be perfect. The real endorsement policy is evaluated by the Orderers when creating the block.

The Return parameter determines the contents of the output document in synchronous mode. The output document can be the input document, the chaincode return value, or the TransactionEvent, The chaincode return value is a ByteString, which can be parsed in different ways. The chaincode return value can be:

The TransactionEvent is an object that can be serialized in XML or JSON, and returned as a parsed tree. In asynchronous mode, the Return parameter is ignored because the transaction is not yet complete. In this mode, the output document is always the input document unless there is an error.

Call

Parameter

Description

Argument Type

The data type of all the chaincode arguments, either a regular String, or a byte array encoded as a Hex String with two consecutive hexadecimal characters per byte.

Argument 0

The value of the first argument.

Argument 1

The value of the second argument.

Argument 2

The value of the third argument.

Argument 3

The value of the fourth argument.

Argument 4

The value of the fifth argument.

In the Call group of parameters, the Argument N properties are the arguments to the chaincode invocation. By convention, Argument 0 is often an operation name understood by the chaincode. There can be an unlimited number of arguments. This is done by defining user properties with names of the form argN. For example, the next argument after Argument 4 is arg5. The list of arguments stops at the first empty argument.

The type of the arguments can be string or byte array. All arguments must be the same type. A byte array is encoded as an hexadecimal string with two consecutive hexadecimal characters per byte. For example, 616263 is abc in a UTF8 byte array.

Asynchronous

Parameter

Description

Is Asynchronous

When selected, the input document is returned immediately after the proposal request. The TransactionEvent response is sent to an internal queue when it arrives.

Queue Name

Name of the internal queue where the asynchronous TransactionEvent will be sent.

Event Format

Format of the document sent to the internal queue, XML or JSON.

Want User Registers

User registers are processing variables and their values. If you want these registers to be emitted with the message set this to true. In resubmit operations, usually this is set to false.

Priority

The priority is an integer between 0 and 9 inclusive. The lowest priority is 0. The highest most expedited priority is 9.

Put Timeout

Time, in milliseconds, to wait for queue to become available when attempting to put a message on the queue. You can enter 0 for an unlimited wait, but this is not recommended. If no value is supplied, timeout will be set to 3000 milliseconds.

Request Context Namespace

For synchronous or asynchronous processing, namespace or list of namespaces containing registers that will be made available to the internal listener. Select Default for all registers in default (no prefix) namespace or None to send no registers at all. Enter an asterisk character (*) for registers from all namespaces.

Asynchronous mode is enabled by selecting the Is Asynchronous parameter. The Queue Name parameter tells the service where the message will be sent when the TransactionEvent arrives. The Event Format chooses the format of the document, either XML or JSON. Want User Registers determines if the User registers are preserved with the message. The priority of the message affects in which order the messages are processed by the internal queue listener. The Put Timeout determines how long the callback will wait for the queue to become available when sending the message. After this timeout, the message is dropped.

The Request Context Namespace selects which registers will be preserved with the message. For example, if the value is ns, then all registers with names beginning with ns. (such as ns.reg1) are preserved. Select Default to preserve registers with no prefix. Select None to ignore all registers. Enter an asterisk character (*) to select all registers.

Edges:

The following table lists and describes the edges that are returned by the Hyperledger Fabric Transaction service.

Edge

Description

success

The operation was successful.

fail_parse

An iFL expression could not be evaluated.

fail_operation

The operation could not be completed successfully.

Example 1:

Example 1 shows the parameter values for an invocation of the chaincode in the End2endIT sample of the Hyperledger Fabric Java SDK. It assumes that the fabric1 provider has the same values as the example shown in Hyperledger Fabric Channel Provider.

Parameter

Value

Fabric Channel Provider

fabric1

Chaincode Name

example_cc_go

Chaincode Path

github.com/example_cc

Chaincode Version

1

Argument Type

String

Argument 0

move

Argument 1

a

Argument 2

b

Argument 3

20

Minimum Successful Proposals

1

Maximum Failed Proposals

0

Example 2:

Example 2 shows that the same invocation can be achieved with the chaincode arguments encoded as byte arrays. The iFL function _hex(value,charset) might be useful.

Parameter

Value

Fabric Channel Provider

fabric1

Chaincode Name

example_cc_go

Chaincode Path

github.com/example_cc

Chaincode Version

1

Argument Type

Hex String

Argument 0

_hex('move', 'UTF8')

Argument 1

61

Argument 2

62

Argument 3

3230

Minimum Successful Proposals

1

Maximum Failed Proposals

0

Example 3:

Example 3 shows the extra properties that can be added to example 1 or 2 to enable asynchronous mode. In this mode, the service will return immediately after sending the transaction to the Orderers. A message will be sent to the internal queue q1 when the transaction event arrives, confirming the transaction is part of the blockchain.

Parameter

Value

Is Asynchronous

true

Queue Name

q1

Event Format

XML

Want User Registers

true

Priority

4

Put Timeout

3000

Request Context Namespace

*

The following is a sample output document when the Return parameter is TransactionEvent as XML in synchronous mode. A message similar to this is sent to the Internal queue in asynchronous mode when the Event Format is XML. This document has been indented for display purposes only.

<TransactionEvent>
  <EventHub>
     <Name>peer0</Name>
     <Url>grpc://thor.ibi.com:7053</Url>
  </EventHub>
  <TransactionID>90fdd06ad2752deaed7c9beab00c46bd770667e...</TransactionID>
  <ChannelID>foo</ChannelID>
  <Epoch>0</Epoch>
  <Timestamp>2017-09-26T12:51:32.138-04:00</Timestamp>
  <IsValid>true</IsValid>
  <ValidationCode>0</ValidationCode>
  <TransactionActionInfos>
    <TransactionActionInfo>
      <ResponseStatus>200</ResponseStatus>
      <ResponseMessageBytes/>
      <EndorserInfos>
        <EndorserInfo>
          <Signature>30440220720e51c11b98c17b72ab9a50fbb6...</Signature>
          <Endorser>0a074f7267314d53501280062d2d2d2d2d424...</Endorser>
        </EndorserInfo>
      </EndorserInfos>
      <ChaincodeInputArgs>
        <Arg>696e766f6b65</Arg>
        <Arg>6d6f7665</Arg>
        <Arg>61</Arg>
        <Arg>62</Arg>
        <Arg>3230</Arg>
      </ChaincodeInputArgs>
      <ProposalResponseStatus>200</ProposalResponseStatus>
      <ProposalResponsePayload/>
    </TransactionActionInfo>
  </TransactionActionInfos>
</TransactionEvent>

The following is a sample output document when the Return parameter is TransactionEvent as JSON in synchronous mode. A message similar to this is sent to the Internal queue in asynchronous mode when the Event Format is JSON. The document has been indented for display purposes only.

{
  "EventHub":{"Name":"peer0",
  "Url":"grpc://thor.ibi.com:7053"},
  "TransactionID":"49fa1193bc30c17cc011a6b5850f8e57c92...",
  "ChannelID":"foo",
  "Epoch":0,
  "Timestamp":"2017-09-26T12:54:56.689-04:00",
  "IsValid":true,
  "ValidationCode": 0,
  "TransactionActionInfos": [
    {
      "ResponseStatus": 200,
      "ResponseMessageBytes": "",
      "EndorserInfos": [
        {
          "Signature": "3045022100e5181d03460959d751...",
          "Endorser": "0a074f7267314d53501280062d2d2..."
        }
      ],
      "ChaincodeInputArgs": [
        "696e766f6b65",
        "6d6f7665",
        "61",
        "62",
        "3230"
      ],
      "ProposalResponseStatus": 200,
      "ProposalResponsePayload": ""
    }
  ]
}