Skip to content

Commit

Permalink
Network CAs Initilization
Browse files Browse the repository at this point in the history
  • Loading branch information
adityanithariya committed Sep 29, 2024
1 parent 2b5f5ee commit de02b9f
Show file tree
Hide file tree
Showing 28 changed files with 2,521 additions and 10 deletions.
2 changes: 2 additions & 0 deletions hyperledger/network/cryptogen/init.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

generateCryptoMaterial() {
echo "Generating crypto material"

Expand Down
11 changes: 11 additions & 0 deletions hyperledger/network/init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/bash

# chmod +x network.sh

export PATH=${PWD}/../bin:${PWD}/../../bin:${PWD}/scripts:$PATH
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

nvm install 18.17.0
nvm use 18.17.0
npm i -g yarn

if ! command -v cryptogen >/dev/null 2>&1; then
echo "bin not found!"
Expand Down
2 changes: 2 additions & 0 deletions hyperledger/network/network.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

chmod +x ./init.sh
. init.sh

Expand Down
12 changes: 7 additions & 5 deletions hyperledger/network/scripts/createChannel.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

if [ $# -lt 1 -o $1 == "-h" ]; then
echo "Usage: ./createChannel.sh <create|join|update|all> [-org1 <domain> <mspID> <port>] [-org2 <domain> <mspID> <port>] [-ch <channelName>] [-p <profile>]"
exit 1
Expand Down Expand Up @@ -73,8 +75,8 @@ generateCCP() {
fi
}

chmod +x ./init.sh
. init.sh
# chmod +x ./init.sh
# . init.sh

if [ "$COMMAND" == "create" ]; then
createChannel
Expand All @@ -84,10 +86,10 @@ elif [ "$COMMAND" == "update" ]; then
updateAnchorPeers
elif [ "$COMMAND" == "all" ]; then
generateCCP
sleep 5
sleep 30
createChannel
sleep 10
sleep 20
joinChannel
sleep 5
sleep 20
updateAnchorPeers
fi
2 changes: 2 additions & 0 deletions hyperledger/network/scripts/deployCC.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

if [ -z "$1" ]; then
echo -e "Usage: ./deployChaincode.sh -lang <language> -v <version> -src <path> -name <name>"
exit 1
Expand Down
4 changes: 4 additions & 0 deletions hyperledger/network/scripts/initVars.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

export COMMAND="$1"

if [[ $COMMAND != -* ]]; then
Expand Down Expand Up @@ -89,6 +91,7 @@ setGlobalsForPeer0Org1(){
export CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG1_CA
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/${ORG1_DOMAIN}/users/Admin@${ORG1_DOMAIN}/msp
export CORE_PEER_ADDRESS=localhost:${ORG1_PORT}
export FABRIC_CFG_PATH=${PWD}/config/
if [[ $1 == true ]]; then
export ORG=$ORG1
export ORG_DOMAIN=$ORG1_DOMAIN
Expand All @@ -104,6 +107,7 @@ setGlobalsForPeer0Org2(){
export CORE_PEER_TLS_ROOTCERT_FILE=$PEER0_ORG2_CA
export CORE_PEER_MSPCONFIGPATH=${PWD}/organizations/peerOrganizations/${ORG2_DOMAIN}/users/Admin@${ORG2_DOMAIN}/msp
export CORE_PEER_ADDRESS=localhost:${ORG2_PORT}
export FABRIC_CFG_PATH=${PWD}/config/
if [[ $1 == true ]]; then
export ORG=$ORG2
export ORG_DOMAIN=$ORG2_DOMAIN
Expand Down
2 changes: 2 additions & 0 deletions hyperledger/network/scripts/utils.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

function one_line_pem {
echo "`awk 'NF {sub(/\\n/, ""); printf "%s\\\\\\\n",$0;}' $1`"
}
Expand Down
8 changes: 8 additions & 0 deletions hyperledger/singleton-network/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
organizations/ordererOrganizations/*
organizations/peerOrganizations/*
*.pb
*.tx
*.log
*.tar.gz
./configtx.yaml
organizations/fabric-ca/*
20 changes: 20 additions & 0 deletions hyperledger/singleton-network/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '2'
services:
peer-base:
image: hyperledger/fabric-peer
environment:
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- CORE_VM_DOCKER_HOSTCONFIG_NETWORKMODE=artifacts_default
- CORE_LOGGING_LEVEL=INFO
- CORE_PEER_GOSSIP_USELEADERELECTION=true
- CORE_PEER_GOSSIP_ORGLEADER=false
- CORE_PEER_GOSSIP_SKIPHANDSHAKE=true
- CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/crypto/peer/msp
- CORE_PEER_TLS_ENABLED=true
- CORE_PEER_TLS_KEY_FILE=/etc/hyperledger/crypto/peer/tls/server.key
- CORE_PEER_TLS_CERT_FILE=/etc/hyperledger/crypto/peer/tls/server.crt
- CORE_PEER_TLS_ROOTCERT_FILE=/etc/hyperledger/crypto/peer/tls/ca.crt
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: peer node start
volumes:
- /var/run/:/host/var/run/
255 changes: 255 additions & 0 deletions hyperledger/singleton-network/config/configtx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,255 @@
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

---
################################################################################
#
# Section: Organizations
#
# - This section defines the different organizational identities which will
# be referenced later in the configuration.
#
################################################################################
Organizations:
- &OrdererOrg
# SampleOrg defines an MSP using the sampleconfig. It should never be used
# in production but may be used as a template for other definitions
# 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: ../organizations/ordererOrganizations/judicature.com/msp
# Policies defines the set of policies at this level of the config tree
# For organization policies, their canonical path is usually
# /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
Policies:
Readers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Writers:
Type: Signature
Rule: "OR('OrdererMSP.member')"
Admins:
Type: Signature
Rule: "OR('OrdererMSP.admin')"
OrdererEndpoints:
- orderer.judicature.com:7050
- &Judicature
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: JudicatureMSP
# ID to load the MSP definition as
ID: Judicature
MSPDir: ../organizations/peerOrganizations/judicature.com/msp
# Policies defines the set of policies at this level of the config tree
# For organization policies, their canonical path is usually
# /Channel/<Application|Orderer>/<OrgName>/<PolicyName>
Policies:
Readers:
Type: Signature
Rule: "OR('Judicature.admin', 'Judicature.peer', 'Judicature.client')"
Writers:
Type: Signature
Rule: "OR('Judicature.admin', 'Judicature.client')"
Admins:
Type: Signature
Rule: "OR('Judicature.admin')"
Endorsement:
Type: Signature
Rule: "OR('Judicature.peer')"
################################################################################
#
# SECTION: Capabilities
#
# - This section defines the capabilities of fabric network. This is a new
# concept as of v1.1.0 and should not be utilized in mixed networks with
# v1.0.x peers and orderers. Capabilities define features which must be
# present in a fabric binary for that binary to safely participate in the
# fabric network. For instance, if a new MSP type is added, newer binaries
# might recognize and validate the signatures from this type, while older
# binaries without this support would be unable to validate those
# transactions. This could lead to different versions of the fabric binaries
# having different world states. Instead, defining a capability for a channel
# informs those binaries without this capability that they must cease
# processing transactions until they have been upgraded. For v1.0.x if any
# capabilities are defined (including a map with all capabilities turned off)
# then the v1.0.x peer will deliberately crash.
#
################################################################################
Capabilities:
# Channel capabilities apply to both the orderers and the peers and must be
# supported by both.
# Set the value of the capability to true to require it.
Channel: &ChannelCapabilities
# V2_0 capability ensures that orderers and peers behave according
# to v2.0 channel capabilities. Orderers and peers from
# prior releases would behave in an incompatible way, and are therefore
# not able to participate in channels at v2.0 capability.
# Prior to enabling V2.0 channel capabilities, ensure that all
# orderers and peers on a channel are at v2.0.0 or later.
V2_0: true
# Orderer capabilities apply only to the orderers, and may be safely
# used with prior release peers.
# Set the value of the capability to true to require it.
Orderer: &OrdererCapabilities
# V2_0 orderer capability ensures that orderers behave according
# to v2.0 orderer capabilities. Orderers from
# prior releases would behave in an incompatible way, and are therefore
# not able to participate in channels at v2.0 orderer capability.
# Prior to enabling V2.0 orderer capabilities, ensure that all
# orderers on channel are at v2.0.0 or later.
V2_0: true
# Application capabilities apply only to the peer network, and may be safely
# used with prior release orderers.
# Set the value of the capability to true to require it.
Application: &ApplicationCapabilities
# V2.5 for Application enables the new non-backwards compatible
# features of fabric v2.5, namely the ability to purge private data.
# Prior to enabling V2.5 application capabilities, ensure that all
# peers on a channel are at v2.5.0 or later.
V2_5: true
################################################################################
#
# SECTION: Application
#
# - This section defines the values to encode into a config transaction or
# genesis block for application related parameters
#
################################################################################
Application: &ApplicationDefaults
# Organizations is the list of orgs which are defined as participants on
# the application side of the network
Organizations:
# Policies defines the set of policies at this level of the config tree
# For Application policies, their canonical path is
# /Channel/Application/<PolicyName>
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
################################################################################
#
# SECTION: Orderer
#
# - This section defines the values to encode into a config transaction or
# genesis block for orderer related parameters
#
################################################################################
Orderer: &OrdererDefaults
# Addresses used to be the list of orderer addresses that clients and peers
# could connect to. However, this does not allow clients to associate orderer
# addresses and orderer organizations which can be useful for things such
# as TLS validation. The preferred way to specify orderer addresses is now
# to include the OrdererEndpoints item in your org definition
Addresses:
- orderer.judicature.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
# Organizations is the list of orgs which are defined as participants on
# the orderer side of the network
Organizations:
# Policies defines the set of policies at this level of the config tree
# For Orderer policies, their canonical path is
# /Channel/Orderer/<PolicyName>
Policies:
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
# BlockValidation specifies what signatures must be included in the block
# from the orderer for the peer to validate it.
BlockValidation:
Type: ImplicitMeta
Rule: "ANY Writers"
################################################################################
#
# CHANNEL
#
# This section defines the values to encode into a config transaction or
# genesis block for channel related parameters.
#
################################################################################
Channel: &ChannelDefaults
# Policies defines the set of policies at this level of the config tree
# For Channel policies, their canonical path is
# /Channel/<PolicyName>
Policies:
# Who may invoke the 'Deliver' API
Readers:
Type: ImplicitMeta
Rule: "ANY Readers"
# Who may invoke the 'Broadcast' API
Writers:
Type: ImplicitMeta
Rule: "ANY Writers"
# By default, who may modify elements at this config level
Admins:
Type: ImplicitMeta
Rule: "MAJORITY Admins"
# Capabilities describes the channel level capabilities, see the
# dedicated Capabilities section elsewhere in this file for a full
# description
Capabilities:
<<: *ChannelCapabilities
################################################################################
#
# Profile
#
# - Different configuration profiles may be encoded here to be specified
# as parameters to the configtxgen tool
#
################################################################################
Profiles:
ChannelUsingRaft:
<<: *ChannelDefaults
Orderer:
<<: *OrdererDefaults
OrdererType: etcdraft
EtcdRaft:
Consenters:
- Host: orderer.judicature.com
Port: 7050
ClientTLSCert: ../organizations/ordererOrganizations/judicature.com/orderers/orderer.judicature.com/tls/server.crt
ServerTLSCert: ../organizations/ordererOrganizations/judicature.com/orderers/orderer.judicature.com/tls/server.crt
Organizations:
- *OrdererOrg
Capabilities: *OrdererCapabilities
Application:
<<: *ApplicationDefaults
Organizations:
- *Judicature
Capabilities: *ApplicationCapabilities
Loading

0 comments on commit de02b9f

Please sign in to comment.