Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
998d190e
Commit
998d190e
authored
4 years ago
by
Alexander Theißen
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use the log crate to output contract generated messages. (#8403)
parent
4fd69de3
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
substrate/frame/contracts/README.md
+15
-0
15 additions, 0 deletions
substrate/frame/contracts/README.md
substrate/frame/contracts/src/wasm/runtime.rs
+1
-1
1 addition, 1 deletion
substrate/frame/contracts/src/wasm/runtime.rs
with
16 additions
and
1 deletion
substrate/frame/contracts/README.md
+
15
−
0
View file @
998d190e
...
...
@@ -57,4 +57,19 @@ will make things a lot easier. One such language is [`ink`](https://github.com/p
which is an
[
`eDSL`
](
https://wiki.haskell.org/Embedded_domain_specific_language
)
that enables
writing WebAssembly based smart contracts in the Rust programming language.
## Debugging
Contracts can emit messages to the node console when run on a development chain through the
`seal_println`
API. This is exposed in ink! via
[
`ink_env::debug_println()`
](
https://docs.rs/ink_env/latest/ink_env/fn.debug_println.html
)
.
In order to see these messages the log level for the
`runtime::contracts`
target needs to be raised
to at least the
`info`
level which is the default. However, those messages are easy to overlook
because of the noise generated by block production. A good starting point for contract debugging
could be:
```
bash
cargo run
--release
--
--dev
--tmp
-lerror
,runtime::contracts
```
License: Apache-2.0
This diff is collapsed.
Click to expand it.
substrate/frame/contracts/src/wasm/runtime.rs
+
1
−
1
View file @
998d190e
...
...
@@ -1366,7 +1366,7 @@ define_env!(Env, <E: Ext>,
seal_println
(
ctx
,
str_ptr
:
u32
,
str_len
:
u32
)
=>
{
let
data
=
ctx
.read_sandbox_memory
(
str_ptr
,
str_len
)
?
;
if
let
Ok
(
utf8
)
=
core
::
str
::
from_utf8
(
&
data
)
{
sp_runtime
::
print
(
utf8
);
log
::
info!
(
target
:
"runtime::contracts"
,
"seal_println: {}"
,
utf8
);
}
Ok
(())
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment