Merge remote-tracking branch 'origin/testnet/3' into feat/4stage-seal

This commit is contained in:
Łukasz Magiera 2020-03-06 00:59:12 +01:00
commit 1c052b7c81
18 changed files with 88 additions and 290 deletions

View File

@ -188,13 +188,9 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B
}
}
owner, err := GetMinerOwner(ctx, sm, pstate, b.Miner)
if err != nil {
return cid.Undef, cid.Undef, xerrors.Errorf("failed to get owner for miner %s: %w", b.Miner, err)
}
var err error
params, err := actors.SerializeParams(&reward.AwardBlockRewardParams{
MinerOwner: owner,
Miner: b.Miner,
Penalty: penalty,
GasReward: gasReward,
})

View File

@ -39,9 +39,9 @@ func (f *Factories) NewRandomnessSource() vstate.RandomnessSource {
}
func (f *Factories) NewValidationConfig() vstate.ValidationConfig {
trackGas := false
checkExit := false
checkRet := false
trackGas := true
checkExit := true
checkRet := false // TODO enable return value checking once https://github.com/filecoin-project/specs-actors/pull/230 lands
// ignore gas and return value assertions
return NewConfig(trackGas, checkExit, checkRet)
}

View File

@ -8,7 +8,6 @@ import (
"github.com/filecoin-project/go-crypto"
acrypto "github.com/filecoin-project/specs-actors/actors/crypto"
ffi "github.com/filecoin-project/filecoin-ffi"
"github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/wallet"
)
@ -87,7 +86,8 @@ func (k *KeyManager) newBLSKey() *wallet.Key {
// FIXME: bls needs deterministic key generation
//sk := ffi.PrivateKeyGenerate(s.blsSeed)
// s.blsSeed++
sk := ffi.PrivateKeyGenerate()
sk := [32]byte{}
sk[0] = uint8(k.blsSeed+1) // hack to keep gas values determinist
key, err := wallet.NewKey(types.KeyInfo{
Type: wallet.KTBLS,
PrivateKey: sk[:],

View File

@ -235,248 +235,3 @@ func (s *StateWrapper) SetupSingletonActor(addr address.Address) (vstate.Actor,
return nil, xerrors.Errorf("%v is not a singleton actor address", addr)
}
}
/*
func NewState() *StateWrapper {
bs := blockstore.NewBlockstore(datastore.NewMapDatastore())
cst := cbor.NewCborStore(bs)
// Put EmptyObjectCid value in the store. When an actor is initially created its Head is set to this value.
_, err := cst.Put(context.TODO(), map[string]string{})
if err != nil {
panic(err)
}
treeImpl, err := state.NewStateTree(cst)
if err != nil {
panic(err) // Never returns error, the error return should be removed.
}
root, err := treeImpl.Flush(context.TODO())
if err != nil {
panic(err)
}
storageImpl := &directStorage{cst}
return &StateWrapper{bs, cst, newKeyStore(), root, storageImpl}
}
func (s *StateWrapper) Cid() cid.Cid {
return s.stateRoot
}
func (s *StateWrapper) Actor(addr address.Address) (vstate.Actor, error) {
vaddr, err := address.NewFromBytes(addr.Bytes())
if err != nil {
return nil, err
}
tree, err := state.LoadStateTree(s.cst, s.stateRoot)
if err != nil {
return nil, err
}
fcActor, err := tree.GetActor(vaddr)
if err != nil {
return nil, err
}
return &actorWrapper{*fcActor}, nil
}
func (s *StateWrapper) Storage(addr address.Address) (vstate.Storage, error) {
return s.storage, nil
}
func (s *StateWrapper) NewAccountAddress() (address.Address, error) {
return s.keys.NewAddress()
}
func (s *StateWrapper) SetActor(addr address.Address, code vactors.ActorCodeID, balance vtypes.BigInt) (vstate.Actor, vstate.Storage, error) {
addrInt, err := address.NewFromBytes(addr.Bytes())
if err != nil {
return nil, nil, err
}
tree, err := state.LoadStateTree(s.cst, s.stateRoot)
if err != nil {
return nil, nil, err
}
actr := &actorWrapper{types.Actor{
Code: fromActorCode(code),
Balance: types.BigInt{balance.Int},
Head: vm.EmptyObjectCid,
}}
// The ID-based address is dropped here, but should be reported back to the caller.
_, err = tree.RegisterNewAddress(addrInt, &actr.Actor)
if err != nil {
return nil, nil, xerrors.Errorf("register new address for actor: %w", err)
}
return actr, s.storage, s.flush(tree)
}
func (s *StateWrapper) SetSingletonActor(addr vactors.SingletonActorID, balance vtypes.BigInt) (vstate.Actor, vstate.Storage, error) {
vaddr := fromSingletonAddress(addr)
tree, err := state.LoadStateTree(s.cst, s.stateRoot)
if err != nil {
return nil, nil, err
}
lotusAddr, err := address.NewFromBytes(vaddr.Bytes())
if err != nil {
return nil, nil, err
}
switch lotusAddr {
case actors.InitAddress:
initact, err := genesis.SetupInitActor(s.bs, "testing", nil)
if err != nil {
return nil, nil, err
}
if err := tree.SetActor(actors.InitAddress, initact); err != nil {
return nil, nil, xerrors.Errorf("set init actor: %w", err)
}
return &actorWrapper{*initact}, s.storage, s.flush(tree)
case actors.StorageMarketAddress:
nsroot, err := genesis.SetupStorageMarketActor(s.bs)
if err != nil {
return nil, nil, err
}
s.stateRoot = nsroot
tree, err = state.LoadStateTree(s.cst, s.stateRoot)
if err != nil {
return nil, nil, err
}
smact, err := tree.GetActor(actors.StorageMarketAddress)
if err != nil {
return nil, nil, err
}
return &actorWrapper{*smact}, s.storage, s.flush(tree)
case actors.StoragePowerAddress:
spact, err := genesis.SetupStoragePowerActor(s.bs)
if err != nil {
return nil, nil, err
}
if err := tree.SetActor(actors.StoragePowerAddress, spact); err != nil {
return nil, nil, xerrors.Errorf("set network storage market actor: %w", err)
}
return &actorWrapper{*spact}, s.storage, s.flush(tree)
case actors.NetworkAddress:
ntwkact := &types.Actor{
Code: actors.AccountCodeCid,
Balance: types.BigInt{balance.Int},
Head: vm.EmptyObjectCid,
}
if err := tree.SetActor(actors.NetworkAddress, ntwkact); err != nil {
return nil, nil, xerrors.Errorf("set network actor: %w", err)
}
return &actorWrapper{*ntwkact}, s.storage, s.flush(tree)
case actors.BurntFundsAddress:
ntwkact := &types.Actor{
Code: actors.AccountCodeCid,
Balance: types.BigInt{balance.Int},
Head: vm.EmptyObjectCid,
}
if err := tree.SetActor(actors.BurntFundsAddress, ntwkact); err != nil {
return nil, nil, xerrors.Errorf("set network actor: %w", err)
}
return &actorWrapper{*ntwkact}, s.storage, s.flush(tree)
default:
return nil, nil, xerrors.Errorf("%v is not a singleton actor address", addr)
}
}
func (s *StateWrapper) Sign(ctx context.Context, addr address.Address, data []byte) (*vtypes.Signature, error) {
sig, err := s.keys.Sign(ctx, addr, data)
if err != nil {
return nil, err
}
return &vtypes.Signature{
Type: sig.Type,
Data: sig.Data,
}, nil
}
func (s *StateWrapper) Signer() *keyStore {
return s.keys
}
// Flushes a state tree to storage and sets this state's root to that tree's root CID.
func (s *StateWrapper) flush(tree *state.StateTree) (err error) {
s.stateRoot, err = tree.Flush(context.TODO())
return
}
//
// Key store
//
type keyStore struct {
// Private keys by address
keys map[address.Address]vtypes.KeyInfo
// Seed for deterministic key generation.
seed int64
}
func newKeyStore() *keyStore {
return &keyStore{
keys: make(map[address.Address]vtypes.KeyInfo),
seed: 0,
}
}
func (s *keyStore) NewAddress() (address.Address, error) {
randSrc := rand.New(rand.NewSource(s.seed))
prv, err := crypto.GenerateKeyFromSeed(randSrc)
if err != nil {
return address.Undef, err
}
vki := vtypes.KeyInfo{
PrivateKey: prv,
Type: types.KTSecp256k1,
}
key, err := wallet.NewKey(types.KeyInfo{
Type: vki.Type,
PrivateKey: vki.PrivateKey,
})
if err != nil {
return address.Undef, err
}
vaddr, err := address.NewFromBytes(key.Address.Bytes())
if err != nil {
return address.Undef, err
}
s.keys[vaddr] = vki
s.seed++
return address.NewFromBytes(key.Address.Bytes())
}
func (s *keyStore) Sign(ctx context.Context, addr address.Address, data []byte) (*types.Signature, error) {
ki, ok := s.keys[addr]
if !ok {
return &types.Signature{}, fmt.Errorf("unknown address %v", addr)
}
b2sum := blake2b.Sum256(data)
digest, err := crypto.Sign(ki.PrivateKey, b2sum[:])
if err != nil {
return &types.Signature{}, err
}
return &types.Signature{
Type: types.KTSecp256k1,
Data: digest,
}, nil
}
//
// Storage
//
type directStorage struct {
cst cbor.IpldStore
}
func (d *directStorage) Get(c cid.Cid, out interface{}) error {
if err := d.cst.Get(context.TODO(), c, out.(cbg.CBORUnmarshaler)); err != nil {
return err
}
return nil
}
*/

View File

@ -7,7 +7,6 @@ import (
"testing"
suites "github.com/filecoin-project/chain-validation/suites"
"github.com/filecoin-project/chain-validation/suites/message"
factory "github.com/filecoin-project/lotus/chain/validation"
)
@ -34,13 +33,7 @@ var TestSuiteSkipper TestSkipper
func init() {
// initialize the test skipper with tests being skipped
TestSuiteSkipper = TestSkipper{testSkips: []suites.TestCase{
// Fails due to gas mismatches
message.TestPaych,
// Fails due to state initialization
message.TestMultiSigActor,
// Fails due to state initialization
//message.TestMessageApplicationEdgecases,
/* tests to skip go here */
}}
}

View File

@ -191,7 +191,7 @@ func (vmc *VMContext) ChargeGas(amount uint64) aerrors.ActorError {
toUse := types.NewInt(amount)
vmc.gasUsed = types.BigAdd(vmc.gasUsed, toUse)
if vmc.gasUsed.GreaterThan(vmc.gasAvailable) {
return aerrors.Newf(outOfGasErrCode, "not enough gas: used=%s, available=%s", vmc.gasUsed, vmc.gasAvailable)
return aerrors.Newf(uint8(exitcode.SysErrOutOfGas), "not enough gas: used=%s, available=%s", vmc.gasUsed, vmc.gasAvailable)
}
return nil
}
@ -461,6 +461,20 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet,
return nil, err
}
serMsg, err := msg.Serialize()
if err != nil {
return nil, xerrors.Errorf("could not serialize message: %w", err)
}
msgGasCost := uint64(len(serMsg)) * gasPerMessageByte
if msgGasCost > msg.GasLimit.Uint64() {
return &ApplyRet{
MessageReceipt: types.MessageReceipt{
ExitCode: exitcode.SysErrOutOfGas,
GasUsed: msg.GasLimit,
},
}, nil
}
st := vm.cstate
if err := st.Snapshot(ctx); err != nil {
return nil, xerrors.Errorf("snapshot failed: %w", err)
@ -480,11 +494,6 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet,
return nil, xerrors.Errorf("failed to look up from actor: %w", err)
}
serMsg, err := msg.Serialize()
if err != nil {
return nil, xerrors.Errorf("could not serialize message: %w", err)
}
msgGasCost := uint64(len(serMsg)) * gasPerMessageByte
gascost := types.BigMul(msg.GasLimit, msg.GasPrice)
totalCost := types.BigAdd(gascost, msg.Value)

View File

@ -68,6 +68,7 @@ var chainHeadCmd = &cli.Command{
var chainGetBlock = &cli.Command{
Name: "getblock",
Usage: "Get a block and print its details",
ArgsUsage: "[blockCid]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "raw",
@ -158,6 +159,7 @@ func apiMsgCids(in []api.Message) []cid.Cid {
var chainReadObjCmd = &cli.Command{
Name: "read-obj",
Usage: "Read the raw bytes of an object",
ArgsUsage: "[objectCid]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -184,6 +186,7 @@ var chainReadObjCmd = &cli.Command{
var chainGetMsgCmd = &cli.Command{
Name: "getmessage",
Usage: "Get and print a message by its cid",
ArgsUsage: "[messageCid]",
Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() {
return fmt.Errorf("must pass a cid of a message to get")
@ -231,6 +234,7 @@ var chainGetMsgCmd = &cli.Command{
var chainSetHeadCmd = &cli.Command{
Name: "sethead",
Usage: "manually set the local nodes head tipset (Caution: normally only used for recovery)",
ArgsUsage: "[tipsetkey]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "genesis",
@ -357,6 +361,7 @@ var chainListCmd = &cli.Command{
var chainGetCmd = &cli.Command{
Name: "get",
Usage: "Get chain DAG node by path",
ArgsUsage: "[path]",
Description: `Get ipld node under a specified path:
lotus chain get /ipfs/[cid]/some/path
@ -414,6 +419,7 @@ func printTipSet(format string, ts *types.TipSet) {
var chainBisectCmd = &cli.Command{
Name: "bisect",
Usage: "bisect chain for an event",
ArgsUsage: "[minHeight maxHeight path shellCommand <shellCommandArgs (if any)>]",
Description: `Bisect the chain state tree:
lotus chain bisect [min height] [max height] '1/2/3/state/path' 'shell command' 'args'
@ -519,6 +525,7 @@ var chainBisectCmd = &cli.Command{
var chainExportCmd = &cli.Command{
Name: "export",
Usage: "export chain to a car file",
ArgsUsage: "[outputPath]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "tipset",
@ -566,6 +573,7 @@ var chainExportCmd = &cli.Command{
var slashConsensusFault = &cli.Command{
Name: "slash-consensus",
Usage: "Report consensus fault",
ArgsUsage: "[blockCid1 blockCid2]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {

View File

@ -37,6 +37,7 @@ var clientCmd = &cli.Command{
var clientImportCmd = &cli.Command{
Name: "import",
Usage: "Import data",
ArgsUsage: "[inputPath]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -83,6 +84,7 @@ var clientLocalCmd = &cli.Command{
var clientDealCmd = &cli.Command{
Name: "deal",
Usage: "Initialize storage deal with a miner",
ArgsUsage: "[dataCid miner price duration]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "manual-transfer",
@ -193,6 +195,7 @@ var clientDealCmd = &cli.Command{
var clientFindCmd = &cli.Command{
Name: "find",
Usage: "find data in the network",
ArgsUsage: "[dataCid]",
Action: func(cctx *cli.Context) error {
if !cctx.Args().Present() {
fmt.Println("Usage: find [CID]")
@ -242,6 +245,7 @@ var clientFindCmd = &cli.Command{
var clientRetrieveCmd = &cli.Command{
Name: "retrieve",
Usage: "retrieve data from network",
ArgsUsage: "[dataCid outputPath]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "address",
@ -312,6 +316,7 @@ var clientRetrieveCmd = &cli.Command{
var clientQueryAskCmd = &cli.Command{
Name: "query-ask",
Usage: "find a miners ask",
ArgsUsage: "[minerAddress]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "peerid",

View File

@ -44,7 +44,7 @@ var logList = &cli.Command{
var logSetLevel = &cli.Command{
Name: "set-level",
Usage: "Set log level",
ArgsUsage: "<level>",
ArgsUsage: "[level]",
Description: `Set the log level for logging systems:
The system flag can be specified multiple times.

View File

@ -49,6 +49,7 @@ var multisigCmd = &cli.Command{
var msigCreateCmd = &cli.Command{
Name: "create",
Usage: "Create a new multisig wallet",
ArgsUsage: "[address1 address2 ...]",
Flags: []cli.Flag{
&cli.Int64Flag{
Name: "required",
@ -159,6 +160,7 @@ var msigCreateCmd = &cli.Command{
var msigInspectCmd = &cli.Command{
Name: "inspect",
Usage: "Inspect a multisig wallet",
ArgsUsage: "[address]",
Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
@ -271,6 +273,7 @@ func state(tx *samsig.Transaction) string {
var msigProposeCmd = &cli.Command{
Name: "propose",
Usage: "Propose a multisig transaction",
ArgsUsage: "[multisigAddress destinationAddress value <methodName methodParams> (optional)]",
Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
@ -383,7 +386,8 @@ var msigProposeCmd = &cli.Command{
var msigApproveCmd = &cli.Command{
Name: "approve",
Usage: "Approve a multisig transaction",
Usage: "Approve a multisig message",
ArgsUsage: "[multisigAddress messageId]",
Flags: []cli.Flag{},
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
@ -393,8 +397,8 @@ var msigApproveCmd = &cli.Command{
defer closer()
ctx := ReqContext(cctx)
if cctx.Args().Len() < 2 {
return fmt.Errorf("must pass multisig address and transaction ID")
if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass multisig address and message ID")
}
msig, err := address.NewFromString(cctx.Args().Get(0))

View File

@ -76,7 +76,7 @@ var netListen = &cli.Command{
var netConnect = &cli.Command{
Name: "connect",
Usage: "Connect to a peer",
ArgsUsage: "<peer multiaddr>",
ArgsUsage: "[peerMultiaddr]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetAPI(cctx)
if err != nil {
@ -129,7 +129,7 @@ var netId = &cli.Command{
var netFindPeer = &cli.Command{
Name: "findpeer",
Usage: "Find the addresses of a given peerID",
ArgsUsage: "<peer ID>",
ArgsUsage: "[peerId]",
Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 {
fmt.Println("Usage: findpeer [peer ID]")

View File

@ -25,6 +25,7 @@ var paychCmd = &cli.Command{
var paychGetCmd = &cli.Command{
Name: "get",
Usage: "Create a new payment channel or get existing one",
ArgsUsage: "[fromAddress toAddress amount]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 3 {
return fmt.Errorf("must pass three arguments: <from> <to> <available funds>")
@ -103,6 +104,7 @@ var paychVoucherCmd = &cli.Command{
var paychVoucherCreateCmd = &cli.Command{
Name: "create",
Usage: "Create a signed payment channel voucher",
ArgsUsage: "[channelAddress amount]",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "lane",
@ -153,6 +155,7 @@ var paychVoucherCreateCmd = &cli.Command{
var paychVoucherCheckCmd = &cli.Command{
Name: "check",
Usage: "Check validity of payment channel voucher",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass payment channel address and voucher to validate")
@ -188,6 +191,7 @@ var paychVoucherCheckCmd = &cli.Command{
var paychVoucherAddCmd = &cli.Command{
Name: "add",
Usage: "Add payment channel voucher to local datastore",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass payment channel address and voucher")
@ -223,6 +227,7 @@ var paychVoucherAddCmd = &cli.Command{
var paychVoucherListCmd = &cli.Command{
Name: "list",
Usage: "List stored vouchers for a given payment channel",
ArgsUsage: "[channelAddress]",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "export",
@ -272,6 +277,7 @@ var paychVoucherListCmd = &cli.Command{
var paychVoucherBestSpendableCmd = &cli.Command{
Name: "best-spendable",
Usage: "Print voucher with highest value that is currently spendable",
ArgsUsage: "[channelAddress]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 1 {
return fmt.Errorf("must pass payment channel address")
@ -326,6 +332,7 @@ var paychVoucherBestSpendableCmd = &cli.Command{
var paychVoucherSubmitCmd = &cli.Command{
Name: "submit",
Usage: "Submit voucher to chain to update payment channel state",
ArgsUsage: "[channelAddress voucher]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() != 2 {
return fmt.Errorf("must pass payment channel address and voucher")

View File

@ -11,7 +11,7 @@ import (
var sendCmd = &cli.Command{
Name: "send",
Usage: "Send funds between accounts",
ArgsUsage: "<target> <amount>",
ArgsUsage: "[targetAddress] [amount]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "source",

View File

@ -63,6 +63,7 @@ var stateCmd = &cli.Command{
var stateMinerInfo = &cli.Command{
Name: "miner-info",
Usage: "Retrieve miner information",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -154,6 +155,7 @@ func loadTipSet(ctx context.Context, cctx *cli.Context, api api.FullNode) (*type
var statePowerCmd = &cli.Command{
Name: "power",
Usage: "Query network or miner power",
ArgsUsage: "[<minerAddress> (optional)]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -197,6 +199,7 @@ var statePowerCmd = &cli.Command{
var stateSectorsCmd = &cli.Command{
Name: "sectors",
Usage: "Query the sector set of a miner",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -236,6 +239,7 @@ var stateSectorsCmd = &cli.Command{
var stateProvingSetCmd = &cli.Command{
Name: "proving",
Usage: "Query the proving set of a miner",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -275,6 +279,7 @@ var stateProvingSetCmd = &cli.Command{
var stateReplaySetCmd = &cli.Command{
Name: "replay",
Usage: "Replay a particular message within a tipset",
ArgsUsage: "[tipsetKey messageCid]",
Action: func(cctx *cli.Context) error {
if cctx.Args().Len() < 1 {
fmt.Println("usage: [tipset] <message cid>")
@ -381,6 +386,7 @@ var statePledgeCollateralCmd = &cli.Command{
var stateGetDealSetCmd = &cli.Command{
Name: "get-deal",
Usage: "View on-chain deal info",
ArgsUsage: "[dealId]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -391,7 +397,7 @@ var stateGetDealSetCmd = &cli.Command{
ctx := ReqContext(cctx)
if !cctx.Args().Present() {
return fmt.Errorf("must specify miner to list sectors for")
return fmt.Errorf("must specify deal ID")
}
dealid, err := strconv.ParseUint(cctx.Args().First(), 10, 64)
@ -482,6 +488,7 @@ var stateListActorsCmd = &cli.Command{
var stateGetActorCmd = &cli.Command{
Name: "get-actor",
Usage: "Print actor information",
ArgsUsage: "[actorrAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -523,6 +530,7 @@ var stateGetActorCmd = &cli.Command{
var stateLookupIDCmd = &cli.Command{
Name: "lookup",
Usage: "Find corresponding ID address",
ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -560,6 +568,7 @@ var stateLookupIDCmd = &cli.Command{
var stateSectorSizeCmd = &cli.Command{
Name: "sector-size",
Usage: "Look up miners sector size",
ArgsUsage: "[minerAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -570,7 +579,7 @@ var stateSectorSizeCmd = &cli.Command{
ctx := ReqContext(cctx)
if !cctx.Args().Present() {
return fmt.Errorf("must pass address of actor to get")
return fmt.Errorf("must pass miner's address")
}
addr, err := address.NewFromString(cctx.Args().First())
@ -596,6 +605,7 @@ var stateSectorSizeCmd = &cli.Command{
var stateReadStateCmd = &cli.Command{
Name: "read-state",
Usage: "View a json representation of an actors state",
ArgsUsage: "[actorAddress]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -788,6 +798,7 @@ var stateComputeStateCmd = &cli.Command{
var stateWaitMsgCmd = &cli.Command{
Name: "wait-msg",
Usage: "Wait for a message to appear on chain",
ArgsUsage: "[messageCid]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "timeout",
@ -828,6 +839,7 @@ var stateWaitMsgCmd = &cli.Command{
var stateCallCmd = &cli.Command{
Name: "call",
Usage: "Invoke a method on an actor locally",
ArgsUsage: "[toAddress methodId <param1 param2 ...> (optional)]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "from",

View File

@ -96,6 +96,7 @@ var syncWaitCmd = &cli.Command{
var syncMarkBadCmd = &cli.Command{
Name: "mark-bad",
Usage: "Mark the given block as bad, will prevent syncing to a chain that contains it",
ArgsUsage: "[blockCid]",
Action: func(cctx *cli.Context) error {
napi, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -120,6 +121,7 @@ var syncMarkBadCmd = &cli.Command{
var syncCheckBadCmd = &cli.Command{
Name: "check-bad",
Usage: "check if the given block was marked bad, and for what reason",
ArgsUsage: "[blockCid]",
Action: func(cctx *cli.Context) error {
napi, closer, err := GetFullNodeAPI(cctx)
if err != nil {

View File

@ -1,6 +1,7 @@
package cli
import (
"bufio"
"encoding/hex"
"encoding/json"
"fmt"
@ -32,7 +33,7 @@ var walletCmd = &cli.Command{
var walletNew = &cli.Command{
Name: "new",
Usage: "Generate a new key of the given type",
ArgsUsage: "[bls|secp256k1]",
ArgsUsage: "[bls|secp256k1 (default secp256k1)]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -83,7 +84,7 @@ var walletList = &cli.Command{
var walletBalance = &cli.Command{
Name: "balance",
Usage: "Get account balance",
ArgsUsage: "[account address]",
ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -136,6 +137,7 @@ var walletGetDefault = &cli.Command{
var walletSetDefault = &cli.Command{
Name: "set-default",
Usage: "Set default wallet address",
ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -160,6 +162,7 @@ var walletSetDefault = &cli.Command{
var walletExport = &cli.Command{
Name: "export",
Usage: "export keys",
ArgsUsage: "[address]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -195,6 +198,7 @@ var walletExport = &cli.Command{
var walletImport = &cli.Command{
Name: "import",
Usage: "import keys",
ArgsUsage: "[<path> (optional, will read from stdin if omitted)]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetFullNodeAPI(cctx)
if err != nil {
@ -205,7 +209,9 @@ var walletImport = &cli.Command{
var hexdata []byte
if !cctx.Args().Present() || cctx.Args().First() == "-" {
indata, err := ioutil.ReadAll(os.Stdin)
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter private key: ")
indata, err := reader.ReadBytes('\n')
if err != nil {
return err
}

4
go.mod
View File

@ -10,7 +10,7 @@ require (
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
github.com/coreos/go-systemd/v22 v22.0.0
github.com/docker/go-units v0.4.0
github.com/filecoin-project/chain-validation v0.0.6-0.20200304211828-4b541348b199
github.com/filecoin-project/chain-validation v0.0.6-0.20200305212458-670d41260fd7
github.com/filecoin-project/filecoin-ffi v0.0.0-20200226231125-fc253ccb5294
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
@ -23,7 +23,7 @@ require (
github.com/filecoin-project/go-paramfetch v0.0.2-0.20200218225740-47c639bab663
github.com/filecoin-project/go-sectorbuilder v0.0.2-0.20200304050010-2cfac00a93e7
github.com/filecoin-project/go-statestore v0.1.0
github.com/filecoin-project/specs-actors v0.0.0-20200304210626-21ee86aadcb9
github.com/filecoin-project/specs-actors v0.0.0-20200305205312-53bb01da9aeb
github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/google/uuid v1.1.1

9
go.sum
View File

@ -97,8 +97,9 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP
github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY=
github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8=
github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E=
github.com/filecoin-project/chain-validation v0.0.6-0.20200304211828-4b541348b199 h1:HIdN3/s/fda3kQYMawG8ysYC207LJ5GnH0XziyTgQJk=
github.com/filecoin-project/chain-validation v0.0.6-0.20200304211828-4b541348b199/go.mod h1:JU9alo66MwdCHkpk1kDXB8vT8A/oMkTkdZ4mQjA4I5E=
github.com/filecoin-project/chain-validation v0.0.6-0.20200305212458-670d41260fd7 h1:elmXXIpuwO7UNWABiUUMISgwt8O9HkqMLKmJEzuxqR8=
github.com/filecoin-project/chain-validation v0.0.6-0.20200305212458-670d41260fd7/go.mod h1:g9PtEzAwUNn45uM2xOWS4fUKTOFRQAFKZz2zYdKQivk=
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=
@ -127,8 +128,8 @@ github.com/filecoin-project/go-statestore v0.1.0 h1:t56reH59843TwXHkMcwyuayStBIi
github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI=
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-20200226200336-94c9b92b2775/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU=
github.com/filecoin-project/specs-actors v0.0.0-20200304210626-21ee86aadcb9 h1:5/XkV9N7Zlidi2RYY/04BToD/XeQrudUseI7Gx6owl8=
github.com/filecoin-project/specs-actors v0.0.0-20200304210626-21ee86aadcb9/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU=
github.com/filecoin-project/specs-actors v0.0.0-20200305205312-53bb01da9aeb h1:9Ch6f/LYCh/BoriHfSp8sRX0OaO+9gQVK6x0vGl9o0s=
github.com/filecoin-project/specs-actors v0.0.0-20200305205312-53bb01da9aeb/go.mod h1:0HAWYrvajFHDgRaKbF0rl+IybVLZL5z4gQ8koCMPhoU=
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=