Make EquivocationDelaySecs a build param
This commit is contained in:
parent
668d615be6
commit
43d1d62fc6
@ -132,6 +132,8 @@ const BlockDelaySecs = uint64(4)
|
||||
|
||||
const PropagationDelaySecs = uint64(1)
|
||||
|
||||
var EquivocationDelaySecs = uint64(0)
|
||||
|
||||
// SlashablePowerDelay is the number of epochs after ElectionPeriodStart, after
|
||||
// which the miner is slashed
|
||||
//
|
||||
|
@ -86,6 +86,8 @@ const BlockDelaySecs = uint64(builtin2.EpochDurationSeconds)
|
||||
|
||||
const PropagationDelaySecs = uint64(6)
|
||||
|
||||
var EquivocationDelaySecs = uint64(2)
|
||||
|
||||
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
|
||||
const BootstrapPeerThreshold = 2
|
||||
|
||||
|
@ -123,6 +123,8 @@ const BlockDelaySecs = uint64(builtin2.EpochDurationSeconds)
|
||||
|
||||
var PropagationDelaySecs = uint64(10)
|
||||
|
||||
var EquivocationDelaySecs = uint64(2)
|
||||
|
||||
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
|
||||
const BootstrapPeerThreshold = 4
|
||||
|
||||
|
@ -121,6 +121,8 @@ const BlockDelaySecs = uint64(builtin2.EpochDurationSeconds)
|
||||
|
||||
const PropagationDelaySecs = uint64(6)
|
||||
|
||||
var EquivocationDelaySecs = uint64(2)
|
||||
|
||||
// BootstrapPeerThreshold is the minimum number peers we need to track for a sync worker to start
|
||||
const BootstrapPeerThreshold = 2
|
||||
|
||||
|
@ -105,6 +105,7 @@ var SupportedProofTypes = []abi.RegisteredSealProof{
|
||||
var ConsensusMinerMinPower = abi.NewStoragePower(10 << 40)
|
||||
var PreCommitChallengeDelay = abi.ChainEpoch(150)
|
||||
var PropagationDelaySecs = uint64(10)
|
||||
|
||||
var EquivocationDelaySecs = uint64(2)
|
||||
|
||||
func init() {
|
||||
|
@ -9,7 +9,6 @@ package build
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
@ -34,6 +33,7 @@ var (
|
||||
MinimumBaseFee = int64(100)
|
||||
BlockDelaySecs = uint64(builtin2.EpochDurationSeconds)
|
||||
PropagationDelaySecs = uint64(6)
|
||||
EquivocationDelaySecs = uint64(2)
|
||||
SupportedProofTypes = []abi.RegisteredSealProof{
|
||||
abi.RegisteredSealProof_StackedDrg32GiBV1,
|
||||
abi.RegisteredSealProof_StackedDrg64GiBV1,
|
||||
@ -139,7 +139,3 @@ const BootstrapPeerThreshold = 1
|
||||
// ChainId defines the chain ID used in the Ethereum JSON-RPC endpoint.
|
||||
// As per https://github.com/ethereum-lists/chains
|
||||
const Eip155ChainId = 31415926
|
||||
|
||||
// Reducing the delivery delay for equivocation of
|
||||
// consistent broadcast to just half a second.
|
||||
var CBDeliveryDelay = 500 * time.Millisecond
|
||||
|
@ -169,6 +169,8 @@ func NewEnsemble(t *testing.T, opts ...EnsembleOpt) *Ensemble {
|
||||
require.NoError(t, build.UseNetworkBundle("testing"))
|
||||
}
|
||||
|
||||
build.EquivocationDelaySecs = 0
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
|
@ -568,19 +568,16 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (minedBlock *type
|
||||
// To safeguard against this, we make sure it's been EquivocationDelaySecs since our base was calculated,
|
||||
// then re-calculate it.
|
||||
// If the daemon detected equivocated blocks, those blocks will no longer be in the new base.
|
||||
// TODO: make param
|
||||
m.niceSleep(time.Until(base.ComputeTime.Add(2 * time.Second)))
|
||||
m.niceSleep(time.Until(base.ComputeTime.Add(time.Duration(build.EquivocationDelaySecs) * time.Second)))
|
||||
newBase, err := m.GetBestMiningCandidate(ctx)
|
||||
if err != nil {
|
||||
err = xerrors.Errorf("failed to refresh best mining candidate: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If the MinTicket is still the same, we take the _intersection_ of our old base and new base,
|
||||
// If the base has changed, we take the _intersection_ of our old base and new base,
|
||||
// thus ejecting blocks from any equivocating miners, without taking any new blocks.
|
||||
// If the MinTicket is not the same, then the work we've done so far is no longer valid.
|
||||
// Instead of choosing to miss a block, we submit our best-effort block anyway.
|
||||
if !newBase.TipSet.Equals(base.TipSet) && newBase.TipSet.MinTicket().Equals(base.TipSet.MinTicket()) {
|
||||
if !newBase.TipSet.Equals(base.TipSet) {
|
||||
newBaseMap := map[cid.Cid]struct{}{}
|
||||
for _, newBaseBlk := range newBase.TipSet.Cids() {
|
||||
newBaseMap[newBaseBlk] = struct{}{}
|
||||
@ -600,14 +597,22 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (minedBlock *type
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.TipSet = refreshedBase
|
||||
if !base.TipSet.MinTicket().Equals(refreshedBase.MinTicket()) {
|
||||
ticket, err = m.computeTicket(ctx, &rbase, round, refreshedBase.MinTicket(), mbi)
|
||||
if err != nil {
|
||||
err = xerrors.Errorf("failed to refresh ticket: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// refresh messages, as the selected messages may no longer be valid
|
||||
msgs, err = m.api.MpoolSelect(ctx, base.TipSet.Key(), ticket.Quality())
|
||||
msgs, err = m.api.MpoolSelect(ctx, refreshedBase.Key(), ticket.Quality())
|
||||
if err != nil {
|
||||
err = xerrors.Errorf("failed to re-select messages for block: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.TipSet = refreshedBase
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user