I run hyperledger fabric network with next configuration:
- 1 fabric-ca
- 1 orderer
- 6 peers
My common connection profile:
name: "Network"
version: "1.0"
channels:
mychannel:
orderers:
- orderer1-org0
peers:
peer1-org0:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer2-org0:
endorsingPeer: false
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer1-org1:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
# discover: true
peer2-org1:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer1-org2:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
peer2-org2:
endorsingPeer: true
chaincodeQuery: true
ledgerQuery: true
eventSource: true
organizations:
org0:
mspid: org0MSP
cryptoPath: path/org0/msp
orderers:
- orderer1-org0
peers:
- peer1-org0
- peer2-org0
certificateAuthorities:
- rca-org1
org1:
mspid: org1MSP
cryptoPath: path/to/org1/msp
peers:
- peer1-org1
- peer2-org1
certificateAuthorities:
- rca-org1
org2:
mspid: org2MSP
cryptoPath: path/to/org2/msp
peers:
- peer1-org2
- peer2-org2
certificateAuthorities:
- rca-org1
orderers:
orderer1-org0:
url: grpc://XXXX:XX
grpcOptions:
grpc.keepalive_time_ms: 600000
grpc-wait-for-ready-timeout: 5000
peers:
peer1-org0:
url: grpc://XXXX:XX
grpcOptions:
grpc.keepalive_time_ms: 600000
grpc-wait-for-ready-timeout: 5000
peer2-org0:
url: grpc://XXXX:XX
grpcOptions:
grpc.keepalive_time_ms: 600000
grpc-wait-for-ready-timeout: 5000
peer1-org1:
url: grpc://XXXX:XX
grpcOptions:
grpc.keepalive_time_ms: 600000
grpc-wait-for-ready-timeout: 5000
peer2-org1:
url: grpc://XXXX:XX
grpcOptions:
grpc.keepalive_time_ms: 600000
grpc-wait-for-ready-timeout: 5000
peer1-org2:
url: grpc://XXXX:XX
grpcOptions:
grpc.keepalive_time_ms: 600000
grpc-wait-for-ready-timeout: 5000
peer2-org2:
url: grpc://XXXX:XX
grpcOptions:
grpc.keepalive_time_ms: 600000
grpc-wait-for-ready-timeout: 5000
certificateAuthorities:
rca-org1:
url: grpc://XXXX:XX
httpOptions:
verify: false
registrar:
- enrollId: XXXX
enrollSecret: XXXX
caName: rca-org1
I try to execute transfer tx from my node.js code:
async function sendTx(email) {
let wallet = await Wallets.newCouchDBWallet("http://XXXX.XXXX");
let couchDBURL = "http://XXXXX";
let stateStore = await new CDBKVS({
url: couchDBURL
});
let configPATH = 'path/to/config.yaml';
let client1 = Client.loadFromConfig(configPATH);
client1.setStateStore(stateStore);
let cryptoSuite = Client.newCryptoSuite();
let cryptoKS = Client.newCryptoKeyStore(CDBKVS, {
url: couchDBURL
});
cryptoSuite.setCryptoKeyStore(cryptoKS);
client1.setCryptoSuite(cryptoSuite);
let connectionProfile = client1._network_config._network_config;
// connect to the network
let gateway = new Gateway();
await gateway.connect(connectionProfile, {
wallet,
identity: email,
discovery: { enabled: false, asLocalhost: false }
});
let network = await gateway.getNetwork('mychannel');
// get contract
let tokenERC20Contract = network.getContract('erc-20');
let clientID = await tokenERC20Contract.evaluateTransaction('ClientAccountID');
console.log('client acc id: ', clientID.toString('ascii'));
let accBalancee = await tokenERC20Contract.evaluateTransaction('BalanceOf', clientID.toString('ascii'));
console.log('acc balance: ', accBalancee.toString('ascii'));
if (accBalancee > 5) {
let transferTx = tokenERC20Contract.createTransaction('Transfer');
let result = await transferTx.submit("XXXX", 1);
console.log('result transfer: ', result);
}
}
peer1-org1 logs:
2022-10-07 09:41:38.219 UTC 0577 WARN [endorser] ProcessProposal -> Failed to invoke chaincode channel=mychannel chaincode=token-erc-20 error="error in simulation: failed to execute transaction XXXX: error sending: txid: XXXX(mychannel) exists"
2022-10-07 09:41:38.217 UTC 0570 INFO [comm.grpc.server] 1 -> unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=10.38.66.18:52088 grpc.code=OK grpc.call_duration=896.107µs
2022-10-07 09:41:38.219 UTC 0578 INFO [comm.grpc.server] 1 -> unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=10.38.66.18:52092 grpc.code=OK grpc.call_duration=771.269µs
2022-10-07 09:41:38.265 UTC 0579 INFO [endorser] callChaincode -> finished chaincode: token-erc-20 duration: 49ms channel=mychannel txID=87af4e13
2022-10-07 09:41:38.266 UTC 057a INFO [comm.grpc.server] 1 -> unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=10.38.66.18:52090 grpc.code=OK grpc.call_duration=50.344009ms
2022-10-07 09:41:38.267 UTC 057b INFO [peer.chaincode.dev-peer1-org1-token-erc-20-1.2] func2 -> 2022/10/07 09:41:38 client XXXX balance updated from 200 to 199
2022-10-07 09:41:38.267 UTC 057c INFO [peer.chaincode.dev-peer1-org1-token-erc-20-1.2] func2 -> 2022/10/07 09:41:38 recipient XXXX balance updated from 0 to 1
2022-10-07 09:41:40.495 UTC 057d INFO [gossip.privdata] StoreBlock -> Received block [30] from buffer channel=mychannel
2022-10-07 09:41:40.496 UTC 057e ERRO [protoutils] ValidateTransaction -> validateEndorserTransaction returns err proposal hash does not match
2022-10-07 09:41:40.496 UTC 057f ERRO [committer.txvalidator] validateTx -> Invalid transaction with index 0
2022-10-07 09:41:40.496 UTC 0580 INFO [committer.txvalidator] Validate -> [mychannel] Validated block [30] in 0ms
2022-10-07 09:41:40.496 UTC 0581 WARN [gossip.privdata] getTxInfoFromTransactionBytes -> Failed obtaining action from envelope: response payload is missing extension
2022-10-07 09:41:40.496 UTC 0582 WARN [validation] preprocessProtoBlock -> Channel [mychannel]: Block [30] Transaction index [0] TxId [XXXX] marked as invalid by committer. Reason code [INVALID_ENDORSER_TRANSACTION]
My transaction executed (peer1-org1 logs printed that balance updated), but I didn't understand, that I receive this logs in my terminal:
client acc id: XXX
acc balance: 200
2022-10-07T09:32:56.095Z - warn: [TransactionEventHandler]: strategyFail: commit failure for transaction "XXXX": TransactionError: Commit of transaction XXXX failed on peer peer1-org1 with status INVALID_ENDORSER_TRANSACTION