Fatal error when initializing core config : Could not find config file. FABRIC_CFG_PATH problem

51 views Asked by At

I'm having trouble creating the channel on my Hyperledger Fabric network.

I am using version 1.4.0 of Hyperledger Fabric following the requirements of the Fabric python SDK.

I'm running everything in a local environment for testing, below the code:

start.sh

        # -----------------------------------        
        #Before this I created crypto-materials, genesis-block, created docker container and created Anchor Peers Update for Orgs 
        # -----------------------------------
        printSeparator "Set Identity to Org1"
        switchIdentity "Org1" 7051 && echoCurrentFabricEnvironment
        printSeparator "Create channel"
        peer channel create -o localhost:7050 -c modbus2chainchannel --ordererTLSHostnameOverride orderer0.modbus2chain.com -f ./channel-artifacts/modbus2chainchannel.tx --outputBlock ./channel-artifacts/modbus2chainchannel.block --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA
        printSeparator "Join Org1 to channel"
        peer channel join -b ./channel-artifacts/modbus2chainchannel.block && sleep 1
        printSeparator "Update Anchor Peers as Org1"
        peer channel update -o localhost:7050 --ordererTLSHostnameOverride orderer0.modbus2chain.com -c modbus2chainchannel -f ./channel-artifacts/ORG1MSPanchors.tx --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA

utils.sh

function switchIdentity() {
    ORG=$1
    LOWER_MSP=$(echo $ORG | tr A-Z a-z)
    PORT=$2

    
    export CORE_PEER_TLS_ENABLED=true
    export ORDERER_CA=${PWD}/crypto-material/ordererOrganizations/modbus2chain.com/orderers/orderer0.modbus2chain.com/msp/tlscacerts/tlsca.modbus2chain.com-cert.pem
    export CORE_PEER_LOCALMSPID=${ORG}MSP
    export CORE_PEER_TLS_ROOTCERT_FILE=${PWD}/crypto-material/peerOrganizations/${LOWER_MSP}.modbus2chain.com/peers/peer0.${LOWER_MSP}.modbus2chain.com/tls/ca.crt
    export CORE_PEER_MSPCONFIGPATH=${PWD}/crypto-material/peerOrganizations/${LOWER_MSP}.modbus2chain.com/users/Admin@${LOWER_MSP}.modbus2chain.com/msp
    export CORE_PEER_ADDRESS=localhost:${PORT}
    export FABRIC_CFG_PATH=${PWD}/config
}

When "peer channel create" I get this error:

2023-12-30 17:29:42.825 CET [main] InitCmd -> ERRO 001 Fatal error when initializing core config : Could not find config file. Please make sure that FABRIC_CFG_PATH is set to a path which contains core.yaml

Although the FABRIC_CFG_PATH variable is set correctly and inside the config folder there are all the configuration files needed for the network (core.yaml, configtx.yaml and orderer.yaml)

I've tried with different configurations but can't find the specific problem. Maybe it's some discrepancy between versions? I went from version 2.x to 1.4.0 and don't want to leave anything behind that can cause problems.

Below I also leave the configuration files hoping they can be of help:

configtx.yaml

Organizations:

    - &OrdererOrg
        Name: OrdererOrg 
        ID: OrdererMSP  # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
        MSPDir: ../crypto-material/ordererOrganizations/modbus2chain.com/msp  
        Policies:    # Configurazione del tipo di ruoli a cui si è autorizzati a fare
            Readers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('OrdererMSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('OrdererMSP.admin')"  
        OrdererEndpoints:
            - orderer0.modbus2chain.com:7050

    - &Org1
        Name: Org1
        ID: Org1MSP   # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
        MSPDir: ../crypto-material/peerOrganizations/org1.modbus2chain.com/msp
        Policies:  # Configurazione del tipo di ruoli a cui si è autorizzati a fare
            Readers:
                Type: Signature
                Rule: "OR('Org1MSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('Org1MSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('Org1MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org1MSP.member')"
        AnchorPeers:  # Gateway peer da un'organizzazione all'Anchor Peer di un'altra organizzazione
            - Host: peer0.org1.modbus2chain.com
              Port: 7051

    - &Org2
        Name: Org2
        ID: Org2MSP   # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
        MSPDir: ../crypto-material/peerOrganizations/org2.modbus2chain.com/msp
        Policies:  # Configurazione del tipo di ruoli a cui si è autorizzati a fare
            Readers:
                Type: Signature
                Rule: "OR('Org2MSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('Org2MSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('Org2MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org2MSP.member')"
        AnchorPeers:  # Gateway peer da un'organizzazione all'Anchor Peer di un'altra organizzazione
            - Host: peer0.org2.modbus2chain.com
              Port: 8051

    - &Org3
        Name: Org3
        ID: Org3MSP   # Consente agli altri partecipanti alla rete l'identificazione di questa entità.
        MSPDir: ../crypto-material/peerOrganizations/org3.modbus2chain.com/msp
        Policies:  # Configurazione del tipo di ruoli a cui si è autorizzati a fare
            Readers:
                Type: Signature
                Rule: "OR('Org3MSP.member')"
            Writers:
                Type: Signature
                Rule: "OR('Org3MSP.member')"
            Admins:
                Type: Signature
                Rule: "OR('Org3MSP.admin')"
            Endorsement:
                Type: Signature
                Rule: "OR('Org3MSP.member')"
        AnchorPeers:  # Gateway peer da un'organizzazione all'Anchor Peer di un'altra organizzazione
            - Host: peer0.org3.modbus2chain.com
              Port: 8052

# Nelle Capabilities *Channel* definisce il set di funzionalità di Hyperledger che viene utilizzato solo dai peer, 
# mentre *Orderer* definisce il set di funzionalità che è rilevante (lo indovini) solo per gli ordini. 
# L'*applicazione* , d'altra parte, definisce il set di funzionalità, che è rilevante per tutti i peer E tutti gli ordinatori e quindi definisce il minimo comune denominatore per l'intera rete.
Capabilities:
    Channel: &ChannelCapabilities
        V1_4: true
    Orderer: &OrdererCapabilities
        V1_4: true
    Application: &ApplicationCapabilities
        V1_4: true

Application: &ApplicationDefaults
    Organizations:
    Policies:  
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        LifecycleEndorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"
        Endorsement:
            Type: ImplicitMeta
            Rule: "MAJORITY Endorsement"
    Capabilities:
        <<: *ApplicationCapabilities

Orderer: &OrdererDefaults
    OrdererType: etcdraft
    etcdRaft:
        Options:
              TickInterval: 500ms
              ElectionTick: 10
              HeartbeatTick: 1
              MaxInflightBlocks: 5
              SnapshotIntervalSize: 20971520
        Consenters:
        - Host: orderer0.modbus2chain.com
          Port: 7050
          ClientTLSCert: ../crypto-material/ordererOrganizations/modbus2chain.com/orderers/orderer0.modbus2chain.com/tls/server.crt
          ServerTLSCert: ../crypto-material/ordererOrganizations/modbus2chain.com/orderers/orderer0.modbus2chain.com/tls/server.crt
    BatchTimeout: 2s      # Definiscono alcune specifiche riguardanti il ​​tempo dopo il quale un blocco dovrebbe essere  
    BatchSize:            # costruito e quante transazioni dovrebbe contenere al massimo
        MaxMessageCount: 10
        AbsoluteMaxBytes: 99 MB
        PreferredMaxBytes: 512 KB
    Organizations:
    Policies:  # Configurazione del tipo di ruoli a cui si è autorizzati a fare (in questo caso per l'intera rete)
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
        BlockValidation:
            Type: ImplicitMeta
            Rule: "ANY Writers"

Channel: &ChannelDefaults   #Si definisce qui quali criteri di canale predefiniti sono impostati per il canale
    Policies:
        Readers:
            Type: ImplicitMeta
            Rule: "ANY Readers"
        Writers:
            Type: ImplicitMeta
            Rule: "ANY Writers"
        Admins:
            Type: ImplicitMeta
            Rule: "MAJORITY Admins"
    Capabilities:
        <<: *ChannelCapabilities

Profiles:
    modbus2chainNetworkProfile:
        <<: *ChannelDefaults
        Orderer:
            <<: *OrdererDefaults   #definiscono chi sarà in grado di modificare ( Admins ) la nostra rete o semplicemente leggere / scrivere ( Readers / Writers ) sulla nostra rete.
            Organizations:      # Qui definiamo da quali organizzazioni provengono i nostri ordinatori
                - *OrdererOrg   
            Capabilities:
                <<: *OrdererCapabilities
        Consortiums:
            modbus2chainConsortium:
                Organizations:   # Quali organizzazioni sono autorizzate a unirsi alla rete e creare canali ecc..?
                    - *Org1
                    - *Org2
                    - *Org3
    modbus2chainChannelProfile:
        Consortium: modbus2chainConsortium
        <<: *ChannelDefaults
        Application:
            <<: *ApplicationDefaults
            Organizations:
                - *Org1
                - *Org2
                - *Org3
            Capabilities:
                <<: *ApplicationCapabilities

core.yaml

peer:
  id: ap
  networkId: apdev
  listenAddress: 0.0.0.0:7051
  address: 0.0.0.0:7051
  addressAutoDetect: false
  keepalive:
    interval: 7200s
    timeout: 20s
    minInterval: 60s
    client:
      interval: 60s
      timeout: 20s
    deliveryClient:
      interval: 60s
      timeout: 20s
  gossip:
    bootstrap: 127.0.0.1:7051
    useLeaderElection: true
    orgLeader: false
    membershipTrackerInterval: 5s
    endpoint:
    maxBlockCountToStore: 100
    maxPropagationBurstLatency: 10ms
    maxPropagationBurstSize: 10
    propagateIterations: 1
    propagatePeerNum: 3
    pullInterval: 4s
    pullPeerNum: 3
    requestStateInfoInterval: 4s
    publishStateInfoInterval: 4s
    stateInfoRetentionInterval:
    publishCertPeriod: 10s
    skipBlockVerification: false
    dialTimeout: 3s
    connTimeout: 2s
    recvBuffSize: 20
    sendBuffSize: 200
    digestWaitTime: 1s
    requestWaitTime: 1500ms
    responseWaitTime: 2s
    aliveTimeInterval: 5s
    aliveExpirationTimeout: 25s
    reconnectInterval: 25s
    externalEndpoint:
    election:
      startupGracePeriod: 15s
      membershipSampleInterval: 1s
      leaderAliveThreshold: 10s
      leaderElectionDuration: 5s
    pvtData:
      pullRetryThreshold: 60s
      transientstoreMaxBlockRetention: 1000
      pushAckTimeout: 3s
      btlPullMargin: 10
      reconcileBatchSize: 10
      reconcileSleepInterval: 1m
      reconciliationEnabled: true
      skipPullingInvalidTransactionsDuringCommit: false
      implicitCollectionDisseminationPolicy:
        requiredPeerCount: 0
        maxPeerCount: 1
    state:
      enabled: true
      checkInterval: 10s
      responseTimeout: 3s
      batchSize: 10
      blockBufferSize: 100
      maxRetries: 3
  tls:
    enabled: true
    clientAuthRequired: false
    cert:
      file: tls/server.crt
    key:
      file: tls/server.key
    rootcert:
      file: tls/ca.crt
    clientRootCAs:
      files:
        - tls/ca.crt
    clientKey:
      file:
    clientCert:
      file:
  authentication:
    timewindow: 15m
  fileSystemPath: /var/hyperledger/production
  BCCSP:
    Default: SW
    SW:
      Hash: SHA2
      Security: 256
      FileKeyStore:
        KeyStore:
    PKCS11:
      Library:
      Label:
      Pin:
      Hash:
      Security:
  mspConfigPath: msp
  localMspId: SampleOrg
  client:
    connTimeout: 3s
  deliveryclient:
    reconnectTotalTimeThreshold: 3600s
    connTimeout: 3s
    reConnectBackoffThreshold: 3600s
    addressOverrides:
  localMspType: bccsp
  profile:
    enabled: false
    listenAddress: 0.0.0.0:6060
  handlers:
    authFilters:
      - name: DefaultAuth
      -
    decorators:
      - name: DefaultDecorator
    endorsers:
      escc:
        name: DefaultEndorsement
        library:
    validators:
      vscc:
        name: DefaultValidation
        library:
  validatorPoolSize:
  discovery:
    enabled: true
    authCacheEnabled: true
    authCacheMaxSize: 1000
    authCachePurgeRetentionRatio: 0.75
    orgMembersAllowedAccess: false
  limits:
    concurrency:
      endorserService: 2500
      deliverService: 2500
vm:
  endpoint: unix:///var/run/docker.sock
  docker:
    tls:
      enabled: true
      ca:
        file: docker/ca.crt
      cert:
        file: docker/tls.crt
      key:
        file: docker/tls.key
    attachStdout: false
    hostConfig:
      NetworkMode: host
      Dns:
      LogConfig:
        Type: json-file
        Config:
          max-size: "50m"
          max-file: "5"
      Memory: 2147483648
chaincode:
  id:
    path:
    name:
  builder: $(DOCKER_NS)/fabric-ccenv:$(TWO_DIGIT_VERSION)
  pull: false
  golang:
    runtime: $(DOCKER_NS)/fabric-baseos:$(TWO_DIGIT_VERSION)
    dynamicLink: false
  java:
    runtime: $(DOCKER_NS)/fabric-javaenv:$(TWO_DIGIT_VERSION)
  node:
    runtime: $(DOCKER_NS)/fabric-nodeenv:$(TWO_DIGIT_VERSION)
  externalBuilders: []
  installTimeout: 300s
  startuptimeout: 300s
  executetimeout: 30s
  mode: net
  keepalive: 0
  system:
    _lifecycle: enable
    cscc: enable
    lscc: enable
    escc: enable
    vscc: enable
    qscc: enable
  logging:
    level: info
    shim: warning
    format: "%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}"
ledger:
  blockchain:
  state:
    stateDatabase: goleveldb
    totalQueryLimit: 100000
    couchDBConfig:
      couchDBAddress: 127.0.0.1:5984
      username:
      password:
      maxRetries: 3
      maxRetriesOnStartup: 12
      requestTimeout: 35s
      internalQueryLimit: 1000
      maxBatchUpdateSize: 1000
      warmIndexesAfterNBlocks: 1
      createGlobalChangesDB: false
      cacheSize: 64
  history:
    enableHistoryDatabase: true
  pvtdataStore:
    collElgProcMaxDbBatchSize: 5000
    collElgProcDbBatchesInterval: 1000
operations:
  listenAddress: 127.0.0.1:9443
  tls:
    enabled: true
    cert:
      file:
    key:
      file:
    clientAuthRequired: false
    clientRootCAs:
      files: []
metrics:
  provider: disabled
  statsd:
    network: udp
    address: 127.0.0.1:8125
    writeInterval: 10s
    prefix:

orderer.yaml

# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

---
################################################################################
#
#   Orderer Configuration
#
#   - This controls the type and configuration of the orderer.
#
################################################################################
General:
    LedgerType: file
    ListenAddress: 127.0.0.1
    ListenPort: 7050
    TLS:
        Enabled: true
        PrivateKey: tls/server.key
        Certificate: tls/server.crt
        RootCAs:
          - tls/ca.crt
        ClientAuthRequired: false
        ClientRootCAs:
    Keepalive:
        ServerMinInterval: 60s
        ServerInterval: 7200s
        ServerTimeout: 20s
    GenesisMethod: provisional
    GenesisProfile: modbus2chainNetworkProfile
    GenesisFile: genesisblock
    LocalMSPDir: msp
    LocalMSPID: SampleOrg
    Profile:
        Enabled: false
        Address: 0.0.0.0:6060
    BCCSP:
        Default: SW
        SW:
            Hash: SHA2
            Security: 256
            FileKeyStore:
                KeyStore:
    Authentication:
        TimeWindow: 15m


################################################################################
#
#   SECTION: File Ledger
#
#   - This section applies to the configuration of the file or json ledgers.
#
################################################################################
FileLedger:

    # Location: The directory to store the blocks in.
    # NOTE: If this is unset, a new temporary location will be chosen every time
    # the orderer is restarted, using the prefix specified by Prefix.
    Location: /var/hyperledger/production/orderer

    # The prefix to use when generating a ledger directory in temporary space.
    # Otherwise, this value is ignored.
    Prefix: hyperledger-fabric-ordererledger

################################################################################
#
#   SECTION: RAM Ledger
#
#   - This section applies to the configuration of the RAM ledger.
#
################################################################################
RAMLedger:

    # History Size: The number of blocks that the RAM ledger is set to retain.
    # WARNING: Appending a block to the ledger might cause the oldest block in
    # the ledger to be dropped in order to limit the number total number blocks
    # to HistorySize. For example, if history size is 10, when appending block
    # 10, block 0 (the genesis block!) will be dropped to make room for block 10.
    HistorySize: 1000

################################################################################
#
#   SECTION: Kafka
#
#   - This section applies to the configuration of the Kafka-based orderer, and
#     its interaction with the Kafka cluster.
#
################################################################################
Kafka:

    # Retry: What do if a connection to the Kafka cluster cannot be established,
    # or if a metadata request to the Kafka cluster needs to be repeated.
    Retry:
        # When a new channel is created, or when an existing channel is reloaded
        # (in case of a just-restarted orderer), the orderer interacts with the
        # Kafka cluster in the following ways:
        # 1. It creates a Kafka producer (writer) for the Kafka partition that
        # corresponds to the channel.
        # 2. It uses that producer to post a no-op CONNECT message to that
        # partition
        # 3. It creates a Kafka consumer (reader) for that partition.
        # If any of these steps fail, they will be re-attempted every
        # <ShortInterval> for a total of <ShortTotal>, and then every
        # <LongInterval> for a total of <LongTotal> until they succeed.
        # Note that the orderer will be unable to write to or read from a
        # channel until all of the steps above have been completed successfully.
        ShortInterval: 5s
        ShortTotal: 10m
        LongInterval: 5m
        LongTotal: 12h
        # Affects the socket timeouts when waiting for an initial connection, a
        # response, or a transmission. See Config.Net for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        NetworkTimeouts:
            DialTimeout: 10s
            ReadTimeout: 10s
            WriteTimeout: 10s
        # Affects the metadata requests when the Kafka cluster is in the middle
        # of a leader election.See Config.Metadata for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        Metadata:
            RetryBackoff: 250ms
            RetryMax: 3
        # What to do if posting a message to the Kafka cluster fails. See
        # Config.Producer for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        Producer:
            RetryBackoff: 100ms
            RetryMax: 3
        # What to do if reading from the Kafka cluster fails. See
        # Config.Consumer for more info:
        # https://godoc.org/github.com/Shopify/sarama#Config
        Consumer:
            RetryBackoff: 2s

    # Verbose: Enable logging for interactions with the Kafka cluster.
    Verbose: false

    # TLS: TLS settings for the orderer's connection to the Kafka cluster.
    TLS:

      # Enabled: Use TLS when connecting to the Kafka cluster.
      Enabled: false

      # PrivateKey: PEM-encoded private key the orderer will use for
      # authentication.
      PrivateKey:
        # As an alternative to specifying the PrivateKey here, uncomment the
        # following "File" key and specify the file name from which to load the
        # value of PrivateKey.
        #File: path/to/PrivateKey

      # Certificate: PEM-encoded signed public key certificate the orderer will
      # use for authentication.
      Certificate:
        # As an alternative to specifying the Certificate here, uncomment the
        # following "File" key and specify the file name from which to load the
        # value of Certificate.
        #File: path/to/Certificate

      # RootCAs: PEM-encoded trusted root certificates used to validate
      # certificates from the Kafka cluster.
      RootCAs:
        # As an alternative to specifying the RootCAs here, uncomment the
        # following "File" key and specify the file name from which to load the
        # value of RootCAs.
        #File: path/to/RootCAs

    # Kafka protocol version used to communicate with the Kafka cluster brokers
    # (defaults to 0.10.2.0 if not specified)
    Version:

################################################################################
#
#   Debug Configuration
#
#   - This controls the debugging options for the orderer
#
################################################################################
Debug:

    # BroadcastTraceDir when set will cause each request to the Broadcast service
    # for this orderer to be written to a file in this directory
    BroadcastTraceDir:

    # DeliverTraceDir when set will cause each request to the Deliver service
    # for this orderer to be written to a file in this directory
    DeliverTraceDir:
0

There are 0 answers