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

improve message when generating from corrupted scale file #740

Closed
dzmitry-lahoda opened this issue Dec 10, 2022 · 4 comments · Fixed by #841
Closed

improve message when generating from corrupted scale file #740

dzmitry-lahoda opened this issue Dec 10, 2022 · 4 comments · Fixed by #841
Labels
bug Something isn't working

Comments

@dzmitry-lahoda
Copy link

It is very unclear what happens here:

dz@dz-pc-11:~/github.com/AcalaNetwork/chopsticks$ RUST_BACKTRACE=full  subxt codegen --file=./result.scale
The application panicked (crashed).
Message:  proc-macro-error API cannot be used outside of `entry_point` invocation, perhaps you forgot to annotate your #[proc_macro] function with `#[proc_macro_error]
Location: /home/dz/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro-error-1.0.4/src/lib.rs:483

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 7 frames hidden ⋮                               
   8: proc_macro_error::diagnostic::Diagnostic::emit::h71ed7196a89e2746
      at <unknown source file>:<unknown line>
   9: proc_macro_error::diagnostic::Diagnostic::abort::h8f21112efec23e85
      at <unknown source file>:<unknown line>
  10: subxt_codegen::api::generate_runtime_api_from_bytes::h0ff1f2f3ac0feadd
      at <unknown source file>:<unknown line>
  11: subxt::commands::codegen::codegen::he8bf517fc01e777a
      at <unknown source file>:<unknown line>
  12: subxt::main::{{closure}}::h016da6de0ae33237
      at <unknown source file>:<unknown line>
  13: tokio::runtime::park::CachedParkThread::block_on::h2b6fa559db493273
      at <unknown source file>:<unknown line>
  14: tokio::runtime::scheduler::multi_thread::MultiThread::block_on::h6f350664f51835b8
      at <unknown source file>:<unknown line>
  15: tokio::runtime::runtime::Runtime::block_on::haa2dbc4ce2ac990f
      at <unknown source file>:<unknown line>
  16: subxt::main::hfbaa01add1608d1e
      at <unknown source file>:<unknown line>
  17: std::sys_common::backtrace::__rust_begin_short_backtrace::h3d6ba28366c1d5da
      at <unknown source file>:<unknown line>
  18: std::rt::lang_start::{{closure}}::h64023f3b354b6755
      at <unknown source file>:<unknown line>
  19: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hf105ddd1169c173a
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/core/src/ops/function.rs:286
  20: std::panicking::try::do_call::he5d8f4184990e3bb
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:483
  21: std::panicking::try::h3fd4bce8ca12f40a
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:447
  22: std::panic::catch_unwind::hbc34baf325dba023
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panic.rs:137
  23: std::rt::lang_start_internal::{{closure}}::hd38e0e16beb6e1a4
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/rt.rs:148
  24: std::panicking::try::do_call::h9204340ea5cb9cf9
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:483
  25: std::panicking::try::h96892eb3cbae8cf8
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panicking.rs:447
  26: std::panic::catch_unwind::h1595c408747ffa84
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/panic.rs:137
  27: std::rt::lang_start_internal::h294cac284b8f9297
      at /rustc/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1/library/std/src/rt.rs:148
  28: main<unknown>
      at <unknown source file>:<unknown line>
  29: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  30: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
dz@dz-pc-11:~/github.com/AcalaNetwork/chopsticks$ 
@lexnv
Copy link
Collaborator

lexnv commented Dec 12, 2022

Hi!

Manged to reproduce this issue in the following way

# 1. Trim the polkadot.scale artifact
dd if=./artifacts/polkadot_metadata.scale of=./artifacts/polkadot_metadata_tmp.scale bs=1 skip=25 count=73

# 2. Run codegen against the incompatible file
cargo run --release -p subxt-cli -- codegen --file artifacts/polkadot_metadata_tmp.scale
    Finished release [optimized] target(s) in 3.11s
     Running `target/release/subxt codegen --file artifacts/polkadot_metadata_tmp.scale`
The application panicked (crashed).
Message:  proc-macro-error API cannot be used outside of `entry_point` invocation, perhaps you forgot to annotate your #[proc_macro] function with `#[proc_macro_error]
Location: /home/lexnv/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro-error-1.0.4/src/lib.rs:483

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets

@jsdw jsdw added the bug Something isn't working label Jan 9, 2023
@jsdw
Copy link
Collaborator

jsdw commented Jan 9, 2023

Sounds like a bug to me; I'd hope that we can do better here!

@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Jan 9, 2023

and I found root cause. I used AcalaNetwork/chopsticks#80 to generate metadata. it starts not as Metadata, but with prefix VersionMetadata. may be there is another issue with that subxt could support versioned prefix too (feature, not bug so)

@jsdw
Copy link
Collaborator

jsdw commented Mar 3, 2023

Hopefully #841 resolves the original issue; now instead of a panic you should get back a slightly nicer error message at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants