-
Notifications
You must be signed in to change notification settings - Fork 669
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
[NEP-491] Non-refundable storage #9600
Conversation
The purpose of this reference implementation is to show the proposed protocol changes in practice. It should be sufficient to convince the reader that all technical challenges have been identified and that there is a solution. However, this is not a full implementation. - tests are not fixed - boilerplate code changes are left as todo!() - (rosetta) rpc node code does not compile - changes are not behind feature flags - some refactoring would make sense
introduces the error variant `NonRefundableBalanceToExistingAccount`
…reference_implementation
includes first integration test and TODOs for missing tests
@jbajic: I will close this. We can reopen if and when we decide to progress on this approach for the NEP. |
@akhi3030 I should have updated the PR, but I will be working on it, as was decided in the conversation that happened online. Posting the relevant comment here near/NEPs#491 (comment) |
c528fee
to
0568a23
Compare
3c42704
to
c16c135
Compare
@nagisa Could you take a look at this as a code owner? |
e29955d
to
69a2287
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't say I'm deeply familiar with any of the codebase areas touched by this PR, so this review is only a best effort outcome…
49f41bf
to
061a539
Compare
061a539
to
efa4c98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see any further problems with the implementation code. One non-trivial operational point is that the coverage report is not favourable to this PR – it would be ideal to make sure the uncovered lines get tests added for them. I don't expect a full coverage, but I see entire match branches not being covered, which ain't great.
We're also waiting on a resolution of that Coinbase question.
80d296f
to
f49adef
Compare
@nagisa The Coinbase question has been resolved: #9600 (comment) |
There is ongoing work on [global contracts](#12716) that addresses the problem near/NEPs#491 was originally designed to solve. NEP-491 code is quite messy and has been around for about a year. We no longer see external interest in this feature, but if the need arises in the future, we can always restore the code. Reverts most of (because some part is used by #12794): - #9600 - #10701 Also, #11005 can be closed.
Context
NEP: near/NEPs#491
NonrefundableStorageTransfer
name that was proposed in NEP-491: Non-refundable storage NEPs#491 (comment).Goal
We aim to enable the sponsorship of accounts with arbitrary storage (for example, with a contract that exceeds the zero balance account limit). Currently, there is a financial incentive to deplete such a sponsor by deleting the account and then cashing in.
Summary
This PR introduces a non-refundable balance, which is a type of balance that can only be transferred to an account at the time of its creation. It is burned upon account deletion. This change eliminates the possibility of cashing out sponsored accounts.
Changes
protocol_feature_nonrefundable_transfer_nep491
and change nightly protocol version.AccountVersion::V2
as the new default version.Account
with anonrefundable
field that will only be used by accounts V2 or higher.NonrefundableStorageTransfer
action that behaves similar toTransfer
but it modifies thenonrefundable
instead of theamount
account field. Bothnonrefundable
andamount
are used to calculate the storage allowance.NonRefundableBalanceToExistingAccount
that it is raised on an attempt to make a non-refundable transfer outside of a transaction that creates an account.u128::MAX
) as a first field during Borsh serialization in case of V2 accounts, to distinguish between V1 and V2 accounts. From V2, theversion
field is Borsh serialized and subsequent versions can use that field.version
field is missing. This is required when we parse the mainnet genesis file, so that the mainnet genesis hash does not change.other_burnt_amount
is updated when deleting an account that had a non-refundable balance. Update related tests.Original description of a draft implementation by @jakmeier