methodsfinancecryptocurrencynearprotocol

What warrants an account deletion on the NEAR Protocol


Runtime Specification listed here: https://nomicon.io/RuntimeSpec/Scenarios/FinancialTransaction#transaction-to-receipt states within the verify_and_charge_transaction method, one of the operations is supposedly to:

Checks whether after all these operations account has enough balance to passively pay for the rent for the next several blocks (an economical constant defined by Near Protocol). Otherwise account will be open for an immediate deletion...

Is this referring to an attempt to overspend from an account? Just curious on what warrants an account deletion in this case?


Solution

  • Yes, this is checking that the account does not overspend. The account balance afterwards has to be above the threshold required for storage staking.

    The check gets called here, at which point the tokens have already been subtracted locally: https://github.com/near/nearcore/blob/aad3bf2adc1b07df9dd6321d8e1faefbe50afe9c/runtime/runtime/src/verifier.rs#L160-L172

    And the source code for the check itself: https://github.com/near/nearcore/blob/aad3bf2adc1b07df9dd6321d8e1faefbe50afe9c/core/primitives/src/runtime/mod.rs#L14-L42

    Regarding account deletion, this is a just a hypothetical. If somehow there was not enough balance left to store the account's state, it would have to be deleted immediately. Deletion here means removing all its state from the chain's state. That includes all access keys, hence you would no longer be able to use that account. (You or someone else could claim it again, though.)

    But to be very clear, there is no circumstance where this actually happens. Overspending is always prevented and can never lead to an automatic deletion.