"Minimum memory limit allowed is 4MB" 链码实例化失败

"Minimum memory limit allowed is 4MB" failure during the chaincode instantiation

在每个节点上成功安装链代码后,实例化链代码失败,因为 "Minimum memory limit allowed is 4MB" 错误。

在订购者上,它打印:

Error: Error endorsing chaincode: rpc error: code = Unknown desc = Error starting container: API error (400): {"message":"Minimum memory limit allowed is 4MB"}

然后,在对等节点上,它打印:

2018-07-10 08:02:35.893 UTC [dockercontroller] Start -> ERRO 610 start-could not recreate container <10.11.1.121-10.11.1.121-mycc-1.0>, because of API error (400): {"message":"Minimum memory limit allowed is 4MB"}
2018-07-10 08:02:35.893 UTC [container] unlockContainer -> DEBU 611 container lock deleted(10.11.1.121-10.11.1.121-mycc-1.0)
2018-07-10 08:02:35.893 UTC [chaincode] Launch -> ERRO 612 launchAndWaitForRegister failed Error starting container: API error (400): {"message":"Minimum memory limit allowed is 4MB"}
2018-07-10 08:02:35.893 UTC [endorser] callChaincode -> DEBU 613 Exit
2018-07-10 08:02:35.894 UTC [endorser] simulateProposal -> ERRO 614 failed to invoke chaincode name:"lscc"  on transaction c67380e075c9a178cd11b6570cf774c616249a5a1412bdc2f96ebecc3d7bbb7b, error: Error starting container: API error (400): {"message":"Minimum memory limit allowed is 4MB"}

我该如何处理这个错误?该消息的确切含义是什么?

Fabric版本为1.0-rc,本网络在嵌入式环境下测试,硬件资源有限

当 运行 Hyperledger v0.6 在 Raspberry Pi 3 上时,我遇到了同样的问题。

您需要修改 peer/core.yaml 并将 Memory 值从 2147483648 更改为低于您的内存的值大小(在我的例子中,我只输入了 134217728,它小于系统的 972230656 B):

-            Memory: 2147483648
+            Memory: 134217728

您可能还想更改 core/ledger/statemgmt/buckettree/data_key 的第 36 行。go:

-       bucketNumber := int(bucketHash)%conf.getNumBucketsAtLowestLevel() + 1
+       bucketNumber := int(bucketHash % uint32(conf.getNumBucketsAtLowestLevel()) + 1)

因为 bucketHash 是 uint32 而 int 在 Raspberry Pi(或任何其他 32 位系统)上是 32 位。因此,您可能会得到一个负数的 bucketNumber,它会产生这个致命错误:

panic: Invalid bucket number [-483217]. Bucket nuber at level [9] can be between 1 and [1000003]

进行这些更改后,重新编译对等点:

$ make peer