hyperledger-archives / iroha

Iroha - A simple, decentralized ledger
http://iroha.tech
Apache License 2.0
988 stars 298 forks source link

Fix command service infinite replay #2102

Closed igor-egorov closed 5 years ago

igor-egorov commented 5 years ago

Signed-off-by: Igor Egorov igor@soramitsu.co.jp

Description of the Change

Persistent cache for some reason was not integrated into command service. That was resulting in infinite resending of a replayed transaction between Iroha components.

The fix makes CommandServiceImpl aware of persistent cache and the infinite loop is broken now.

Caches lookup strategy during batch processing in command service (even single incoming transaction will be represented as a batch internally):

Benefits

Potentially improved CPU and memory consumption. Reduced network load. An infinite resending of a replayed transaction between Iroha components is avoided.

Possible Drawbacks

Weird cache dependency for CommandServiceImpl appeared.

Usage Examples or Tests

command_service_replay_test

compile and run irohad

Check that there is no infinite resending

run repro script https://gist.github.com/igor-egorov/ff56db9ca1de50215d6830f5980155d6

Iroha output should not contain inifinitely repeated message about duplicated transaction from OnDemandOrderingServiceImpl like "Duplicate transaction: ..."

Check that correct statuses are delivered in tx status stream

repro script https://gist.github.com/igor-egorov/152b821faa335193569dec2246e578fb

You have to compile two versions of irohad: one from develop branch, another - from that pr.

Run the script with both irohad's and capture the output to files. The statuses (their order) should not differ.

igor-egorov commented 5 years ago

Please review the two last commits.