consistent broadcast delay as build param
This commit is contained in:
parent
894da941af
commit
91bd679d1e
@ -6,6 +6,7 @@ package build
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
@ -131,3 +132,7 @@ const InteractivePoRepConfidence = 6
|
||||
const BootstrapPeerThreshold = 1
|
||||
|
||||
var WhitelistedBlock = cid.Undef
|
||||
|
||||
// Reducing the delivery delay for equivocation of
|
||||
// consistent broadcast to just one second.
|
||||
const CBDeliveryDelay = 1 * time.Second
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
@ -126,3 +127,7 @@ const BootstrapPeerThreshold = 4
|
||||
|
||||
// we skip checks on message validity in this block to sidestep the zero-bls signature
|
||||
var WhitelistedBlock = MustParseCid("bafy2bzaceapyg2uyzk7vueh3xccxkuwbz3nxewjyguoxvhx77malc2lzn2ybi")
|
||||
|
||||
// CBDeliveryDelay is the delay before deliver in the synchronous consistent broadcast.
|
||||
// This determines the wait time for the detection of potential equivocations.
|
||||
const CBDeliveryDelay = 6 * time.Second
|
||||
|
@ -13,11 +13,13 @@ import (
|
||||
"github.com/multiformats/go-multihash"
|
||||
)
|
||||
|
||||
// TODO: Take const out of here and make them build params.
|
||||
const (
|
||||
DELAY = 6 * time.Second
|
||||
GC_SANITY_CHECK = 5
|
||||
GC_LOOKBACK = 2
|
||||
// GcSanityCheck determines the number of epochs that in the past
|
||||
// that will be garbage collected from the current epoch.
|
||||
GcSanityCheck = 5
|
||||
// GcLookback determines the number of epochs kept in the consistent
|
||||
// broadcast cache.
|
||||
GcLookback = 2
|
||||
)
|
||||
|
||||
type blksInfo struct {
|
||||
@ -57,7 +59,8 @@ func newBcastDict() *bcastDict {
|
||||
return &bcastDict{new(sync.Map)}
|
||||
}
|
||||
|
||||
// TODO: What if the VRFProof is already small?? We don´t need the CID. Useless computation.
|
||||
// TODO: the VRFProof may already be small enough so we may not need to use a hash here.
|
||||
// we can maybe bypass the useless computation.
|
||||
func BCastKey(bh *types.BlockHeader) (multihash.Multihash, error) {
|
||||
k := make([]byte, len(bh.Ticket.VRFProof))
|
||||
copy(k, bh.Ticket.VRFProof)
|
||||
@ -150,9 +153,9 @@ func (cb *ConsistentBCast) GarbageCollect(currEpoch abi.ChainEpoch) {
|
||||
// and we use the sanity-check in case there were a few rounds
|
||||
// without delivery, and the garbage collection wasn't triggered
|
||||
// for a few epochs.
|
||||
for i := 0; i < GC_SANITY_CHECK; i++ {
|
||||
if currEpoch > GC_LOOKBACK {
|
||||
delete(cb.m, currEpoch-abi.ChainEpoch(GC_LOOKBACK+i))
|
||||
for i := 0; i < GcSanityCheck; i++ {
|
||||
if currEpoch > GcLookback {
|
||||
delete(cb.m, currEpoch-abi.ChainEpoch(GcLookback+i))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func TestSeveralEpochs(t *testing.T) {
|
||||
}(i)
|
||||
}
|
||||
wg.Wait()
|
||||
require.Equal(t, cb.Len(), bcast.GC_LOOKBACK)
|
||||
require.Equal(t, cb.Len(), bcast.GcLookback)
|
||||
}
|
||||
|
||||
// bias is expected to be 0-1
|
||||
|
@ -48,7 +48,7 @@ func HandleIncomingBlocks(ctx context.Context, bsub *pubsub.Subscription, self p
|
||||
// Timeout after (block time + propagation delay). This is useless at
|
||||
// this point.
|
||||
timeout := time.Duration(build.BlockDelaySecs+build.PropagationDelaySecs) * time.Second
|
||||
cb := bcast.NewConsistentBCast(bcast.DELAY)
|
||||
cb := bcast.NewConsistentBCast(build.CBDeliveryDelay)
|
||||
|
||||
for {
|
||||
msg, err := bsub.Next(ctx)
|
||||
|
@ -1,78 +0,0 @@
|
||||
[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 = "synchronized"
|
||||
|
||||
[[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]
|
||||
|
||||
# Implementation of the attacker.
|
||||
[[groups.build.dependencies]]
|
||||
module = "github.com/filecoin-project/lotus"
|
||||
target = "github.com/adlrocha/lotus"
|
||||
version = "b9ca4b71bf613ef9a1f21f302238c0d1fc55e65d"
|
||||
|
||||
# Modification of gossipsub
|
||||
[[groups.build.dependencies]]
|
||||
module = "github.com/libp2p/go-libp2p-pubsub"
|
||||
target = "github.com/adlrocha/go-libp2p-pubsub"
|
||||
version = "781f60ae88e4bcb79226232832e0a9b5a08dd3ed"
|
||||
|
||||
[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"
|
@ -1,52 +0,0 @@
|
||||
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.
|
||||
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)
|
||||
}
|
||||
// prepare miners to run.
|
||||
m, err := testkit.PrepareMiner(t)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
go func() {
|
||||
miner := m.FullApi
|
||||
ch, _ := miner.ChainNotify(ctx)
|
||||
for {
|
||||
curr := <-ch
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user