Nika Kurashvili
Nika Kurashvili

Reputation: 6462

What is the profile section in configtx.yaml in Hyperledger Fabric

    TwoOrgsOrdererGenesis:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults
            Organizations:
                - *OrdererOrg
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            SampleConsortium:
                Organizations:
                    - *Org1
                    - *Org2
                    
    TwoOrgsChannel:
        Consortium: SampleConsortium
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
            Capabilities:
                <<: *ApplicationCapabilities

What does that section mean at all?

Let's talk about the first profile: TwoOrgsOrdererGenesis. What does that mean? What is the consortium? And why in examples there's a SampleConsortium name for genesis block settings and channel settings? I checked the genesis block content and couldn't find anything with that name.

Upvotes: 3

Views: 1166

Answers (1)

Mohamed Assem
Mohamed Assem

Reputation: 164

In this file we configure genesis block which can be implemented by you to build your own network so let's dive in some details.

In the field of organizations, which looks like this:

Organizations:

# SampleOrg defines an MSP using the sampleconfig.  It should never be used
# in production but may be used as a template for other definitions
- &OrdererOrg
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: OrdererOrg

    # ID to load the MSP definition as
    ID: OrdererMSP

    # MSPDir is the filesystem path which contains the MSP configuration
    MSPDir: crypto-config/ordererOrganizations/example.com/msp

- &Org1
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: Org1MSP

    # ID to load the MSP definition as
    ID: Org1MSP

    MSPDir: crypto-config/peerOrganizations/org1.example.com/msp

    AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.org1.example.com
          Port: 7051

- &Org2
    # DefaultOrg defines the organization which is used in the sampleconfig
    # of the fabric.git development environment
    Name: Org2MSP

    # ID to load the MSP definition as
    ID: Org2MSP

    MSPDir: crypto-config/peerOrganizations/org2.example.com/msp

    AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.org2.example.com
          Port: 7051

Here we define our organizations with it's peer and give to our fabric the link for the crypto materials for those organizations. so here in this example we have 3 organizations the Orderer Organization and 2 other peerOrganizations at the top of the file you can notice the following

Name: OrdererOrg
ID: OrdererMSP
MSPDir: crypto-config/ordererOrganizations/example.com/msp

Here is the config for the orderer org and we provide id to membership service provider which is framework that handle all the cryptographic operations signing, verifying, issuing and chaining we link it with the place where the crypto material for this org located on our file system MSPDir.

And the following peerOrganizations Org1 and Org2 follows the same structure except they are have to contain at an anchor peer which allows your organization peers to communicate with other organizations peers which is the main point to keep data sync with multiple organizations,so we have to define the anchor peer for each org in the following section

AnchorPeers:
        # AnchorPeers defines the location of peers which can be used
        # for cross org gossip communication.  Note, this value is only
        # encoded in the genesis block in the Application section context
        - Host: peer0.org1.example.com
          Port: 7051

now moving to another section in the file which is Orderer: it looks like

Orderer: &OrdererDefaults

# Orderer Type: The orderer implementation to start
# Available types are "solo" and "kafka"
OrdererType: solo

Addresses:
    - orderer.example.com:7050

# Batch Timeout: The amount of time to wait before creating a batch
BatchTimeout: 2s

# Batch Size: Controls the number of messages batched into a block
BatchSize:

    # Max Message Count: The maximum number of messages to permit in a batch
    MaxMessageCount: 10

    # Absolute Max Bytes: The absolute maximum number of bytes allowed for
    # the serialized messages in a batch.
    AbsoluteMaxBytes: 99 MB

    # Preferred Max Bytes: The preferred maximum number of bytes allowed for
    # the serialized messages in a batch. A message larger than the preferred
    # max bytes will result in a batch larger than preferred max bytes.
    PreferredMaxBytes: 512 KB

Kafka:
    # Brokers: A list of Kafka brokers to which the orderer connects
    # NOTE: Use IP:port notation
    Brokers:
        - 127.0.0.1:9092

# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:

In case you notice Orderer: &OrdererDefaults it's an alias holding the following settings so we can use it in the Profile section as will be explain after this section:

    OrdererType: solo

This means that we use solo messaging server which is applicable in development but not in production we use Kafka in production environment:

Addresses:
    - orderer.example.com:7050

The addresses for the orderers here we have only one orderer but in real production case we can have more than one orderer so you can provide it addresses in here:

BatchSize:

    # Max Message Count: The maximum number of messages to permit in a batch
    MaxMessageCount: 10

    # Absolute Max Bytes: The absolute maximum number of bytes allowed for
    # the serialized messages in a batch.
    AbsoluteMaxBytes: 99 MB

    # Preferred Max Bytes: The preferred maximum number of bytes allowed for
    # the serialized messages in a batch. A message larger than the preferred
    # max bytes will result in a batch larger than preferred max bytes.
    PreferredMaxBytes: 512 KB

In this section we define when to create new block so it depends on your business use case so you can depend on the time of creation new block which is BatchTimeout or on the BatchSize how many transaction should the block hold or even the max size of the block alter those values carefully to meet your needs:

Kafka: # Brokers: A list of Kafka brokers to which the orderer connects # NOTE: Use IP:port notation Brokers: - 127.0.0.1:9092

If you are using Kafka this configurations will be used and in production you will have more than one broker so provide the IP addresses of you brokers.

Finally the Profiles section:

Profiles:

TwoOrgsOrdererGenesis:
    Capabilities:
        <<: *ChannelCapabilities
    Orderer:
        <<: *OrdererDefaults
        Organizations:
            - *OrdererOrg
        Capabilities:
            <<: *OrdererCapabilities
    Consortiums:
        SampleConsortium:
            Organizations:
                - *Org1
                - *Org2
TwoOrgsChannel:
    Consortium: SampleConsortium
    Application:
        <<: *ApplicationDefaults
        Organizations:
            - *Org1
            - *Org2
        Capabilities:
            <<: *ApplicationCapabilities

This section is to combine all our configurations in good readable manner syntax in other words this section will be executed when you try to create the genesis block, in the first section we are going to provide the configuration to create the Genesis block.

  <<: *ChannelCapabilities

This means to import the setting that ChannelCapabilities alias is referring to in this section.

<<: *OrdererDefaults

That means to import all crypto materials OrdererDefaults as alias referring to it in this section.

In the filed Consortiums we here specify which organizations this orderer is going to serve because one orderer can serve more than one organization

The TwoOrgsChannel is the channel the our organizations are going to join keep in mind each organization can join more than one channel so we have to provide the channel Consortium as well to let the channel know who are our joining organizations to serve.

Upvotes: 6

Related Questions