reject blocks with nil signatures
This commit is contained in:
parent
c4564c0597
commit
d57f048c2c
@ -170,5 +170,5 @@ func signBlock(t *testing.T, w *wallet.Wallet, worker address.Address, blk *type
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
blk.BlockSig = *sig
|
blk.BlockSig = sig
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet {
|
|||||||
Messages: msgcid,
|
Messages: msgcid,
|
||||||
ParentMessageReceipts: dummyCid,
|
ParentMessageReceipts: dummyCid,
|
||||||
|
|
||||||
BlockSig: types.Signature{Type: types.KTBLS},
|
BlockSig: &types.Signature{Type: types.KTBLS},
|
||||||
BLSAggregate: types.Signature{Type: types.KTBLS},
|
BLSAggregate: types.Signature{Type: types.KTBLS},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -71,7 +71,7 @@ func makeTs(t *testing.T, h uint64, msgcid cid.Cid) *types.TipSet {
|
|||||||
Messages: msgcid,
|
Messages: msgcid,
|
||||||
ParentMessageReceipts: dummyCid,
|
ParentMessageReceipts: dummyCid,
|
||||||
|
|
||||||
BlockSig: types.Signature{Type: types.KTBLS},
|
BlockSig: &types.Signature{Type: types.KTBLS},
|
||||||
BLSAggregate: types.Signature{Type: types.KTBLS},
|
BLSAggregate: types.Signature{Type: types.KTBLS},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -27,7 +27,7 @@ func TestTsCache(t *testing.T) {
|
|||||||
ParentStateRoot: dummyCid,
|
ParentStateRoot: dummyCid,
|
||||||
Messages: dummyCid,
|
Messages: dummyCid,
|
||||||
ParentMessageReceipts: dummyCid,
|
ParentMessageReceipts: dummyCid,
|
||||||
BlockSig: types.Signature{Type: types.KTBLS},
|
BlockSig: &types.Signature{Type: types.KTBLS},
|
||||||
BLSAggregate: types.Signature{Type: types.KTBLS},
|
BLSAggregate: types.Signature{Type: types.KTBLS},
|
||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -69,7 +69,7 @@ func TestTsCacheNulls(t *testing.T) {
|
|||||||
ParentStateRoot: dummyCid,
|
ParentStateRoot: dummyCid,
|
||||||
Messages: dummyCid,
|
Messages: dummyCid,
|
||||||
ParentMessageReceipts: dummyCid,
|
ParentMessageReceipts: dummyCid,
|
||||||
BlockSig: types.Signature{Type: types.KTBLS},
|
BlockSig: &types.Signature{Type: types.KTBLS},
|
||||||
BLSAggregate: types.Signature{Type: types.KTBLS},
|
BLSAggregate: types.Signature{Type: types.KTBLS},
|
||||||
}})
|
}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -501,6 +501,10 @@ func (syncer *Syncer) ValidateBlock(ctx context.Context, b *types.FullBlock) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fast checks first
|
// fast checks first
|
||||||
|
if h.BlockSig == nil {
|
||||||
|
return xerrors.Errorf("block had nil signature")
|
||||||
|
}
|
||||||
|
|
||||||
if h.Timestamp > uint64(time.Now().Unix()+build.AllowableClockDrift) {
|
if h.Timestamp > uint64(time.Now().Unix()+build.AllowableClockDrift) {
|
||||||
return xerrors.Errorf("block was from the future")
|
return xerrors.Errorf("block was from the future")
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,9 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types
|
|||||||
return &types.BlockHeader{
|
return &types.BlockHeader{
|
||||||
Miner: addr,
|
Miner: addr,
|
||||||
ElectionProof: []byte("cats won the election"),
|
ElectionProof: []byte("cats won the election"),
|
||||||
Tickets: []*types.Ticket{
|
Ticket: &types.Ticket{
|
||||||
{
|
|
||||||
VRFProof: []byte(fmt.Sprintf("====%d=====", ticketNonce)),
|
VRFProof: []byte(fmt.Sprintf("====%d=====", ticketNonce)),
|
||||||
},
|
},
|
||||||
},
|
|
||||||
Parents: pcids,
|
Parents: pcids,
|
||||||
ParentMessageReceipts: c,
|
ParentMessageReceipts: c,
|
||||||
BLSAggregate: types.Signature{Type: types.KTBLS, Data: []byte("boo! im a signature")},
|
BLSAggregate: types.Signature{Type: types.KTBLS, Data: []byte("boo! im a signature")},
|
||||||
@ -48,7 +46,7 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types
|
|||||||
Messages: c,
|
Messages: c,
|
||||||
Height: height,
|
Height: height,
|
||||||
ParentStateRoot: c,
|
ParentStateRoot: c,
|
||||||
BlockSig: types.Signature{Type: types.KTBLS, Data: []byte("boo! im a signature")},
|
BlockSig: &types.Signature{Type: types.KTBLS, Data: []byte("boo! im a signature")},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user