CORE_PEER_ADDRESS in chaincode-docker-devmode - hyperledger-fabric

I am following the tutorial Chaincode for Developers and in the section Testing Using dev mode in Terminal 2 there is the following instantiation of the environment variable
CORE_PEER_ADDRESS=peer:7052
Could you please tell me what is the purpose of this variable and why the port of the used peer is 7052?
I couldn't find in the docker-compose file a container running on this port..

Generally,chain code is going to run on containerized environment, but for dev activities like code/test/deploy, we have a sample folder called Chaincode-dev in fabric samples .It is of optimized with limited orderer,peer,cli. Normally we specify chaincode address as 7052,8052,... and chaincode will be maintained by peers (you can check these parameters in docker-composebase.yaml files ),but now here in dev --peer-chaincodedev mode , chaincode is running from user,you check parameters with chaincode won't be present,so these variables are exporting from user.

Related

How to change the block size in Hyper Ledger Fabric 2.X?

I want to adjust the size of newly created blocks. I found that there is AbsoluteMaxBytes in configtx.yaml. However, I do not understand how to change it. I have docker images including peer and orderer. Both peer and orderer I suppose have default values including default value for AbsoluteMaxBytes. Should I rebuild docker images after I change configtx.yaml or should I somehow modify AbsoluteMaxBytes inside running container?
What is the procedure?
This requires a channel config update to be done.
Please refer here:
https://hyperledger-fabric.readthedocs.io/en/release-2.2/config_update.html?highlight=channel%20config%20update

Can we find the endorser details in smart contract during execution(Hyperledger Fabric)?

Can we find the endorser details in smart contract during execution(Hyperledger Fabric) ?
Check out the below link, by using this library you access MSPid, fabric-ca certificate details inside the chaincode
https://github.com/hyperledger/fabric-chaincode-go/blob/main/pkg/cid/README.md
https://hyperledger-fabric.readthedocs.io/en/release-2.2/endorsement-policies.html
https://github.com/hyperledger/fabric-samples/blob/main/asset-transfer-secured-agreement/chaincode-go/asset_transfer.go
If you use the internal docker build mechanism then the only thing available to chaincode is CORE_PEER_LOCALMSPID
I've not tried but if you use an external builder you could add more information yourself during the run part see https://hyperledger-fabric.readthedocs.io/en/release-2.2/cc_launcher.html?highlight=builder#external-builder-and-launcher-api
and if you use chaincode as a service then it may be possible for you to bake something into the image you use in different orgs

Feasibility of Dynamically setting Environment Variables in Hyperledger Fabric

Can we dynamically change the Hyperledger environment variables that we are setting before setting up the HyperLedger components during the run time. For instance, if we need to change the FABRIC_LOGGING_SPEC from debug to info during the Orderer or PEER runtime with or without docker image, is it possible?
Yes, The peer logging can dynamically changed using the cli docker access.
There are certain helpful commands that will guide you the usage like
To get the log level for logger peer:
peer logging getlevel peer
To get the active logging spec for the peer:
peer logging getlogspec
To set the log level for loggers matching logger name prefix gossip to log level INFO:
peer logging setlevel gossip info
To revert the logging spec to the start-up value:
peer logging revertlevels
Get a more detailed explanation and usage on docs.
I was trying to achieve the same in past once. But found out after you create a docker container using the service mentioned in yaml file, one can't modify the env parameters. Using 'export' you can change it but only as long as you are bashed in that container. Once you bash out of that container, the old default value will set in. One solution to it can be, spin a new container with desired env parameters. And port all the data from old container to new container. Also required updates to config blocks of the channel.

Hyperledger Composer: command "composer network start" failing with "Error: REQUEST_TIMEOUT"

Suddenly I cannot start my hyperledger composer business network any more ...
composer network start --networkName my-network --networkVersion 0.0.45 --card PeerAdmin#hlfv1 --networkAdmin admin --networkAdminEnrollSecret adminpw
is giving me the following error message:
Starting business network definition. This may take a minute...
Error: Error trying to start business network. Error: No valid responses from any peers.
Response from attempted peer comms was an error: Error: REQUEST_TIMEOUT
I reset docker to factory settings ... but the problem remains.
Does anybody have any idea what is going on here?
Request timeout can have 2 main reasons
1. There is some code in your logic.js, permission.acl or query that is taking too long to resolve , look for any infinite loops or Dynamic queries or any complex permission that you have added.
Resolution: If you have some previous version which was working try on that slowly bring in your changes to check if any of your changes have caused the network start to run for long.
Alternatively you can also look into the docker logs which is created when you fire network start command and there are chances you found your issue there.
In case you are using some VM or low performance machine , there could be also be chances that load of your machine to too much and it is not able to handle so much processing collectively.
Resolution : Check for any previous docker container or memory extensive processes to make sure there is enough hardware to complete the task in time bound manner.

Extra dev peers in hyperledger fabric

I am following the two org hyperledger fabric example. After starting the network I can see 4 extra dev peers running along with 4 peers(2 peers per org) in docker containers. But in configuration I gave only 4 peers. I am not understanding how the other 4 dev peers got created and whats their purpose.
A specific 'Chain Code Container' gets created for each peer running the Business Network. E.g. dev-peer0.org1.example.com-tutorial-network-0.16.3.... These containers are started and restarted automatically.
Chaincodes are instantiated in a separate container. When you instantiate a chaincode in a peer ,container for that chaincode is created.
If you instantiate 3 chaincode in a peer0 then you will see 3 containers with name like dev-peer0.mycc1, dev-peer0.mycc2,dev-peer0.mycc3
More details about this process can be found in an offical document mentioned below.(search text "dev-peer")
https://github.com/hyperledger/fabric/blob/release-1.4/docs/source/build_network.rst

Resources