From 909c12c6b4a4d827b716d21cd515c85b6e48df90 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Mon, 29 Jun 2020 17:06:04 +0200 Subject: [PATCH 1/2] sync miners --- lotus-soup/common_roles.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lotus-soup/common_roles.go b/lotus-soup/common_roles.go index 9d5c1d1b7..971203254 100644 --- a/lotus-soup/common_roles.go +++ b/lotus-soup/common_roles.go @@ -3,8 +3,6 @@ package main import ( "context" "fmt" - "math/rand" - "time" "github.com/filecoin-project/lotus/build" "github.com/testground/sdk-go/sync" @@ -54,15 +52,15 @@ func runMiner(t *TestEnvironment) error { stateMineNext := sync.State(fmt.Sprintf("mine-block-%d", i)) t.SyncClient.MustSignalAndWait(ctx, stateMineNext, miners) - // add some random delay to encourage a different miner winning each round - time.Sleep(time.Duration(100 + rand.Intn(int(100*time.Millisecond)))) - + ch := make(chan struct{}) err := miner.MineOne(ctx, func(mined bool) { t.D().Counter(fmt.Sprintf("block.mine,miner=%s", myActorAddr)).Inc(1) + close(ch) }) if err != nil { panic(err) } + <-ch } // signal the last block to make sure no miners are left stuck waiting for the next block signal From 0ec247de8c8dc7f31e6ee12d3a9367ba3949059a Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Mon, 29 Jun 2020 17:21:50 +0200 Subject: [PATCH 2/2] fix broken counter --- lotus-soup/common_roles.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lotus-soup/common_roles.go b/lotus-soup/common_roles.go index 971203254..6bb0b9855 100644 --- a/lotus-soup/common_roles.go +++ b/lotus-soup/common_roles.go @@ -54,7 +54,9 @@ func runMiner(t *TestEnvironment) error { ch := make(chan struct{}) err := miner.MineOne(ctx, func(mined bool) { - t.D().Counter(fmt.Sprintf("block.mine,miner=%s", myActorAddr)).Inc(1) + if mined { + t.D().Counter(fmt.Sprintf("block.mine,miner=%s", myActorAddr)).Inc(1) + } close(ch) }) if err != nil {