dtr-org / unit-e

A digital currency for a new era of decentralized trust
https://unit-e.io
MIT License
45 stars 15 forks source link

Fix race-condition in feature_no_esperanza_tx_relay_delay #833

Closed kostyantyn closed 5 years ago

kostyantyn commented 5 years ago

Resolves #819

From the log:

node4 08:17:32.499560 UpdateTip: new best=479432abf8d0ff6f3e97bcea6e819312e4baf34dd205184841f758860d3a529c height=18 version=0x20000000 log2_work=5.2479275 tx=34 date='2019-03-21 08:17:34' progress=1.000000 cache=0.0MiB(0txo) 
node0 08:17:32.501461 UpdateTip: new best=479432abf8d0ff6f3e97bcea6e819312e4baf34dd205184841f758860d3a529c height=18 version=0x20000000 log2_work=5.2479275 tx=34 date='2019-03-21 08:17:34' progress=1.000000 cache=0.0MiB(0txo) 
node1 08:17:32.509251 UpdateTip: new best=479432abf8d0ff6f3e97bcea6e819312e4baf34dd205184841f758860d3a529c height=18 version=0x20000000 log2_work=5.2479275 tx=34 date='2019-03-21 08:17:34' progress=1.000000 cache=0.0MiB(0txo) 
node2 08:17:32.511159 UpdateTip: new best=479432abf8d0ff6f3e97bcea6e819312e4baf34dd205184841f758860d3a529c height=18 version=0x20000000 log2_work=5.2479275 tx=34 date='2019-03-21 08:17:34' progress=1.000000 cache=0.0MiB(0txo) 
node3 08:17:32.515410 ERROR: IsVotable: vote for wrong target_epoch=8. validator=6cb00591c9da64afc2930d2151bb7bb4e0c1cd09 current_epoch=8
node3 08:17:32.530314 UpdateTip: new best=479432abf8d0ff6f3e97bcea6e819312e4baf34dd205184841f758860d3a529c height=18 version=0x20000000 log2_work=5.2479275 tx=34 date='2019-03-21 08:17:34' progress=1.000000 cache=0.0MiB(0txo) 

We see that the vote was received earlier than the block was marked as a new Tip.

This is a known race-condition and explained here https://github.com/dtr-org/unit-e/pull/731#issuecomment-469335061

We should always disconnect finalizer from the node that generates blocks.

We have a function wait_for_vote_and_disconnect which takes care of this but in this particular test we measure propagation time and that function has an overhead when it tries to check the content of mempool so we can't use it.

Signed-off-by: Kostiantyn Stepaniuk kostia@thirdhash.com

kostyantyn commented 5 years ago

squashed commits and force-pushed to try to fix DCO/Mergeable