Skip to content

feat: improve cli error handling and add git commit info#1246

Merged
KaoImin merged 3 commits intoaxonweb3:mainfrom
blckngm:cli-error-handling
Jul 3, 2023
Merged

feat: improve cli error handling and add git commit info#1246
KaoImin merged 3 commits intoaxonweb3:mainfrom
blckngm:cli-error-handling

Conversation

@blckngm
Copy link
Copy Markdown
Contributor

@blckngm blckngm commented Jun 30, 2023

What this PR does / why we need it:

  • It's hard to read errors displayed with unwrap and Debug:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Deserialize(Error { inner: Error { inner: TomlError { message: "invalid type: map, expected a string", original: Some("# crypto\nis_force_read_only = true\n\nprivkey = \"0x37aa0f893d05914a4def0460c0a984d3611546cfb26924d7a7ca6e0db9950a2d\"\n\n# db config\ndata_path = \"./devtools/chain/data\"\n\ncrosschain_contract_address = \"0xb9dc8bde1db42410d304b5e78c2ff843134e15e0\"\nwckb_contract_address = \"0xa13763691970d9373d4fab7cc323d7ba06fa9986\"\n\n[[accounts]]\naddress = \"0xa0ee7a142d267c1f36714e4a8f75612f20a79720\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x70997970C51812dc3A010C7d01b50e0d17dc79C8\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x90F79bf6EB2c4f870365E785982E1f101E93b906\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x976EA74026E726554dB657fA54763abd0C3a0aa9\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x14dC79964da2C08b23698B3D3cc7Ca32193d9955\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[[accounts]]\naddress = \"0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f\"\nbalance = \"04ee2d6d415b85acef8100000000\"\n\n[rpc]\nhttp_listening_address = \"0.0.0.0:8000\"\nws_listening_address = \"0.0.0.0:8010\"\nmaxconn = 25000\nmax_payload_size = 10485760\nclient_version = \"0.1.0\"\ngas_cap = 50_000_000\n\n[network]\nlistening_address = \"/ip4/0.0.0.0/tcp/8001\"\nrpc_timeout = 10\n\n[consensus]\nsync_txs_chunk_size = 5000\n\n[[network.bootstraps]]\nmulti_address = \"/ip4/13.41.118.235/tcp/8001/p2p/QmNk6bBwkLPuqnsrtxpp819XLZY3ymgjs3p1nKtxBVgqxj\"\n\n[mempool]\ntimeout_gap = 20\npool_size = 50000\nbroadcast_txs_size = 200\nbroadcast_txs_interval = 200\n\n[executor]\nlight = false\ntriedb_cache_size = 2000\n\n[logger]\nfilter = \"info\"\nlog_to_console = true\nconsole_show_file_and_line = false\nlog_path = \"logs/\"\nlog_to_file = true\nfile_size_limit = 1073741824 # 1 GiB\nmetrics = true\n# you can specify log level for modules with config below\n# modules_level = { \"overlord::state::process\" = \"debug\", core_consensus = \"error\" }\n\n[rocksdb]\nmax_open_files = 64\ncache_size = 1000\n# Provide an options file to tune RocksDB for your workload and your system configuration.\n# More details can be found in [the official tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide).\noptions_file = \"default.db-options\"\n\n[jaeger]\nservice_name = \"axon\"\ntracing_address = \"127.0.0.1:6831\"\ntracing_batch_size = 50\n\n[prometheus]\nlistening_address = \"0.0.0.0:8100\"\n\nis_force_read_only = true\n"), keys: ["accounts"], span: Some(310..418) } } })', core/cli/src/lib.rs:42:65

Now it's:

Error: parsing config file

Caused by:
    TOML parse error at line 1, column 1
      |
    1 | # crypto
      | ^^^^^^^^
    missing field `web3`
  • Git commit hash is added to cli version info. It's hard to know from which commit a binary is built otherwise.
$ axon --version
axon 0.1.0-beta.1 4d126a2

Which issue(s) this PR fixes:

Fixes #

Which docs this PR relation:

Ref #

Which toolchain this PR adaption:

No Breaking Change

Special notes for your reviewer:

NIL

CI Description

CI Name Description
Chaos CI Test the liveness and robustness of Axon under terrible network condition
Cargo Clippy Run cargo clippy --all --all-targets --all-features
Coverage Test Get the unit test coverage report
E2E Test Run end-to-end test to check interfaces
Code Format Run cargo +nightly fmt --all -- --check and cargo sort -gwc
Web3 Compatible Test Test the Web3 compatibility of Axon
v3 Core Test Run the compatibility tests provided by Uniswap V3
OCT 1-5 | 6-10 | 11 | 12-15 | 16-19 Run the compatibility tests provided by OpenZeppelin

CI Usage

Check the CI you want to run below, and then comment /run-ci.

CI Switch

  • Chaos CI
  • Cargo Clippy
  • Coverage Test
  • E2E Tests
  • Code Format
  • Unit Tests
  • Web3 Compatible Tests
  • OCT 1-5 And 12-15
  • OCT 6-10
  • OCT 11
  • OCT 16-19
  • v3 Core Tests

@blckngm blckngm requested a review from a team as a code owner June 30, 2023 04:18
@blckngm blckngm requested review from felicityin and liya2017 June 30, 2023 04:18
Comment thread src/lib.rs
pub fn run(
fee_allocator: impl FeeAllocate + 'static,
key_provider: impl KeyProvider,
cli_version: &'static str,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Custom chains should define their own cli version.

@KaoImin
Copy link
Copy Markdown
Contributor

KaoImin commented Jul 3, 2023

/run-ci

@axon-bot
Copy link
Copy Markdown

axon-bot Bot commented Jul 3, 2023

CI tests run on commit:

CI test list:

  • Code Format
  • Cargo Clippy
  • Unit Tests

Please check ci test results later.

KaoImin
KaoImin previously approved these changes Jul 3, 2023
@KaoImin
Copy link
Copy Markdown
Contributor

KaoImin commented Jul 3, 2023

/run-ci

@axon-bot
Copy link
Copy Markdown

axon-bot Bot commented Jul 3, 2023

CI tests run on commit:

CI test list:

  • Code Format
  • Cargo Clippy
  • Unit Tests

Please check ci test results later.

@KaoImin KaoImin merged commit dfd2525 into axonweb3:main Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants