From f1dbd35407269313df4fa8ab2405304376aed7b5 Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sat, 21 Mar 2020 15:25:00 -0700 Subject: [PATCH] change genesis fields to match interop --- chain/events/events_test.go | 4 ++-- chain/events/tscache_test.go | 4 ++-- chain/gen/genesis/genesis.go | 9 +++------ chain/gen/mining.go | 4 ++-- chain/sync.go | 2 +- chain/types/blockheader.go | 2 +- chain/types/blockheader_test.go | 2 +- chain/types/cbor_gen.go | 16 ++++++++++++++-- chain/types/mock/chain.go | 2 +- node/hello/cbor_gen.go | 2 +- 10 files changed, 28 insertions(+), 19 deletions(-) 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 ab16fbcd5..e1c3e4474 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -267,8 +267,20 @@ func (t *BlockHeader) UnmarshalCBOR(r io.Reader) error { { - if err := t.BLSAggregate.UnmarshalCBOR(br); err != nil { - return xerrors.Errorf("unmarshaling t.BLSAggregate: %w", err) + 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) + } } } 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/node/hello/cbor_gen.go b/node/hello/cbor_gen.go index f65beaeff..5185496b9 100644 --- a/node/hello/cbor_gen.go +++ b/node/hello/cbor_gen.go @@ -7,7 +7,7 @@ import ( "io" "github.com/filecoin-project/specs-actors/actors/abi" - cid "github.com/ipfs/go-cid" + "github.com/ipfs/go-cid" cbg "github.com/whyrusleeping/cbor-gen" xerrors "golang.org/x/xerrors" )