diff options
author | Wei-Ning Huang <w@byzantine-lab.io> | 2019-08-28 18:35:27 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-09-17 16:57:31 +0800 |
commit | 2ae7b0db497d8f7793c51a0420f1f2d676f228fd (patch) | |
tree | 2be5f72021213095f2b84e4af8859dc6ea4099c0 | |
parent | dff8a1eb364bc522c06256b24b46913866a06110 (diff) | |
download | go-tangerine-2ae7b0db497d8f7793c51a0420f1f2d676f228fd.tar.gz go-tangerine-2ae7b0db497d8f7793c51a0420f1f2d676f228fd.tar.zst go-tangerine-2ae7b0db497d8f7793c51a0420f1f2d676f228fd.zip |
dex: add back recovery time alignment
-rwxr-xr-x | build/recovery-test.sh | 2 | ||||
-rw-r--r-- | dex/blockproposer.go | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/build/recovery-test.sh b/build/recovery-test.sh index 46182b88a..26f1b69cc 100755 --- a/build/recovery-test.sh +++ b/build/recovery-test.sh @@ -11,7 +11,7 @@ fail() endpoint=http://127.0.0.1:8545 -timeout=300 +timeout=700 echo "Wait for recovery" if ! go run build/testtool/testtool.go waitForRecovery $endpoint $timeout; then diff --git a/dex/blockproposer.go b/dex/blockproposer.go index 762707aac..122540ba5 100644 --- a/dex/blockproposer.go +++ b/dex/blockproposer.go @@ -196,6 +196,7 @@ Loop: defer sub.Unsubscribe() // Listen chain head event until synced. + nextDMoment := time.Now().Unix() ListenLoop: for { select { @@ -238,6 +239,19 @@ ListenLoop: case <-b.watchCat.Meow(): log.Info("WatchCat signaled to stop syncing") + // Sleep until the next consensus start time slot. + // The interval T_i need to meet the following requirement: + // + // T_i > T_timeout + T_panic + T_restart + // + // Currently, T_timeout = 120, T_panic = 60, T_restart ~ 60 + // + // We set T_i = 600 to be safe. + + interval := int64(600) + nextDMoment = (time.Now().Unix()/interval + 1) * interval + log.Info("Sleeping until next starting time", "time", nextDMoment) + b.dex.protocolManager.SetReceiveCoreMessage(true) consensusSync.ForceSync(b.watchCat.LastPosition(), true) break ListenLoop @@ -245,5 +259,6 @@ ListenLoop: } con, err := consensusSync.GetSyncedConsensus() + time.Sleep(time.Duration(nextDMoment-time.Now().Unix()) * time.Second) return con, err } |