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

Cannot delete account with large state (Aurora Engine) #4265

Closed
frankbraun opened this issue Apr 30, 2021 · 4 comments
Closed

Cannot delete account with large state (Aurora Engine) #4265

frankbraun opened this issue Apr 30, 2021 · 4 comments
Labels
A-EVM Area: Native EVM implementation and support C-discussion Category: Discussion, leading to research or enhancement

Comments

@frankbraun
Copy link
Contributor

When stress testing the Aurora Engine with the evm-bully on TestNet and a local node I ran into the problem that I cannot delete accounts anymore. For example on TestNet:

$ near delete evm.evm-bully.testnet evm-bully.testnet
Deleting account. Account id: evm.evm-bully.testnet, node: https://rpc.testnet.near.org, helper: https://helper.testnet.near.org, beneficiary: evm-bully.testnet
Receipt: 
	Failure [evm.evm-bully.testnet]: Error: {"index":0,"kind":{"index":0,"kind":{"DeleteAccountWithLargeState":{"account_id":"evm.evm-bully.testnet"}}}}
An error occured
Error: {"index":0,"kind":{"index":0,"kind":{"DeleteAccountWithLargeState":{"account_id":"evm.evm-bully.testnet"}}}}
    at Object.parseResultError (/home/frank/node_modules/near-cli/node_modules/near-api-js/lib/utils/rpc_errors.js:48:29)
    at Account.signAndSendTransaction (/home/frank/node_modules/near-cli/node_modules/near-api-js/lib/account.js:129:36)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async exports.deleteAccount (/home/frank/node_modules/near-cli/index.js:193:20)
    at async Object.handler (/home/frank/node_modules/near-cli/utils/exit-on-error.js:36:9)
ServerTransactionError: {"index":0,"kind":{"index":0,"kind":{"DeleteAccountWithLargeState":{"account_id":"evm.evm-bully.testnet"}}}}
    at Object.parseResultError (/home/frank/node_modules/near-cli/node_modules/near-api-js/lib/utils/rpc_errors.js:48:29)
    at Account.signAndSendTransaction (/home/frank/node_modules/near-cli/node_modules/near-api-js/lib/account.js:129:36)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at async exports.deleteAccount (/home/frank/node_modules/near-cli/index.js:193:20)
    at async Object.handler (/home/frank/node_modules/near-cli/utils/exit-on-error.js:36:9) {
  type: 'ActionError',
  context: undefined,
  index: 0,
  kind: {
    index: 0,
    kind: {
      DeleteAccountWithLargeState: { account_id: 'evm.evm-bully.testnet' }
    }
  },
  transaction_outcome: {
    proof: [
      {
        hash: '6SQc6pxBKaQjeiAhnf4ZX1o2oTxH9gwYLaj68LqqCiNW',
        direction: 'Right'
      }
    ],
    block_hash: '3kuqKDFuKaLDZtwdnts8g3tzgHHE7mAyXdXbfGZ5dwLN',
    id: 'D89HzFmbqDyUtz9E4KrsgE6t3WjYTqEerAdpPDf14hyZ',
    outcome: {
      logs: [],
      receipt_ids: [ 'Fx56Gz3kALVjbBQZpC69jyrbPygqiVMV1tqyXQKAQRon' ],
      gas_burnt: 255548500000,
      tokens_burnt: '25554850000000000000',
      executor_id: 'evm.evm-bully.testnet',
      status: {
        SuccessReceiptId: 'Fx56Gz3kALVjbBQZpC69jyrbPygqiVMV1tqyXQKAQRon'
      }
    }
  }
}

So the problem is:

{
  "ActionError": {
    "index": 0,
    "kind": {
      "DeleteAccountWithLargeState": {
        "account_id": "evm.evm-bully.testnet"
      }
    }
  }
}

I traced this in nearcore to these places in the code:

/// Delete account whose state is large is temporarily banned.
DeleteAccountWithLargeState { account_id: AccountId },

/// Max number of bytes an account can have in its state (excluding contract code)
/// before it is infeasible to delete.
pub const MAX_ACCOUNT_DELETION_STORAGE_USAGE: u64 = 10_000;

Why is the deletion of accounts with large states "temporarily disabled" and/or "infeasible"?

While this is probably not a problem for the production deployment of the Aurora Engine (I assume we never want to delete the state there) it makes testing a lot harder and leads to a lot of wasted storage on TestNet, if I always have to create a new account for a test run there.

@frankbraun frankbraun added C-discussion Category: Discussion, leading to research or enhancement A-EVM Area: Native EVM implementation and support labels Apr 30, 2021
@bowenwang1996
Copy link
Collaborator

@frankbraun see the PR description here #4116. This is an inherent limitation that we cannot circumvent at this point in time. If you want to delete some state, it is better to implement it in the contract itself.

@frankbraun
Copy link
Contributor Author

Thanks @bowenwang1996 for the pointer. I'll leave this issue open for further discussion until we have decided how to circumvent this for the Aurora Engine.

@frankbraun
Copy link
Contributor Author

OK, it's not a problem on MainNet for Aurora Engine. Locally it's a non-issue as well. Only on TestNet it means that we create accounts that we cannot delete anymore if we deploy an EVM contract for the evm-bully there.

One idea that was brought up was to delete the state from within the EVM, but according to @artob you can only iterate the contract storage keys via the RPC, not from within the contract. And that’s unlikely to change in the near term.

But since this is not a big issue for Aurora for now, I'm closing the issue.

@bowenwang1996
Copy link
Collaborator

but according to @artob you can only iterate the contract storage keys via the RPC, not from within the contract

There is no host functions to do that, but if you use collections from near-sdk you should be able to do that from within the contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-EVM Area: Native EVM implementation and support C-discussion Category: Discussion, leading to research or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants