working towards a working genesis generator

This commit is contained in:
whyrusleeping 2020-02-17 23:15:30 -08:00
parent 4ad160ef80
commit 6d0eec6395
16 changed files with 221 additions and 80 deletions

View File

@ -36,6 +36,7 @@ import (
"github.com/filecoin-project/lotus/genesis"
"github.com/filecoin-project/lotus/lib/sigs"
"github.com/filecoin-project/lotus/node/repo"
"github.com/filecoin-project/lotus/storage/sbmock"
"go.opencensus.io/trace"
"golang.org/x/xerrors"
@ -161,7 +162,7 @@ func NewGenerator() (*ChainGen, error) {
return nil, err
}
sys := vm.Syscalls(sectorbuilder.ProofVerifier)
sys := vm.Syscalls(&genFakeVerifier{})
tpl := genesis.Template{
Accounts: []genesis.Actor{
@ -662,3 +663,22 @@ func ComputeVRF(ctx context.Context, sign SignFunc, worker, miner address.Addres
return sig.Data, nil
}
type genFakeVerifier struct{}
var _ sectorbuilder.Verifier = (*genFakeVerifier)(nil)
func (m genFakeVerifier) VerifyElectionPost(ctx context.Context, sectorSize abi.SectorSize, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address) (bool, error) {
panic("nyi")
}
func (m genFakeVerifier) GenerateDataCommitment(ssize abi.PaddedPieceSize, pieces []ffi.PublicPieceInfo) ([sectorbuilder.CommLen]byte, error) {
return sbmock.MockVerifier.GenerateDataCommitment(ssize, pieces)
}
func (m genFakeVerifier) VerifySeal(sectorSize abi.SectorSize, commR, commD []byte, proverID address.Address, ticket []byte, seed []byte, sectorID abi.SectorNumber, proof []byte) (bool, error) {
return true, nil
}
func (m genFakeVerifier) VerifyFallbackPost(ctx context.Context, sectorSize abi.SectorSize, sectorInfo sectorbuilder.SortedPublicSectorInfo, challengeSeed []byte, proof []byte, candidates []sectorbuilder.EPostCandidate, proverID address.Address, faults uint64) (bool, error) {
panic("nyi")
}

View File

@ -9,6 +9,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore"
bstore "github.com/ipfs/go-ipfs-blockstore"
@ -210,7 +211,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
return state, nil
}
func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys *types.VMSyscalls, template genesis.Template) (*GenesisBootstrap, error) {
func MakeGenesisBlock(ctx context.Context, bs bstore.Blockstore, sys runtime.Syscalls, template genesis.Template) (*GenesisBootstrap, error) {
st, err := MakeInitialStateTree(ctx, bs, template)
if err != nil {
return nil, xerrors.Errorf("make initial state tree failed: %w", err)

View File

@ -3,6 +3,9 @@ package genesis
import (
"bytes"
"context"
"fmt"
"math/rand"
"github.com/filecoin-project/specs-actors/actors/builtin/power"
"github.com/filecoin-project/go-address"
@ -32,7 +35,8 @@ func MinerAddress(genesisIndex uint64) address.Address {
}
func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid, miners []genesis.Miner) (cid.Cid, error) {
vm, err := vm.NewVM(sroot, 0, nil, actors.SystemAddress, cs.Blockstore(), cs.VMSys())
vm, err := vm.NewVM(sroot, 0, &fakeRand{}, actors.SystemAddress, cs.Blockstore(), cs.VMSys())
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
}
@ -73,7 +77,7 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
// Add market funds
{
params := mustEnc(&m.Worker)
params := mustEnc(&maddr)
_, err := doExecValue(ctx, vm, actors.StorageMarketAddress, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
@ -86,10 +90,12 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
{
params := &market.PublishStorageDealsParams{}
for _, preseal := range m.Sectors {
params.Deals = append(params.Deals, market.ClientDealProposal{
Proposal: preseal.Deal,
ClientSignature: crypto.Signature{},
ClientSignature: crypto.Signature{}, // TODO: do we want to sign these? Or do we want to fake signatures for genesis setup?
})
fmt.Printf("calling publish storage deals on miner %s with worker %s\n", preseal.Deal.Provider, m.Worker)
}
ret, err := doExecValue(ctx, vm, builtin.StorageMarketActorAddr, m.Worker, big.Zero(), builtin.MethodsMarket.PublishStorageDeals, mustEnc(params))
@ -106,34 +112,33 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
// Publish preseals
{
for pi, preseal := range m.Sectors {
// Precommit
{
params := &miner.SectorPreCommitInfo{
SectorNumber: preseal.SectorID,
SealedCID: commcid.ReplicaCommitmentV1ToCID(preseal.CommR[:]),
SealEpoch: 0,
DealIDs: []abi.DealID{dealIDs[pi]},
Expiration: preseal.Deal.EndEpoch,
}
_, err := doExecValue(ctx, vm, maddr, m.Worker, big.Zero(), builtin.MethodsMiner.PreCommitSector, mustEnc(params))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}
}
for pi, preseal := range m.Sectors {
// Precommit
params := &miner.SectorPreCommitInfo{
SectorNumber: preseal.SectorID,
SealedCID: commcid.ReplicaCommitmentV1ToCID(preseal.CommR[:]),
SealEpoch: 0,
DealIDs: []abi.DealID{dealIDs[pi]},
Expiration: preseal.Deal.EndEpoch,
}
_, err := doExecValue(ctx, vm, maddr, m.Worker, big.Zero(), builtin.MethodsMiner.PreCommitSector, mustEnc(params))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}
}
// Commit
{
params := &miner.ProveCommitSectorParams{
SectorNumber: preseal.SectorID,
Proof: abi.SealProof{},
}
_, err := doExecValue(ctx, vm, maddr, m.Worker, big.Zero(), builtin.MethodsMiner.ProveCommitSector, mustEnc(params))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}
}
// You can't prove sector commitments at the same height that you precommit them
vm.SetBlockHeight(7) // needs to be between PorepMinDelay and PorepMaxDelay
// Commit
for _, preseal := range m.Sectors {
params := &miner.ProveCommitSectorParams{
SectorNumber: preseal.SectorID,
Proof: nil,
}
_, err := doExecValue(ctx, vm, maddr, m.Worker, big.Zero(), builtin.MethodsMiner.ProveCommitSector, mustEnc(params))
if err != nil {
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
}
}
}
@ -141,3 +146,12 @@ func SetupStorageMiners(ctx context.Context, cs *store.ChainStore, sroot cid.Cid
c, err := vm.Flush(ctx)
return c, err
}
// TODO: copied from actors test harness, deduplicate or remove from here
type fakeRand struct{}
func (fr *fakeRand) GetRandomness(ctx context.Context, h int64) ([]byte, error) {
out := make([]byte, 32)
rand.New(rand.NewSource(h)).Read(out)
return out, nil
}

View File

@ -15,6 +15,7 @@ import (
"github.com/filecoin-project/lotus/chain/vm"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
cbg "github.com/whyrusleeping/cbor-gen"
"golang.org/x/xerrors"
@ -36,7 +37,7 @@ type StateManager struct {
stCache map[string][]cid.Cid
compWait map[string]chan struct{}
stlk sync.Mutex
newVM func(cid.Cid, abi.ChainEpoch, vm.Rand, address.Address, blockstore.Blockstore, *types.VMSyscalls) (*vm.VM, error)
newVM func(cid.Cid, abi.ChainEpoch, vm.Rand, address.Address, blockstore.Blockstore, runtime.Syscalls) (*vm.VM, error)
}
func NewStateManager(cs *store.ChainStore) *StateManager {
@ -679,6 +680,6 @@ func (sm *StateManager) ValidateChain(ctx context.Context, ts *types.TipSet) err
return nil
}
func (sm *StateManager) SetVMConstructor(nvm func(cid.Cid, abi.ChainEpoch, vm.Rand, address.Address, blockstore.Blockstore, *types.VMSyscalls) (*vm.VM, error)) {
func (sm *StateManager) SetVMConstructor(nvm func(cid.Cid, abi.ChainEpoch, vm.Rand, address.Address, blockstore.Blockstore, runtime.Syscalls) (*vm.VM, error)) {
sm.newVM = nvm
}

View File

@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/specs-actors/actors/util/adt"
"go.opencensus.io/trace"
"go.uber.org/multierr"
@ -63,10 +64,10 @@ type ChainStore struct {
mmCache *lru.ARCCache
tsCache *lru.ARCCache
vmcalls *types.VMSyscalls
vmcalls runtime.Syscalls
}
func NewChainStore(bs bstore.Blockstore, ds dstore.Batching, vmcalls *types.VMSyscalls) *ChainStore {
func NewChainStore(bs bstore.Blockstore, ds dstore.Batching, vmcalls runtime.Syscalls) *ChainStore {
c, _ := lru.NewARC(2048)
tsc, _ := lru.NewARC(4096)
cs := &ChainStore{
@ -861,7 +862,7 @@ func (cs *ChainStore) Store(ctx context.Context) adt.Store {
return ActorStore(ctx, cs.bs)
}
func (cs *ChainStore) VMSys() *types.VMSyscalls {
func (cs *ChainStore) VMSys() runtime.Syscalls {
return cs.vmcalls
}

View File

@ -7,6 +7,7 @@ import (
"testing"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/specs-actors/actors/crypto"
cid "github.com/ipfs/go-cid"
)
@ -34,12 +35,12 @@ func testBlockHeader(t testing.TB) *BlockHeader {
},
Parents: []cid.Cid{c, c},
ParentMessageReceipts: c,
BLSAggregate: Signature{Type: KTBLS, Data: []byte("boo! im a signature")},
BLSAggregate: crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")},
ParentWeight: NewInt(123125126212),
Messages: c,
Height: 85919298723,
ParentStateRoot: c,
BlockSig: &Signature{Type: KTBLS, Data: []byte("boo! im a signature")},
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")},
}
}

View File

@ -68,7 +68,7 @@ func (s *Signature) UnmarshalCBOR(br io.Reader) error {
return err
}
if buf[0] != byte(crypto.SigTypeSecp256k1) || buf[0] != byte(crypto.SigTypeBLS) {
if buf[0] != byte(crypto.SigTypeSecp256k1) && buf[0] != byte(crypto.SigTypeBLS) {
return fmt.Errorf("invalid signature type in cbor input: %d", buf[0])
}

View File

@ -3,12 +3,14 @@ package types
import (
"bytes"
"testing"
"github.com/filecoin-project/specs-actors/actors/crypto"
)
func TestSignatureSerializeRoundTrip(t *testing.T) {
s := &Signature{
Data: []byte("foo bar cat dog"),
Type: KTBLS,
Type: crypto.SigTypeBLS,
}
buf := new(bytes.Buffer)

View File

@ -6,6 +6,7 @@ import (
"github.com/filecoin-project/go-sectorbuilder"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/chain/actors/aerrors"
@ -44,7 +45,7 @@ type VMContext interface {
ChargeGas(uint64) aerrors.ActorError
GetRandomness(height abi.ChainEpoch) ([]byte, aerrors.ActorError)
GetBalance(address.Address) (BigInt, aerrors.ActorError)
Sys() *VMSyscalls
Sys() runtime.Syscalls
Context() context.Context
}

View File

@ -47,6 +47,8 @@ func (rs *runtimeShim) shimCall(f func() interface{}) (rval []byte, aerr aerrors
defer func() {
if r := recover(); r != nil {
if ar, ok := r.(aerrors.ActorError); ok {
fmt.Println("VM.Call failure: ", ar)
debug.PrintStack()
aerr = ar
return
}
@ -152,7 +154,7 @@ func (rs *runtimeShim) NewActorAddress() address.Address {
func (rs *runtimeShim) CreateActor(codeId cid.Cid, address address.Address) {
var err error
st,err := rs.vmctx.StateTree()
st, err := rs.vmctx.StateTree()
if err != nil {
rs.Abortf(exitcode.SysErrInternal, "getting statetree: %v", err)
}
@ -175,7 +177,7 @@ func (rs *runtimeShim) DeleteActor() {
}
func (rs *runtimeShim) Syscalls() vmr.Syscalls {
panic("implement me")
return rs.vmctx.Sys()
}
func (rs *runtimeShim) StartSpan(name string) vmr.TraceSpan {
@ -188,8 +190,7 @@ func (rs *runtimeShim) ValidateImmediateCallerIs(as ...address.Address) {
return
}
}
fmt.Println("Caller: ", rs.vmctx.Message().From, as)
panic("we like to panic when people call the wrong methods")
rs.Abortf(exitcode.ErrForbidden, "caller %s is not one of %s", rs.vmctx.Message().From, as)
}
func (rs *runtimeShim) ImmediateCaller() address.Address {
@ -225,12 +226,16 @@ func (dwt *dumbWrapperType) Into(um vmr.CBORUnmarshaler) error {
}
func (rs *runtimeShim) Send(to address.Address, method abi.MethodNum, m vmr.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) {
buf := new(bytes.Buffer)
if err := m.MarshalCBOR(buf); err != nil {
rs.Abortf(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err)
var params []byte
if m != nil {
buf := new(bytes.Buffer)
if err := m.MarshalCBOR(buf); err != nil {
rs.Abortf(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err)
}
params = buf.Bytes()
}
ret, err := rs.vmctx.Send(to, method, types.BigInt(value), buf.Bytes())
ret, err := rs.vmctx.Send(to, method, types.BigInt(value), params)
if err != nil {
if err.IsFatal() {
panic(err)

View File

@ -1,30 +1,114 @@
package vm
import (
"context"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-sectorbuilder"
"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"
"go.opencensus.io/trace"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
"github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
"golang.org/x/xerrors"
)
func init() {
mh.Codes[0xf104] = "filecoin"
}
// Actual type is defined in chain/types/vmcontext.go because the VMContext interface is there
func Syscalls(verifier sectorbuilder.Verifier) *types.VMSyscalls {
return &types.VMSyscalls{
ValidatePoRep: func(ctx context.Context, maddr address.Address, ssize abi.SectorSize, commD, commR, ticket, proof, seed []byte, sectorID abi.SectorNumber) (bool, actors.ActorError) {
_, span := trace.StartSpan(ctx, "ValidatePoRep")
defer span.End()
ok, err := verifier.VerifySeal(ssize, commR, commD, maddr, ticket, seed, sectorID, proof)
if err != nil {
return false, aerrors.Absorb(err, 25, "verify seal failed")
}
return ok, nil
},
VerifyFallbackPost: verifier.VerifyFallbackPost,
}
func Syscalls(verifier sectorbuilder.Verifier) runtime.Syscalls {
return &syscallShim{verifier}
}
type syscallShim struct {
verifier sectorbuilder.Verifier
}
func (ss *syscallShim) ComputeUnsealedSectorCID(ssize abi.SectorSize, pieces []abi.PieceInfo) (cid.Cid, error) {
// TODO: does this pull in unwanted dependencies?
var ffipieces []ffi.PublicPieceInfo
for _, p := range pieces {
ffipieces = append(ffipieces, ffi.PublicPieceInfo{
Size: p.Size.Unpadded(),
CommP: cidToCommD(p.PieceCID),
})
}
commd, err := sectorbuilder.GenerateDataCommitment(ssize, ffipieces)
if err != nil {
log.Errorf("generate data commitment failed: %s", err)
return cid.Undef, err
}
// TODO: pulling these numbers kinda out of an unmerged PR
hb, err := mh.Encode(commd[:], 0xf104)
if err != nil {
log.Errorf("mh encode failed: %s", err)
return cid.Undef, err
}
return cid.NewCidV1(0xf101, mh.Multihash(hb)), nil
}
func (ss *syscallShim) HashBlake2b(data []byte) [32]byte {
panic("NYI")
}
func (ss *syscallShim) VerifyConsensusFault(a, b []byte) bool {
panic("NYI")
}
func (ss *syscallShim) VerifyPoSt(ssize abi.SectorSize, proof abi.PoStVerifyInfo) (bool, error) {
panic("NYI")
}
func cidToCommD(c cid.Cid) [32]byte {
b := c.Bytes()
var out [32]byte
copy(out[:], b[len(b)-32:])
return out
}
func cidToCommR(c cid.Cid) [32]byte {
b := c.Bytes()
var out [32]byte
copy(out[:], b[len(b)-32:])
return out
}
func (ss *syscallShim) VerifySeal(ssize abi.SectorSize, info abi.SealVerifyInfo) (bool, error) {
//_, span := trace.StartSpan(ctx, "ValidatePoRep")
//defer span.End()
commD := cidToCommD(info.UnsealedCID)
commR := cidToCommR(info.OnChain.SealedCID)
miner, err := address.NewIDAddress(uint64(info.Miner))
if err != nil {
return false, xerrors.Errorf("weirdly failed to construct address: %w", err)
}
ticket := []byte(info.Randomness)
proof := []byte(info.OnChain.Proof)
seed := []byte(info.InteractiveRandomness)
//func(ctx context.Context, maddr address.Address, ssize abi.SectorSize, commD, commR, ticket, proof, seed []byte, sectorID abi.SectorNumber)
ok, err := ss.verifier.VerifySeal(ssize, commR[:], commD[:], miner, ticket, seed, info.SectorID.Number, proof)
if err != nil {
return false, xerrors.Errorf("failed to validate PoRep: %w", err)
}
return ok, nil
}
func (ss *syscallShim) VerifySignature(sig crypto.Signature, addr address.Address, input []byte) bool {
return true
/* // TODO: in genesis setup, we are currently faking signatures
if err := ss.rt.vmctx.VerifySignature(&sig, addr, input); err != nil {
return false
}
return true
*/
}

View File

@ -9,6 +9,7 @@ import (
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/builtin/account"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/specs-actors/actors/runtime"
block "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
hamt "github.com/ipfs/go-hamt-ipld"
@ -60,7 +61,7 @@ type VMContext struct {
gasAvailable types.BigInt
gasUsed types.BigInt
sys *types.VMSyscalls
sys runtime.Syscalls
// root cid of the state of the actor this invocation will be on
sroot cid.Cid
@ -83,7 +84,7 @@ func (vmc *VMContext) GetRandomness(height abi.ChainEpoch) ([]byte, aerrors.Acto
return res, nil
}
func (vmc *VMContext) Sys() *types.VMSyscalls {
func (vmc *VMContext) Sys() runtime.Syscalls {
return vmc.sys
}
@ -318,10 +319,10 @@ type VM struct {
inv *invoker
rand Rand
Syscalls *types.VMSyscalls
Syscalls runtime.Syscalls
}
func NewVM(base cid.Cid, height abi.ChainEpoch, r Rand, maddr address.Address, cbs blockstore.Blockstore, syscalls *types.VMSyscalls) (*VM, error) {
func NewVM(base cid.Cid, height abi.ChainEpoch, r Rand, maddr address.Address, cbs blockstore.Blockstore, syscalls runtime.Syscalls) (*VM, error) {
buf := bufbstore.NewBufferedBstore(cbs)
cst := cbor.NewCborStore(buf)
state, err := state.LoadStateTree(cst, base)

6
go.mod
View File

@ -12,7 +12,7 @@ require (
github.com/docker/go-units v0.4.0
github.com/filecoin-project/chain-validation v0.0.3
github.com/filecoin-project/filecoin-ffi v0.0.0-20191219131535-bb699517a590
github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5
github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e
github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
@ -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-20200217213446-ac1ea4569f6a
github.com/filecoin-project/specs-actors v0.0.0-20200217221016-d2e2112b7a8b
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,3 +115,5 @@ 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 => ../specs-actors

7
go.sum
View File

@ -101,6 +101,10 @@ github.com/filecoin-project/chain-validation v0.0.3 h1:luT/8kJ0WdMIqQ9Bm31W4JkuY
github.com/filecoin-project/chain-validation v0.0.3/go.mod h1:NCEGFjcWRjb8akWFSOXvU6n2efkWIqAeOKU6o5WBGQw=
github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5 h1:/MmWluswvDIbuPvBct4q6HeQgVm62O2DzWYTB38kt4A=
github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be h1:TooKBwR/g8jG0hZ3lqe9S5sy2vTUcLOZLlz3M5wGn2E=
github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0=
github.com/filecoin-project/go-amt-ipld v1.0.0 h1:jJteqdKcwFYoN9Wgs7MzDWVWvRWUfhhFo4bltJ7wrus=
github.com/filecoin-project/go-amt-ipld v1.0.0/go.mod h1:KsFPWjF+UUYl6n9A+qbg4bjFgAOneicFZtDH/LQEX2U=
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e h1:IOoff6yAZSJ5zHCPY2jzGNwQYQU6ygsRVe/cSnJrY+o=
github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200131012142-05d80eeccc5e/go.mod h1:boRtQhzmxNocrMxOXo1NYn4oUc1NGvR8tEa79wApNXg=
github.com/filecoin-project/go-cbor-util v0.0.0-20191219014500-08c40a1e63a2 h1:av5fw6wmm58FYMgJeoB/lK9XXrgdugYiTqkdxjTy9k8=
@ -142,6 +146,8 @@ github.com/filecoin-project/specs-actors v0.0.0-20200217172540-9989695a4859 h1:q
github.com/filecoin-project/specs-actors v0.0.0-20200217172540-9989695a4859/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
github.com/filecoin-project/specs-actors v0.0.0-20200217213446-ac1ea4569f6a h1:pD0cvMAT7aLFYsNsuIIYPzwzQJyI4IPh11KCtYEU2CY=
github.com/filecoin-project/specs-actors v0.0.0-20200217213446-ac1ea4569f6a/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA=
github.com/filecoin-project/specs-actors v0.0.0-20200217221016-d2e2112b7a8b h1:cb37QS3vhAGimWq746yaeXoJS/+hSqKQL0pUxZDoIHQ=
github.com/filecoin-project/specs-actors v0.0.0-20200217221016-d2e2112b7a8b/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=
@ -764,6 +770,7 @@ github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc h1:BCPnHtcboa
github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc/go.mod h1:r45hJU7yEoA81k6MWNhpMj/kms0n14dkzkxYHoB96UM=
github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba h1:X4n8JG2e2biEZZXdBKt9HX7DN3bYGFUqljqqy0DqgnY=
github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba/go.mod h1:CHQnYnQUEPydYCwuy8lmTHfGmdw9TKrhWV0xLx8l0oM=
github.com/whyrusleeping/cbor-gen v0.0.0-20190917003517-d78d67427694/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
github.com/whyrusleeping/cbor-gen v0.0.0-20191116002219-891f55cd449d/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
github.com/whyrusleeping/cbor-gen v0.0.0-20191212224538-d370462a7e8a/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
github.com/whyrusleeping/cbor-gen v0.0.0-20191216205031-b047b6acb3c0/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=

View File

@ -6,6 +6,7 @@ import (
"github.com/filecoin-project/go-address"
commcid "github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/crypto"
"github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/types"
@ -13,18 +14,18 @@ import (
"github.com/filecoin-project/lotus/genesis"
)
func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis.GenesisMiner, error) {
k, err := wallet.GenerateKey(types.KTBLS)
func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis.Miner, error) {
k, err := wallet.GenerateKey(crypto.SigTypeBLS)
if err != nil {
return nil, err
}
genm := &genesis.GenesisMiner{
genm := &genesis.Miner{
Owner: k.Address,
Worker: k.Address,
SectorSize: ssize,
Sectors: make([]*genesis.PreSeal, sectors),
Key: k.KeyInfo,
//Key: k.KeyInfo,
}
for i := range genm.Sectors {

View File

@ -187,7 +187,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
params := &miner.ProveCommitSectorParams{
SectorNumber: sector.SectorID,
Proof: abi.SealProof{ProofBytes: proof},
Proof: proof,
}
enc, aerr := actors.SerializeParams(params)