Does hyperledger fabric smartcontract support more than one go file - hyperledger-fabric

Does hyperledger fabric smartcontract support more than one go file?
for example, the go file is too large, so splited into several files.
If support ,how to submit the smartcontract?

Yes. Chaincode is just like a normal go project. You just need to pass the chaincode path to the folder where you locate the main package files
Example:
mycc_folder
____ go.mod
____ main_package_folder
____ ____ main.go
____ ____ something_else.go
____ support_package_folder
____ ____ common.go
____ ____ utils.go
./bin/peer lifecycle chaincode package mycc.tar.gz --path $path_to_mycc_folder/main_package_folder --lang golang --label mycc

Related

Installing Self Hosted Linux Agent for Azure devops Server

Hello Cloud Engineers,
I am trying to create a self hosted agent in azure to run by build and release pipeline.
When i am configuring the linux VM as a agent, i am getting below error.
--------OS Information--------
NAME="SLES"
VERSION="15-SP2"
PRETTY_NAME="SUSE Linux Enterprise Server 15 SP2"
___ ______ _ _ _
/ _ \ | ___ (_) | (_)
/ /_\ \_____ _ _ __ ___ | |_/ /_ _ __ ___| |_ _ __ ___ ___
| _ |_ / | | | '__/ _ \ | __/| | '_ \ / _ \ | | '_ \ / _ \/ __|
| | | |/ /| |_| | | | __/ | | | | |_) | __/ | | | | | __/\__ \
\_| |_/___|\__,_|_| \___| \_| |_| .__/ \___|_|_|_| |_|\___||___/
| |
agent v2.183.1 |_| (commit b8617e6)
>> End User License Agreements:
Building sources from a TFVC repository requires accepting the Team Explorer Everywhere End User License Agreement. This step is not required for building sources from Git repositories.
A copy of the Team Explorer Everywhere license agreement can be found at:
/home/selfhosted-linuxagent/externals/tee/license.html
Enter (Y/N) Accept the Team Explorer Everywhere license agreement now? (press enter for N) > y
>> Connect:
Enter server URL > https://hello.world.com/
Enter authentication type (press enter for PAT) >
Enter personal access token > *****************
Error reported in diagnostic logs. Please examine the log for more details.
- /home/selfhosted-linuxagent/_diag/Agent_20210308-094413-utc.log
The SSL connection could not be established, see inner exception.
Failed to connect. Try again or ctrl-c to quit
Enter server URL >
The error may indicate the server certificate you used on your TFS server is not trusted by the build machine. Make sure you install your self-signed ssl server certificate into the OS certificate store.
Windows: Windows certificate store
Linux: OpenSSL certificate store
macOS: OpenSSL certificate store for agent version 2.124.0 or below
Keychain for agent version 2.125.0 or above
You can easily verify whether the certificate has been installed correctly by running few commands. You should be good as long as SSL handshake finished correctly even you get a 401 for the request.
Windows: PowerShell Invoke-WebRequest -Uri https://corp.tfs.com/tfs -UseDefaultCredentials
Linux: curl -v https://corp.tfs.com/tfs
macOS: curl -v https://corp.tfs.com/tfs (agent version 2.124.0 or below, curl needs to be built for OpenSSL)
curl -v https://corp.tfs.com/tfs (agent version 2.125.0 or above, curl needs to be built for Secure Transport)
Check the following documentation for more details:
https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/certificate?view=azure-devops-2020

How do I troubleshoot Azure Linux App Service when logs are not including error messages

I have deployed an Azure Linux App Service that runs a NodeJS app with LoopBack 4 framework for quite some time now, but since last week or so, I'm having troubles deploying a new version of the application using Azure DevOps.
Last week when an app was deployed, it took several restarts for the app to be started. Since yesterday it took around 7 hours before the application was available and today (at the time of writing) it's taking 3 hours.
This is currently only in my development environment (prod will be deployed only on pull request), but I think that the same will happen to my production environment when I deploy a new version for that. Unfortunately, I can't try this at this time.
When I open the log stream, I don't see any errors beside that it Waiting for response to warmup request for container.
I don't know if it can have something to do with a timeout for starting the application, since I'm getting that error message in the "Diagnose & solve problems" screen, but when I run my application om my development machine, it boots in less than 5 seconds.
I tried settings the WEBSITES_CONTAINER_START_TIME_LIMIT setting to 1800 via:
portal > app service > Configuration > Application settings
DevOps job for settings app settings
But this doesn't have the desired result as I'm still seeing the Waiting for response to warup request for container message.
In the "Diagnose & Solve problems" screen in the Azure portal, I also have an error for container crash. I would expect that I would see some kind of error as for why it fails, but all I see is the following output:
Container qusito-core-dev_0_fdc9a431 couldn't be started: Logs = 2020-09-11T13:43:59.410899652Z _____
2020-09-11T13:43:59.410934153Z / _ \ __________ _________ ____
2020-09-11T13:43:59.410938953Z / /_\ \___ / | \_ __ \_/ __ \
2020-09-11T13:43:59.410942753Z / | \/ /| | /| | \/\ ___/
2020-09-11T13:43:59.410946453Z \____|__ /_____ \____/ |__| \___ >
2020-09-11T13:43:59.410950153Z \/ \/ \/
2020-09-11T13:43:59.410953753Z A P P S E R V I C E O N L I N U X
2020-09-11T13:43:59.410957153Z
2020-09-11T13:43:59.410960353Z Documentation: http://aka.ms/webapp-linux
2020-09-11T13:43:59.410963553Z NodeJS quickstart: https://aka.ms/node-qs
2020-09-11T13:43:59.410966853Z NodeJS Version : v10.14.2
2020-09-11T13:43:59.410970153Z Note: Any data outside '/home' is not persisted
2020-09-11T13:43:59.410973453Z
2020-09-11T13:44:00.211504840Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-09-11T13:44:00.211887043Z Could not find operation ID in manifest. Generating an operation id...
2020-09-11T13:44:00.211897743Z Build Operation ID: 7cf16daf-ccef-4ad1-b496-50778dafc913
2020-09-11T13:44:02.114481171Z Writing output script to '/opt/startup/startup.sh'
2020-09-11T13:44:02.490713708Z Running #!/bin/sh
2020-09-11T13:44:02.491320612Z
2020-09-11T13:44:02.491332412Z # Enter the source directory to make sure the script runs where the user expects
2020-09-11T13:44:02.491336512Z cd "/home/site/wwwroot"
2020-09-11T13:44:02.491340212Z
2020-09-11T13:44:02.491344012Z export NODE_PATH=$(npm root --quiet -g):$NODE_PATH
2020-09-11T13:44:02.491347512Z if [ -z "$PORT" ]; then
2020-09-11T13:44:02.493136724Z export PORT=8080
2020-09-11T13:44:02.493148924Z fi
2020-09-11T13:44:02.493152724Z
2020-09-11T13:44:02.493341325Z PATH="$PATH:/home/site/wwwroot" npm run start
2020-09-11T13:44:06.600726640Z npm info it worked if it ends with ok
2020-09-11T13:44:06.600776740Z npm info using npm#6.9.0
2020-09-11T13:44:06.600875440Z npm info using node#v10.14.2
2020-09-11T13:44:06.868226973Z npm info lifecycle core#1.0.0~prestart: core#1.0.0
2020-09-11T13:44:06.885230583Z
2020-09-11T13:44:06.885248883Z > core#1.0.0 prestart /home/site/wwwroot
2020-09-11T13:44:06.885253583Z > npm run build
2020-09-11T13:44:06.885264583Z
2020-09-11T13:44:07.662776822Z npm info it worked if it ends with ok
2020-09-11T13:44:07.663855429Z npm info using npm#6.9.0
2020-09-11T13:44:07.664656534Z npm info using node#v10.14.2
2020-09-11T13:44:07.823510864Z npm info lifecycle core#1.0.0~prebuild: core#1.0.0
2020-09-11T13:44:07.824905373Z npm info lifecycle core#1.0.0~build: core#1.0.0
2020-09-11T13:44:07.835657242Z
2020-09-11T13:44:07.835673743Z > core#1.0.0 build /home/site/wwwroot
2020-09-11T13:44:07.835678743Z > lb-tsc
2020-09-11T13:44:07.835682343Z
At this time I'm stuck with this issue. I saw a reference somewhere on SO that logging in Linux is not completely supported in the log stream (in Azure portal), but I don't know where to find any other logs.
Any help on how I should move forward is appreciated.
You can manage your App Service through Console or Kudu in Advanced Tools.
As it turn out, I had a typo in my settings: WEBSITE_CONTAINER_START_TIME_LIMIT (Forgot the “S” after WEBSITE).
After chaning this, I didn’t had any problem on deploying. I also noged that the lb-tsc command takes around 5-6 minutes when running. This is what probably went wrong when deploying.

How to enable private data in fabric v1.3.0

I am using fabric 1.3.0 in docker environment. I am getting error while trying to instantiate the chaincode with --collections-config. The setup is working fine if I remove the --collections-config
While executing :
peer chaincode instantiate -C org12 -n tranargy -v 1.0 -c '{"Args":[]}' -P "OR('Org1MSP.member','Org2MSP.member')" --collections-config /opt/gopath/src/tranargy/collections/collections_config.json
Getting following error :
Error: could not assemble transaction, err Proposal response was not
successful, error code 500, msg as V1_2 or later capability is not
enabled, private channel collections and data are not available
Can any one help in how to enable private data in fabric v1.3.0.
You must enable the V1_3 capability when creating the channel configuration transaction. See the required configuration in the sample. This is required so that all peers on a channel behave consistently, even if a rolling upgrade is in progress for the peers in the channel.
Problem is you are not using fabric 1.3.0 docker image
Even though it is present in your local, when you do compose up at that time it will download a new image of different version
Make sure
hyperledger/fabric-peer 1.2.0 82c262e65984 3 months ago 159MB
compose file service image: hyperledger/fabric-ca-peer:1.2.0
Both versions are same here i used 1.2.0
In your case 1.3.0
Make Sure:
Application: &ApplicationCapabilities
V1_3: true
See configtx.yaml

"channel [{channel-name}]: MSP error: channel doesn't exist" warning fails the instantiation of chaincode on Hyperledger Fabric

I'm trying to run the Hyperledger Fabric network, which consists of a single orderer, a single peer, and a cli. To learn the procedure of launching Hyperledger Fabric network, from creating crypto-related artifacts to running cli as a docker container, I execute them one by one.
Everything is okay, but when I try to instantiate the installed chaincode, the peer produces channel [reputationch]: MSP error: channel doesn't exist (reputationch is my channel name) and the instantiation has been failed.
(Check the below screenshot)
I'm not sure that this warning on the peer node causes the failure of the instantiation of chaincode, but I guess it is the reason.
My crypto-config.yaml and configtx.yaml are like below. They are nothing special because I just modified some names based on the official example.
crytp-config.yaml and configtx.yaml
And the script to create crypto-related artifacts based on the above yaml files is:
script to create crypto-related artifacts
My running scripts to launch an orderer, a peer, and a cli are like below. It calls docker commands.
running scripts to launch an orderer, a peer, and a cli
After I launch a cli, I connect the cli using docker exec -it cli bash. Then, I run three commands, which work well without an error or a warning:
peer channel create -o orderer.operator.com:7050 -c reputationch -f ./channel-artifacts/reputation-channel.tx
peer channel update -o orderer.operator.com:7050 -c reputationch -f ./channel-artifacts/Company1anchors.tx
peer chaincode install -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/
Then, the following command is failed.
peer chaincode instantiate -o orderer.operator.com:7050 -C reputationch -n mycc -v 1.0 -c '{"Args":["init","a", "100", "b","200"]}' -P "OR ('Company1MSP.peer')"
My version information is:
macOS: macOS High Sierra 10.13.3
Go: 1.10
Docker: Version 18.03.0-ce-mac59 (23608)
Hyperledger Fabric: 1.1
cryptogen: 1.1.0
configtxgen: 1.1.0
Any kind of comment or help will be very great for me. Thanks.
Basically you also need your peers to join your channels. Which it seems like you are not doing here. If your peers do not join any channel, you will be getting this error. Make sure that your peers join channel before installing chaincode.
peer channel join -b $CHANNEL_NAME.block

Query result on peer1.org2 is INVALID

All of a sudden latest version 1.1.0-alpha, started throwing errors in bring the Hyperledger Fabric Samples - first-network, while running ./byfc.sh -m up
2018-02-20 10:40:29.991 UTC [main] main -> INFO 008 Exiting.....
!!!!!!!!!!!!!!! Query result on peer1.org2 is INVALID !!!!!!!!!!!!!!!!
================== ERROR !!! FAILED to execute End-2-End Scenario ==================
ERROR !!!! Test failed
Need help.. How to debug?
Updates
I had everything running using Fabric 1.1.0-alpha, when I tried sometime after Jan 26. Recently I wanted to try adding a new org to the network. So thought of re-doing from scratch, but now it's failing. Not able to proceed, which I had done it earlier, couple of times. Not sure what is wrong since yesterday, with latest fabric samples...
Cloned the source from master branch.
Docker version 17.12.0-ce, build c97c6d6
Node version v8.9.4
NPM version 5.6.0
cryptogen version 1.1.0-alpha
configtxlator version 1.1.0-alpha
Removed old binaries (/bin folder) and docker containers and images, to start from scratch, but no luck:
./byfn.sh -m down
docker rm -f $(docker ps -aq)
docker rmi -f $(docker images -q)
docker network prune
I tried running ./byfn.sh, using -m, also without, Same result.
./byfn.sh generate
./byfn.sh up
And,
./byfn.sh -m generate
./byfn.sh -m up
Did you checkout the right fabric-samples repo tag that matches the binaries version? The documentation for this was just updated serveral hours ago, so if you were referring to an earlier version of the documentation you might want to refresh:
https://hyperledger-fabric.readthedocs.io/en/latest/samples.html#download-platform-specific-binaries
Make sure you Checkout to the right tag. eg: after you clone, then cd to that folder, finally you git git checkout v1.1.0-alpha
then when running the byfn.sh script, you might need to use the -m option, e.g. `./byfn.sh -m generate
With v1.1.0-rc1, I am able to execute the first-network successfully.
===================== Query on peer1.org2 on channel 'mychannel' is successful =====================
========= All GOOD, BYFN execution completed ===========
_____ _ _ ____
| ____| | \ | | | _ \
| _| | \| | | | | |
| |___ | |\ | | |_| |
|_____| |_| \_| |____/
I suspect, the error which I faced previously with v1.1.0-alpha, was just due to missing instruction in the tutorial, i.e., git checkout {TAG}. Now this has been updated correctly in the tutorial.
I was facing similar error with Release 1.4.1
100
!!!!!!!!!!!!!!! Query result on peer1.org2 is INVALID !!!!!!!!!!!!!!!!
================== ERROR !!! FAILED to execute End-2-End Scenario ==================
ERROR !!!! Test failed
I resolved it by following steps:
Removed fabric-samples directory
Run command in hyperledger directory
curl -sSL https://raw.githubusercontent.com/hyperledger/fabric/master/scripts/bootstrap.sh | bash -s -- 1.4.1 1.4.1 0.4.15
./byfn.sh up -l node
It is working fine.
90
===================== Query successful on peer1.org2 on channel 'mychannel' =====================
========= All GOOD, BYFN execution completed ===========

Resources