How Hyperledger Sawtooth take care of infinite/endless loops?

与世无争的帅哥 提交于 2020-06-13 05:28:30

问题


I could not find anything concrete about how Hyperledger Sawtooth handles the problem of infinite loops created by mistake or voluntarily by the developer (Only some issues regarding the IntKey transaction family Intkey workload command run in endless loop with wrong URL).

I am sure that on Hyperledger Fabric the concept of the timeout of chain code execution avoids the creation of infinite loops, but which mechanism is used in Hyperledger Sawtooth?

Thanks!


回答1:


The best thing to do is to test your custom transaction processor. A common mistake in writing transaction processors is the return code. InternalError is supposed to be a transient error (some internal fault like 'out of memory' that is temporary), and may succeed if retried. The validator retries the transaction with the TP and results in a loop. If the transaction is invalid, you probably want to raise an InvalidTransaction error instead. Bottom line—internal errors are retried, and invalid transactions are not retried.

To make your blockchain more resistent to faulty transaction processors I strongly suggest running the Validator in parallel mode. That would make it possible for other transactions to be processed in case of some bug is hit in a transaction processor. To run in parallel processing mode use sawtooth-validator --scheduler parallel -vv

The Sawtooth Validator also checks connections with transaction processors and those that do not respond (are hung or frozen) are removed.

Edit: as for your follow-up question about DoS mitigation, there is a back pressure test in Sawtooth. Back pressure is a flow-control technique to help prevent DoS attacks. If the validator is overwhelmed it will stop accepting new batches until it can handle more work. The number of batches that validator can accept is based on a multiplier, QUEUE_MULTIPLIER (currently 10, formerly 2), times a rolling average of the number of published batches.

Also, one can put the Sawtooth network behind a VPN. Sawtooth is a permissioned enterprised blockchain and is not designed for use in the public Internet.



来源:https://stackoverflow.com/questions/53641603/how-hyperledger-sawtooth-take-care-of-infinite-endless-loops

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!