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

debug_println! doesn't work in #[ink(constructor)] #821

Closed
cmichi opened this issue Jun 17, 2021 · 7 comments
Closed

debug_println! doesn't work in #[ink(constructor)] #821

cmichi opened this issue Jun 17, 2021 · 7 comments
Labels
C-bug Something isn't working

Comments

@cmichi
Copy link
Collaborator

cmichi commented Jun 17, 2021

To reproduce one can use the contract-transfer example. Just modify the constructor in this way:

/// Creates a new instance of this contract.
#[ink(constructor)]
pub fn new() -> Self {
    ink_env::debug_println!("constructor!");
    Self {}
}

Start the canvas-node this way:

$ canvas --tmp --dev -lerror,runtime::contracts=debug

If you deploy and interact with the contract the debug_println!'s in the #[ink(message)]'s will show up on the console, but not the one from the constructor.

Note that #820 needs to be merged to reproduce this.

@cmichi cmichi added the C-bug Something isn't working label Jun 17, 2021
@Robbepop
Copy link
Collaborator

Might it be possible that this is not an ink! related issue but resides in the contracts pallet instead? I cannot see a reason atm why constructors and messages would behave different in ink!. Do you?

@cmichi
Copy link
Collaborator Author

cmichi commented Jun 17, 2021

Nope, it was also my intuition that an investigation would probably lead to the contracts pallet. I haven't looked deeper though.

Does @athei maybe have an immediate hunch if this could be caused by the contracts pallet?

@athei
Copy link
Contributor

athei commented Jun 17, 2021

AFAIK no UI dry-runs the constructor as RPC before deploying. Remember: Debugging is not enabled during on-chain execution. Only during RPC calls.

@cmichi
Copy link
Collaborator Author

cmichi commented Jun 17, 2021

Ok, but in principle it's possible to do a dry-run of the constructor, right? Then I would create follow-ups for the UI's.

@athei
Copy link
Contributor

athei commented Jun 17, 2021

Yes. This functionality was added somewhat recently.

@cmichi
Copy link
Collaborator Author

cmichi commented Oct 24, 2022

Things left to do for this ticket:

  • Test if this bug still appears when instantiating a contract with cargo contract instantiate.
  • Test if it still happens with polkadot-js.
  • Test if it still happens with contracts-ui.

If it happens in none of those we can close this issue.

@SkymanOne
Copy link
Contributor

Closing as the bug no longer appears on ink! 4.1

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

No branches or pull requests

4 participants