Debugging Composer Transaction processor? - node.js

I've no clue how can I debug the transaction processor in hyperledger composer ..
I did the steps below but there is nothing is showing up:
Start fabric network
Create connection profile
Develop sample application (model.cto, permission.acl, transaction processor or logic.js)
Create business network archive file (.bna)
Deploy .bna file on hyperledger fabric
Finally create the rest server and run our example
But sometimes during testing our contract we need to see some logs related to the contract execution. So we can find if there are any logical issues with the contract. I tried to check docker logs contract_container_id but I didn't find anything.

See this answer here -> Debugging Transaction Code
The correct link in the example is
https://github.com/hyperledger/composer-sample-networks/blob/master/packages/carauction-network/test/CarAuction.js#L31-L49
can use console.log() as normal for messages etc.
See also:
https://hyperledger.github.io/composer/latest/problems/diagnostics

Related

create a Hyperledger Fabric network

Hyperledger Fabric community,
I am a beginner Hyperledger Fabric developer, I have some ambiguities regarding how a Hyperledger Fabric network works and is created.
So what is the use of the fabric-samples network and the test-network or first network and above all, what are the steps to follow to create, configure and launch a Hyperledger Fabric network
I need your help
Go to Getting Started
Use a Mac OS or Ubuntu platform and follow the instructions for installing and running the networks. The test-network example is a great starting point, as it covers all of the basic concepts. There are shell scripts there that will help you to create a new 2 peer network, as well as scripts to help you deploy some chaincode. There are a lot of concepts to learn, but just getting a network up and running and being able to run contract code will be a great start.
After you have got a network up and running, you should look at the shell scripts and see exactly which Hyperledger commands were used to create each artefact.

Block chain data will lose in Hyperleger composer network

I Just create a hyper ledger composer network in production level. There are many data(Participant and asset) is existing in my composer blockchain( That is on CouchDB). My main problem is I need to set up a hyper ledger explorer for my existing network. I already use https://github.com/hyperledger/blockchain-explorer. But the issue is my network orderer port is not synced with explorer( I already post a question regarding this issue Hyperledger explorer starting problem- orderer port communication issue. Unfortunately no replay).
At this moment I decided to stop the running hyper ledger composer network and start again it without any data(participant and asset data) lose. Actually restart the network without data loss is possible...???
Have any other suggestion is available to resolve my issue..???
Any suggestion is much appreciated..
Thank you.
OS: Ubuntu 16.04
Composer: 0.19.16
Fabric: 1.1.0
When you stop your business network using stopFaric.sh under fabric-dev-servers (or fabric-tools). It will stop fabric Containers and after that run startFabric.sh it will recreate new Containers from the Docker Images. Impact of this is that you lose all data(assets, participant, transaction etc) of your business network.
So if you want to stop and start your fabric without loss of existing data. Then follow below commands :
Need to change the directory where the docker-compose.yml(/home/<user>/fabric-dev-servers/fabric-scripts/hlfv11/composer) file is, and
Run docker-compose stop to stop the Fabric then
Run docker-compose start to restart Fabric it will start your network with existing data. Make sure you are in the correct folder.
Hope, it will help you :)

Azure Ethereum(PoW) Blockchain issues

I'm trying to run Ethereum Blockchain network with Azure Blockchain Service but I stuck with some issues.... And below I described one of them.
I will realy apreciate any advice and help from people who alredy has experience with Azure Blockchain Service.
Could you please help me to eliminate this error:
"Error: Contract transaction couldn't be found after 50 blocks"
I create new Ethereum blockchain network and it's working fine approximately 1 day (24 hours) but after this period I'm not able to deploy my smart-contract and getting this error. When I restart my virtual machines (mining and transaction nodes) it's start working for a while but later on it's failing again.
What could be the cause of this error: "Error: Contract transaction couldn't be found after 50 blocks"? I tried increasing gasPrice but it didn't help.
What the recomended server hardware configuration for mining and transaction nodes to run Azure Ethereum Blockchain Service? Maybe my virtual machines run out of the RAM or SSD?
Also could you tell me please where can I see some error log related to my blockchain network in Azure?
Thanks!
Please take a look at this GitHub issue detailed in the Truffle Suite (issue) repository. The issue you are experiencing is cause by Truffle Suite, and can be quickly explained as:
... now believe this may be caused by Infura closing the connection while truffle-hdwallet-provider continues to try to poll them.
Contract transaction couldn't be found after 50 blocks
using infura in truffle and get Error: Invalid JSON RPC response:""
Investigating...

Deploying simpleStorage contract with Kaleido

I have been following this tutorial to connect the consortium i have created using the Kaleido UI to truffle: link . When i finally do : ./truffle_migrate.sh
it gets stuck in there, here is the output:
$ ./truffle_migrate.sh
+ truffle migrate --network supnode --reset Using network 'supnode'.
Running migration: 1_initial_migration.js Saving artifacts... Running
migration: 2_deploy_simplestorage.js Deploying SimpleStorage...
... 0xd6d9cfe1ab5b01abb759fb8280920d8f7ba0cef73340af22e47a9c7e40120c14
I don't understand where is the problem, i'm sure i have followed the tutorial carefully and i ve created the same scenario.. If anyone have any idea i would appreciate it. Thanks.
So I went through step by step in an attempt to recreate your scenario - 3 nodes running Quorum + Raft and a private transaction between nodes 1 & 3.
On the initial migration attempt I came across the same hung state as you observed. Inspection of the block explorer reveals that both contracts were actually deployed, however neither were invoked (i.e. no state was set for simple storage via the migration file).
I then changed the truffle_migrate.sh file to target the original privateFor node (3) and used the original targeted node (1) as the new privateFor recipient. This worked immediately. The question is why :)
Truffle is finicky sometimes, especially when using RAFT with private transactions.
I would suggest:
Check your block explorer to ensure that the connection to the network was successful and the contracts were deployed.
Kill the running migrate process and just kick it off again.
If that doesn't work, try the flip flop process I described.
I'm curious if there is a correlation with targeting the RAFT leader or if perhaps truffle just needs a few extra nudges sometimes. We will investigate.
FYI I tried originally with a public transaction and used a truffle.js file with only a single node. This also worked immediately. So my supposition is there is some nuanced approach for private transactions and RAFT.
In the meantime this should give you a potential workaround; you'll just have the original migration and simple storage contracts as orphans in your environment.

Hyperledger composer got stuck when upgrading the network

Here are the steps that I went through:
Stop and tear down fabric
Start fabric
Create a Business network using yo hyperledger-composer
Create .bna archive and install it
Start network with version 0.0.1
Import card to the playground
All these steps work fine, but when I start playground and try to upgrade business network with my changes, in a browser it gets stuck on
Please Wait: Your new business network is being upgraded
Upgrading business network using PeerAdmin#hlfv1 (2/2)
and never responds
Here what I see in logs of composer--playground:
info: [Hyperledger-Composer] :ConnectionProfileManager :getConnectionManagerByTyp Looking up a connection manager for type 0=hlfv1
Maybe someone has already faced this kind of issue and knows how solve it? Or in the local environment, I should upgrade it manually?
P.S I am new to Composer, so all these steps I found in the
Developer tutorial
The composer network upgrade command and its equivalent action in the Composer Playground generate a new docker "chaincode image" and "chaincode container". Creating the image and starting the container is what takes the time. You will see that you now have redundant docker containers and images of previous versions of the Business Network. This is intended behaviour of Hyperledger Fabric (and Composer) but you may want to do some housekeeping to remove the old versions.
If you are in early versions of development and experimentation - generating lots of versions of Networks, you can use the 'Web Profile' in the Playground which simulates a Fabric in the LocalStorage of the Browser - it is much faster but if you use it be sure to periodically export to a BNA otherwise you might lose work if there is a browser issue or upgrade.
Updated following Comment
The command docker ps can be used to see all running containers (docker ps -a will also show stopped containers.) docker stop is used to stop a container and docker rm to remove the container.
Docker containers are running (or stopped) instances of docker images so you will also want to remove the redundant images. You list the images with docker images and remove them with docker rmi.
The docker web site has a full list of commands.
Interestingly, but the process of upgrading the network took more time than I thought, so the solution will be simple:
Wait 3-4 minutes until the process finishes and do not click anywhere
in the browser (by mistake I tried to reconnect to the card, and in
that case, the process of upgrading fails).
Additionally, important to mention, in the manual process of upgrading of the card(using CLI), it takes the same amount of time

Resources