added testground test case for epoch boundary attack

This commit is contained in:
Alfonso de la Rocha 2022-09-19 09:11:30 +02:00
parent 0209052821
commit 749d13359f
No known key found for this signature in database
GPG Key ID: 97DE48FDFC756FBD
3 changed files with 150 additions and 2 deletions

View File

@ -0,0 +1,71 @@
[metadata]
name = "lotus-soup"
author = ""
[global]
plan = "lotus-soup"
case = "epoch-boundary"
total_instances = 4
builder = "exec:go"
runner = "local:exec"
[global.build]
selectors = ["testground"]
[global.run_config]
exposed_ports = { pprof = "6060", node_rpc = "1234", miner_rpc = "2345" }
[global.build_config]
enable_go_build_cache = true
[global.run.test_params]
clients = "0"
miners = "3"
genesis_timestamp_offset = "0"
balance = "20000000.5" # These balances will work for maximum 100 nodes, as TotalFilecoin is 2B
sectors = "10"
random_beacon_type = "mock"
mining_mode = "natural"
[[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"
[[groups]]
id = "attacker"
[groups.build]
# TODO: Configure different versions for the different nodes.
# [[groups.build.dependencies]]
# module = "github.com/filecoin-project/lotus"
# version = "master"
[groups.instances]
count = 1
percentage = 0.0
[groups.run]
[groups.run.test_params]
role = "miner"
# [[groups]]
# id = "clients"
# [groups.instances]
# count = 0
# percentage = 0.0
# [groups.run]
# [groups.run.test_params]
# role = "client"

View File

@ -0,0 +1,43 @@
package main
import (
"context"
"time"
"github.com/filecoin-project/lotus/testplans/lotus-soup/testkit"
)
// 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)
ctx := context.Background()
// Dispatch/forward non-client roles to defaults.
if t.Role != "miner" {
return testkit.HandleDefaultRole(t)
}
m, err := testkit.PrepareMiner(t)
if err != nil {
return err
}
go func() {
miner := m.FullApi
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())
}
}()
err = m.RunDefault()
if err != nil {
return err
}
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
@ -61,6 +61,40 @@ instances = { min = 1, max = 100, default = 5 }
# Bounce connection during push and pull data transfers
bounce_conn_data_transfers = { type = "bool", default = false }
[[testcases]]
name = "epoch-boundary"
instances = { min = 1, max = 100, default = 5 }
[testcases.params]
clients = { type = "int", default = 1 }
miners = { type = "int", default = 1 }
attackers = { type = "int", default = 1 }
balance = { type = "float", default = 1 }
sectors = { type = "int", default = 1 }
role = { type = "string" }
genesis_timestamp_offset = { type = "int", default = 0 }
random_beacon_type = { type = "enum", default = "mock", options = ["mock", "local-drand", "external-drand"] }
# Params relevant to drand nodes. drand nodes should have role="drand", and must all be
# in the same composition group. There must be at least threshold drand nodes.
# To get lotus nodes to actually use the drand nodes, you must set random_beacon_type="local-drand"
# for the lotus node groups.
drand_period = { type = "duration", default="10s" }
drand_threshold = { type = "int", default = 2 }
drand_gossip_relay = { type = "bool", default = true }
drand_log_level = { type = "string", default="info" }
# Params relevant to pubsub tracing
enable_pubsub_tracer = { type = "bool", default = false }
mining_mode = { type = "enum", default = "synchronized", options = ["synchronized", "natural"] }
# Fast retrieval
fast_retrieval = { type = "bool", default = false }
# Bounce connection during push and pull data transfers
bounce_conn_data_transfers = { type = "bool", default = false }
[[testcases]]
name = "drand-halting"