use proper round number, allow block signature to be nil

This commit is contained in:
whyrusleeping 2019-11-19 14:05:21 -06:00
parent f8eabd3db4
commit c4564c0597
7 changed files with 19 additions and 9 deletions

View File

@ -120,7 +120,7 @@ func MinerCreateBlock(ctx context.Context, sm *stmgr.StateManager, w *wallet.Wal
return nil, xerrors.Errorf("failed to sign new block: %w", err)
}
next.BlockSig = *sig
next.BlockSig = sig
fullBlock := &types.FullBlock{
Header: next,

View File

@ -393,7 +393,7 @@ func MakeGenesisBlock(bs bstore.Blockstore, balances map[address.Address]types.B
Messages: mmb.Cid(),
ParentMessageReceipts: emptyroot,
BLSAggregate: types.Signature{Type: types.KTBLS, Data: []byte("signatureeee")},
BlockSig: types.Signature{Type: types.KTBLS, Data: []byte("block signatureeee")},
BlockSig: &types.Signature{Type: types.KTBLS, Data: []byte("block signatureeee")},
Timestamp: ts,
}

View File

@ -478,8 +478,6 @@ func (syncer *Syncer) validateTicket(ctx context.Context, mworker address.Addres
vrfBase := gen.TicketHash(base.MinTicket(), round)
log.Infof("about to verify ticket: %x %d", base.MinTicket().VRFProof, round)
// TODO: ticket signatures should also include miner address
if err := sig.Verify(mworker, vrfBase); err != nil {
return xerrors.Errorf("invalid ticket, VRFProof invalid: %w", err)

View File

@ -45,7 +45,7 @@ type BlockHeader struct {
Timestamp uint64
BlockSig Signature
BlockSig *Signature
}
func (b *BlockHeader) ToStorageBlock() (block.Block, error) {
@ -96,7 +96,7 @@ func (blk *BlockHeader) LastTicket() *Ticket {
func (blk *BlockHeader) SigningBytes() ([]byte, error) {
blkcopy := *blk
blkcopy.BlockSig = Signature{}
blkcopy.BlockSig = nil
return blkcopy.Serialize()
}

View File

@ -35,7 +35,7 @@ func testBlockHeader(t testing.TB) *BlockHeader {
Messages: c,
Height: 85919298723,
ParentStateRoot: c,
BlockSig: Signature{Type: KTBLS, Data: []byte("boo! im a signature")},
BlockSig: &Signature{Type: KTBLS, Data: []byte("boo! im a signature")},
}
}

View File

@ -261,9 +261,21 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error {
{
if err := t.BlockSig.UnmarshalCBOR(br); err != nil {
pb, err := br.PeekByte()
if err != nil {
return err
}
if pb == cbg.CborNull[0] {
var nbuf [1]byte
if _, err := br.Read(nbuf[:]); err != nil {
return err
}
} else {
t.BlockSig = new(Signature)
if err := t.BlockSig.UnmarshalCBOR(br); err != nil {
return err
}
}
}
return nil

View File

@ -304,7 +304,7 @@ func (m *Miner) getMinerWorker(ctx context.Context, addr address.Address, ts *ty
}
func (m *Miner) scratchTicket(ctx context.Context, addr address.Address, base *MiningBase) (*types.Ticket, error) {
round := base.ts.Height() + base.nullRounds
round := base.ts.Height() + base.nullRounds + 1
vrfBase := gen.TicketHash(base.ts.MinTicket(), round)