1

I was following the tutorial at https://developer.ibm.com/tutorials/ibm-blockchain-platform-vscode-smart-contract/ and when I submit a transaction via the IBM blockchain platform VS code extension, I get the error:

"Error submitting transaction: No successful events received".

The function called was 'instantiate' as shown below:

    public async instantiate(ctx: Context): Promise<any> {
        const greeting = { text: 'Instantiate was called!' };
        await ctx.stub.putState('GREETING', Buffer.from(JSON.stringify(greeting)));
    }

Running this will successfully write to the ledger in fact even though an error was thrown. I was able to query the ledger afterwards and saw the right value "{ text: 'Instantiate was called!' }" was returned.

Here's the error trace when I ran the unit test for instantiate. Hope it helps:

     Error: No successful events received
      at AllForTxStrategy.checkCompletion (node_modules/fabric-network/lib/impl/event/allfortxstrategy.js:34:12)
      at AllForTxStrategy.errorReceived (node_modules/fabric-network/lib/impl/event/abstracteventstrategy.js:67:8)
      at TransactionEventHandler._onError (node_modules/fabric-network/lib/impl/event/transactioneventhandler.js:126:17)
      at EventRegistration.eventHub.registerTxEvent [as _onErrorFn] (node_modules/fabric-network/lib/impl/event/transactioneventhandler.js:90:20)
      at EventRegistration.onError (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:1709:9)
      at ChannelEventHub._closeAllCallbacks (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:867:15)
      at ChannelEventHub._disconnect (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:625:8)
      at ClientDuplexStream._stream.on (node_modules/fabric-network/node_modules/fabric-client/lib/ChannelEventHub.js:539:11)
      at addChunk (_stream_readable.js:283:12)
      at readableAddChunk (_stream_readable.js:264:11)
      at ClientDuplexStream.Readable.push (_stream_readable.js:219:10)
      at Object.onReceiveMessage (node_modules/fabric-network/node_modules/grpc/src/client_interceptors.js:1292:19)
      at InterceptingListener.recvMessageWithContext (node_modules/fabric-network/node_modules/grpc/src/client_interceptors.js:607:19)
      at /Users/chana/projects/ibm-bp/node_modules/fabric-network/node_modules/grpc/src/client_interceptors.js:706:14
Aloysius
  • 49
  • 8
  • So it looks like the chaincode instantiated and ran the instantiate transaction. Do you get the same problem if you try to invoke other transactions using VSCode ? (you can even invoke the instantiate transaction again. It is just a normal transaction that can be run again and again and isn't only invocable when you instantiate the contract) – david_k Apr 12 '19 at 16:15
  • Yes. Also the same problem occurs when I re-try Submit Transaction for the instantiate function. Same problem for the other functions which are just really basic. Selecting 'Evaluate Transaction' for `instantiate` doesn't throw the error. Though this means it won't write to the ledger. – Aloysius Apr 13 '19 at 11:15

1 Answers1

4

I noticed a discrepancy in the local fabric output in VS Code after I submitted a transaction:

[4/13/2019 9:41:22 PM] [INFO] fabricvscodelocalfabric_peer0.org1.example.com|2019-04-12 12:17:55.210 UTC [common.deliver] deliverBlocks -> WARN 05a Rejecting deliver for 172.19.0.1:34608 due to envelope validation error: envelope timestamp 2019-04-13 11:41:22.439 +0000 UTC is more than 15m0s apart from current server time 2019-04-12 12:17:55.210409997 +0000 UTC m=+169.648611001

This looked like some sort of time discrepancy on peer0 so I went into its bash and ran date to see the incorrect server time (2019-04-12 12:17:55), then I went about trying correct the server time.

After this, I re-tried Submit Transaction and it worked without throwing the error!

I tried to replicate the original issue again by tearing down fabric then restarting but submit transaction seems to work as expected now.

Aloysius
  • 49
  • 8
  • The issue you described was what I was thinking might be the problem. I am guessing you are running VSCode on either windows or mac ? Then the problem is that the virtual machine (docker on these platforms has to have a virtual machine for linux containers) used to run the various containers has a time discrepency with your host machine and this stops the client from being able to register for events. The events are used to determine when the tx has been committed. It doesn't stop the tx from being commited if valid. – david_k Apr 14 '19 at 11:03
  • Yes I'm running VSCode on mac. Thanks for clarifying @david_k . Appreciate it. – Aloysius Apr 16 '19 at 03:18
  • Hi, I have a similar error and I want to set the peer time. How did you set it? date command results in an error "operation not permitted" – SKuri Aug 29 '19 at 09:15
  • @SKuri Here we will get the UTC date from peer0 then use this to set the UTC date on your local machine. Get date in UTC for setting on another machine `> date -u "+%m%d%H%M%Y"` Set date in UTC on your local machine `> date -u 090509112019` – Aloysius Dec 04 '19 at 23:40