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

[3.2] Build framework for leap-util #150

Merged
merged 24 commits into from
Oct 4, 2022
Merged

[3.2] Build framework for leap-util #150

merged 24 commits into from
Oct 4, 2022

Conversation

vladtr
Copy link
Contributor

@vladtr vladtr commented Sep 13, 2022

This is initial proposed implementation of leap-util utility comprising following features:

  • CLI11 cli parsing library, patched to support auto-completion
  • partition subcommand handlers by separate files
  • added blocklog implementation eosio-blocklog as subcommand "blockllog"
  • included bash autocompletion configuration script for leap-util (its tested on Ubuntu and FreeBSD and works fine)
  • moved cli11 to interface only lib, bot cleos and leap-util use it now

This PR still work in progress and things will change, notes about changes will be added in comments.

@vladtr vladtr linked an issue Sep 13, 2022 that may be closed by this pull request
@vladtr vladtr self-assigned this Sep 13, 2022
@vladtr vladtr linked an issue Sep 13, 2022 that may be closed by this pull request
@spoonincode
Copy link
Member

With both cleos & leap-util using CLI11, does it make sense to have just one instance of it? Does it make sense to have that one instance be a submodule from upstream?

@vladtr
Copy link
Contributor Author

vladtr commented Sep 13, 2022

With both cleos & leap-util using CLI11, does it make sense to have just one instance of it? Does it make sense to have that one instance be a submodule from upstream?

Yes! This is the plan. And cleos will get autocompletion and --help-all for free.

@vladtr
Copy link
Contributor Author

vladtr commented Sep 23, 2022

in (e592a4a, 511f6db)

  • added readme to leap-CLI11
  • genesys subcommand moved to blocklog
  • blocklog -> block_log
  • chain- > chain_state
  • disabled snapshot subcommand
  • refactored blocklog opts to be subcommands

programs/leap-cli11/README.md Outdated Show resolved Hide resolved
programs/leap-cli11/bash-completion/completions/cleos Outdated Show resolved Hide resolved
programs/leap-cli11/bash-completion/completions/leap-util Outdated Show resolved Hide resolved
programs/leap-util/actions/blocklog.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/blocklog.cpp Show resolved Hide resolved
programs/leap-util/actions/blocklog.hpp Outdated Show resolved Hide resolved
programs/leap-util/actions/blocklog.hpp Outdated Show resolved Hide resolved
programs/leap-util/main.cpp Outdated Show resolved Hide resolved
programs/leap-util/actions/chain.cpp Outdated Show resolved Hide resolved
programs/CMakeLists.txt Outdated Show resolved Hide resolved
@vladtr vladtr marked this pull request as ready for review September 29, 2022 18:22
// Originally designed by Henry Schreiner
// https://github.com/CLIUtils/CLI11
//
// This is a standalone header file generated by MakeSingleHeader.py in CLI11/scripts
// from: v1.9.0
// from: 4c832a2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not the same version as in AntelopeIO/CLI11's main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thank you! It's 1d3b0a7 now.

@spoonincode
Copy link
Member

If I just run leap-util chain-state nothing is printed, and exit status is 0. This seems to apply to some other invocations too, like leap-util chain-state build-info which does nothing and has 0 exit status.

@spoonincode
Copy link
Member

I know we were just aiming for 1:1 of current functionality, but there are some missed opportunities to improve the commands to make operator lifes' easier. Just based on a cursory look two things stood out:

build info

build-info command is missing a very useful ability to probe what the environment is for an existing state file (as is, it only prints what leap-util was compiled with).

For example, I could image an operator trying to do something like

if [[ $(leap-util chain-state build-info -p) != $(leap-util chain-state --state-file /var/nodeos/shared_state.bin build-info -p) ]]; then
  echo "uh oh, looks like next time I launch nodeos I'll need a snapshot" && exit 1
fi

(the above assumes some canonical string representation of the environment, which might be kinda bad, and doesn't capture that in addtion to environment there could be other reasons the state isn't compatible). Maybe instead, just as an off the cuff thought, there would be a

if ! leap-util chain-state is-compatible /var/nodeos/shared_state.bin; then
  echo "uh oh, looks like next time I launch nodeos I'll need a snapshot" && exit 1
fi

block log query

The block-log command could use a way to query properties of an existing block log. Like --block-log-version or --block-log-first-block or --block-log-chain-id or such.

@spoonincode
Copy link
Member

when I just run leap-util block-log genesis some unexpected behavior occurs

./leap-util block-log genesis
warn  2022-09-29T22:08:26.313 leap-util blocklog.cpp:164              do_genesis           ] No blocks.log found at '/home/spoon/f/leap/build.empty/programs/leap-util/blocks/blocks.log'. Using default genesis state.
info  2022-09-29T22:08:26.313 leap-util blocklog.cpp:171              do_genesis           ] Genesis JSON:
{
  "initial_timestamp": "2018-06-01T12:00:00.000",
  "initial_key": "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
  "initial_configuration": {
    "max_block_net_usage": 1048576,
    "target_block_net_usage_pct": 1000,
    "max_transaction_net_usage": 524288,
    "base_per_transaction_net_usage": 12,
    "net_usage_leeway": 500,
    "context_free_discount_net_usage_num": 20,
    "context_free_discount_net_usage_den": 100,
    "max_block_cpu_usage": 200000,
    "target_block_cpu_usage_pct": 1000,
    "max_transaction_cpu_usage": 150000,
    "min_transaction_cpu_usage": 100,
    "max_transaction_lifetime": 3600,
    "deferred_trx_expiration_window": 600,
    "max_transaction_delay": 3888000,
    "max_inline_action_size": 524288,
    "max_inline_action_depth": 4,
    "max_authority_depth": 6
  }
}
error 2022-09-29T22:08:26.314 leap-util blocklog.cpp:138              run_subcommand       ] 3190000 block_log_exception: Block log exception
No blocks found in block log
    {}
    leap-util  blocklog.cpp:293 read_log

That alone is not what I'd expect. And then if I run it again...

./leap-util block-log genesis
error 2022-09-29T22:09:02.493 leap-util blocklog.cpp:138              run_subcommand       ] 3190001 block_log_unsupported_version: unsupported version of block log
Unsupported version of block log. Block log version is 0 while code supports version(s) [1,3]
    {"version":0,"min":1,"max":3}
    leap-util  block_log.cpp:1026 extract_chain_context

The tool made a new blocks directory. Something like the block-log genesis command should be read-only.

sub->add_subcommand("to-json", "convert snapshot file to convert to json format");

// options
sub->add_option("--input-file,-i", opt->input_file, "snapshot file to convert to json format, writes to <file>.json if output file not specified (tmp state dir used), and exit.")->required();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite follow what this description of the option is trying to tell me. It seems to be saying if I give an input file without an output file, the output file will be basenameofinput.json; but that's in conflict of the output-file description which says no output file means output goes to stdout. And I don't know what "tmp state dir" means in this context.

More generally, since the options are attached to snapshot, not to-json, the descriptions are probably too narrowly defined solely for the to-json use case. There are a number of useful operations on a snapshot file we can add in the future that don't have anything to do with json.

Copy link
Member

@linh2931 linh2931 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocklog needs more refactoring like specific options for a subcommand, ... @766C6164 and talked about them.

@spoonincode
Copy link
Member

I wonder if bash-completion package should be added to CPACK_DEBIAN_BASE_PACKAGE_SUGGESTS. Not sure if that's a typical thing for debian/ubuntu packages to do. Not critical for now.

@arhag arhag merged commit edbaedb into main Oct 4, 2022
@arhag arhag deleted the leap-util branch October 4, 2022 18:19
@arhag arhag linked an issue Oct 4, 2022 that may be closed by this pull request
@arhag arhag changed the title Build framework for leap-util [3.2] Build framework for leap-util Oct 4, 2022
@arhag arhag linked an issue Oct 4, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants