cmd

package
v1.15.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0, MIT Imports: 95 Imported by: 0

Documentation

Overview

Package commands implements the command to print the blockchain.

Package cmd implements the command to print the blockchain.

Index

Constants

View Source
const (
	// OptionAPI is the name of the option for specifying the api port.
	OptionAPI = "cmdapiaddr"

	OptionToken = "token"
	// OptionRepoDir is the name of the option for specifying the directory of the repo.
	OptionRepoDir = "repo"

	OptionLegacyRepoDir = "repodir"

	// OptionDrandConfigAddr is the init option for configuring drand to a given network address at init time
	OptionDrandConfigAddr = "drand-config-addr"

	// offlineMode tells us if we should try to connect this Filecoin node to the network
	OfflineMode = "offline"

	// ELStdout tells the daemon to write event logs to stdout.
	ELStdout = "elstdout"

	ULimit = "manage-fdlimit"

	// SwarmAddress is the multiaddr for this Filecoin node
	SwarmAddress = "swarmlisten"

	// SwarmPublicRelayAddress is a public address that the venus node
	// will listen on if it is operating as a relay.  We use this to specify
	// the public ip:port of a relay node that is sitting behind a static
	// NAT mapping.
	SwarmPublicRelayAddress = "swarmrelaypublic"

	// GenesisFile is the path of file containing archive of genesis block DAG data
	GenesisFile = "genesisfile"

	// Network populates config with network-specific parameters for a known network (e.g. testnet2)
	Network = "network"

	// IsRelay when set causes the the daemon to provide libp2p relay
	// services allowing other filecoin nodes behind NATs to talk directly.
	IsRelay = "is-relay"

	Size = "size"

	ImportSnapshot = "import-snapshot"

	// wallet password
	Password = "password"

	AuthServiceURL   = "auth-url"
	AuthServiceToken = "auth-token"

	BootstrapPeers = "bootstrap-peers"

	Profile = "profile"
)
View Source
const Confidence = 10

Variables

View Source
var RootCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "Filecoin decentralized storage network client",
		Subcommands: `
START RUNNING VENUS
  daemon                 - Start a venus daemon process
  wallet                 - Manage wallet
  info                   - Print node info

VIEW DATA STRUCTURES
  chain                  - Inspect the filecoin blockchain
  sync                   - Inspect the filecoin Sync

NETWORK COMMANDS
  swarm                  - Interact with the swarm
  drand                  - Retrieve randomness from drand server

MESSAGE COMMANDS
  send                   - Send message
  mpool                  - Manage the message pool

MINER COMMANDS
  miner                  - Interact with actors

State COMMANDS
  state                  - query states of the filecoin network

Paych COMMANDS 
  paych                  - Manage payment channels

Cid COMMANDS
  manifest-cid-from-car  - Get the manifest CID from a car file

Evm COMMANDS
  evm                    - Commands related to the Filecoin EVM runtime

TOOL COMMANDS
  inspect                - Show info about the venus node
  log                    - Interact with the daemon event log output
  version                - Show venus version information
  seed                   - Seal sectors for genesis miner
  fetch                  - Fetch proving parameters
`,
	},
	Options: []cmds.Option{
		cmds.StringsOption(OptionToken, "set the auth token to use"),
		cmds.StringOption(OptionAPI, "set the api port to use"),
		cmds.StringOption(OptionRepoDir, OptionLegacyRepoDir, "set the repo directory, defaults to ~/.venus"),
		cmds.StringOption(cmds.EncLong, cmds.EncShort, "The encoding type the output should be encoded with (pretty-json or json)").WithDefault("pretty-json"),
		cmds.BoolOption("help", "Show the full command help text."),
		cmds.BoolOption("h", "Show a short version of the command help text."),
	},
	Subcommands: make(map[string]*cmds.Command),
}

command object for the local cli

View Source
var RootCmdDaemon = &cmds.Command{
	Subcommands: make(map[string]*cmds.Command),
}

command object for the daemon

View Source
var StateComputeStateCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "Perform state computations",
	},
	Options: []cmds.Option{
		cmds.Uint64Option("vm-height", "set the height that the vm will see"),
		cmds.BoolOption("apply-mpool-messages", "apply messages from the mempool to the computed state"),
		cmds.BoolOption("show-trace", "print out full execution trace for given tipset"),
		cmds.BoolOption("json", "generate json output"),
		cmds.StringOption("compute-state-output", "a json file containing pre-existing compute-state output, to generate html reports without rerunning state changes"),
		cmds.BoolOption("no-timing", "don't show timing information in html traces"),
		cmds.StringOption("tipset", ""),
	},
	Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
		ctx := req.Context

		h, _ := req.Options["vm-height"].(uint64)
		height := abi.ChainEpoch(h)
		var ts *types.TipSet
		var err error
		chainAPI := getEnv(env).ChainAPI
		if tss := req.Options["tipset"].(string); tss != "" {
			ts, err = ParseTipSetRef(ctx, chainAPI, tss)
		} else if height > 0 {
			ts, err = chainAPI.ChainGetTipSetByHeight(ctx, height, types.EmptyTSK)
		} else {
			ts, err = chainAPI.ChainHead(ctx)
		}
		if err != nil {
			return err
		}

		if height == 0 {
			height = ts.Height()
		}

		var msgs []*types.Message
		if applyMsg, _ := req.Options["apply-mpool-messages"].(bool); applyMsg {
			pmsgs, err := getEnv(env).MessagePoolAPI.MpoolSelect(ctx, ts.Key(), 1)
			if err != nil {
				return err
			}

			for _, sm := range pmsgs {
				msgs = append(msgs, &sm.Message)
			}
		}

		var stout *types.ComputeStateOutput
		if csofile, _ := req.Options["compute-state-output"].(string); len(csofile) != 0 {
			data, err := os.ReadFile(csofile)
			if err != nil {
				return err
			}

			var o types.ComputeStateOutput
			if err := json.Unmarshal(data, &o); err != nil {
				return err
			}

			stout = &o
		} else {
			o, err := getEnv(env).ChainAPI.StateCompute(ctx, height, msgs, ts.Key())
			if err != nil {
				return err
			}

			stout = o
		}

		buf := &bytes.Buffer{}
		writer := NewSilentWriter(buf)

		if ok, _ := req.Options["json"].(bool); ok {
			out, err := json.Marshal(stout)
			if err != nil {
				return err
			}
			writer.Println(string(out))
			return re.Emit(buf)
		}

		writer.Println("computed state cid: ", stout.Root)
		if showTrace, _ := req.Options["show-trace"].(bool); showTrace {
			for _, ir := range stout.Trace {
				writer.Printf("%s\t%s\t%s\t%d\t%x\t%d\t%x\n", ir.Msg.From, ir.Msg.To, ir.Msg.Value, ir.Msg.Method, ir.Msg.Params, ir.MsgRct.ExitCode, ir.MsgRct.Return)
				printInternalExecutions(writer, "\t", ir.ExecutionTrace.Subcalls)
			}
		}

		return re.Emit(buf)
	},
}

Functions

func EpochTime

func EpochTime(curr, e abi.ChainEpoch, blockDelay uint64) string

func EpochTimeTs added in v1.10.1

func EpochTimeTs(curr, e abi.ChainEpoch, blockDelay uint64, ts *types.TipSet) string

EpochTimeTs is like EpochTime, but also outputs absolute time. `ts` is only used to provide a timestamp at some epoch to calculate time from. It can be a genesis tipset.

Example output: `1944975 (01 Jul 22 08:07 CEST, 10 hours 29 minutes ago)`

func Import

func Import(ctx context.Context, r repo.Repo, fileName string) error

Import cache tipset cids to store. The value of the cached tipset CIDS is used as the check-point when running `venus daemon`

func LoadTipSet added in v1.1.0

func LoadTipSet(ctx context.Context, req *cmds.Request, chainAPI v1api.IChain) (*types.TipSet, error)

LoadTipSet gets the tipset from the context, or the head from the API.

It always gets the head from the API so commands use a consistent tipset even if time pases.

func ParseTipSetRef added in v1.1.0

func ParseTipSetRef(ctx context.Context, chainAPI v1api.IChain, tss string) (*types.TipSet, error)

func ParseTipSetString added in v1.1.0

func ParseTipSetString(ts string) ([]cid.Cid, error)

func PrintString

func PrintString(w io.Writer, s fmt.Stringer) error

PrintString prints a given Stringer to the writer.

func ReqContext added in v0.9.4

func ReqContext(cctx context.Context) context.Context

func Run

func Run(ctx context.Context, args []string, stdin, stdout, stderr *os.File) (int, error)

Run processes the arguments and stdin

func SyncBasefeeCheck added in v1.9.0

func SyncBasefeeCheck(ctx context.Context, chainAPI v1.IChain, blockDelaySecs int64, writer *SilentWriter) error

Types

type APIInfo added in v0.9.7

type APIInfo struct {
	Addr  string
	Token string
}

type ActorView

type ActorView struct {
	Address string          `json:"address"`
	Code    cid.Cid         `json:"code,omitempty"`
	Nonce   uint64          `json:"nonce"`
	Balance abi.TokenAmount `json:"balance"`
	Head    cid.Cid         `json:"head,omitempty"`
}

ActorView represents a generic way to represent details about any actor to the user.

type AddressLsResult

type AddressLsResult struct {
	Addresses []address.Address
}

AddressLsResult is the result of running the address list command.

type AddressResult

type AddressResult struct {
	Address address.Address
}

type BlockResult

type BlockResult struct {
	Cid   cid.Cid
	Miner address.Address
}

type ChainHeadResult

type ChainHeadResult struct {
	Height       abi.ChainEpoch
	ParentWeight big.Int
	Cids         []cid.Cid
	Timestamp    string
}

type ChainLsResult

type ChainLsResult struct {
	Height    abi.ChainEpoch
	Timestamp string
	Blocks    []BlockResult
}

type IDDetails

type IDDetails struct {
	Addresses       []ma.Multiaddr
	ID              peer.ID
	AgentVersion    string
	ProtocolVersion string
	PublicKey       []byte // raw bytes
}

IDDetails is a collection of information about a node.

func (IDDetails) MarshalJSON

func (idd IDDetails) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*IDDetails) UnmarshalJSON

func (idd *IDDetails) UnmarshalJSON(data []byte) error

UnmarshalJSON implements Unmarshaler

type MessageSendResult

type MessageSendResult struct {
	Cid     cid.Cid
	GasUsed int64
	Preview bool
}

MessageSendResult is the return type for message send command

type SilentWriter

type SilentWriter struct {
	// contains filtered or unexported fields
}

SilentWriter writes to a stream, stopping after the first error and discarding output until the error is cleared. No printing methods return an error (to avoid warnings about ignoring it), but they do return a boolean indicating whether an error is waiting to be cleared. Example usage:

sw := NewSilentWriter(w)
sw.Println("A line")
sw.Println("Another line")
return sw.Error()

func NewSilentWriter

func NewSilentWriter(w io.Writer) *SilentWriter

NewSilentWriter returns a new writer backed by `w`.

func (*SilentWriter) ClearError

func (sw *SilentWriter) ClearError() error

ClearError clears and returns any error encountered while writing. Subsequent writes will attempt to write to the underlying writer again.

func (*SilentWriter) Error

func (sw *SilentWriter) Error() error

Error returns any error encountered while writing.

func (*SilentWriter) Print

func (sw *SilentWriter) Print(a ...interface{}) bool

Print writes with fmt.Fprint and returns true if there was no error.

func (*SilentWriter) Printf

func (sw *SilentWriter) Printf(format string, a ...interface{}) bool

Printf writes with fmt.Fprintf and returns true if there was no error.

func (*SilentWriter) Println

func (sw *SilentWriter) Println(a ...interface{}) bool

Println writes with fmt.Fprintln and returns true if there was no error.

func (*SilentWriter) Write

func (sw *SilentWriter) Write(p []byte) bool

Write writes with io.Writer.Write and returns true if there was no error.

func (*SilentWriter) WriteString

func (sw *SilentWriter) WriteString(str string) bool

WriteString writes with io.WriteString and returns true if there was no error.

func (*SilentWriter) WriteStringln

func (sw *SilentWriter) WriteStringln(str string) bool

WriteString writes with io.WriteString and returns true if there was no error.

type WaitResult

type WaitResult struct {
	Message   *types.Message
	Receipt   *types.MessageReceipt
	Signature vm.ActorMethodSignature
}

WaitResult is the result of a message wait call.

type WalletSerializeResult

type WalletSerializeResult struct {
	KeyInfo []*key.KeyInfo
}

WalletSerializeResult is the type wallet export and import return and expect.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL