genesis: Register system actor
This commit is contained in:
parent
d5027bfbb2
commit
a92099258b
@ -42,6 +42,7 @@ From a list of parameters, create a genesis block / initial state
|
||||
The process:
|
||||
- Bootstrap state (MakeInitialStateTree)
|
||||
- Create empty state
|
||||
- Create system actor
|
||||
- Make init actor
|
||||
- Create accounts mappings
|
||||
- Set NextID to MinerStart
|
||||
@ -103,6 +104,16 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
||||
return nil, xerrors.Errorf("failed putting empty object: %w", err)
|
||||
}
|
||||
|
||||
// Create system actor
|
||||
|
||||
sysact, err := SetupSystemActor(bs)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("setup init actor: %w", err)
|
||||
}
|
||||
if err := state.SetActor(actors.SystemAddress, sysact); err != nil {
|
||||
return nil, xerrors.Errorf("set init actor: %w", err)
|
||||
}
|
||||
|
||||
// Create init actor
|
||||
|
||||
initact, err := SetupInitActor(bs, template.NetworkName, template.Accounts)
|
||||
|
@ -3,6 +3,7 @@ package genesis
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
||||
@ -45,15 +46,14 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
|
||||
|
||||
var maddr address.Address
|
||||
{
|
||||
constructorParams := &miner.ConstructorParams{
|
||||
OwnerAddr: m.Owner,
|
||||
WorkerAddr: m.Worker,
|
||||
constructorParams := &power.CreateMinerParams{
|
||||
Worker: m.Worker,
|
||||
SectorSize: m.SectorSize,
|
||||
PeerId: m.PeerId,
|
||||
Peer: m.PeerId,
|
||||
}
|
||||
|
||||
params := mustEnc(constructorParams)
|
||||
rval, err := doExecValue(ctx, vm, actors.StoragePowerAddress, m.Worker, m.PowerBalance, actors.SPAMethods.CreateMiner, params)
|
||||
rval, err := doExecValue(ctx, vm, actors.StoragePowerAddress, m.Owner, m.PowerBalance, actors.SPAMethods.CreateMiner, params)
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
||||
}
|
||||
|
28
chain/gen/genesis/t00_system.go
Normal file
28
chain/gen/genesis/t00_system.go
Normal file
@ -0,0 +1,28 @@
|
||||
package genesis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
bstore "github.com/ipfs/go-ipfs-blockstore"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
)
|
||||
|
||||
func SetupSystemActor(bs bstore.Blockstore) (*types.Actor, error) {
|
||||
var st adt.EmptyValue
|
||||
|
||||
cst := cbor.NewCborStore(bs)
|
||||
|
||||
statecid, err := cst.Put(context.TODO(), &st)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
act := &types.Actor{
|
||||
Code: builtin.SystemActorCodeID,
|
||||
Head: statecid,
|
||||
}
|
||||
|
||||
return act, nil
|
||||
}
|
@ -7,16 +7,18 @@ import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
vmr "github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/market"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/multisig"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/system"
|
||||
vmr "github.com/filecoin-project/specs-actors/actors/runtime"
|
||||
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||
@ -38,6 +40,7 @@ func NewInvoker() *invoker {
|
||||
}
|
||||
|
||||
// add builtInCode using: register(cid, singleton)
|
||||
inv.Register(builtin.SystemActorCodeID, system.Actor{}, adt.EmptyValue{})
|
||||
inv.Register(actors.InitCodeCid, actors.InitActor{}, actors.InitActorState{})
|
||||
inv.Register(actors.CronCodeCid, actors.CronActor{}, actors.CronActorState{})
|
||||
inv.Register(actors.StoragePowerCodeCid, actors.StoragePowerActor{}, actors.StoragePowerState{})
|
||||
|
4
go.mod
4
go.mod
@ -23,7 +23,7 @@ require (
|
||||
github.com/filecoin-project/go-paramfetch v0.0.1
|
||||
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200210220012-eb75ec747d6b
|
||||
github.com/filecoin-project/go-statestore v0.1.0
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200214164743-74b45ccaaff9
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200214213304-f699edd41914
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||
github.com/gorilla/mux v1.7.3
|
||||
@ -115,5 +115,3 @@ replace github.com/golangci/golangci-lint => github.com/golangci/golangci-lint v
|
||||
replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi
|
||||
|
||||
replace github.com/coreos/go-systemd => github.com/coreos/go-systemd/v22 v22.0.0
|
||||
|
||||
replace github.com/filecoin-project/specs-actors => /home/magik6k/gohack/github.com/filecoin-project/specs-actors
|
||||
|
2
go.sum
2
go.sum
@ -130,6 +130,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200212234534-e2abd13ec4b1 h1:j
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200212234534-e2abd13ec4b1/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200214164743-74b45ccaaff9 h1:i6hLXvnse+C7DE2/1anKrlKahBFbusa066LG0K/v8KM=
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200214164743-74b45ccaaff9/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200214213304-f699edd41914 h1:3AqKuA/ha8amt24Ya3l/45+PfFDlHcm4Jt1YWKuw6A0=
|
||||
github.com/filecoin-project/specs-actors v0.0.0-20200214213304-f699edd41914/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 h1:EzDjxMg43q1tA2c0MV3tNbaontnHLplHyFF6M5KiVP0=
|
||||
|
Loading…
Reference in New Issue
Block a user