2019-07-25 22:15:03 +00:00
|
|
|
package gen
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
|
2019-09-17 01:56:37 +00:00
|
|
|
amt "github.com/filecoin-project/go-amt-ipld"
|
2019-10-22 19:29:05 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
|
|
|
"github.com/ipfs/go-datastore"
|
|
|
|
hamt "github.com/ipfs/go-hamt-ipld"
|
|
|
|
bstore "github.com/ipfs/go-ipfs-blockstore"
|
|
|
|
peer "github.com/libp2p/go-libp2p-peer"
|
|
|
|
cbg "github.com/whyrusleeping/cbor-gen"
|
|
|
|
"golang.org/x/xerrors"
|
|
|
|
|
2019-10-18 04:47:41 +00:00
|
|
|
"github.com/filecoin-project/lotus/build"
|
|
|
|
actors "github.com/filecoin-project/lotus/chain/actors"
|
|
|
|
"github.com/filecoin-project/lotus/chain/address"
|
|
|
|
"github.com/filecoin-project/lotus/chain/state"
|
|
|
|
"github.com/filecoin-project/lotus/chain/store"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
"github.com/filecoin-project/lotus/chain/vm"
|
2019-11-25 04:45:13 +00:00
|
|
|
"github.com/filecoin-project/lotus/genesis"
|
2019-07-25 22:15:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type GenesisBootstrap struct {
|
|
|
|
Genesis *types.BlockHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetupInitActor(bs bstore.Blockstore, addrs []address.Address) (*types.Actor, error) {
|
|
|
|
var ias actors.InitActorState
|
|
|
|
ias.NextID = 100
|
|
|
|
|
|
|
|
cst := hamt.CSTFromBstore(bs)
|
|
|
|
amap := hamt.NewNode(cst)
|
|
|
|
|
|
|
|
for i, a := range addrs {
|
|
|
|
if err := amap.Set(context.TODO(), string(a.Bytes()), 100+uint64(i)); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ias.NextID += uint64(len(addrs))
|
|
|
|
if err := amap.Flush(context.TODO()); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
amapcid, err := cst.Put(context.TODO(), amap)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
ias.AddressMap = amapcid
|
|
|
|
|
|
|
|
statecid, err := cst.Put(context.TODO(), &ias)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
act := &types.Actor{
|
2019-10-21 18:12:11 +00:00
|
|
|
Code: actors.InitCodeCid,
|
2019-07-25 22:15:03 +00:00
|
|
|
Head: statecid,
|
|
|
|
}
|
|
|
|
|
|
|
|
return act, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeInitialStateTree(bs bstore.Blockstore, actmap map[address.Address]types.BigInt) (*state.StateTree, error) {
|
|
|
|
cst := hamt.CSTFromBstore(bs)
|
|
|
|
state, err := state.NewStateTree(cst)
|
|
|
|
if err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("making new state tree: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
emptyobject, err := cst.Put(context.TODO(), map[string]string{})
|
|
|
|
if err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("failed putting empty object: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var addrs []address.Address
|
|
|
|
for a := range actmap {
|
|
|
|
addrs = append(addrs, a)
|
|
|
|
}
|
|
|
|
|
|
|
|
initact, err := SetupInitActor(bs, addrs)
|
|
|
|
if err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("setup init actor: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-10-21 18:12:11 +00:00
|
|
|
if err := state.SetActor(actors.InitAddress, initact); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("set init actor: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 17:34:59 +00:00
|
|
|
spact, err := SetupStoragePowerActor(bs)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("setup storage market actor: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := state.SetActor(actors.StoragePowerAddress, spact); err != nil {
|
|
|
|
return nil, xerrors.Errorf("set storage market actor: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-07-25 22:15:03 +00:00
|
|
|
smact, err := SetupStorageMarketActor(bs)
|
|
|
|
if err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("setup storage market actor: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-10-22 17:34:59 +00:00
|
|
|
if err := state.SetActor(actors.StorageMarketAddress, smact); err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("set storage market actor: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 16:47:42 +00:00
|
|
|
netAmt := types.FromFil(build.TotalFilecoin)
|
2019-09-12 23:48:03 +00:00
|
|
|
for _, amt := range actmap {
|
|
|
|
netAmt = types.BigSub(netAmt, amt)
|
|
|
|
}
|
|
|
|
|
2019-07-25 22:15:03 +00:00
|
|
|
err = state.SetActor(actors.NetworkAddress, &types.Actor{
|
2019-10-21 18:12:11 +00:00
|
|
|
Code: actors.AccountCodeCid,
|
2019-09-12 23:48:03 +00:00
|
|
|
Balance: netAmt,
|
2019-07-25 22:15:03 +00:00
|
|
|
Head: emptyobject,
|
|
|
|
})
|
|
|
|
if err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("set network account actor: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-09-12 23:48:03 +00:00
|
|
|
err = state.SetActor(actors.BurntFundsAddress, &types.Actor{
|
2019-10-21 18:12:11 +00:00
|
|
|
Code: actors.AccountCodeCid,
|
2019-09-12 23:48:03 +00:00
|
|
|
Balance: types.NewInt(0),
|
|
|
|
Head: emptyobject,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("set burnt funds account actor: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-07-25 22:15:03 +00:00
|
|
|
for a, v := range actmap {
|
|
|
|
err = state.SetActor(a, &types.Actor{
|
2019-10-21 18:12:11 +00:00
|
|
|
Code: actors.AccountCodeCid,
|
2019-07-25 22:15:03 +00:00
|
|
|
Balance: v,
|
|
|
|
Head: emptyobject,
|
|
|
|
})
|
|
|
|
if err != nil {
|
2019-09-10 02:05:24 +00:00
|
|
|
return nil, xerrors.Errorf("setting account from actmap: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state, nil
|
|
|
|
}
|
|
|
|
|
2019-10-22 17:34:59 +00:00
|
|
|
func SetupStoragePowerActor(bs bstore.Blockstore) (*types.Actor, error) {
|
2019-09-10 02:05:24 +00:00
|
|
|
cst := hamt.CSTFromBstore(bs)
|
|
|
|
nd := hamt.NewNode(cst)
|
|
|
|
emptyhamt, err := cst.Put(context.TODO(), nd)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-11-13 21:16:17 +00:00
|
|
|
blks := amt.WrapBlockstore(bs)
|
|
|
|
emptyamt, err := amt.FromArray(blks, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("amt build failed: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-10-11 22:59:36 +00:00
|
|
|
sms := &actors.StoragePowerState{
|
2019-11-13 21:16:17 +00:00
|
|
|
Miners: emptyhamt,
|
|
|
|
ProvingBuckets: emptyamt,
|
|
|
|
TotalStorage: types.NewInt(0),
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-09-10 02:05:24 +00:00
|
|
|
stcid, err := cst.Put(context.TODO(), sms)
|
2019-07-25 22:15:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &types.Actor{
|
2019-10-21 18:12:11 +00:00
|
|
|
Code: actors.StoragePowerCodeCid,
|
2019-07-25 22:15:03 +00:00
|
|
|
Head: stcid,
|
|
|
|
Nonce: 0,
|
|
|
|
Balance: types.NewInt(0),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2019-10-22 17:34:59 +00:00
|
|
|
func SetupStorageMarketActor(bs bstore.Blockstore) (*types.Actor, error) {
|
|
|
|
cst := hamt.CSTFromBstore(bs)
|
|
|
|
nd := hamt.NewNode(cst)
|
|
|
|
emptyHAMT, err := cst.Put(context.TODO(), nd)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
blks := amt.WrapBlockstore(bs)
|
|
|
|
|
|
|
|
emptyAMT, err := amt.FromArray(blks, nil)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("amt build failed: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
sms := &actors.StorageMarketState{
|
|
|
|
Balances: emptyHAMT,
|
|
|
|
Deals: emptyAMT,
|
|
|
|
NextDealID: 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
stcid, err := cst.Put(context.TODO(), sms)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &types.Actor{
|
|
|
|
Code: actors.StorageMarketCodeCid,
|
|
|
|
Head: stcid,
|
|
|
|
Nonce: 0,
|
|
|
|
Balance: types.NewInt(0),
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2019-08-15 02:30:21 +00:00
|
|
|
type GenMinerCfg struct {
|
2019-09-06 06:26:02 +00:00
|
|
|
Owners []address.Address
|
|
|
|
Workers []address.Address
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-11-25 04:45:13 +00:00
|
|
|
PreSeals map[string]genesis.GenesisMiner
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
// The addresses of the created miner, this is set by the genesis setup
|
|
|
|
MinerAddrs []address.Address
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
PeerIDs []peer.ID
|
2019-08-15 02:30:21 +00:00
|
|
|
}
|
|
|
|
|
2019-09-10 19:58:45 +00:00
|
|
|
func mustEnc(i cbg.CBORMarshaler) []byte {
|
2019-08-15 02:30:21 +00:00
|
|
|
enc, err := actors.SerializeParams(i)
|
|
|
|
if err != nil {
|
2019-11-16 23:41:14 +00:00
|
|
|
panic(err) // ok
|
2019-08-15 02:30:21 +00:00
|
|
|
}
|
|
|
|
return enc
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, gmcfg *GenMinerCfg) (cid.Cid, error) {
|
2019-10-15 04:33:29 +00:00
|
|
|
vm, err := vm.NewVM(sroot, 0, nil, actors.NetworkAddress, cs.Blockstore())
|
2019-08-15 02:30:21 +00:00
|
|
|
if err != nil {
|
2019-08-15 18:45:32 +00:00
|
|
|
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
|
2019-08-15 02:30:21 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
for i := 0; i < len(gmcfg.Workers); i++ {
|
|
|
|
owner := gmcfg.Owners[i]
|
|
|
|
worker := gmcfg.Workers[i]
|
|
|
|
pid := gmcfg.PeerIDs[i]
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-10 19:58:45 +00:00
|
|
|
params := mustEnc(&actors.CreateStorageMinerParams{
|
2019-09-06 06:26:02 +00:00
|
|
|
Owner: owner,
|
|
|
|
Worker: worker,
|
2019-10-16 07:07:16 +00:00
|
|
|
SectorSize: build.SectorSizes[0],
|
2019-09-06 06:26:02 +00:00
|
|
|
PeerID: pid,
|
|
|
|
})
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-13 01:06:06 +00:00
|
|
|
// TODO: hardcoding 7000000 here is a little fragile, it changes any
|
|
|
|
// time anyone changes the initial account allocations
|
2019-10-19 08:06:41 +00:00
|
|
|
rval, err := doExecValue(ctx, vm, actors.StoragePowerAddress, owner, types.FromFil(6500), actors.SPAMethods.CreateStorageMiner, params)
|
2019-09-06 06:26:02 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
|
|
|
}
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
maddr, err := address.NewFromBytes(rval)
|
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
gmcfg.MinerAddrs = append(gmcfg.MinerAddrs, maddr)
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-10 19:58:45 +00:00
|
|
|
params = mustEnc(&actors.UpdateStorageParams{Delta: types.NewInt(5000)})
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-10-19 08:06:41 +00:00
|
|
|
_, err = doExec(ctx, vm, actors.StoragePowerAddress, maddr, actors.SPAMethods.UpdateStorage, params)
|
2019-09-06 06:26:02 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("failed to update total storage: %w", err)
|
|
|
|
}
|
2019-08-15 18:45:32 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
// UGLY HACKY MODIFICATION OF MINER POWER
|
2019-08-15 18:45:32 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
// we have to flush the vm here because it buffers stuff internally for perf reasons
|
|
|
|
if _, err := vm.Flush(ctx); err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("vm.Flush failed: %w", err)
|
|
|
|
}
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
st := vm.StateTree()
|
|
|
|
mact, err := st.GetActor(maddr)
|
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("get miner actor failed: %w", err)
|
|
|
|
}
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
cst := hamt.CSTFromBstore(cs.Blockstore())
|
|
|
|
var mstate actors.StorageMinerActorState
|
|
|
|
if err := cst.Get(ctx, mact.Head, &mstate); err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("getting miner actor state failed: %w", err)
|
|
|
|
}
|
2019-11-25 04:45:13 +00:00
|
|
|
mstate.Power = types.NewInt(build.SectorSizes[0])
|
2019-09-06 06:26:02 +00:00
|
|
|
|
2019-11-22 16:41:09 +00:00
|
|
|
blks := amt.WrapBlockstore(cs.Blockstore())
|
2019-11-25 04:45:13 +00:00
|
|
|
|
|
|
|
ps, ok := gmcfg.PreSeals[maddr.String()]
|
|
|
|
if ok {
|
|
|
|
for _, s := range ps.Sectors {
|
|
|
|
nssroot, err := actors.AddToSectorSet(ctx, blks, mstate.Sectors, s.SectorID, s.CommD[:], s.CommR[:])
|
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, xerrors.Errorf("failed to add fake sector to sector set: %w", err)
|
|
|
|
}
|
|
|
|
mstate.Sectors = nssroot
|
|
|
|
mstate.ProvingSet = nssroot
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.Warning("No preseals for miner: ", maddr)
|
2019-11-22 16:41:09 +00:00
|
|
|
}
|
|
|
|
|
2019-09-10 19:58:45 +00:00
|
|
|
nstate, err := cst.Put(ctx, &mstate)
|
2019-09-06 06:26:02 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
2019-08-15 02:30:21 +00:00
|
|
|
|
2019-09-06 06:26:02 +00:00
|
|
|
mact.Head = nstate
|
|
|
|
if err := st.SetActor(maddr, mact); err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
|
|
|
// End of super haxx
|
2019-08-15 02:30:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return vm.Flush(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func doExec(ctx context.Context, vm *vm.VM, to, from address.Address, method uint64, params []byte) ([]byte, error) {
|
2019-09-13 01:06:06 +00:00
|
|
|
return doExecValue(ctx, vm, to, from, types.NewInt(0), method, params)
|
|
|
|
}
|
|
|
|
|
|
|
|
func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value types.BigInt, method uint64, params []byte) ([]byte, error) {
|
2019-09-06 06:26:02 +00:00
|
|
|
act, err := vm.StateTree().GetActor(from)
|
|
|
|
if err != nil {
|
|
|
|
return nil, xerrors.Errorf("doExec failed to get from actor: %w", err)
|
|
|
|
}
|
|
|
|
|
2019-08-15 02:30:21 +00:00
|
|
|
ret, err := vm.ApplyMessage(context.TODO(), &types.Message{
|
|
|
|
To: to,
|
|
|
|
From: from,
|
|
|
|
Method: method,
|
|
|
|
Params: params,
|
|
|
|
GasLimit: types.NewInt(1000000),
|
|
|
|
GasPrice: types.NewInt(0),
|
2019-09-13 01:06:06 +00:00
|
|
|
Value: value,
|
2019-09-06 06:26:02 +00:00
|
|
|
Nonce: act.Nonce,
|
2019-08-15 02:30:21 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
2019-09-10 19:58:45 +00:00
|
|
|
return nil, xerrors.Errorf("doExec apply message failed: %w", err)
|
2019-08-15 02:30:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ret.ExitCode != 0 {
|
|
|
|
return nil, fmt.Errorf("failed to call method: %s", ret.ActorErr)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret.Return, nil
|
|
|
|
}
|
|
|
|
|
2019-08-30 02:59:54 +00:00
|
|
|
func MakeGenesisBlock(bs bstore.Blockstore, balances map[address.Address]types.BigInt, gmcfg *GenMinerCfg, ts uint64) (*GenesisBootstrap, error) {
|
2019-08-15 02:30:21 +00:00
|
|
|
ctx := context.Background()
|
2019-07-25 22:15:03 +00:00
|
|
|
|
|
|
|
state, err := MakeInitialStateTree(bs, balances)
|
|
|
|
if err != nil {
|
2019-08-15 18:45:32 +00:00
|
|
|
return nil, xerrors.Errorf("make initial state tree failed: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stateroot, err := state.Flush()
|
|
|
|
if err != nil {
|
2019-08-15 18:45:32 +00:00
|
|
|
return nil, xerrors.Errorf("flush state tree failed: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
2019-08-15 02:30:21 +00:00
|
|
|
// temp chainstore
|
|
|
|
cs := store.NewChainStore(bs, datastore.NewMapDatastore())
|
|
|
|
stateroot, err = SetupStorageMiners(ctx, cs, stateroot, gmcfg)
|
|
|
|
if err != nil {
|
2019-08-15 18:45:32 +00:00
|
|
|
return nil, xerrors.Errorf("setup storage miners failed: %w", err)
|
2019-08-15 02:30:21 +00:00
|
|
|
}
|
|
|
|
|
2019-09-17 01:56:37 +00:00
|
|
|
blks := amt.WrapBlockstore(bs)
|
2019-08-01 20:40:47 +00:00
|
|
|
|
2019-09-17 01:56:37 +00:00
|
|
|
emptyroot, err := amt.FromArray(blks, nil)
|
2019-07-25 22:15:03 +00:00
|
|
|
if err != nil {
|
2019-09-17 01:56:37 +00:00
|
|
|
return nil, xerrors.Errorf("amt build failed: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
2019-08-22 01:29:19 +00:00
|
|
|
|
|
|
|
mm := &types.MsgMeta{
|
2019-08-01 20:40:47 +00:00
|
|
|
BlsMessages: emptyroot,
|
|
|
|
SecpkMessages: emptyroot,
|
2019-08-22 01:29:19 +00:00
|
|
|
}
|
|
|
|
mmb, err := mm.ToStorageBlock()
|
2019-08-01 20:40:47 +00:00
|
|
|
if err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return nil, xerrors.Errorf("serializing msgmeta failed: %w", err)
|
|
|
|
}
|
|
|
|
if err := bs.Put(mmb); err != nil {
|
|
|
|
return nil, xerrors.Errorf("putting msgmeta block to blockstore: %w", err)
|
2019-08-01 20:40:47 +00:00
|
|
|
}
|
|
|
|
|
2019-08-29 22:59:12 +00:00
|
|
|
log.Infof("Empty Genesis root: %s", emptyroot)
|
2019-07-25 22:15:03 +00:00
|
|
|
|
2019-08-15 02:30:21 +00:00
|
|
|
genesisticket := &types.Ticket{
|
2019-10-27 09:18:27 +00:00
|
|
|
VRFProof: []byte("vrf proof0000000vrf proof0000000"),
|
2019-08-15 02:30:21 +00:00
|
|
|
}
|
|
|
|
|
2019-07-25 22:15:03 +00:00
|
|
|
b := &types.BlockHeader{
|
2019-11-21 22:21:45 +00:00
|
|
|
Miner: actors.InitAddress,
|
|
|
|
Ticket: genesisticket,
|
|
|
|
EPostProof: types.EPostProof{
|
|
|
|
Proof: []byte("not a real proof"),
|
|
|
|
PostRand: []byte("i guess this is kinda random"),
|
|
|
|
},
|
2019-09-27 23:55:15 +00:00
|
|
|
Parents: []cid.Cid{},
|
|
|
|
Height: 0,
|
|
|
|
ParentWeight: types.NewInt(0),
|
|
|
|
ParentStateRoot: stateroot,
|
|
|
|
Messages: mmb.Cid(),
|
|
|
|
ParentMessageReceipts: emptyroot,
|
|
|
|
BLSAggregate: types.Signature{Type: types.KTBLS, Data: []byte("signatureeee")},
|
2019-11-19 20:05:21 +00:00
|
|
|
BlockSig: &types.Signature{Type: types.KTBLS, Data: []byte("block signatureeee")},
|
2019-09-27 23:55:15 +00:00
|
|
|
Timestamp: ts,
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sb, err := b.ToStorageBlock()
|
|
|
|
if err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return nil, xerrors.Errorf("serializing block header failed: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if err := bs.Put(sb); err != nil {
|
2019-08-22 01:29:19 +00:00
|
|
|
return nil, xerrors.Errorf("putting header to blockstore: %w", err)
|
2019-07-25 22:15:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return &GenesisBootstrap{
|
|
|
|
Genesis: b,
|
|
|
|
}, nil
|
|
|
|
}
|