2

I am converting a certificate signing request to self signed certificate using hyper ledger chaincode. But while storing information regarding the certificate, transaction is not being successful and it gives me no ledger context error.

Nodejs version : 8.9.4

My chaincode function is:

async registerDomain(ctx, csr) {
let buff = new Buffer(csr, 'base64')
let csrData = buff.toString('ascii')
pem.createPrivateKey(2048, {
    aes128: "11223344"
}, async function (err, pk) {
    let domain = new Domain(ctx, "abcd", "data.detail", "keys.certificate", "pk.key");
    await ctx.stub.putState(domain.domainId, Buffer.from(JSON.stringify(domain)));
});

While transaction this is what I am getting inside peer docker logs:

HandleTransaction -> ERRO 09f [ddc81d1b] Failed to handle PUT_STATE. error: no ledger context runtime.goexit /opt/go/src/runtime/asm_amd64.s:1333 PUT_STATE failed: transaction ID: ddc81d1bcb69eecd6c6bbcf85ba16b2168486d4b232ef3c03fe5bbc7bb2adea1 github.com/hyperledger/fabric/core/chaincode. runtime.goexit

Any help would be much appreciated.

david_k
  • 5,843
  • 2
  • 9
  • 16
  • Hi, Is the issue fixed. Could you please tell me as I'm also stuck with this error for long time? – sasi Jun 30 '20 at 02:57

1 Answers1

1

I have also faced a similar issue. Though there is no any proper solution for this error. As per my understanding, this error is thrown when tx takes more time to complete and lose the context instance provided by state db api's.

In your example, createPrivateKey might be taking more time to generate pk and thus causing "no ledger context" issue.

Reference: https://jira.hyperledger.org/browse/FAB-17512?focusedCommentId=69269&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-69269