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 total contract deposit #1347

Merged
merged 22 commits into from
Nov 15, 2023
Merged

Add total contract deposit #1347

merged 22 commits into from
Nov 15, 2023

Conversation

smiasojed
Copy link
Collaborator

@smiasojed smiasojed commented Sep 27, 2023

Summary

Closes #1035

  • [n] y/n | Does it introduce breaking changes?
  • [y] y/n | Is it dependent on the specific version of ink or pallet-contracts?
    Add total contract deposit

Description

Added functionality to contract info command, which calculates and displays storage total deposit:

                TrieId 6ec258b9d34918154e689c37920ee3ff6d1afb0bb69938e67853092ce0fced18
             Code Hash 0x2de75ab18bfb8e24c968e8ff0a76d40e49ace69eb9e95d814c1cc4232be8c8eb
         Storage Items 1
  Storage Items Deposit 100000000000
 Storage Total Deposit 200770000000

Old Storage Deposit (which displayed contract_info.storage_item_deposit) has been renamed to the Storage Items Deposit

This change depends on pallet-contracts, it should work with the versions >=8

The metadata has been extended by the Pallet Balances, and it now includes the pallets Contracts and Balances

Checklist before requesting a review

  • My code follows the style guidelines of this project
  • I have added an entry to CHANGELOG.md
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

// From contracts pallet version 10 deposit calculation has changed.
if contract_pallet_version >= 10 {
let existential_deposit_address =
api::constants().balances().existential_deposit();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This call introduces a dependency on the Balances pallet. The drawback is that we now have an additional dependency in the metadata, which has caused its size to grow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see no problem with that. We are not particularly concerned with the binary sized of cargo-contract


let version = client
.rpc()
.storage(key.as_slice(), None)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Raw access to the storage

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't there an RPC method to fetch a pallet version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have not found it

.saturating_add(storage_byte_deposit);

// From contracts pallet version 10 deposit calculation has changed.
if contract_pallet_version >= 10 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to display an error to the user otherwise

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the pallet-contracts version >=8, it works. The issue may arise for pallets-contract versions <8, as it will result in an error during the scale decoding of ContractInfo struct, which has changed at this time. It's important to note that this limitation is not introduced by this commit.

@smiasojed smiasojed marked this pull request as ready for review November 7, 2023 14:28
@smiasojed smiasojed merged commit f0660d0 into master Nov 15, 2023
@smiasojed smiasojed deleted the sm/storage-dep branch November 15, 2023 16:05
@smiasojed smiasojed mentioned this pull request Nov 30, 2023
@smiasojed smiasojed mentioned this pull request Mar 4, 2024
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.

Display storage deposit in cargo contract info different for pallet-contracts v10
3 participants