Coder Social home page Coder Social logo

microgrid's People

Contributors

erickzzh avatar kalleknast avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

liyuan321123

microgrid's Issues

How to change the affiliation?

In registerUser.js, the call to fabric_ca_client.register(...) only seems to work when affiliation is set to 'org1.department1'.
Trying with 'house01' gives an error.

$ node registerUser.js
 Store path:./hfc-key-store
Successfully loaded admin from persistence
Failed to register: Error: fabric-ca request register failed with errors [[{"code":0,"message":"Registration of 'user1' failed in affiliation validation: Failed getting affiliation 'house01': : scode: 404, code: 63, msg: Failed to get Affiliation: sql: no rows in result set"}]]

It seems like the affiliations are hardcoded in /etc/hyperledger/fabric-ca-server/fabric-ca-server-config.yaml in the ca.microgrid.org container.

How to set the affiliations properly?

Instantiating the chaincode fails

Creating channel, joining peer and installing the chaincode works.
But, instantiating the chaincode fails.

The command:

docker exec -e "CORE_PEER_LOCALMSPID=House01MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house01.microgrid.org/users/[email protected]/msp" cli peer chaincode instantiate -o orderer.microgrid.org:7050 -C hachannel -n carecords -l golang -v 1.0 -c '{"Args":[""]}' -P "OR ('House01MSP.member','House02MSP.member')"

and the strange error:

2018-09-29 02:24:30.947 UTC [grpc] HandleSubConnStateChange -> DEBU 075 pickfirstBalancer: HandleSubConnStateChange: 0xc420412ef0, TRANSIENT_FAILURE
Error: could not assemble transaction, err proposal response was not successful, error code 500, msg error starting container: error starting container: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

I did try to stop, remove, and then configure and start the network again, but it didn't help.
Any idea?

Query fails with Error: 2 UNKNOWN: Stream removed

I updated to fabric 1.4 and fixed the "Failed to find private key for certificate..." error that was brought up before. I still haven't fixed the affiliation issue, but its not critical so I put it on hold.

Unfortunately, I cannot query the ledger. I added query.js, a modification of fabcar query.js but it fails with 2019-01-24T15:09:00.316Z - error: [Network]: _initializeInternalChannel: Unable to initialize channel. Attempted to contact 1 Peers. Last error was Error: 2 UNKNOWN: Stream removed. The last error Error: 2 UNKNOWN: Stream removed seems to be a grpc error. I tried running the fabcar example, just the check that there was nothing wrong with my installations in general, but it worked fine.

query.js fails on const network = await gateway.getNetwork('hachannel');, and specifically when it tries to initialize the channel.
I compared the gateway returned by the previous line: await gateway.connect(ccp, { wallet, identity: 'user1', discovery: { enabled: false } }); of fabcar and microgrid and they identical (except where they should be different).

However, I can write and query to the chaincode from the cli.
This works:
TLS_ROOT_CERT_FILES_PEER1=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house01.microgrid.org/peers/peer0.house01.microgrid.org/tls/ca.crt TLS_ROOT_CERT_FILES_PEER2=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house03.microgrid.org/peers/peer0.house03.microgrid.org/tls/ca.crt CA_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/microgrid.org/orderers/orderer.microgrid.org/msp/tlscacerts/tlsca.microgrid.org-cert.pem

peer chaincode invoke -o orderer.microgrid.org:7050 --tls true --cafile $CA_FILE -C $CHANNEL_NAME -n carecords --peerAddresses peer0.house01.microgrid.org:7051 --tlsRootCertFiles $TLS_ROOT_CERT_FILES_PEER1 --peerAddresses peer0.house03.microgrid.org:7051 --tlsRootCertFiles $TLS_ROOT_CERT_FILES_PEER2 -c '{"Args":["appendRecord","House01","2019-01-25 12:03","10"]}'

as does this:
peer chaincode query -C $CHANNEL_NAME -n carecords -c '{"Args": ["getAllRecords"]}'

returning:
[{"Key":"House01", "Record":{"amount":"10","house":"House01","time":"2019-01-25 12:03"}}]

Join a peer to the channel

Join peer0.house01.microgrid.org to the channel (I renamed it to hachannel)

docker exec -e "CORE_PEER_LOCALMSPID=House01MSP" -e "CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house01.microgrid.org/users/[email protected]/msp" peer0.house01.microgrid.org peer channel join -b hachannel.block

ERROR!

2018-09-25 22:32:58.573 UTC [main] InitCmd -> ERRO 001 Cannot run peer because cannot init crypto, folder "/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house01.microgrid.org/users/[email protected]/msp" does not exist

However, if I enter cli, I can cd to the folder, i.e.:

# works fine:
cd /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/house01.microgrid.org/users/[email protected]/msp

hachannel.bloc is located in peer/

root@6197168cb161:/opt/gopath/src/github.com/hyperledger/fabric/peer# ls
channel-artifacts  crypto  hachannel.block

Failed to register user user1: Error: fabric-ca request register failed with error

node registerUser.js
Wallet path: C:\Users\07\OneDrive\Desktop\Final Try\fabcar-blockchain-sample\web-app\server\wallet
Failed to register user user1: Error: fabric-ca request register failed with errors [[{"code":0,"message":"Registration of 'user1' failed in affiliation validation: Failed getting affiliation 'org1.department1': : scode: 404, code: 63, msg: Failed to get Affiliation: sql: no rows in result set"}]]

Failed to register user user1.Failed to get Affiliation.Here, in this I'm following the basic Hyperledger faberic Fabcar tutorial. But I'm geting error as failed to Register user user1.msg: Failed to get Affiliation: sql: no rows in result set". The tutorial which I'm following is, https://github.com/IBM/fabcar-blockchain-sample.

Create a channel

I noticed that your channel wont create maybe try running the following code on the order

docker start cli
docker exec -it cli bash
export CHANNEL_NAME={your channel name}
peer channel create -o orderer.{your network name}:7050 -c $CHANNEL_NAME -f ./channel-artifacts/channel.tx --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/ordererOrganizations/{your 
 networkname}/orderers/orderer.{your networkname}/msp/tlscacerts/tlsca.acme.com-cert.pem

The peer channel create command returns a genesis block which will be used to join the channel. You can check that by running ls command to review that the file {your channel}.block has been created.

screen shot 2018-09-24 at 12 27 46 pm

json.Unmarshal(bidsAsBytes, &bids) error when quering getBidsByRange() from getMCP()

Line 95 in MCP.go (err := json.Unmarshal(bidsAsBytes, &bids)) fails with

Error: endorsement failure during query. response: status:500 message:'Failed to parse bidsAsBytes. Got error: invalid character 'I' looking for beginning of value'

i.e. something is funny with

response := stub.InvokeChaincode("getBidsByRange", invokeArgs, channelID)
bidsAsBytes := response.GetPayload()

I checked the documentation for shim and peer.Response but cannot figure out what is wrong.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.