diff --git a/api/cbor_gen.go b/api/cbor_gen.go index 2a72de578..3e80fb67d 100644 --- a/api/cbor_gen.go +++ b/api/cbor_gen.go @@ -124,7 +124,7 @@ func (t *PaymentInfo) UnmarshalCBOR(r io.Reader) error { { if err := t.Channel.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Channel: %w", err) } } diff --git a/chain/blocksync/cbor_gen.go b/chain/blocksync/cbor_gen.go index 60cb1c0b3..6668eb3a6 100644 --- a/chain/blocksync/cbor_gen.go +++ b/chain/blocksync/cbor_gen.go @@ -7,7 +7,7 @@ import ( "io" "github.com/filecoin-project/lotus/chain/types" - "github.com/ipfs/go-cid" + cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" ) diff --git a/chain/events/events_test.go b/chain/events/events_test.go index eaddad69b..c599b676b 100644 --- a/chain/events/events_test.go +++ b/chain/events/events_test.go @@ -70,7 +70,7 @@ func makeTs(t *testing.T, h abi.ChainEpoch, msgcid cid.Cid) *types.TipSet { ParentMessageReceipts: dummyCid, BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS}, - BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS}, + BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS}, }, { Height: h, @@ -83,7 +83,7 @@ func makeTs(t *testing.T, h abi.ChainEpoch, msgcid cid.Cid) *types.TipSet { ParentMessageReceipts: dummyCid, BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS}, - BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS}, + BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS}, }, }) diff --git a/chain/events/tscache_test.go b/chain/events/tscache_test.go index 62a8a2d25..1278e58e9 100644 --- a/chain/events/tscache_test.go +++ b/chain/events/tscache_test.go @@ -30,7 +30,7 @@ func TestTsCache(t *testing.T) { Messages: dummyCid, ParentMessageReceipts: dummyCid, BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS}, - BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS}, + BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS}, }}) if err != nil { t.Fatal(err) @@ -72,7 +72,7 @@ func TestTsCacheNulls(t *testing.T) { Messages: dummyCid, ParentMessageReceipts: dummyCid, BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS}, - BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS}, + BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS}, }}) if err != nil { t.Fatal(err) diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index 0e46b0079..35f69d221 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -5,10 +5,8 @@ import ( "encoding/json" "github.com/filecoin-project/go-amt-ipld/v2" - "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/builtin/account" - "github.com/filecoin-project/specs-actors/actors/crypto" "github.com/filecoin-project/specs-actors/actors/runtime" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" @@ -254,10 +252,9 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Sys } b := &types.BlockHeader{ - Miner: builtin.InitActorAddr, + Miner: builtin.SystemActorAddr, Ticket: genesisticket, EPostProof: types.EPostProof{ - Proofs: []abi.PoStProof{{ProofBytes: []byte("not a real proof")}}, PostRand: []byte("i guess this is kinda random"), }, Parents: []cid.Cid{}, @@ -266,8 +263,8 @@ func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Sys ParentStateRoot: stateroot, Messages: mmb.Cid(), ParentMessageReceipts: emptyroot, - BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("signatureeee")}, - BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("block signatureeee")}, + BLSAggregate: nil, + BlockSig: nil, Timestamp: template.Timestamp, } diff --git a/chain/gen/mining.go b/chain/gen/mining.go index 5b8bafa85..083d972c1 100644 --- a/chain/gen/mining.go +++ b/chain/gen/mining.go @@ -133,7 +133,7 @@ func MinerCreateBlock(ctx context.Context, sm *stmgr.StateManager, w *wallet.Wal return fullBlock, nil } -func aggregateSignatures(sigs []crypto.Signature) (crypto.Signature, error) { +func aggregateSignatures(sigs []crypto.Signature) (*crypto.Signature, error) { var blsSigs []bls.Signature for _, s := range sigs { var bsig bls.Signature @@ -142,7 +142,7 @@ func aggregateSignatures(sigs []crypto.Signature) (crypto.Signature, error) { } aggSig := bls.Aggregate(blsSigs) - return crypto.Signature{ + return &crypto.Signature{ Type: crypto.SigTypeBLS, Data: aggSig[:], }, nil diff --git a/chain/sync.go b/chain/sync.go index eeb78b745..87759d422 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -874,7 +874,7 @@ func (syncer *Syncer) checkBlockMessages(ctx context.Context, b *types.FullBlock return nil } -func (syncer *Syncer) verifyBlsAggregate(ctx context.Context, sig crypto.Signature, msgs []cid.Cid, pubks []bls.PublicKey) error { +func (syncer *Syncer) verifyBlsAggregate(ctx context.Context, sig *crypto.Signature, msgs []cid.Cid, pubks []bls.PublicKey) error { _, span := trace.StartSpan(ctx, "syncer.verifyBlsAggregate") defer span.End() span.AddAttributes( diff --git a/chain/types/blockheader.go b/chain/types/blockheader.go index 7d579a261..1bffe2230 100644 --- a/chain/types/blockheader.go +++ b/chain/types/blockheader.go @@ -53,7 +53,7 @@ type BlockHeader struct { Messages cid.Cid // 8 - BLSAggregate crypto.Signature // 9 + BLSAggregate *crypto.Signature // 9 Timestamp uint64 // 10 diff --git a/chain/types/blockheader_test.go b/chain/types/blockheader_test.go index 7a59ccdcc..d46bc1876 100644 --- a/chain/types/blockheader_test.go +++ b/chain/types/blockheader_test.go @@ -36,7 +36,7 @@ func testBlockHeader(t testing.TB) *BlockHeader { }, Parents: []cid.Cid{c, c}, ParentMessageReceipts: c, - BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")}, + BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")}, ParentWeight: NewInt(123125126212), Messages: c, Height: 85919298723, diff --git a/chain/types/cbor_gen.go b/chain/types/cbor_gen.go index 0adccccbb..e1c3e4474 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -9,7 +9,7 @@ import ( "github.com/filecoin-project/specs-actors/actors/abi" "github.com/filecoin-project/specs-actors/actors/crypto" "github.com/filecoin-project/specs-actors/actors/runtime/exitcode" - "github.com/ipfs/go-cid" + cid "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" ) @@ -133,7 +133,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { { if err := t.Miner.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Miner: %w", err) } } @@ -153,7 +153,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { } else { t.Ticket = new(Ticket) if err := t.Ticket.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Ticket pointer: %w", err) } } @@ -163,7 +163,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { { if err := t.EPostProof.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.EPostProof: %w", err) } } @@ -198,7 +198,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { { if err := t.ParentWeight.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.ParentWeight: %w", err) } } @@ -267,9 +267,21 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { { - if err := t.BLSAggregate.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.BLSAggregate = new(crypto.Signature) + if err := t.BLSAggregate.UnmarshalCBOR(br); err != nil { + return xerrors.Errorf("unmarshaling t.BLSAggregate pointer: %w", err) + } + } } // t.Timestamp (uint64) (uint64) @@ -302,7 +314,7 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { } else { t.BlockSig = new(crypto.Signature) if err := t.BlockSig.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.BlockSig pointer: %w", err) } } @@ -707,7 +719,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { { if err := t.To.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.To: %w", err) } } @@ -716,7 +728,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { { if err := t.From.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.From: %w", err) } } @@ -739,7 +751,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { { if err := t.Value.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Value: %w", err) } } @@ -748,7 +760,7 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { { if err := t.GasPrice.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.GasPrice: %w", err) } } @@ -852,7 +864,7 @@ func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error { { if err := t.Message.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Message: %w", err) } } @@ -861,7 +873,7 @@ func (t *SignedMessage) UnmarshalCBOR(r io.Reader) error { { if err := t.Signature.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Signature: %w", err) } } @@ -1026,7 +1038,7 @@ func (t *Actor) UnmarshalCBOR(r io.Reader) error { { if err := t.Balance.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Balance: %w", err) } } @@ -1238,7 +1250,7 @@ func (t *BlockMsg) UnmarshalCBOR(r io.Reader) error { } else { t.Header = new(BlockHeader) if err := t.Header.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Header pointer: %w", err) } } diff --git a/chain/types/mock/chain.go b/chain/types/mock/chain.go index b10ebe728..4b5494e0c 100644 --- a/chain/types/mock/chain.go +++ b/chain/types/mock/chain.go @@ -68,7 +68,7 @@ func MkBlock(parents *types.TipSet, weightInc uint64, ticketNonce uint64) *types }, Parents: pcids, ParentMessageReceipts: c, - BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")}, + BLSAggregate: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")}, ParentWeight: weight, Messages: c, Height: height, diff --git a/go.mod b/go.mod index b15a48922..b8bc49cf2 100644 --- a/go.mod +++ b/go.mod @@ -92,7 +92,7 @@ require ( github.com/prometheus/common v0.4.0 // indirect github.com/stretchr/testify v1.4.0 github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba - github.com/whyrusleeping/cbor-gen v0.0.0-20200222160900-51052a1e8191 + github.com/whyrusleeping/cbor-gen v0.0.0-20200321164527-9340289d0ca7 github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 github.com/whyrusleeping/pubsub v0.0.0-20131020042734-02de8aa2db3d go.opencensus.io v0.22.2 diff --git a/go.sum b/go.sum index 1d1481fc2..3124f53bb 100644 --- a/go.sum +++ b/go.sum @@ -759,6 +759,8 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200123233031-1cdf64d27158/go.mod h1:X github.com/whyrusleeping/cbor-gen v0.0.0-20200206220010-03c9665e2a66/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= github.com/whyrusleeping/cbor-gen v0.0.0-20200222160900-51052a1e8191 h1:TeuxLwKwQy612jEhfVhGJTqLsM2EwMi1eJE052ug+NY= github.com/whyrusleeping/cbor-gen v0.0.0-20200222160900-51052a1e8191/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= +github.com/whyrusleeping/cbor-gen v0.0.0-20200321164527-9340289d0ca7 h1:SVU2yhhHHamTPIMT9kk28KSYdO3ykTZeIp5p+6G9qNk= +github.com/whyrusleeping/cbor-gen v0.0.0-20200321164527-9340289d0ca7/go.mod h1:Xj/M2wWU+QdTdRbu/L/1dIZY8/Wb2K9pAhtroQuxJJI= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f h1:jQa4QT2UP9WYv2nzyawpKMOCl+Z/jW7djv2/J50lj9E= github.com/whyrusleeping/chunker v0.0.0-20181014151217-fe64bd25879f/go.mod h1:p9UJB6dDgdPgMJZs7UjUOdulKyRr9fqkS+6JKAInPy8= github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 h1:EKhdznlJHPMoKr0XTrX+IlJs1LH3lyx2nfr1dOlZ79k= diff --git a/node/hello/cbor_gen.go b/node/hello/cbor_gen.go index 3572e1594..5185496b9 100644 --- a/node/hello/cbor_gen.go +++ b/node/hello/cbor_gen.go @@ -133,7 +133,7 @@ func (t *HelloMessage) UnmarshalCBOR(r io.Reader) error { { if err := t.HeaviestTipSetWeight.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.HeaviestTipSetWeight: %w", err) } } diff --git a/paychmgr/cbor_gen.go b/paychmgr/cbor_gen.go index 158fd5912..abaf760f5 100644 --- a/paychmgr/cbor_gen.go +++ b/paychmgr/cbor_gen.go @@ -110,7 +110,7 @@ func (t *VoucherInfo) UnmarshalCBOR(r io.Reader) error { } else { t.Voucher = new(paych.SignedVoucher) if err := t.Voucher.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Voucher pointer: %w", err) } } @@ -294,7 +294,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { { if err := t.Channel.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Channel: %w", err) } } @@ -304,7 +304,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { { if err := t.Control.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Control: %w", err) } } @@ -314,7 +314,7 @@ func (t *ChannelInfo) UnmarshalCBOR(r io.Reader) error { { if err := t.Target.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Target: %w", err) } } diff --git a/storage/sealing/cbor_gen.go b/storage/sealing/cbor_gen.go index 6fe46d985..42ad7c029 100644 --- a/storage/sealing/cbor_gen.go +++ b/storage/sealing/cbor_gen.go @@ -694,7 +694,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { { if err := t.Ticket.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Ticket: %w", err) } } @@ -729,7 +729,7 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error { { if err := t.Seed.UnmarshalCBOR(br); err != nil { - return err + return xerrors.Errorf("unmarshaling t.Seed: %w", err) } }