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 external (debug) printing functionality #20

Closed
Robbepop opened this issue Mar 4, 2019 · 4 comments
Closed

Add external (debug) printing functionality #20

Robbepop opened this issue Mar 4, 2019 · 4 comments
Labels
A-eDSL Concerning the Rust eDSL as a total. B-enhancement New feature or request
Projects

Comments

@Robbepop
Copy link
Collaborator

Robbepop commented Mar 4, 2019

Testing a smart contract on-chain is currently very hard.
There are no debuggers available nor can a developer currently even make use of simple println debugging.

By adding a println external function we could at least fairly easy implement some println debugging facilities - better than nothing!

However, having those println calls in real on-chain smart contracts would be catastrophic.
They must not be used in non---dev chains - this should be checked in an upcoming eDSL as well as on the substrate side upon PUT_CODE.

For this to implement we need to also adjust the substrate SRML-contracts interface and workings.
A simple approach would be to add another flag to SRML-contracts indicating whether ext_println should be enabled. This must only be true if the current environment is a --dev chain.

The eDSL must make sure that ext_println is only available if there was a debug opt-in.
To do this we need to add another crate feature that smart contract developers could enable to actually make use of ext_println. Otherwise using ext_println will be a compile error.

@Robbepop Robbepop added B-enhancement New feature or request A-eDSL Concerning the Rust eDSL as a total. D-medium labels Mar 12, 2019
@Robbepop Robbepop added this to To Do in Sub0 Mar 28, 2019
@xlc
Copy link

xlc commented Apr 9, 2019

Contract is able to raise custom events now, is it possible to repurpose it to emit logging events?
So there will be a a log macro that does nothing in release build but emit a logging event in debug build

@Robbepop
Copy link
Collaborator Author

For debuggability we cannot rely on events since they do not guarantee ordered dispatch.
So @ascjones is currently implementing the ext_println mechanics that are going to be dev chain only.

@pepyakin
Copy link
Contributor

I think we could more or less rely on the ordering, however, the more apparent problem is that events are discarded when the execution fails which might not be useful for debugging failures : )

@Robbepop
Copy link
Collaborator Author

Commit 8517e0b implements this on the pDSL side. Can be closed now since it is also already merged on the Substrate side: https://github.com/paritytech/substrate/pull/2239/files

@Robbepop Robbepop moved this from To Do to Done in Sub0 Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-eDSL Concerning the Rust eDSL as a total. B-enhancement New feature or request
Projects
No open projects
Sub0
  
Done
Development

No branches or pull requests

3 participants