diff --git a/chain/gen/genesis/genesis.go b/chain/gen/genesis/genesis.go index a30ebf25e..2cbf7fd44 100644 --- a/chain/gen/genesis/genesis.go +++ b/chain/gen/genesis/genesis.go @@ -32,7 +32,6 @@ var log = logging.Logger("genesis") type GenesisBootstrap struct { Genesis *types.BlockHeader } - /* From a list of parameters, create a genesis block / initial state @@ -47,6 +46,7 @@ The process: - Setup Cron - Create empty power actor - Create empty market + - Create verified registry - Setup burnt fund address - Initialize account / msig balances - Instantiate early vm with genesis syscalls @@ -164,6 +164,15 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge return nil, xerrors.Errorf("set market actor: %w", err) } + // Create verified registry + verifact, err := SetupVerifiedRegistryActor(bs) + if err != nil { + return nil, xerrors.Errorf("setup storage market actor: %w", err) + } + if err := state.SetActor(builtin.VerifiedRegistryActorAddr, verifact); err != nil { + return nil, xerrors.Errorf("set market actor: %w", err) + } + // Setup burnt-funds err = state.SetActor(builtin.BurntFundsActorAddr, &types.Actor{ Code: builtin.AccountActorCodeID, diff --git a/chain/gen/genesis/t06_vreg.go b/chain/gen/genesis/t06_vreg.go new file mode 100644 index 000000000..f7a1c29bf --- /dev/null +++ b/chain/gen/genesis/t06_vreg.go @@ -0,0 +1,44 @@ +package genesis + +import ( + "context" + "crypto/rand" + + "github.com/filecoin-project/go-address" + "github.com/ipfs/go-hamt-ipld" + bstore "github.com/ipfs/go-ipfs-blockstore" + cbor "github.com/ipfs/go-ipld-cbor" + + "github.com/filecoin-project/specs-actors/actors/builtin" + "github.com/filecoin-project/specs-actors/actors/builtin/verifreg" + + "github.com/filecoin-project/lotus/chain/types" +) + +func SetupVerifiedRegistryActor(bs bstore.Blockstore) (*types.Actor, error) { + cst := cbor.NewCborStore(bs) + + h, err := cst.Put(context.TODO(), hamt.NewNode(cst, hamt.UseTreeBitWidth(5))) + if err != nil { + return nil, err + } + + var r [32]byte // TODO: grab from genesis template + _, _ = rand.Read(r[:]) + k, _ := address.NewSecp256k1Address(r[:]) + + sms := verifreg.ConstructState(h, k) + + stcid, err := cst.Put(context.TODO(), sms) + if err != nil { + return nil, err + } + + act := &types.Actor{ + Code: builtin.VerifiedRegistryActorCodeID, + Head: stcid, + Balance: types.NewInt(0), + } + + return act, nil +}