Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

pallet-contracts: Rent projection RPC #4754

Merged
merged 17 commits into from
Jan 31, 2020
Merged

Conversation

pepyakin
Copy link
Contributor

This change adds a new RPC endpoint which allows a user to query the current state of a given contract.

State rent is enacted lazy. That is, if a contract runs out of funds it becomes inaccessible, but it is not removed from the chain storage right away. Instead, it will be removed on the first access: a call or e.g. or poking with claim_surcharge.

This however poses a problem from an external users of the chain. If an external user wants to know if a given contract is usable or not, the user will have to do the calculations by themselves.

While it might be possible to work around this issue by piggybacking on some other call, we introduce a new RPC call here: contracts_rentProjection. This call doesn't can tell the status of the given contract, it will also return the projected block number of eviction. Such functionality might be useful in creation of crawlers that would call claim_surcharge for the nearly expiring contracts.

@pepyakin pepyakin added the A0-please_review Pull request needs code review. label Jan 28, 2020
@pepyakin pepyakin requested a review from gui1117 January 28, 2020 17:47
@pepyakin pepyakin marked this pull request as ready for review January 29, 2020 12:34
@pepyakin pepyakin requested a review from tomusdrw as a code owner January 29, 2020 12:34
Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

lgtm! The code is really nice and readable, however I didn't carefully check if the logic has not been altered, but it makes sense to me in it's current form.

@pepyakin pepyakin force-pushed the ser-rent-projection-rpc branch from 294c7c4 to 2997990 Compare January 29, 2020 14:07
Copy link
Contributor

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

lgtm!

@pepyakin pepyakin merged commit 3d076d8 into master Jan 31, 2020
@pepyakin pepyakin deleted the ser-rent-projection-rpc branch January 31, 2020 14:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants