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

fix: improve contract experience #330

Merged
merged 7 commits into from
Nov 8, 2024
Merged

Conversation

AlexD10S
Copy link
Collaborator

@AlexD10S AlexD10S commented Oct 31, 2024

For instantiating an already uploaded contract, code_hash is currently not displayed, as retrieving it would require parsing events or querying the value on-chain.

It adds -lerror,runtime::contracts=debug when running substrate-contracts-node to allow debugging messages (the contract has to be build without --release flag).

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 27.27273% with 24 lines in your changes missing coverage. Please review.

Project coverage is 70.27%. Comparing base (2af82eb) to head (0ff6eb3).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/pop-cli/src/commands/up/contract.rs 0.00% 22 Missing ⚠️
crates/pop-contracts/src/call.rs 66.66% 0 Missing and 1 partial ⚠️
crates/pop-contracts/src/up.rs 85.71% 0 Missing and 1 partial ⚠️
@@            Coverage Diff             @@
##             main     #330      +/-   ##
==========================================
- Coverage   70.33%   70.27%   -0.06%     
==========================================
  Files          53       54       +1     
  Lines        9098     9152      +54     
  Branches     9098     9152      +54     
==========================================
+ Hits         6399     6432      +33     
- Misses       1718     1736      +18     
- Partials      981      984       +3     
Files with missing lines Coverage Δ
crates/pop-contracts/src/node/mod.rs 64.70% <100.00%> (+0.26%) ⬆️
crates/pop-contracts/src/call.rs 78.62% <66.66%> (ø)
crates/pop-contracts/src/up.rs 77.89% <85.71%> (+0.24%) ⬆️
crates/pop-cli/src/commands/up/contract.rs 23.88% <0.00%> (-1.88%) ⬇️

... and 7 files with indirect coverage changes

@AlexD10S AlexD10S marked this pull request as ready for review October 31, 2024 16:42
@AlexD10S AlexD10S requested a review from brunopgalvao November 1, 2024 12:52
Copy link
Contributor

@evilrobot-01 evilrobot-01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, various minor improvements and clippy warnings to address and then I'm good to approve.

crates/pop-contracts/src/up.rs Show resolved Hide resolved
crates/pop-contracts/src/up.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/up/contract.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/up/contract.rs Outdated Show resolved Hide resolved
crates/pop-cli/src/commands/up/contract.rs Outdated Show resolved Hide resolved
@AlexD10S AlexD10S requested a review from evilrobot-01 November 5, 2024 22:15
@brunopgalvao
Copy link
Contributor

Really happy with this PR.

One thing to note, if I re-deploy the same contract, the code hash is not shown:

pop up contract --args true

Code hash is shown for the above command is shown. But then if I re-deploy:

pop up contract --args true --salt 0x3c

Code hash not shown:

┌   Pop CLI : Deploy a smart contract
│
◇  Gas limit estimate: Weight { ref_time: 146361110, proof_size: 16689 }
│
◇  Contract deployed and instantiated:
● The Contract Address is "5HGyVrVkCrKVRBrjXcVFrFzei93YkFBmkA4WHvqw5jk2s8jq"

│
└  🚀 Deployment complete

I guess this is expected as you mentioned here:

For instantiating an already uploaded contract, code_hash is currently not displayed, as retrieving it would require parsing events or querying the value on-chain.

◇  Local node started successfully:
│  portal: https://polkadot.js.org/apps/?rpc=ws://localhost:9944/#/explorer
│  logs: tail -f /var/folders/vl/txnq6gdj22s9rn296z0md27w0000gn/T/.tmpOenKTn

For some reason the logs are empty. Is this the correct log path?

@AlexD10S
Copy link
Collaborator Author

AlexD10S commented Nov 6, 2024

For some reason the logs are empty. Is this the correct log path?

Exactly. If the contract has already been uploaded, retrieving the code_hash is a bit more complex. I left it out for now, but we can handle it later by parsing events or querying on-chain.

As for the logs, they are working.
Keep in mind that the contract must be built without the --release flag to display debug logs (see Ink! Debugging Guide). Also, note that the proposed -lerror,runtime::contracts=debug flag only shows error and debug output. If we need more verbosity, I can switch it to -linfo,runtime::contracts=debug to include all info logs.

Copy link
Contributor

@al3mart al3mart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the feedback has been included.
I don't have much more to point out rather than a small nit. But definitely not blocking the merge.

image

The emojis are not colored like the rest of the prompt is :P
Aside from that, I would assume that a user who can instantiate some code, has access to the code and could obtain the hash easily. Though, I agree that being consistent and showing it every time would be the best experience.

crates/pop-contracts/src/up.rs Outdated Show resolved Hide resolved
@brunopgalvao
Copy link
Contributor

Also, note that the proposed -lerror,runtime::contracts=debug flag only shows error and debug output. If we need more verbosity, I can switch it to -linfo,runtime::contracts=debug to include all info logs.

I think more verbosity would nice.

@AlexD10S
Copy link
Collaborator Author

AlexD10S commented Nov 7, 2024

Also, note that the proposed -lerror,runtime::contracts=debug flag only shows error and debug output. If we need more verbosity, I can switch it to -linfo,runtime::contracts=debug to include all info logs.

I think more verbosity would nice.

Agree. Makes sense to have info

@AlexD10S AlexD10S requested a review from brunopgalvao November 7, 2024 14:30
@AlexD10S AlexD10S merged commit bc3fb5d into main Nov 8, 2024
18 of 20 checks passed
@AlexD10S AlexD10S deleted the fix/improve-contract-experience branch November 8, 2024 08:03
@brunopgalvao
Copy link
Contributor

closes #319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants