Setup datacap actor
This commit is contained in:
parent
bc4f9bb805
commit
530e6a02fc
59
chain/gen/genesis/f07_dcap.go
Normal file
59
chain/gen/genesis/f07_dcap.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package genesis
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-state-types/builtin"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/datacap"
|
||||||
|
|
||||||
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
actorstypes "github.com/filecoin-project/go-state-types/actors"
|
||||||
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
|
|
||||||
|
bstore "github.com/filecoin-project/lotus/blockstore"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
var GovernorId address.Address
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
idk, err := address.NewFromString("t085")
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
GovernorId = idk
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetupDatacapActor(ctx context.Context, bs bstore.Blockstore, av actorstypes.Version) (*types.Actor, error) {
|
||||||
|
cst := cbor.NewCborStore(bs)
|
||||||
|
vst, err := datacap.MakeState(adt.WrapStore(ctx, cbor.NewCborStore(bs)), av, GovernorId, builtin.DefaultHamtBitwidth)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
statecid, err := cst.Put(ctx, vst.GetState())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
actcid, ok := actors.GetActorCodeID(av, actors.DatacapKey)
|
||||||
|
if !ok {
|
||||||
|
return nil, xerrors.Errorf("failed to get verifreg actor code ID for actors version %d", av)
|
||||||
|
}
|
||||||
|
|
||||||
|
act := &types.Actor{
|
||||||
|
Code: actcid,
|
||||||
|
Head: statecid,
|
||||||
|
Balance: big.Zero(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return act, nil
|
||||||
|
}
|
@ -6,6 +6,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/datacap"
|
||||||
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
cbor "github.com/ipfs/go-ipld-cbor"
|
||||||
@ -215,6 +217,15 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return nil, nil, xerrors.Errorf("set verified registry actor: %w", err)
|
return nil, nil, xerrors.Errorf("set verified registry actor: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create verified registry
|
||||||
|
dcapact, err := SetupDatacapActor(ctx, bs, av)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, xerrors.Errorf("setup datacap actor: %w", err)
|
||||||
|
}
|
||||||
|
if err := state.SetActor(datacap.Address, dcapact); err != nil {
|
||||||
|
return nil, nil, xerrors.Errorf("set datacap actor: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
bact, err := MakeAccountActor(ctx, cst, av, builtin.BurntFundsActorAddr, big.Zero())
|
bact, err := MakeAccountActor(ctx, cst, av, builtin.BurntFundsActorAddr, big.Zero())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, xerrors.Errorf("setup burnt funds actor state: %w", err)
|
return nil, nil, xerrors.Errorf("setup burnt funds actor state: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user