minor fixes. sync mining.

This commit is contained in:
Alfonso de la Rocha 2022-09-22 19:46:25 +02:00
parent 8f48631fc4
commit ebafb6584e
No known key found for this signature in database
GPG Key ID: 97DE48FDFC756FBD
4 changed files with 22 additions and 11 deletions

View File

@ -25,7 +25,7 @@
balance = "20000000.5" # These balances will work for maximum 100 nodes, as TotalFilecoin is 2B
sectors = "10"
random_beacon_type = "mock"
mining_mode = "natural"
mining_mode = "synchronized"
[[groups]]
id = "bootstrapper"
@ -49,10 +49,11 @@
id = "attacker"
[groups.build]
# TODO: Configure different versions for the different nodes.
# [[groups.build.dependencies]]
# module = "github.com/filecoin-project/lotus"
# version = "master"
# Implementation of the attacker.
[[groups.build.dependencies]]
module = "github.com/filecoin-project/lotus"
module = "github.com/adlrocha/lotus"
version = "b9ca4b71bf613ef9a1f21f302238c0d1fc55e65d"
[groups.instances]
count = 1

View File

@ -10,7 +10,6 @@ import (
// This test runs a set of miners and let them mine for some time.
// Each miner tracks the different blocks they are mining so we can
// process a posteriori the different chains they are mining.
// TODO: Include the attacker.
func epochBoundary(t *testkit.TestEnvironment) error {
t.RecordMessage("running node with role '%s'", t.Role)
@ -19,6 +18,7 @@ func epochBoundary(t *testkit.TestEnvironment) error {
if t.Role != "miner" {
return testkit.HandleDefaultRole(t)
}
// prepare miners to run.
m, err := testkit.PrepareMiner(t)
if err != nil {
return err
@ -28,15 +28,24 @@ func epochBoundary(t *testkit.TestEnvironment) error {
ch, _ := miner.ChainNotify(ctx)
for {
curr := <-ch
// We collect new blocks seen by the node along with its cid.
// We can process the results a posteriori to determine the number of equivocations.
t.RecordMessage("New Block: height=%v, cid=%v", curr[0].Val.Height(), curr[0].Val.Cids())
for _, c := range curr {
if c.Type != "apply" {
continue
}
// We collect new blocks seen by the node along with its cid.
// We can process the results a posteriori to determine the number of equivocations.
ts := c.Val
t.RecordMessage("New Block: height=%v, cid=%v", ts.Height(), ts.Cids())
}
}
}()
err = m.RunDefault()
if err != nil {
return err
}
// time to mine in the experiment.
// TODO: Make this configurable and optionally make it a number of epochs.
time.Sleep(120 * time.Second)
t.SyncClient.MustSignalAndWait(ctx, testkit.StateDone, t.TestInstanceCount)
return nil

View File

@ -9,8 +9,8 @@ enabled = true
[builders."docker:go"]
enabled = true
# build_base_image = "iptestground/oni-buildbase:v15-lotus"
# runtime_image = "iptestground/oni-runtime:v10-debug"
build_base_image = "iptestground/oni-buildbase:v15-lotus"
runtime_image = "iptestground/oni-runtime:v10-debug"
[runners."local:exec"]
enabled = true

View File

@ -547,6 +547,7 @@ func (m *LotusMiner) RunDefault() error {
defer t.RecordMessage("shutting down mining")
defer close(done)
mine := true
var i int
for i = 0; mine; i++ {
// synchronize all miners to mine the next block