Anchor peer vs CORE_PEER_GOSSIP_EXTERNALENDPOINT? - hyperledger-fabric

Why should one use Anchor peers when the cross org communication can be acheived by setting CORE_PEER_GOSSIP_EXTERNALENDPOINT in every peer?
Can anyone explain the correct way one should be used?

Let me clearly explains you
In the hyperledger fabric there are total Three Types of peers
Endorsing Peers
Committing Peers
Orderer Peer (Orderer is also a
Peer)
Something Hidden is:
Anchor Peers
Leader Peers
Anchor Peers are for cross-organization peer-to-peer communication, to setup Anchor Peers you need to setup Anchor Peers and use ENV
Step-By-Step
- &org1
Name: org1
ID: org1MSP
MSPDir: ./data/orgs/org1/msp
AnchorPeers:
- Host: org1-peer
- Port: 7051
# generate anchor peer transaction
configtxgen -profile OrgsChannel -outputAnchorPeersUpdate ./crypto-config/org1Anchors.tx -channelID publicchannel -asOrg org1
if [ "$?" -ne 0 ]; then
echo "Failed to generate anchor peer update for maersksea..."
exit 1org1 fi
Now you need to send a transaction inorder to setup Anchor Peers
Check this >> https://hyperledger-fabric.readthedocs.io/en/release-1.1/commands/peerchannel.html#peer-channel-update
If you want to make other peers in your organization known to other organizations, you need to set the
CORE_PEER_GOSSIP_EXTERNALENDPOINT
What They Do:
High-level, peer-to-peer communication happens through gossip protocol and Anchor Peers are the key to gossip communication.
Make sure peers in different organizations know about each other through gossip protocol.
One Can use Private Data Concept using Anchor Peers because gossip distributes the private data peer-to-peer across authorized organizations, it is required to set up anchor peers on the channel
Read below mentioned docs
- https://hyperledger-fabric.readthedocs.io/en/release-1.4/private-data/private-data.html
- https://hyperledger-fabric.readthedocs.io/en/release-1.4/glossary.html
LeaderPeers are the main entry point for orderer to ship blocks to peers
One can set up leader Peers or Peers can elect one by its own
Two Types
Static leader election
Dynamic leader election
Static leader election
Static leader election allows you to manually define one or more peers within an organization as leader peers. Please note, however, that having too many peers connect to the ordering service may result in inefficient use of bandwidth.
export CORE_PEER_GOSSIP_USELEADERELECTION=false
export CORE_PEER_GOSSIP_ORGLEADER=true
Dynamic leader election
Dynamic leader election enables organization peers to elect one peer which will connect to the ordering service and pull out new blocks. This leader is elected for an organization’s peers independently.
export CORE_PEER_GOSSIP_USELEADERELECTION=true
export CORE_PEER_GOSSIP_ORGLEADER=false

Suppose there are 2 orgs in the network A and B. Each org has 2 peers.
ORGA-peer1.orgA, peer2.orgA
ORGB-peer1.orgB, peer2.orgB
Lets say peer1 is anchor peer in both the orgs.
When org A anchor peer(peer1.orgA) communicates with orgB anchor peer(peer1.orgB), then org A anchor peer will tell the org B anchor peer about the CORE_PEER_GOSSIP_EXTERNALENDPOINT of other non anchor peer (peer2.orgA) and vice-versa.
So anchor peer shares the gossip endpoint of non anchor peers. So all the peers in the network know about all the other peers through anchor peers. And then peers can use the CORE_PEER_GOSSIP_EXTERNALENDPOINT of another peer to communicate with that peer.

Related

How to set up non endorsing peers in Hyperledger Fabric 2.2.3

I installed two peers in two different organizations Org1MSP and Org2MSP and installed chaincode on all 4 peers. I did not set signing policy explicitly as it takes "Majority" as implicit signing policy. I am able to get information from all the peers when executed query. Later I added two new peers to each organization and made both of them to join the channel and installed chaincode on both of them. I did not execute approveformyorg now as it was already done in the previous step.
I am using Hyperledger Fabric 2.2.3 version.
Later when I executed
"discover --configFile discovery-conf.yaml endorsers --channel
channelone --server peer0.org1.example.com:7051 --chaincode basic"
I am getting details of all 6 peers of both the organizations. How do I configure non endorsing peers in my set up. I want to have atleast one non endorsing peer in each organization.
Every peer that has joined a channel is a committer on that channel.
If the peer has chaincode installed, it can act as an endorser.
If clients Invoke the installed chaincode on the peer, then it will act as an endorser.

HL Fabric Gossip bootstrap and endpoint for orgs with single peer

This is helpful but not current for HLF 1.4.3.
Hyperledger Fabric GOSSIP_BOOTSTRAP & GOSSIP_EXTERNALENDPOINTS
#GariSingh, #yacovm would you know, if our config consists of 5 orgs, each with a single peer, each with a single CA and one network orderer, would the following be correct for docker-compose-base.yaml?
IOW, is the following correct for GOSSIP for two of the example peers:
CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.org1.example.com:7051
CORE_PEER_GOSSIP_BOOTSTRAP=peer0.org1.example.com:8051
CORE_PEER_GOSSIP_EXTERNALENDPOINT=peer0.orgA.example.com:13051
CORE_PEER_GOSSIP_BOOTSTRAP=peer0.orgA.example.com:14051
Thanks for your help.
#CT99, it's fine, assuming orgA is a second organization
You can have a single peer per organization but it is advisable to have two peers per organization,
reg gossip:
If you use private data concept then it is must else it's optional

Is it possible to have a single peer Org in the network?

I'm setting up a little architecture to test some things with Hyperledger Fabric.
Having 3 Orgs, 2 of which formed by just one peer each (availability not the main concern for the test), I'm getting some warning on gossip: can't establish connection with 0.0.0.0:7051, same for both single peers.
2019-10-02 15:18:49.667 UTC [gossip.discovery] func1 -> WARN 02e Could not
connect to Endpoint: 127.0.0.1:7051, InternalEndpoint: 127.0.0.1:7051,
PKI ID: <nil>, Metadata: : context deadline exceeded
I began to wonder if having just one peer for Org is at least feasable, can't find any example or any guide on how to choose env setting in docker-compose.yaml, or anything that would state that you can't have single peer Orgs.
Any hint?
Thanks
warning on gossip: can't establish connection with 0.0.0.0:7051
Its because you did not update anchor peer transaction, please do update transaction by providing the anchor.tx
check: https://hyperledger-fabric.readthedocs.io/en/release-1.1/glossary.html#anchor-peer
Anchor peers are used to establishing cross-organization communication
Command to generate anchorpeer.tx:
configtxgen -outputAnchorPeersUpdate anchor_peer_tx.pb -profile SampleSingleMSPChannelV1_1 -asOrg Org1
Output a configuration update transaction to anchor_peer_tx.pb which
sets the anchor peers for organization Org1 as defined in profile
SampleSingleMSPChannelV1_1 based on configtx.yaml.

Chaincode Instantiation fails on 3rd peer in BYFN example

I'm testing Hyperledger Fabric network, which is based on the BYFN example (2 Organizations, 2 Peers for each organization, Single orderer, 1 channel, 1 chaincode).
In the default example, they only instantiate chaincode on each anchor peer. What I tried to do is instantiate chaincode on a peer in addition to two anchor peers. So, the chaincode is instantiated on the anchor peer for Org1, the anchor peer for Org2, and the normal peer for Org1. But, everytime I tried, instantiating chaincode for the 3rd peer (no matter what the peer is), it fails.
For example,
* Anchor peer for Org1 (success) -> Normal peer for Org1 (success) -> Anchor peer for Org2 (failed)
* Anchor peer for Org1 (success) -> Anchor peer for Org2 (success) -> Normal peer for Org1 (failed)
Failed error message is "the chaincode is already instantiated", which actually not.
Is there any restriction of the number of chaincode distribution? My endorsement policy is "OR(Org1.member, Org2.member)".
You only instantiate chaincode once per channel not per peer. As long as peers in the channel have the chaincode installed, they will receive the instantiate transaction from the ordering service. The first time the chaincode is invoked on any peers in the channel (which have the chaincode installed), the chaincode will be launched

When adding a new org, do you need to apply the anchors?

I have been following http://hyperledger-fabric.readthedocs.io/en/release-1.1/channel_update_tutorial.html to add a new org to my network, however I noticed something about the anchors that I need clarification.
In the new configtx.yaml file for the new org, there is a part for anchor peers and it is configured for peer0 to be an anchor.
Organizations:
- &Org3
# DefaultOrg defines the organization which is used in the sampleconfig
# of the fabric.git development environment
Name: Org3MSP
# ID to load the MSP definition as
ID: Org3MSP
MSPDir: crypto-config/peerOrganizations/org3.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.org3.example.com
Port: 7051
But the guide never runs the command to create the anchor.tx file.
e.g.
configtxgen -profile TwoOrgsChannel -outputAnchorPeersUpdate ./channel-artifacts/Org3MSPanchors.tx -channelID $CHANNEL_NAME -asOrg Org3MSP
And never runs the CLI container command to add this new anchor
e.g.
peer channel update -o orderer.example.com:7050 -c $CHANNEL_NAME -f ./channel-artifacts/Org3MSPanchors.tx
I continued following the steps and after successfully joining the new org to the channel, I saw in the gossip logs in the peers of the other orgs what appears to be them discovering the new org.
My questions is, does this mean that the anchor peer for the new org configured in the new configtx.yaml file automatically gets added when the new org joined or am I miss reading the logs and I still need to add the anchor for the new org to the channel?
Well, let me clarify. The fact peers are capable to discover new organization, is due to fact that peers of new organization used anchor peers of already available organizations in the channel. Thus in your experiment it appeared that new peers was discovered.
The process work as following, once peer joins the channel it learns available anchor peers and introduces itself to all anchors peers enabling other peers of the organizations to expand membership. To keep this process symmetry it's good practice to have all organization publishing theirs anchors. Therefore despite the fact those steps are missing from documentation I'd advise to follow them and update anchors for new organization as well.

Resources