Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: improve VM CLI a bit more #2740

Merged
merged 11 commits into from
Oct 13, 2022
Merged

cli: improve VM CLI a bit more #2740

merged 11 commits into from
Oct 13, 2022

Conversation

AnnaShaleva
Copy link
Member

@AnnaShaleva AnnaShaleva commented Oct 11, 2022

Close #2729, close #2606.

  • Add test for signers parsing.
  • Add test for (p *Parameter) ToStackItem().
  • Prettify VM CLI commands documentation.

@AnnaShaleva AnnaShaleva marked this pull request as draft October 11, 2022 12:14
@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Merging #2740 (8b91428) into master (44df4b9) will decrease coverage by 0.16%.
The diff coverage is 66.53%.

@@            Coverage Diff             @@
##           master    #2740      +/-   ##
==========================================
- Coverage   85.40%   85.23%   -0.17%     
==========================================
  Files         324      324              
  Lines       40064    40080      +16     
==========================================
- Hits        34217    34163      -54     
- Misses       4494     4551      +57     
- Partials     1353     1366      +13     
Impacted Files Coverage Δ
pkg/smartcontract/context/context.go 86.14% <ø> (ø)
pkg/vm/vm.go 92.88% <0.00%> (-0.58%) ⬇️
pkg/smartcontract/parameter.go 92.90% <50.00%> (-0.81%) ⬇️
cli/vm/cli.go 79.30% <61.38%> (-5.34%) ⬇️
cli/cmdargs/parser.go 94.61% <100.00%> (+0.34%) ⬆️
cli/smartcontract/smart_contract.go 92.82% <100.00%> (-0.94%) ⬇️
pkg/smartcontract/param_type.go 97.40% <100.00%> (+0.04%) ⬆️
pkg/vm/stackitem/item.go 89.90% <100.00%> (+1.25%) ⬆️
pkg/services/oracle/oracle.go 72.99% <0.00%> (-14.60%) ⬇️
pkg/services/oracle/request.go 58.18% <0.00%> (-5.00%) ⬇️
... and 8 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@AnnaShaleva AnnaShaleva mentioned this pull request Oct 11, 2022
@AnnaShaleva AnnaShaleva force-pushed the cli-improvement branch 2 times, most recently from d84e66a to 2fe8aad Compare October 12, 2022 10:50
@AnnaShaleva AnnaShaleva marked this pull request as ready for review October 12, 2022 10:50
Share parameters parsing code between 'contract invokefunction' and
'vm run' commands. It allows VM CLI to parse more complicated parameter
types including arrays and file-backed bytestrings.
Share signers parsing code between 'contract invokefunction' and
'vm load*' commands, quite a useful thing when it comes to witness
checks.
Load script from provided transaction if so.
Usage message is shown on common --help command, thus it should be meaningful
and short. If user needs more detailed command description, then he can use
command-specific help.

As a result, current VM help looks pretty simple:
```
NEO-GO-VM > help
NAME:
   VM CLI - Official VM CLI for Neo-Go

USAGE:
    [global options] command [command options] [arguments...]

VERSION:
   0.99.5-pre-15-g5463ec41

COMMANDS:
   exit          Exit the VM prompt
   ip            Show current instruction
   break         Place a breakpoint
   jump          Jump to the specified instruction (absolute IP value)
   estack        Show evaluation stack contents
   istack        Show invocation stack contents
   sslot         Show static slot contents
   lslot         Show local slot contents
   aslot         Show arguments slot contents
   loadnef       Load a NEF-consistent script into the VM optionally attaching to it provided signers with scopes
   loadbase64    Load a base64-encoded script string into the VM optionally attaching to it provided signers with scopes
   loadhex       Load a hex-encoded script string into the VM optionally attaching to it provided signers with scopes
   loadgo        Compile and load a Go file with the manifest into the VM optionally attaching to it provided signers with scopes
   loadtx        Load transaction into the VM from chain or from parameter context file
   loaddeployed  Load deployed contract into the VM from chain optionally attaching to it provided signers with scopes
   reset         Unload compiled script from the VM and reset context to proper (possibly, historic) state
   parse         Parse provided argument and convert it into other possible formats
   run           Execute the current loaded script
   cont          Continue execution of the current loaded script
   step          Step (n) instruction in the program
   stepinto      Stepinto instruction to take in the debugger
   stepout       Stepout instruction to take in the debugger
   stepover      Stepover instruction to take in the debugger
   ops           Dump opcodes of the current loaded program
   events        Dump events emitted by the current loaded program
   env           Dump state of the chain that is used for VM CLI invocations (use -v for verbose node configuration)
   storage       Dump storage of the contract with the specified hash, address or ID as is at the current stage of script invocation
   changes       Dump storage changes as is at the current stage of loaded script invocation
   help, h       Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

```
1. UsageText shows the command usage rule. Fixed/added where needed.
2. Description shows the command description, huh. It is shown right after
   UsageText, so there's no need to repeat the command usage rule. If
   Description contains Example, then it should be printed on a new line.
@roman-khimov roman-khimov merged commit c3001bc into master Oct 13, 2022
@roman-khimov roman-khimov deleted the cli-improvement branch October 13, 2022 13:21
@roman-khimov roman-khimov added the cli Command line interface label Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Command line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve VM CLI VM CLI: set ip
2 participants