fix: supply extra params for ReportConsensusFaultParams
This commit is contained in:
parent
16b9787db9
commit
2fca475dd4
@ -26,7 +26,7 @@ func New(dstore ds.Batching) *SlashFilter {
|
||||
}
|
||||
}
|
||||
|
||||
func (f *SlashFilter) CheckBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) (cid.Cid, error) {
|
||||
func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) (cid.Cid, error) {
|
||||
epochKey := ds.NewKey(fmt.Sprintf("/%s/%d", bh.Miner, bh.Height))
|
||||
{
|
||||
// double-fork mining (2 blocks at one epoch)
|
||||
@ -73,7 +73,7 @@ func (f *SlashFilter) CheckBlock(ctx context.Context, bh *types.BlockHeader, par
|
||||
}
|
||||
|
||||
if !found {
|
||||
return cid.Undef, xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent)
|
||||
return parent, xerrors.Errorf("produced block would trigger 'parent-grinding fault' consensus fault; miner: %s; bh: %s, expected parent: %s", bh.Miner, bh.Cid(), parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,11 +89,6 @@ func (f *SlashFilter) CheckBlock(ctx context.Context, bh *types.BlockHeader, par
|
||||
return cid.Undef, nil
|
||||
}
|
||||
|
||||
func (f *SlashFilter) MinedBlock(ctx context.Context, bh *types.BlockHeader, parentEpoch abi.ChainEpoch) error {
|
||||
_, err := f.CheckBlock(ctx, bh, parentEpoch)
|
||||
return err
|
||||
}
|
||||
|
||||
func checkFault(ctx context.Context, t ds.Datastore, key ds.Key, bh *types.BlockHeader, faultType string) (cid.Cid, error) {
|
||||
fault, err := t.Has(ctx, key)
|
||||
if err != nil {
|
||||
|
@ -639,7 +639,7 @@ func slashConsensus(a lapi.FullNode, p string, from string) error {
|
||||
}
|
||||
for block := range blocks {
|
||||
log.Infof("deal with block: %d, %v, %s", block.Height, block.Miner, block.Cid())
|
||||
if otherBlock, err := slashFilterMinedBlock(ctx, sf, a, block); err != nil {
|
||||
if otherBlock, extraBlock, err := slashFilterMinedBlock(ctx, sf, a, block); err != nil {
|
||||
if otherBlock == nil {
|
||||
continue
|
||||
}
|
||||
@ -660,6 +660,14 @@ func slashConsensus(a lapi.FullNode, p string, from string) error {
|
||||
BlockHeader1: bh1,
|
||||
BlockHeader2: bh2,
|
||||
}
|
||||
if extraBlock != nil {
|
||||
be, err := cborutil.Dump(extraBlock)
|
||||
if err != nil {
|
||||
log.Errorf("could not dump block:%s, err:%s", block.Cid(), err)
|
||||
continue
|
||||
}
|
||||
params.BlockHeaderExtra = be
|
||||
}
|
||||
|
||||
enc, err := actors.SerializeParams(¶ms)
|
||||
if err != nil {
|
||||
@ -684,18 +692,18 @@ func slashConsensus(a lapi.FullNode, p string, from string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, blockB *types.BlockHeader) (*types.BlockHeader, error) {
|
||||
func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a lapi.FullNode, blockB *types.BlockHeader) (*types.BlockHeader, *types.BlockHeader, error) {
|
||||
blockC, err := a.ChainGetBlock(ctx, blockB.Parents[0])
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("chain get block error:%s", err)
|
||||
return nil, nil, xerrors.Errorf("chain get block error:%s", err)
|
||||
}
|
||||
otherCid, err := sf.CheckBlock(ctx, blockB, blockC.Height)
|
||||
otherCid, err := sf.MinedBlock(ctx, blockB, blockC.Height)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("slash filter check block error:%s", err)
|
||||
return nil, nil, xerrors.Errorf("slash filter check block error:%s", err)
|
||||
}
|
||||
if otherCid != cid.Undef {
|
||||
otherHeader, err := a.ChainGetBlock(ctx, otherCid)
|
||||
return otherHeader, xerrors.Errorf("chain get other block error:%s", err)
|
||||
return otherHeader, nil, xerrors.Errorf("chain get other block error:%s", err)
|
||||
}
|
||||
blockA, err := a.ChainGetBlock(ctx, otherCid)
|
||||
|
||||
@ -709,8 +717,8 @@ func slashFilterMinedBlock(ctx context.Context, sf *slashfilter.SlashFilter, a l
|
||||
// [A, C]
|
||||
if types.CidArrsEqual(blockA.Parents, blockC.Parents) && blockA.Height == blockC.Height &&
|
||||
types.CidArrsContains(blockB.Parents, blockC.Cid()) && !types.CidArrsContains(blockB.Parents, blockA.Cid()) {
|
||||
return blockC, xerrors.Errorf("chain get other block error:%s", err)
|
||||
return blockA, blockC, xerrors.Errorf("chain get other block error:%s", err)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ minerLoop:
|
||||
"block-time", btime, "time", build.Clock.Now(), "difference", build.Clock.Since(btime))
|
||||
}
|
||||
|
||||
if err := m.sf.MinedBlock(ctx, b.Header, base.TipSet.Height()+base.NullRounds); err != nil {
|
||||
if _, err = m.sf.MinedBlock(ctx, b.Header, base.TipSet.Height()+base.NullRounds); err != nil {
|
||||
log.Errorf("<!!> SLASH FILTER ERROR: %s", err)
|
||||
if os.Getenv("LOTUS_MINER_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" {
|
||||
continue
|
||||
|
@ -58,7 +58,7 @@ func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) erro
|
||||
}
|
||||
|
||||
if a.SlashFilter != nil && os.Getenv("LOTUS_NO_SLASHFILTER") != "_yes_i_know_i_can_and_probably_will_lose_all_my_fil_and_power_" {
|
||||
if err := a.SlashFilter.MinedBlock(ctx, blk.Header, parent.Height); err != nil {
|
||||
if _, err = a.SlashFilter.MinedBlock(ctx, blk.Header, parent.Height); err != nil {
|
||||
log.Errorf("<!!> SLASH FILTER ERROR: %s", err)
|
||||
return xerrors.Errorf("<!!> SLASH FILTER ERROR: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user