Fix build errors

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-04-07 20:25:34 +02:00 committed by Jeromy
parent 9c250f24fa
commit 9fd1b95fd5
2 changed files with 33 additions and 30 deletions

View File

@ -543,33 +543,37 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
return xerrors.Errorf("received block was from slashed or invalid miner")
}
mpow, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner)
if err != nil {
return xerrors.Errorf("failed getting power: %w", err)
}
// TODO fix winners
/*
ssize, err := stmgr.GetMinerSectorSize(ctx, syncer.sm, baseTs, h.Miner)
if err != nil {
return xerrors.Errorf("failed to get sector size for block miner: %w", err)
}
snum := types.BigDiv(mpow, types.NewInt(uint64(ssize)))
if len(h.EPostProof.Candidates) == 0 {
return xerrors.Errorf("no candidates")
}
wins := make(map[uint64]bool)
for _, t := range h.EPostProof.Candidates {
if wins[t.ChallengeIndex] {
return xerrors.Errorf("block had duplicate epost candidates")
mpow, tpow, err := stmgr.GetPower(ctx, syncer.sm, baseTs, h.Miner)
if err != nil {
return xerrors.Errorf("failed getting power: %w", err)
}
wins[t.ChallengeIndex] = true
if !types.IsTicketWinner(t.Partial, ssize, snum.Uint64(), tpow) {
return xerrors.Errorf("miner created a block but was not a winner")
ssize, err := stmgr.GetMinerSectorSize(ctx, syncer.sm, baseTs, h.Miner)
if err != nil {
return xerrors.Errorf("failed to get sector size for block miner: %w", err)
}
}
snum := types.BigDiv(mpow, types.NewInt(uint64(ssize)))
if len(h.EPostProof.Candidates) == 0 {
return xerrors.Errorf("no candidates")
}
wins := make(map[uint64]bool)
for _, t := range h.EPostProof.Candidates {
if wins[t.ChallengeIndex] {
return xerrors.Errorf("block had duplicate epost candidates")
}
wins[t.ChallengeIndex] = true
if !types.IsTicketWinner(t.Partial, ssize, snum.Uint64(), tpow) {
return xerrors.Errorf("miner created a block but was not a winner")
}
}
*/
return nil
})
@ -978,13 +982,12 @@ func (syncer *Syncer) collectHeaders(ctx context.Context, from *types.TipSet, to
syncer.bad.Add(from.Cids()[0], "no beacon entires")
return nil, xerrors.Errorf("block (%s) contained no drand entires", from.Cids()[0])
}
cur := targetBE[0].Index
cur := targetBE[0].Index
for _, e := range targetBE[1:] {
if cur >= e.Index {
syncer.bad.Add(from.Cids()[0], "wrong order of beacon entires")
return nil, xerrors.Errorf("wrong order of beacon entires")
}
for _, e := range targetBE[1:] {
if cur >= e.Index {
syncer.bad.Add(from.Cids()[0], "wrong order of beacon entires")
return nil, xerrors.Errorf("wrong order of beacon entires")
}
}

View File

@ -317,7 +317,7 @@ func (m *Miner) mineOne(ctx context.Context, addr address.Address, base *MiningB
return nil, xerrors.Errorf("scratching ticket failed: %w", err)
}
proofin, err := gen.IsRoundWinner(ctx, base.ts, int64(round), addr, m.epp, bvals[len(bvals)-1] m.api)
proofin, err := gen.IsRoundWinner(ctx, base.ts, int64(round), addr, m.epp, bvals[len(bvals)-1], m.api)
if err != nil {
return nil, xerrors.Errorf("failed to check if we win next round: %w", err)
}