diff --git a/dashboards/project-oni-baseline-dashboard.json b/dashboards/project-oni-baseline-dashboard.json index 2db88c585..4a7e72049 100644 --- a/dashboards/project-oni-baseline-dashboard.json +++ b/dashboards/project-oni-baseline-dashboard.json @@ -16,7 +16,7 @@ "gnetId": null, "graphTooltip": 0, "id": 16, - "iteration": 1593204217741, + "iteration": 1593448862489, "links": [], "panels": [ { @@ -111,7 +111,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] } ], "timeFrom": null, @@ -216,7 +222,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] }, { "alias": "all ($tag_run)", @@ -259,7 +271,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] } ], "thresholds": [], @@ -406,7 +424,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] } ], "thresholds": [], @@ -547,7 +571,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] }, { "alias": "find-data.offer - $tag_miner ($tag_run)", @@ -596,7 +626,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] } ], "thresholds": [], @@ -743,7 +779,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] } ], "thresholds": [], @@ -876,7 +918,13 @@ } ] ], - "tags": [] + "tags": [ + { + "key": "run", + "operator": "=~", + "value": "/^$runid$/" + } + ] } ], "thresholds": [], @@ -956,11 +1004,37 @@ "refresh": 2, "skipUrlSync": false, "type": "interval" + }, + { + "allValue": null, + "current": { + "selected": true, + "text": "All", + "value": "$__all" + }, + "datasource": "influxdb", + "definition": "SHOW TAG VALUES WITH KEY = run", + "hide": 0, + "includeAll": true, + "label": null, + "multi": false, + "name": "runid", + "options": [], + "query": "SHOW TAG VALUES WITH KEY = run", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 1, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false } ] }, "time": { - "from": "now-8m", + "from": "now-15m", "to": "now" }, "timepicker": { @@ -979,5 +1053,5 @@ "timezone": "", "title": "Project Oni - Baseline test", "uid": "8em8RXWMz", - "version": 8 + "version": 1 } diff --git a/lotus-soup/common_roles.go b/lotus-soup/common_roles.go index 27017bf8a..cddcc25c0 100644 --- a/lotus-soup/common_roles.go +++ b/lotus-soup/common_roles.go @@ -44,31 +44,40 @@ func runMiner(t *TestEnvironment) error { // mine / stop mining mine := true done := make(chan struct{}) - go func() { - defer close(done) - var i int - for i = 0; mine; i++ { - // synchronize all miners to mine the next block - t.RecordMessage("synchronizing all miners to mine next block [%d]", i) - stateMineNext := sync.State(fmt.Sprintf("mine-block-%d", i)) - t.SyncClient.MustSignalAndWait(ctx, stateMineNext, miners) - 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) + if miner.MineOne != nil { + go func() { + defer t.RecordMessage("shutting down mining") + defer close(done) + + var i int + for i = 0; mine; i++ { + // synchronize all miners to mine the next block + t.RecordMessage("synchronizing all miners to mine next block [%d]", i) + stateMineNext := sync.State(fmt.Sprintf("mine-block-%d", i)) + t.SyncClient.MustSignalAndWait(ctx, stateMineNext, miners) + + ch := make(chan struct{}) + err := miner.MineOne(ctx, func(mined bool) { + if mined { + t.D().Counter(fmt.Sprintf("block.mine,miner=%s", myActorAddr)).Inc(1) + } + close(ch) + }) + if err != nil { + panic(err) + } + <-ch } - <-ch - } - // signal the last block to make sure no miners are left stuck waiting for the next block signal - // while the others have stopped - stateMineLast := sync.State(fmt.Sprintf("mine-block-%d", i)) - t.SyncClient.MustSignalEntry(ctx, stateMineLast) - }() + // signal the last block to make sure no miners are left stuck waiting for the next block signal + // while the others have stopped + stateMineLast := sync.State(fmt.Sprintf("mine-block-%d", i)) + t.SyncClient.MustSignalEntry(ctx, stateMineLast) + }() + } else { + close(done) + } // wait for a signal from all clients to stop mining err = <-t.SyncClient.MustBarrier(ctx, stateStopMining, clients).C @@ -77,7 +86,6 @@ func runMiner(t *TestEnvironment) error { } mine = false - t.RecordMessage("shutting down mining") <-done time.Sleep(3600 * time.Second) diff --git a/lotus-soup/compositions/composition-k8s-10-3.toml b/lotus-soup/compositions/composition-k8s-10-3.toml index 91b0276d7..bc4a44220 100644 --- a/lotus-soup/compositions/composition-k8s-10-3.toml +++ b/lotus-soup/compositions/composition-k8s-10-3.toml @@ -20,7 +20,6 @@ miners = "3" genesis_timestamp_offset = "100000" balance = "2000" - sectors = "20" [[groups]] id = "bootstrapper" @@ -35,16 +34,30 @@ role = "bootstrapper" [[groups]] - id = "miners" + id = "miners-weak" [groups.resources] memory = "8192Mi" cpu = "1000m" [groups.instances] - count = 3 + count = 2 percentage = 0.0 [groups.run] [groups.run.test_params] role = "miner" + sectors = "8" + +[[groups]] + id = "miners-strong" + [groups.resources] + memory = "8192Mi" + cpu = "1000m" + [groups.instances] + count = 1 + percentage = 0.0 + [groups.run] + [groups.run.test_params] + role = "miner" + sectors = "24" [[groups]] id = "clients" diff --git a/lotus-soup/compositions/composition-natural.toml b/lotus-soup/compositions/composition-natural.toml new file mode 100644 index 000000000..e82c6a397 --- /dev/null +++ b/lotus-soup/compositions/composition-natural.toml @@ -0,0 +1,49 @@ +[metadata] + name = "lotus-soup" + author = "" + +[global] + plan = "lotus-soup" + case = "lotus-baseline" + total_instances = 6 + builder = "docker:go" + runner = "local:docker" + +[global.build_config] + enable_go_build_cache = true + +[global.run.test_params] + clients = "3" + miners = "2" + genesis_timestamp_offset = "100000" + balance = "2000000000" + sectors = "10" + random_beacon_type = "mock" + +[[groups]] + id = "bootstrapper" + [groups.instances] + count = 1 + percentage = 0.0 + [groups.run] + [groups.run.test_params] + role = "bootstrapper" + +[[groups]] + id = "miners" + [groups.instances] + count = 2 + percentage = 0.0 + [groups.run] + [groups.run.test_params] + role = "miner" + mining_mode = "natural" + +[[groups]] + id = "clients" + [groups.instances] + count = 3 + percentage = 0.0 + [groups.run] + [groups.run.test_params] + role = "client" diff --git a/lotus-soup/compositions/composition-tracer.toml b/lotus-soup/compositions/composition-tracer.toml index ec3e5dc5e..d632d287e 100644 --- a/lotus-soup/compositions/composition-tracer.toml +++ b/lotus-soup/compositions/composition-tracer.toml @@ -12,6 +12,15 @@ [global.build_config] enable_go_build_cache = true +[global.run.test_params] + clients = "3" + miners = "2" + genesis_timestamp_offset = "100000" + balance = "2000000000" + sectors = "10" + random_beacon_type = "mock" + enable_pubsub_tracer = "true" + [[groups]] id = "pubsub-tracer" [groups.instances] @@ -29,12 +38,6 @@ [groups.run] [groups.run.test_params] role = "bootstrapper" - clients = "3" - miners = "2" - balance = "2000000000" - sectors = "10" - random_beacon_type = "mock" - enable_pubsub_tracer = "true" [[groups]] id = "miners" @@ -44,13 +47,6 @@ [groups.run] [groups.run.test_params] role = "miner" - clients = "3" - miners = "2" - balance = "2000000000" - sectors = "10" - random_beacon_type = "mock" - enable_pubsub_tracer = "true" - [[groups]] id = "clients" @@ -60,9 +56,3 @@ [groups.run] [groups.run.test_params] role = "client" - clients = "3" - miners = "2" - balance = "2000000000" - sectors = "10" - random_beacon_type = "mock" - enable_pubsub_tracer = "true" diff --git a/lotus-soup/compositions/composition.toml b/lotus-soup/compositions/composition.toml index 05dc7b688..1b24f3b94 100644 --- a/lotus-soup/compositions/composition.toml +++ b/lotus-soup/compositions/composition.toml @@ -12,6 +12,14 @@ [global.build_config] enable_go_build_cache = true +[global.run.test_params] + clients = "3" + miners = "2" + genesis_timestamp_offset = "100000" + balance = "2000000000" + sectors = "10" + random_beacon_type = "mock" + [[groups]] id = "bootstrapper" [groups.instances] @@ -20,11 +28,6 @@ [groups.run] [groups.run.test_params] role = "bootstrapper" - clients = "3" - miners = "2" - balance = "2000000000" - sectors = "10" - random_beacon_type = "mock" [[groups]] id = "miners" @@ -34,12 +37,6 @@ [groups.run] [groups.run.test_params] role = "miner" - clients = "3" - miners = "2" - balance = "2000000000" - sectors = "10" - random_beacon_type = "mock" - [[groups]] id = "clients" @@ -49,9 +46,3 @@ [groups.run] [groups.run.test_params] role = "client" - clients = "3" - miners = "2" - balance = "2000000000" - sectors = "10" - random_beacon_type = "mock" - diff --git a/lotus-soup/manifest.toml b/lotus-soup/manifest.toml index 2ee118523..7227fdd35 100644 --- a/lotus-soup/manifest.toml +++ b/lotus-soup/manifest.toml @@ -41,3 +41,6 @@ instances = { min = 1, max = 100, default = 5 } # Params relevant to pubsub tracing enable_pubsub_tracer = { type = "bool", default = false } + + # Mining Mode: synchronized -vs- natural time + mining_mode = { type = "enum", default = "synchronized", options = ["synchronized", "natural"] } diff --git a/lotus-soup/node.go b/lotus-soup/node.go index 395bba8b8..52f57f28e 100644 --- a/lotus-soup/node.go +++ b/lotus-soup/node.go @@ -80,9 +80,10 @@ var ( clientsAddrsTopic = sync.NewTopic("clientsAddrsTopic", &peer.AddrInfo{}) minersAddrsTopic = sync.NewTopic("minersAddrsTopic", &MinerAddresses{}) - stateReady = sync.State("ready") - stateDone = sync.State("done") - stateStopMining = sync.State("stop-mining") + stateReady = sync.State("ready") + stateDone = sync.State("done") + stateStopMining = sync.State("stop-mining") + stateMinerPickSeqNum = sync.State("miner-pick-seq-num") ) type TestEnvironment struct { @@ -301,7 +302,10 @@ func prepareMiner(t *TestEnvironment) (*Node, error) { return nil, err } - minerAddr, err := address.NewIDAddress(genesis_chain.MinerStart + uint64(t.GroupSeq-1)) + // pick unique sequence number for each miner, no matter in which group they are + seq := t.SyncClient.MustSignalAndWait(ctx, stateMinerPickSeqNum, t.IntParam("miners")) + + minerAddr, err := address.NewIDAddress(genesis_chain.MinerStart + uint64(seq-1)) if err != nil { return nil, err } @@ -320,7 +324,7 @@ func prepareMiner(t *TestEnvironment) (*Node, error) { t.RecordMessage("Miner Info: Owner: %s Worker: %s", genMiner.Owner, genMiner.Worker) - presealMsg := &PresealMsg{Miner: *genMiner, Seqno: t.GroupSeq} + presealMsg := &PresealMsg{Miner: *genMiner, Seqno: seq} t.SyncClient.Publish(ctx, presealTopic, presealMsg) // then collect the genesis block and bootstrapper address @@ -414,8 +418,7 @@ func prepareMiner(t *TestEnvironment) (*Node, error) { return nil, err } - mineBlock := make(chan func(bool)) - stop2, err := node.New(context.Background(), + minerOpts := []node.Option{ node.StorageMiner(&n.minerApi), node.Online(), node.Repo(minerRepo), @@ -427,9 +430,24 @@ func prepareMiner(t *TestEnvironment) (*Node, error) { } return lr.SetAPIEndpoint(apima) }), - node.Override(new(*miner.Miner), miner.NewTestMiner(mineBlock, minerAddr)), withMinerListenAddress(minerIP), - ) + } + + if t.StringParam("mining_mode") != "natural" { + mineBlock := make(chan func(bool)) + minerOpts = append(minerOpts, + node.Override(new(*miner.Miner), miner.NewTestMiner(mineBlock, minerAddr))) + n.MineOne = func(ctx context.Context, cb func(bool)) error { + select { + case mineBlock <- cb: + return nil + case <-ctx.Done(): + return ctx.Err() + } + } + } + + stop2, err := node.New(context.Background(), minerOpts...) if err != nil { stop1(context.TODO()) return nil, err @@ -455,15 +473,6 @@ func prepareMiner(t *TestEnvironment) (*Node, error) { panic(err) } - n.MineOne = func(ctx context.Context, cb func(bool)) error { - select { - case mineBlock <- cb: - return nil - case <-ctx.Done(): - return ctx.Err() - } - } - endpoint, err := minerRepo.APIEndpoint() if err != nil { return nil, err