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

contracts: Lazy contract removal #6594

@athei

Description

@athei

With O(1) child trie removal not happening anytime soon ( see discussion in #5280 ) we need to cope with the fact that contract removal takes linear time depending on how much storage a contract accumulated. This can be a problem because the removal can take longer than a single block and makes the chain subject to DoS because no-one is there to pay for the removal of an evicted contract.

For that reason we should move to a model where contracts are removed lazily. When the removal of a contract is decided through one of the various entry points (discussed later), we immediately remove the contract itself (ContractInfo) and schedule the actual storage removal to happen asynchronously possibly over multiple blocks. This operation is bounded and not DoSable because every storage item scheduled for removal is subject to rent payment making it expensive to accumulate huge amounts of storage.

The following entry points can trigger the removal of a contract and must transfer to an asynchronous model:

  • ext_terminate: Contract triggers the removal of an contract
  • claim_surchargedispatchable: Some external caller triggers the eviction of a contract that did not pay rent

Depends on: #7671

Metadata

Metadata

Assignees

No one assigned

    Labels

    I2-securityThe client fails to follow expected, security-sensitive, behaviour.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions