diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 2dced4630..16e0aa9b3 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -188,15 +188,11 @@ 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, - Penalty: penalty, - GasReward: gasReward, + Miner: b.Miner, + Penalty: penalty, + GasReward: gasReward, }) if err != nil { return cid.Undef, cid.Undef, xerrors.Errorf("failed to serialize award params: %w", err) diff --git a/chain/validation/factories.go b/chain/validation/factories.go index 2b5291426..7b4f444b0 100644 --- a/chain/validation/factories.go +++ b/chain/validation/factories.go @@ -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) } diff --git a/chain/validation/keymanager.go b/chain/validation/keymanager.go index a0ae8478b..3161883b9 100644 --- a/chain/validation/keymanager.go +++ b/chain/validation/keymanager.go @@ -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[:], diff --git a/chain/validation/state.go b/chain/validation/state.go index e159b5b4b..7ac9717ca 100644 --- a/chain/validation/state.go +++ b/chain/validation/state.go @@ -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 -} - -*/ diff --git a/chain/vm/validation_test.go b/chain/vm/validation_test.go index 8532773d3..2531dc77b 100644 --- a/chain/vm/validation_test.go +++ b/chain/vm/validation_test.go @@ -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 */ }} } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 001f59d4a..d35856495 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -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) diff --git a/cli/chain.go b/cli/chain.go index 1bebc78e9..b1a5c1b6a 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -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 ]", 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 { diff --git a/cli/client.go b/cli/client.go index 20339753c..3150840dc 100644 --- a/cli/client.go +++ b/cli/client.go @@ -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", diff --git a/cli/log.go b/cli/log.go index 152a855f6..561d949d5 100644 --- a/cli/log.go +++ b/cli/log.go @@ -44,7 +44,7 @@ var logList = &cli.Command{ var logSetLevel = &cli.Command{ Name: "set-level", Usage: "Set log level", - ArgsUsage: "", + ArgsUsage: "[level]", Description: `Set the log level for logging systems: The system flag can be specified multiple times. diff --git a/cli/multisig.go b/cli/multisig.go index 91959d6b3..877fd41a4 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -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 (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)) diff --git a/cli/net.go b/cli/net.go index ac559e919..cf634df64 100644 --- a/cli/net.go +++ b/cli/net.go @@ -76,7 +76,7 @@ var netListen = &cli.Command{ var netConnect = &cli.Command{ Name: "connect", Usage: "Connect to a peer", - ArgsUsage: "", + 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: "", + ArgsUsage: "[peerId]", Action: func(cctx *cli.Context) error { if cctx.NArg() != 1 { fmt.Println("Usage: findpeer [peer ID]") diff --git a/cli/paych.go b/cli/paych.go index 5d42a0ea5..4d2077e75 100644 --- a/cli/paych.go +++ b/cli/paych.go @@ -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: ") @@ -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") diff --git a/cli/send.go b/cli/send.go index d4883dd61..1a329ddad 100644 --- a/cli/send.go +++ b/cli/send.go @@ -11,7 +11,7 @@ import ( var sendCmd = &cli.Command{ Name: "send", Usage: "Send funds between accounts", - ArgsUsage: " ", + ArgsUsage: "[targetAddress] [amount]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "source", diff --git a/cli/state.go b/cli/state.go index 5e489ed7c..ca6ce888c 100644 --- a/cli/state.go +++ b/cli/state.go @@ -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: "[ (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] ") @@ -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 (optional)]", Flags: []cli.Flag{ &cli.StringFlag{ Name: "from", diff --git a/cli/sync.go b/cli/sync.go index 588fcf91e..0cde9c97e 100644 --- a/cli/sync.go +++ b/cli/sync.go @@ -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 { diff --git a/cli/wallet.go b/cli/wallet.go index 2548deb21..b7123b594 100644 --- a/cli/wallet.go +++ b/cli/wallet.go @@ -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: "[ (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 } diff --git a/go.mod b/go.mod index 482296b7b..a340978ac 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index b0cf94939..a23673afe 100644 --- a/go.sum +++ b/go.sum @@ -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=