working towards a working genesis generator
This commit is contained in:
parent
4ad160ef80
commit
6d0eec6395
@ -36,6 +36,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
"github.com/filecoin-project/lotus/lib/sigs"
|
"github.com/filecoin-project/lotus/lib/sigs"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
|
"github.com/filecoin-project/lotus/storage/sbmock"
|
||||||
|
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -161,7 +162,7 @@ func NewGenerator() (*ChainGen, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
sys := vm.Syscalls(sectorbuilder.ProofVerifier)
|
sys := vm.Syscalls(&genFakeVerifier{})
|
||||||
|
|
||||||
tpl := genesis.Template{
|
tpl := genesis.Template{
|
||||||
Accounts: []genesis.Actor{
|
Accounts: []genesis.Actor{
|
||||||
@ -662,3 +663,22 @@ func ComputeVRF(ctx context.Context, sign SignFunc, worker, miner address.Addres
|
|||||||
|
|
||||||
return sig.Data, nil
|
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")
|
||||||
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"github.com/filecoin-project/specs-actors/actors/builtin"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"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-cid"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
bstore "github.com/ipfs/go-ipfs-blockstore"
|
bstore "github.com/ipfs/go-ipfs-blockstore"
|
||||||
@ -210,7 +211,7 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
|
|||||||
return state, nil
|
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)
|
st, err := MakeInitialStateTree(ctx, bs, template)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("make initial state tree failed: %w", err)
|
return nil, xerrors.Errorf("make initial state tree failed: %w", err)
|
||||||
|
@ -3,6 +3,9 @@ package genesis
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
"github.com/filecoin-project/specs-actors/actors/builtin/power"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"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) {
|
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 {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create NewVM: %w", err)
|
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
|
// Add market funds
|
||||||
|
|
||||||
{
|
{
|
||||||
params := mustEnc(&m.Worker)
|
params := mustEnc(&maddr)
|
||||||
_, err := doExecValue(ctx, vm, actors.StorageMarketAddress, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
|
_, err := doExecValue(ctx, vm, actors.StorageMarketAddress, m.Worker, m.MarketBalance, builtin.MethodsMarket.AddBalance, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
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{}
|
params := &market.PublishStorageDealsParams{}
|
||||||
for _, preseal := range m.Sectors {
|
for _, preseal := range m.Sectors {
|
||||||
|
|
||||||
params.Deals = append(params.Deals, market.ClientDealProposal{
|
params.Deals = append(params.Deals, market.ClientDealProposal{
|
||||||
Proposal: preseal.Deal,
|
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))
|
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
|
// Publish preseals
|
||||||
|
|
||||||
{
|
for pi, preseal := range m.Sectors {
|
||||||
for pi, preseal := range m.Sectors {
|
// Precommit
|
||||||
// Precommit
|
params := &miner.SectorPreCommitInfo{
|
||||||
{
|
SectorNumber: preseal.SectorID,
|
||||||
params := &miner.SectorPreCommitInfo{
|
SealedCID: commcid.ReplicaCommitmentV1ToCID(preseal.CommR[:]),
|
||||||
SectorNumber: preseal.SectorID,
|
SealEpoch: 0,
|
||||||
SealedCID: commcid.ReplicaCommitmentV1ToCID(preseal.CommR[:]),
|
DealIDs: []abi.DealID{dealIDs[pi]},
|
||||||
SealEpoch: 0,
|
Expiration: preseal.Deal.EndEpoch,
|
||||||
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 {
|
||||||
_, err := doExecValue(ctx, vm, maddr, m.Worker, big.Zero(), builtin.MethodsMiner.PreCommitSector, mustEnc(params))
|
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
||||||
if err != nil {
|
}
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Commit
|
// You can't prove sector commitments at the same height that you precommit them
|
||||||
{
|
vm.SetBlockHeight(7) // needs to be between PorepMinDelay and PorepMaxDelay
|
||||||
params := &miner.ProveCommitSectorParams{
|
|
||||||
SectorNumber: preseal.SectorID,
|
// Commit
|
||||||
Proof: abi.SealProof{},
|
for _, preseal := range m.Sectors {
|
||||||
}
|
params := &miner.ProveCommitSectorParams{
|
||||||
_, err := doExecValue(ctx, vm, maddr, m.Worker, big.Zero(), builtin.MethodsMiner.ProveCommitSector, mustEnc(params))
|
SectorNumber: preseal.SectorID,
|
||||||
if err != nil {
|
Proof: nil,
|
||||||
return cid.Undef, xerrors.Errorf("failed to create genesis miner: %w", err)
|
}
|
||||||
}
|
_, 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)
|
c, err := vm.Flush(ctx)
|
||||||
return c, err
|
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
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/chain/vm"
|
"github.com/filecoin-project/lotus/chain/vm"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin"
|
"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"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
cbg "github.com/whyrusleeping/cbor-gen"
|
cbg "github.com/whyrusleeping/cbor-gen"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
@ -36,7 +37,7 @@ type StateManager struct {
|
|||||||
stCache map[string][]cid.Cid
|
stCache map[string][]cid.Cid
|
||||||
compWait map[string]chan struct{}
|
compWait map[string]chan struct{}
|
||||||
stlk sync.Mutex
|
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 {
|
func NewStateManager(cs *store.ChainStore) *StateManager {
|
||||||
@ -679,6 +680,6 @@ func (sm *StateManager) ValidateChain(ctx context.Context, ts *types.TipSet) err
|
|||||||
return nil
|
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
|
sm.newVM = nvm
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"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"
|
"github.com/filecoin-project/specs-actors/actors/util/adt"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
"go.uber.org/multierr"
|
"go.uber.org/multierr"
|
||||||
@ -63,10 +64,10 @@ type ChainStore struct {
|
|||||||
mmCache *lru.ARCCache
|
mmCache *lru.ARCCache
|
||||||
tsCache *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)
|
c, _ := lru.NewARC(2048)
|
||||||
tsc, _ := lru.NewARC(4096)
|
tsc, _ := lru.NewARC(4096)
|
||||||
cs := &ChainStore{
|
cs := &ChainStore{
|
||||||
@ -861,7 +862,7 @@ func (cs *ChainStore) Store(ctx context.Context) adt.Store {
|
|||||||
return ActorStore(ctx, cs.bs)
|
return ActorStore(ctx, cs.bs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *ChainStore) VMSys() *types.VMSyscalls {
|
func (cs *ChainStore) VMSys() runtime.Syscalls {
|
||||||
return cs.vmcalls
|
return cs.vmcalls
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,12 +35,12 @@ func testBlockHeader(t testing.TB) *BlockHeader {
|
|||||||
},
|
},
|
||||||
Parents: []cid.Cid{c, c},
|
Parents: []cid.Cid{c, c},
|
||||||
ParentMessageReceipts: 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),
|
ParentWeight: NewInt(123125126212),
|
||||||
Messages: c,
|
Messages: c,
|
||||||
Height: 85919298723,
|
Height: 85919298723,
|
||||||
ParentStateRoot: c,
|
ParentStateRoot: c,
|
||||||
BlockSig: &Signature{Type: KTBLS, Data: []byte("boo! im a signature")},
|
BlockSig: &crypto.Signature{Type: crypto.SigTypeBLS, Data: []byte("boo! im a signature")},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func (s *Signature) UnmarshalCBOR(br io.Reader) error {
|
|||||||
return err
|
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])
|
return fmt.Errorf("invalid signature type in cbor input: %d", buf[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,14 @@ package types
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSignatureSerializeRoundTrip(t *testing.T) {
|
func TestSignatureSerializeRoundTrip(t *testing.T) {
|
||||||
s := &Signature{
|
s := &Signature{
|
||||||
Data: []byte("foo bar cat dog"),
|
Data: []byte("foo bar cat dog"),
|
||||||
Type: KTBLS,
|
Type: crypto.SigTypeBLS,
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"github.com/filecoin-project/go-sectorbuilder"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"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/go-address"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
"github.com/filecoin-project/lotus/chain/actors/aerrors"
|
||||||
@ -44,7 +45,7 @@ type VMContext interface {
|
|||||||
ChargeGas(uint64) aerrors.ActorError
|
ChargeGas(uint64) aerrors.ActorError
|
||||||
GetRandomness(height abi.ChainEpoch) ([]byte, aerrors.ActorError)
|
GetRandomness(height abi.ChainEpoch) ([]byte, aerrors.ActorError)
|
||||||
GetBalance(address.Address) (BigInt, aerrors.ActorError)
|
GetBalance(address.Address) (BigInt, aerrors.ActorError)
|
||||||
Sys() *VMSyscalls
|
Sys() runtime.Syscalls
|
||||||
|
|
||||||
Context() context.Context
|
Context() context.Context
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,8 @@ func (rs *runtimeShim) shimCall(f func() interface{}) (rval []byte, aerr aerrors
|
|||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
if ar, ok := r.(aerrors.ActorError); ok {
|
if ar, ok := r.(aerrors.ActorError); ok {
|
||||||
|
fmt.Println("VM.Call failure: ", ar)
|
||||||
|
debug.PrintStack()
|
||||||
aerr = ar
|
aerr = ar
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -152,7 +154,7 @@ func (rs *runtimeShim) NewActorAddress() address.Address {
|
|||||||
|
|
||||||
func (rs *runtimeShim) CreateActor(codeId cid.Cid, address address.Address) {
|
func (rs *runtimeShim) CreateActor(codeId cid.Cid, address address.Address) {
|
||||||
var err error
|
var err error
|
||||||
st,err := rs.vmctx.StateTree()
|
st, err := rs.vmctx.StateTree()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rs.Abortf(exitcode.SysErrInternal, "getting statetree: %v", err)
|
rs.Abortf(exitcode.SysErrInternal, "getting statetree: %v", err)
|
||||||
}
|
}
|
||||||
@ -175,7 +177,7 @@ func (rs *runtimeShim) DeleteActor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (rs *runtimeShim) Syscalls() vmr.Syscalls {
|
func (rs *runtimeShim) Syscalls() vmr.Syscalls {
|
||||||
panic("implement me")
|
return rs.vmctx.Sys()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *runtimeShim) StartSpan(name string) vmr.TraceSpan {
|
func (rs *runtimeShim) StartSpan(name string) vmr.TraceSpan {
|
||||||
@ -188,8 +190,7 @@ func (rs *runtimeShim) ValidateImmediateCallerIs(as ...address.Address) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Println("Caller: ", rs.vmctx.Message().From, as)
|
rs.Abortf(exitcode.ErrForbidden, "caller %s is not one of %s", rs.vmctx.Message().From, as)
|
||||||
panic("we like to panic when people call the wrong methods")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *runtimeShim) ImmediateCaller() address.Address {
|
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) {
|
func (rs *runtimeShim) Send(to address.Address, method abi.MethodNum, m vmr.CBORMarshaler, value abi.TokenAmount) (vmr.SendReturn, exitcode.ExitCode) {
|
||||||
buf := new(bytes.Buffer)
|
var params []byte
|
||||||
if err := m.MarshalCBOR(buf); err != nil {
|
if m != nil {
|
||||||
rs.Abortf(exitcode.SysErrInvalidParameters, "failed to marshal input parameters: %s", err)
|
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 != nil {
|
||||||
if err.IsFatal() {
|
if err.IsFatal() {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -1,30 +1,114 @@
|
|||||||
package vm
|
package vm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-sectorbuilder"
|
"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"
|
"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
|
// Actual type is defined in chain/types/vmcontext.go because the VMContext interface is there
|
||||||
|
|
||||||
func Syscalls(verifier sectorbuilder.Verifier) *types.VMSyscalls {
|
func Syscalls(verifier sectorbuilder.Verifier) runtime.Syscalls {
|
||||||
return &types.VMSyscalls{
|
return &syscallShim{verifier}
|
||||||
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()
|
type syscallShim struct {
|
||||||
ok, err := verifier.VerifySeal(ssize, commR, commD, maddr, ticket, seed, sectorID, proof)
|
verifier sectorbuilder.Verifier
|
||||||
if err != nil {
|
}
|
||||||
return false, aerrors.Absorb(err, 25, "verify seal failed")
|
|
||||||
}
|
func (ss *syscallShim) ComputeUnsealedSectorCID(ssize abi.SectorSize, pieces []abi.PieceInfo) (cid.Cid, error) {
|
||||||
|
// TODO: does this pull in unwanted dependencies?
|
||||||
return ok, nil
|
var ffipieces []ffi.PublicPieceInfo
|
||||||
},
|
for _, p := range pieces {
|
||||||
VerifyFallbackPost: verifier.VerifyFallbackPost,
|
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
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||||
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
"github.com/filecoin-project/specs-actors/actors/builtin/account"
|
||||||
"github.com/filecoin-project/specs-actors/actors/crypto"
|
"github.com/filecoin-project/specs-actors/actors/crypto"
|
||||||
|
"github.com/filecoin-project/specs-actors/actors/runtime"
|
||||||
block "github.com/ipfs/go-block-format"
|
block "github.com/ipfs/go-block-format"
|
||||||
cid "github.com/ipfs/go-cid"
|
cid "github.com/ipfs/go-cid"
|
||||||
hamt "github.com/ipfs/go-hamt-ipld"
|
hamt "github.com/ipfs/go-hamt-ipld"
|
||||||
@ -60,7 +61,7 @@ type VMContext struct {
|
|||||||
gasAvailable types.BigInt
|
gasAvailable types.BigInt
|
||||||
gasUsed types.BigInt
|
gasUsed types.BigInt
|
||||||
|
|
||||||
sys *types.VMSyscalls
|
sys runtime.Syscalls
|
||||||
|
|
||||||
// root cid of the state of the actor this invocation will be on
|
// root cid of the state of the actor this invocation will be on
|
||||||
sroot cid.Cid
|
sroot cid.Cid
|
||||||
@ -83,7 +84,7 @@ func (vmc *VMContext) GetRandomness(height abi.ChainEpoch) ([]byte, aerrors.Acto
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vmc *VMContext) Sys() *types.VMSyscalls {
|
func (vmc *VMContext) Sys() runtime.Syscalls {
|
||||||
return vmc.sys
|
return vmc.sys
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,10 +319,10 @@ type VM struct {
|
|||||||
inv *invoker
|
inv *invoker
|
||||||
rand Rand
|
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)
|
buf := bufbstore.NewBufferedBstore(cbs)
|
||||||
cst := cbor.NewCborStore(buf)
|
cst := cbor.NewCborStore(buf)
|
||||||
state, err := state.LoadStateTree(cst, base)
|
state, err := state.LoadStateTree(cst, base)
|
||||||
|
6
go.mod
6
go.mod
@ -12,7 +12,7 @@ require (
|
|||||||
github.com/docker/go-units v0.4.0
|
github.com/docker/go-units v0.4.0
|
||||||
github.com/filecoin-project/chain-validation v0.0.3
|
github.com/filecoin-project/chain-validation v0.0.3
|
||||||
github.com/filecoin-project/filecoin-ffi v0.0.0-20191219131535-bb699517a590
|
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-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-cbor-util v0.0.0-20191219014500-08c40a1e63a2
|
||||||
github.com/filecoin-project/go-crypto v0.0.0-20191218222705-effae4ea9f03
|
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-paramfetch v0.0.1
|
||||||
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200210220012-eb75ec747d6b
|
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/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/gbrlsnchs/jwt/v3 v3.0.0-beta.1
|
||||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||||
github.com/gorilla/mux v1.7.3
|
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/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/coreos/go-systemd => github.com/coreos/go-systemd/v22 v22.0.0
|
||||||
|
|
||||||
|
replace github.com/filecoin-project/specs-actors => ../specs-actors
|
||||||
|
7
go.sum
7
go.sum
@ -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/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 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.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 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-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=
|
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-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 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-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 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
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=
|
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/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 h1:X4n8JG2e2biEZZXdBKt9HX7DN3bYGFUqljqqy0DqgnY=
|
||||||
github.com/whyrusleeping/bencher v0.0.0-20190829221104-bb6607aa8bba/go.mod h1:CHQnYnQUEPydYCwuy8lmTHfGmdw9TKrhWV0xLx8l0oM=
|
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-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-20191212224538-d370462a7e8a/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
|
||||||
github.com/whyrusleeping/cbor-gen v0.0.0-20191216205031-b047b6acb3c0/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
|
github.com/whyrusleeping/cbor-gen v0.0.0-20191216205031-b047b6acb3c0/go.mod h1:xdlJQaiqipF0HW+Mzpg7XRM3fWbGvfgFlcppuvlkIvY=
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
commcid "github.com/filecoin-project/go-fil-commcid"
|
commcid "github.com/filecoin-project/go-fil-commcid"
|
||||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
"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/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -13,18 +14,18 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/genesis"
|
"github.com/filecoin-project/lotus/genesis"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis.GenesisMiner, error) {
|
func PreSeal(ssize abi.SectorSize, maddr address.Address, sectors int) (*genesis.Miner, error) {
|
||||||
k, err := wallet.GenerateKey(types.KTBLS)
|
k, err := wallet.GenerateKey(crypto.SigTypeBLS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
genm := &genesis.GenesisMiner{
|
genm := &genesis.Miner{
|
||||||
Owner: k.Address,
|
Owner: k.Address,
|
||||||
Worker: k.Address,
|
Worker: k.Address,
|
||||||
SectorSize: ssize,
|
SectorSize: ssize,
|
||||||
Sectors: make([]*genesis.PreSeal, sectors),
|
Sectors: make([]*genesis.PreSeal, sectors),
|
||||||
Key: k.KeyInfo,
|
//Key: k.KeyInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range genm.Sectors {
|
for i := range genm.Sectors {
|
||||||
|
@ -187,7 +187,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo)
|
|||||||
|
|
||||||
params := &miner.ProveCommitSectorParams{
|
params := &miner.ProveCommitSectorParams{
|
||||||
SectorNumber: sector.SectorID,
|
SectorNumber: sector.SectorID,
|
||||||
Proof: abi.SealProof{ProofBytes: proof},
|
Proof: proof,
|
||||||
}
|
}
|
||||||
|
|
||||||
enc, aerr := actors.SerializeParams(params)
|
enc, aerr := actors.SerializeParams(params)
|
||||||
|
Loading…
Reference in New Issue
Block a user