| mbip | 3 |
|---|---|
| title | Rent mechanism [rejected] |
| author | Alan Sapède (@crystalin) |
| status | Rejected |
| category | Core |
| created | 2023-05-11 |
A renting mechanism using a deposit for smart contracts to deal with storage congestion.
Introduce a deposit assigned to a smart contract when being deployed. The deposit is consumed every time the smart contract executes, proportionally to the elapsed time since it was executed.
Moonbeam chain state needs to be sustainable for collators and archive nodes. With its current fee mechanism, it doesn't account sufficiently for new storage data being added.
In order to avoid impacting the gas price, a distinct mechanism is proposed.
Users CAN send tokens to any address "rent deposit".
The destination address MUST have sufficient "rent deposit" for a Smart Contract to be deployed. The sufficient amount corresponds to 1 year of rent based on the size of the contract plus initial storage data.
Executing a transaction MUST burn part of the "rent deposit" based on the elapsed number of blocks since the last time it was executed.
Executing a smart contract with not enough "rent deposit" MUST get reverted.
Formula to compute the "rent deposit" amount when deploying a smart contract:
YEAR = 5 * 60 * 24 * 365
BURN_RATIO = 0.0001 GLMR / Bytes / YEAR
token_burnt = (bytes of AccountCodes storage key (68) +
bytes of stored contract code (variable) +
(bytes of SystemAccount storage key (68) +
bytes of stored contract code (32))
* number of storage item accessed)
* (current block number - last time used block number) * BURN_RATIO
A deposit ratio of 0.00001 GLMR / Byte / Year would lead to:
1GB => 1_000_000_000 * 0.0001 GLMR => 100_000 GLMR / Year
Executing a Smart contract within the same block would trigger the "rent deposit" to be burnt only at the first execution.
The "rent deposit" can be refilled by anyone include the chain treasury through Governance.
Deploying the complex contract (24_400 Bytes and 5 storage data) would require a deposit of:
bytes = 24_400 + 5 * (68 + 32)
= 24_900
deposit_required = bytes * 0.0001 GLMR
= 2.49 GLMR
burn_rate = bytes * 0.0001 GLMR * elapsed_blocks / YEAR
= 2.49 GLMR / year
= 947 Gwei / block
Deploying small contract with many storage data (1_000 bytes + 100 storage data) would require a deposit of:
bytes = 1_000 + 100 * (68 + 32)
= 11_000
deposit_required = bytes * 0.0001 GLMR
= 1.1 GLMR
burn_rate = bytes * 0.0001 GLMR * elapsed_blocks / YEAR
= 1.1 GLMR / year
= 418.5 Gwei / block