-
Notifications
You must be signed in to change notification settings - Fork 628
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
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.
@staffik Thank you for cleaning a lot of this up and making it all ready! It looks pretty good already.
I left several comments regarding changes I think you should consider. I think most things, if not all, could also be done in follow-up PRs. As long as everything is addressed (or dismissed) before the feature gets stabilized, it should be fine IMO.
But that's obviously your choice how you want to split the PRs. And a code owner will have to decide if it's really ready for merging to master.
@@ -352,6 +352,36 @@ impl From<NearActions> for Vec<crate::models::Operation> { | |||
); | |||
} | |||
|
|||
#[cfg(feature = "protocol_feature_nonrefundable_transfer_nep491")] | |||
// Note(jakmeier): Both refundable and non-refundable transfers are considered as available balance. |
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 don't remember checking that this specific behaviour is what we want. I think I've just put it in to have something in the prototype. But considering how the NEP discussion went, I wonder if it wouldn't make more sense to consider the nonrefundable balance burnt instead of showing it as balance on the receiving account?
Can we check with relevant parties how the nonrefundable storage balance should show up in the rosetta RPC?
Ideally, someone who feels responsible for the Rosetta RPC should review all Rosetta RPC changes.
I hope @firatNEAR or @walnut-the-cat can help to find the right person?
The main question to resolve:
When an account has nonrefundable storage balance, should it show up as balance in the Rosetta RPC adapter?
(oh and once this is resolved, I don't think we need to attribute the note to specific person, git blame should work better to find he source of a comment as it leads to the actual PR discussion)
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.
Added a TODO comment to consider this before stabilizing.
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 think this is a question that we should ask Coinbase since they own the spec. They usually are okay with making changes as long as they confirm from their side. @gmilescu could you help me with this, I am a bit out of loop with Coinbase.
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.
This change should be fine the way Rosetta handles this scenario. Thanks for checking.
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.
@nasmithan Could you take a look at this change?
In discussion we decided to burn the nonrefundable balance instead of showing it as balance on the receiving account.
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.
Yup that should be fine
runtime/runtime/src/config.rs
Outdated
#[cfg(feature = "protocol_feature_nonrefundable_transfer_nep491")] | ||
NonrefundableStorageTransfer(_) => { | ||
// Account for implicit account creation | ||
transfer_send_fee( |
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 just noticed that we are now reusing the same gas cost parameter for two actions.
This seems inconsistent.
Something to consider before stabilizing.
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.
Added a TODO comment to consider this before stabilizing.
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.
@jakmeier Do you mean estimating cost for NonrefundableStorageTransfer
action (which seems to be the same as for Transfer
action IMO) or just introducing sth like ActionCosts::nonrefundable_storage_transfer
with the same values as ActionCosts::transfer
?
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 was thinking about the second option. Using the same numerical value makes sense to me.
Creating a new parameter is mostly for consistency, which makes it easier to understand gas profiles and do all kinds of gas analysis work.
@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) |
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