genesis: Change template types

This commit is contained in:
Łukasz Magiera 2020-02-12 01:58:55 +01:00
parent 63e801e00f
commit a4f6b739be
13 changed files with 281 additions and 279 deletions

View File

@ -7,11 +7,13 @@ import (
"fmt"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/types"
init_ "github.com/filecoin-project/specs-actors/actors/builtin/init"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
cbor "github.com/ipfs/go-ipld-cbor"
@ -41,11 +43,7 @@ func init() {
type InitActor struct{}
type InitActorState struct {
AddressMap cid.Cid
NextID uint64
}
type InitActorState = init_.State
type iAMethods struct {
Exec uint64

View File

@ -16,16 +16,24 @@ var MultisigCodeCid = builtin.MultisigActorCodeID
var InitCodeCid = builtin.InitActorCodeID
var PaymentChannelCodeCid = builtin.PaymentChannelActorCodeID
var SystemAddress = mustIDAddress(0)
var InitAddress = mustIDAddress(1)
var RewardActor = mustIDAddress(2)
var CronAddress = mustIDAddress(3)
var StoragePowerAddress = mustIDAddress(4)
var StorageMarketAddress = mustIDAddress(5)
var SystemAddress = builtin.SystemActorAddr
var InitAddress = builtin.InitActorAddr
var RewardActor = builtin.RewardActorAddr
var CronAddress = builtin.CronActorAddr
var StoragePowerAddress = builtin.StoragePowerActorAddr
var StorageMarketAddress = builtin.StorageMarketActorAddr
var BurntFundsAddress = builtin.BurntFundsActorAddr
var NetworkAddress = mustIDAddress(17) // TODO: needs to be removed in favor of reward actor
var BurntFundsAddress = mustIDAddress(99)
/*
SystemActorAddr = mustMakeAddress(0)
InitActorAddr = mustMakeAddress(1)
RewardActorAddr = mustMakeAddress(2)
CronActorAddr = mustMakeAddress(3)
StoragePowerActorAddr = mustMakeAddress(4)
StorageMarketActorAddr = mustMakeAddress(5)
// Distinguished AccountActor that is the destination of all burnt funds.
BurntFundsActorAddr = mustMakeAddress(99)
*/
func mustIDAddress(i uint64) address.Address {
a, err := address.NewIDAddress(i)

View File

@ -2,8 +2,12 @@ package genesis
import (
"context"
"encoding/json"
"github.com/filecoin-project/go-amt-ipld/v2"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
bstore "github.com/ipfs/go-ipfs-blockstore"
@ -18,14 +22,175 @@ import (
"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/genesis"
)
const AccountStart = 100
const MinerStart = 1000
const MaxAccounts = MinerStart - AccountStart
var log = logging.Logger("genesis")
type GenesisBootstrap struct {
Genesis *types.BlockHeader
}
/*
From a list of parameters, create a genesis block / initial state
The process:
- Bootstrap state
- Create empty state
- Make init actor
- Create accounts mappings
- Set NextID to MinerStart
- Setup Reward (1.4B fil)
- Setup Cron
- Create empty power actor
- Create empty market
- Setup burnt fund address
- Initialize account / msig balances
- Instantiate early vm with genesis syscalls
- Create miners
- Each:
- power.CreateMiner, set msg value to PowerBalance
- market.AddFunds with correct value
- Set precommits
- Commit presealed sectors
Data Types:
PreSeal :{
CommR CID
CommD CID
SectorID SectorNumber
Deal market.DealProposal # Start at 0, self-deal!
}
Genesis: {
Accounts: [ # non-miner, non-singleton actors, max len = MaxAccounts
{
Type: "account" / "multisig",
Value: "attofil",
[Meta: {msig settings, account key..}]
},...
],
Miners: [
{
Owner, Worker Addr # ID
MarketBalance, PowerBalance TokenAmount
SectorSize uint64
PreSeals []PreSeal
},...
],
}
*/
func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template genesis.Template) (*state.StateTree, error) {
// Create empty state tree
cst := cbor.NewCborStore(bs)
state, err := state.NewStateTree(cst)
if err != nil {
return nil, xerrors.Errorf("making new state tree: %w", err)
}
emptyobject, err := cst.Put(context.TODO(), []struct{}{})
if err != nil {
return nil, xerrors.Errorf("failed putting empty object: %w", err)
}
// Create init actor
initact, err := SetupInitActor(bs, template.NetworkName, template.Accounts)
if err != nil {
return nil, xerrors.Errorf("setup init actor: %w", err)
}
if err := state.SetActor(actors.InitAddress, initact); err != nil {
return nil, xerrors.Errorf("set init actor: %w", err)
}
// Create accounts
for id, info := range template.Accounts {
if info.Type != genesis.TAccount {
return nil, xerrors.New("unsupported account type") // TODO: msigs
}
ida, err := address.NewIDAddress(uint64(AccountStart + id))
if err != nil {
return nil, err
}
var ainfo genesis.AccountMeta
if err := json.Unmarshal(info.Meta, &ainfo); err != nil {
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
}
st, err := cst.Put(ctx, account.State{Address: ainfo.Owner})
if err != nil {
return nil, err
}
err = state.SetActor(ida, &types.Actor{
Code: actors.AccountCodeCid,
Balance: info.Balance,
Head: st,
})
if err != nil {
return nil, xerrors.Errorf("setting account from actmap: %w", err)
}
}
// Setup initial market state
marketact, err := SetupStorageMarketActor(bs, template.Miners)
if err != nil {
return nil, xerrors.Errorf("setup storage market actor: %w", err)
}
if err := state.SetActor(actors.StorageMarketAddress, marketact); err != nil {
return nil, xerrors.Errorf("set market actor: %w", err)
}
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)
}
err = state.SetActor(actors.RewardActor, &types.Actor{
Code: builtin.RewardActorCodeID,
Balance: big.Int{Int: build.InitialReward},
Head: emptyobject,
})
if err != nil {
return nil, xerrors.Errorf("set network account actor: %w", err)
}
cronact, err := SetupCronActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup cron actor: %w", err)
}
if err := state.SetActor(actors.CronAddress, cronact); err != nil {
return nil, xerrors.Errorf("set cron actor: %w", err)
}
err = state.SetActor(actors.BurntFundsAddress, &types.Actor{
Code: actors.AccountCodeCid,
Balance: types.NewInt(0),
Head: emptyobject,
})
if err != nil {
return nil, xerrors.Errorf("set burnt funds account actor: %w", err)
}
return state, nil
}
func MakeGenesisBlock(bs bstore.Blockstore, sys *types.VMSyscalls, balances map[address.Address]types.BigInt, gmcfg *GenMinerCfg, ts uint64) (*GenesisBootstrap, error) {
ctx := context.TODO()
@ -46,16 +211,6 @@ func MakeGenesisBlock(bs bstore.Blockstore, sys *types.VMSyscalls, balances map[
return nil, xerrors.Errorf("setup storage miners failed: %w", err)
}
stateroot, err = SetupStorageMarketActor(bs, stateroot, deals)
if err != nil {
return nil, xerrors.Errorf("setup storage market actor: %w", err)
}
stateroot, err = AdjustInitActorStartID(ctx, bs, stateroot, 1000)
if err != nil {
return nil, xerrors.Errorf("failed to adjust init actor start ID: %w", err)
}
cst := cbor.NewCborStore(bs)
emptyroot, err := amt.FromArray(ctx, cst, nil)
@ -112,84 +267,3 @@ func MakeGenesisBlock(bs bstore.Blockstore, sys *types.VMSyscalls, balances map[
Genesis: b,
}, nil
}
func MakeInitialStateTree(bs bstore.Blockstore, actmap map[address.Address]types.BigInt) (*state.StateTree, error) {
cst := cbor.NewCborStore(bs)
state, err := state.NewStateTree(cst)
if err != nil {
return nil, xerrors.Errorf("making new state tree: %w", err)
}
emptyobject, err := cst.Put(context.TODO(), []struct{}{})
if err != nil {
return nil, xerrors.Errorf("failed putting empty object: %w", err)
}
var addrs []address.Address
for a := range actmap {
addrs = append(addrs, a)
}
initact, err := SetupInitActor(bs, addrs)
if err != nil {
return nil, xerrors.Errorf("setup init actor: %w", err)
}
if err := state.SetActor(actors.InitAddress, initact); err != nil {
return nil, xerrors.Errorf("set init actor: %w", err)
}
cronact, err := SetupCronActor(bs)
if err != nil {
return nil, xerrors.Errorf("setup cron actor: %w", err)
}
if err := state.SetActor(actors.CronAddress, cronact); err != nil {
return nil, xerrors.Errorf("set cron actor: %w", err)
}
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)
}
netAmt := types.FromFil(build.TotalFilecoin)
for _, amt := range actmap {
netAmt = types.BigSub(netAmt, amt)
}
err = state.SetActor(actors.NetworkAddress, &types.Actor{
Code: actors.AccountCodeCid,
Balance: netAmt,
Head: emptyobject,
})
if err != nil {
return nil, xerrors.Errorf("set network account actor: %w", err)
}
err = state.SetActor(actors.BurntFundsAddress, &types.Actor{
Code: actors.AccountCodeCid,
Balance: types.NewInt(0),
Head: emptyobject,
})
if err != nil {
return nil, xerrors.Errorf("set burnt funds account actor: %w", err)
}
for a, v := range actmap {
err = state.SetActor(a, &types.Actor{
Code: actors.AccountCodeCid,
Balance: v,
Head: emptyobject,
})
if err != nil {
return nil, xerrors.Errorf("setting account from actmap: %w", err)
}
}
return state, nil
}

View File

@ -25,7 +25,7 @@ import (
)
type GenMinerCfg struct {
PreSeals map[string]genesis.GenesisMiner
PreSeals map[string]genesis.Miner
// The addresses of the created miner, this is set by the genesis setup
MinerAddrs []address.Address

View File

@ -1,38 +1,46 @@
package genesis
import (
"bytes"
"context"
"encoding/json"
"github.com/filecoin-project/go-address"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-hamt-ipld"
blockstore "github.com/ipfs/go-ipfs-blockstore"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/state"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/lotus/genesis"
)
func SetupInitActor(bs bstore.Blockstore, addrs []address.Address) (*types.Actor, error) {
func SetupInitActor(bs bstore.Blockstore, netname string, initialActors []genesis.Actor) (*types.Actor, error) {
if len(initialActors) > MaxAccounts {
return nil, xerrors.New("too many initial actors")
}
var ias actors.InitActorState
ias.NextID = 100
ias.NextID = MinerStart
ias.NetworkName = netname
cst := cbor.NewCborStore(bs)
amap := hamt.NewNode(cst)
for i, a := range addrs {
if err := amap.Set(context.TODO(), string(a.Bytes()), 100+uint64(i)); err != nil {
for i, a := range initialActors {
if a.Type != genesis.TAccount {
return nil, xerrors.Errorf("unsupported account type: %s", a.Type) // TODO: Support msig (skip here)
}
var ainfo genesis.AccountMeta
if err := json.Unmarshal(a.Meta, &ainfo); err != nil {
return nil, xerrors.Errorf("unmarshaling account meta: %w", err)
}
if err := amap.Set(context.TODO(), string(ainfo.Owner.Bytes()), AccountStart+uint64(i)); err != nil {
return nil, err
}
}
ias.NextID += uint64(len(addrs))
if err := amap.Flush(context.TODO()); err != nil {
return nil, err
}
@ -55,110 +63,3 @@ func SetupInitActor(bs bstore.Blockstore, addrs []address.Address) (*types.Actor
return act, nil
}
func AdjustInitActorStartID(ctx context.Context, bs blockstore.Blockstore, stateroot cid.Cid, val uint64) (cid.Cid, error) {
cst := cbor.NewCborStore(bs)
tree, err := state.LoadStateTree(cst, stateroot)
if err != nil {
return cid.Undef, err
}
act, err := tree.GetActor(actors.InitAddress)
if err != nil {
return cid.Undef, err
}
var st actors.InitActorState
if err := cst.Get(ctx, act.Head, &st); err != nil {
return cid.Undef, err
}
st.NextID = val
nstate, err := cst.Put(ctx, &st)
if err != nil {
return cid.Undef, err
}
act.Head = nstate
if err := tree.SetActor(actors.InitAddress, act); err != nil {
return cid.Undef, err
}
return tree.Flush(ctx)
}
func initActorReassign(vm *vm.VM, cst cbor.IpldStore, from, to address.Address) error {
ctx := context.TODO()
initact, err := vm.StateTree().GetActor(actors.InitAddress)
if err != nil {
return xerrors.Errorf("couldnt get init actor: %w", err)
}
var st actors.InitActorState
if err := cst.Get(ctx, initact.Head, &st); err != nil {
return xerrors.Errorf("reassign loading init actor state: %w", err)
}
amap, err := hamt.LoadNode(ctx, cst, st.AddressMap)
if err != nil {
return xerrors.Errorf("failed to load init actor map: %w", err)
}
target, err := address.IDFromAddress(from)
if err != nil {
return xerrors.Errorf("failed to extract ID: %w", err)
}
var out string
halt := xerrors.Errorf("halt")
err = amap.ForEach(ctx, func(k string, v interface{}) error {
_, val, err := cbg.CborReadHeader(bytes.NewReader(v.(*cbg.Deferred).Raw))
if err != nil {
return xerrors.Errorf("parsing int in map failed: %w", err)
}
if val == target {
out = k
return halt
}
return nil
})
if err == nil {
return xerrors.Errorf("could not find from address in init ID map")
}
if !xerrors.Is(err, halt) {
return xerrors.Errorf("finding address in ID map failed: %w", err)
}
if err := amap.Delete(ctx, out); err != nil {
return xerrors.Errorf("deleting 'from' entry in amap: %w", err)
}
if err := amap.Set(ctx, out, target); err != nil {
return xerrors.Errorf("setting 'to' entry in amap: %w", err)
}
if err := amap.Flush(ctx); err != nil {
return xerrors.Errorf("failed to flush amap: %w", err)
}
ncid, err := cst.Put(ctx, amap)
if err != nil {
return err
}
st.AddressMap = ncid
nacthead, err := cst.Put(ctx, &st)
if err != nil {
return err
}
initact.Head = nacthead
return nil
}

View File

@ -5,19 +5,18 @@ import (
"github.com/filecoin-project/go-amt-ipld/v2"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
"github.com/ipfs/go-cid"
bstore "github.com/ipfs/go-ipfs-blockstore"
cbor "github.com/ipfs/go-ipld-cbor"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/chain/actors"
"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/genesis"
)
func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []market.DealProposal) (cid.Cid, error) {
func SetupStorageMarketActor(bs bstore.Blockstore, miners []genesis.Miner) (*types.Actor, error) {
ctx := context.TODO()
cst := cbor.NewCborStore(bs)
ast := store.ActorStore(context.TODO(), bs)
@ -37,17 +36,17 @@ func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []market
dealAmt, err := amt.FromArray(ctx, cst, cdeals)
if err != nil {
return cid.Undef, xerrors.Errorf("amt build failed: %w", err)
return nil, xerrors.Errorf("amt build failed: %w", err)
}
stateAmt, err := amt.FromArray(ctx, cst, sdeals)
if err != nil {
return cid.Undef, xerrors.Errorf("amt build failed: %w", err)
return nil, xerrors.Errorf("amt build failed: %w", err)
}
sms, err := market.ConstructState(ast)
if err != nil {
return cid.Cid{}, err
return nil, err
}
sms.Proposals = dealAmt
@ -55,7 +54,7 @@ func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []market
stcid, err := cst.Put(context.TODO(), sms)
if err != nil {
return cid.Undef, err
return nil, err
}
// TODO: MARKET BALANCES!!!!!!111
@ -63,18 +62,8 @@ func SetupStorageMarketActor(bs bstore.Blockstore, sroot cid.Cid, deals []market
act := &types.Actor{
Code: actors.StorageMarketCodeCid,
Head: stcid,
Nonce: 0,
Balance: types.NewInt(0),
}
state, err := state.LoadStateTree(cst, sroot)
if err != nil {
return cid.Undef, xerrors.Errorf("making new state tree: %w", err)
}
if err := state.SetActor(actors.StorageMarketAddress, act); err != nil {
return cid.Undef, xerrors.Errorf("set storage market actor: %w", err)
}
return state.Flush(context.TODO())
return act, nil
}

View File

@ -7,15 +7,16 @@ import (
"runtime/debug"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/runtime"
vmr "github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
"github.com/ipfs/go-cid"
cbg "github.com/whyrusleeping/cbor-gen"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
"github.com/filecoin-project/lotus/chain/types"
)
type runtimeShim struct {
@ -146,6 +147,16 @@ type shimStateHandle struct {
rs *runtimeShim
}
func (ssh *shimStateHandle) Create(obj vmr.CBORMarshaler) {
c, err := ssh.rs.vmctx.Storage().Put(obj)
if err != nil {
panic(err)
}
if err := ssh.rs.vmctx.Storage().Commit(actors.EmptyCBOR, c); err != nil {
panic(err)
}
}
func (ssh *shimStateHandle) Readonly(obj vmr.CBORUnmarshaler) {
if err := ssh.rs.vmctx.Storage().Get(ssh.rs.vmctx.Storage().GetHead(), obj); err != nil {
panic(err)
@ -170,15 +181,3 @@ func (ssh *shimStateHandle) Transaction(obj vmr.CBORer, f func() interface{}) in
return out
}
func (ssh *shimStateHandle) Construct(f func() vmr.CBORMarshaler) {
out := f()
c, err := ssh.rs.vmctx.Storage().Put(out)
if err != nil {
panic(err)
}
if err := ssh.rs.vmctx.Storage().Commit(actors.EmptyCBOR, c); err != nil {
panic(err)
}
}

View File

@ -32,7 +32,7 @@ import (
var log = logging.Logger("preseal")
func PreSeal(maddr address.Address, ssize abi.SectorSize, offset abi.SectorNumber, sectors int, sbroot string, preimage []byte) (*genesis.GenesisMiner, error) {
func PreSeal(maddr address.Address, ssize abi.SectorSize, offset abi.SectorNumber, sectors int, sbroot string, preimage []byte) (*genesis.Miner, error) {
cfg := &sectorbuilder.Config{
Miner: maddr,
SectorSize: ssize,
@ -96,7 +96,7 @@ func PreSeal(maddr address.Address, ssize abi.SectorSize, offset abi.SectorNumbe
return nil, err
}
miner := &genesis.GenesisMiner{
miner := &genesis.Miner{
Owner: minerAddr.Address,
Worker: minerAddr.Address,
@ -104,10 +104,10 @@ func PreSeal(maddr address.Address, ssize abi.SectorSize, offset abi.SectorNumbe
Sectors: sealedSectors,
Key: minerAddr.KeyInfo,
// Key: minerAddr.KeyInfo, // TODO: Export separately
}
if err := createDeals(miner, minerAddr, maddr, abi.SectorSize(ssize)); err != nil {
if err := createDeals(miner, minerAddr, maddr, ssize); err != nil {
return nil, xerrors.Errorf("creating deals: %w", err)
}
@ -118,8 +118,8 @@ func PreSeal(maddr address.Address, ssize abi.SectorSize, offset abi.SectorNumbe
return miner, nil
}
func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.GenesisMiner) error {
output := map[string]genesis.GenesisMiner{
func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner) error {
output := map[string]genesis.Miner{
maddr.String(): *gm,
}
@ -148,7 +148,7 @@ func commDCID(commd []byte) cid.Cid {
return d
}
func createDeals(m *genesis.GenesisMiner, k *wallet.Key, maddr address.Address, ssize abi.SectorSize) error {
func createDeals(m *genesis.Miner, k *wallet.Key, maddr address.Address, ssize abi.SectorSize) error {
for _, sector := range m.Sectors {
pref := make([]byte, len(sector.CommD))
copy(pref, sector.CommD[:])

View File

@ -1,11 +1,17 @@
package genesis
import (
"encoding/json"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/market"
)
"github.com/filecoin-project/lotus/chain/types"
type ActorType string
const (
TAccount ActorType = "account"
TMultisig ActorType = "multisig"
)
type PreSeal struct {
@ -15,17 +21,37 @@ type PreSeal struct {
Deal market.DealProposal
}
type GenesisMiner struct {
type Miner struct {
Owner address.Address
Worker address.Address
MarketBalance abi.TokenAmount
PowerBalance abi.TokenAmount
WorkerBalance abi.TokenAmount
SectorSize abi.SectorSize
Sectors []*PreSeal
Key types.KeyInfo // TODO: separate file
}
type AccountMeta struct {
Owner address.Address // bls / secpk
}
type MultisigMeta struct {
// TODO
}
type Actor struct {
Type ActorType
Balance abi.TokenAmount
Meta json.RawMessage
}
type Template struct {
Accounts []Actor
Miners []Miner
NetworkName string
Timestamp uint64
}

2
go.mod
View File

@ -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-20200210130641-2d1fbd8672cf
github.com/filecoin-project/specs-actors v0.0.0-20200211202147-e5d0a86dd8fb
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

2
go.sum
View File

@ -141,6 +141,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200207231150-6c4532d56ffd h1:j
github.com/filecoin-project/specs-actors v0.0.0-20200207231150-6c4532d56ffd/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf h1:fbxBG12yrxilPFV1EG2lYqpUyAlRZWkvtqjk2svSeXY=
github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
github.com/filecoin-project/specs-actors v0.0.0-20200211202147-e5d0a86dd8fb h1:6kQpqlJmRuMLCaK7XkCTyyAuFWaaBwowG6UCYc2M2bo=
github.com/filecoin-project/specs-actors v0.0.0-20200211202147-e5d0a86dd8fb/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=

View File

@ -3,6 +3,7 @@ package sealing
import (
"context"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/go-sectorbuilder/fs"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
@ -97,11 +98,15 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
}
params := &miner.PreCommitSectorParams{
SectorNumber: sector.SectorID,
Info: miner.SectorPreCommitInfo{
Expiration: 0,
SectorNumber: sector.SectorID,
SealedCID: commcid.ReplicaCommitmentV1ToCID(sector.CommR),
SealEpoch: sector.Ticket.BlockHeight,
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
},
CommR: sector.CommR,
SealEpoch: sector.Ticket.BlockHeight,
DealIDs: nil, // sector.deals(), // TODO: REFACTOR
}
enc, aerr := actors.SerializeParams(params)
if aerr != nil {

View File

@ -8,12 +8,12 @@ import (
)
type SealTicket struct {
BlockHeight uint64
BlockHeight abi.ChainEpoch
TicketBytes []byte
}
func (t *SealTicket) SB() sectorbuilder.SealTicket {
out := sectorbuilder.SealTicket{BlockHeight: t.BlockHeight}
out := sectorbuilder.SealTicket{BlockHeight: uint64(t.BlockHeight)}
copy(out.TicketBytes[:], t.TicketBytes)
return out
}