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

Add debug log to each host function #4838

Closed
bowenwang1996 opened this issue Sep 17, 2021 · 1 comment · Fixed by #5018
Closed

Add debug log to each host function #4838

bowenwang1996 opened this issue Sep 17, 2021 · 1 comment · Fixed by #5018
Assignees
Labels
A-contract-runtime Area: contract compilation and execution, virtual machines, etc C-good-first-issue Category: issues that are self-contained and easy for newcomers to work on.

Comments

@bowenwang1996
Copy link
Collaborator

@matklad suggests that we add debug logging to each host function so that when a node crashes inside runtime, we could better understand what happened. We can enable/disable such logging at compile time to avoid adding extra overhead to production builds.

@bowenwang1996 bowenwang1996 added A-contract-runtime Area: contract compilation and execution, virtual machines, etc C-good-first-issue Category: issues that are self-contained and easy for newcomers to work on. labels Sep 17, 2021
@matklad
Copy link
Contributor

matklad commented Sep 17, 2021

To clarify, we should use spans for logging here:

let _span = tracing::debug_span!(target: "vm", "compile_and_serialize_wasmer").entered();

Appropriate target and level are up for discussion.

@ailisp ailisp self-assigned this Oct 13, 2021
near-bulldozer bot pushed a commit that referenced this issue Oct 20, 2021
Fix #4838

Test Plan
------------

```
cargo build -p neard
target/debug/neard --verbose=host-function run
```

In another terminal:
```
export NEAR_ENV=local
near deploy --accountId test.near --wasmFile runtime/near-test-contracts/res/simple_state.wasm
near call test.near set_status --accountId test.near '{"message":"hello"}'
```

In neard window, will see:
```
...
Oct 15 14:45:06.384 DEBUG gas: host-function: enter
Oct 15 14:45:06.384 DEBUG gas: host-function: close time.busy=63.8µs time.idle=17.7µs
Oct 15 14:45:06.384 DEBUG log_utf8: host-function: enter
Oct 15 14:45:06.384 DEBUG log_utf8: host-function: close time.busy=114µs time.idle=11.7µs
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-contract-runtime Area: contract compilation and execution, virtual machines, etc C-good-first-issue Category: issues that are self-contained and easy for newcomers to work on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants